#include "gui.h" #include "sed1335.h" #include "graphics.h" #include "touch.h" //#include "string.h" struct Widget widgets[MAX_WIDGETS]; // keep array in bank 1 char num_widgets; void GUI_init() { num_widgets = 0; } void GUI_add_button(unsigned short left_x, unsigned short top_y, unsigned short width, unsigned short height, flash unsigned char* bitmap, void (*on_press)()) { SED1335_bitmap(bitmap, top_y, left_x); // Add button to widget list widgets[num_widgets].x1 = left_x + 10; widgets[num_widgets].y1 = top_y + 10; widgets[num_widgets].x2 = left_x + width - 10 ; widgets[num_widgets].y2 = top_y + height - 10; widgets[num_widgets].on_press = on_press; num_widgets++; // draw button rectangle(left_x+10, top_y+10, width-20, height-20); } void GUI_poll () { char i; struct Point* coord; for (i=0; i widgets[i].x1) && ((*coord).x < widgets[i].x2) && ((*coord).y > widgets[i].y1) && ((*coord).y < widgets[i].y2) ) { widgets[i].on_press(); // execute callback return; } } }