wg_button.h

00001 // wg_button.h
00002 //
00003 // CButton interface
00004 //
00005 //
00006 // Copyright (c) 2002-2004 Rob Wiskow
00007 // rob-dev@boxedchaos.com
00008 //
00009 // This library is free software; you can redistribute it and/or
00010 // modify it under the terms of the GNU Lesser General Public
00011 // License as published by the Free Software Foundation; either
00012 // version 2.1 of the License, or (at your option) any later version.
00013 //
00014 // This library is distributed in the hope that it will be useful,
00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00017 // Lesser General Public License for more details.
00018 //
00019 // You should have received a copy of the GNU Lesser General Public
00020 // License along with this library; if not, write to the Free Software
00021 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
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      // CWindow overrides
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      // CMessageClient overrides
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      // CWindow overrides
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 

Generated on Wed May 16 23:11:25 2007 for wGui by  doxygen 1.5.1