# 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     Crazy Eddie's GUI System (http://www.cegui.org.uk)
    00010     Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
    00011
    00012     This library is free software; you can redistribute it and/or
    00013     modify it under the terms of the GNU Lesser General Public
    00014     License as published by the Free Software Foundation; either
    00015     version 2.1 of the License, or (at your option) any later version.
    00016
    00017     This library is distributed in the hope that it will be useful,
    00018     but WITHOUT ANY WARRANTY; without even the implied warranty of
    00019     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00020     Lesser General Public License for more details.
    00021
    00022     You should have received a copy of the GNU Lesser General Public
    00023     License along with this library; if not, write to the Free Software
    00024     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    00025 *************************************************************************/
    00026 #ifndef _CEGUIListboxItem_h_
    00027 #define _CEGUIListboxItem_h_
    00028
    00029 #include "CEGUIBase.h"
    00030 #include "CEGUIString.h"
    00031 #include "CEGUIColourRect.h"
    00032 #include "CEGUIRenderCache.h"
    00033
    00034 // Start of CEGUI namespace section
    00035 namespace CEGUI
    00036 {
    00041 class CEGUIEXPORT ListboxItem
    00042 {
    00043 public:
    00044         /*************************************************************************
    00045                 Constants
    00046         *************************************************************************/
    00047         static const colour     DefaultSelectionColour;
    00048
    00049
    00050         /*************************************************************************
    00051                 Construction and Destruction
    00052         *************************************************************************/
    00057         ListboxItem(const String& text, uint item_id = 0, void* item_data = NULL, bool disabled = false, bool auto_delete = true);
    00058
    00059
    00064         virtual ~ListboxItem(void) {}
    00065
    00066
    00067         /*************************************************************************
    00068                 Accessors
    00069         *************************************************************************/
    00080         const String&   getText(void) const             {return d_itemText;}
    00081         const String&   getTooltipText(void) const              {return d_tooltipText;}
    00082
    00093         uint    getID(void) const                       {return d_itemID;}
    00094
    00095
    00106         void*   getUserData(void) const         {return d_itemData;}
    00107
    00108
    00116         bool    isSelected(void) const          {return d_selected;}
    00117
    00118
    00126         bool    isDisabled(void) const          {return d_disabled;}
    00127
    00128
    00139         bool    isAutoDeleted(void) const       {return d_autoDelete;}
    00140
    00141
    00151         const Window*   getOwnerWindow(const Window* owner)             {return d_owner;}
    00152
    00153
    00161         ColourRect      getSelectionColours(void) const         {return d_selectCols;}
    00162
    00163
    00171         const Image*    getSelectionBrushImage(void) const              {return d_selectBrush;}
    00172
    00173
    00174         /*************************************************************************
    00175                 Manipulators
    00176         *************************************************************************/
    00190         void    setText(const String& text)             {d_itemText = text;}
    00191
    00192         void    setTooltipText(const String& text)              {d_tooltipText = text;}
    00193
    00207         void    setID(uint item_id)             {d_itemID = item_id;}
    00208
    00209
    00223         void    setUserData(void* item_data)    {d_itemData = item_data;}
    00224
    00225
    00236         void    setSelected(bool setting)               {d_selected = setting;}
    00237
    00238
    00249         void    setDisabled(bool setting)               {d_disabled = setting;}
    00250
    00264         void    setAutoDeleted(bool setting)            {d_autoDelete = setting;}
    00265
    00266
    00278         void    setOwnerWindow(const Window* owner)             {d_owner = owner;}
    00279
    00280
    00291         void    setSelectionColours(const ColourRect& cols)             {d_selectCols = cols;}
    00292
    00293
    00313         void    setSelectionColours(colour top_left_colour, colour top_right_colour, colour bottom_left_colour, colour bottom_right_colour);
    00314
    00315
    00326         void    setSelectionColours(colour col)         {setSelectionColours(col, col, col, col);}
    00327
    00328
    00339         void    setSelectionBrushImage(const Image* image)              {d_selectBrush = image;}
    00340
    00341
    00355         void    setSelectionBrushImage(const String& imageset, const String& image);
    00356
    00357
    00358         /*************************************************************************
    00359                 Abstract portion of interface
    00360         *************************************************************************/
    00368         virtual Size    getPixelSize(void) const        = 0;
    00369
    00370
    00387         virtual void    draw(const Vector3& position, float alpha, const Rect& clipper) const   = 0;
    00388
    00389     virtual void    draw(RenderCache& cache,const Rect& targetRect, float zBase,  float alpha, const Rect* clipper) const = 0;
    00390
    00391         /*************************************************************************
    00392                 Operators
    00393         *************************************************************************/
    00398         virtual bool    operator<(const ListboxItem& rhs) const         {return d_itemText < rhs.getText();}
    00399
    00400
    00405         virtual bool    operator>(const ListboxItem& rhs) const         {return d_itemText > rhs.getText();}
    00406
    00407
    00408 protected:
    00409         /*************************************************************************
    00410                 Implementation methods
    00411         *************************************************************************/
    00417         ColourRect getModulateAlphaColourRect(const ColourRect& cols, float alpha) const;
    00418
    00419
    00425         colour calculateModulatedAlphaColour(colour col, float alpha) const;
    00426
    00427
    00428         /*************************************************************************
    00429                 Implementation Data
    00430         *************************************************************************/
    00431         String  d_itemText;
    00432         String  d_tooltipText;
    00433         uint    d_itemID;
    00434         void*   d_itemData;
    00435         bool    d_selected;
    00436         bool    d_disabled;
    00437         bool    d_autoDelete;
    00438         const Window*   d_owner;
    00439         ColourRect              d_selectCols;
    00440         const Image*    d_selectBrush;
    00441 };
    00442
    00443 } // End of  CEGUI namespace section
    00444
    00445
    00446 #endif  // end of guard _CEGUIListboxItem_h_