menu_.pp 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. (******************************************************************************
  2. *
  3. * Copyright (c) 1994-2000 Palm, Inc. or its subsidiaries.
  4. * All rights reserved.
  5. *
  6. * File: Menu.h
  7. *
  8. * Release: Palm OS SDK 4.0 (63220)
  9. *
  10. * Description:
  11. * This file defines menu structures and routines.
  12. *
  13. * History:
  14. * November 18, 1994 Created by Roger Flores
  15. * Name Date Description
  16. * ---- ---- -----------
  17. * gap 09/29/99 Added gsiWasEnabled to MenuCmdBarType
  18. *
  19. *****************************************************************************)
  20. unit menu_;
  21. interface
  22. uses palmos, coretraps, errorbase, control, event_;
  23. // Errors returned by Menu routines
  24. const
  25. menuErrNoMenu = menuErrorClass or 1;
  26. menuErrNotFound = menuErrorClass or 2;
  27. menuErrSameId = menuErrorClass or 3;
  28. menuErrTooManyItems = menuErrorClass or 4;
  29. menuErrOutOfMemory = menuErrorClass or 5;
  30. // Command bar structures
  31. type
  32. MenuCmdBarResultType = Enum;
  33. const
  34. menuCmdBarResultNone = 0; // send nothing (this'd be quite unusual but is allowed)
  35. menuCmdBarResultChar = Succ(menuCmdBarResultNone); // char to send (with commandKeyMask bit set)
  36. menuCmdBarResultMenuItem = Succ(menuCmdBarResultChar); // id of the menu item
  37. menuCmdBarResultNotify = Succ(menuCmdBarResultMenuItem); // Nofication Manager notification type
  38. // maximum length of the prompt string to display in the command bar
  39. menuCmdBarMaxTextLength = 20;
  40. type
  41. MenuCmdBarButtonType = record
  42. {$ifdef ALLOW_ACCESS_TO_INTERNALS_OF_MENUS} // These fields will not be available in the next OS release!
  43. bitmapId: UInt16;
  44. name: array [0..menuCmdBarMaxTextLength-1] of Char;
  45. resultType: MenuCmdBarResultType;
  46. reserved: UInt8; // alignment padding
  47. result: UInt32;
  48. {$endif}
  49. end;
  50. MenuCmdBarButtonTag = MenuCmdBarButtonType;
  51. MenuCmdBarType = record
  52. {$ifdef ALLOW_ACCESS_TO_INTERNALS_OF_MENUS} // These fields will not be available in the next OS release!
  53. bitsBehind: WinHandle;
  54. timeoutTick: Int32; // tick to disappear on
  55. top: Coord;
  56. numButtons: Int16;
  57. insPtWasEnabled: Boolean;
  58. gsiWasEnabled: Boolean;
  59. feedbackMode: Boolean; // set when just displaying confirmation feedback
  60. buttonsData: ^MenuCmdBarButtonType;
  61. {$endif}
  62. end;
  63. // to tell MenuCmdBarAddButton where to add the button: on right or left.
  64. const
  65. menuCmdBarOnRight = 0;
  66. menuCmdBarOnLeft = $ff;
  67. ////Menu-specific
  68. noMenuSelection = -1;
  69. noMenuItemSelection = -1;
  70. separatorItemSelection = -2;
  71. // cause codes for menuOpen Event
  72. menuButtonCause = 0;
  73. menuCommandCause = 1;
  74. // To match Apple's ResEdit the first byte of a menu item's text can
  75. // be a special char indicating a special menu item.
  76. MenuSeparatorChar = '-';
  77. type
  78. MenuItemType = record
  79. {$ifdef ALLOW_ACCESS_TO_INTERNALS_OF_MENUS} // These fields will not be available in the next OS release!
  80. id: UInt16; // id of the menu item
  81. command: Char; // command key
  82. bits: UInt8;
  83. {
  84. UInt8 hidden: 1; // true if menu item is hidden
  85. UInt8 reserved: 7;
  86. }
  87. itemStr: PChar; // string to be displayed
  88. {$endif}
  89. end;
  90. MenuItemTag = MenuItemType;
  91. MenuPullDownType = record
  92. {$ifdef ALLOW_ACCESS_TO_INTERNALS_OF_MENUS} // These fields will not be available in the next OS release!
  93. menuWin: WinHandle; // window of pull-down menu
  94. bounds: RectangleType; // bounds of the pulldown
  95. bitsBehind: WinHandle; // saving bits behind pull-down menu
  96. titleBounds: RectangleType; // bounds of the title in menu bar
  97. title: PChar; // menu title displayed in menu bar
  98. bits: UInt16;
  99. {
  100. UInt16 hidden: 1; // true if pulldown is hidden
  101. UInt16 numItems: 15; // number of items in the menu
  102. }
  103. items: ^MenuItemType; // array of menu items
  104. {$endif}
  105. end;
  106. MenuPullDownTag = MenuPullDownType;
  107. MenuPullDownPtr = ^MenuPullDownType;
  108. MenuBarAttrType = record
  109. {$ifdef ALLOW_ACCESS_TO_INTERNALS_OF_MENUS} // These fields will not be available in the next OS release!
  110. bits: UInt16;
  111. {
  112. UInt16 visible :1; // Set if menu bar is drawn
  113. UInt16 commandPending :1; // Set if next key is a command
  114. UInt16 insPtEnabled :1; // Set if insPt was on when menu was drawn
  115. UInt16 needsRecalc :1; // if set then recalc menu dimensions
  116. UInt16 attnIndicatorIsAllowed :1; // set if attn indicator was allowed when menu was drawn
  117. UInt16 reserved :11; // reserved for future use
  118. }
  119. {$endif}
  120. end;
  121. MenuBarAttrTag = MenuBarAttrType;
  122. MenuBarType = record
  123. {$ifdef ALLOW_ACCESS_TO_INTERNALS_OF_MENUS} // These fields will not be available in the next OS release!
  124. barWin: WinHandle; // window of menu bar
  125. bitsBehind: WinHandle; // saving bits behind menu bar
  126. savedActiveWin: WinHandle;
  127. bitsBehindStatus: WinHandle;
  128. attr: MenuBarAttrType;
  129. curMenu: Int16; // current menu or -1 if none
  130. curItem: Int16; // current item in curMenu, -1 if none
  131. commandTick: Int32;
  132. numMenus: Int16; // number of menus
  133. menus: MenuPullDownPtr; // array of menus
  134. {$endif}
  135. end;
  136. MenuBarTag = MenuBarType;
  137. MenuBarPtr = ^MenuBarType;
  138. function MenuInit(resourceId: UInt16): MenuBarPtr; syscall sysTrapMenuInit;
  139. function MenuGetActiveMenu: MenuBarPtr; syscall sysTrapMenuGetActiveMenu;
  140. function MenuSetActiveMenu(menuP: MenuBarPtr): MenuBarPtr; syscall sysTrapMenuSetActiveMenu;
  141. procedure MenuDispose(menuP: MenuBarPtr); syscall sysTrapMenuDispose;
  142. function MenuHandleEvent(menuP: MenuBarPtr; var event: EventType; var error: UInt16): Boolean; syscall sysTrapMenuHandleEvent;
  143. procedure MenuDrawMenu(menuP: MenuBarPtr); syscall sysTrapMenuDrawMenu;
  144. procedure MenuEraseStatus(menuP: MenuBarPtr); syscall sysTrapMenuEraseStatus;
  145. procedure MenuSetActiveMenuRscID(resourceId: UInt16); syscall sysTrapMenuSetActiveMenuRscID;
  146. function MenuCmdBarAddButton(where: UInt8; bitmapId: UInt16; resultType: MenuCmdBarResultType;
  147. result_: UInt32; nameP: PChar): Err; syscall sysTrapMenuCmdBarAddButton;
  148. function MenuCmdBarGetButtonData(buttonIndex: Int16; var bitmapIdP: UInt16; var resultTypeP: MenuCmdBarResultType;
  149. var resultP: UInt32; nameP: PChar): Boolean; syscall sysTrapMenuCmdBarGetButtonData;
  150. procedure MenuCmdBarDisplay; syscall sysTrapMenuCmdBarDisplay;
  151. function MenuShowItem(id: UInt16): Boolean; syscall sysTrapMenuShowItem;
  152. function MenuHideItem(id: UInt16): Boolean; syscall sysTrapMenuHideItem;
  153. function MenuAddItem(positionId, id: UInt16; cmd: Char; const textP: PChar): Err; syscall sysTrapMenuAddItem;
  154. implementation
  155. end.