Slide 9.1: Menus
  Slide 9.3: Menu demonstrations (cont.)
  Home


Menu Demonstrations


The following emulator screen dumps show the interface generated by the next application Menu.
  1. Go to Screen B after clicking on Menu icon.

    Note that the default icon is replaced by the image .
  2. This form shows the main interface, which includes five fields, four buttons, and a menu bar.

    Go to Screen C after taping on the Record menu of the menu bar.

  3. This is the Record menu, which includes five records.

    Selecting a record will display the record on the main interface.
  4. This is the Edit menu, which provides users to copy/cut/paste/ ... fields.

    However, changes made to records are NOT saved.
  5. This is the Options menu, which includes Help and About items.

  6. This is an alert for Help.
  7. This is an alert for About.

Before the Palm OS Resource Editor, you have to manually create the following C header file Menu.h and Palm OS resource file Menu.rcp for the above interface:

 Menu.h 

#define  MainForm              1000
#define  MainFirstName	       3001
#define	 MainLastName	       3002
#define	 MainInstrument        3003
#define	 MainCursor            3004
#define	 MainFirstRec          1010
#define	 MainPrevRec	       1011
#define	 MainNextRec	       1012
#define	 MainLastRec           1013

#define  MainMenu              1000
#define  MainRecord1Cmd        1000
#define  MainRecord2Cmd        1001
#define  MainRecord3Cmd        1002
#define  MainRecord4Cmd        1003
#define  MainRecord5Cmd        1004
#define  MainEditClearCmd      1010
#define  MainEditCutCmd        1011
#define  MainEditCopyCmd       1012
#define	 MainEditPasteCmd      1013
#define	 MainEditSelectAllCmd  1014
#define	 MainOptionsHelpCmd    1020         
#define	 MainOptionsAboutCmd   1021

#define	 HelpAlert             1000
#define	 AboutAlert            1001
#define	 RomIncompatibleAlert  1002


 Menu.rcp 

#include  "Menu.h"

FORM ID  MainForm AT (0 0 160 160)
USABLE
MENUID  MainMenu
BEGIN
  TITLE  "Menu"

  LABEL  "Play with menu and fields!" AUTOID AT (CENTER 30) FONT 2

  LABEL  "First Name: " AUTOID AT (RIGHT@70 PREVBOTTOM+20) FONT 1
  FIELD ID  MainFirstName AT (PREVRIGHT PREVTOP 80 AUTO)
    LEFTALIGN EDITABLE UNDERLINED MAXCHARS 20

  LABEL  "Last Name: " AUTOID AT (RIGHT@70 PREVBOTTOM+4) FONT 1
  FIELD ID  MainLastName AT (PREVRIGHT PREVTOP 80 AUTO)
    LEFTALIGN EDITABLE UNDERLINED MAXCHARS 20

  LABEL  "Instrument: " AUTOID AT (RIGHT@70 PREVBOTTOM+4) FONT 1
  FIELD ID  MainInstrument AT (PREVRIGHT PREVTOP 80 AUTO)
    LEFTALIGN EDITABLE UNDERLINED MAXCHARS 20

  BUTTON "\003" ID  MainFirstRec   AT
    (CENTER@40  PREVBOTTOM+20 AUTO AUTO) FONT 3 NOFRAME
  BUTTON "\002" ID  MainPrevRec    AT
    (CENTER@60  PREVTOP AUTO AUTO) FONT 4 NOFRAME
  FIELD         ID  MainCursor     AT
    (CENTER@80  PREVTOP 20 AUTO) LEFTALIGN NONEDITABLE MAXCHARS 5
  BUTTON "\003" ID  MainNextRec    AT
    (CENTER@100 PREVTOP AUTO AUTO) FONT 4 NOFRAME
  BUTTON "\004" ID  MainLastRec    AT
    (CENTER@120 PREVTOP AUTO AUTO) FONT 3 NOFRAME
END

MENU ID  MainMenu
BEGIN
  PULLDOWN  "Record"
  BEGIN
    MENUITEM  "Jarrett"      ID MainRecord1Cmd "1"
    MENUITEM  "Peacock"	     ID MainRecord2Cmd "2"
    MENUITEM  "De Johnette"  ID MainRecord3Cmd "3"
    MENUITEM  "Terrasson"    ID MainRecord4Cmd "4"
    MENUITEM  "Pastorius"    ID MainRecord5Cmd "5"
  END
    
  PULLDOWN  "Edit"
  BEGIN
    MENUITEM  "Clear"  ID MainEditClearCmd "L"
    MENUITEM  SEPARATOR
    MENUITEM  "Cut"	   ID  MainEditCutCmd   "X"
    MENUITEM  "Copy"	   ID  MainEditCopyCmd  "C"
    MENUITEM  "Paste"	   ID  MainEditPasteCmd "V"
    MENUITEM  SEPARATOR
    MENUITEM  "Select All"  ID  MainEditSelectAllCmd "S"
  END

  PULLDOWN  "Options"
  BEGIN
    MENUITEM  "Help"  ID  MainOptionsHelpCmd  "H"
    MENUITEM  SEPARATOR
    MENUITEM  "About" ID  MainOptionsAboutCmd "A"
  END
END

ALERT ID  HelpAlert
INFORMATION
BEGIN
  TITLE   "Help"
  MESSAGE "This app provides a set of records that you can browse "\
    "using buttons, menu and hard keys.  Feel free to copy/cut/paste... "\
    "fields. However, changes made to records are NOT saved!\n"
  BUTTON  "OK"
END

ALERT ID  AboutAlert
INFORMATION
BEGIN
  TITLE   "About Menu"
  MESSAGE "This is a demonstration of menu programming for PalmOS.\n"
  BUTTON  "OK"
END

ALERT ID  RomIncompatibleAlert
ERROR
BEGIN
  TITLE   "System Incompatible"
  MESSAGE "System Version 2.0 or greater is required to run this application."
  BUTTONS "Ok"
END

ICON  "menu.bmp"
VERSION 1  "1.0.0"
LAUNCHERCATEGORY ID  1000 "Tutorial"