<< inputui GUI Tools

GUI Tools >> GUI Tools > menumaker

menumaker

Add menus to a figure

Calling Sequence

[h_menu] = menumaker(menus[,callbackFun][,f][,Flag])
[h_menu] = menumaker(menus) // creates a new figure with menus
[h_menu] = menumaker(menus,callbackFun)  // as above but also with callbackFun('Label') as callback

Parameters

menus:

list defining the menus to be added.

menu:

element in menus where menu=list(Label,callback,arg1,arg1val,....) or menu=list(Label,submenus)

Label:

string with the label name of a menu entry.

callback:

string containing the callback of the menu item. If callback='' then callbackFun will be used.

argn:

optional relevant arguments like Enable,Checked,ForgroundColor,Tag og Visible. See uimenu.

submenus:

list defining submenus item in a menu (submenus elements have the same structure as menu)

callbackFun:

optional string with the name of the callback function to be called as callbackFun('Label') if no callback is given for any particular item.

f:

optional figure handle. If empty then f=gcf().

Flag:

optional Flag=1 remove standard menus, Flag=2 remove Graphics menu or Flag3=remove both.

h_menu:

list of handles to the menus. Handles to sub menus are present as lists.

Description

menumaker is a tool for adding menus to figures and gui's with a minimum of programming.

The menu structure is defined using nested lists similar to the way gui's are defined in guimaker. See the Parameters section and the examples.

Examples

// Example from help uimenu
scf();
menus=list(list('windows',list('operations',...
list('new window','show_window()'),...
list('clear window','delete(gca())'))),...
list('quit scilab','exit'),...
list('$\LaTeX$',list('$\int_0^\infty\mathrm{e}^{-x^2}\,dx$',''),...
list('$\frac\sqrt{\pi}2$','')),...
list('MathML',list('<msup><mn>x</mn><mi>2</mi></msup>',''),...
list('<mrow><msup><mn>a</mn><mi>2</mi></msup><mo>+</mo><msup><mn>b</mn><mi>2</mi></msup><mo>=</mo><msup><mn>c</mn><mi>2</mi></msup></mrow>','')));
menumaker(menus,'messagebox');
//
// Example from the demo section GUI - Uicontrol1
scf();
menus=list();
menus($+1)=list('Application',list('Exit figure','close(gcf())'),...
list('Quit Scilab','quit'));
menus($+1)=list('Scilab Graphics',list('Launch plot3d','plot3d()'),...
list('Launch plot2d','plot2d()'));
menus($+1)=list('Menu',list('Sub menu 1','disp(''''Sub menu 1'''')'),...
list('Sub menu 2',list('Sub menu 2-1','disp(''''Sub menu 2-1'''')'),...
list('Sub menu 2-2','disp(''''Sub menu 2-2'''')')),...
list('Sub menu 3','if get(gcbo,''''checked'''')==''''on'''' then set(gcbo,''''checked'''',''''off''''); else set(gcbo,''''checked'''',''''on''''); end'));
menumaker(menus);
demo_viewCode('menumaker2.dem.sce');

See also

Authors

<< inputui GUI Tools