nux-0.9.46
|
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 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 ComputeChildLayout(); 00120 } 00121 }; 00122 00123 } 00124 00125 #endif // STATICTEXTBOX_H