Ide/Creating new Project Items/Creating a Toolbar
The Toolbar editor allows you interactively create various kinds of toolbars.
- 1 Creating a Toolbar
- 2 Editing a Toolbar
Creating a Toolbar
To create and register a new toolbar in a project you need to use the File | New menu command. In the opened Create Project Item dialog you should select in the left pane the Toolbar type of created item. Then the dialog will accept the following shape:
New Toolbar Dialog
- In the Name field you should type in the name, which will be associated with this toolbar in the automatically generated code. This name should be a correct Visual Prolog name. It should be any sequence of letters, digits, and underscores, beginning with a letter. This name appears in names of files generated for handling the toolbar. These files appear in the project tree in the Project window. The Code Expert uses this name for generation of the name of class, which handle the toolbar.
- You should check one of the New Package or Existing Package radio buttons to specify whether the generated resource file and class, which handle the toolbar, will be included to the new package that will be created or will be included to the existing one.
- If you check the New Package radio button, then you should type in the directory name in the Parent Directory field; it is (TaskWindow\) in the picture. The package and the toolbar handling files will be created and placed into the parent directory.
- If you check the Existing Package radio button, then in the Package list button you should select one of the packages known to the project (the TaskWindow.pack in the picture). The files handling the created toolbar will be included into this package. The created files will be placed into the selected package subdirectory. The name of this subdirectory is displayed after the package name; it is (TaskWindow\) in the picture.
Toolbar Attributes Dialog
After you press the OK button in the Create Project Item dialog, the Toolbar Attributes dialog appears.
The possible settings for a toolbar are:
- There are several toolbar styles. And since the layout of a toolbar simply shows the order of the controls it is easy to change the toolbar style.
- The toolbar Style can be one of the following:
|Toolbar Style||Toolbar Location|
|Top||Placed at the top of window|
|Left||Placed at the left side of the window|
|Bottom||Placed at bottom of window|
|Right||Placed at the right side of the window|
|Inside||Placed at a fixed location inside the window. (The Graphics Editor uses several of these)|
|Movable||A floating toolbar, which the user can move around|
- Try to change the toolbar style to see the various layouts.
- Sets the title for the toolbar. It is disabled for all toolbar styles except for the Movable.
- Shows the toolbar position. The position can be set for the Inside and Movable toolbar styles.
- This group box contains the read only Class Name text field and the Update Code push button.
- Class Name
- In this read-only control you can see the name of the class in which the IDE places the default code for the toolbar.
- Update Code
- Click this push button to enforce code updating.
After clicking the OK button the new toolbar will be created and its name will be added to the existing toolbars for the current project. You can always go back and wake up the Toolbar Attributes dialog (with the Resource | Attribute task menu item or with the Attribute item from pop up menu) for the toolbar to change any of the toolbar attributes.
Editing a Toolbar
To edit a toolbar, double-click (or press Enter) the name of a file with a toolbar description in the project tree in the Project window's list of project files. The Toolbar Editor window appears and you can create whatever form of a toolbar you wish.
In the top of the picture you see edited toolbar (ProjectToolbar in the picture).
In the bottom of the previous picture you see the [Controls_Toolbar_in_the_Toolbar_Editor.htm Controls] toolbar. Using the [Controls_Toolbar_in_the_Toolbar_Editor.htm Controls] toolbar you can easily add desired controls into the edited toolbar.
Control Types Used in Toolbars
In the lower part of the previous picture we see the [Controls_Toolbar_in_the_Toolbar_Editor.htm Controls] toolbar, which contains all kinds of controls that can be used in toolbars.
|Push Button||This is a standard push button. When pressed it sends an vpiDomains::e_Menu event to the parent window. The bitmap must be registered for the button.|
|Check Button||This is used to indicate the state of a property that can have two states; either checked or unchecked. When pressed it sends an vpiDomains::e_Control(_, vpiDomains::wc_CheckBox,_,_) event to the parent window. You must register a bitmap for a check button.|
|List Button||A list button can be used to select one item from a number of values. When pressed it sends an vpiDomains::e_Control(_, vpiDomains::wc_LBoxButton,_,_) event to the parent window.|
|Static Text||Text may be placed in this control initially and also dynamically. A Static Text is often used for titles.|
|Context Sensitive Text||If a Context Sensitive Text field is put into the toolbar, this field will display help information about the control the mouse is currently located over.|
|Separator||A separator is like a space; it is used to make some space and a vertical bar between other controls, usually to divide them into functional groups.|
|New Row||New row is relevant only for toolbars with the styles Inside and Movable. A New Row control will cause the current line to break, and the following controls to appear on the next line of the toolbar.|
Toolbar Layout Editing
The layout of the toolbar can be done both with the keyboard, and with the mouse. There is an insertion point that is marked with a colored bar. This insertion point can be moved with the arrow keys, or by clicking the mouse on the new location. When the insertion bar is at a given location, the control to the right of the bar can be deleted by pressing the Delete key, the control to the left can be deleted by pressing the Backspace key.
To place a new control at the insertion point:
- select an item from the Controls menu or
- choose a control from the ones shown in the Controls floating dialog or
- click the right mouse button anywhere in the Toolbars Editor window area outside the toolbar to display a pop up from which a desired control can be selected.
Attributes of Toolbar Controls
After a control is inserted, it is possible to change the control attributes. Just double-click the control.
Push and Check Button Attributes
Double-click a Push button or a Check button calls the Button Attributes dialog.
The following information must be specified:
Text Control Attributes
Double-clicking a Static Text or a Context Sensitive Text control calls the Text Attributes dialog:
The following information must be specified:
|Constant||A constant name to identify the Text control.|
|Initial Text||The default text to display in the field.|
|Select the appropriate text control type. The style can be changed at any time.|
|Font||Select a font name, font style (Normal, Bold, Italic ...), and font size for the displayed text.|
|Text Width||Determines a width in pixels of the Text control field. It can be entered manually or, by pushing the "|<---Text--->|" button. In this case the width of the field will be optimized to display the Initial Text with the selected Font.|
|Foreground Color||Select the Foreground Color for the displayed text.|
List Button Attributes
Double-clicking a List Button control calls the List Button Attributes dialog.
Only two parameters can be set for a list button in a toolbar:
|Constant||A constant name to identify the List Button control.|
|Width||Determines the width in pixels of the List Button control field.|