00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef _WG_BUTTON_H_
00026 #define _WG_BUTTON_H_
00027
00028 #include "wg_window.h"
00029 #include "wg_painter.h"
00030 #include "wg_renderedstring.h"
00031 #include "wg_picture.h"
00032 #include <memory>
00033
00034
00035 namespace wGui
00036 {
00037
00039
00041
00042 class CButton : public CWindow
00043 {
00044 public:
00051 CButton(const CRect& WindowRect, CWindow* pParent, std::wstring sText, CFontEngine* pFontEngine = 0);
00052
00054 virtual ~CButton(void);
00055
00057 enum EState {
00058 UP,
00059 DOWN,
00060 DISABLED
00061 };
00062
00065 EState GetButtonState(void) const { return m_eButtonState; }
00066
00069 void SetButtonState(EState eState);
00070
00071
00072
00074 virtual void Draw(void) const;
00075
00078 virtual void SetWindowText(const std::wstring& sWindowText);
00079
00085 virtual bool OnMouseButtonDown(CPoint Point, unsigned int Button);
00086
00092 virtual bool OnMouseButtonUp(CPoint Point, unsigned int Button);
00093
00094
00095
00098 virtual bool HandleMessage(CMessage* pMessage);
00099
00100
00101 protected:
00102 CFontEngine* m_pFontEngine;
00103 std::auto_ptr<CRenderedString> m_pRenderedString;
00104 EState m_eButtonState;
00105 unsigned int m_MouseButton;
00106
00107 private:
00108 void operator=(CButton) { }
00109 };
00110
00111
00113
00114 class CPictureButton : public CButton
00115 {
00116 public:
00121 CPictureButton(const CRect& WindowRect, CWindow* pParent, std::wstring sPictureFile);
00122
00127 CPictureButton(const CRect& WindowRect, CWindow* pParent, const CBitmapResourceHandle& hBitmap);
00128
00130 virtual ~CPictureButton(void);
00131
00132
00135 void SetPicture(std::wstring sPictureFile);
00136
00139 void SetPicture(const CBitmapResourceHandle& hBitmap);
00140
00141
00142
00144 virtual void Draw(void) const;
00145
00146
00147 private:
00148 std::auto_ptr<CBitmapResourceHandle> m_phBitmap;
00149 void operator=(CPictureButton) { }
00150 };
00151
00152 }
00153
00154
00155 #include "unit_tests/wg_button_unittests.h"
00156
00157 #endif // _WG_BUTTON_H_
00158
00159