SilverScreen Solid Modeler

Custom Menus

Custom Menus

Previous topic Next topic  

Custom Menus

Previous topic Next topic JavaScript is required for the print function  

SilverScreenAPI

 

Custom Menus

 

 

 

 

SilverScreen allows the use of custom menus. These menus, in appearance and in functionality, are very similar to the SilverScreen menus. The menus can be displayed using the built-in function menu. Using this function, a program can display a menu and receive the user's response.

 

The construction of custom menus begins with a source file that defines the structure of the menus. This file is then compiled to produce a .CMF file. It is the .CMF file that is used by the menu function.

 

Sample Custom Menu File

 

 heading="Sample menu"

 {

 ceiling      "CEILING Ceiling commands"

    {

    build     "BUILD Build ceiling"        10

    display   "DISPLAY Display ceiling"    20

    }

 floor        "FLOOR Floor commands"

    {

    build     "BUILD Build floor"           30

    display   "DISPLAY Display floor"       40

    }

 quit         "QUIT Exit"                   50

 }

 

 

This is a simple menu consisting of three major menu selections (ceiling, floor, quit). The ceiling and floor selections have secondary menus, while the quit selection does not. The quoted strings are single line descriptors that appear at the top of the screen when the corresponding selection is highlighted.

 

The numbers at the right are returned to the program if the user selects that item. Note that these numbers appear only at the leaf level of the menu tree.

 

Let us assume that above source menu is stored in the file SAMPLE1. The file is compiled using the following SilverScreen command:

 

Command Syntax

 

 CUSTOM-MENU COMPILE <source menu file>

 

 

This will produce, in this example, a custom menu file SAMPLE1.CMF, which will be stored in the current directory. The CMF file may now be used by the menu function:

 

C / C++ Code

 

switch ( menu ( "sample1" ) )

  {

  case 0: // The user entered ESCAPE

  break;

 
  case 1: // The user entered a function key or control key

     switch ( ich )

        {

        case F1:

           . . .

        case F2:

           . . .

        }

     break;

 

  case 10:  // CEILING BUILD

     . . .

  case 20:  // CEILING DISPLAY

     . . .

  case 30:  // FLOOR BUILD

     . . .

  case 40:  // FLOOR DISPLAY

     . . .

  case 50:  // QUIT

     . . .

  }

 

 

The menu command returns 0, 1, or a number corresponding to a menu selection. The return value 0 means that the user chose to enter Esc rather than select an item from the menu. The return value 1 means that the user pressed a function or control key. When this occurs, the key is made available in the predefined variable ich. The other numbers correspond to a successful menu selection by the user.

 

Structure of a Custom Menu File

 

A custom menu file has the following format:

 

Menu File Syntax

 

[HEADING = <string>]

[TITLE = <string>]

[MACRO = <string>]

MENU_UNIT

 

where:

 

MENU_UNIT    ==>   { MENU_ITEMS }

MENU_ITEMS   ==>   [ MENU_ITEMS ] MENU_ITEM

MENU_ITEM    ==>   <id> <string> MENU_UNIT ||

                 <id> <string> <number>        ||

                 <id> <string>

                 *

 

 

The ‘*’ menu item denotes a menu separator.