Decoration consis in adding objects to DFrame.
Those objects have no specific constructors and are alyway created with methods of DFrame of Bar objects.
All those methods return an
object corresponding to the method used:
var bar = dFrame.addBar()
var button = bar.addButton()
var menu = bar.addMenu()
A bar (Bar object) is a
rectangular surface, being able to have borders and a background color different
from the DFrame that contains it or to remain invisible. It can be placed in
top, in bottom, on the left or on the right sides of the DFrame or be
positioned at a precise place. These parameters are indicated in the style used
at the time of the instantiation of the bar.
Its role is primarily to
contain buttons and menus.
Example :
//Create a barStyle
var barStyle = new BarStyle();
barStyle.setPos('LEFT')
barStyle.setBackgroundColor('red')
//set position as null (position of barStyle will be used)
var position = null
//add the bar to the dFrame
dFrame.addBar(position, 'title of the bar', barStyle)
A button (Button object)
allows launching actions. As for the bar it will be defined by a Style. In
complement the caption of the button and the corresponding action will be
specified.
The action can refer to a
DFrame method or launch the execution of a function stored in the principal
page (mainPage) or in the page inserted in the DFrame. These various possibilities
are detailed in another section of this document.
Example :
var buttonStyle = new ButtonStyle() ;
buttonStyle.setActivateOn('OVER');
buttonStyle.setBordersWidth(2);
//Action of the button calls a method of the dFrame object containing the button
bar.addButton('Close', 'thisDFrame.closeFrame()', buttonStyle);
or
//Action of the button calls a function in mainPage
bar.addButton('Go', 'functionGo()', buttonStyle);
or
//Action of the button calls a function in the page inserted in the DFrame
bar.addButton('Go', 'thisDFrame.window.functionGo()', buttonStyle);
Menus are groups of Buttons.
There are two kinds of Menus:
Pop-up Menus, which corresponds to the usual menus of the graphic interfaces
(File, Edit...) and tree Menus that corresponds more with tree structures.
Pop-up Menus have an additional
button that will set the menu visible when clicked.
The syntax of instantiation is
simple but uses a structure of arrays of arrays:
//Define arrays for a sub pop-up menu
subPopUpMenu = new Array()
subPopUpMenu[0] = new Array('Button', 'New document', 'newDocFunction()')
subPopUpMenu[1] = new Array('Button', 'Open', 'openDocFunction()')
//Define arrays for the main pop-up menu
var popUpMenu = new Array()
popUpMenu[1] = new Array('Button', 'Documents', subPopUpMenu)
popUpMenu[2] = new Array('Button', 'Exit', 'exitFunction()')
//Create the styles for the button of the menu and the menu itself
var buttonStyle = new ButtonStyle();
var menuStyle = new MenuStyle();
//Add the menu to a bar
bar.addMenu(popUpMenu, menuStyle, 'File', buttonStyle);
Context Menus are pop-up Menus
associated with DFrames. They are shown when the user click on the right button
of his mouse.
Once the array defining a Menu
is specified the syntax of instantiation is simple:
dFrame.addContextMenu(popUpMenu, menuStyle)