Crazy Eddie's GUI System  0.8.4
ListboxItem.h
00001 /***********************************************************************
00002     created:    8/6/2004
00003     author:     Paul D Turner
00004 
00005     purpose:    Interface to base class for list 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 _CEGUIListboxItem_h_
00030 #define _CEGUIListboxItem_h_
00031 
00032 #include "../Base.h"
00033 #include "../String.h"
00034 #include "../ColourRect.h"
00035 #include "../TextUtils.h"
00036 #include "../Size.h"
00037 #include "../Rect.h"
00038 
00039 #if defined(_MSC_VER)
00040 #  pragma warning(push)
00041 #  pragma warning(disable : 4251)
00042 #endif
00043 
00044 // Start of CEGUI namespace section
00045 namespace CEGUI
00046 {
00051 class CEGUIEXPORT ListboxItem :
00052     public AllocatedObject<ListboxItem>
00053 {
00054 public:
00055     /*************************************************************************
00056         Constants
00057     *************************************************************************/
00058     static const Colour DefaultSelectionColour;     
00059 
00060 
00061     /*************************************************************************
00062         Construction and Destruction
00063     *************************************************************************/
00068     ListboxItem(const String& text, uint item_id = 0, void* item_data = 0, bool disabled = false, bool auto_delete = true);
00069 
00070 
00075     virtual ~ListboxItem(void);
00076 
00077 
00078     /*************************************************************************
00079         Accessors
00080     *************************************************************************/
00091     const String&   getTooltipText(void) const      {return d_tooltipText;}
00092 
00093     const String& getText(void) const {return d_textLogical;}
00094 
00096     const String& getTextVisual() const;
00097 
00108     uint    getID(void) const           {return d_itemID;}
00109 
00110 
00121     void*   getUserData(void) const     {return d_itemData;}
00122 
00123 
00131     bool    isSelected(void) const      {return d_selected;}
00132 
00133 
00141     bool    isDisabled(void) const      {return d_disabled;}
00142 
00143 
00154     bool    isAutoDeleted(void) const   {return d_autoDelete;}
00155 
00156 
00166     const Window*   getOwnerWindow() const      {return d_owner;}
00167 
00168 
00176     ColourRect  getSelectionColours(void) const     {return d_selectCols;}
00177 
00178 
00186     const Image*    getSelectionBrushImage(void) const      {return d_selectBrush;}
00187 
00188 
00189     /*************************************************************************
00190         Manipulators
00191     *************************************************************************/
00205     virtual void setText(const String& text);
00206 
00207     void    setTooltipText(const String& text)      {d_tooltipText = text;}
00208 
00222     void    setID(uint item_id)     {d_itemID = item_id;}
00223 
00224 
00238     void    setUserData(void* item_data)    {d_itemData = item_data;}
00239 
00240 
00251     void    setSelected(bool setting)       {d_selected = setting;}
00252 
00253 
00264     void    setDisabled(bool setting)       {d_disabled = setting;}
00265 
00279     void    setAutoDeleted(bool setting)        {d_autoDelete = setting;}
00280 
00281 
00293     void    setOwnerWindow(const Window* owner)     {d_owner = owner;}
00294 
00295 
00306     void    setSelectionColours(const ColourRect& cols)     {d_selectCols = cols;}
00307 
00308 
00328     void    setSelectionColours(Colour top_left_colour, Colour top_right_colour, Colour bottom_left_colour, Colour bottom_right_colour);
00329 
00330 
00341     void    setSelectionColours(Colour col)     {setSelectionColours(col, col, col, col);}
00342 
00343 
00354     void    setSelectionBrushImage(const Image* image)      {d_selectBrush = image;}
00355 
00356 
00367     void    setSelectionBrushImage(const String& name);
00368 
00384     virtual bool handleFontRenderSizeChange(const Font* const font);
00385 
00386     /*************************************************************************
00387         Abstract portion of interface
00388     *************************************************************************/
00396     virtual Sizef getPixelSize(void) const = 0;
00397 
00398 
00415     virtual void draw(GeometryBuffer& buffer, const Rectf& targetRect,
00416                       float alpha, const Rectf* clipper) const = 0;
00417 
00418     /*************************************************************************
00419         Operators
00420     *************************************************************************/
00425     virtual bool    operator<(const ListboxItem& rhs) const     {return getText() < rhs.getText();}
00426 
00427 
00432     virtual bool    operator>(const ListboxItem& rhs) const     {return getText() > rhs.getText();}
00433 
00434 
00435 protected:
00436     /*************************************************************************
00437         Implementation methods
00438     *************************************************************************/
00444     ColourRect getModulateAlphaColourRect(const ColourRect& cols, float alpha) const;
00445 
00446 
00452     Colour calculateModulatedAlphaColour(Colour col, float alpha) const;
00453 
00454 
00455     /*************************************************************************
00456         Implementation Data
00457     *************************************************************************/
00458     String d_textLogical;
00460     BidiVisualMapping* d_bidiVisualMapping;
00462     mutable bool d_bidiDataValid;
00463     String  d_tooltipText;  
00464     uint    d_itemID;       
00465     void*   d_itemData;     
00466     bool    d_selected;     
00467     bool    d_disabled;     
00468     bool    d_autoDelete;   
00469     const Window*   d_owner;    
00470     ColourRect      d_selectCols;       
00471     const Image*    d_selectBrush;      
00472 };
00473 
00474 } // End of  CEGUI namespace section
00475 
00476 #if defined(_MSC_VER)
00477 #  pragma warning(pop)
00478 #endif
00479 
00480 #endif  // end of guard _CEGUIListboxItem_h_
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends