/***********************************************************
* Artsoft Retro-Game Library *
*----------------------------------------------------------*
-* (c) 1994-2000 Artsoft Entertainment *
+* (c) 1994-2002 Artsoft Entertainment *
* Holger Schemel *
* Detmolder Strasse 189 *
* 33604 Bielefeld *
return id;
}
+#if 0
+void DUMP_GADGET_MAP_STATE()
+{
+ struct GadgetInfo *gi = gadget_list_first_entry;
+
+ while (gi)
+ {
+ printf("-XXX-1-> '%s': %s\n",
+ gi->info_text, (gi->mapped ? "mapped" : "not mapped"));
+
+ gi = gi->next;
+ }
+}
+#endif
+
static struct GadgetInfo *getGadgetInfoFromMousePosition(int mx, int my)
{
struct GadgetInfo *gi = gadget_list_first_entry;
static void default_callback_info(void *ptr)
{
-#if 0
- if (game_status == LEVELED)
- HandleEditorGadgetInfoText(ptr);
-#endif
-
return;
}
case GD_TYPE_NORMAL_BUTTON:
case GD_TYPE_CHECK_BUTTON:
case GD_TYPE_RADIO_BUTTON:
- BlitBitmap(gd->bitmap, drawto,
- gd->x, gd->y, gi->width, gi->height, gi->x, gi->y);
+ 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,
border, gi->height, gi->x + gi->width - border, gi->y);
/* gadget text value */
- DrawText(gi->x + border, gi->y + border, text, FS_SMALL, font_type);
+ DrawTextExt(drawto,
+ gi->x + border, gi->y + border, text,
+ FS_SMALL, font_type, FONT_OPAQUE);
cursor_letter = gi->text.value[gi->text.cursor_position];
cursor_string[0] = '~';
/* draw cursor, if active */
if (pressed)
- DrawText(gi->x + border + gi->text.cursor_position * font_width,
- gi->y + border, cursor_string, FS_SMALL, font_type);
+ DrawTextExt(drawto,
+ gi->x + border + gi->text.cursor_position * font_width,
+ gi->y + border, cursor_string,
+ FS_SMALL, font_type, FONT_OPAQUE);
}
break;
int step_size_remain = size_body - num_steps * design_body;
/* clear scrollbar area */
- ClearRectangle(backbuffer, gi->x, gi->y, gi->width, gi->height);
+ ClearRectangleOnBackground(backbuffer, gi->x, gi->y,
+ gi->width, gi->height);
/* upper part of gadget */
- BlitBitmap(gd->bitmap, drawto,
- gd->x, gd->y,
- gi->width, gi->border.size,
- xpos, ypos);
+ BlitBitmapOnBackground(gd->bitmap, drawto,
+ gd->x, gd->y,
+ gi->width, gi->border.size,
+ xpos, ypos);
/* middle part of gadget */
for (i=0; i<num_steps; i++)
- BlitBitmap(gd->bitmap, drawto,
- gd->x, gd->y + gi->border.size,
- gi->width, design_body,
- xpos, ypos + gi->border.size + i * design_body);
+ BlitBitmapOnBackground(gd->bitmap, drawto,
+ gd->x, gd->y + gi->border.size,
+ gi->width, design_body,
+ xpos, ypos + gi->border.size
+ + i * design_body);
/* remaining middle part of gadget */
if (step_size_remain > 0)
- BlitBitmap(gd->bitmap, drawto,
- gd->x, gd->y + gi->border.size,
- gi->width, step_size_remain,
- xpos, ypos + gi->border.size + num_steps * design_body);
+ BlitBitmapOnBackground(gd->bitmap, drawto,
+ gd->x, gd->y + gi->border.size,
+ gi->width, step_size_remain,
+ xpos, ypos + gi->border.size
+ + num_steps * design_body);
/* lower part of gadget */
- BlitBitmap(gd->bitmap, drawto,
- gd->x, gd->y + design_full - gi->border.size,
- gi->width, gi->border.size,
- xpos, ypos + size_full - gi->border.size);
+ BlitBitmapOnBackground(gd->bitmap, drawto,
+ gd->x, gd->y + design_full - gi->border.size,
+ gi->width, gi->border.size,
+ xpos, ypos + size_full - gi->border.size);
}
break;
case GDI_INFO_TEXT:
{
int max_textsize = MAX_INFO_TEXTSIZE - 1;
+ char *text = va_arg(ap, char *);
+
+ if (text != NULL)
+ strncpy(gi->info_text, text, max_textsize);
+ else
+ max_textsize = 0;
- strncpy(gi->info_text, va_arg(ap, char *), max_textsize);
gi->info_text[max_textsize] = '\0';
}
break;
break;
case GDI_CHECKED:
- gi->checked = va_arg(ap, boolean);
+ /* take care here: "boolean" is typedef'ed as "unsigned char",
+ which gets promoted to "int" */
+ gi->checked = (boolean)va_arg(ap, int);
break;
case GDI_RADIO_NR:
struct GadgetInfo *CreateGadget(int first_tag, ...)
{
- struct GadgetInfo *new_gadget = checked_malloc(sizeof(struct GadgetInfo));
+ struct GadgetInfo *new_gadget = checked_calloc(sizeof(struct GadgetInfo));
va_list ap;
/* always start with reliable default values */
- memset(new_gadget, 0, sizeof(struct GadgetInfo)); /* zero all fields */
new_gadget->id = getNewGadgetID();
new_gadget->callback_info = default_callback_info;
new_gadget->callback_action = default_callback_action;
+ new_gadget->next = NULL;
va_start(ap, first_tag);
HandleGadgetTags(new_gadget, first_tag, ap);
if (gi == gadget_list_last_entry)
gadget_list_last_entry = gi_previous;
- gi_previous->next = gi->next;
+ if (gi_previous)
+ gi_previous->next = gi->next;
+
free(gi);
}
if (last_info_gi != new_gi ||
(new_gi && new_gi->type == GD_TYPE_DRAWING_AREA && changed_position))
{
- last_info_gi = new_gi;
-
if (new_gi != NULL && (button == 0 || new_gi == last_gi))
{
- new_gi->event.type = 0;
+ new_gi->event.type = GD_EVENT_INFO_ENTERING;
new_gi->callback_info(new_gi);
}
- else
+ else if (last_info_gi != NULL)
+ {
+ last_info_gi->event.type = GD_EVENT_INFO_LEAVING;
+ last_info_gi->callback_info(last_info_gi);
+
+#if 0
default_callback_info(NULL);
+
+ printf("It seems that we are leaving gadget [%s]!\n",
+ (last_info_gi != NULL &&
+ last_info_gi->info_text != NULL ?
+ last_info_gi->info_text : ""));
+#endif
+ }
+
+ last_info_gi = new_gi;
}
if (gadget_pressed)