/* The GEM Dialog Box Example using LASER C */ /* By Eric Tremblay (CompuServe I.D. 73117,460) */ /* April 7, 1990 */ /* I would like to thank Steve, Rene, and Bill for */ /* all making an effort and making the dialog work */ /* and making me understand how it works. */ /* If only I would have found something like this from CompuServe */ /* I would have saved many many hours... */ /* Now I will uploaded this code to help the people who like me */ /* need a little help to understand. */ /* Feel free to send you remarks! Bye! */ #include #include #include #include /* #include "dialog.h" it's already included below */ #define TREE1 0 #define EXITT 9 #define DISPLAY 1 #define BUTTON2 5 #define BUTTON3 6 #define LINE2 3 #define BUTTON1 4 #define LINE1 2 main () { /* Open MAIN statement */ OBJECT *tree1; int x,y,w,h; appl_init(); rsrc_load("DIALOG.RSC"); rsrc_gaddr(0,TREE1, &tree1); setbuf(stdin,NULL); setbuf(stdout,NULL); form_center(tree1, &x, &y, &w, &h); ((TEDINFO *)tree1[DISPLAY].ob_spec)->te_ptext= "This is the Display"; ((TEDINFO *)tree1[LINE1].ob_spec)->te_ptext= "Input text here. LINE1"; ((TEDINFO *)tree1[LINE2].ob_spec)->te_ptext= "More text here. LINE2"; objc_draw(tree1, 0, 10, x, y, w, h); /* Makes a loop until EXITT button equals SELECTED */ while ((tree1[EXITT].ob_state&SELECTED)!=SELECTED) { /* Open of WHILE statement */ form_do(tree1, 0); /* Wait for OK button */ /* Check's if the ob_state of BUTTON1 is SELECTED */ if ((tree1[BUTTON1].ob_state&SELECTED)==SELECTED) { /* Resets ob_state of BUTTON1 to NORMAL */ tree1[BUTTON1].ob_state=NORMAL; /* Changes value of te_ptext of the object DISPLAY */ ((TEDINFO *)tree1[DISPLAY].ob_spec)->te_ptext= "You have SELECTED BUTTON 1"; /* Draws the object in the dialog box */ objc_draw(tree1,0,10, x, y, w, h); } /* Check's if the ob_state of BUTTON2 is SELECTED */ if((tree1[BUTTON2].ob_state&SELECTED)==SELECTED) { ((TEDINFO *)tree1[DISPLAY].ob_spec)->te_ptext= "You have SELECTED BUTTON 2"; tree1[BUTTON2].ob_state=NORMAL; tree1[BUTTON2].ob_state=SHADOWED; objc_draw(tree1, 0, 10, x, y, w, h); } /* Check's if the ob_state of BUTTON3 is SELECTED */ if ((tree1[BUTTON3].ob_state&SELECTED)==SELECTED) { ((TEDINFO *)tree1[DISPLAY].ob_spec)->te_ptext= "You have SELECTED BUTTON 3"; tree1[BUTTON3].ob_state=NORMAL; objc_draw(tree1, 0, 10, x, y, w, h); } } /* Close WHILE statement */ appl_exit(); /* Gets the text entered on LINE1 */ printf("\nptext in LINE1: %s\n",((TEDINFO *)tree1[LINE1].ob_spec)->te_ptext); /* Gets the text entered from LINE2 */ printf("\nptext in LINE2: %s\n",((TEDINFO *)tree1[LINE2].ob_spec)->te_ptext); /* celui /* Ask's for an answer */ printf("\nPRESS TO EXIT"); getchar(); /* Waits for */ } /* Close MAIN statement */