+ switch(tag)
+ {
+ case GDI_CUSTOM_ID:
+ gi->custom_id = va_arg(ap, int);
+ break;
+
+ case GDI_CUSTOM_TYPE_ID:
+ gi->custom_type_id = va_arg(ap, int);
+ break;
+
+ case GDI_INFO_TEXT:
+ {
+ int max_textsize = MAX_INFO_TEXTSIZE - 1;
+
+ strncpy(gi->info_text, va_arg(ap, char *), max_textsize);
+ gi->info_text[max_textsize] = '\0';
+ }
+ break;
+
+ case GDI_X:
+ gi->x = va_arg(ap, int);
+ break;
+
+ case GDI_Y:
+ gi->y = va_arg(ap, int);
+ break;
+
+ case GDI_WIDTH:
+ gi->width = va_arg(ap, int);
+ break;
+
+ case GDI_HEIGHT:
+ gi->height = va_arg(ap, int);
+ break;
+
+ case GDI_TYPE:
+ gi->type = va_arg(ap, unsigned long);
+ break;
+
+ case GDI_STATE:
+ gi->state = va_arg(ap, unsigned long);
+ break;
+
+ case GDI_CHECKED:
+ gi->checked = va_arg(ap, boolean);
+ break;
+
+ case GDI_RADIO_NR:
+ gi->radio_nr = va_arg(ap, unsigned long);
+ break;
+
+ case GDI_NUMBER_VALUE:
+ gi->text.number_value = va_arg(ap, long);
+ sprintf(gi->text.value, "%d", gi->text.number_value);
+ gi->text.cursor_position = strlen(gi->text.value);
+ break;
+
+ case GDI_NUMBER_MIN:
+ gi->text.number_min = va_arg(ap, long);
+ if (gi->text.number_value < gi->text.number_min)
+ {
+ gi->text.number_value = gi->text.number_min;
+ sprintf(gi->text.value, "%d", gi->text.number_value);
+ }
+ break;
+
+ case GDI_NUMBER_MAX:
+ gi->text.number_max = va_arg(ap, long);
+ if (gi->text.number_value > gi->text.number_max)
+ {
+ gi->text.number_value = gi->text.number_max;
+ sprintf(gi->text.value, "%d", gi->text.number_value);
+ }
+ break;
+
+ case GDI_TEXT_VALUE:
+ {
+ int max_textsize = MAX_GADGET_TEXTSIZE;
+
+ if (gi->text.size)
+ max_textsize = MIN(gi->text.size, MAX_GADGET_TEXTSIZE - 1);
+
+ strncpy(gi->text.value, va_arg(ap, char *), max_textsize);
+ gi->text.value[max_textsize] = '\0';
+ gi->text.cursor_position = strlen(gi->text.value);
+ }
+ break;
+
+ case GDI_TEXT_SIZE:
+ {
+ int tag_value = va_arg(ap, int);
+ int max_textsize = MIN(tag_value, MAX_GADGET_TEXTSIZE - 1);
+
+ gi->text.size = max_textsize;
+ gi->text.value[max_textsize] = '\0';
+
+ if (gi->width == 0 && gi->height == 0)
+ {
+ gi->width = (gi->text.size + 1) * FONT2_XSIZE + 6;
+ gi->height = ED_WIN_COUNT_YSIZE;
+ }
+ }
+ break;
+
+ case GDI_DESIGN_UNPRESSED:
+ gi->design[GD_BUTTON_UNPRESSED].pixmap = va_arg(ap, Pixmap);
+ gi->design[GD_BUTTON_UNPRESSED].x = va_arg(ap, int);
+ gi->design[GD_BUTTON_UNPRESSED].y = va_arg(ap, int);
+ break;
+
+ case GDI_DESIGN_PRESSED:
+ gi->design[GD_BUTTON_PRESSED].pixmap = va_arg(ap, Pixmap);
+ gi->design[GD_BUTTON_PRESSED].x = va_arg(ap, int);
+ gi->design[GD_BUTTON_PRESSED].y = va_arg(ap, int);
+ break;
+
+ case GDI_ALT_DESIGN_UNPRESSED:
+ gi->alt_design[GD_BUTTON_UNPRESSED].pixmap= va_arg(ap, Pixmap);
+ gi->alt_design[GD_BUTTON_UNPRESSED].x = va_arg(ap, int);
+ gi->alt_design[GD_BUTTON_UNPRESSED].y = va_arg(ap, int);
+ break;
+
+ case GDI_ALT_DESIGN_PRESSED:
+ gi->alt_design[GD_BUTTON_PRESSED].pixmap = va_arg(ap, Pixmap);
+ gi->alt_design[GD_BUTTON_PRESSED].x = va_arg(ap, int);
+ gi->alt_design[GD_BUTTON_PRESSED].y = va_arg(ap, int);
+ break;
+
+ case GDI_DESIGN_BORDER:
+ gi->design_border = va_arg(ap, int);
+ break;
+
+ case GDI_DECORATION_DESIGN:
+ gi->deco.design.pixmap = va_arg(ap, Pixmap);
+ gi->deco.design.x = va_arg(ap, int);
+ gi->deco.design.y = va_arg(ap, int);
+ break;
+
+ case GDI_DECORATION_POSITION:
+ gi->deco.x = va_arg(ap, int);
+ gi->deco.y = va_arg(ap, int);
+ break;
+
+ case GDI_DECORATION_SIZE:
+ gi->deco.width = va_arg(ap, int);
+ gi->deco.height = va_arg(ap, int);
+ break;
+
+ case GDI_DECORATION_SHIFTING:
+ gi->deco.xshift = va_arg(ap, int);
+ gi->deco.yshift = va_arg(ap, int);
+ break;
+
+ case GDI_EVENT_MASK:
+ gi->event_mask = va_arg(ap, unsigned long);
+ break;
+
+ case GDI_AREA_SIZE:
+ gi->drawing.area_xsize = 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)
+ {
+ 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)
+ {
+ gi->drawing.item_xsize = gi->width / gi->drawing.area_xsize;
+ gi->drawing.item_ysize = gi->height / gi->drawing.area_ysize;
+ }
+ break;
+
+ case GDI_ITEM_SIZE:
+ gi->drawing.item_xsize = va_arg(ap, int);
+ 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)
+ {
+ 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)
+ {
+ gi->drawing.area_xsize = gi->width / gi->drawing.item_xsize;
+ gi->drawing.area_ysize = gi->height / gi->drawing.item_ysize;
+ }
+ break;
+
+ case GDI_SCROLLBAR_ITEMS_MAX:
+ gi->scrollbar.items_max = va_arg(ap, int);
+ break;
+
+ case GDI_SCROLLBAR_ITEMS_VISIBLE:
+ gi->scrollbar.items_visible = va_arg(ap, int);
+ break;
+
+ case GDI_SCROLLBAR_ITEM_POSITION:
+ gi->scrollbar.item_position = va_arg(ap, int);
+ break;
+
+ case GDI_CALLBACK_INFO:
+ gi->callback_info = va_arg(ap, gadget_function);
+ break;
+
+ case GDI_CALLBACK_ACTION:
+ gi->callback_action = va_arg(ap, gadget_function);
+ break;
+
+ default:
+ Error(ERR_EXIT, "HandleGadgetTags(): unknown tag %d", tag);
+ }