Crazy Eddies GUI System  0.7.2
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 "../CEGUITextUtils.h"
37 
38 #if defined(_MSC_VER)
39 # pragma warning(push)
40 # pragma warning(disable : 4251)
41 #endif
42 
43 // Start of CEGUI namespace section
44 namespace CEGUI
45 {
50 class CEGUIEXPORT ListboxItem
51 {
52 public:
53  /*************************************************************************
54  Constants
55  *************************************************************************/
57 
58 
59  /*************************************************************************
60  Construction and Destruction
61  *************************************************************************/
66  ListboxItem(const String& text, uint item_id = 0, void* item_data = 0, bool disabled = false, bool auto_delete = true);
67 
68 
73  virtual ~ListboxItem(void);
74 
75 
76  /*************************************************************************
77  Accessors
78  *************************************************************************/
89  const String& getTooltipText(void) const {return d_tooltipText;}
90 
91  const String& getText(void) const {return d_textLogical;}
92 
94  const String& getTextVisual() const;
95 
106  uint getID(void) const {return d_itemID;}
107 
108 
119  void* getUserData(void) const {return d_itemData;}
120 
121 
129  bool isSelected(void) const {return d_selected;}
130 
131 
139  bool isDisabled(void) const {return d_disabled;}
140 
141 
152  bool isAutoDeleted(void) const {return d_autoDelete;}
153 
154 
164  const Window* getOwnerWindow() const {return d_owner;}
165 
166 
174  ColourRect getSelectionColours(void) const {return d_selectCols;}
175 
176 
184  const Image* getSelectionBrushImage(void) const {return d_selectBrush;}
185 
186 
187  /*************************************************************************
188  Manipulators
189  *************************************************************************/
203  virtual void setText(const String& text);
204 
205  void setTooltipText(const String& text) {d_tooltipText = text;}
206 
220  void setID(uint item_id) {d_itemID = item_id;}
221 
222 
236  void setUserData(void* item_data) {d_itemData = item_data;}
237 
238 
249  void setSelected(bool setting) {d_selected = setting;}
250 
251 
262  void setDisabled(bool setting) {d_disabled = setting;}
263 
277  void setAutoDeleted(bool setting) {d_autoDelete = setting;}
278 
279 
291  void setOwnerWindow(const Window* owner) {d_owner = owner;}
292 
293 
304  void setSelectionColours(const ColourRect& cols) {d_selectCols = cols;}
305 
306 
326  void setSelectionColours(colour top_left_colour, colour top_right_colour, colour bottom_left_colour, colour bottom_right_colour);
327 
328 
339  void setSelectionColours(colour col) {setSelectionColours(col, col, col, col);}
340 
341 
352  void setSelectionBrushImage(const Image* image) {d_selectBrush = image;}
353 
354 
368  void setSelectionBrushImage(const String& imageset, const String& image);
369 
370 
371  /*************************************************************************
372  Abstract portion of interface
373  *************************************************************************/
381  virtual Size getPixelSize(void) const = 0;
382 
383 
400  virtual void draw(GeometryBuffer& buffer, const Rect& targetRect,
401  float alpha, const Rect* clipper) const = 0;
402 
403  /*************************************************************************
404  Operators
405  *************************************************************************/
410  virtual bool operator<(const ListboxItem& rhs) const {return getText() < rhs.getText();}
411 
412 
417  virtual bool operator>(const ListboxItem& rhs) const {return getText() > rhs.getText();}
418 
419 
420 protected:
421  /*************************************************************************
422  Implementation methods
423  *************************************************************************/
429  ColourRect getModulateAlphaColourRect(const ColourRect& cols, float alpha) const;
430 
431 
437  colour calculateModulatedAlphaColour(colour col, float alpha) const;
438 
439 
440  /*************************************************************************
441  Implementation Data
442  *************************************************************************/
443  String d_textLogical;
447  mutable bool d_bidiDataValid;
449  uint d_itemID;
450  void* d_itemData;
451  bool d_selected;
452  bool d_disabled;
454  const Window* d_owner;
457 };
458 
459 } // End of CEGUI namespace section
460 
461 #if defined(_MSC_VER)
462 # pragma warning(pop)
463 #endif
464 
465 #endif // end of guard _CEGUIListboxItem_h_