#include <string.h>
#include "gadgets.h"
+#include "image.h"
#include "text.h"
#include "misc.h"
{
switch(tag)
{
+ case GDI_IMAGE_ID:
+ gi->image_id = va_arg(ap, int);
+ break;
+
case GDI_CUSTOM_ID:
gi->custom_id = va_arg(ap, int);
break;
/* always start with reliable default values */
new_gadget->id = getNewGadgetID();
+ new_gadget->image_id = -1;
new_gadget->callback_info = default_callback_info;
new_gadget->callback_action = default_callback_action;
new_gadget->active = TRUE;
void ClickOnGadget(struct GadgetInfo *gi, int button)
{
- if (!gi->mapped)
+ if (gi == NULL || gi->deactivated || !gi->mapped)
return;
/* simulate releasing mouse button over last gadget, if still pressed */
return TRUE;
}
+
+void DumpGadgetIdentifiers()
+{
+ struct GadgetInfo *gi;
+
+ Print("Gadgets on current screen:\n");
+
+ for (gi = gadget_list_first_entry; gi != NULL; gi = gi->next)
+ {
+ if (gi->mapped && gi->image_id != -1)
+ {
+ char *token = getTokenFromImageID(gi->image_id);
+ char *prefix = "gfx.";
+
+ if (strPrefix(token, prefix))
+ token = &token[strlen(prefix)];
+
+ Print("- '%s'\n", token);
+ }
+ }
+
+ Print("Done.\n");
+}
+
+boolean DoGadgetAction(int image_id)
+{
+ struct GadgetInfo *gi;
+
+ for (gi = gadget_list_first_entry; gi != NULL; gi = gi->next)
+ {
+ if (gi->mapped && gi->image_id == image_id)
+ {
+ gi->callback_action(gi);
+
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}