Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

ODMenu.h

Go to the documentation of this file.
00001 #ifndef _ODMENU_CLW
00002 #define _ODMENU_CLW
00003 
00004 #include <windows.h>
00005 #include <map>
00006 #include <string>
00007 
00008 using namespace std;
00009 
00010 enum bitmapType {eNormal, eDisabled, eShadow, eFaded};
00011 
00012 typedef struct tagODMENUITEM 
00013 {
00014     UINT dwType;
00015     UINT wID;
00016     string rawText;
00017     string displayText;
00018     string rawDisplayText;
00019     string shortcutText;
00020     HBITMAP hBitmap;
00021     bool topMost;
00022 
00023 } ODMENUITEM;
00024 
00025 typedef map<UINT, ODMENUITEM> ODMENUITEMS;
00026 
00027 class ODMenu
00028 {
00029     //Aesthetic parameters
00030     COLORREF m_clrIconBar;
00031     COLORREF m_clrTranparent;
00032     COLORREF m_clrItemText;
00033     COLORREF m_clrItemBackground;
00034     COLORREF m_clrHighlightItemText;
00035     COLORREF m_clrHighlightItemBackground;
00036     COLORREF m_clrHighlightItemOutline;
00037     COLORREF m_clrSeparator;
00038     COLORREF m_clrIconShadow;
00039     COLORREF m_clrCheckMark;
00040     COLORREF m_clrCheckMarkBackground;
00041     COLORREF m_clrCheckMarkBackgroundHighlight;
00042     UINT m_iconBarMargin;
00043     UINT m_iconWidth;
00044     UINT m_iconHeight;
00045     UINT m_textLeftMargin;
00046     UINT m_textRightMargin;
00047     UINT m_verticalSpacing;
00048 
00049     //GDI object handles
00050     HBRUSH m_hIconBarBrush;
00051     HBRUSH m_hIconShadowBrush;
00052     HBRUSH m_hCheckMarkBackgroundBrush;
00053     HBRUSH m_hCheckMarkBackgroundHighlightBrush;
00054         HBRUSH m_hItemBackground;
00055     HBRUSH m_hHighlightItemBackgroundBrush;
00056     HPEN m_hSelectionOutlinePen;
00057     HPEN m_hSeparatorPen;
00058     HPEN m_hCheckMarkPen;
00059     HFONT m_hFont;
00060     
00061     UINT m_seqNumber;
00062     HMENU m_hRootMenu;
00063     TCHAR m_szItemText[256];
00064     ODMENUITEMS m_menuItems;
00065     
00066     int m_alpDx[256];
00067 
00068     void EnumMenuItems(HMENU hMenu);
00069     void DeleteSubMenu(HMENU hMenu);
00070     void SetMenuItemOwnerDrawn(HMENU hMenu, UINT item, UINT type);
00071     void GenerateDisplayText(ODMENUITEM& item);
00072     void DrawItemText(DRAWITEMSTRUCT* lpdis, ODMENUITEM& item);
00073     void DrawIconBar(DRAWITEMSTRUCT* lpdis, ODMENUITEM& item);
00074     void ComputeMenuTextPos(DRAWITEMSTRUCT* lpdis, ODMENUITEM& item, int& x, int& y, SIZE& size);
00075     void DrawTransparentBitmap(HDC hDC, HBITMAP hBitmap, short xStart, short yStart,
00076             COLORREF cTransparentColor, bitmapType eType=eNormal);
00077     void DrawCheckMark(HDC hDC, short x, short y, bool bNarrow=true);
00078     COLORREF LightenColor(COLORREF col, double factor);
00079     COLORREF DarkenColor(COLORREF col, double factor);
00080     COLORREF AverageColor(COLORREF col1, COLORREF col2, double weight1=0.5);
00081     double GetColorIntensity(COLORREF col);
00082 
00083 public:
00084     ODMenu();
00085     ~ODMenu();
00086 
00087     bool Init(HWND hOwnerWnd, HMENU hMenu);
00088     void MeasureItem(HWND hWnd, LPARAM lParam);
00089     void DrawItem(HWND hWnd, LPARAM lParam);
00090     void OnDestroy();
00091     bool GetItem(UINT id, ODMENUITEM** ppItem);
00092     void SetItemImage(HINSTANCE hInst, UINT wID, UINT idBitmap);
00093     void AddItem(HMENU hMenu, int index, MENUITEMINFO* pItemInfo=NULL);
00094     void DeleteItem(HMENU hMenu, int index);
00095 };
00096 
00097 #endif

Generated on Sat Jan 14 22:30:31 2006 for Celestia by  doxygen 1.4.1