## Default Styles

Default Styles are used in two cases:

§ when the Style is omitted in the instantiation syntax.

§ when dFrameAPI automatically creates a default Bar.

### Omitted Styles

The common way to add an object to another one is to set the Style as a parameter of the add methods:

(Task Menus and task Bars used below are object whose Buttons, automatically created by DFrameAPI, correspond to a created DFrame)

var button = bar.addButton(caption, action, buttonStyle)

or

var menu = bar.addMenu(menuDefinitions, menuStyle, buttonCaption, buttonStyle)

var menu = bar.addTaskMenu(menuStyle, buttonCaption, buttonStyle)

or

var menu = dFrame.addContextMenu(menuDefinitions, menuStyle)

var bar = dFrame.addBar(position, title, barStyle)

var bar = dFrame.addTaskBar(position, title, barStyle)

However it is possible to add objects without indicating the Style:

var button = bar.addButton(caption, action)

or

var menu = bar.addMenu(menuDefinitions, null, buttonCaption, null)

var menu = bar.addMenu(null, buttonCaption, null)

or

var menu = dFrame.addContextMenu(menuDefinitions)

var bar = dFrame.addBar(position, title)

var bar = dFrame.addTaskBar(position, title)

are correct syntaxes.

In those cases default Styles of the parent object (Bar for Buttons and Menus, DFrame for Bars) will be used.

The default Styles are created with the setDefaultXXXStyle:

var buttonStyle = new ButtonStyle()

buttonStyle.setBordersWidth(1)

var barStyle = new BarStyle

barStyle.setDefaultButtonStyle(buttonStyle)

will create the default ButtonStyle for barStyle.

The default Styles and the corresponding methods are:

For MenuStyle:

§ Default ButtonStyle: The default ButtonStyle used with the addMenu methods (on DFrame, Bar and BarLayer) to define the default Style of the Button when creating a pop-up Menu.

§ Default Title BarStyle : The default BarStyle used with the Menu.addTitleBar or MenuStyle.setTitleBar methods.

§ Note that the MenuStyle has an itemsStyle created from a ButtonStyle. This itemsStyle is a kind of default Style as it will be used to create items of the Menu and the developer has no other way to define the Style of those items

For BarStyle:

§ Default ButtonStyle: The defaultButtonStyle used with the addButton method on DFrame, Bar and BarLayer

§ Default MenuStyle: The default MenuStyle used with the addMenu and addTaskMenu methods on DFrame, Bar and BarLayer.

§ Default Title BarStyle : The default BarStyle used with the Bar.addTitleBar or BarStyle.setTitleBar methods.

For DFrameStyle:

§ Default BarStyle : The default BarStyle used with the DFrame.addBar method

§ Default Task BarStyle: The default BarStyle used with the DFrame.addTaskBar method.

§ Default Title BarStyle : The default BarStyle used with the DFrame.addTitleBar or DFrameStyle.setTitleBar methods.

§ Default Context MenuStyle : The default MenuStyle used with the DFrame.ContextMenu method.

As all properties of Styles, default Styles and properties of those default Styles are initialized as soon the Style is instantiated.

They can be accessed with the getDefaultXXXStyle (same syntaxes as the set methods) methods:

dFrameStyle.getDefaultBarStyle()

will return the default BarStyle of DFrameStyle.

Example:

As a BarStyle has a default ButtonStyle this syntax will return the default ButtonStyle of the default BarStyle of dFrameStyle:

dFrameStyle.detDefaultBarStyle().getDefaultButtonStyle().

Note that is it possible - and often useful - to get a Style from an object:

dFrame.getStyle().getDefaultBarStyle().getDefaultButtonStyle().

This syntax will only work if the object has its own Style when this method is launched. See getStyle() for more information

Note that there is no default task MenuStyle: The default MenuStyle used with the DFrame.addTaskMenu method will the default MenuStyle of the DFrame.

### DefaultStyle for defaultBar

The normal way of creating objects is hierarchical:

Only one object is created with the 'new' constructor, the DFrame object:

var dFrame = new DFrame(parameters)

Bars are added to the DFrame:

var bar = dFrame.addBar(position, title, style)

Buttons and Menus are then added to Bars :

var button = bar.addButton(text, action, style)

var menu = bar.addMenu(menuDefs, style)

However there are shortcut methods that allow to add Buttons and Menus directly to DFrames:

var button = dFrame.addButton(text, action, style)

var menu = dFrame.addMenu(menuDefs, style)

In those cases a default Bar is created.

As all objects the default Bar needs a Style to be created and the default BarStyle of the DFrame will be used.

### Comments:

§ The default BarStyle of the DFrameStyle has 2 roles:

§ As a definition of BarStyle for the DFrame.addBar method used without Styles parameters,

var bar = dFrame.addBar()

§ As a 'container' of ButtonStyle and MenuStyle for creations of Buttons and Menus on DFrames:

var button = dFrame.addButton(text, action) uses the default ButtonStyle of the default BarStyle.

§ In the same way the default task BarStyle (created with the DFrame.setDefaultTaskBarStyle method) will be used when adding a task Bar and when dFrameAPI will add buttons corresponding to tasks to this Bar.

§ As Buttons and Menus (except the context Menu) are always created on Bars there is no default ButtonStyle and default MenuStyle for a DFrameStyle. The defaultContextMenuStyle will be used as default Style for the DFrame.addContextMenu method.

DFrameStyle and BarStyle can have a default title BarStyle to define title Bars. See setDefaultTitleBarStyle for more information.