Crazy Eddie's GUI System  0.8.6
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_
uint getID(void) const
Return the current ID assigned to this list box item.
Definition: ListboxItem.h:108
virtual bool operator>(const ListboxItem &rhs) const
Greater-than operator, compares item texts.
Definition: ListboxItem.h:432
void setOwnerWindow(const Window *owner)
Set the owner window for this ListboxItem. This is called by all the list box widgets when an item is...
Definition: ListboxItem.h:293
Definition: MemoryAllocatedObject.h:109
String d_tooltipText
Text for the individual tooltip of this item.
Definition: ListboxItem.h:463
void * getUserData(void) const
Return the pointer to any client assigned user data attached to this lis box item.
Definition: ListboxItem.h:121
const Image * getSelectionBrushImage(void) const
Return the current selection highlighting brush.
Definition: ListboxItem.h:186
Interface for Image.
Definition: Image.h:158
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1
bool isSelected(void) const
return whether this item is selected.
Definition: ListboxItem.h:131
Abstract class defining the interface for objects that buffer geometry for later rendering.
Definition: GeometryBuffer.h:42
Class that holds details of colours for the four corners of a rectangle.
Definition: ColourRect.h:43
bool d_autoDelete
true if the system should destroy this item, false if client code will destroy the item...
Definition: ListboxItem.h:468
Abstract class to wrap a Bidi visual mapping of a text string.
Definition: BidiVisualMapping.h:50
void setUserData(void *item_data)
Set the client assigned user data attached to this lis box item.
Definition: ListboxItem.h:238
void setDisabled(bool setting)
set whether this item is disabled.
Definition: ListboxItem.h:264
const String & getTooltipText(void) const
return the text string set for this list box item.
Definition: ListboxItem.h:91
void setSelected(bool setting)
set whether this item is selected.
Definition: ListboxItem.h:251
const Window * getOwnerWindow() const
Get the owner window for this ListboxItem.
Definition: ListboxItem.h:166
void setSelectionColours(const ColourRect &cols)
Set the colours used for selection highlighting.
Definition: ListboxItem.h:306
Class that encapsulates a typeface.
Definition: Font.h:58
uint d_itemID
ID code assigned by client code. This has no meaning within the GUI system.
Definition: ListboxItem.h:464
BidiVisualMapping * d_bidiVisualMapping
pointer to bidirection support object
Definition: ListboxItem.h:460
bool isAutoDeleted(void) const
return whether this item will be automatically deleted when the list box it is attached to is destroy...
Definition: ListboxItem.h:154
const Window * d_owner
Pointer to the window that owns this item.
Definition: ListboxItem.h:469
An abstract base class providing common functionality and specifying the required interface for deriv...
Definition: Window.h:149
Base class for list box items.
Definition: ListboxItem.h:51
bool d_bidiDataValid
whether bidi visual mapping has been updated since last text change.
Definition: ListboxItem.h:462
const Image * d_selectBrush
Image used for rendering selection.
Definition: ListboxItem.h:471
void setID(uint item_id)
Set the ID assigned to this list box item.
Definition: ListboxItem.h:222
Class representing colour values within the system.
Definition: Colour.h:44
void * d_itemData
Pointer to some client code data. This has no meaning within the GUI system.
Definition: ListboxItem.h:465
void setSelectionBrushImage(const Image *image)
Set the selection highlighting brush image.
Definition: ListboxItem.h:354
virtual bool operator<(const ListboxItem &rhs) const
Less-than operator, compares item texts.
Definition: ListboxItem.h:425
ColourRect d_selectCols
Colours used for selection highlighting.
Definition: ListboxItem.h:470
void setSelectionColours(Colour col)
Set the colours used for selection highlighting.
Definition: ListboxItem.h:341
bool d_disabled
true if this item is disabled. false if the item is not disabled.
Definition: ListboxItem.h:467
void setAutoDeleted(bool setting)
Set whether this item will be automatically deleted when the list box it is attached to is destroyed...
Definition: ListboxItem.h:279
ColourRect getSelectionColours(void) const
Return the current colours used for selection highlighting.
Definition: ListboxItem.h:176
bool isDisabled(void) const
return whether this item is disabled.
Definition: ListboxItem.h:141
bool d_selected
true if this item is selected. false if the item is not selected.
Definition: ListboxItem.h:466
String class used within the GUI system.
Definition: String.h:62
static const Colour DefaultSelectionColour
Default selection brush colour.
Definition: ListboxItem.h:58