Post 6- Retro C IDE – Menus

The TUI Library has functions to add menus to CC65 C programs.  Adding menus function in the Retro C IDE is explained in this post.  The TreeView object is Visual Basic is being used to make adding menus easy.  The first step is to click on the Menu’s Checkbox in the Window Definition group.  This will show the Menu Definition group where the menu is added.

rci16

The menu system allows for two levels of menus, a top level which is visible across the top of the window and each of those top level menu items can have a sub menu level as seen below.  To see this menu in action take a look at this youtube video

rci23

Let’s walk through building this menu which is show for a Commodore Plus/4, but it works the same for all target systems.  There are four options in the Menu Definition Group:

Add Menu – this adds a top level menu
Add Sub Item – this adds a sub menu item for the selected top level menu item
Rename – this allows the renaming of any level menu item
Remove – this removes menu items, if a top level menu is removed so are the sub level items

When Add Menu is clicked a text entry box is displayed and the name of the menu should be entered, once complete it shows in the menu tree.

To add sub menu items the top level item should be selected in the tree then clicking the Add Sub Item button will bring up a text entry box for adding the item. You will have to click on the “+” in front of the top level menu item to show the sub tree.

In order to be able to exit out of the menu you can designate one or more items as “exit items”.  For now just double clicking on an item will assign this designation and generate the appropriate call back function this this to work.  As the IDE enhances this functionality will become one of several options for call back functions for a menu item which is the key usage for the menu and the TUI library.   In the picture below the Exit sub menu item was double clicked and now will be used to exit the menu system.

rci22

For those who are interested below is the C code that is generated from this menu:

rci24

The top arrow points to the call  back function that sets the window property “quitflag” =1 1 which the menu processing routine will use to exit out.  The code in the box are all the function calls to build the top and sub level menu items.  The last parameter in the call is the pointer to the callback function for that menu item.  The second arrow points to the Exit sub menu item we picked as an exit item and the rci_quit is the pointer to the function described above.  Once all the menus are set up, a call to showmenu() displays the top level menu.  Finally the do loop activates the menu system processing and using the previously discuss quitflag property to exit the loop.

The next two posts will be a Mid Point update followed by adding objects to applications using TUI Library and Retro C IDE.

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s