Crazy Eddie's GUI System  0.8.4
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
ListboxItem.h
1 /***********************************************************************
2  created: 8/6/2004
3  author: Paul D Turner
4 
5  purpose: Interface to base class for list items
6 *************************************************************************/
7 /***************************************************************************
8  * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
9  *
10  * Permission is hereby granted, free of charge, to any person obtaining
11  * a copy of this software and associated documentation files (the
12  * "Software"), to deal in the Software without restriction, including
13  * without limitation the rights to use, copy, modify, merge, publish,
14  * distribute, sublicense, and/or sell copies of the Software, and to
15  * permit persons to whom the Software is furnished to do so, subject to
16  * the following conditions:
17  *
18  * The above copyright notice and this permission notice shall be
19  * included in all copies or substantial portions of the Software.
20  *
21  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
25  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27  * OTHER DEALINGS IN THE SOFTWARE.
28  ***************************************************************************/
29 #ifndef _CEGUIListboxItem_h_
30 #define _CEGUIListboxItem_h_
31 
32 #include "../Base.h"
33 #include "../String.h"
34 #include "../ColourRect.h"
35 #include "../TextUtils.h"
36 #include "../Size.h"
37 #include "../Rect.h"
38 
39 #if defined(_MSC_VER)
40 # pragma warning(push)
41 # pragma warning(disable : 4251)
42 #endif
43 
44 // Start of CEGUI namespace section
45 namespace CEGUI
46 {
51 class CEGUIEXPORT ListboxItem :
52  public AllocatedObject<ListboxItem>
53 {
54 public:
55  /*************************************************************************
56  Constants
57  *************************************************************************/
59 
60 
61  /*************************************************************************
62  Construction and Destruction
63  *************************************************************************/
68  ListboxItem(const String& text, uint item_id = 0, void* item_data = 0, bool disabled = false, bool auto_delete = true);
69 
70 
75  virtual ~ListboxItem(void);
76 
77 
78  /*************************************************************************
79  Accessors
80  *************************************************************************/
91  const String& getTooltipText(void) const {return d_tooltipText;}
92 
93  const String& getText(void) const {return d_textLogical;}
94 
96  const String& getTextVisual() const;
97 
108  uint getID(void) const {return d_itemID;}
109 
110 
121  void* getUserData(void) const {return d_itemData;}
122 
123 
131  bool isSelected(void) const {return d_selected;}
132 
133 
141  bool isDisabled(void) const {return d_disabled;}
142 
143 
154  bool isAutoDeleted(void) const {return d_autoDelete;}
155 
156 
166  const Window* getOwnerWindow() const {return d_owner;}
167 
168 
176  ColourRect getSelectionColours(void) const {return d_selectCols;}
177 
178 
186  const Image* getSelectionBrushImage(void) const {return d_selectBrush;}
187 
188 
189  /*************************************************************************
190  Manipulators
191  *************************************************************************/
205  virtual void setText(const String& text);
206 
207  void setTooltipText(const String& text) {d_tooltipText = text;}
208 
222  void setID(uint item_id) {d_itemID = item_id;}
223 
224 
238  void setUserData(void* item_data) {d_itemData = item_data;}
239 
240 
251  void setSelected(bool setting) {d_selected = setting;}
252 
253 
264  void setDisabled(bool setting) {d_disabled = setting;}
265 
279  void setAutoDeleted(bool setting) {d_autoDelete = setting;}
280 
281 
293  void setOwnerWindow(const Window* owner) {d_owner = owner;}
294 
295 
306  void setSelectionColours(const ColourRect& cols) {d_selectCols = cols;}
307 
308 
328  void setSelectionColours(Colour top_left_colour, Colour top_right_colour, Colour bottom_left_colour, Colour bottom_right_colour);
329 
330 
341  void setSelectionColours(Colour col) {setSelectionColours(col, col, col, col);}
342 
343 
354  void setSelectionBrushImage(const Image* image) {d_selectBrush = image;}
355 
356 
367  void setSelectionBrushImage(const String& name);
368 
384  virtual bool handleFontRenderSizeChange(const Font* const font);
385 
386  /*************************************************************************
387  Abstract portion of interface
388  *************************************************************************/
396  virtual Sizef getPixelSize(void) const = 0;
397 
398 
415  virtual void draw(GeometryBuffer& buffer, const Rectf& targetRect,
416  float alpha, const Rectf* clipper) const = 0;
417 
418  /*************************************************************************
419  Operators
420  *************************************************************************/
425  virtual bool operator<(const ListboxItem& rhs) const {return getText() < rhs.getText();}
426 
427 
432  virtual bool operator>(const ListboxItem& rhs) const {return getText() > rhs.getText();}
433 
434 
435 protected:
436  /*************************************************************************
437  Implementation methods
438  *************************************************************************/
444  ColourRect getModulateAlphaColourRect(const ColourRect& cols, float alpha) const;
445 
446 
452  Colour calculateModulatedAlphaColour(Colour col, float alpha) const;
453 
454 
455  /*************************************************************************
456  Implementation Data
457  *************************************************************************/
458  String d_textLogical;
462  mutable bool d_bidiDataValid;
464  uint d_itemID;
465  void* d_itemData;
466  bool d_selected;
467  bool d_disabled;
469  const Window* d_owner;
472 };
473 
474 } // End of CEGUI namespace section
475 
476 #if defined(_MSC_VER)
477 # pragma warning(pop)
478 #endif
479 
480 #endif // end of guard _CEGUIListboxItem_h_