Crazy Eddies GUI System  0.6.0
CEGUIListboxItem.h
1 /***********************************************************************
2  filename: CEGUIListboxItem.h
3  created: 8/6/2004
4  author: Paul D Turner
5 
6  purpose: Interface to base class for list items
7 *************************************************************************/
8 /***************************************************************************
9  * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
10  *
11  * Permission is hereby granted, free of charge, to any person obtaining
12  * a copy of this software and associated documentation files (the
13  * "Software"), to deal in the Software without restriction, including
14  * without limitation the rights to use, copy, modify, merge, publish,
15  * distribute, sublicense, and/or sell copies of the Software, and to
16  * permit persons to whom the Software is furnished to do so, subject to
17  * the following conditions:
18  *
19  * The above copyright notice and this permission notice shall be
20  * included in all copies or substantial portions of the Software.
21  *
22  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
25  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
26  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
27  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28  * OTHER DEALINGS IN THE SOFTWARE.
29  ***************************************************************************/
30 #ifndef _CEGUIListboxItem_h_
31 #define _CEGUIListboxItem_h_
32 
33 #include "CEGUIBase.h"
34 #include "CEGUIString.h"
35 #include "CEGUIColourRect.h"
36 #include "CEGUIRenderCache.h"
37 
38 // Start of CEGUI namespace section
39 namespace CEGUI
40 {
45 class CEGUIEXPORT ListboxItem
46 {
47 public:
48  /*************************************************************************
49  Constants
50  *************************************************************************/
52 
53 
54  /*************************************************************************
55  Construction and Destruction
56  *************************************************************************/
61  ListboxItem(const String& text, uint item_id = 0, void* item_data = 0, bool disabled = false, bool auto_delete = true);
62 
63 
68  virtual ~ListboxItem(void) {}
69 
70 
71  /*************************************************************************
72  Accessors
73  *************************************************************************/
84  const String& getText(void) const {return d_itemText;}
85  const String& getTooltipText(void) const {return d_tooltipText;}
86 
97  uint getID(void) const {return d_itemID;}
98 
99 
110  void* getUserData(void) const {return d_itemData;}
111 
112 
120  bool isSelected(void) const {return d_selected;}
121 
122 
130  bool isDisabled(void) const {return d_disabled;}
131 
132 
143  bool isAutoDeleted(void) const {return d_autoDelete;}
144 
145 
155  const Window* getOwnerWindow() const {return d_owner;}
156 
157 
165  ColourRect getSelectionColours(void) const {return d_selectCols;}
166 
167 
175  const Image* getSelectionBrushImage(void) const {return d_selectBrush;}
176 
177 
178  /*************************************************************************
179  Manipulators
180  *************************************************************************/
194  void setText(const String& text) {d_itemText = text;}
195 
196  void setTooltipText(const String& text) {d_tooltipText = text;}
197 
211  void setID(uint item_id) {d_itemID = item_id;}
212 
213 
227  void setUserData(void* item_data) {d_itemData = item_data;}
228 
229 
240  void setSelected(bool setting) {d_selected = setting;}
241 
242 
253  void setDisabled(bool setting) {d_disabled = setting;}
254 
268  void setAutoDeleted(bool setting) {d_autoDelete = setting;}
269 
270 
282  void setOwnerWindow(const Window* owner) {d_owner = owner;}
283 
284 
295  void setSelectionColours(const ColourRect& cols) {d_selectCols = cols;}
296 
297 
317  void setSelectionColours(colour top_left_colour, colour top_right_colour, colour bottom_left_colour, colour bottom_right_colour);
318 
319 
330  void setSelectionColours(colour col) {setSelectionColours(col, col, col, col);}
331 
332 
343  void setSelectionBrushImage(const Image* image) {d_selectBrush = image;}
344 
345 
359  void setSelectionBrushImage(const String& imageset, const String& image);
360 
361 
362  /*************************************************************************
363  Abstract portion of interface
364  *************************************************************************/
372  virtual Size getPixelSize(void) const = 0;
373 
374 
391  virtual void draw(const Vector3& position, float alpha, const Rect& clipper) const = 0;
392 
393  virtual void draw(RenderCache& cache,const Rect& targetRect, float zBase, float alpha, const Rect* clipper) const = 0;
394 
395  /*************************************************************************
396  Operators
397  *************************************************************************/
402  virtual bool operator<(const ListboxItem& rhs) const {return d_itemText < rhs.getText();}
403 
404 
409  virtual bool operator>(const ListboxItem& rhs) const {return d_itemText > rhs.getText();}
410 
411 
412 protected:
413  /*************************************************************************
414  Implementation methods
415  *************************************************************************/
421  ColourRect getModulateAlphaColourRect(const ColourRect& cols, float alpha) const;
422 
423 
429  colour calculateModulatedAlphaColour(colour col, float alpha) const;
430 
431 
432  /*************************************************************************
433  Implementation Data
434  *************************************************************************/
437  uint d_itemID;
438  void* d_itemData;
439  bool d_selected;
440  bool d_disabled;
442  const Window* d_owner;
445 };
446 
447 } // End of CEGUI namespace section
448 
449 
450 #endif // end of guard _CEGUIListboxItem_h_