• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

xap_Win32ColourButton.h

Go to the documentation of this file.
00001 /* AbiWord
00002  * Copyright (C) 2003 Jordi Mas i Hernāndez
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00017  * 02110-1301 USA.
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         /* Draw colour example*/
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 /* xap_Win32ColourButton_H */
00084 

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1