wg_editbox.h

00001 // wg_editbox.h
00002 //
00003 // CEditBox 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_EDITBOX_H_
00026 #define _WG_EDITBOX_H_
00027 
00028 #include "wg_window.h"
00029 #include "wg_painter.h"
00030 #include "wg_renderedstring.h"
00031 #include "wg_timer.h"
00032 #include "wg_resources.h"
00033 #include <memory>
00034 
00035 
00036 namespace wGui
00037 {
00038 
00040 
00042 
00043 class CEditBox : public CWindow
00044 {
00045 public:
00051      CEditBox(const CRect& WindowRect, CWindow* pParent, CFontEngine* pFontEngine = 0);
00052 
00054      virtual ~CEditBox(void);
00055 
00058      void SetUsePasswordMask(bool bUseMask) { m_bUseMask = bUseMask; }
00059 
00062      bool UsingPasswordMask(void) const { return m_bUseMask; }
00063 
00066      void SetReadOnly(bool bReadOnly);
00067 
00070      bool IsReadOnly(void) const { return m_bReadOnly; }
00071 
00074      std::wstring GetSelText(void) const;
00075 
00079      void SetSelection(std::wstring::size_type iSelStart, int iSelLength);
00080 
00083      virtual std::wstring::size_type GetSelectionStart(void) const { return m_SelStart; }
00084 
00087      virtual int GetSelectionLength(void) const { return m_SelLength; }
00088 
00092      virtual std::wstring::size_type GetIndexFromPoint(const CPoint& Point) const; 
00093 
00094 
00095      // CWindow overrides
00097      virtual void Draw(void) const;
00098 
00101      virtual void SetWindowText(const std::wstring& sText);
00102 
00108      virtual bool OnMouseButtonDown(CPoint Point, unsigned int Button);
00109 
00110 
00111      // CMessageClient overrides
00114      virtual bool HandleMessage(CMessage* pMessage);
00115 
00116 
00117 protected:
00118 
00122      void SelDelete(std::wstring* psString);
00123 
00124      CFontEngine* m_pFontEngine; 
00125      std::auto_ptr<CRenderedString> m_pRenderedString; 
00126      unsigned char m_FontSize;  
00127      std::wstring::size_type m_SelStart;  
00128      int m_SelLength;  
00129      std::wstring::size_type m_DragStart;  
00130      mutable int m_ScrollOffset;  
00131      bool m_bReadOnly;  
00132      bool m_bMouseDown; 
00133      bool m_bUseMask; 
00134      bool m_bLastMouseMoveInside;  
00135 
00136 
00137 private:
00138      void operator=(CEditBox) { }  
00139      bool m_bDrawCursor;
00140      CTimer* m_pDblClickTimer; 
00141      CTimer* m_pCursorTimer; 
00142 };
00143 
00144 }
00145 
00146 
00147 #include "unit_tests/wg_editbox_unittests.h"
00148 
00149 #endif // _WG_EDITBOX_H_

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