summaryrefslogtreecommitdiff
path: root/win/Bmpmenu.h
blob: b32e01e1d6dccd7fd2cf4caa8e2dd44763578696 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
// BMPMenu.h : header file
// Version : 2.3

#include <afxtempl.h>

#ifndef _BMPMENU_H_
#define _BMPMENU_H_

// CBMPMenuData class. Fill this class structure to define a single menu item:

class CBMPMenuData
{
wchar_t *m_szMenuText;
public:
CBMPMenuData () {menuIconNormal=-1;xoffset=-1;bitmap=NULL;
               nFlags=0;nID=0;syncflag=0;m_szMenuText=NULL;};
void SetAnsiString(LPCSTR szAnsiString);
void SetWideString(const wchar_t *szWideString);
const wchar_t *GetWideString(void) {return m_szMenuText;};
~CBMPMenuData ();
CString GetString(void);//returns the menu text in ANSI or UNICODE
int xoffset;
int menuIconNormal;
UINT nFlags,nID,syncflag;
CImageList *bitmap;
};

//struct CMenuItemInfo : public MENUITEMINFO {
struct CMenuItemInfo : public 
//MENUITEMINFO 
#ifndef UNICODE   //SK: this fixes warning C4097: typedef-name 'MENUITEMINFO' used as synonym for class-name 'tagMENUITEMINFOA'
tagMENUITEMINFOA
#else
tagMENUITEMINFOW
#endif
    {
	CMenuItemInfo()
	{ memset(this, 0, sizeof(MENUITEMINFO));
	  cbSize = sizeof(MENUITEMINFO);
	}
};




typedef enum {Normal,TextOnly} HIGHLIGHTSTYLE;

#ifndef UNICODE
#define AppendODMenu AppendODMenuA
#define ModifyODMenu ModifyODMenuA
#else
#define AppendODMenu AppendODMenuW
#define ModifyODMenu ModifyODMenuW
#endif



class CBMPMenu : public CMenu  // Derived from CMenu
{
// Construction
public:
CBMPMenu(); 
// Attributes
protected:
CTypedPtrArray<CPtrArray, CBMPMenuData*> m_MenuList;  // Stores list of menu items 
// When loading an owner-drawn menu using a Resource, CBMPMenu must keep track of
// the popup menu's that it creates. Warning, this list *MUST* be destroyed
// last item first :)
CImageList m_List;

CTypedPtrArray<CPtrArray, CBMPMenu*>  m_SubMenus;  // Stores list of sub-menus 
// Operations
public: 
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CCustomMenu)
//}}AFX_VIRTUAL 
// Implementation
public:
  static BOOL IsNewShell(void);
  void SetBitmapBackground(COLORREF color);
  void SetDisableOldStyle(void);
  void UnSetDisableOldStyle(void);
  BOOL GetDisableOldStyle(void);
  void UnSetBitmapBackground(void);
  int AddBitmapToImageList(CImageList *list,UINT nResourceID);
  BOOL LoadFromToolBar(UINT nID,UINT nToolBar,int& xoffset);
  void InsertSpaces(void);
  static LRESULT FindKeyboardShortcut(UINT nChar,UINT nFlags,CMenu *pMenu);
  static void UpdateMenu(CMenu *pmenu);
  BOOL IsMenu(CMenu *submenu);
  void DrawCheckMark(CDC *pDC,int x,int y,COLORREF color);
  void DrawRadioDot(CDC *pDC,int x,int y,COLORREF color);
  CBMPMenu *FindMenuOption(int nId,int& nLoc);
  CBMPMenuData *FindMenuOption(wchar_t *lpstrText);
  BOOL GetMenuText(UINT id,CString &string);
  CImageList *checkmaps;
  BOOL checkmapsshare;
  int m_selectcheck;
  int m_unselectcheck;
  void LoadCheckmarkBitmap(int unselect,int select);
  void DitherBlt(HDC hdcDest, int nXDest, int nYDest, int nWidth, 
                 int nHeight, HBITMAP hbm, int nXSrc, int nYSrc);
  void DitherBlt2(CDC *drawdc, int nXDest, int nYDest, int nWidth, 
                  int nHeight, CBitmap &bmp, int nXSrc, int nYSrc);
  HBITMAP LoadSysColorBitmap(int nResourceId);

virtual ~CBMPMenu();  // Virtual Destructor 
// Drawing: 
virtual void DrawItem( LPDRAWITEMSTRUCT);  // Draw an item
virtual void MeasureItem( LPMEASUREITEMSTRUCT );  // Measure an item

// Customizing:

void SetIconSize (int, int);  // Set icon size

BOOL AppendODMenuA(LPCSTR lpstrText, 
UINT nFlags = MF_OWNERDRAW,
UINT nID = 0,
int nIconNormal = -1); // Owner-Drawn Append 

BOOL AppendODMenuW(wchar_t *lpstrText, 
UINT nFlags = MF_OWNERDRAW,
UINT nID = 0,
int nIconNormal = -1); // Owner-Drawn Append 


BOOL ModifyODMenuA(const char *lpstrText,UINT nID=0,int nIconNormal=-1);
BOOL ModifyODMenuA(const char *lpstrText,const char *OptionText,int nIconNormal);
BOOL ModifyODMenuW(wchar_t *lpstrText,UINT nID=0,int nIconNormal=-1);
BOOL ModifyODMenuW(wchar_t *lpstrText,wchar_t *OptionText,int nIconNormal);
CBMPMenuData *NewODMenu(UINT pos,UINT nFlags,UINT nID,CString string);
void SynchronizeMenu(void);
void CBMPMenu::InitializeMenuList(int value);
void CBMPMenu::DeleteMenuList(void);
CBMPMenuData *CBMPMenu::FindMenuList(UINT nID);
virtual BOOL LoadMenu(LPCTSTR lpszResourceName);  // Load a menu
virtual BOOL LoadMenu(int nResource);  // ... 
void AddFromToolBar(CToolBar* pToolBar, int nResourceID);
BOOL Draw3DCheckmark(CDC *dc, const CRect& rc,BOOL bSelected,
                     HBITMAP hbmCheck);
BOOL LoadToolbar(UINT nToolBar);
BOOL LoadToolbars(const UINT *arID,int n);

// Destoying:

virtual BOOL DestroyMenu();

// Generated message map functions
protected:
int m_iconX,m_iconY;
COLORREF m_bitmapBackground;
BOOL m_bitmapBackgroundFlag;
BOOL disable_old_style;
}; 

#endif