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 >
Wrap
Text File
|
1996-07-29
|
6KB
|
217 lines
//--------------------------------------------------------------
// $Source: /rcs/vwrcs/components/intel/pmsubs.hh,v $
// Checked in by: $Author: mathieuj $
// $Date: 1996/04/03 18:47:10 $ $Revision: 1.12 $
//--------------------------------------------------------------
// Copyright (c) International Business Machines Inc, 1994
//
// ALL RIGHTS RESERVED. This notice is intended as a precaution
// against inadvertent publication, and shall not be deemed to
// consitute an acknowledgment that publication has occurred
// nor to imply any waiver of confidentiality. The year included
// in the notice is the year of the creation of the work.
//--------------------------------------------------------------
// DESCRIPTION:
// This file contains the class declaration for the
// VwpMenu class.
//--------------------------------------------------------------
#ifndef PMSUBS_HH
#define PMSUBS_HH
#ifdef VSYS_OS2
#define MENU_MASK 0xffffffff
#define MF_BYCOMMAND 1
#define MF_POPUP 2
#define MF_STRING 4
#define MF_BYPOSITION 8
#define MF_ENABLED 0
#define MF_GRAYED 16
#define MF_CHECKED 32
#define MF_UNCHECKED 0
#define MF_SEPARATOR 64
#define MF_MENUBREAK 128
#define MF_MENUBARBREAK 512
#define MF_DISABLED 1024
#define SHIFT_FLAG AF_SHIFT
#define CTRL_FLAG AF_CONTROL
#define ALT_FLAG AF_ALT
#define POPUPMENU_LEFTALIGN 0 // The left side of the pop-up menu is at x.
#define POPUPMENU_CENTERALIGN 4 // The pop-up menu is centered at x.
#define POPUPMENU_RIGHTALIGN 8 // The right side of the pop-up menu is at x.
#define POPUPMENU_LEFTBUTTON 0 // Recognizes left button only
#define POPUPMENU_RIGHTBUTTON 2 // Recognizes left or right button
#else //WINDOWS
#define MENU_MASK 0x0ffff
#define MIT_END -1
#define SHIFT_FLAG 0x04
#define CTRL_FLAG 0x08
#define ALT_FLAG 0x10
class VwpMenu;
#ifdef NOTEMPLATES
# ifndef MwMenuListDefined
# define MwMenuListDefined
# define CLASSNAME VwiMenuList
# define ENTRYTYPE VwpMenu*
# include <mst/varray.mst>
# endif
# ifndef HmenuToMwCompMapDefined
# define HmenuToMwCompMapDefined
# define CLASSNAME VwiHmenuToMwCompMap
# define ENTRYTYPE VwpMenu*
# include <mst/ihash.mst>
# endif
#else
# include <ihash.hh>
typedef VeIHashTable<VwpMenu*> VwiHmenuToMwCompMap;
#endif // NOTEMPLATES
#endif
#define POPUPMENU_XPASSED 64
#define POPUPMENU_YPASSED 128
VCLASS VwpMenu : public VwpWnd {
public:
VOPERDECL VwpMenu(void);
VINLINEOPERDECL VwpMenu(HMENU hMenu);
VMETHODDECL(void) CreateMenu(VwpWnd *parent);
VMETHODDECL(void) CreatePopupMenu(int id,HMENU parent);
VINLINEDECL(void) RemoveMenu(int id, int flag);
VINLINEDECL(void) SetMenuText(int id, char *text);
VINLINEDECL(void) EnableMenuItem(int id, int flag);
VINLINEDECL(void) CheckMenuItem(int id, int flag);
VMETHODDECL(void) InsertMenu(int id, int pos, int flags,HMENU hMenu, char *itsCaption);
VMETHODDECL(void) InsertMenu( int pos, int flags,int id, char *itsCaption);
VMETHODDECL(void) ModifyMenu(int id, int flags, int id2, char *aCaption);
VINLINEDECL(HMENU) GetSafeHmenu(void);
VMETHODDECL(void) SizeMenu(VwpWnd *parent);
VMETHODDECL(BOOL) Popup(HWND frame, int flags, int x, int y);
VINLINEDECL(void) Detach();
static VMETHODDECL(VwpMenu *) FromHandle(HWND hwnd);
static VMETHODDECL(BOOL) UpdatingMenu(void);
VINLINEDECL(void) IncNbItems() {itsNbItems++;};
VINLINEDECL(void) DecNbItems() {itsNbItems--;};
VINLINEDECL(int) NbItems() {return itsNbItems;};
#ifdef VSYS_WINDOWS
VOPERDECL ~VwpMenu(void);
VMETHODDECL(VwpMenu*) GetSubMenu(int i);
VINLINEDECL(int) GetMenuItemCount (void);
VMETHODDECL(void) Link (HMENU);
VMETHODDECL(void) Unlink (HMENU);
static VMETHODDECL(VwpMenu*) Owner(HMENU);
static VMETHODDECL(VwpMenu*) FromHandle(HMENU hm);
#endif
protected:
private:
#ifdef VSYS_WINDOWS
HMENU hmenu;
static VwiHmenuToMwCompMap itsLinks;
#endif
int itsNbItems;
};
VINLINEOPERDEF VwpMenu::VwpMenu(HMENU hMenu)
{
hwnd = (HWND)hMenu;
#ifdef VSYS_WINDOWS
hmenu = hMenu;
#endif
};
VINLINEDEF(void) VwpMenu::Detach()
{
#ifdef VSYS_WINDOWS
hmenu = 0;
#endif
};
#ifdef VSYS_OS2
VINLINEDEF(void) VwpMenu::RemoveMenu(int id, int flag)
{
Message(MM_REMOVEITEM,MPFROM2SHORT(id,TRUE),0L);
}
VINLINEDEF(void) VwpMenu::SetMenuText(int id, char *text)
{
Message(MM_SETITEMTEXT, (MPARAM) id, (MPARAM) text);
}
VINLINEDEF(void) VwpMenu::EnableMenuItem(int id, int flag)
{
Message(MM_SETITEMATTR, MPFROM2SHORT(id,TRUE),
MPFROM2SHORT(MIA_DISABLED,((flag & MF_GRAYED) ? MIA_DISABLED : FALSE)));
}
VINLINEDEF(void) VwpMenu::CheckMenuItem(int id, int flag)
{
Message(MM_SETITEMATTR, MPFROM2SHORT(id,TRUE),
MPFROM2SHORT(MIA_CHECKED,((flag & MF_CHECKED) ? MIA_CHECKED : FALSE)));
}
VINLINEDEF(HMENU) VwpMenu::GetSafeHmenu(void)
{
return hwnd;
}
inline VwpMenu* VwpMenu::FromHandle(HWND hwnd)
{
return (VwpMenu *) FromHandlePermanent(hwnd);
}
#else // WINDOWS
VINLINEDEF(void) VwpMenu::RemoveMenu(int id, int flag)
{
::RemoveMenu (hmenu, id, flag);
}
VINLINEDEF(void) VwpMenu::SetMenuText(int id, char *text)
{
::ModifyMenu (hmenu, id, MF_BYCOMMAND, id, text);
}
VINLINEDEF(void) VwpMenu::EnableMenuItem(int id, int flag)
{
::EnableMenuItem (hmenu, id, flag);
}
VINLINEDEF(void) VwpMenu::CheckMenuItem(int id, int flag)
{
::CheckMenuItem(hmenu, id, flag);
}
VINLINEDEF(HMENU) VwpMenu::GetSafeHmenu(void)
{
return hmenu;
}
VINLINEDEF(int) VwpMenu::GetMenuItemCount()
{
return ::GetMenuItemCount(hmenu);
}
#endif
#endif // PMSUBS_HH