#define DG_BUFFERED 0
#define DG_DIRECT 1
-#define GADGET_DEACTIVATED(g) ((g)->x < 0 || (g)->y < 0)
-
#define OPTION_TEXT_SELECTABLE(g, t) \
(t[0] != g->selectbox.char_unselectable && \
t[0] != '\0' && \
boolean check_horizontal = (IS_WHEEL_BUTTON_HORIZONTAL(button) ||
GetKeyModState() & KMOD_Shift);
+ /* check for the first active scrollbar directly under the mouse pointer */
+ for (gi = gadget_list_first_entry; gi != NULL; gi = gi->next)
+ {
+ if (gi->mapped && gi->active &&
+ (gi->type & GD_TYPE_SCROLLBAR) &&
+ mx >= gi->x && mx < gi->x + gi->width &&
+ my >= gi->y && my < gi->y + gi->height)
+ return gi;
+ }
+
/* check for the first active scrollbar with matching mouse wheel area */
for (gi = gadget_list_first_entry; gi != NULL; gi = gi->next)
{
int state = (pressed ? GD_BUTTON_PRESSED : GD_BUTTON_UNPRESSED);
boolean redraw_selectbox = FALSE;
- if (gi == NULL)
+ if (gi == NULL || gi->deactivated)
return;
gd = (!gi->active ? &gi->alt_design[state] :
case GD_TYPE_NORMAL_BUTTON:
case GD_TYPE_CHECK_BUTTON:
case GD_TYPE_RADIO_BUTTON:
+
BlitBitmapOnBackground(gd->bitmap, drawto,
gd->x, gd->y, gi->width, gi->height,
gi->x, gi->y);
+
if (gi->deco.design.bitmap)
- BlitBitmap(gi->deco.design.bitmap, drawto,
- gi->deco.design.x, gi->deco.design.y,
- gi->deco.width, gi->deco.height,
- gi->x + gi->deco.x + (pressed ? gi->deco.xshift : 0),
- gi->y + gi->deco.y + (pressed ? gi->deco.yshift : 0));
+ {
+ // make sure that decoration does not overlap gadget border
+ int deco_x = gi->deco.x + (pressed ? gi->deco.xshift : 0);
+ int deco_y = gi->deco.y + (pressed ? gi->deco.yshift : 0);
+ int deco_width = MIN(gi->deco.width, gi->width - deco_x);
+ int deco_height = MIN(gi->deco.height, gi->height - deco_y);
+
+ if (gi->deco.masked)
+ BlitBitmapMasked(gi->deco.design.bitmap, drawto,
+ gi->deco.design.x, gi->deco.design.y,
+ deco_width, deco_height,
+ gi->x + deco_x, gi->y + deco_y);
+ else
+ BlitBitmap(gi->deco.design.bitmap, drawto,
+ gi->deco.design.x, gi->deco.design.y,
+ deco_width, deco_height,
+ gi->x + deco_x, gi->y + deco_y);
+ }
+
break;
case GD_TYPE_TEXT_BUTTON:
return;
}
+ // do not use direct gadget drawing anymore; this worked as a speed-up once,
+ // but would slow things down a lot now the screen is always fully redrawn
+ direct = FALSE;
+
if (direct)
{
BlitBitmap(drawto, window,
{
int tag = first_tag;
- if (gi == NULL)
+ if (gi == NULL || gi->deactivated)
return;
while (tag != GDI_END)
gi->deco.yshift = va_arg(ap, int);
break;
+ case GDI_DECORATION_MASKED:
+ gi->deco.masked = (boolean)va_arg(ap, int);
+ break;
+
case GDI_EVENT_MASK:
gi->event_mask = va_arg(ap, unsigned int);
break;
gi->drawing.area_ysize = va_arg(ap, int);
/* determine dependent values for drawing area gadget, if needed */
- if (gi->width == 0 && gi->height == 0 &&
- gi->drawing.item_xsize !=0 && gi->drawing.item_ysize !=0)
+ if (gi->drawing.item_xsize != 0 && gi->drawing.item_ysize != 0)
{
gi->width = gi->drawing.area_xsize * gi->drawing.item_xsize;
gi->height = gi->drawing.area_ysize * gi->drawing.item_ysize;
}
- else if (gi->drawing.item_xsize == 0 && gi->drawing.item_ysize == 0 &&
- gi->width != 0 && gi->height != 0)
+ else if (gi->width != 0 && gi->height != 0)
{
gi->drawing.item_xsize = gi->width / gi->drawing.area_xsize;
gi->drawing.item_ysize = gi->height / gi->drawing.area_ysize;
gi->drawing.item_ysize = va_arg(ap, int);
/* determine dependent values for drawing area gadget, if needed */
- if (gi->width == 0 && gi->height == 0 &&
- gi->drawing.area_xsize !=0 && gi->drawing.area_ysize !=0)
+ if (gi->drawing.area_xsize != 0 && gi->drawing.area_ysize != 0)
{
gi->width = gi->drawing.area_xsize * gi->drawing.item_xsize;
gi->height = gi->drawing.area_ysize * gi->drawing.item_ysize;
}
- else if (gi->drawing.area_xsize == 0 && gi->drawing.area_ysize == 0 &&
- gi->width != 0 && gi->height != 0)
+ else if (gi->width != 0 && gi->height != 0)
{
gi->drawing.area_xsize = gi->width / gi->drawing.item_xsize;
gi->drawing.area_ysize = gi->height / gi->drawing.item_ysize;
tag = va_arg(ap, int); /* read next tag */
}
- /* check if gadget is complete */
+ gi->deactivated = FALSE;
+
+ /* check if gadget has undefined bitmaps */
if (gi->type != GD_TYPE_DRAWING_AREA &&
- (!gi->design[GD_BUTTON_UNPRESSED].bitmap ||
- !gi->design[GD_BUTTON_PRESSED].bitmap))
- Error(ERR_EXIT, "gadget incomplete (missing Bitmap)");
+ (gi->design[GD_BUTTON_UNPRESSED].bitmap == NULL ||
+ gi->design[GD_BUTTON_PRESSED].bitmap == NULL))
+ gi->deactivated = TRUE;
+
+ /* check if gadget is placed off-screen */
+ if (gi->x < 0 || gi->y < 0)
+ gi->deactivated = TRUE;
/* adjust gadget values in relation to other gadget values */
void RedrawGadget(struct GadgetInfo *gi)
{
- if (gi == NULL)
+ if (gi == NULL || gi->deactivated)
return;
if (gi->mapped)
static void MapGadgetExt(struct GadgetInfo *gi, boolean redraw)
{
- if (gi == NULL || gi->mapped || GADGET_DEACTIVATED(gi))
+ if (gi == NULL || gi->deactivated || gi->mapped)
return;
gi->mapped = TRUE;
void UnmapGadget(struct GadgetInfo *gi)
{
- if (gi == NULL || !gi->mapped)
+ if (gi == NULL || gi->deactivated || !gi->mapped)
return;
gi->mapped = FALSE;
if (gadget_pressed_inside_select_line)
new_gi = NULL;
+
+ StopTextInput();
}
gadget_pressed =
if (gi->textinput.cursor_position != old_cursor_position)
DrawGadget(gi, DG_PRESSED, gi->direct_draw);
+
+ if (press_event)
+ StartTextInput(gi->x, gi->y, gi->width, gi->height);
}
else if (gi->type & GD_TYPE_TEXT_AREA && button != 0 && !motion_status)
{
if (gi->textarea.cursor_position != old_cursor_position)
DrawGadget(gi, DG_PRESSED, gi->direct_draw);
+
+ if (press_event)
+ StartTextInput(gi->x, gi->y, gi->width, gi->height);
}
else if (gi->type & GD_TYPE_SELECTBOX && gi->selectbox.open &&
!keep_selectbox_open)
{
boolean scroll_single_step = ((GetKeyModState() & KMOD_Alt) != 0);
- item_steps = (scroll_single_step ? 1 : DEFAULT_WHEEL_STEPS);
+ item_steps = (scroll_single_step ? 1 : wheel_steps);
item_direction = (button == MB_WHEEL_UP ||
button == MB_WHEEL_LEFT ? -1 : +1);
}
{
struct GadgetInfo *gi = last_gi;
- if (gi == NULL || !gi->mapped ||
+ if (gi == NULL || gi->deactivated || !gi->mapped ||
!(gi->type & GD_TYPE_TEXT_INPUT ||
gi->type & GD_TYPE_TEXT_AREA ||
gi->type & GD_TYPE_SELECTBOX))
return FALSE;
- if (key == KSYM_Return) /* valid for both text input and selectbox */
+ if (key == KSYM_Escape)
+ {
+ StopTextInput();
+ }
+ else if (key == KSYM_Return) /* valid for both text input and selectbox */
{
boolean gadget_changed = ((gi->event_mask & GD_EVENT_TEXT_RETURN) != 0);
strcpy(gi->textinput.last_value, gi->textinput.value);
else
gadget_changed = FALSE;
+
+ StopTextInput();
}
else if (gi->type & GD_TYPE_SELECTBOX)
{