void muiDrawObject(muiObject *obj) { switch (obj->type) { case MUI_BUTTON: drawbut(obj); break; case MUI_RADIOBUTTON: drawradiobutton(obj); break; case MUI_TINYRADIOBUTTON: drawtinyradio(obj); break; case MUI_LABEL: drawlabel(obj); break; case MUI_BOLDLABEL: drawboldlabel(obj); break; case MUI_TEXTBOX: drawtb(obj); break; case MUI_VSLIDER: drawvs(obj); break; case MUI_HSLIDER: drawhs(obj); break; case MUI_TEXTLIST: drawtl(obj); break; case MUI_PULLDOWN: drawpulldown(obj); break; } }
static void drawmenu(void) { int i; for (i=0;i<NBUTTONS;i++) { drawbut(i); } }
static void turn_on_off (int pressed) { /* Shows when the menu is active or inactive by colouring the * * buttons. */ int i; for (i=0;i<NBUTTONS;i++) { button[i].ispressed = pressed; drawbut(i); } }
void event_loop (void (*act_on_button) (float x, float y), void (*drawscreen) (void)) { /* The program's main event loop. Must be passed a user routine * * drawscreen which redraws the screen. It handles all window resizing * * zooming etc. itself. If the user clicks a button in the graphics * * (toplevel) area, the act_on_button routine passed in is called. */ XEvent report; int bnum; float x, y; #define OFF 1 #define ON 0 turn_on_off (ON); while (1) { XNextEvent (display, &report); switch (report.type) { case Expose: #ifdef VERBOSE printf("Got an expose event.\n"); printf("Count is: %d.\n",report.xexpose.count); printf("Window ID is: %d.\n",report.xexpose.window); #endif if (report.xexpose.count != 0) break; if (report.xexpose.window == menu) drawmenu(); else if (report.xexpose.window == toplevel) drawscreen(); else if (report.xexpose.window == textarea) draw_message(); break; case ConfigureNotify: top_width = report.xconfigure.width; top_height = report.xconfigure.height; update_transform(); #ifdef VERBOSE printf("Got a ConfigureNotify.\n"); printf("New width: %d New height: %d.\n",top_width,top_height); #endif break; case ButtonPress: #ifdef VERBOSE printf("Got a buttonpress.\n"); printf("Window ID is: %d.\n",report.xbutton.window); #endif if (report.xbutton.window == toplevel) { x = XTOWORLD(report.xbutton.x); y = YTOWORLD(report.xbutton.y); act_on_button (x, y); } else { /* A menu button was pressed. */ bnum = which_button(report.xbutton.window); #ifdef VERBOSE printf("Button number is %d\n",bnum); #endif button[bnum].ispressed = 1; drawbut(bnum); XFlush(display); /* Flash the button */ button[bnum].fcn(bnum, drawscreen); button[bnum].ispressed = 0; drawbut(bnum); if (button[bnum].fcn == proceed) { turn_on_off(OFF); flushinput (); return; /* Rather clumsy way of returning * * control to the simulator */ } } break; } } }