Back to index

nux  3.0.0
StaticTextBox.h
Go to the documentation of this file.
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 char *Caption, NUX_FILE_LINE_PROTO);
00036     ~StaticTextBox();
00037     virtual void Draw(GraphicsEngine &graphics_engine, bool force_draw);
00038     virtual void DrawContent(GraphicsEngine &graphics_engine, bool force_draw);
00039     virtual void PostDraw(GraphicsEngine &graphics_engine, bool force_draw);
00040 
00041     // API
00042     void SetText(const char &Caption);
00043     void SetText(const char *Caption);
00044     void SetText(const tstring &Caption);
00045     void SetText(const NString &Caption);
00046     const char *GetText() const;
00047     unsigned int GetTextSize() const
00048     {
00049       return (unsigned int) m_Text.Length();
00050     }
00051 
00053 
00057     void SetMinWidthMatchText(bool b);
00059     bool GetMinWidthMatchText() const;
00060 
00061     void SetTextColor(Color color)
00062     {
00063       m_TextColor = color;
00064     };
00065     Color GetTextColor() const
00066     {
00067       return m_TextColor;
00068     };
00069 
00070     void SetTextBackgroundColor(const Color &color)
00071     {
00072       m_BackgroundColor = color;
00073     }
00074     Color GetTextBackgroundColor() const
00075     {
00076       return m_BackgroundColor;
00077     }
00078 
00079     void SetTextAlignment(TextAlignment alignment)
00080     {
00081       m_TextAlignment = alignment;
00082     }
00083     TextAlignment GetTextAlignment()
00084     {
00085       return m_TextAlignment;
00086     }
00087 
00088     void SetDrawBackground(bool b)
00089     {
00090       m_bDrawBackground = b;
00091     }
00092     void SetBackground(AbstractPaintLayer *bkg);
00093 
00095     //  SIGNALS    //
00097 
00098     virtual void SetFont(ObjectPtr<FontTexture> Font);
00099   protected:
00100     virtual bool AcceptKeyNavFocus();
00101     void AdjustMinWidthToMatchText();
00102 
00103     NString m_Text;
00104     Color m_TextColor;
00105     Color m_BackgroundColor;
00106     tstring m_temporary_caption;
00107     Validator *m_validator;
00108     TextAlignment m_TextAlignment;
00109     AbstractPaintLayer *m_Background;
00110     bool m_bMinimumWidthMatchText;
00111     bool m_bDrawBackground;
00113     bool m_WriteAlpha;
00114 
00115   public:
00116     virtual void SetGeometry(const Geometry &geo)
00117     {
00118       Area::SetGeometry(geo);
00119       ComputeContentSize();
00120     }
00121   };
00122 
00123 }
00124 
00125 #endif // STATICTEXTBOX_H