/* example9b2.c -XT COPYRIGHT (c) 2000 Kapteyn Astronomical Institute University of Groningen - 9700 AV Groningen, The Netherlands Example program to demonstrate GgiInset. The program allows the user to open an inset/box composer. Using this composer he or she can specify a set/subset and a box. This specification is then passed to task MNMX, which will report its findings in the GIPSY log file. Author: J.P. Terlouw. */ #include "stddef.h" #include "gipsyc.h" #include "cmain.h" #include "init.h" #include "finis.h" #include "deputy.h" #include "userfio.h" #include "ggi.h" /* * Button keyword handler for quitting. */ static void quit(ident id, char *key, int code, void *arg) { bool button=toflog(FALSE); (void)userflog(&button, 1, 2, key, " "); if (tobool(button)) { wkeyf(key); /* reset button */ if (GgiVerify("Really quit?", "Yes, quit", "No, continue")) { finis_c(); /* terminate program */ } } } /* * Button keyword handler for popping the set composer up or down. */ static void compose(ident id, char *key, int code, void *arg) { bool button=toflog(FALSE); ident composer; (void)userflog(&button, 1, 2, key, " "); if (tobool(button)) { wkeyf(key); composer = GgiInset(ggiIdent, "SETNAME="); /* check existence */ if (composer) { (void)GgiInset(ggiDelete, composer); /* exists: close */ } else { composer = GgiInset(ggiCreate, "SETNAME=", "INSET=", "BOX=", "Set/subset and box to be MNMX'd"); } } } /* * Keyword handler receiving the set/subset. */ static void getset(ident id, char *key, int code, void *arg) { fint irc; deputy_c(tofchar("mnmx"), &irc); /* start deputy task MNMX */ if (irc<0) rejectf(key, "MNMX error code %d", irc); /* report any error */ } MAIN_PROGRAM_ENTRY { ident button, quitbtn; init_c(); GgiAutoLayout(FALSE); GgiPostponeRealize(TRUE); button = GgiButton("COMPOSE=", "Input set, subset, box"); quitbtn = GgiButton("QUIT=", "Terminate program"); GgiSetPosition(quitbtn, 0, NULL, 0, NULL); GgiSetPosition(button, 0, quitbtn, 0, NULL); GgiRealize(); (void)ScheduleKeyevent(quit, "QUIT=", KEYCHANGE, NULL); (void)ScheduleKeyevent(compose, "COMPOSE=", KEYCHANGE, NULL); (void)ScheduleKeyevent(getset, "INSET=", KEYCHANGE, NULL); MainLoop(); }