home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2000 February
/
PCWorld_2000-02_cd.bin
/
Software
/
TemaCD
/
tcvpa
/
data1.cab
/
MyFileGroup
/
INCLUDE
/
Menu.hpp
< prev
next >
Wrap
C/C++ Source or Header
|
1999-06-03
|
4KB
|
122 lines
#ifdef BUILD_TCCORE
#define TCCORELIB __declspec(dllexport)
#else
#ifdef BUILD_LOCAL
#define TCCORELIB
#else
#define TCCORELIB __declspec(dllimport)
#endif
#endif
#define NEW_THIS_MENU_ITEM(mi,pp,text,func,dw_u,cls) \
mi=new TC_CMenu(0,text);(pp)->Add(mi);\
mi->SetCEventHandler(event_t(0,0),this,\
(C_EVENT_HANDLER)((BOOL(cls::*)(TC_Event*))func),\
dw_u)
/**** Example:
void MyClass :: RunPopupMenu (void)
{
TC_CMenu menu( TC_CMenu::T_POPUP, "" );
TC_CMenu * mi;
NEW_THIS_MENU_ITEM( mi, &menu, "Some action1", Ev_SomeAction1, 0, MyClass );
NEW_THIS_MENU_ITEM( mi, &menu, "Some action2", Ev_SomeAction2, 0, MyClass );
NEW_THIS_MENU_ITEM( mi, &menu, "Some action X1", Ev_SomeActionX, 1, MyClass );
NEW_THIS_MENU_ITEM( mi, &menu, "Some action X2", Ev_SomeActionX, 2, MyClass );
.......
menu.ExecPopup(x_mouse,y_mouse);
}
BOOL MyClass :: Ev_SomeAction1 ( TC_Event * )
{
return TRUE;
}
BOOL MyClass :: Ev_SomeActionX ( TC_Event * event)
{
switch( event->dw_user )
{
case 1 : DO SOME; return TRUE;
case 2 : DO SOME; return TRUE;
}
return TRUE;
}
*/
#define NEW_S_MENU_ITEM(mi,pp,text,func,dw_u) \
mi=new TC_CMenu(0,text);(pp)->Add(mi);\
mi->SetSEventHandler(event_t(0,0),\
(S_EVENT_HANDLER)func,\
dw_u)
// **********************************************************************
class TCCORELIB TC_CMenu
: public TC_CEventMaster
{
public:
enum {
T_SEP = -1,
T_ITEM = 0,
T_POPUP = 1,
};
public: int m_Type ;
public: HMENU m_HMenu ;
public: int m_Cmd0 ;
public: int m_Cmd ;
public: HIMAGELIST hImgLst ;
public: int iImgIdx ;
public: char b_Checked ;
public: char b_Disabled ;
public: char b_OwnerDraw ;
public: char b_Bold ;
public: char _ppp_OwnerDraw ;
public: int _ppp_CxImg ;
public: int _ppp_CxLeft ;
public: int _ppp_CxRight ;
public: int _mi_Height ;
public: TC_CMenu* m_Parent ;
public: TC_CString m_Text ;
public: TC_CString m_StatusText ;
public: TC_TArrayPTR <TC_CMenu> aChildren ;
public: static HWND m_HWndPPP ;
public: static BOOL b_Done ;
public: static int m_GCmd ;
public: static TCArrayINT a_GCmds ;
public: static TC_CMenu* p_CurMenu ;
public: TC_CMenu (int type, LPCSTR text, int cmd=0) ;
public: virtual ~TC_CMenu () ;
public: virtual void* GetInterface (LPCSTR name) ;
public: virtual const char* GetClassName () ;
public: void Clear () ;
public: int Insert (int idx, TC_CMenu *m) ;
public: void Add (TC_CMenu *m) ;
public: TC_CMenu* Add (LPCSTR text, int cmd, int mask =0) ;
public: TC_CMenu * AddSep () ;
public: int Count () ;
public: TC_CMenu* PChild (int idx) ;
public: TC_CMenu* GetByCmd (int cmd) ;
public: TC_CMenu* GetByHMenu (HMENU hmenu) ;
public: void SetupCmds () ;
public: void ExecBar (HWND hWnd) ;
public: void RebuildPopup () ;
public: int ExecPopup (int x, int y, HWND hwnd=0) ;
public: static void InitializeTPM (HWND hwnd) ;
public: BOOL Wm_MenuSelect (WPARAM wParam, LPARAM lParam, TC_CString &stt, BOOL mdi_max) ;
private: void Clear_HMenu (BOOL me) ;
private: void _Add2H () ;
private: void Add2HLoop () ;
private: void Check_CMDs1 () ;
private: void Check_CMDs2 () ;
private: static WNDPROC oldWndProc ;
private: static LRESULT CALLBACK WndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) ;
public: void Draw (DRAWITEMSTRUCT *dis) ;
public: void Measure (MEASUREITEMSTRUCT *mis) ;
}; // end of class TC_CMenu
// **********************************************************************