Properties

From Wiki
Jump to navigationJump to search


Name and Title

Every control element has its own name that can be queried using the following model property:

Model.Name (String)
control element name

You can specify the title that appears in the title bar of a dialog with the following model property:

Model.Title (String)
dialog title (only applies to dialogs)

Position and Size

You can query the size and position of a control element using the following properties of the model object:

Model.Height (long)
height of control element (in ma units)
Model.Width (long)
width of control element (in ma units)
Model.PositionX (long)
X-position of control element, measured from the left inner edge of the dialog (in ma units)
Model.PositionY (long)
Y-position of control element, measured from top inner edge of the dialog (in ma units)

To ensure platform independence for the appearance of dialogs, OpenOffice.org uses the Map AppFont (ma) internal unit to specify the position and size within dialogs. An ma unit is defined as being one eighth of the average height of a character from the system font defined in the operating system and one quarter of its width. By using ma units, OpenOffice.org ensures that a dialog looks the same on different systems under different system settings.

If you want to change the size or position of control elements for runtime, determine the total size of the dialog and adjust the values for the control elements to the corresponding part ratios.

Documentation note.png The Map AppFont (ma) replaces the Twips unit to achieve better platform independence.

Focus and Tabulator Sequence

You can navigate through the control elements in any dialog by pressing the Tab key. The following properties are available in this context in the control elements model:

Model.Enabled (Boolean)
activates the control element
Model.Tabstop (Boolean)
allows the control element to be reached through the Tab key
Model.TabIndex (Long)
position of control element in the order of activation

Finally, the control element provides a setFocus method that ensures that the underlying control element receives the focus:

setFocus
control element receives the focus (only for dialogs)

Multi-Page Dialogs

A dialog in OpenOffice.org can have more than one tab page. The Step property of a dialog defines the current tab page of the dialog whereas the Step property for a control element specifies the tab page where the control element is to be displayed.

The Step-value of 0 is a special case. If you set this value to zero in a dialog, all of the control elements are visible regardless of their Step value. Similarly, if you set this value to zero for a control element, the element is displayed on all of the tab pages in a dialog.

Designing Page 1 of the dialog

In the preceding example, you can also assign the Step value of 0 to the dividing line as well as the Cancel, Prev, Next, and Done buttons to display these elements on all pages. You can also assign the elements to an individual tab page (for example page 1).

The following program code shows how the Step value in event handlers of the Next and Prev buttons can be increased or reduced and changes the status of the buttons.

Sub cmdNext_Initiated

   Dim cmdNext As Object
   Dim cmdPrev As Object

   cmdPrev = Dlg.getControl("cmdPrev")
   cmdNext = Dlg.getControl("cmdNext")
   cmdPrev.Model.Enabled = Not cmdPrev.Model.Enabled
   cmdNext.Model.Enabled = False
   Dlg.Model.Step = Dlg.Model.Step + 1

End Sub

Sub cmdPrev_Initiated

   Dim cmdNext As Object
   Dim cmdPrev As Object

   cmdPrev = Dlg.getControl("cmdPrev")
   cmdNext = Dlg.getControl("cmdNext")
   cmdPrev.Model.Enabled = False
   cmdNext.Model.Enabled = True
   Dlg.Model.Step = Dlg.Model.Step - 1

End Sub

A global Dlg variable that references an open dialog must be included to make this example possible. The dialog then changes its appearance as follows:

Page 1
Page 2
Tip.png You can find an other OOoBasic example here.



Dialogs supporting several languages

The strings of a Dialog can be localized, see the Developer's Guide chapter Dialog Localization. fr:FR/Documentation/BASIC Guide/Properties hu:HU/Documentation/BASIC Guide/Properties it:IT/Documentation/BASIC Guide/Properties ja:JA/Documentation/BASIC Guide/Properties zh:ZH/Documentation/BASIC Guide/Properties


Content on this page is licensed under the Public Documentation License (PDL).