Menu Bar and Popup Menu


 

This chapter introduces the menu components, namely the elements that display a list of options using pull down entities.   Menu Bar and Popup Menu belong into this group, in fact a menu bar is composed of a number of pull down menus activated by buttons. The behavior of a pull down menu is exactly the same as a popup menu.

BAR Menu

A menu bar is a region where computer menus are housed. Its purpose is to hold specific menus which provide access to functions such as opening files, interacting with an application, or help. Menu bars are typically present in graphical user interfaces with windows, so in Eagle v.14 this element has been implemented and updated to follow the evolution of GUI, but menu bar additionally provides many features not supported by default:

 

Horizontal Docking

Vertical Docking

Floating

menutop

menuleft

menufloat

 

 

1

Click menu

2

Show menu

3

Select option

4

Execute option

5

Next reload

 

 

 

 

 

 

 

Themes less than or equal to Window Xp Native

Themes greater than  or equal to Office 2007 Release 1

 

 

Using the “BAR_EXPANDABLE” entry in the configuration file developers can choose between the new (accordion style) or classical menu behavior.  If the entry is omitted, the new style is the default presentation.

 

INI Sample :

 

 

BAR_EXPANDABLE = yes | no

 

If the new features behavior is enabled, then all menus and popups in the application will be displayed with hidden items, the chevron button and exhibit the display behavior that consists of a short delay before displaying the least used options.   If the BAR_EXPANDABLE is set to “no” every menu will be displayed using the standard presentation without any of the new elements.

 

Classic (BAR_EXPANDABLE=no)

New (BAR_EXPANDABLE=yes)

 

Similarly it’s also possible to enable or disable the undocking mechanism of the menu bar by using the “BAR_DOCKING_ENABLED” configuration setting.  If this option is set to “yes” then the  bar can be undocked, otherwise the bar always remains docked at the top of the main frame.  The default setting for this option is “yes”.

 

INI Sample :

 

 

BAR_DOCKING_ENABLED = yes | no

 

 

The Menu Bar is created and destroyed with the bar command (BAR ON and BAR OFF).

Prototype :

 

 

 

bar      

on|off {,f=<file>}

 

where:

Parameter

Description

on

To define a new bar menu or redefine an existing one.

off

To dismount an installed bar menu.

f = <file>

The name of the file (extension .TAB) where the list of all the cascade menus is stored.

 

Sample Code :

 

 

bar off

bar on, f=mybar.tab

 

A menu bar is created by defining entries in a .tab file that contains a catalog of .men files :

 

File Sample:

 

 

 

mybar.tab

file.men

edit.men 

search.men 

project.men 

window.men

 

This files .tab contains five cascade menu; these menu can have options and submenus.

 

A file which describes menu (.men),  can contain different kinds of objects, the next table reports the list of items and the related code template:

 

 

Description

Code Template

1

simple menu item

index,'text' : command;

2

option with an icon

index, 'text@file.bmp': command;

3

check item that shows the enabled/disabled status

index ,'text#on': command;

or 

index ,'text#off': command;

4

cascade submenu

index ,'Text'> file.men

5

separator

index ,''&

6

disabled element (one of previous); the option starts frozen

-index,'text': command;

Note : NEGATIVE INDEX

7

List of active document windows at the end of the menu

999 ,''

 

 

 

To set the title of the menu (for instance Caption2), the first row of the menu file will consist of  a string with the text for the title.

Furthermore the Menu Bar allows definition of shortcut-keys to quickly access an option from keyboard accelerators. In order to use shortcut-keys you must introduce an ampersand " & "  before the character that identifies the accelerator (i.e.  'C&aption2' or 1,'&Command 1' : vane).

Just by adding # symbol followed by the name of the string variable that represents the status (eg.: turnit). If the value of the turnit variable is ‘on’ then, when displayed, the menu will show the checked symbol, otherwise if the value is ‘off’ then nothing will be shown.

File Sample:

 

 

 

 

33,'OpenGl graphics#turnit': do turnit

 

Clarification of the layout concepts contained in the the .men file illustration above are presented below :

File Sample:

 

 

 

cap2.men

'C&aption2'

1,'&Command 1' : vane 

2,'C&ommand 2': plan 

3,''& 

4,'Cascade'> sub1.men 

5,''& 

6,'popup':popup cap1 

7,'On/Off direct#on': tell'on/off...dir!' 

-8,'Co&mmand 3@binocolus.bmp': get $test; 

9,'Comm&and 4@se12.bmp': fit; 

10,'OpenGl graphics#TURNIT': do turnit

 

Up to sixteen options can be specified. If an option in an active bar menu is changed, i.e. a string variable referring to an option is altered, it is no longer necessary to issue the bar off command and then reissue a bar on.  Just issue the bar on,f=<filename>.tab again and the bar menu will be updated.

In Eagle v.14, when a Menu Bar is floating, it is also possible to use the close button in the same way as other control bars. So when the X button in the caption is pressed, Eagle calls the event defined in the entry BAR_CLOSE_ACTION of the INI file.

INI Sample :

 

 

BAR_CLOSE_ACTION = C:\MyFolder\closebar.cmd

 

The bar menu or parts of the bar menu can be frozen or unfrozen using the FREEZE and UNFREEZE commands :

Prototype :

 

 

 

freeze mb

, p=<panel>, b=<button>

 

where:

Parameter

Description

p

[Optional] Is the menu number in a range from 1 to the amount of items in the menu bar.

b

[Optional and need p] Is the index of the option inside the popup menu specified using the p parameter.

 

Prototype :

 

 

 

unfreeze mb

, p=<panel>, b=<button>

 

where:

Parameter

Description

p

[Optional] Is the menu number in a range from 1 to the amount of items in the menu bar.

b

[Optional and need p] Is the index of the option inside the popup menu specified using the p parameter.

 

Observing the prototypes for the freeze and unfreeze command, we can understand that its possible to freeze/unfreeze :

 

 

 

 

Sample Code :

 

 

freeze mb

unfreeze mb 

freeze mb, p=2 

unfreeze mb, p=2 

freeze mb, p=1, b=3 

unfreeze mb, p=1, b=3

 

Eagle V14 allows appending the list of the current active document windows; not available when in SDI mode; to a menu of the menubar.

When the special option 999 is added to a “*.men” file , the window list will be applied at the end of the menu; if there is more than one defined , only the last will be considered. A marker will be displayed adjacent to the active window enabling the user to change the current document by selecting another appropriate document item from the list; for instance:

Sample Code :

 

 

File “.men” of the menu 4 that contains the list document windows  

 

'Men&u_4'

1,'&Command 1' : vane

2,'C&ommand 2': plan

3,''&

999,''

5,''&

6,'popup':popup cap1

 

 

POPUP Menu

The other component introduced in this section is the Popup Menu.  In v14, as in previous versions,you  can call and activate a multiple choice Window based "recursive" popup menu.  Recursion means that an option in the menu file can activate a sub-popup menu in a recursive fashion, using appropriate widgets available in the windowing system.  The configuration is located in the appropriate .men file (the same used in bar menu) with each option followed by a desired action, so like in Menu Bar it is possible to add icons and status symbols (Images and markers) to the text descriptive options in popup menus :

 

 

The left button of the mouse is used to select an option from the menu.   If the left button is pressed outside the menu it is then de-selected thereby enabling the user to move the menu using right button.  Sub menus are activated moving the cursor above the options "marked" with an arrow on the right. During the "moving" phase all the exposed widgets are available for selection. Left clicking outside a popup menu causes the popup to exit.

 

Prototype :

 

 

 

popup

<file>

 

where:

Parameter

Description

<file>

The name of the file containing the menu. The default extension is men..

 

 

As we have seen before the format for the menu file takes the format:

File Format:

 

 

'title'

index, 'text':<commands> 

index, 'text'><sub-menu file> 

index, 'sub title'&

 

Obviously, if index is -1 then the option is disabled, i.e. it is half-toned and not selectable.

The first row, without index, represents the title for the popup menu; only one line is accepted, further lines are ignored. The user can chose to allow for no title in popup menus set through the environment variable called POPUP_IGNORE_TITLE. Default value is no, so popup with title.

INI Sample :

 

 

POPUP_IGNORE_TITLE = no | yes

 

 

Note that if the same popup file (<file>.men) is called recursively, the error/warning message is: File not found <file>.men.

The "Popup Menu", like the bar menu, also follows the currently selected theme.