Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
RiscOS
S
Sources
Toolbox
Gadgets
Commits
4e72d458
Commit
4e72d458
authored
27 years ago
by
Piers Wombwell
Browse files
Options
Download
Email Patches
Plain Diff
Added scrollbar dragging
parent
bbcef0d6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
77 additions
and
11 deletions
+77
-11
c/ScrollList
c/ScrollList
+24
-11
c/Scrollbar
c/Scrollbar
+51
-0
c/TextGadget
c/TextGadget
+2
-0
No files found.
c/ScrollList
View file @
4e72d458
...
...
@@ -617,7 +617,7 @@ static _kernel_oserror *_add_item(PrivateScrollList *sdata,
}
else
new_spr_name
=
NULL
;
for
(
i
=
sdata
->
no_entries
;
i
>
=
index
;
i
--
)
for
(
i
=
sdata
->
no_entries
;
i
>
index
;
i
--
)
{
sdata
->
entries
[
i
].
text
=
sdata
->
entries
[
i
-
1
].
text
;
sdata
->
entries
[
i
].
sprite_area
=
sdata
->
entries
[
i
-
1
].
sprite_area
;
...
...
@@ -802,6 +802,25 @@ static _kernel_oserror *_get_selected(const PrivateScrollList *sdata,
return
NULL
;
}
static
_kernel_oserror
*
_make_visible
(
const
PrivateScrollList
*
sdata
,
int
visible
)
{
unsigned
int
item_height
;
WimpGetWindowStateBlock
block
;
_get_item_size
(
sdata
,
NULL
,
&
item_height
,
NULL
);
window_get_wimp_handle
(
0
,
sdata
->
object_id
,
&
block
.
window_handle
);
wimp_get_window_state
(
&
block
);
block
.
yscroll
=
-
visible
*
item_height
;
wimp_open_window
((
WimpOpenWindowBlock
*
)
&
block
);
return
NULL
;
}
static
_kernel_oserror
*
_get_item_text
(
const
PrivateScrollList
*
sdata
,
char
*
buffer
,
int
buffer_size
,
int
index
,
int
*
nbytes
)
{
...
...
@@ -885,12 +904,7 @@ _kernel_oserror *scrolllist_method(PrivateScrollList *sdata,
break
;
case
ScrollList_MakeVisible
:
if
(
regs
->
r
[
4
]
<
0
)
sdata
->
visible
=
0
;
else
sdata
->
visible
=
regs
->
r
[
4
];
scrolllist_update
(
sdata
,
sdata
->
box
.
xmin
,
sdata
->
box
.
ymin
,
sdata
->
box
.
xmax
-
SCROLLBAR_SIZE
,
sdata
->
box
.
ymax
);
_make_visible
(
sdata
,
regs
->
r
[
4
]
<
0
?
0
:
regs
->
r
[
4
]);
break
;
case
ScrollList_SetColour
:
...
...
@@ -1037,7 +1051,7 @@ _kernel_oserror *_scrolllist_redraw(const PrivateScrollList *sdata,
unsigned
int
sprite_info
=
sdata
->
entries
[
i
].
flags
&
(
FLAGS_SPRITE_AREA
|
FLAGS_SPRITE_NAME
);
if
(
sprite_info
!=
3
)
if
(
sprite_info
!=
(
FLAGS_SPRITE_AREA
|
FLAGS_SPRITE_NAME
)
)
{
// We have a sprite to plot
WimpPlotIconBlock
icon
;
...
...
@@ -1055,7 +1069,7 @@ _kernel_oserror *_scrolllist_redraw(const PrivateScrollList *sdata,
else
icon
.
data
.
is
.
sprite_area
=
(
int
*
)
sdata
->
entries
[
i
].
sprite_area
;
if
(
sprite_info
==
3
)
if
(
sprite_info
==
2
)
icon
.
data
.
is
.
sprite_name_length
=
0
;
else
icon
.
data
.
is
.
sprite_name_length
=
strlen
(
...
...
@@ -1241,8 +1255,7 @@ _kernel_oserror *scrolllist_filter(_kernel_swi_regs *regs)
if
(
window_handle
==
wimp_mouse_event
->
window_handle
)
{
scrolllist_mclick
(
scrolllist_list
[
i
],
wimp_mouse_event
);
// Claim event, since we don't want the application to know
// what's going on?
// Claim event
regs
->
r
[
0
]
=
-
1
;
}
}
...
...
This diff is collapsed.
Click to expand it.
c/Scrollbar
View file @
4e72d458
...
...
@@ -22,6 +22,7 @@
* piers 20/11/96 Got around a bug in the toolbox where if a gadget isn't
* made up of icons, it creates new ones. Passing a NULL
* list fails, but passing an empty list containing -1 works.
* piers 19/01/98 Added dragging support
*/
#include <stdio.h>
...
...
@@ -461,6 +462,52 @@ sdata = sdata;
return
NULL
;
}
static
_kernel_oserror
*
_do_drag_scroll
(
WimpOpenWindowRequestEvent
*
event
)
{
int
old_position
,
i
;
for
(
i
=
0
;
scrollbar_list
[
i
]
!=
NULL
;
i
++
)
if
(
scrollbar_list
[
i
]
->
scrollbar_window
==
event
->
window_handle
)
{
PrivateScrollbar
*
sdata
=
scrollbar_list
[
i
];
ScrollbarPositionChangedEvent
changed
;
old_position
=
sdata
->
value
;
if
(
sdata
->
state
&
Scrollbar_Horizontal
)
{
sdata
->
value
=
(
event
->
xscroll
*
(
sdata
->
max
-
sdata
->
min
)
*
sdata
->
visible
/
((
sdata
->
box
.
xmax
-
sdata
->
box
.
xmin
)
*
(
sdata
->
max
-
sdata
->
min
+
sdata
->
visible
)))
+
sdata
->
min
;
}
else
{
sdata
->
value
=
(
-
event
->
yscroll
*
(
sdata
->
max
-
sdata
->
min
)
*
sdata
->
visible
/
((
sdata
->
box
.
ymax
-
sdata
->
box
.
ymin
)
*
(
sdata
->
max
-
sdata
->
min
+
sdata
->
visible
)))
+
sdata
->
min
;
}
if
(
old_position
!=
sdata
->
value
)
{
changed
.
hdr
.
size
=
sizeof
(
ScrollbarPositionChangedEvent
);
changed
.
hdr
.
event_code
=
sdata
->
event
;
changed
.
hdr
.
flags
=
0
;
changed
.
direction
=
0
;
changed
.
new_position
=
sdata
->
value
;
toolbox_raise_toolbox_event
(
0
,
sdata
->
object_id
,
sdata
->
component_id
,
(
ToolboxEvent
*
)
&
changed
);
scrollbar_show
(
sdata
);
}
}
return
NULL
;
}
static
_kernel_oserror
*
_do_scroll
(
WimpScrollRequestEvent
*
event
)
{
PrivateScrollbar
*
sdata
;
...
...
@@ -545,6 +592,10 @@ _kernel_oserror *scrollbar_filter(_kernel_swi_regs *regs)
{
_do_scroll
((
WimpScrollRequestEvent
*
)
regs
->
r
[
1
]);
}
else
if
(
event_code
==
Wimp_EOpenWindow
)
{
_do_drag_scroll
((
WimpOpenWindowRequestEvent
*
)
regs
->
r
[
1
]);
}
// All checks after here should assume event is a toolbox event
if
(
event_code
!=
Wimp_EToolboxEvent
)
...
...
This diff is collapsed.
Click to expand it.
c/TextGadget
View file @
4e72d458
...
...
@@ -19,6 +19,7 @@
* piers 18/06/96 Created
* piers 26/09/96 Restarted
* piers 06/01/96 Added TextArea plot method for ResEd
* piers 19/01/98 Added Wimp_EOpenWindow to interested-events for dragging
*/
#include <stdio.h>
...
...
@@ -64,6 +65,7 @@ int filter_toolbox_events[] =
int
filter_wimp_events
[]
=
{
Wimp_ENull
,
0
,
Wimp_EOpenWindow
,
0
,
Wimp_ERedrawWindow
,
0
,
Wimp_EMouseClick
,
0
,
Wimp_EUserDrag
,
0
,
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment