29#include <oslib/dragasprite.h>
31#include <oslib/osspriteop.h>
32#include <oslib/wimp.h>
33#include <oslib/wimpspriteop.h>
43#define BUTTONBAR_SPRITE_NAME_LENGTH 12
44#define BUTTONBAR_VALIDATION_LENGTH 40
141 NSLOG(netsurf, INFO,
"No memory for malloc()");
174 for (def = 0; buttons[def].
icon != NULL; def++) {
176 if (new_icon == NULL) {
184 icon->next = new_icon;
185 icon->bar_next = new_icon;
189 icon->bar_next = NULL;
191 strncpy(
icon->sprite, buttons[def].
icon,
195 "R5;S%s,p%s",
icon->sprite,
icon->sprite);
198 icon->shaded =
false;
199 icon->separator =
false;
204 icon->help_suffix = buttons[def].
help;
212 icon->separator =
true;
221 struct button_bar *source,
void (* refresh)(
void *),
224 if (target == NULL || source == NULL ||
247 wimp_w window,
bool edit)
278 while (button != NULL) {
287 button = button->
next;
317 button = button->
next) {
326 for (i = 0; order[i] !=
'\0'; i++) {
327 if (order[i] !=
'|') {
372 while (button != NULL) {
438 int x0,
int y0,
int x1,
int y1)
485 wimp_icon_create
icon;
495 while (button != NULL) {
509 icon.icon.extent.x0 = 0;
510 icon.icon.extent.y0 = 0;
511 icon.icon.extent.x1 = 0;
512 icon.icon.extent.y1 = 0;
513 icon.icon.flags = wimp_ICON_TEXT | wimp_ICON_SPRITE |
514 wimp_ICON_INDIRECTED |
518 << wimp_ICON_BG_COLOUR_SHIFT);
519 icon.icon.data.indirected_text.size = 1;
527 icon.icon.flags |= wimp_ICON_SHADED;
530 icon.icon.flags |= (wimp_BUTTON_CLICK_DRAG <<
531 wimp_ICON_BUTTON_TYPE_SHIFT);
533 icon.icon.flags |= (wimp_BUTTON_CLICK <<
534 wimp_ICON_BUTTON_TYPE_SHIFT);
537 icon.icon.data.indirected_text.validation =
540 error = xwimp_create_icon(&
icon, &button->
icon);
543 "xwimp_create_icon: 0x%x: %s",
551 && button->
icon != -1) {
556 "xwimp_delete_icon: 0x%x: %s",
566 button = button->
next;
593 while (button != NULL) {
594 if(button->
icon != -1) {
609 "xwimp_resize_icon: 0x%x: %s",
661 if (button->
icon != -1 &&
683 (redraw->clip.x0 - (redraw->box.x0 - redraw->xscroll))
685 (redraw->clip.y0 - (redraw->box.y1 - redraw->yscroll))
687 (redraw->clip.x1 - (redraw->box.x0 - redraw->xscroll))
689 (redraw->clip.y1 - (redraw->box.y1 - redraw->yscroll))
694 icon.flags = wimp_ICON_SPRITE | wimp_ICON_INDIRECTED |
695 wimp_ICON_HCENTRED | wimp_ICON_VCENTRED;
697 icon.flags |= wimp_ICON_BORDER | wimp_COLOUR_DARK_GREY <<
698 wimp_ICON_FG_COLOUR_SHIFT;
700 icon.flags |= wimp_ICON_FILLED | wimp_COLOUR_LIGHT_GREY <<
701 wimp_ICON_BG_COLOUR_SHIFT;
704 icon.data.indirected_sprite.size = 12;
715 xwimp_plot_icon(&
icon);
724 wimp_pointer *pointer, wimp_window_state *state,
736 pos.
x = pointer->pos.x - state->visible.x0 + state->xscroll;
737 pos.y = pointer->pos.y - state->visible.y1 + state->yscroll;
761 box.x0 = pointer->pos.
x -
774 error = xdragasprite_start(dragasprite_HPOS_CENTRE |
775 dragasprite_VPOS_CENTRE |
776 dragasprite_BOUND_SPRITE |
777 dragasprite_BOUND_TO_WINDOW |
778 dragasprite_DROP_SHADOW,
783 "xdragasprite_start: 0x%x: %s",
795 (pointer->buttons == wimp_CLICK_SELECT ||
796 pointer->buttons == wimp_CLICK_ADJUST)) {
803 if (button != NULL) {
804 if (action != NULL) {
805 switch (pointer->buttons) {
806 case wimp_CLICK_SELECT:
809 case wimp_CLICK_ADJUST:
827 os_coord *mouse, wimp_window_state *state,
828 wimp_mouse_state buttons,
const char **suffix)
838 pos.x = mouse->x - state->visible.x0 + state->xscroll;
839 pos.y = mouse->y - state->visible.y1 + state->yscroll;
869 struct button_bar *source = NULL, *target = NULL;
872 wimp_window_state state;
873 wimp_pointer pointer;
884 error = xwimp_get_pointer_info(&pointer);
886 NSLOG(netsurf, INFO,
"xwimp_get_pointer_info: 0x%x: %s",
887 error->errnum, error->errmess);
895 error = xwimp_get_window_state(&state);
897 NSLOG(netsurf, INFO,
"xwimp_get_window_state: 0x%x: %s",
898 error->errnum, error->errmess);
903 pos.x = pointer.pos.x - state.visible.x0 + state.xscroll;
904 pos.y = pointer.pos.y - state.visible.y1 + state.yscroll;
911 if (pos.x >= target->extent.x0 && pos.x <= target->extent.x1 &&
912 pos.y >= target->extent.y0 &&
913 pos.y <= target->extent.y1)
918 if (pos.x >= target->extent.x0 && pos.x <= target->extent.x1 &&
919 pos.y >= target->extent.y0 &&
920 pos.y <= target->extent.y1)
928 assert(button != NULL);
932 if (drag_end == target) {
943 if (
drag_start == target && drag_end == target && button == drop) {
953 }
else if (target->bar == button) {
956 for (previous = target->bar; previous != NULL &&
959 assert(previous != NULL);
985 target->bar = button;
986 }
else if (target->bar != drop) {
987 for (previous = target->bar; previous != NULL &&
990 assert(previous != NULL);
1013 xwimp_force_redraw(target->window,
1014 target->extent.x0, target->extent.y0,
1015 target->extent.x1, target->extent.y1);
1037 if (source == NULL || target == NULL)
1042 for (sb = source->
bar; sb != NULL; sb = sb->
bar_next)
1049 for (tb = target->
bar; tb != NULL; tb = tb->
bar_next) {
1058 for (sb = source->
bar; sb != NULL; sb = sb->
bar_next)
1084 config = malloc(size);
1085 if (config == NULL) {
1086 NSLOG(netsurf, INFO,
"No memory for malloc()");
1093 config[i++] = button->
opt_key;
1122 while (button != NULL && button->
icon !=
icon)
1123 button = button->
next;
1148 button = button->
next;
1172 while (button != NULL &&
1175 button = button->
next;
1204 while (button != NULL) {
1210 x1 = x0 + button->
x_size;
1211 y1 = y0 + button->
y_size;
1213 if (pos.x > x0 && pos.y > y0 && pos.x < x1 && pos.y < y1) {
1218 *right = (pos.x > x0 + button->
x_size/2) ?
1228 if (pos.x > x0 && pos.y > y0 && pos.x < x1 && pos.y < y1 &&
void ro_mouse_drag_start(void(*drag_end)(wimp_dragged *dragged, void *data), void(*drag_track)(wimp_pointer *pointer, void *data), void(*drag_cancel)(void *data), void *data)
Start a drag, providing a function to be called when the Wimp_DragEnd event is received and optionall...
Mouse dragging and tracking support interface for RISC OS.
Window themes(interface).
@ THEME_ELEMENT_BACKGROUND
theme_style
Theme styles, collecting groups of attributes for different locations.
#define NSLOG(catname, level, logmsg, args...)
nserror ro_warn_user(const char *warning, const char *detail)
Display a warning for a serious problem (eg memory exhaustion).
osspriteop_area * ro_gui_theme_get_sprites(struct theme_descriptor *descriptor)
Returns a sprite area for use with the given theme.
int ro_gui_theme_get_style_element(struct theme_descriptor *descriptor, theme_style style, theme_element element)
Returns an interger element from the specified theme, or the current theme if the descriptor is NULL.
Interface to utility string handling.
int x
Coordinate of left padding edge relative to parent box, or relative to ancestor that contains this bo...
int y
Coordinate of top padding edge, relative as for x.
bool ro_gui_wimp_get_sprite_dimensions(osspriteop_area *area, char *sprite, int *width, int *height)
Get the dimensions of a sprite.
void ro_gui_set_icon_shaded_state(wimp_w w, wimp_i i, bool state)
Set the shaded state of an icon.
General RISC OS WIMP/OS library functions (interface).