nux-1.16.0
StaticTextBox.h
00001 /*
00002  * Copyright 2010 Inalogic® Inc.
00003  *
00004  * This program is free software: you can redistribute it and/or modify it
00005  * under the terms of the GNU Lesser General Public License, as
00006  * published by the  Free Software Foundation; either version 2.1 or 3.0
00007  * of the License.
00008  *
00009  * This program is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranties of
00011  * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
00012  * PURPOSE.  See the applicable version of the GNU Lesser General Public
00013  * License for more details.
00014  *
00015  * You should have received a copy of both the GNU Lesser General Public
00016  * License along with this program. If not, see <http://www.gnu.org/licenses/>
00017  *
00018  * Authored by: Jay Taoko <jaytaoko@inalogic.com>
00019  *
00020  */
00021 
00022 
00023 #ifndef STATICTEXTBOX_H
00024 #define STATICTEXTBOX_H
00025 
00026 namespace nux
00027 {
00028 
00029   class Validator;
00030 
00031   class StaticTextBox : public View //public InputArea
00032   {
00033     NUX_DECLARE_OBJECT_TYPE (StaticTextBox, View);
00034   public:
00035     StaticTextBox (const TCHAR *Caption, NUX_FILE_LINE_PROTO);
00036     ~StaticTextBox();
00037     virtual long ProcessEvent (IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
00038     virtual void Draw (GraphicsEngine &GfxContext, bool force_draw);
00039     virtual void DrawContent (GraphicsEngine &GfxContext, bool force_draw);
00040     virtual void PostDraw (GraphicsEngine &GfxContext, bool force_draw);
00041 
00042     // API
00043     void SetText (const TCHAR &Caption);
00044     void SetText (const TCHAR *Caption);
00045     void SetText (const tstring &Caption);
00046     void SetText (const NString &Caption);
00047     const TCHAR *GetText() const;
00048     t_u32 GetTextSize() const
00049     {
00050       return (t_u32) m_Text.Length();
00051     }
00052 
00054 
00058     void SetMinWidthMatchText (bool b);
00060     bool GetMinWidthMatchText() const;
00061 
00062     void SetTextColor (Color color)
00063     {
00064       m_TextColor = color;
00065     };
00066     Color GetTextColor() const
00067     {
00068       return m_TextColor;
00069     };
00070 
00071     void SetTextBackgroundColor (const Color &color)
00072     {
00073       m_BackgroundColor = color;
00074     }
00075     Color GetTextBackgroundColor() const
00076     {
00077       return m_BackgroundColor;
00078     }
00079 
00080     void SetTextAlignment (TextAlignment alignment)
00081     {
00082       m_TextAlignment = alignment;
00083     }
00084     TextAlignment GetTextAlignment()
00085     {
00086       return m_TextAlignment;
00087     }
00088 
00089     void SetDrawBackground (bool b)
00090     {
00091       m_bDrawBackground = b;
00092     }
00093     void SetBackground (AbstractPaintLayer *bkg);
00094 
00096     //  SIGNALS    //
00098 
00099     virtual void SetFont (ObjectPtr<FontTexture> Font);
00100   protected:
00101     virtual bool AcceptKeyNavFocus();
00102     void AdjustMinWidthToMatchText();
00103 
00104     NString m_Text;
00105     Color m_TextColor;
00106     Color m_BackgroundColor;
00107     tstring m_temporary_caption;
00108     Validator *m_validator;
00109     TextAlignment m_TextAlignment;
00110     AbstractPaintLayer *m_Background;
00111     bool m_bMinimumWidthMatchText;
00112     bool m_bDrawBackground;
00114     bool m_WriteAlpha;
00115 
00116   public:
00117     virtual void SetGeometry (const Geometry &geo)
00118     {
00119       Area::SetGeometry (geo);
00120       ComputeChildLayout();
00121     }
00122   };
00123 
00124 }
00125 
00126 #endif // STATICTEXTBOX_H
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends