Crazy Eddies GUI System: CEGUIListboxItem.h Source File

Crazy Eddies GUI System 0.7.6

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List

CEGUIListboxItem.h

    00001 /***********************************************************************
    00002     filename:   CEGUIListboxItem.h
    00003     created:    8/6/2004
    00004     author:     Paul D Turner
    00005
    00006     purpose:    Interface to base class for list items
    00007 *************************************************************************/
    00008 /***************************************************************************
    00009  *   Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
    00010  *
    00011  *   Permission is hereby granted, free of charge, to any person obtaining
    00012  *   a copy of this software and associated documentation files (the
    00013  *   "Software"), to deal in the Software without restriction, including
    00014  *   without limitation the rights to use, copy, modify, merge, publish,
    00015  *   distribute, sublicense, and/or sell copies of the Software, and to
    00016  *   permit persons to whom the Software is furnished to do so, subject to
    00017  *   the following conditions:
    00018  *
    00019  *   The above copyright notice and this permission notice shall be
    00020  *   included in all copies or substantial portions of the Software.
    00021  *
    00022  *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
    00023  *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
    00024  *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
    00025  *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
    00026  *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
    00027  *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
    00028  *   OTHER DEALINGS IN THE SOFTWARE.
    00029  ***************************************************************************/
    00030 #ifndef _CEGUIListboxItem_h_
    00031 #define _CEGUIListboxItem_h_
    00032
    00033 #include "../CEGUIBase.h"
    00034 #include "../CEGUIString.h"
    00035 #include "../CEGUIColourRect.h"
    00036 #include "../CEGUITextUtils.h"
    00037
    00038 #if defined(_MSC_VER)
    00039 #  pragma warning(push)
    00040 #  pragma warning(disable : 4251)
    00041 #endif
    00042
    00043 // Start of CEGUI namespace section
    00044 namespace CEGUI
    00045 {
    00050 class CEGUIEXPORT ListboxItem
    00051 {
    00052 public:
    00053     /*************************************************************************
    00054         Constants
    00055     *************************************************************************/
    00056     static const colour DefaultSelectionColour;
    00057
    00058
    00059     /*************************************************************************
    00060         Construction and Destruction
    00061     *************************************************************************/
    00066     ListboxItem(const String& text, uint item_id = 0, void* item_data = 0, bool disabled = false, bool auto_delete = true);
    00067
    00068
    00073     virtual ~ListboxItem(void);
    00074
    00075
    00076     /*************************************************************************
    00077         Accessors
    00078     *************************************************************************/
    00089     const String&   getTooltipText(void) const      {return d_tooltipText;}
    00090
    00091     const String& getText(void) const {return d_textLogical;}
    00092
    00094     const String& getTextVisual() const;
    00095
    00106     uint    getID(void) const           {return d_itemID;}
    00107
    00108
    00119     void*   getUserData(void) const     {return d_itemData;}
    00120
    00121
    00129     bool    isSelected(void) const      {return d_selected;}
    00130
    00131
    00139     bool    isDisabled(void) const      {return d_disabled;}
    00140
    00141
    00152     bool    isAutoDeleted(void) const   {return d_autoDelete;}
    00153
    00154
    00164     const Window*   getOwnerWindow() const      {return d_owner;}
    00165
    00166
    00174     ColourRect  getSelectionColours(void) const     {return d_selectCols;}
    00175
    00176
    00184     const Image*    getSelectionBrushImage(void) const      {return d_selectBrush;}
    00185
    00186
    00187     /*************************************************************************
    00188         Manipulators
    00189     *************************************************************************/
    00203     virtual void setText(const String& text);
    00204
    00205     void    setTooltipText(const String& text)      {d_tooltipText = text;}
    00206
    00220     void    setID(uint item_id)     {d_itemID = item_id;}
    00221
    00222
    00236     void    setUserData(void* item_data)    {d_itemData = item_data;}
    00237
    00238
    00249     void    setSelected(bool setting)       {d_selected = setting;}
    00250
    00251
    00262     void    setDisabled(bool setting)       {d_disabled = setting;}
    00263
    00277     void    setAutoDeleted(bool setting)        {d_autoDelete = setting;}
    00278
    00279
    00291     void    setOwnerWindow(const Window* owner)     {d_owner = owner;}
    00292
    00293
    00304     void    setSelectionColours(const ColourRect& cols)     {d_selectCols = cols;}
    00305
    00306
    00326     void    setSelectionColours(colour top_left_colour, colour top_right_colour, colour bottom_left_colour, colour bottom_right_colour);
    00327
    00328
    00339     void    setSelectionColours(colour col)     {setSelectionColours(col, col, col, col);}
    00340
    00341
    00352     void    setSelectionBrushImage(const Image* image)      {d_selectBrush = image;}
    00353
    00354
    00368     void    setSelectionBrushImage(const String& imageset, const String& image);
    00369
    00370
    00371     /*************************************************************************
    00372         Abstract portion of interface
    00373     *************************************************************************/
    00381     virtual Size    getPixelSize(void) const    = 0;
    00382
    00383
    00400     virtual void draw(GeometryBuffer& buffer, const Rect& targetRect,
    00401                       float alpha, const Rect* clipper) const = 0;
    00402
    00403     /*************************************************************************
    00404         Operators
    00405     *************************************************************************/
    00410     virtual bool    operator<(const ListboxItem& rhs) const     {return getText() < rhs.getText();}
    00411
    00412
    00417     virtual bool    operator>(const ListboxItem& rhs) const     {return getText() > rhs.getText();}
    00418
    00419
    00420 protected:
    00421     /*************************************************************************
    00422         Implementation methods
    00423     *************************************************************************/
    00429     ColourRect getModulateAlphaColourRect(const ColourRect& cols, float alpha) const;
    00430
    00431
    00437     colour calculateModulatedAlphaColour(colour col, float alpha) const;
    00438
    00439
    00440     /*************************************************************************
    00441         Implementation Data
    00442     *************************************************************************/
    00443     String d_textLogical;
    00445     BiDiVisualMapping* d_bidiVisualMapping;
    00447     mutable bool d_bidiDataValid;
    00448     String  d_tooltipText;
    00449     uint    d_itemID;
    00450     void*   d_itemData;
    00451     bool    d_selected;
    00452     bool    d_disabled;
    00453     bool    d_autoDelete;
    00454     const Window*   d_owner;
    00455     ColourRect      d_selectCols;
    00456     const Image*    d_selectBrush;
    00457 };
    00458
    00459 } // End of  CEGUI namespace section
    00460
    00461 #if defined(_MSC_VER)
    00462 #  pragma warning(pop)
    00463 #endif
    00464
    00465 #endif  // end of guard _CEGUIListboxItem_h_