Crazy Eddie's GUI System
0.8.4
|
00001 /*********************************************************************** 00002 created: 12/6/2004 00003 author: Paul D Turner 00004 00005 purpose: Interface for list box text items 00006 *************************************************************************/ 00007 /*************************************************************************** 00008 * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team 00009 * 00010 * Permission is hereby granted, free of charge, to any person obtaining 00011 * a copy of this software and associated documentation files (the 00012 * "Software"), to deal in the Software without restriction, including 00013 * without limitation the rights to use, copy, modify, merge, publish, 00014 * distribute, sublicense, and/or sell copies of the Software, and to 00015 * permit persons to whom the Software is furnished to do so, subject to 00016 * the following conditions: 00017 * 00018 * The above copyright notice and this permission notice shall be 00019 * included in all copies or substantial portions of the Software. 00020 * 00021 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00022 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00023 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 00024 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 00025 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 00026 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00027 * OTHER DEALINGS IN THE SOFTWARE. 00028 ***************************************************************************/ 00029 #ifndef _CEGUIListboxTextItem_h_ 00030 #define _CEGUIListboxTextItem_h_ 00031 #include "./ListboxItem.h" 00032 #include "../BasicRenderedStringParser.h" 00033 #include "../DefaultRenderedStringParser.h" 00034 00035 // Start of CEGUI namespace section 00036 namespace CEGUI 00037 { 00042 class CEGUIEXPORT ListboxTextItem : public ListboxItem 00043 { 00044 public: 00045 /************************************************************************* 00046 Constants 00047 *************************************************************************/ 00048 static const Colour DefaultTextColour; 00049 00050 00051 /************************************************************************* 00052 Construction and Destruction 00053 *************************************************************************/ 00058 ListboxTextItem(const String& text, uint item_id = 0, void* item_data = 0, bool disabled = false, bool auto_delete = true); 00059 00060 00065 virtual ~ListboxTextItem(void) {} 00066 00067 00068 /************************************************************************* 00069 Accessor methods 00070 *************************************************************************/ 00081 const Font* getFont(void) const; 00082 00083 00091 ColourRect getTextColours(void) const {return d_textCols;} 00092 00093 00094 /************************************************************************* 00095 Manipulator methods 00096 *************************************************************************/ 00107 void setFont(Font* font); 00108 00109 00120 void setFont(const String& font_name); 00121 00122 00133 void setTextColours(const ColourRect& cols) {d_textCols = cols;} 00134 00135 00155 void setTextColours(Colour top_left_colour, Colour top_right_colour, Colour bottom_left_colour, Colour bottom_right_colour); 00156 00157 00168 void setTextColours(Colour col) {setTextColours(col, col, col, col);} 00169 00179 void setTextParsingEnabled(const bool enable); 00180 00182 bool isTextParsingEnabled() const; 00183 00184 // base class overrides 00185 void setText(const String& text); 00186 bool handleFontRenderSizeChange(const Font* const font); 00187 00188 00189 /************************************************************************* 00190 Required implementations of pure virtuals from the base class. 00191 *************************************************************************/ 00192 Sizef getPixelSize(void) const; 00193 void draw(GeometryBuffer& buffer, const Rectf& targetRect, float alpha, const Rectf* clipper) const; 00194 00195 protected: 00196 void parseTextString() const; 00197 00198 /************************************************************************* 00199 Implementation Data 00200 *************************************************************************/ 00201 ColourRect d_textCols; 00202 Font* d_font; 00203 00204 static BasicRenderedStringParser d_stringParser; 00206 mutable RenderedString d_renderedString; 00208 mutable bool d_renderedStringValid; 00210 static DefaultRenderedStringParser d_noTagsStringParser; 00212 bool d_textParsingEnabled; 00213 }; 00214 00215 } // End of CEGUI namespace section 00216 00217 00218 #endif // end of guard _CEGUIListboxTextItem_h_