The C Designer ~~~~~~~~~~~~~~ by Nicholas Dyson By Way of Explanation- This programs purpose in life is to help with the annoying, but necessary, task of designing, defining and typing out the C structures for Intuitions windows, screens and menus. There is a window designer which will be of assistance to those of us who can never remember the right names for those IDCMP flags, and for those who cannot visualise the way their windows should look in their heads. There is a screen designer, for people who really find it necessary to "design" screens. And there is a menu designer which takes most of the drudgery out of this most tedious of tasks. In each case the program generates source code in the form of a text file which can then be included or inserted into your C programs. Instructions- 1. Main Screen- When you run the program you will be presented with a screen containing 4 buttons. These are marked with the names of the three services available in the program and the quit option. Just click on the button that contains the service you require. If you hit quit you will be asked to confirm this action. 2. Window Designer- When you enter this part of the program you will find a screen full of buttons and string gadgets. Never fear. IDCMP Flags-The first set of words represent the various options for IDCMP flags. Each word is a toggle select button. In order to select a flag just click on that word and it will be highlighted, click again and it will be de-highlighted. Window Flags-The next set are the window flags, these work in the same way as the IDCMP flags, just click on those options you want for your window. Screen Type-Next is the screen type option, the default here is WBENCHSCREEN, if you want your window in a custom screen click on the CUSTOMSCREEN button, if the button is not highlighted the window will be of type WBENCHSCREEN. Title- Enter the title for your window in the box marked "title". Click on the box and enter the title. Window Colours- To enter detailpen and blockpen click on the box so marked and enter the values you want, there is enough room to enter in decimal or hex. However if you want the standard workbench colours (4 and 1 respectively) don't bother putting in anything as these are the defaults. Size Ranges- To enter the min and max ranges click on the boxes and enter your values. Again you can enter decimal or hex values. These options also have default values which will be used in the save if you don't enter a value here, in the case of the min options the default is 0 for both width and height. The rom kernel manual states that a min value of 0 means that the min size is that of the original size of the window. The default value for both maximums is 0xFFFF which is as big as it gets. Dimensions- In order to set the initial dimensions for the window click on the button marked "Resize". You first be asked to chose a screen resolution, pick the one that corresponds to the resolution of the screen your window will be opened in. You will now find a screen with two windows in it. The one marked "Dimensions" contains the current dimensions and position of the other window. The other window represents the window you are designing, you can size it and re- position it until you are happy with it. If you make the window so small you cannot click on its resize gadget, simply This done, click on the close button in the Dimensions window and you will return to the main screen. If you make the window so small you cannot click on its resize gadget, simply quit to the window designer screen and click on "Resize" again, when you are asked for resolution chose a different screen res to the one you were previously working with and quit back once again to the window designer. Now if you go back into your original res you will find the window has grown to more manageable proportions. Saving- In order to save your creation, click on the save button. A lovely file requester will pop up. What will be saved are the options that are currently highlighted or entered, or, if no values have been entered and the text boxes are blank, the default values will be saved. Quiting- Once you get bored playing with your window click on the button marked "Quit", you will returned to the main screen. Returning to the main screen will not remove the options that you have already entered, they will still be there if you return to the window designer. Notes- You can enter values, click on flags and resize the window at any time and in any order. Any values that you don't enter will, when you save the window, be replaced by either a default value or the NULL value in the case of flags and the title. When resizing the window you will notice that the title that you are currently working with appears in the title bar of the sizing window, this is meant to help with sizing the window, the standard window gadgets that you selected for your final window will appear in the sizing window as well. Another thing about the sizing screen is that it is just that, a screen, separate from the screen that the rest of the program uses, I removed the drag bar at the top but you can still leave this screen by hitting "Left Amiga N", if you do this by accident just keep putting the screens to the back until you find the sizing screen again. Finally, there are 4 elements in the newwindow struct that the program does not attempt to set, these are FirstGadget, CheckMark, Screen and Bitmap, in the saved text these values will all appear as NULLs. 3. Screen Designer- If you want to knock out a quick screen, this bit of the program might come in useful, it certainly helps if you can't remember the screen structure itself. The layout of this bit is in the same vein as the window designer, but with less options. Screen width and leftedge cannot be altered by the user directly as these are fixed to the viewmode of the screen. Topedge- Click on the box marked "TopEdge" and enter the value you want. A value of 0 is already in there as that amount is practically always used. Height- Click on the box marked "Height" and enter your value, or alternatively click on the button marked "Maximum Height" which will instantly make the height value the max depending on what you currently have entered in "ViewModes". Depth- Same procedure as the other boxes, default value of 2 should already be in the box. A depth of 2 is for a standard workbench style screen. Pens- Again, these boxes already contain, as a default, the standard workbench colour registers. Viewmodes- The set of words marked "ViewModes" are another set of buttons, click on to select the option (and turn the background orange), click again to deselect. HIRES is already selected, standard workbench (surely nobody still uses lo-res screens). If LACE is selected clicking on the "Maximum Height" button will give a value of 512, off will give you 256. Screen Types- The set of words marked Types works the same way as the last batch, CUSTOMSCREEN is already selected as I don't know of any instance where it could be off, but its there just in case. Title- Enter your title here. Saving- Once everything is to your satisfaction, click "Save" enter the filename and hit "Okay". Quiting- Hit "Quit" to quit. Once again all your entries will remain as they are until you quit the whole program. 4. Menu Designer- The menu designer works in a similar way to the window and screen designers in that you enter all the parameters for the menus structures by clicking on gadgets and entering text in text boxes. In addition the menu you are designing appears on screen in a conceptual form in order to give you some idea about what you are creating. For the final output the program works out the best-fit dimensions for each menu, in fact all spacing, placing and sizing is calculated by the program so all you have to do is tell the program how many items each menu has, name them and enter their flags. It doesn't sound too clear yet does it. Read on. Add Menu Items- To start with all you will see is a rather unimpressive white box, this just represents a menu with one item in that doesn't have a name. To get more menu items click on the "Add A Menu Item" button. The box will expand downwards to show that more space for menu items is now available. Name Menu Item- In the aforementioned white box you will notice a white bar, this bar represents the current menu item, the details of this item are described by the gadgets on the right of the screen, among these gadgets if the text box marked "Item Name", this box contains the name of the current menu item. In order to change it click on the box and enter the new name, then press RETURN. If you don't press RETURN after entering text in this box the item name will remain unchanged. If you did it right the name will also appear in the current item bar. The program will also resize the menu box accordingly. Delete Menu Item- To remove a menu item, position the current menu bar over the item you wish to remove and click on the button marked "Delete Menu Item". You cannot delete the item if it is the only item in the menu. Name Menu- The name of the current menu appears at the top of the menu box on the right of the screen. It also appears in the text box marked "Menu Name". You can change the name at any time by clicking in the text box typing the new name and pressing RETURN. Change Current Item- In order to change the current menu item either up or down click on the buttons at the far left of the screen marked with arrows, these move the white bar up and down to show you the new current item. You can also use the keyboard, the up and down arrow keys perform the same function as the arrow gadgets. And if you get fed up with those options you can use the mouse to click on the menu item you want, the bar will move directly to the new item. Add Menus- You start with just one menu, in order to add more to the end of the menu list click on the "Add A Menu" button. The number at the top of the screen marked number of menus will increase by one. Beware, you cannot have more than 99 menus in this program. Change Current Menu- In order to move to another menu use the left and right arrow keys, or the left and right arrow buttons. The number marked "Current Menu Number" will change to display um well the current menu number of course. Delete Menu- If you want to remove a whole menu simply change the current menu to the one you want to get rid of and click on the button marked "Delete a Menu". You cannot delete the menu if it is the only one in the list and you cannot delete a menu whilst inside a sub menu. Add a Sub Menu- When your "current item" bar is on an item that has no sub menu the sub menu button will read "Add a Sub Menu". Click on the button and that item will now have a sub menu attached to it, this is represented by a "»" character at the left of the item. Delete a Sub Menu- When your current item bar is on an item that has a sub menu the sub menu button will read "Delete a Sub Menu". Click on the button and the sub menu and all its items will be removed. Enter a Sub Menu- If you want to make a sub menu the current menu so you can edit it you have a number of options. From the keyboard hit the RETURN key while the current item bar is over the item with a sub item. With the mouse, place the pointer over the item with the sub item you want and press the right(menu) mouse button. Or even hit the button at the right between the two big up and down arrows marked with a "»" character. Once in the sub menu you will not be able to add or delete or change the name of a menu, though you can edit menu items as normal. Leave Sub Menu- To leave the sub menu hit the left arrow key or the left arrow button at the top of the screen or the button at the right which should now be marked with a "«". Change Menu Item Flags- The menu item flags can be changed in the same way as the flags in the other parts of this program. Just click on the flag you want, this will highlight it to show it has been selected, click again and it is de-selected. Each menu item is created with the ITEMENABLED and HIGHCOMP flags already selected as these are the most common. The ITEMTEXT flag is non user-selectable, but is always saved as a default because all the menus created with this designer are of type ITEMTEXT. Add a COMMSEQ- If you want your menu item to have a COMMSEQ, enter a letter into the box marked "Commseq" and press when the current menu item is the one you want the commseq to be associated with. The commseq does not appear on the graphical representation but it will re-appear in the Commseq box the next time that item is selected. Also, don't worry about the commseq affecting the width of the menu, the program works out the best fit for your item text and commseqs. Saving- To save your creation click on the button marked "Save". The program will save two versions of your menu system. The first will have the proper filename you gave the file requester and will contain the actual ascii text defining in C code your menu for inclusion in your C program. The other will be given your filename plus the extension ".TOK", this file contains your menu structure in a binary, tokenised format that you can use to load back into the C Designer at a later date. Loading- As I already mentioned, you should have a tokenised file from when you saved your menus called .TOK, to load this into the program and continue working on it click on the button marked "Load" (patronising stuff this) whereupon you will be presented with a pretty file requester. Find your file with .TOK on the end and load it in. Bear in mind that this will remove all the menus that you currently have in the program, there is no requester that pops up to ask you if you are sure you want to do this, but if you hit the load button by mistake just click on "Cancel" at the file requester and everything will be okay. By the way, don't try to load in the text file from a previous save, or any other kind of file for that matter apart from the proper tokenised file. The program does check to see if it's the right kind of file, but it doesn't check very hard so err on the side of caution just in case it doesn't spot your mistake. Clearing- If you get fed up with what you're doing click on the "Clear" button and you will be freed of the monster you have created. Notes- Okay so its not perfect, it can't handle mutual exclusion, images, fancy item positioning, different fonts or any kind of weird stuff, but for those of us who want to "bash" out a quick menu system or try out some new ideas it works just fine. There is no memory checking so if you're working in a very low memory situation then watch out. Along with the menu definition a text attribute (TextAttr) definition is also saved, this is there to ensure that the topaz 80 font is used with the menu, if you want to change the definition to use a different sized font there is an example of how to do this in the "Libraries and Devices" book, I know that's a bit lame so I'll try and sort it out in a later version. About the Author - Nicholas Dyson is a singularly unimpressive human being who likes to listen to Led Zeppelin on his sterio whilst using his computer, and is therefore understandably annoyed by games that have music built into them. He would also like to give a tip of the hat to Paul, Scott, Colin, Big Stu (the man) and William (who said it looked quite good) all without whom this program would still have been entirely possible. Oh, and woof to Pink the Alien, wherever he may be. For those who really want to know, this program was written and compiled on a 2 meg A500, kitted up with a 90 meg SCSI and an external floppy, using Lattice C V5.10. 136 Craiglea Drive Morningside Edinburgh, EH10 5PR