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 / ART50C.SCR < prev    next >
Encoding:
Text File  |  2003-12-09  |  7.9 KB  |  182 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=2582>
  8. <bgcolor=-1>
  9. <background=0> 
  10. <link_color=000>
  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=2582 b=-1 c=-1>
  18.  
  19.  
  20. .: GEM in one pill :.
  21. -----------------------------
  22. 4) MENU BAR CONSTRUCTION
  23. ----------------------------
  24. GEM  posses one menu bar, no matter how many applications are present. The look 
  25. of  the  menu  is  set  in  RSC  file.  And what is that resource file you ask? 
  26.  
  27. Basically  speaking it is a tree structure of objects. Main object is a "root", 
  28. which  has  many  subobjects (called "children"). The objects on the same level 
  29. are  called siblings. In what manner the tree of objects is organised? The main 
  30. object  is  a  rectangle of the size of the screen ( our desktop with the green 
  31. background).  After  there are two children: white bar and all the objects that 
  32. are inside of it. 
  33. The  white  menubox has under each menutitle one child (or more), and box which 
  34. has  the  desktop  icons and others. With this little explanation, you know how 
  35. easy  is  to  put  the images into desktop. All is needed to change the desktop 
  36. background  or  exchange  the  root  object  with picture. 
  37. The menu consists of several children of menu bar, which are menu titles. Under 
  38. each  tite  there  is  a box and this box has it's own titles as it's children. 
  39. Each menu title is a string object. 
  40. Resource file structure:
  41.  
  42.     Root (G_BOX)-------------------------------+
  43.          /                                     |
  44.         /                                      |
  45.        /                                       |
  46.  BAR ((G_BOX char+2 pixels of width))          |
  47.      /                                         |
  48.   ACTIVE (G_IBOX)              SCREEN (G_IBOX over rest of the screen)          
  49.     /|\                                       /|\
  50. MENU TITLES (G_TITLES)           BOX (G_BOX contains drop-down menu)
  51.                                               /\ 
  52.                                           MENU TITLES               
  53.                              (usually G_STRINGS, but can be each type)      
  54.  
  55.          Single line has 1 children, several lines mean many children.
  56.  
  57. That's  all  about  resource  files,  now  you  have  to use one of the several 
  58. programs to design RSC files: Resource Master, WERCS, MKRSC. 
  59.  
  60. Resource file design guidelines
  61. During  designing  of  resourcefile we have to bear in mind several guidelines. 
  62. The  very  first title in menubar should have Atati logo, but when multitasking 
  63. kernel  was introduced there was decision to put in the name of the program, so 
  64. the  user  will  know  which application he is actually using. This menu should 
  65. contain  "0  <program name>" followed by separator ("-------------" string with 
  66. DISABLED  attribute). After that there should be six empty strings for names of 
  67. accessories. 
  68.  
  69. Next  position in menubar should be "File" with following titles (you can skeep 
  70. everything  what is not needed): New, Open, Save, Save as.., Save all (option), 
  71. separator,  Import, Export, another operations on files (see below), separator, 
  72. page settings, print, Output commands, separator, quit. 
  73.  
  74. Save all - saves all opened files
  75. Refresh - refreshes/redraws actual document/image or anything else
  76. another  file  operations  - shouldn't contain format disk or delete file. File 
  77. managment should be left to desktop or multitasking interface not application.
  78.  
  79. Third  title should be "Edit" with Undo, Redo, Copy, Insert, Delete, separator, 
  80. Select  All(option),  separator,  Find, Exchange, Find next(option), separator, 
  81. the rest of edit options. 
  82.  
  83. Another  things  like  "Save  settings"  and/or  "Set preferences" should be in 
  84. "Options"  menu NOT "File" menu. The help shoul be far to the right. More about 
  85. guidelines, you can read in Atari Compedium. 
  86.  
  87. After  the  designing of application's interface it is stored in RSC file. Good 
  88. ide  is  to  give  titlebars  in the same way as their string content. Moreover 
  89. sometimes  program  that  is  used to edit rsc files usually can generate files 
  90. with  defined  names  (i  think  the  best  is  Resource Master, because it can 
  91. generate files for C, GFA Basic and assembler). The work is easier, because you 
  92. operate on names, not "bare" object numbers which aren't very readable. 
  93.  
  94. Using of hte menubar
  95. After  loading  of the resorce file we need to fetch the address of the menubar 
  96. from rsc tree structure: 
  97.  
  98. int status;
  99. OBJECT  *menutree;  (don't  be  afraid  OBJECT is a structure of object used in
  100. resource file) 
  101.  
  102. status = rsrc_gaddr(R_TREE, MAINMENU, &menutree);
  103.  
  104. Here  MAINMENU  is  a  name  of  menubar  setted  in  rsc  editor. R_TREE gives 
  105. information  to  the function, that it has to seek the specific tree of objects 
  106. (it  can  seek  for several another things) and menutree is a pointer to object 
  107. structure, which will direct us to our seeked menubar. We can have mor than one 
  108. menu  structure  in  rsc  file  and change it as we like. In this case the best 
  109. solution will be when each menu structure will possess separate pointer. 
  110.  
  111. If status = 0 you have found the object, if not you have problem and you should 
  112. exit apllication immadiately. 
  113.  
  114. When you have the menu within you grasp, you have to display it:
  115. graf_mouse(256,&dummy);    (mouse off to not disturb the drawing of menu)
  116. status = menu_bar(menutree,1); (draw the menu)
  117. graf_mouse (257,&dummy); (mouse on!)
  118.  
  119. To hide the menu:
  120. graf_mouse (256,&dummy);    (mouse off to not disturb... )
  121. status = menu_bar(menutree,0); (erase menu)
  122. graf_mouse (257,&dummy); (switch on the mouse!!!)
  123.  
  124. If status > 0 there is an error occurred, if status = 0 everything is ok.
  125.  
  126. After  drawing  the menu, system handles drop-down menus and inverts the chosen 
  127. titles.  It  waits  only  for a mouse click and will be sending messages if the 
  128. need  for  redraw  of  menubar occurs. How menubar racts on the mouse click? It 
  129. simply sends the message! We should know something about the messages. Messages 
  130. that we should expect are looking like this: 
  131.  
  132. 0        10(it will be defined somewhere as MN_SELECTED, so you can use this)
  133.  
  134. 3       number of object for menu title
  135.  
  136. 4       number of object of menu position
  137.  
  138. The  last two should be defined in RSC file, generated by RSC editor so instead 
  139. of: 
  140.  
  141. if ((message[3]=5) AND ((message[4]=8)) then do_quit();
  142.  
  143. we can write:
  144.  
  145. if ((message[3]=FILE) AND ((message[4]=QUIT)) then do_quit();
  146.  
  147. After  proper  handling od the mouse click we have to return the menu to former 
  148. state: 
  149. status = menu_tnormal(menutree,message[3],1);
  150. if  status  < 0 then OK, if status=0 then error occured. After that some things 
  151. should be switched off, sometimes add "ticks" to menu entry. 
  152.  
  153. Switching on/off of menu entries
  154. Menu entries are switched when they aren't needed at given moment. (e.g lack of 
  155. save  option  if there is no document opened). We can change the tree structure 
  156. directly, but what for if we have: 
  157. status=menu_ienable(menutree, ITEMNO (or it's name), flag);
  158. flag=0 mark off; flag=1 mark on; status=0 if error;
  159.  
  160. If  we  want  to indicate something then we have to prepare extra free space in 
  161. menu  entry and move the text to the right a little. If we put the text outside 
  162. the menu the giant CRASH! will occur, so be warned (look out for what you do in 
  163. RSC editor). 
  164.  
  165. To put / erase indicator from menubar we have:
  166. status = menu_icheck(menutree,ITEMNO,flag);
  167.  
  168. flag=0 mark off; flag=1 mark on; status=0 if error;
  169.  
  170. Changing of text in menu entry
  171. Two  choices  are  here.  Thefirst one is direct modification of structure (the 
  172. only way for changing menubar titles). Second is the use of: 
  173.  
  174. char  *text;  (pointer  to  NULL  terminated  string,  it has to fit inside the 
  175. menubox. If it will not fit then CRASH!) 
  176. status = menu_text (menutree,ITEMNO, text);
  177.  
  178. <link=art50d.scr>Go to PART #4</l>
  179. </frame>
  180. </body>
  181.  
  182.