+2014-10-08
+ * added handling of unselectable selectbox options and option headlines
+
2014-10-07
* fixed bug when changing between graphic sets with different tile size
* cleanup of handling the various graphic sizes for different purposes
-#define COMPILE_DATE_STRING "2014-10-08 00:24"
+#define COMPILE_DATE_STRING "2014-10-09 01:55"
GDI_Y, y,
GDI_TYPE, GD_TYPE_SELECTBOX,
GDI_SELECTBOX_OPTIONS, selectbox_info[i].options,
+ GDI_SELECTBOX_CHAR_UNSELECTABLE, '[',
GDI_TEXT_SIZE, selectbox_info[i].size,
GDI_TEXT_FONT, FONT_INPUT_1,
GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
+ GDI_TEXT_FONT_UNSELECTABLE, FONT_TEXT_1,
GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x, gd_y,
GDI_DESIGN_PRESSED, gd_bitmap, gd_x, gd_y,
GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
#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;
{
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,
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);
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;
{
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;
#define GDI_TEXT_SIZE 15
#define GDI_TEXT_FONT 16
#define GDI_TEXT_FONT_ACTIVE 17
-#define GDI_SELECTBOX_OPTIONS 18
-#define GDI_SELECTBOX_INDEX 19
-#define GDI_DESIGN_UNPRESSED 20
-#define GDI_DESIGN_PRESSED 21
-#define GDI_ALT_DESIGN_UNPRESSED 22
-#define GDI_ALT_DESIGN_PRESSED 23
-#define GDI_BORDER_SIZE 24
-#define GDI_BORDER_SIZE_SELECTBUTTON 25
-#define GDI_DESIGN_WIDTH 26
-#define GDI_DECORATION_DESIGN 27
-#define GDI_DECORATION_POSITION 28
-#define GDI_DECORATION_SIZE 29
-#define GDI_DECORATION_SHIFTING 30
-#define GDI_EVENT_MASK 31
-#define GDI_EVENT 32
-#define GDI_CALLBACK_INFO 33
-#define GDI_CALLBACK_ACTION 34
-#define GDI_AREA_SIZE 35
-#define GDI_ITEM_SIZE 36
-#define GDI_SCROLLBAR_ITEMS_MAX 37
-#define GDI_SCROLLBAR_ITEMS_VISIBLE 38
-#define GDI_SCROLLBAR_ITEM_POSITION 39
-#define GDI_WHEEL_AREA_X 40
-#define GDI_WHEEL_AREA_Y 41
-#define GDI_WHEEL_AREA_WIDTH 42
-#define GDI_WHEEL_AREA_HEIGHT 43
-#define GDI_INFO_TEXT 44
-#define GDI_ACTIVE 45
-#define GDI_DIRECT_DRAW 46
+#define GDI_TEXT_FONT_UNSELECTABLE 18
+#define GDI_SELECTBOX_OPTIONS 19
+#define GDI_SELECTBOX_INDEX 20
+#define GDI_SELECTBOX_CHAR_UNSELECTABLE 21
+#define GDI_DESIGN_UNPRESSED 22
+#define GDI_DESIGN_PRESSED 23
+#define GDI_ALT_DESIGN_UNPRESSED 24
+#define GDI_ALT_DESIGN_PRESSED 25
+#define GDI_BORDER_SIZE 26
+#define GDI_BORDER_SIZE_SELECTBUTTON 27
+#define GDI_DESIGN_WIDTH 28
+#define GDI_DECORATION_DESIGN 29
+#define GDI_DECORATION_POSITION 30
+#define GDI_DECORATION_SIZE 31
+#define GDI_DECORATION_SHIFTING 32
+#define GDI_EVENT_MASK 33
+#define GDI_EVENT 34
+#define GDI_CALLBACK_INFO 35
+#define GDI_CALLBACK_ACTION 36
+#define GDI_AREA_SIZE 37
+#define GDI_ITEM_SIZE 38
+#define GDI_SCROLLBAR_ITEMS_MAX 39
+#define GDI_SCROLLBAR_ITEMS_VISIBLE 40
+#define GDI_SCROLLBAR_ITEM_POSITION 41
+#define GDI_WHEEL_AREA_X 42
+#define GDI_WHEEL_AREA_Y 43
+#define GDI_WHEEL_AREA_WIDTH 44
+#define GDI_WHEEL_AREA_HEIGHT 45
+#define GDI_INFO_TEXT 46
+#define GDI_ACTIVE 47
+#define GDI_DIRECT_DRAW 48
/* gadget deactivation hack */
#define GDI_ACTIVE_POS(a) ((a) < 0 ? POS_OFFSCREEN : (a))
struct ValueTextInfo *options; /* pointer to text/value array */
int index; /* index of actual text string */
int size; /* maximal size of text strings */
+ char char_unselectable; /* first char of unselectable options */
/* automatically determined values */
int x, y; /* open selectbox position */
boolean direct_draw; /* directly draw to frontbuffer */
int font; /* font to use when inactive */
int font_active; /* font to use when active */
+ int font_unselectable; /* font to use when unselectable */
struct GadgetBorder border; /* gadget border design */
struct GadgetDesign design[2]; /* 0: normal; 1: pressed */
struct GadgetDesign alt_design[2]; /* alternative design */