00001 /*********************************************************************** 00002 filename: FalStaticText.h 00003 created: Tue Jul 5 2005 00004 author: Paul D Turner <paul@cegui.org.uk> 00005 *************************************************************************/ 00006 /*************************************************************************** 00007 * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team 00008 * 00009 * Permission is hereby granted, free of charge, to any person obtaining 00010 * a copy of this software and associated documentation files (the 00011 * "Software"), to deal in the Software without restriction, including 00012 * without limitation the rights to use, copy, modify, merge, publish, 00013 * distribute, sublicense, and/or sell copies of the Software, and to 00014 * permit persons to whom the Software is furnished to do so, subject to 00015 * the following conditions: 00016 * 00017 * The above copyright notice and this permission notice shall be 00018 * included in all copies or substantial portions of the Software. 00019 * 00020 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00021 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00022 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 00023 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 00024 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 00025 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00026 * OTHER DEALINGS IN THE SOFTWARE. 00027 ***************************************************************************/ 00028 #ifndef _FalStaticText_h_ 00029 #define _FalStaticText_h_ 00030 00031 #include "FalModule.h" 00032 #include "FalStatic.h" 00033 #include "FalStaticTextProperties.h" 00034 #include <vector> 00035 00036 #if defined(_MSC_VER) 00037 # pragma warning(push) 00038 # pragma warning(disable : 4251) 00039 #endif 00040 00041 // Start of CEGUI namespace section 00042 namespace CEGUI 00043 { 00070 class FALAGARDBASE_API FalagardStaticText : public FalagardStatic 00071 { 00072 public: 00073 static const utf8 TypeName[]; 00074 00075 /************************************************************************* 00076 Formatting Enumerations 00077 *************************************************************************/ 00082 enum HorzFormatting 00083 { 00084 LeftAligned, 00085 RightAligned, 00086 HorzCentred, 00087 HorzJustified, 00088 WordWrapLeftAligned, 00089 WordWrapRightAligned, 00090 WordWrapCentred, 00091 WordWrapJustified 00092 }; 00093 00098 enum VertFormatting 00099 { 00100 TopAligned, 00101 BottomAligned, 00102 VertCentred 00103 }; 00104 00105 /************************************************************************* 00106 Child Widget name suffix constants 00107 *************************************************************************/ 00108 static const String VertScrollbarNameSuffix; 00109 static const String HorzScrollbarNameSuffix; 00110 00111 /************************************************************************ 00112 Constructor / Destructor 00113 *************************************************************************/ 00118 FalagardStaticText(const String& type); 00119 00120 /************************************************************************ 00121 Scrolled text implementation 00122 *************************************************************************/ 00127 ColourRect getTextColours(void) const {return d_textCols;} 00128 00133 HorzFormatting getHorizontalFormatting(void) const {return d_horzFormatting;} 00134 00139 VertFormatting getVerticalFormatting(void) const {return d_vertFormatting;} 00140 00145 void setTextColours(const ColourRect& colours); 00146 00151 void setVerticalFormatting(VertFormatting v_fmt); 00152 00157 void setHorizontalFormatting(HorzFormatting h_fmt); 00158 00163 bool isVerticalScrollbarEnabled(void) const {return d_enableVertScrollbar;} 00164 00169 bool isHorizontalScrollbarEnabled(void) const {return d_enableHorzScrollbar;} 00170 00175 void setVerticalScrollbarEnabled(bool setting); 00176 00181 void setHorizontalScrollbarEnabled(bool setting); 00182 00183 void render(void); 00184 00185 protected: 00186 // overridden from FalagardStatic base class 00187 void onLookNFeelAssigned(); 00188 void onLookNFeelUnassigned(); 00189 00190 // text field with scrollbars methods 00191 void renderScrolledText(void); 00192 void configureScrollbars(void); 00193 Scrollbar* getVertScrollbar(void) const; 00194 Scrollbar* getHorzScrollbar(void) const; 00195 Rect getTextRenderArea(void) const; 00196 Size getDocumentSize(const Rect& renderArea) const; 00197 00198 // overridden event handlers 00199 bool onTextChanged(const EventArgs& e); 00200 bool onSized(const EventArgs& e); 00201 bool onFontChanged(const EventArgs& e); 00202 bool onMouseWheel(const EventArgs& e); 00203 00204 // event subscribers 00205 bool handleScrollbarChange(const EventArgs& e); 00206 00207 // properties 00208 static FalagardStaticTextProperties::TextColours d_textColoursProperty; 00209 static FalagardStaticTextProperties::VertFormatting d_vertFormattingProperty; 00210 static FalagardStaticTextProperties::HorzFormatting d_horzFormattingProperty; 00211 static FalagardStaticTextProperties::VertScrollbar d_vertScrollbarProperty; 00212 static FalagardStaticTextProperties::HorzScrollbar d_horzScrollbarProperty; 00213 00214 // implementation data 00215 HorzFormatting d_horzFormatting; 00216 VertFormatting d_vertFormatting; 00217 ColourRect d_textCols; 00218 bool d_enableVertScrollbar; 00219 bool d_enableHorzScrollbar; 00220 00221 typedef std::vector<Event::Connection> ConnectionList; 00222 ConnectionList d_connections; 00223 }; 00224 00225 } // End of CEGUI namespace section 00226 00227 #if defined(_MSC_VER) 00228 # pragma warning(pop) 00229 #endif 00230 00231 #endif // end of guard _FalStaticText_h_