Handling menus

The application includes different types of menus: text, icon, and keyboard menus as well as toolbars. All menus and toolbars are defined in menu files (.mnu). Icon and text menus must be defined in a different file than toolbars. For example, the standard menus and toolbars provided with the application are defined in the cads.mnu file, while icon and text menus are defined in cads2.mnu).

All functions in the menu files are defined as command scripts. The command script can either be defined straight in the menu or by a separate command ID.

Menu files are text files that can be created and edited with a text editor. Some menus can also be edited in drawing mode.

A menu file has different sections separated by key fields. The definitions always start with one of the following key fields:

  •    [Groupdata] – menu group's general information

  •    [Toolbar] – toolbar definitions

  •    [KeyboardMenu] – keyboard menu definitions

  •    [PointingdeviceMenu] – pointing device definitions

  •    [IconMenu:nimi] – icon menu definitions

  •    [TextMenu:nimi] – text menu definitions

  •    [Itemdata] – command ID definitions

Learn more:

Group data

The resource files that include toolbar buttons are defined below Groupdata. The syntax is as follows:

[Groupdata]

Resources=resource file

  Resources defines the resource file (.dll) from which toolbar buttons are searched.

The following example defines scads.dll, which includes CADMATIC Electrical toolbar buttons abd buttons.dll, which includes CADMATIC Draw toolbar buttons:

[Groupdata]

Resources=scads.dll;buttons.dll

Toolbars

A toolbar consists of buttons with bitmap images. Each button starts a separate command. A toolbar can float on the drawing area, or you can dock it to the side of the drawing area.

Toolbars are defined in three separate files:

  • Command definition in the menu file (.mnu)

  • Compiled menu file (.mns)

  • Toolbar button images (.dll or .bmp)

Toolbar buttons are bitmap images saved as a resource file (such as buttons.dll) or as separate files (.bmp).

Information about toolbar visibility, location, and number of rows is saved in the cads.ini file. The program gets the default values for these options from the menu file.

 

Toolbars are defined below [Toolbars]. You can define the functions of multiple different toolbar buttons in the same file.

The syntax is as follows:

[Toolbars]

TOOLBAR "Toolbar_name", command_ID, "visibility location coordinates rows"

{

"button", command_ID

}
 

Button defines the button shown in the toolbar. If you add .bmp after the button name, the button will be searched from a separate bitmap file. Otherwise, the button is searched from the resource files defined below [Groupdata].

 

Visibility defines whether to open the toolbar when a menu is loaded. The value is either show or hide.

 

Location defines whether to open the toolbar as floating or docked. The value is floating, top, bottom, left, or right.

 

Coordinates defines the location of the screen. The origo is in the top left corner.

 

Number of rows defines the number of row the toolbar is opened to.

Keyboard menus

Keyboard menus are defined below [KeyboardMenu]. The keyboard menu consists of rows that indicate the command script and the key it is connected to. The row syntax is as follows:

"key", "command script"

You can use keys from Ctrl + A to Ctrl + Z, function keys and their Shift and Ctrl combinations.

Note: Shortcut key combinations defined in Windows cannot be used in application's keyboard menu. F10 is also reserved for Windows only.

You only need rows in the menu file for the function keys you want to use. The row order is not relevant.

Pointing device menus

Pointing device menus are defined below [PointingdeviceMenu]. The pointing device menu consists of rows that indicate the command script and the key it is connected to. The row syntax is as follows:

"key", "command script"

You can use keys from 1 to n,  function keys and their Shift and Ctrl combinations. Key 0 (left mouse button) is not available for definitions. Mouse wheel (typically key 2) is reserved for zooming and panning. If you define a function for this key, it starts by double-clicking the wheel.

Icon menus

Icon menus are graphical menus from where you can select functions. Icon menus need to be defined in a file other than the one for keyboard menus, pointing device menus and toolbars.

Incon menus are typically defined in two separate files:

  • Command definition in the menu file (.mnu)

  • Icon library file (.vlb) including the icons used in the menus

The icon used in an icon menu is created from a CAD drawing. You draw what you want to see in the menu normally and then save it as an icon with the ICON command. You can save as many individual icons as necessary in the icon library files (ending with .vlb). Icon menus can consist of one or more icons.

Steps for creating icon menus:

  1. Draw the icons you want to have in your icon menu. You do not need to draw the light grey background, the application will add it. You can use different colors. The colors will be printed as they would be in the drawing itself. For example, color number 2 will be shown as red when using the default settings.

    The icon menu consists of the individual icons saved in the icon menu library. Keep that in mind when drawing.

  2. Save each icon in the icon menu library with the ICON Save Window command, indicating the button area as precisely as possible. The icon is saved in the icon directory. However, you can also save it directly to the desired icon library by entering the name of the library in parenthesis. For example, if you want to save the icon in the USER library with the name button1, enter it as follows:

    (user) button1.

  3. Write a file that defines the command scripts started by the icons (e.g. .mnu).

  4. Open the icon menu with the ICONMENU command. You can add the call to the keyboard menu or toolbar button, for example.

Icon menus are defined below [IconMenu]. In the menu file, you can include button functions for several different icon menus.

The syntax is as follows:

"icon", "command_script" [, "instruction_text"]

"icon", "command_script" [, "instruction_text"]

"icon", "command_script" [, "instruction_text"]

...

 

[IconMenu:name] defines the name of the icon menu.

 

Caption="caption characters" defines the caption, which by default is the same as the name.

 

IconLibrary=IconLibraryName defines the name of the icon library (can also be a path).

 

Columns=NumberOfColumns defines the number of columns, which by default is 8.

 

IconWidthheight=PixelWidth defines the width of the icon, which by default is 48.

 

IconHeight=PixelHeight defines the height of the icon, which by default is the same as the icon width.

 

ForceSelect=n defines whether you need to select something in order to continue.

Columns, icon width and icon height can be left out if default values can be used.

Note: Because you can set the number of columns, icon width and icon height in the menu file, you can also change these values (for standard menus as well). This allows you to make the menus bigger by changing the width, for example.

Text menus

Icon menus are defined below TextMenu]. Text menus are similar to icon menus regarding the syntax.

The syntax is as follows:

 

[TextMenu:name] defines the name of the text menu.

 

Caption="caption characters" defines the caption, which by default is the same as the name.

 

Columns=NumberOfColumns defines the maximum width.

 

Rows=NumberOfRows defines the maximum height.

 

ForceSelect=n defines whether you need to select something in order to continue.

 

"name", "command script"

You can open a text menu with the TEXTMENU command. The command script can, for example, be as follows:

|TEXTMENU menufile^#menu^#location^#

  menufile  defines the menu file where the information of the text menu to be opened is. For example, the text files used by the application are in cads2.mnu.
  menu  defines the text menu to be opened, such as TEXTMENU
  location  defines whether to pen the text menu in the center of the screen or where the cursor is.

For example:

|TEXTMENU CADS2^#TEXTMENU^#CEN^#

Defining commands for toolbar buttons

Instead of command scirpts, you can define item data with command ID for menus. The command ID includes the command script with the instruction text. In addition, it can include conditions related to the item data's status.

Command IDs are defined below [Itemdata.

The syntax is as follows:

ID_command_id "instruction_text\nInstructionText" Command="command_script"

Checked=clause Gray=clause

  Command id is a unique code starting with ID_. It is recommend to use a name that describes the function. Command IDs starting with IDCADS_ come with the application and cannot be changed.
 

Instruction text consists of two parts separated with \n. The first part is typically a longer description. The second part is shown next to the cursor.

  Command= precedes the actual command string that the command ID will execute.
 

Checked= precedes the condition stating when the item data is shown as selected i.e. toolbar button pressed down. The condition is usually connected to a system variable. When the condition is true, the item data is shown as selected.

 

Gray= precedes the condition stating when item data is shown as gray i.e. not available for selection. The condition is usually connected to a system variable. When the condition is false, the item data is shown as gray.

Taking menu files into use

Before a menu or toolbar can be opened, the menu group needs to be taken into use with the MENU command.

You can open and close toolbars with the TOOLBARS command or by selecting File > Settings > Show/hide toolbars. Alternatively, right-click an empty spot on a toolbar to open a menu showing all uploaded menu groups. From these menu groups you can then open and close individual toolbars.

With the Customize function, you can edit and make your own toolbars.