home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 25: Programming / pc_actual_25.iso / C_C++ / VisualProgrammingArmoury / data1.cab / MyFileGroup / INCLUDE / Menu.hpp < prev    next >
Encoding:
C/C++ Source or Header  |  1999-06-23  |  3.8 KB  |  142 lines

  1. #ifndef _INC_MENU_HPP
  2. #define _INC_MENU_HPP
  3. #ifdef __GNUG__
  4.  
  5. #ifdef BUILD_TCCORE
  6. #define TCCORELIB    dllexport
  7. #else
  8. #ifdef BUILD_LOCAL
  9. #define TCCORELIB
  10. #else
  11. #define TCCORELIB    dllimport
  12. #endif
  13. #endif
  14.  
  15. #else
  16.  
  17. #ifdef BUILD_TCCORE
  18. #define TCCORELIB    __declspec(dllexport)
  19. #else
  20. #ifdef BUILD_LOCAL
  21. #define TCCORELIB
  22. #else
  23. #define TCCORELIB    __declspec(dllimport)
  24. #endif
  25. #endif
  26.  
  27. #endif
  28. #define NEW_THIS_MENU_ITEM(mi,pp,text,func,dw_u,cls)    \
  29.     mi=new TC_CMenu(0,text);(pp)->Add(mi);\
  30.     mi->SetCEventHandler(event_t(0,0),this,\
  31.     (C_EVENT_HANDLER)((BOOL(cls::*)(TC_Event*))func),\
  32.     dw_u)
  33.  
  34. /****  Example:
  35.  
  36. void MyClass :: RunPopupMenu (void)
  37. {
  38.   TC_CMenu menu( TC_CMenu::T_POPUP, "" );
  39.   TC_CMenu * mi;
  40.  
  41.   NEW_THIS_MENU_ITEM( mi, &menu, "Some action1",   Ev_SomeAction1, 0, MyClass );
  42.   NEW_THIS_MENU_ITEM( mi, &menu, "Some action2",   Ev_SomeAction2, 0, MyClass );
  43.   NEW_THIS_MENU_ITEM( mi, &menu, "Some action X1", Ev_SomeActionX, 1, MyClass );
  44.   NEW_THIS_MENU_ITEM( mi, &menu, "Some action X2", Ev_SomeActionX, 2, MyClass );
  45.   .......
  46.  
  47.   menu.ExecPopup(x_mouse,y_mouse);
  48. }
  49.  
  50.  
  51. BOOL MyClass :: Ev_SomeAction1 ( TC_Event * )
  52. {
  53.   return TRUE;
  54. }
  55.  
  56.  
  57. BOOL MyClass :: Ev_SomeActionX ( TC_Event * event)
  58. {
  59.   switch( event->dw_user )
  60.   {
  61.     case 1 : DO SOME; return TRUE;
  62.     case 2 : DO SOME; return TRUE;
  63.   }
  64.   return TRUE;
  65. }
  66.  
  67. */
  68. #define NEW_S_MENU_ITEM(mi,pp,text,func,dw_u)    \
  69.     mi=new TC_CMenu(0,text);(pp)->Add(mi);\
  70.     mi->SetSEventHandler(event_t(0,0),\
  71.     (S_EVENT_HANDLER)func,\
  72.     dw_u)
  73.  
  74. // **********************************************************************
  75. class TCCORELIB TC_CMenu 
  76.     : public TC_CEventMaster
  77. {
  78. public: 
  79. enum  {
  80.  T_SEP = -1,
  81.  T_ITEM = 0,
  82.  T_POPUP = 1,
  83. };
  84. public:  int m_Type ;
  85. public:  HMENU m_HMenu ;
  86. public:  int m_Cmd0 ;
  87. public:  int m_Cmd ;
  88. public:  HIMAGELIST hImgLst ;
  89. public:  int iImgIdx ;
  90. public:  char b_Checked ;
  91. public:  char b_Disabled ;
  92. public:  char b_OwnerDraw ;
  93. public:  char b_Break ;
  94. public:  char _ppp_OwnerDraw ;
  95. public:  int _ppp_CxImg ;
  96. public:  int _ppp_CxLeft ;
  97. public:  int _ppp_CxRight ;
  98. public:  int _mi_Height ;
  99. public:  TC_CMenu* m_Parent ;
  100. public:  TC_CString m_Text ;
  101. public:  TC_CString m_StatusText ;
  102. public:  TC_TArrayPTR <TC_CMenu> aChildren ;
  103. public:  static  HWND m_HWndPPP ;
  104. public:  static  BOOL b_Done ;
  105. public:  static  int m_GCmd ;
  106. public:  static  TCArrayINT a_GCmds ;
  107. public:  static  TC_CMenu* p_CurMenu ;
  108. public:   TC_CMenu (int type, LPCSTR text, int cmd=0)  ;
  109. public: virtual  ~TC_CMenu ()  ;
  110. public: virtual void* GetInterface (LPCSTR name)  ;
  111. public: virtual const char* GetClassName ()  ;
  112. public:  void Clear ()  ;
  113. public:  int Insert (int idx, TC_CMenu *m)  ;
  114. public:  void Add (TC_CMenu *m)  ;
  115. public:  TC_CMenu* Add (LPCSTR text, int cmd, int mask =0)  ;
  116. public:  TC_CMenu * AddSep ()  ;
  117. public:  int Count ()  ;
  118. public:  TC_CMenu* PChild (int idx)  ;
  119. public:  TC_CMenu* GetByCmd (int cmd)  ;
  120. public:  TC_CMenu* GetByHMenu (HMENU hmenu)  ;
  121. public:  void SetupCmds ()  ;
  122. public:  void ExecBar (HWND hWnd)  ;
  123. public:  void RebuildPopup ()  ;
  124. public:  int ExecPopup (int x, int y, HWND hwnd=0)  ;
  125. public: static void InitializeTPM (HWND hwnd)  ;
  126. public:  BOOL Wm_MenuSelect (WPARAM wParam, LPARAM lParam, TC_CString &stt, BOOL mdi_max)  ;
  127. private:  void Clear_HMenu (BOOL me)  ;
  128. private:  void _Add2H ()  ;
  129. private:  void Add2HLoop ()  ;
  130. private:  void Check_CMDs1 ()  ;
  131. private:  void Check_CMDs2 ()  ;
  132. private:  static  WNDPROC oldWndProc ;
  133. private: static LRESULT CALLBACK WndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)  ;
  134. public:  void Draw (DRAWITEMSTRUCT *dis)  ;
  135. public:  void Measure (MEASUREITEMSTRUCT *mis)  ;
  136.  
  137. }; // end of class TC_CMenu
  138.  
  139. // **********************************************************************
  140.  
  141. #endif // _INC_MENU_HPP
  142.