home *** CD-ROM | disk | FTP | other *** search
- <head>
- <title="...forever...">
- <font=monaco10.fnt>
- <font=newy36.fnt>
- <font=time24.fnt>
- <image=back.raw w=256 h=256 t=-1>
- <buf=2582>
- <bgcolor=-1>
- <background=0>
- <link_color=000>
- <module=console.mod>
- <pal=back.pal>
- colors:
- 251 - black
- </head>
- <body>
- <frame x=0 y=0 w=640 h=2582 b=-1 c=-1>
-
-
- .: GEM in one pill :.
- -----------------------------
- 4) MENU BAR CONSTRUCTION
- ----------------------------
- GEM posses one menu bar, no matter how many applications are present. The look
- of the menu is set in RSC file. And what is that resource file you ask?
-
- Basically speaking it is a tree structure of objects. Main object is a "root",
- which has many subobjects (called "children"). The objects on the same level
- are called siblings. In what manner the tree of objects is organised? The main
- object is a rectangle of the size of the screen ( our desktop with the green
- background). After there are two children: white bar and all the objects that
- are inside of it.
- The white menubox has under each menutitle one child (or more), and box which
- has the desktop icons and others. With this little explanation, you know how
- easy is to put the images into desktop. All is needed to change the desktop
- background or exchange the root object with picture.
- The menu consists of several children of menu bar, which are menu titles. Under
- each tite there is a box and this box has it's own titles as it's children.
- Each menu title is a string object.
- Resource file structure:
-
- Root (G_BOX)-------------------------------+
- / |
- / |
- / |
- BAR ((G_BOX char+2 pixels of width)) |
- / |
- ACTIVE (G_IBOX) SCREEN (G_IBOX over rest of the screen)
- /|\ /|\
- MENU TITLES (G_TITLES) BOX (G_BOX contains drop-down menu)
- /\
- MENU TITLES
- (usually G_STRINGS, but can be each type)
-
- Single line has 1 children, several lines mean many children.
-
- That's all about resource files, now you have to use one of the several
- programs to design RSC files: Resource Master, WERCS, MKRSC.
-
- Resource file design guidelines
- During designing of resourcefile we have to bear in mind several guidelines.
- The very first title in menubar should have Atati logo, but when multitasking
- kernel was introduced there was decision to put in the name of the program, so
- the user will know which application he is actually using. This menu should
- contain "0 <program name>" followed by separator ("-------------" string with
- DISABLED attribute). After that there should be six empty strings for names of
- accessories.
-
- Next position in menubar should be "File" with following titles (you can skeep
- everything what is not needed): New, Open, Save, Save as.., Save all (option),
- separator, Import, Export, another operations on files (see below), separator,
- page settings, print, Output commands, separator, quit.
-
- Save all - saves all opened files
- Refresh - refreshes/redraws actual document/image or anything else
- another file operations - shouldn't contain format disk or delete file. File
- managment should be left to desktop or multitasking interface not application.
-
- Third title should be "Edit" with Undo, Redo, Copy, Insert, Delete, separator,
- Select All(option), separator, Find, Exchange, Find next(option), separator,
- the rest of edit options.
-
- Another things like "Save settings" and/or "Set preferences" should be in
- "Options" menu NOT "File" menu. The help shoul be far to the right. More about
- guidelines, you can read in Atari Compedium.
-
- After the designing of application's interface it is stored in RSC file. Good
- ide is to give titlebars in the same way as their string content. Moreover
- sometimes program that is used to edit rsc files usually can generate files
- with defined names (i think the best is Resource Master, because it can
- generate files for C, GFA Basic and assembler). The work is easier, because you
- operate on names, not "bare" object numbers which aren't very readable.
-
- Using of hte menubar
- After loading of the resorce file we need to fetch the address of the menubar
- from rsc tree structure:
-
- int status;
- OBJECT *menutree; (don't be afraid OBJECT is a structure of object used in
- resource file)
-
- status = rsrc_gaddr(R_TREE, MAINMENU, &menutree);
-
- Here MAINMENU is a name of menubar setted in rsc editor. R_TREE gives
- information to the function, that it has to seek the specific tree of objects
- (it can seek for several another things) and menutree is a pointer to object
- structure, which will direct us to our seeked menubar. We can have mor than one
- menu structure in rsc file and change it as we like. In this case the best
- solution will be when each menu structure will possess separate pointer.
-
- If status = 0 you have found the object, if not you have problem and you should
- exit apllication immadiately.
-
- When you have the menu within you grasp, you have to display it:
- graf_mouse(256,&dummy); (mouse off to not disturb the drawing of menu)
- status = menu_bar(menutree,1); (draw the menu)
- graf_mouse (257,&dummy); (mouse on!)
-
- To hide the menu:
- graf_mouse (256,&dummy); (mouse off to not disturb... )
- status = menu_bar(menutree,0); (erase menu)
- graf_mouse (257,&dummy); (switch on the mouse!!!)
-
- If status > 0 there is an error occurred, if status = 0 everything is ok.
-
- After drawing the menu, system handles drop-down menus and inverts the chosen
- titles. It waits only for a mouse click and will be sending messages if the
- need for redraw of menubar occurs. How menubar racts on the mouse click? It
- simply sends the message! We should know something about the messages. Messages
- that we should expect are looking like this:
-
- 0 10(it will be defined somewhere as MN_SELECTED, so you can use this)
-
- 3 number of object for menu title
-
- 4 number of object of menu position
-
- The last two should be defined in RSC file, generated by RSC editor so instead
- of:
-
- if ((message[3]=5) AND ((message[4]=8)) then do_quit();
-
- we can write:
-
- if ((message[3]=FILE) AND ((message[4]=QUIT)) then do_quit();
-
- After proper handling od the mouse click we have to return the menu to former
- state:
- status = menu_tnormal(menutree,message[3],1);
- if status < 0 then OK, if status=0 then error occured. After that some things
- should be switched off, sometimes add "ticks" to menu entry.
-
- Switching on/off of menu entries
- Menu entries are switched when they aren't needed at given moment. (e.g lack of
- save option if there is no document opened). We can change the tree structure
- directly, but what for if we have:
- status=menu_ienable(menutree, ITEMNO (or it's name), flag);
- flag=0 mark off; flag=1 mark on; status=0 if error;
-
- If we want to indicate something then we have to prepare extra free space in
- menu entry and move the text to the right a little. If we put the text outside
- the menu the giant CRASH! will occur, so be warned (look out for what you do in
- RSC editor).
-
- To put / erase indicator from menubar we have:
- status = menu_icheck(menutree,ITEMNO,flag);
-
- flag=0 mark off; flag=1 mark on; status=0 if error;
-
- Changing of text in menu entry
- Two choices are here. Thefirst one is direct modification of structure (the
- only way for changing menubar titles). Second is the use of:
-
- char *text; (pointer to NULL terminated string, it has to fit inside the
- menubox. If it will not fit then CRASH!)
- status = menu_text (menutree,ITEMNO, text);
-
- <link=art50d.scr>Go to PART #4</l>
- </frame>
- </body>
-
-