Represents the display content and control method for each menu item displayed on the screen. An array of this AM_MenuItem structures defines the display for a menu screen.

Syntax

typedef struct {
  int id;
  int ypos;
  int xpos;
  void *menuText;
  int paletteIndex;
  bool visible;
  bool enabled;
  bool selectable;
  int showControl;
  bool checked;
  int font;
  unsigned short itemOption;
} AM_MenuItem;

Members

id
Item ID:
If you need to specify this menu item in the menu display functions, specify the item ID with a positive number more than 0. You can specify 0 for menu items that you want to display statically and do not need to specify it.
Specify -1 for the last element of the array of AM_MenuItem structures.
ypos
Y coordinate:
Specify the line position starting from 0. Or specify pixel Y coordinate with the AM_PIX macro.
xpos
X cordinate:
Specify the character position starting from 0. Or specify pixel X coordinate with the AM_PIX macro.
menuText
Display content:
If the value of showControl of this structure is AM_TEXT_EDIT, specify a pointer to AM_EditParam structure.
If the value of showControl of this structure is AM_BMPFILE, specify a pointer to the name of the BMP file.
If the value of showControl is AM_SHIFT_MODE or AM_SHIFT_CANDIDATE, specify a pointer to an empty string ("").
If the value of showControl of this structure is other than the above, specify a pointer to the string to display.
paletteIndex
Palette index:
Specify the display color with the index number of the array of AM_ColorPalette structures. Specify 0 if you have not registered your own color palette.
visible
visible attribute:
Specify true when displaying this menu item, and specify false otherwise.
When the visible attribute is false, this menu item will not be displayed regardless of the values of enabled, selectable, and showControl.
enabled
enabled attribute:
When the enabled attribute is false, it is displayed in the color specified by the MenuDisabledForeColor of the AM_Option structure, and the focus does not move to this menu item even if the selectable attribute of this menu item is true.
selectable
selectable attribute:
Specify true to enable moving focus to this menu item, and specify false otherwise.
showControl
Type of control:
Specify the type of control to add to this menu item with one of the following values
ValueDescription
AM_NO_CONTROLNo control is added.
AM_TITLE_LINEThis is for displaying the title line of the menu, the string is automatically centered, and the background of the entire line (128 dots) is drawn with the background color specified for the item. (Ver. 1.5.0 or later)
AM_TEXT_EDIT Specify when this menu item is an input field. When the focus is on this menu item, the input editing is controlled according to the setting of AM_EditParam structure specified by menuText.
AM_SHIFT_MODE Displays the current shift mode.
[123] (NUmeric mode)
[abc] (Lowercase English mode)
[ABC] (Uppercase English mode)
[HEX] (HEX mode)
AM_SHIFT_CANDIDATEWhen the current shift mode is English mode or HEX mode, input candidate characters are displayed.
AM_CHECK_BOXDisplays a check box in front of the display string.
AM_RADIO_BTNDisplays a radio button in front of the display string.
AM_BMPFILEThe image of the BMP file with the file name specified by menuText is displayed.
AM_LIST_MARKDisplays ▼ after the display string. The string is displayed with underline.
AM_JUMP_MARKDisplays ▶ in front of the display string.
AM_CLEAR_ICONDisplays [CLR] icon in front of the display string.
AM_ENT_ICONDisplays [ENT] icon in front of the display string.
AM_SCAN_ICONDisplays [SCAN] icon in front of the display string.
AM_F1_ICONDisplays [F1] icon in front of the display string.
AM_F2_ICONDisplays [F2] icon in front of the display string.
AM_F3_ICONDisplays [F3] icon in front of the display string.
AM_Q1_ICONDisplays [Q1] icon in front of the display string.
AM_Q2_ICONDisplays [F2] icon in front of the display string.
AM_BS_ICONDisplays [BS] icon in front of the display string.
AM_1_ICONDisplays [1] icon in front of the display string.
AM_2_ICONDisplays [2] icon in front of the display string.
AM_3_ICONDisplays [3] icon in front of the display string.
AM_4_ICONDisplays [4] icon in front of the display string.
AM_5_ICONDisplays [5] icon in front of the display string.
AM_6_ICONDisplays [6] icon in front of the display string.
AM_7_ICONDisplays [7] icon in front of the display string.
AM_8_ICONDisplays [8] icon in front of the display string.
AM_9_ICONDisplays [9] icon in front of the display string.
AM_0_ICONDisplays [0] icon in front of the display string.
AM_ASTER_ICONDisplays [*] icon in front of the display string.

checked
checked attribute:
Specifies the initial state of the radio button or check box. If true, the checked state is displayed, otherwise the unchecked state is displayed.
font
Font:
Specify the font type with one of the following values.
ValueDescription
MEDIUM_FONT Display with MEDIUM_FONT.
LARGE_FONT Display with LARGE_FONT.
HUGE_FONT Display with HUGE_FONT.
0 No font is specified. (Use default font.)
itemOption
Other options:
ValueDescription
AM_MULTI_START The menu items from AM_MULTI_START to AM_MULTI_END are treated as one menu item.
AM_MULTI_MID AM_MULTI_MID must be specified for menu items between AM_MULTI_START and AM_MULTI_END.
AM_MULTI_END (See the description for AM_MULTI_START.)
0 No option is specified.

Remarks

One AM_MenuItem structure represents one menu item.

An array of AM_MenuItem structures defines the display for one screen.

Specify -1 for the id of the last element of the array to indicate the end of the array.

Within the same array, values for the id other than 0 or -1 must be unique.

Initialize the menu resource by calling AM_CreateMenu function or AL_CreateList function with passing a pointer to the array of AM_MenuItem structures to the menuTable parameter.

When you specify ypos or xpos, you can use the AM_PIX macro to specify pixel coordinate. For example, if you write AM_PIX(100), you can specify 100 in pixel coordinate.

To define an input field for entering characters using the keyboard, set AM_TEXT_EDIT to showControl and specify a pointer to the AM_EditParam structure in menuText.

To display an image, set AM_BMPFILE to showControl and specify a pointer to the filename of the BMP file in menuText.

Use the color palette to specify the display color of menu items.
Color palette is an array of AM_ColorPalette structures. Specify the menu item color by specifying the index number of that array in paletteIndex. Follow the procedure below to register your own color palette in the menu resource in advance.
  1. Define the required color palette in an array of AM_ColorPalette structures.
  2. Define the AM_Option structure and set NumberOfColorPalette and ColorPalettes to register the array of AM_ColorPalette structures above.
  3. Register your own color palette in the menu resource by passing the AM_Option structure above to the option parameter of AM_CreateMenu function or AL_CreateList function.

Requirements

Header file:
lib.h
AdvancedMenu.h

Sample

// Table of the menu items for task #2 screen
static const AM_MenuItem Task2MenuTable[] = {
//   itemID,           y,           x,          menuText,              Palette,       visible, enabled, selectable, showControl,   checked, font
    {0,                0,           0,          "    Task #2     ",    PX_TITLE_TASK, true,    true,    false,      AM_NO_CONTROL, false,   LARGE_FONT},
    {0,                2,           1,          "EAN/UPC code:",       PX_BASE,       true,    true,    false,      AM_NO_CONTROL},
    {TASK2_ID_BARCODE, AM_PIX(42),  1,          (void *)&EditParamEAN, PX_EDIT,       true,    true,    false,      AM_TEXT_EDIT,  false,   LARGE_FONT},
    {0,                5,           1,          "Result:",             PX_BASE,       true,    true,    false,      AM_NO_CONTROL},
    {TASK2_ID_RESULT,  6,           2,          "",                    PX_BASE,       true,    true,    false,      AM_NO_CONTROL},
    {TASK2_ID_SCAN,    AM_PIX(114), 0,          "Read barcode",        PX_GUIDE,      true,    true,    false,      AM_SCAN_ICON},
    {TASK2_ID_EXIT,    AM_PIX(129), 0,          "Exit",                PX_GUIDE,      true,    true,    false,      AM_CLEAR_ICON},
    {TASK2_ID_CANCEL,  AM_PIX(129), 0,          "Cancel",              PX_GUIDE,      false,   true,    false,      AM_CLEAR_ICON},
    {TASK2_ID_APPLY,   AM_PIX(129), AM_PIX(64), "Apply",               PX_APPLY,      false,   true,    false,      AM_ENT_ICON},
    {-1}
};

See also

Last updated: 2021/06/03