home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1996 November / VPR9611B.ISO / vabasic / ntclnt.exe / DISK8 / data.8 / datab / INCLUDE / PMSUBS.HH < prev    next >
Text File  |  1996-07-29  |  6KB  |  217 lines

  1. //--------------------------------------------------------------
  2. // $Source: /rcs/vwrcs/components/intel/pmsubs.hh,v $
  3. // Checked in by: $Author: mathieuj $
  4. // $Date: 1996/04/03 18:47:10 $              $Revision: 1.12 $
  5. //--------------------------------------------------------------
  6. //      Copyright (c) International Business Machines Inc, 1994
  7. //
  8. // ALL RIGHTS RESERVED. This notice is intended as a precaution
  9. // against inadvertent publication, and shall not be deemed to
  10. // consitute an acknowledgment that publication has occurred
  11. // nor to imply any waiver of confidentiality. The year included
  12. // in the notice is the year of the creation of the work.
  13. //--------------------------------------------------------------
  14. // DESCRIPTION:
  15. //      This file contains the class declaration for the
  16. //      VwpMenu class.
  17. //--------------------------------------------------------------
  18. #ifndef PMSUBS_HH
  19. #define PMSUBS_HH
  20.  
  21. #ifdef VSYS_OS2
  22.  
  23. #define MENU_MASK 0xffffffff
  24.  
  25. #define MF_BYCOMMAND    1
  26. #define  MF_POPUP         2
  27. #define  MF_STRING        4
  28. #define  MF_BYPOSITION    8
  29. #define  MF_ENABLED       0
  30. #define  MF_GRAYED        16
  31. #define  MF_CHECKED       32
  32. #define  MF_UNCHECKED     0
  33. #define  MF_SEPARATOR     64
  34. #define  MF_MENUBREAK     128
  35. #define  MF_MENUBARBREAK  512
  36. #define  MF_DISABLED      1024
  37.  
  38. #define SHIFT_FLAG                      AF_SHIFT
  39. #define CTRL_FLAG                       AF_CONTROL
  40. #define ALT_FLAG                        AF_ALT
  41.  
  42. #define POPUPMENU_LEFTALIGN   0   // The left side of the pop-up menu is at x.
  43. #define POPUPMENU_CENTERALIGN 4   // The pop-up menu is centered at x.
  44. #define POPUPMENU_RIGHTALIGN  8   // The right side of the pop-up menu is at x.
  45. #define POPUPMENU_LEFTBUTTON  0   // Recognizes left button only
  46. #define POPUPMENU_RIGHTBUTTON 2   // Recognizes left or right button
  47.  
  48. #else //WINDOWS
  49.  
  50. #define MENU_MASK 0x0ffff
  51. #define MIT_END -1
  52.  
  53. #define SHIFT_FLAG                      0x04
  54. #define CTRL_FLAG                       0x08
  55. #define ALT_FLAG                        0x10
  56. class  VwpMenu;
  57.  
  58.  
  59.  
  60. #ifdef NOTEMPLATES
  61. #       ifndef MwMenuListDefined
  62. #               define MwMenuListDefined
  63. #               define CLASSNAME        VwiMenuList
  64. #               define ENTRYTYPE        VwpMenu*
  65. #               include <mst/varray.mst>
  66. #       endif
  67.  
  68. #       ifndef HmenuToMwCompMapDefined
  69. #               define HmenuToMwCompMapDefined
  70. #               define CLASSNAME        VwiHmenuToMwCompMap
  71. #               define ENTRYTYPE        VwpMenu*
  72. #               include <mst/ihash.mst>
  73. #       endif
  74. #else
  75. #       include <ihash.hh>
  76.         typedef VeIHashTable<VwpMenu*>     VwiHmenuToMwCompMap;
  77. #endif  // NOTEMPLATES
  78.  
  79. #endif
  80.  
  81.  
  82. #define POPUPMENU_XPASSED 64
  83. #define POPUPMENU_YPASSED 128
  84.  
  85.  
  86. VCLASS VwpMenu : public VwpWnd {
  87.  
  88. public:
  89.  
  90.         VOPERDECL         VwpMenu(void);
  91.         VINLINEOPERDECL   VwpMenu(HMENU hMenu);
  92.  
  93.         VMETHODDECL(void) CreateMenu(VwpWnd *parent);
  94.         VMETHODDECL(void) CreatePopupMenu(int id,HMENU parent);
  95.         VINLINEDECL(void) RemoveMenu(int id, int flag);
  96.         VINLINEDECL(void) SetMenuText(int id, char *text);
  97.         VINLINEDECL(void) EnableMenuItem(int id, int flag);
  98.         VINLINEDECL(void) CheckMenuItem(int id, int flag);
  99.         VMETHODDECL(void) InsertMenu(int id, int pos, int flags,HMENU hMenu, char *itsCaption);
  100.         VMETHODDECL(void) InsertMenu( int pos, int flags,int id, char *itsCaption);
  101.         VMETHODDECL(void) ModifyMenu(int id, int flags, int id2, char *aCaption);
  102.         VINLINEDECL(HMENU) GetSafeHmenu(void);
  103.         VMETHODDECL(void) SizeMenu(VwpWnd *parent);
  104.         VMETHODDECL(BOOL) Popup(HWND frame, int flags, int x, int y);
  105.         VINLINEDECL(void) Detach();
  106.  
  107.         static VMETHODDECL(VwpMenu *) FromHandle(HWND hwnd);
  108.         static VMETHODDECL(BOOL) UpdatingMenu(void);
  109.         VINLINEDECL(void)    IncNbItems() {itsNbItems++;};
  110.         VINLINEDECL(void)    DecNbItems() {itsNbItems--;};
  111.         VINLINEDECL(int)    NbItems() {return itsNbItems;};
  112.  
  113. #ifdef VSYS_WINDOWS
  114.         VOPERDECL         ~VwpMenu(void);
  115.         VMETHODDECL(VwpMenu*) GetSubMenu(int i);
  116.         VINLINEDECL(int) GetMenuItemCount (void);
  117.         VMETHODDECL(void) Link (HMENU);
  118.         VMETHODDECL(void) Unlink (HMENU);
  119.         static VMETHODDECL(VwpMenu*) Owner(HMENU);
  120.         static VMETHODDECL(VwpMenu*) FromHandle(HMENU hm);
  121. #endif
  122.  
  123. protected:
  124.  
  125. private:
  126. #ifdef VSYS_WINDOWS
  127.         HMENU  hmenu;
  128.         static VwiHmenuToMwCompMap itsLinks;
  129. #endif
  130.      int itsNbItems;
  131. };
  132.  
  133. VINLINEOPERDEF VwpMenu::VwpMenu(HMENU hMenu)
  134. {
  135.     hwnd = (HWND)hMenu;
  136. #ifdef VSYS_WINDOWS
  137.     hmenu = hMenu;
  138. #endif
  139. };
  140.  
  141. VINLINEDEF(void) VwpMenu::Detach()
  142. {
  143. #ifdef VSYS_WINDOWS
  144.         hmenu = 0;
  145. #endif
  146. };
  147.  
  148.  
  149. #ifdef VSYS_OS2
  150. VINLINEDEF(void) VwpMenu::RemoveMenu(int id, int flag)
  151. {
  152.         Message(MM_REMOVEITEM,MPFROM2SHORT(id,TRUE),0L);
  153. }
  154.  
  155. VINLINEDEF(void) VwpMenu::SetMenuText(int id, char *text)
  156. {
  157.         Message(MM_SETITEMTEXT, (MPARAM) id, (MPARAM) text);
  158. }
  159.  
  160. VINLINEDEF(void) VwpMenu::EnableMenuItem(int id, int flag)
  161. {
  162.         Message(MM_SETITEMATTR, MPFROM2SHORT(id,TRUE),
  163.                 MPFROM2SHORT(MIA_DISABLED,((flag & MF_GRAYED) ? MIA_DISABLED : FALSE)));
  164. }
  165.  
  166. VINLINEDEF(void) VwpMenu::CheckMenuItem(int id, int flag)
  167. {
  168.         Message(MM_SETITEMATTR, MPFROM2SHORT(id,TRUE),
  169.                 MPFROM2SHORT(MIA_CHECKED,((flag & MF_CHECKED) ? MIA_CHECKED : FALSE)));
  170. }
  171.  
  172. VINLINEDEF(HMENU) VwpMenu::GetSafeHmenu(void)
  173. {
  174.         return hwnd;
  175. }
  176.  
  177. inline VwpMenu* VwpMenu::FromHandle(HWND hwnd)
  178. {
  179.         return (VwpMenu *) FromHandlePermanent(hwnd);
  180. }
  181.  
  182. #else // WINDOWS
  183.  
  184. VINLINEDEF(void) VwpMenu::RemoveMenu(int id, int flag)
  185. {
  186.         ::RemoveMenu (hmenu, id, flag);
  187. }
  188.  
  189. VINLINEDEF(void) VwpMenu::SetMenuText(int id, char *text)
  190. {
  191.         ::ModifyMenu (hmenu, id, MF_BYCOMMAND, id, text);
  192. }
  193.  
  194. VINLINEDEF(void) VwpMenu::EnableMenuItem(int id, int flag)
  195. {
  196.         ::EnableMenuItem (hmenu, id, flag);
  197. }
  198.  
  199. VINLINEDEF(void) VwpMenu::CheckMenuItem(int id, int flag)
  200. {
  201.         ::CheckMenuItem(hmenu, id, flag);
  202. }
  203.  
  204. VINLINEDEF(HMENU) VwpMenu::GetSafeHmenu(void)
  205. {
  206.         return hmenu;
  207. }
  208.  
  209. VINLINEDEF(int) VwpMenu::GetMenuItemCount()
  210. {
  211.         return ::GetMenuItemCount(hmenu);
  212. }
  213. #endif
  214.  
  215.  
  216. #endif // PMSUBS_HH
  217.