int main(int argc, char **argv) { GrEvent ev; long oldtime = 0; if (argc >= 4) { gwidth = atoi(argv[1]); gheight = atoi(argv[2]); gbpp = atoi(argv[3]); } ini_graphics(); GrSetWindowTitle(wintitle); ini_objects(); paint_screen(); while (1) { GrEventRead(&ev); if (ev.type == GREV_MOUSE) { ev.p2 -= worg; ev.p3 -= horg; } if (ev.type == GREV_END) break; if ((ev.type == GREV_KEY) && (ev.p1 == GrKey_Escape)) break; if ((ev.type == GREV_KEY) && (ev.p1 == 's')) { GrSaveContextToPpm(NULL, "demomgrx.ppm", "DemoMGRX"); continue; } if (pev_button_group(&ev, bgact)) continue; if (pev_command(&ev)) continue; if (pev_select(&ev)) continue; if (ev.type == GREV_MOUSE) { if (ev.p1 == GRMOUSE_LB_PRESSED) paint_foot("over a button, please"); else if (ev.p1 == GRMOUSE_LB_RELEASED) paint_foot("Hold down left mouse buttom to see a comment"); } if (ev.type == GREV_NULL) { if (ev.time > (oldtime + 5)) { paint_animation(); oldtime = ev.time; } } } gfaz_fin(); return 0; }
void NX_SetCaption (_THIS, const char * title, const char * icon) { Dprintf ("enter NX_SetCaption\n") ; // Lock the event thread, in multi-threading environments SDL_Lock_EventThread () ; if (SDL_Window) GrSetWindowTitle (SDL_Window, title) ; SDL_Unlock_EventThread () ; Dprintf ("leave NX_SetCaption\n") ; }
static int pev_command(GrEvent * ev) { int i; char nprog[81]; if (ev->type == GREV_COMMAND) { if (ev->p1 == ID_EXIT) { par_event_queue(GREV_END, 0, 0, 0); return 1; } if (ev->p1 == ID_PAGE1) { bgact = &bgp1; paint_screen(); return 1; } if (ev->p1 == ID_PAGE2) { bgact = &bgp2; paint_screen(); return 1; } for (i = 0; i < NDEMOS; i++) { if (ev->p1 == ptable[i].cid) { gfaz_fin(); #if defined(__MSDOS__) || defined(__WIN32__) if (ev->p1 == ID_MODETEST) strcpy(nprog, "..\\bin\\"); else strcpy(nprog, ".\\"); #else if (ev->p1 == ID_MODETEST) strcpy(nprog, "../bin/"); else strcpy(nprog, "./"); #endif #if defined(__XWIN__) strcat(nprog, "x"); #endif strcat(nprog, ptable[i].prog); system(nprog); ini_graphics(); GrSetWindowTitle(wintitle); paint_screen(); return 1; } } } return 0; }