#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' && \
+ !strEqual(t, " "))
+#define CURRENT_OPTION_SELECTABLE(g) \
+ OPTION_TEXT_SELECTABLE(g, g->selectbox.options[g->selectbox.current_index].text)
+
static struct GadgetInfo *gadget_list_first_entry = NULL;
static struct GadgetInfo *gadget_list_last_entry = NULL;
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 i;
char text[MAX_GADGET_TEXTSIZE + 1];
- int font_nr = (pressed ? gi->font_active : gi->font);
+ int font_nr_default = (pressed ? gi->font_active : gi->font);
+ int font_nr = font_nr_default;
int font_width = getFontWidth(font_nr);
int font_height = getFontHeight(font_nr);
int border_x = gi->border.xsize;
gi->selectbox.size);
text[gi->selectbox.size] = '\0';
+ /* set font value */
+ font_nr = (OPTION_TEXT_SELECTABLE(gi, text) ? font_nr_default :
+ gi->font_unselectable);
+
/* gadget text value */
DrawTextExt(drawto, gi->x + border_x, gi->y + border_y, text,
font_nr, BLIT_MASKED);
strncpy(text, gi->selectbox.options[i].text, gi->selectbox.size);
text[gi->selectbox.size] = '\0';
- if (i == gi->selectbox.current_index)
+ font_nr = (OPTION_TEXT_SELECTABLE(gi, text) ? font_nr_default :
+ gi->font_unselectable);
+
+ if (i == gi->selectbox.current_index &&
+ OPTION_TEXT_SELECTABLE(gi, text))
{
FillRectangle(drawto,
gi->selectbox.x + border_x,
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,
gi->font = va_arg(ap, int);
if (gi->font_active == 0)
gi->font_active = gi->font;
+ if (gi->font_unselectable == 0)
+ gi->font_unselectable = gi->font;
break;
case GDI_TEXT_FONT_ACTIVE:
gi->font_active = va_arg(ap, int);
break;
+ case GDI_TEXT_FONT_UNSELECTABLE:
+ gi->font_unselectable = va_arg(ap, int);
+ break;
+
case GDI_SELECTBOX_OPTIONS:
gi->selectbox.options = va_arg(ap, struct ValueTextInfo *);
break;
gi->selectbox.index = va_arg(ap, int);
break;
+ case GDI_SELECTBOX_CHAR_UNSELECTABLE:
+ gi->selectbox.char_unselectable = (char)va_arg(ap, int);
+ break;
+
case GDI_DESIGN_UNPRESSED:
gi->design[GD_BUTTON_UNPRESSED].bitmap = va_arg(ap, Bitmap *);
gi->design[GD_BUTTON_UNPRESSED].x = va_arg(ap, int);
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;
if (gi->type & GD_TYPE_SELECTBOX &&
(keep_selectbox_open ||
mouse_released_where_pressed ||
- !gadget_released_inside_select_area)) /* selectbox stays open */
+ !gadget_released_inside_select_area ||
+ !CURRENT_OPTION_SELECTABLE(gi))) /* selectbox stays open */
{
gi->selectbox.stay_open = TRUE;
pressed_mx = 0;
{
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);
}
{
if (keep_selectbox_open ||
mouse_released_where_pressed ||
- !gadget_released_inside_select_area) /* selectbox stays open */
+ !gadget_released_inside_select_area ||
+ !CURRENT_OPTION_SELECTABLE(gi)) /* selectbox stays open */
{
deactivate_gadget = FALSE;
gadget_changed = FALSE;