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
Value Description AM_NO_CONTROL No control is added. AM_TITLE_LINE This 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_CANDIDATE When the current shift mode is English mode or HEX mode, input candidate characters are displayed. AM_CHECK_BOX Displays a check box in front of the display string. AM_RADIO_BTN Displays a radio button in front of the display string. AM_BMPFILE The image of the BMP file with the file name specified by menuText is displayed. AM_LIST_MARK Displays ▼ after the display string. The string is displayed with underline. AM_JUMP_MARK Displays ▶ in front of the display string. AM_CLEAR_ICON Displays [CLR] icon in front of the display string. AM_ENT_ICON Displays [ENT] icon in front of the display string. AM_SCAN_ICON Displays [SCAN] icon in front of the display string. AM_F1_ICON Displays [F1] icon in front of the display string. AM_F2_ICON Displays [F2] icon in front of the display string. AM_F3_ICON Displays [F3] icon in front of the display string. AM_Q1_ICON Displays [Q1] icon in front of the display string. AM_Q2_ICON Displays [F2] icon in front of the display string. AM_BS_ICON Displays [BS] icon in front of the display string. AM_1_ICON Displays [1] icon in front of the display string. AM_2_ICON Displays [2] icon in front of the display string. AM_3_ICON Displays [3] icon in front of the display string. AM_4_ICON Displays [4] icon in front of the display string. AM_5_ICON Displays [5] icon in front of the display string. AM_6_ICON Displays [6] icon in front of the display string. AM_7_ICON Displays [7] icon in front of the display string. AM_8_ICON Displays [8] icon in front of the display string. AM_9_ICON Displays [9] icon in front of the display string. AM_0_ICON Displays [0] icon in front of the display string. AM_ASTER_ICON Displays [*] 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.
Value Description 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:
Value Description 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.
- Define the required color palette in an array of AM_ColorPalette structures.
- Define the AM_Option structure and set NumberOfColorPalette and ColorPalettes to register the array of AM_ColorPalette structures above.
- 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