Crazy Eddie's GUI System  0.8.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
ListboxItem.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 "../Base.h"
34 #include "../String.h"
35 #include "../ColourRect.h"
36 #include "../TextUtils.h"
37 #include "../Size.h"
38 #include "../Rect.h"
39 
40 #if defined(_MSC_VER)
41 # pragma warning(push)
42 # pragma warning(disable : 4251)
43 #endif
44 
45 // Start of CEGUI namespace section
46 namespace CEGUI
47 {
52 class CEGUIEXPORT ListboxItem :
53  public AllocatedObject<ListboxItem>
54 {
55 public:
56  /*************************************************************************
57  Constants
58  *************************************************************************/
60 
61 
62  /*************************************************************************
63  Construction and Destruction
64  *************************************************************************/
69  ListboxItem(const String& text, uint item_id = 0, void* item_data = 0, bool disabled = false, bool auto_delete = true);
70 
71 
76  virtual ~ListboxItem(void);
77 
78 
79  /*************************************************************************
80  Accessors
81  *************************************************************************/
92  const String& getTooltipText(void) const {return d_tooltipText;}
93 
94  const String& getText(void) const {return d_textLogical;}
95 
97  const String& getTextVisual() const;
98 
109  uint getID(void) const {return d_itemID;}
110 
111 
122  void* getUserData(void) const {return d_itemData;}
123 
124 
132  bool isSelected(void) const {return d_selected;}
133 
134 
142  bool isDisabled(void) const {return d_disabled;}
143 
144 
155  bool isAutoDeleted(void) const {return d_autoDelete;}
156 
157 
167  const Window* getOwnerWindow() const {return d_owner;}
168 
169 
177  ColourRect getSelectionColours(void) const {return d_selectCols;}
178 
179 
187  const Image* getSelectionBrushImage(void) const {return d_selectBrush;}
188 
189 
190  /*************************************************************************
191  Manipulators
192  *************************************************************************/
206  virtual void setText(const String& text);
207 
208  void setTooltipText(const String& text) {d_tooltipText = text;}
209 
223  void setID(uint item_id) {d_itemID = item_id;}
224 
225 
239  void setUserData(void* item_data) {d_itemData = item_data;}
240 
241 
252  void setSelected(bool setting) {d_selected = setting;}
253 
254 
265  void setDisabled(bool setting) {d_disabled = setting;}
266 
280  void setAutoDeleted(bool setting) {d_autoDelete = setting;}
281 
282 
294  void setOwnerWindow(const Window* owner) {d_owner = owner;}
295 
296 
307  void setSelectionColours(const ColourRect& cols) {d_selectCols = cols;}
308 
309 
329  void setSelectionColours(Colour top_left_colour, Colour top_right_colour, Colour bottom_left_colour, Colour bottom_right_colour);
330 
331 
342  void setSelectionColours(Colour col) {setSelectionColours(col, col, col, col);}
343 
344 
355  void setSelectionBrushImage(const Image* image) {d_selectBrush = image;}
356 
357 
368  void setSelectionBrushImage(const String& name);
369 
385  virtual bool handleFontRenderSizeChange(const Font* const font);
386 
387  /*************************************************************************
388  Abstract portion of interface
389  *************************************************************************/
397  virtual Sizef getPixelSize(void) const = 0;
398 
399 
416  virtual void draw(GeometryBuffer& buffer, const Rectf& targetRect,
417  float alpha, const Rectf* clipper) const = 0;
418 
419  /*************************************************************************
420  Operators
421  *************************************************************************/
426  virtual bool operator<(const ListboxItem& rhs) const {return getText() < rhs.getText();}
427 
428 
433  virtual bool operator>(const ListboxItem& rhs) const {return getText() > rhs.getText();}
434 
435 
436 protected:
437  /*************************************************************************
438  Implementation methods
439  *************************************************************************/
445  ColourRect getModulateAlphaColourRect(const ColourRect& cols, float alpha) const;
446 
447 
453  Colour calculateModulatedAlphaColour(Colour col, float alpha) const;
454 
455 
456  /*************************************************************************
457  Implementation Data
458  *************************************************************************/
459  String d_textLogical;
463  mutable bool d_bidiDataValid;
465  uint d_itemID;
466  void* d_itemData;
467  bool d_selected;
468  bool d_disabled;
470  const Window* d_owner;
473 };
474 
475 } // End of CEGUI namespace section
476 
477 #if defined(_MSC_VER)
478 # pragma warning(pop)
479 #endif
480 
481 #endif // end of guard _CEGUIListboxItem_h_