home *** CD-ROM | disk | FTP | other *** search
/ PC Administrator / spravce.iso / TaskModule / src / ButtonImage.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-09-08  |  4.7 KB  |  127 lines

  1. // ButtonImage.h: interface for the CButtonImage class.
  2. //
  3. /*
  4. Copyright 2001 Anish Mistry. All rights reserved.
  5.  
  6. Redistribution and use in source and binary forms, with or without modification,
  7. are permitted provided that the following conditions are met:
  8.  
  9.    1. Redistributions of source code must retain the above copyright notice, 
  10.    this list of conditions and the following disclaimer.
  11.    2. Redistributions in binary form must reproduce the above copyright notice,
  12.    this list of conditions and the following disclaimer in the documentation 
  13.    and/or other materials provided with the distribution.
  14.  
  15. THIS SOFTWARE IS PROVIDED BY ANISH MISTRY ``AS IS'' AND ANY EXPRESS OR IMPLIED 
  16. WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 
  17. AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS 
  18. OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  19. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  20. GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  21. CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  22. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  23. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24.  
  25. The views and conclusions contained in the software and documentation are those
  26. of the authors and should not be interpreted as representing official policies,
  27. either expressed or implied, of Anish Mistry or AM Productions.
  28.  
  29. * Variation of the FreeBSD License. http://www.freebsd.org/copyright/freebsd-license.html
  30. */
  31. //////////////////////////////////////////////////////////////////////
  32.  
  33. #if !defined(AFX_ButtonImage_H__0317E4E1_0333_11D4_93B2_00A0CC3702BF__INCLUDED_)
  34. #define AFX_ButtonImage_H__0317E4E1_0333_11D4_93B2_00A0CC3702BF__INCLUDED_
  35.  
  36. #if _MSC_VER > 1000
  37. #pragma once
  38. #endif // _MSC_VER > 1000
  39.  
  40. #include "Thunk.h"
  41.  
  42. // button image attribs
  43. #define BI_CENTERIMAGE 1        // 00000001
  44. // other image attribs
  45. #define BI_SIZE 8        // 00001000
  46.  
  47. class CButtonImage  
  48. {
  49. protected:
  50.     virtual LRESULT WindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
  51.     ThunkData m_Thunk;
  52. public:
  53.     void SetTransparentColor(COLORREF cColor);
  54.     void SetTextStyles(unsigned int styles);
  55.     COLORREF SetFontColor(COLORREF color);
  56.     COLORREF SetColor(COLORREF color);
  57.     CButtonImage();
  58.     virtual ~CButtonImage();
  59.     virtual void Create(UINT ID,HWND ownerWnd,HINSTANCE parentInstance,BYTE imageFlags,SIZE imgSz);
  60.     SIZE SetImageSize(SIZE newImageSize);
  61.     bool LoadCtrlImage(UINT iconID);
  62.     HWND GetSafeHwnd(void);
  63. protected:
  64.     bool OnDestroy();
  65.     virtual void Setup();
  66.     virtual void Cleanup();
  67.     COLORREF cTransparentColor;
  68.     void Draw3dRect(HDC destDC,RECT *rect,COLORREF topLeftColor,COLORREF bottomRightColor);
  69.     COLORREF GetHiliteColor(COLORREF color);
  70.     COLORREF GetShadowColor(COLORREF color);
  71.     SIZE GetButtonEdgeSize(unsigned long int extendedStyles);
  72.     void DrawControlText(HDC buttonDC,char *buttonText,RECT &buttonTextRect);
  73.     LRESULT OnPaint();
  74.     int LevelColorBottom(int color);
  75.     int LevelColorTop(int color);
  76.     POINT buttonTopLeft;
  77.     int OnSetStyle(unsigned long int styles,bool redraw);
  78.     unsigned int OnGetState();
  79.     void ToggleButtonState();
  80.     int OnSetState(WPARAM state);
  81.     HANDLE GetButtonImage();
  82.     virtual void OnClick(HWND hWnd,LPARAM lParam);
  83.     void SetButtonImage(unsigned int type, HANDLE image);
  84.     virtual void OnMouseMove(LPARAM lParam);
  85.     void DrawButtonFrame(const HDC buttonDC,RECT *buttonRect);
  86.     void DrawButtonImage(const HDC buttonDC,const POINT imagePos);
  87.     void DrawImage(const HDC hDC,const POINT *pLeftTop,HANDLE hImage = NULL);
  88.     virtual RECT DrawButtonText(const HDC buttonDC,POINT &textPos, const RECT buttonRect);
  89.     void ExpandRectangle(unsigned int num, RECT *rect);
  90.     void ContractRectangle(unsigned int num,RECT *rect);
  91.     void ExpandRectangle(SIZE size,RECT *rect);
  92.     void ContractRectangle(SIZE size,RECT *rect);
  93.     bool CleanUpImage();
  94.     void DrawTransparentBitmap(HDC hDC, HBITMAP hBitmap, int x, int y, COLORREF crColour);
  95. //    LRESULT OnSetText(WPARAM wParam,LPARAM lParam);
  96.  
  97.     virtual bool Draw(HDC originalButtonDC);
  98.  
  99.     void SetOffset(void);
  100.  
  101.     WNDPROC oldWndProc;
  102.     HWND parentWnd;
  103.     unsigned int ctrlID;
  104.     bool firstDraw;
  105.     COLORREF fontColor;
  106.     bool hasFocus;
  107.     unsigned int imageType;
  108.     bool IsDown;
  109.     POINT imageTopLeft;    
  110.     int buttonState;
  111.     HGDIOBJ buttonImage;
  112.     SIZE imageSize;
  113.     HWND ctrlWnd;
  114.     HWND m_hWnd;
  115.     HINSTANCE appInstance;
  116.     BYTE flags;
  117.     POINT lastPoint;
  118.     bool cursorIsOut;
  119.     unsigned int m_nTextStyles;
  120.     unsigned int buttonColor;
  121.     SIZE borderSize;
  122.     UINT lastState;
  123.     unsigned long int m_nStyles;
  124. };
  125.  
  126. #endif // !defined(AFX_ButtonImage_H__0317E4E1_0333_11D4_93B2_00A0CC3702BF__INCLUDED_)
  127.