Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef xap_Win32ColourButton_H
00021 #define xap_Win32ColourButton_H
00022
00023 #include <windows.h>
00024
00025 #define COLOUR_SMPLENGTH 20
00026 #define COLOUR_SMPHIGH 10
00027
00028 class ABI_EXPORT XAP_Win32ColourButton
00029 {
00030 public:
00031
00032 XAP_Win32ColourButton()
00033 {
00034 m_hBrush = NULL;
00035 m_bBtnEnabled = true;
00036 }
00037
00038 ~XAP_Win32ColourButton()
00039 {
00040 if (m_hBrush) DeleteObject (m_hBrush);
00041 }
00042
00043 void setColour(COLORREF color)
00044 {
00045 if (m_hBrush) DeleteObject (m_hBrush);
00046 m_hBrush = CreateSolidBrush(color);
00047 }
00048
00049 void setEnable(bool enable)
00050 {
00051 m_bBtnEnabled = enable;
00052 }
00053
00054 void draw(DRAWITEMSTRUCT* dis)
00055 {
00056 RECT colourArea;
00057
00058 DrawFrameControl(dis->hDC, &dis->rcItem, DFC_BUTTON, DFCS_BUTTONPUSH);
00059
00060
00061 colourArea.top = ((dis->rcItem.bottom-dis->rcItem.top)-COLOUR_SMPHIGH)/2;
00062 colourArea.left = ((dis->rcItem.right-dis->rcItem.left)-COLOUR_SMPLENGTH)/2;
00063 colourArea.bottom = colourArea.top+COLOUR_SMPHIGH;
00064 colourArea.right = colourArea.left+COLOUR_SMPLENGTH;
00065
00066 if (m_hBrush)
00067 FillRect(dis->hDC, &colourArea, (m_bBtnEnabled ? m_hBrush : GetSysColorBrush(COLOR_BTNSHADOW)));
00068 else
00069 FillRect(dis->hDC, &colourArea, GetSysColorBrush(m_bBtnEnabled ? COLOR_BTNFACE : COLOR_BTNSHADOW));
00070
00071 if ((dis->itemState & ODS_SELECTED) == ODS_SELECTED)
00072 DrawEdge(dis->hDC, &dis->rcItem, EDGE_RAISED, BF_RECT |BF_FLAT);
00073 }
00074
00075 private:
00076
00077 HBRUSH m_hBrush;
00078 bool m_bBtnEnabled;
00079 };
00080
00081
00082
00083 #endif
00084