Difference between revisions of "Ide/Creating new Project Items/Creating a Menu"

From wiki.visual-prolog.com
(New page: <noinclude>Category:Ide</noinclude> ---- The '''Menu Editor''' can be used to create both pull-down menus (for windows), and pop-up menus (useful for object oriented user interfaces). ...)
(No difference)

Revision as of 10:58, 6 March 2013


The Menu Editor can be used to create both pull-down menus (for windows), and pop-up menus (useful for object oriented user interfaces).

Creating a New Menu

To create and register a new menu in a project you need to use the File | New menu command. In the opened Create Project Item dialog you should select the Menu type of created item. Then the dialog will accept the following shape:

Ide MenuNew.png

In this dialog you should specify the following items:

Name

In the Name field you should type in the name, which will be associated with this menu in the automatically generated code. This name should be a correct Visual Prolog name. It should be any sequence of letters, digits, and underscores, beginning with a letter. This name appears as the name of the files storing the menu description (with .mnu extension). This file appears in the project tree in the Project window.

Parent Directory

In the Parent Directory field you should type in the parent directory (the TaskWindow\ on the picture). The menu resource file will be placed into the selected directory.

Menu Attributes Dialog

After you press the OK button in the Create Project Item dialog, the Menu Attributes dialog appears.

Ide MenuAttributes.png

After clicking the OK button the new menu will be created and its name will be added to the list of menus existing in the current project. You can always go back and wake up (with the Resource | Attribute task menu item or with the Attribute item from pop-up menu) the Menu Attributes dialog for the menu. The only possible setting for menu attributes is:

  • Constant
    In this list edit the programmer can change the default resource constant for the menu (at the picture it is id_mymenu). A menu identifier must be unique throughout the project.
  • Resourse File
    In this read-only field the programmer can see the name of the file in which the creating menu resource will be stored.

Editing a Menu

To edit a menu, double-click (or press Enter) the name of a file with a menu description in the project tree in the Project window. For example TaskMenu.mnu. The Menu Editor dialog appears and you can create (or modify) whatever kind of a menu you wish.

Menu Editor

The Menu Editor dialog allows you to modify or delete existing menu items or add new ones. The main pane in this dialog contains the tree of menu items of the edited (it is TaskMenu in the picture) menu.

By pressing the New toolbar buttons it is possible to create new menu items and sub-items. You can use: Ide MenuEdit First.png - the New First Item, Ide MenuEdit New.png - the next New Item , and Ide MenuEdit Subitem.png - the menu New SubItem.

Menu items can optionally be grouped by inserting separators. To insert a separator just click the New Separator toolbar button Ide MenuEdit Separator.png.

Cut, Copy and Paste operations for selected menu items (with all their submenu items) can be executed with Ctrl+X, Ctrl+C, and Ctrl+V keyboard accelerators.

The Menu Editor can create nested menus of any level. To enter/create a submenu for the selected menu item click the Submenu button Ide MenuEdit Subitem.png.

By pressing the Test toolbar button Ide MenuEdit Test.png you activate the test mode in which the edited menu will be displayed instead of the main IDE menu. You can open it submenus, etc. To exit the test mode, you can click somewhere in the IDE window out of the tested menu.

Customizing Menu Item Attributes

In the bottom of the menu editor dialog you see the big pane (the Menu Tree pane) in which you can see the edited menu tree. Menu items prefixed with the plus Ide Plus Icon.png icon have submenus. Click the plus Ide Plus Icon.png icon or press the right arrow on the keypad to expand one level of such submenu. Notice that the plus Ide Plus Icon.png icon before expanded menu items is changed for the minus Ide Minus Icon.png icon.

When you select any menu item in the menu tree, the menu editor controls display attributes of this menu item. For each menu item the programmer can specify the following attributes:

  • Item Title
    Select a menu item in the Menu Tree pane and click the menu item title. The menu item title becomes surrounded by the frame like:
    Ide MenuEdit Title.png
    Here you can specify/edit the menu item title (name).
    • The menu item title may contain up to 255 characters. It may include the \t (tab) escape sequence.
    • In the menu item title the ampersand symbol & can be used for indicating that the following character is to be underlined. For example, if you type in the string &Contents, then at runtime this menu item will be displayed as Contents. I.e. the character C will be displayed underlined (thus visually indicating that the C is an accelerator key). The underlined character should be unique on each level of a menu. If you need to display the & character, use two &&.
  • Item Constant
    The Item Constant input box is where you can select or type in the symbolic (or integer) constant that will be used as the menu item identifier. It can be typed-in directly from the keyboard or selected from the list of available constants (by clicking the File:Ide ListButton button.png button). It must be either a legal symbolic constant (for example, id_help_contents) or an integer value.

    If you enter a symbolic constant name, then the IDE automatically places this symbolic constant into the resourceidentifiers.i file and generates an appropriate integer value for it. The Menu Editor automatically generates the default symbolic constant name (for example, id_file_exit) from the Constant Prefix id_file and names of menu items (Exit on the picture).
  • Constant Prefix
    The Constant Prefix edit control is where you can input a common prefix for all item constants of menu items on the current level of submenu.
  • Checked
    Set the initial state of the menu item to Checked.
  • Disabled
    Specifies that initially the menu item will be Disabled.
  • Accelerator
    In the Accelerator group box you can set an accelerator key (hot key), which will be used to activate this menu item. The accelerator key can be defined as a combination of a basic accelerator key and of the Shift, Ctrl, and Alt keys. The basic accelerator key can be typed in or chosen from the list in the list edit control. To specify the desired Shift, Ctrl, and Alt keys check on the corresponding check box. To assign more than one accelerator key to a menu item, use the vpi::setAccelerators/1 predicate.
  • Help Constant
    In this list button control you can select one of constants of the existing first-level menu items. The Windows (system handling) menu item (in MDI mode) will be placed just before the first-level menu item with this constant.

    Notice that this possibility can be used only for MDI applications. (It is ignored for non-MDI applications since they do not have the Windows (system handling) menu item.

Editing the Window Submenu

In MDI applications Windows automatically add the Windows first-level menu item, which, by default, is placed after (the most right) all other user-created first-level menu items in each application menu. By default, it contains the Tile, Cascade, and Arrange Icons menu commands and in the bottom of this menu are listed titles of all opened MDI document windows.

To customize items of the Windows submenu, the programmer should create a new menu with the Item Constant equal to mdiwindow_menu. This menu should include only one level of menu items. Notice that since this user-designed submenu will be used instead of the default system Windows submenu, so handling of ALL its menu commands should be explicitly programmed. For instance, handling of the Tile, Cascade, and Arrange Icons menu commands should be programmed if they are included into the designed menu.