Package muntjac :: Package ui :: Module menu_bar :: Class MenuBar
[hide private]
[frames] | no frames]

Class MenuBar

source code

                          object --+                
                                   |                
                 util.IEventListener --+            
                                       |            
           terminal.paintable.IPaintable --+        
                                           |        
                              object --+   |        
                                       |   |        
  terminal.variable_owner.IVariableOwner --+        
                                           |        
                              object --+   |        
                                       |   |        
             terminal.sizeable.ISizeable --+        
                                           |        
                        component.IComponent --+    
                                               |    
                                  object --+   |    
                                           |   |    
event.method_event_source.IMethodEventSource --+    
                                               |    
            abstract_component.AbstractComponent --+
                                                   |
                                                  MenuBar

A class representing a horizontal menu bar. The menu can contain MenuItem objects, which in turn can contain more MenuBars. These sub-level MenuBars are represented as vertical menu.

Instance Methods [hide private]
 
__init__(self)
Constructs an empty, horizontal menu
source code
 
paintContent(self, target)
Paint (serialise) the component for the client.
source code
 
paintItem(self, target, item) source code
 
changeVariables(self, source, variables)
Deserialize changes received from client.
source code
 
addItem(self, *args)
Add a new item to the menu bar.
source code
 
addItemBefore(self, caption, icon, command, itemToAddBefore)
Add an item before some item.
source code
 
getItems(self)
Returns a list with all the MenuItem objects in the menu bar
source code
 
removeItem(self, item)
Remove first occurrence the specified item from the main menu
source code
 
removeItems(self)
Empty the menu bar
source code
 
getSize(self)
Returns the size of the menu.
source code
 
setSubmenuIcon(self, icon)
Set the icon to be used if a sub-menu has children.
source code
 
getSubmenuIcon(self) source code
 
setCollapse(self, collapse)
Enable or disable collapsing top-level items.
source code
 
getCollapse(self) source code
 
setMoreMenuItem(self, item)
Set the item that is used when collapsing the top level menu.
source code
 
getMoreMenuItem(self)
Get the MenuItem used as the collapse menu item.
source code
 
setAutoOpen(self, autoOpenTopLevelMenu)
Using this method menubar can be put into a special mode where top level menus opens without clicking on the menu, but automatically when mouse cursor is moved over the menu.
source code
 
isAutoOpen(self)
Detects whether the menubar is in a mode where top level menus are automatically opened when the mouse cursor is moved over the menu.
source code
 
setHtmlContentAllowed(self, htmlContentAllowed)
Sets whether html is allowed in the item captions.
source code
 
isHtmlContentAllowed(self)
Checks whether item captions are interpreted as html or plain text.
source code

Inherited from abstract_component.AbstractComponent: __getstate__, __setstate__, addCallback, addListener, addStyleName, attach, childRequestedRepaint, detach, fireComponentErrorEvent, fireComponentEvent, fireEvent, fireRequestRepaintEvent, focus, getApplication, getCSSHeight, getCSSWidth, getCaption, getComponentError, getData, getDebugId, getDescription, getErrorHandler, getErrorMessage, getHeight, getHeightUnits, getIcon, getListeners, getLocale, getParent, getStyle, getStyleName, getWidth, getWidthUnits, getWindow, handleError, hasListeners, isEnabled, isImmediate, isReadOnly, isVisible, paint, parseStringSize, registerCallback, registerListener, removeCallback, removeListener, removeStyleName, requestRepaint, requestRepaintRequests, setCaption, setComponentError, setData, setDebugId, setDescription, setEnabled, setErrorHandler, setHeight, setHeightUnits, setIcon, setImmediate, setLocale, setParent, setReadOnly, setSizeFull, setSizeUndefined, setStyle, setStyleName, setVisible, setWidth, setWidthUnits, withdrawCallback, withdrawListener

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  CLIENT_WIDGET = None
hash(x)

Inherited from abstract_component.AbstractComponent: SIZE_PATTERN

Inherited from terminal.sizeable.ISizeable: SIZE_UNDEFINED, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS, UNIT_SYMBOLS

Instance Variables [hide private]
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self)
(Constructor)

source code 

Constructs an empty, horizontal menu

Overrides: object.__init__

paintContent(self, target)

source code 

Paint (serialise) the component for the client.

Parameters:
  • target - the target UIDL stream where the component should paint itself to
Raises:
Overrides: abstract_component.AbstractComponent.paintContent

changeVariables(self, source, variables)

source code 

Deserialize changes received from client.

Parameters:
  • source - the Source of the variable change. This is the origin of the event. For example in Web Adapter this is the request.
  • variables - the Mapping from variable names to new variable values.
Overrides: terminal.variable_owner.IVariableOwner.changeVariables

addItem(self, *args)

source code 

Add a new item to the menu bar. Icon and command can be null, but a caption must be given.

Parameters:
  • args - tuple of the form
    • (caption, command)
      1. the text for the menu item
      2. the command for the menu item
    • (caption, icon, command)
      1. the text for the menu item
      2. the icon for the menu item
      3. the command for the menu item
Raises:
  • ValueError

addItemBefore(self, caption, icon, command, itemToAddBefore)

source code 

Add an item before some item. If the given item does not exist the item is added at the end of the menu. Icon and command can be null, but a caption must be given.

Parameters:
  • caption - the text for the menu item
  • icon - the icon for the menu item
  • command - the command for the menu item
  • itemToAddBefore - the item that will be after the new item
Raises:
  • ValueError

getItems(self)

source code 

Returns a list with all the MenuItem objects in the menu bar

Returns:
a list containing the MenuItem objects in the menu bar

removeItem(self, item)

source code 

Remove first occurrence the specified item from the main menu

Parameters:
  • item - The item to be removed

getSize(self)

source code 

Returns the size of the menu.

Returns:
The size of the menu

setSubmenuIcon(self, icon)

source code 

Set the icon to be used if a sub-menu has children. Defaults to null;

Deprecated: Icon is set in theme, no need to worry about the visual representation here.

getSubmenuIcon(self)

source code 

See Also: setSubmenuIcon

setCollapse(self, collapse)

source code 

Enable or disable collapsing top-level items. Top-level items will collapse together if there is not enough room for them. Items that don't fit will be placed under the "More" menu item.

Collapsing is enabled by default.

Deprecated: Collapsing is always enabled if the MenuBar has a specified width.

getCollapse(self)

source code 

See Also: #setCollapse(boolean) @deprecated

setMoreMenuItem(self, item)

source code 

Set the item that is used when collapsing the top level menu. All "overflowing" items will be added below this. The item command will be ignored. If set to null, the default item with a downwards arrow is used.

The item command (if specified) is ignored.

setAutoOpen(self, autoOpenTopLevelMenu)

source code 

Using this method menubar can be put into a special mode where top level menus opens without clicking on the menu, but automatically when mouse cursor is moved over the menu. In this mode the menu also closes itself if the mouse is moved out of the opened menu.

Note, that on touch devices the menu still opens on a click event.

Parameters:
  • autoOpenTopLevelMenu - true if menus should be opened without click, the default is false

isAutoOpen(self)

source code 

Detects whether the menubar is in a mode where top level menus are automatically opened when the mouse cursor is moved over the menu. Normally root menu opens only by clicking on the menu. Submenus always open automatically.

Returns:
true if the root menus open without click, the default is false

setHtmlContentAllowed(self, htmlContentAllowed)

source code 

Sets whether html is allowed in the item captions. If set to true, the captions are passed to the browser as html and the developer is responsible for ensuring no harmful html is used. If set to false, the content is passed to the browser as plain text.

Parameters:
  • htmlContentAllowed - true if the captions are used as html, false if used as plain text

isHtmlContentAllowed(self)

source code 

Checks whether item captions are interpreted as html or plain text.

Returns:
true if the captions are used as html, false if used as plain text