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 "CEGUIRenderCache.h"
00037 
00038 // Start of CEGUI namespace section
00039 namespace CEGUI
00040 {
00045 class CEGUIEXPORT ListboxItem
00046 {
00047 public:
00048         /*************************************************************************
00049                 Constants
00050         *************************************************************************/
00051         static const colour     DefaultSelectionColour;         
00052 
00053 
00054         /*************************************************************************
00055                 Construction and Destruction
00056         *************************************************************************/
00061         ListboxItem(const String& text, uint item_id = 0, void* item_data = 0, bool disabled = false, bool auto_delete = true);
00062 
00063 
00068         virtual ~ListboxItem(void) {}
00069 
00070 
00071         /*************************************************************************
00072                 Accessors
00073         *************************************************************************/
00084         const String&   getText(void) const             {return d_itemText;}
00085         const String&   getTooltipText(void) const              {return d_tooltipText;}
00086 
00097         uint    getID(void) const                       {return d_itemID;}
00098 
00099 
00110         void*   getUserData(void) const         {return d_itemData;}
00111 
00112 
00120         bool    isSelected(void) const          {return d_selected;}
00121 
00122 
00130         bool    isDisabled(void) const          {return d_disabled;}
00131 
00132 
00143         bool    isAutoDeleted(void) const       {return d_autoDelete;}
00144 
00145 
00155         const Window*   getOwnerWindow() const          {return d_owner;}
00156 
00157 
00165         ColourRect      getSelectionColours(void) const         {return d_selectCols;}
00166 
00167 
00175         const Image*    getSelectionBrushImage(void) const              {return d_selectBrush;}
00176 
00177 
00178         /*************************************************************************
00179                 Manipulators
00180         *************************************************************************/
00194         void    setText(const String& text)             {d_itemText = text;}
00195 
00196         void    setTooltipText(const String& text)              {d_tooltipText = text;}
00197 
00211         void    setID(uint item_id)             {d_itemID = item_id;}
00212 
00213 
00227         void    setUserData(void* item_data)    {d_itemData = item_data;}
00228 
00229 
00240         void    setSelected(bool setting)               {d_selected = setting;}
00241 
00242 
00253         void    setDisabled(bool setting)               {d_disabled = setting;}
00254 
00268         void    setAutoDeleted(bool setting)            {d_autoDelete = setting;}
00269 
00270 
00282         void    setOwnerWindow(const Window* owner)             {d_owner = owner;}
00283 
00284 
00295         void    setSelectionColours(const ColourRect& cols)             {d_selectCols = cols;}
00296 
00297 
00317         void    setSelectionColours(colour top_left_colour, colour top_right_colour, colour bottom_left_colour, colour bottom_right_colour);
00318 
00319 
00330         void    setSelectionColours(colour col)         {setSelectionColours(col, col, col, col);}
00331 
00332 
00343         void    setSelectionBrushImage(const Image* image)              {d_selectBrush = image;}
00344 
00345 
00359         void    setSelectionBrushImage(const String& imageset, const String& image);
00360 
00361 
00362         /*************************************************************************
00363                 Abstract portion of interface
00364         *************************************************************************/
00372         virtual Size    getPixelSize(void) const        = 0;
00373 
00374 
00391         virtual void    draw(const Vector3& position, float alpha, const Rect& clipper) const   = 0;
00392 
00393     virtual void    draw(RenderCache& cache,const Rect& targetRect, float zBase,  float alpha, const Rect* clipper) const = 0;
00394 
00395         /*************************************************************************
00396                 Operators
00397         *************************************************************************/
00402         virtual bool    operator<(const ListboxItem& rhs) const         {return d_itemText < rhs.getText();}
00403 
00404 
00409         virtual bool    operator>(const ListboxItem& rhs) const         {return d_itemText > rhs.getText();}
00410 
00411 
00412 protected:
00413         /*************************************************************************
00414                 Implementation methods
00415         *************************************************************************/
00421         ColourRect getModulateAlphaColourRect(const ColourRect& cols, float alpha) const;
00422 
00423 
00429         colour calculateModulatedAlphaColour(colour col, float alpha) const;
00430 
00431 
00432         /*************************************************************************
00433                 Implementation Data
00434         *************************************************************************/
00435         String  d_itemText;             
00436         String  d_tooltipText;  
00437         uint    d_itemID;               
00438         void*   d_itemData;             
00439         bool    d_selected;             
00440         bool    d_disabled;             
00441         bool    d_autoDelete;   
00442         const Window*   d_owner;        
00443         ColourRect              d_selectCols;           
00444         const Image*    d_selectBrush;          
00445 };
00446 
00447 } // End of  CEGUI namespace section
00448 
00449 
00450 #endif  // end of guard _CEGUIListboxItem_h_

Generated on Sun Nov 5 14:35:28 2006 for Crazy Eddies GUI System by  doxygen 1.4.7