home *** CD-ROM | disk | FTP | other *** search
/ No Fragments Archive 10: Diskmags / nf_archive_10.iso / MAGS / CHOSNECK / CHOS2.ZIP / CHOSNECK.2ND / STUFF / DATAS.ZIP / ART50F.SCR < prev    next >
Encoding:
Text File  |  2003-12-08  |  8.1 KB  |  160 lines

  1. <head>
  2. <title="...forever...">
  3. <font=monaco10.fnt>
  4. <font=newy36.fnt>
  5. <font=time24.fnt>
  6. <image=back.raw w=256 h=256 t=-1>
  7. <buf=2213>
  8. <bgcolor=-1>
  9. <background=0> 
  10. <link_color=253>
  11. <module=console.mod>
  12. <pal=back.pal>
  13. colors:
  14. 251 - black
  15. </head>
  16. <body>
  17. <frame x=0 y=0 w=640 h=2213 b=-1 c=-1>
  18.  
  19.  
  20. .: GEM in one pill :.
  21. -----------------------------
  22. 7) Dialog boxes
  23. ------------------
  24. Dialog  boxes  are an interactive formular in which the user can input text and 
  25. make selections with mouse pointer. 
  26. Dialog boxes are 'modal' and it means that while dialog box is displayed, other 
  27. screen  and  window  control  functions  are  suspended  (you have no access to 
  28. menubar for example) until you close the dialog. 
  29. In  most cases, the visual look of the dialog boxes is described in RSC file of 
  30. your application. 
  31. To put the dialog box on screen you have to:
  32. a) load rsc file with rsrc_load()
  33. b) find the address of our dialog in resource tree with 
  34. rsrc_gaddr(R_TREE,MY_DIALOG,&tree)
  35. c) after finding the address you can display it:
  36.  
  37. form_center()  sets the position of the dialog box on the screen. It calculates 
  38. top-left  position to center the dialog box on the screen i copies the OB_X and 
  39. OB_Y  fields  to  ROOT  object of the tree. It calculates also the rectangle in 
  40. which dialog will be displayed and saves the coordinates to variables 
  41. xdial,ydial,wdial,hdial.
  42. WARNING:  form_center()  is  causing  trouble, the rectangle returned in xdial, 
  43. ydial,wdial,hdial  is the same size like the oridinary dialog box. When we will 
  44. add  the OUTLINED attribute to the dialog, form_center() adds 3 pixel margin to 
  45. returned  rectangle  and  the  screen  underneath  the  dialog  isn't correctly 
  46. refreshed.  Attributes  like  SHADOWED and OUTSIDE aren't automatically handled 
  47. and you have to take it into account when writing code. 
  48.  
  49. After  that  we  call form_dial() with 0 as a parameter (it reserves the screen 
  50. for our dialog). 
  51.  
  52. Next  goes form_dial() with 1 as a parameter. It creates an effect called "zoom 
  53. box" (fully optional). 
  54.  
  55. Then  we  perform objc_draw() to draw the dialog on the screen. As a parameters 
  56. we  put  the address of of the rsc tree, address of the beginning of the object 
  57. (our dialog), the depth of the objects to draw and rectangle assigned to the 
  58. dialog box.
  59. Generally  speaking dialog boxes and their parts are ALWAYS on the beginning of 
  60. the  ROOT or object nr. 0. When you want to draw only a part of the dialog box, 
  61. adjust  only  the  clipping rectangle, not the object number, so the background 
  62. will be drawn correctly. 
  63.  
  64. Function  form_do()  hands  out  the overall control to AES, which animates the 
  65. dialog  ().  The  adress  of  the  dialog tree is passed as a parameter. Second 
  66. parameter  is  a  number  of  editable object, on which the text cursor will be 
  67. placed. If you don't expect any editable fields then simply pass 0. 
  68.  
  69. After that form_do() returns the object number which was pressed, in most cases 
  70. is  the  BUTTON  object  with  EXIT  and SELECTABLE flags setted. Activating of 
  71. DEFAULT    attribute   tells  to  the  system  that  the  specified  object  is 
  72. automatically  chosen  by CR (carriage return) or RETURN or ENTER in more human 
  73. language. 
  74. ATTENTION  PLEASE!  If  the  most significant bit is setted, then it means that 
  75. EXIT object had TOUCHEXIT attribute and was chosen with the double click of the 
  76. mouse.(it's possible to mask it) 
  77.  
  78. Next  the  for_do()  does  reverse  "zoom  box".  It  zooms the dialog from the 
  79. specified location to the rectangle (x,y,w,h). 
  80.  
  81. After  that form_dial() tells that the dialog box is ready and the parts of the 
  82. screen  area  are considered as "dirtied" and have to be redrawn. GEM sends the 
  83. redraw messages to all the damaged windows and redraws all that is needed. 
  84.  
  85. The calling of form_dial(3) redraws the area, which is 2 pixel higher and wider 
  86. than  area  that  you specified! This little thing isn't harmful at all, and it 
  87. redraws  all the shadows if they exist. If shadows dosn't exist then who cares? 
  88. The  calling  of form_dial(3) isn't only used as a redrawing routine for dialog 
  89. boxes.  With  this  call  you can redraw any screen area you want. The merit is 
  90. that, the redrawed area doesn't have to lay wholly in the window like in redraw 
  91. message  handling  functions.  Of course the drawback is that this treatment is 
  92. much  slower,  because  AES  has  to  decide  what  parts of display need to be 
  93. redrawn. 
  94.  
  95. CLEANING UP
  96. The  very  last  step is clearing of the SELECTED flag on the chosen object. If 
  97. you don't do this , the object will be inverted after next displaying of dialog 
  98. box.  The  clearing of the flag should be perfored with objc_change(), but this 
  99. is  not  very good in sense of performance, because we don't have to redraw the 
  100. whole object. 
  101.  
  102. SUMMARY
  103. Handling of the dialog consists of 3 steps:
  104. - initialisation (loading of the rsc file)
  105. - presentation of the dialog box
  106. - cleaning up
  107.  
  108. With  more  complicated  dialog boxes, the standard handling process is getting 
  109. complicated a bit. The initialisation will have for example the initial setting 
  110. of the flags and strings and the cleaning up phase will check what the user has 
  111. done. 
  112.  
  113. MORE BUTTONS..........
  114. Oridinary  dialog  boxes  contain only one EXIT button as a active object. They 
  115. aren't  much  better than simple windows with warnings. Now we want to increase 
  116. complexity  by  adding  the buttons without exit. They are setted by SELECTABLE 
  117. attribute  on  the  BUTTON object. The chosen object will be changing the state 
  118. from  selected (highlightened) to not selected each time the user will click on 
  119. it.  The  SELECTABLE attribute can also be used on objects of another type than 
  120. button.  Owning of this kind of button forces us to solve the problem tied with 
  121. initialisation  of  buttons before showing the dialog, checking and deselecting 
  122. them. As activating and deactivating of the button is connected with it's flag, 
  123. we  have  to  test  the  flag  during  the  initialisation  and  if true make a 
  124. sel_objc(tree,BTOBJ)  call. This will highlight the button after the first draw 
  125. of  the  dialog.  BTOBJ contains the name of the button defined in RSC file. As 
  126. the  button  starts  deselected  you  don't  have  to  do anything if your flag 
  127. variable isn't true. 
  128.  
  129. After  sucessful  drawing  of  the dialog box we have to check the state of the 
  130. object.  We  can  mask  out  the OB_STATE field. After that we deselect all the 
  131. dialog buttons before exiting the dialog box function. 
  132.  
  133. DIALOGS WITH MULTIPLE CHOICES
  134. The next application of the button are buttons with multiple choices. This type 
  135. of  objects  are  radio  buttons.  Selecting  of  one button from the whole set 
  136. deselects all the other. Each member of the button set has to be the sibling of 
  137. the  same  parent.  What the hell is that you ask?
  138. To  create  such  structure you have to put the BOX object to the dialog box in 
  139. RSC  editor,  check if all the buttons will fit inside the box, add them one at 
  140. time  into  the  box.  By nesting the buttons inside the box we force the radio 
  141. buttons  to  became  the  members  of the one parent. Each buttons must have an 
  142. attribute  SELECTABLE and RADIO BUTTON activated. Additionally you can hide the 
  143. box  by setting the box frame to 0, but do not flatten it! (whatever it means).
  144.  
  145. As  each  of  the radio buttons represents another option. After the dialog box 
  146. inintialisation  we  have  to  check which option is activated first and select 
  147. adequate button. Instructions if-then-else should be constucted in the way, so 
  148. the  only  one  button can be selected at once. While exiting you have to check 
  149. every button and set the internal variables. Once again the if-then-else should 
  150. be performed to make sure that only one button is activated. 
  151.  
  152.  
  153. -- - --- -- -------------------------------------------------------------------
  154.  CHOSNECK 4th appearance                                           contact us:
  155.  done by the dream survivors                                 greymsb@poczta.fm
  156. ----------------------------------------------------------------- -- - --------
  157. </frame>
  158. </body>
  159.  
  160.