home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / files / etfiles / cdialog / dialog.c next >
Encoding:
C/C++ Source or Header  |  1990-04-07  |  3.1 KB  |  109 lines

  1. /* The GEM Dialog Box Example using LASER C         */
  2. /* By Eric Tremblay  (CompuServe I.D. 73117,460)    */
  3. /* April 7, 1990                                    */
  4.  
  5. /* I would like to thank Steve, Rene, and Bill for  */
  6. /* all making an effort and making the dialog work  */
  7. /* and making me understand how it works.           */                                           
  8.  
  9. /* If only I would have found something like this from CompuServe */
  10. /* I would have saved many many hours...                          */
  11.  
  12. /* Now I will uploaded this code to help the people who like me   */
  13. /* need a little help to understand.                              */
  14. /* Feel free to send you remarks! Bye!                            */
  15.  
  16. #include <stdio.h>
  17. #include <osbind.h>
  18. #include <obdefs.h>
  19. #include <gemdefs.h>
  20.  
  21. /* #include "dialog.h" it's already included below */
  22. #define TREE1 0
  23. #define EXITT 9
  24. #define DISPLAY 1
  25. #define BUTTON2 5
  26. #define BUTTON3 6
  27. #define LINE2 3
  28. #define BUTTON1 4
  29. #define LINE1 2
  30.  
  31. main ()
  32.  
  33.     {  /* Open MAIN statement */
  34.  
  35.  
  36. OBJECT *tree1;
  37. int x,y,w,h;
  38.  
  39.  
  40. appl_init();
  41. rsrc_load("DIALOG.RSC");
  42. rsrc_gaddr(0,TREE1, &tree1);
  43.  
  44. setbuf(stdin,NULL);
  45. setbuf(stdout,NULL);
  46.  
  47. form_center(tree1, &x, &y, &w, &h);
  48. ((TEDINFO *)tree1[DISPLAY].ob_spec)->te_ptext= "This is the Display";
  49. ((TEDINFO *)tree1[LINE1].ob_spec)->te_ptext= "Input text here. LINE1";
  50. ((TEDINFO *)tree1[LINE2].ob_spec)->te_ptext= "More text here.  LINE2";
  51.  
  52.  
  53. objc_draw(tree1, 0, 10, x, y, w, h);
  54.  
  55. /* Makes a loop until EXITT button equals SELECTED */
  56. while ((tree1[EXITT].ob_state&SELECTED)!=SELECTED)
  57.  
  58. {   /* Open of WHILE statement */
  59.  
  60. form_do(tree1, 0); /* Wait for OK button */
  61.  
  62. /* Check's if the ob_state of BUTTON1 is SELECTED */
  63. if ((tree1[BUTTON1].ob_state&SELECTED)==SELECTED)
  64.     {
  65.     /* Resets ob_state of BUTTON1 to NORMAL */
  66.     tree1[BUTTON1].ob_state=NORMAL;
  67.     
  68.     /* Changes value of te_ptext of the object DISPLAY */
  69.     ((TEDINFO *)tree1[DISPLAY].ob_spec)->te_ptext= "You have SELECTED BUTTON 1";    
  70.   
  71.     /* Draws the object in the dialog box */
  72.     objc_draw(tree1,0,10, x, y, w, h);    
  73.     }  
  74.  
  75. /* Check's if the ob_state of BUTTON2 is SELECTED */
  76.     if((tree1[BUTTON2].ob_state&SELECTED)==SELECTED)
  77.         {
  78.         ((TEDINFO *)tree1[DISPLAY].ob_spec)->te_ptext= "You have SELECTED BUTTON 2"; 
  79.         tree1[BUTTON2].ob_state=NORMAL;    
  80.         tree1[BUTTON2].ob_state=SHADOWED;
  81.         objc_draw(tree1, 0, 10, x, y, w, h);    
  82.         }
  83.  
  84. /* Check's if the ob_state of BUTTON3 is SELECTED */        
  85. if ((tree1[BUTTON3].ob_state&SELECTED)==SELECTED)
  86.         {
  87.         ((TEDINFO *)tree1[DISPLAY].ob_spec)->te_ptext= "You have SELECTED BUTTON 3";
  88.         tree1[BUTTON3].ob_state=NORMAL;    
  89.         objc_draw(tree1, 0, 10, x, y, w, h);
  90.         }
  91.  
  92. }   /* Close WHILE statement */
  93.  
  94. appl_exit(); 
  95.  
  96.  
  97. /* Gets the text entered on LINE1 */
  98. printf("\nptext in LINE1: %s\n",((TEDINFO *)tree1[LINE1].ob_spec)->te_ptext); 
  99.  
  100. /* Gets the text entered from LINE2 */
  101. printf("\nptext in LINE2: %s\n",((TEDINFO *)tree1[LINE2].ob_spec)->te_ptext); /* celui
  102.  
  103. /* Ask's for an answer */
  104. printf("\nPRESS <ENTER> TO EXIT");
  105.  
  106. getchar(); /* Waits for <ENTER> */
  107.  
  108. }   /* Close MAIN statement */
  109.