Programming Guide



sm_menu_get*

Gets a menu's property

int sm_menu_get_int(int mem_location, char *script, char *menu, int prop);
char *sm_menu_get_str(int mem_location, char *script, char *menu, int prop);

mem_location
The menu's memory location, one of the following constants:
MNL_APPLIC
MNL_SCREEN
MNL_FIELD

script
The name of a memory-resident script that contains the menu. The script must already be loaded into memory at mem_location by sm_mnscript_load. If you supply NULL, Panther searches in the most recently loaded script in mem_location for the specified menu.

menu
The menu's name. If you supply NULL, Panther uses the first menu in script.

prop
The property to get. Table 5-12 lists the properties that you can get and their constants.

Returns

Description

sm_menu_get_int and sm_menu_get_str returns the current setting of the specified property. Use the _int variant for those properties that have an integer value—for example, MN_TEAR; use the _str variant for properties that take string values, such as MN_NAME and MN_TITLE.

Table 5-12 Menu properties

Property Type* Description

MN_EXTERNAL

int

A value of PROP_ON or PROP_OFF specifies whether to find this menu's definition in another script.

MN_NAME

str

The name of this menu.

MN_NUM_ITEMS

int

Number of items in this menu.

MN_TEAR

int

A value of PROP_ON or PROP_OFF enables or disables this submenu as a tear-off menu.

MN_TITLE

str

A title to display with popup menus.

MNI_SHOW_ACCEL

int

A value of PROP_ON or PROP_OFF specifies whether menu items display the accelerator key next to their labels.

MNI_ACCEL_ACTIVE

int

A value of PROP_ON or PROP_OFF specifies whether menu item accelerators are active.

MNI_ACTIVE

int

A value of PROP_ON or PROP_OFF allows or disallows user access to menu items. If MNI_ACTIVE is set to PROP_OFF, menu items are greyed out.

MNI_INDICATOR

int

A value of PROP_ON or PROP_OFF specifies whether to show the toggle indicator on items

MNI_SEP_STYLE

int

The default style used by separator-type items, specified by one of these constants:

SEP_SINGLE
SEP_DOUBLE
SEP_NOLINE
SEP_SINGLE_DASHED
SEP_DOUBLE_DASHED
SEP_ETCHEDIN
SEP_ETCHEDOUT
SEP_ETCHEDIN_DASHED
SEP_ETCHEDOUT_DASHED

* For integer-type properties, use sm_menu_get_int; for string-properties, use sm_menu_get_str.

Example

/*enable and disable menu tear-offs*/

int ToggleTearOffs(void)
{
int errorCode;
switch
(sm_menu_get_int(MNL_SCREEN, "menucom", "main", MN_TEAR)
{
/*enable tear-offs */
case 0: sm_menu_change
(MNL_SCREEN, "menucom", "main", MN_TEAR, 1, NULL);
break;

/*disable tear-offs */
case 1: sm_menu_change
(MNL_SCREEN, "menucom", "main", MN_TEAR, 0, NULL);
break;

/* if error returned, find out why */
case -1:
errorCode = sm_menu_bar_error();
menuErrorHandler(errorCode);
break;
}
}