Crazy Eddie's GUI System  0.8.7
TreeItem.h
1 /***********************************************************************
2  created: 5-13-07
3  author: Jonathan Welch (Based on Code by David Durant)
4  *************************************************************************/
5 /***************************************************************************
6  * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining
9  * a copy of this software and associated documentation files (the
10  * "Software"), to deal in the Software without restriction, including
11  * without limitation the rights to use, copy, modify, merge, publish,
12  * distribute, sublicense, and/or sell copies of the Software, and to
13  * permit persons to whom the Software is furnished to do so, subject to
14  * the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be
17  * included in all copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
23  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25  * OTHER DEALINGS IN THE SOFTWARE.
26  ***************************************************************************/
27 #ifndef _CEGUITreeItem_h_
28 #define _CEGUITreeItem_h_
29 
30 #include "../Base.h"
31 #include "../String.h"
32 #include "../ColourRect.h"
33 #include "../BasicRenderedStringParser.h"
34 
35 #if defined(_MSC_VER)
36 # pragma warning(push)
37 # pragma warning(disable : 4251)
38 #endif
39 
40 // Start of CEGUI namespace section
41 namespace CEGUI
42 {
57 class CEGUIEXPORT TreeItem : public
58  AllocatedObject<TreeItem>
59 {
60 public:
61  typedef std::vector<TreeItem*
62  CEGUI_VECTOR_ALLOC(TreeItem*)> LBItemList;
63 
64  /*************************************************************************
65  Constants
66  *************************************************************************/
68  static const Colour DefaultTextColour;
71 
72  /*************************************************************************
73  Construction and Destruction
74  *************************************************************************/
79  TreeItem(const String& text, uint item_id = 0, void* item_data = 0,
80  bool disabled = false, bool auto_delete = true);
81 
86  virtual ~TreeItem(void);
87 
88  /*************************************************************************
89  Accessors
90  *************************************************************************/
101  const Font* getFont(void) const;
102 
111  { return d_textCols; }
112 
113  /*************************************************************************
114  Manipulator methods
115  *************************************************************************/
126  void setFont(const Font* font);
127 
139  void setFont(const String& font_name);
140 
151  void setTextColours(const ColourRect& cols)
152  { d_textCols = cols; d_renderedStringValid = false; }
153 
177  void setTextColours(Colour top_left_colour, Colour top_right_colour,
178  Colour bottom_left_colour, Colour bottom_right_colour);
179 
191  { setTextColours(col, col, col, col); }
192 
203  const String& getText() const {return d_textLogical;}
204 
206  const String& getTextVisual() const;
207 
216  const String& getTooltipText(void) const
217  { return d_tooltipText; }
218 
229  uint getID(void) const
230  { return d_itemID; }
231 
243  void* getUserData(void) const
244  { return d_itemData; }
245 
254  bool isSelected(void) const
255  { return d_selected; }
256 
265  bool isDisabled(void) const
266  { return d_disabled; }
267 
281  bool isAutoDeleted(void) const
282  { return d_autoDelete; }
283 
294  const Window* getOwnerWindow(void)
295  { return d_owner; }
296 
305  { return d_selectCols; }
306 
307 
315  const Image* getSelectionBrushImage(void) const
316  { return d_selectBrush; }
317 
318 
319  /*************************************************************************
320  Manipulators
321  *************************************************************************/
335  void setText(const String& text);
336 
348  void setTooltipText(const String& text)
349  { d_tooltipText = text; }
350 
364  void setID(uint item_id)
365  { d_itemID = item_id; }
366 
380  void setUserData(void* item_data)
381  { d_itemData = item_data; }
382 
394  void setSelected(bool setting)
395  { d_selected = setting; }
396 
408  void setDisabled(bool setting)
409  { d_disabled = setting; }
410 
426  void setAutoDeleted(bool setting)
427  { d_autoDelete = setting; }
428 
441  void setOwnerWindow(const Window* owner)
442  { d_owner = owner; }
443 
454  void setSelectionColours(const ColourRect& cols)
455  { d_selectCols = cols; }
456 
457 
481  void setSelectionColours(Colour top_left_colour,
482  Colour top_right_colour,
483  Colour bottom_left_colour,
484  Colour bottom_right_colour);
485 
497  { setSelectionColours(col, col, col, col); }
498 
499 
510  void setSelectionBrushImage(const Image* image)
511  { d_selectBrush = image; }
512 
513 
524  void setSelectionBrushImage(const String& name);
525 
534  void setButtonLocation(Rectf& buttonOffset)
535  { d_buttonLocation = buttonOffset; }
536 
537  Rectf& getButtonLocation(void)
538  { return d_buttonLocation; }
539 
540  bool getIsOpen(void)
541  { return d_isOpen; }
542 
543  void toggleIsOpen(void)
544  { d_isOpen = !d_isOpen; }
545 
546  TreeItem *getTreeItemFromIndex(size_t itemIndex);
547 
548  size_t getItemCount(void) const
549  { return d_listItems.size(); }
550 
551  LBItemList &getItemList(void)
552  { return d_listItems; }
553 
554  void addItem(TreeItem* item);
555  void removeItem(const TreeItem* item);
556 
557  void setIcon(const Image &theIcon)
558  { d_iconImage = &theIcon; }
559 
560  /*************************************************************************
561  Abstract portion of interface
562  *************************************************************************/
570  virtual Sizef getPixelSize(void) const;
571 
589  virtual void draw(GeometryBuffer& buffer, const Rectf& targetRect,
590  float alpha, const Rectf* clipper) const;
591 
604  virtual bool handleFontRenderSizeChange(const Font* const font);
605 
606  /*************************************************************************
607  Operators
608  *************************************************************************/
613  virtual bool operator<(const TreeItem& rhs) const
614  { return getText() < rhs.getText(); }
615 
620  virtual bool operator>(const TreeItem& rhs) const
621  { return getText() > rhs.getText(); }
622 
623 protected:
624  /*************************************************************************
625  Implementation methods
626  *************************************************************************/
633  float alpha) const;
634 
640  Colour calculateModulatedAlphaColour(Colour col, float alpha) const;
641 
643  void parseTextString() const;
644 
645  /*************************************************************************
646  Implementation Data
647  *************************************************************************/
650  BidiVisualMapping* d_bidiVisualMapping;
653  mutable bool d_bidiDataValid;
657  uint d_itemID;
659  void* d_itemData;
669  const Window* d_owner;
677  const Font* d_font;
681  LBItemList d_listItems;
683  bool d_isOpen;
689  mutable bool d_renderedStringValid;
690 };
691 
692 } // End of CEGUI namespace section
693 
694 #if defined(_MSC_VER)
695 # pragma warning(pop)
696 #endif
697 
698 #endif // end of guard _CEGUITreeItem_h_
CEGUI::TreeItem::d_iconImage
const Image * d_iconImage
Image for the icon to be displayed with this TreeItem.
Definition: TreeItem.h:679
CEGUI::GeometryBuffer
Abstract class defining the interface for objects that buffer geometry for later rendering.
Definition: GeometryBuffer.h:44
CEGUI::TreeItem::d_selected
bool d_selected
true if item is selected. false if item is not selected.
Definition: TreeItem.h:661
CEGUI::TreeItem::draw
virtual void draw(GeometryBuffer &buffer, const Rectf &targetRect, float alpha, const Rectf *clipper) const
Draw the tree item in its current state.
CEGUI::Font
Class that encapsulates a typeface.
Definition: Font.h:62
CEGUI::TreeItem::setSelectionColours
void setSelectionColours(Colour col)
Set the colours used for selection highlighting.
Definition: TreeItem.h:496
CEGUI::TreeItem::d_owner
const Window * d_owner
Pointer to the window that owns this item.
Definition: TreeItem.h:669
CEGUI::TreeItem::setSelected
void setSelected(bool setting)
Set the selected state for the item.
Definition: TreeItem.h:394
CEGUI::TreeItem::setAutoDeleted
void setAutoDeleted(bool setting)
Set whether this item will be automatically deleted when it is removed from the tree,...
Definition: TreeItem.h:426
CEGUI::TreeItem::setOwnerWindow
void setOwnerWindow(const Window *owner)
Set the owner window for this TreeItem. This is called by the tree widget when an item is added or in...
Definition: TreeItem.h:441
CEGUI::TreeItem::TreeItem
TreeItem(const String &text, uint item_id=0, void *item_data=0, bool disabled=false, bool auto_delete=true)
base class constructor
CEGUI::TreeItem
Base class for tree items.
Definition: TreeItem.h:59
CEGUI::TreeItem::getUserData
void * getUserData(void) const
Return the pointer to any client assigned user data attached to this tree item.
Definition: TreeItem.h:243
CEGUI::TreeItem::getSelectionColours
ColourRect getSelectionColours(void) const
Return the current colours used for selection highlighting.
Definition: TreeItem.h:304
CEGUI::TreeItem::setFont
void setFont(const Font *font)
Set the font to be used by this TreeItem.
CEGUI::TreeItem::~TreeItem
virtual ~TreeItem(void)
base class destructor
CEGUI::TreeItem::d_stringParser
static BasicRenderedStringParser d_stringParser
Parser used to produce a final RenderedString from the standard String.
Definition: TreeItem.h:685
CEGUI::TreeItem::d_disabled
bool d_disabled
true if item is disabled. false if item is not disabled.
Definition: TreeItem.h:663
CEGUI::TreeItem::setTextColours
void setTextColours(Colour col)
Set the colours used for text rendering.
Definition: TreeItem.h:190
CEGUI::TreeItem::setSelectionBrushImage
void setSelectionBrushImage(const String &name)
Set the selection highlighting brush image.
CEGUI::TreeItem::isSelected
bool isSelected(void) const
return whether this item is selected.
Definition: TreeItem.h:254
CEGUI::TreeItem::d_selectCols
ColourRect d_selectCols
Colours used for selection highlighting.
Definition: TreeItem.h:671
CEGUI::TreeItem::setSelectionColours
void setSelectionColours(const ColourRect &cols)
Set the colours used for selection highlighting.
Definition: TreeItem.h:454
CEGUI::TreeItem::d_listItems
LBItemList d_listItems
list of items in this item's tree branch.
Definition: TreeItem.h:681
CEGUI::TreeItem::setUserData
void setUserData(void *item_data)
Set the client assigned user data attached to this lis box item.
Definition: TreeItem.h:380
CEGUI::TreeItem::isAutoDeleted
bool isAutoDeleted(void) const
return whether this item will be automatically deleted when it is removed from the tree or when the t...
Definition: TreeItem.h:281
CEGUI::TreeItem::d_font
const Font * d_font
Font used for rendering text.
Definition: TreeItem.h:677
CEGUI::TreeItem::getID
uint getID(void) const
Return the current ID assigned to this tree item.
Definition: TreeItem.h:229
CEGUI
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1
CEGUI::RenderedString
Class representing a rendered string of entities.
Definition: RenderedString.h:52
CEGUI::TreeItem::setTextColours
void setTextColours(const ColourRect &cols)
Set the colours used for text rendering.
Definition: TreeItem.h:151
CEGUI::TreeItem::setTooltipText
void setTooltipText(const String &text)
Set the tooltip text to be used for this item.
Definition: TreeItem.h:348
CEGUI::AllocatedObject
Definition: MemoryAllocatedObject.h:110
CEGUI::ColourRect
Class that holds details of colours for the four corners of a rectangle.
Definition: ColourRect.h:45
CEGUI::TreeItem::setSelectionColours
void setSelectionColours(Colour top_left_colour, Colour top_right_colour, Colour bottom_left_colour, Colour bottom_right_colour)
Set the colours used for selection highlighting.
CEGUI::BidiVisualMapping
Abstract class to wrap a Bidi visual mapping of a text string.
Definition: BidiVisualMapping.h:52
CEGUI::TreeItem::getTextVisual
const String & getTextVisual() const
return text string with visual ordering of glyphs.
CEGUI::TreeItem::setSelectionBrushImage
void setSelectionBrushImage(const Image *image)
Set the selection highlighting brush image.
Definition: TreeItem.h:510
CEGUI::TreeItem::isDisabled
bool isDisabled(void) const
return whether this item is disabled.
Definition: TreeItem.h:265
CEGUI::TreeItem::d_textCols
ColourRect d_textCols
Colours used for rendering the text.
Definition: TreeItem.h:675
CEGUI::TreeItem::d_textLogical
String d_textLogical
Text for this tree item. If not rendered, still used for sorting.
Definition: TreeItem.h:649
CEGUI::TreeItem::operator>
virtual bool operator>(const TreeItem &rhs) const
Greater-than operator, compares item texts.
Definition: TreeItem.h:620
CEGUI::TreeItem::d_tooltipText
String d_tooltipText
Text for the individual tooltip of this item.
Definition: TreeItem.h:655
CEGUI::TreeItem::setText
void setText(const String &text)
set the text string for this tree item.
CEGUI::TreeItem::handleFontRenderSizeChange
virtual bool handleFontRenderSizeChange(const Font *const font)
Perform any updates needed because the given font's render size has changed.
CEGUI::TreeItem::getTextColours
ColourRect getTextColours(void) const
Return the current colours used for text rendering.
Definition: TreeItem.h:110
CEGUI::TreeItem::d_renderedString
RenderedString d_renderedString
RenderedString drawn by this item.
Definition: TreeItem.h:687
CEGUI::TreeItem::d_itemData
void * d_itemData
Pointer to some client code data.
Definition: TreeItem.h:659
CEGUI::TreeItem::getOwnerWindow
const Window * getOwnerWindow(void)
Get the owner window for this TreeItem.
Definition: TreeItem.h:294
CEGUI::TreeItem::setTextColours
void setTextColours(Colour top_left_colour, Colour top_right_colour, Colour bottom_left_colour, Colour bottom_right_colour)
Set the colours used for text rendering.
CEGUI::TreeItem::d_bidiDataValid
bool d_bidiDataValid
whether bidi visual mapping has been updated since last text change.
Definition: TreeItem.h:653
CEGUI::Window
An abstract base class providing common functionality and specifying the required interface for deriv...
Definition: Window.h:151
CEGUI::TreeItem::parseTextString
void parseTextString() const
parse the text visual string into a RenderString representation.
CEGUI::TreeItem::setButtonLocation
void setButtonLocation(Rectf &buttonOffset)
Tell the treeItem where its button is located. Calculated and set in Tree.cpp.
Definition: TreeItem.h:534
CEGUI::TreeItem::getText
const String & getText() const
return the text string set for this tree item.
Definition: TreeItem.h:203
CEGUI::TreeItem::DefaultTextColour
static const Colour DefaultTextColour
Default text colour.
Definition: TreeItem.h:68
CEGUI::TreeItem::getPixelSize
virtual Sizef getPixelSize(void) const
Return the rendered pixel size of this tree item.
CEGUI::TreeItem::DefaultSelectionColour
static const Colour DefaultSelectionColour
Default selection brush colour.
Definition: TreeItem.h:70
CEGUI::Size< float >
CEGUI::TreeItem::setID
void setID(uint item_id)
Set the ID assigned to this tree item.
Definition: TreeItem.h:364
CEGUI::TreeItem::getSelectionBrushImage
const Image * getSelectionBrushImage(void) const
Return the current selection highlighting brush.
Definition: TreeItem.h:315
CEGUI::String
String class used within the GUI system.
Definition: String.h:64
CEGUI::TreeItem::d_renderedStringValid
bool d_renderedStringValid
boolean used to track when item state changes (and needs re-parse)
Definition: TreeItem.h:689
CEGUI::TreeItem::getModulateAlphaColourRect
ColourRect getModulateAlphaColourRect(const ColourRect &cols, float alpha) const
Return a ColourRect object describing the colours in cols after having their alpha component modulate...
CEGUI::TreeItem::d_buttonLocation
Rectf d_buttonLocation
Location of the 'expand' button for the item.
Definition: TreeItem.h:667
CEGUI::TreeItem::operator<
virtual bool operator<(const TreeItem &rhs) const
Less-than operator, compares item texts.
Definition: TreeItem.h:613
CEGUI::TreeItem::setDisabled
void setDisabled(bool setting)
Set the disabled state for the item.
Definition: TreeItem.h:408
CEGUI::TreeItem::getTooltipText
const String & getTooltipText(void) const
Return the text string currently set to be used as the tooltip text for this item.
Definition: TreeItem.h:216
CEGUI::Colour
Class representing colour values within the system.
Definition: Colour.h:46
CEGUI::Rect< float >
CEGUI::TreeItem::calculateModulatedAlphaColour
Colour calculateModulatedAlphaColour(Colour col, float alpha) const
Return a colour value describing the colour specified by col after having its alpha component modulat...
CEGUI::BasicRenderedStringParser
Basic RenderedStringParser class that offers support for the following tags:
Definition: BasicRenderedStringParser.h:65
CEGUI::Image
Interface for Image.
Definition: Image.h:161
CEGUI::TreeItem::getFont
const Font * getFont(void) const
Return a pointer to the font being used by this TreeItem.
CEGUI::TreeItem::d_itemID
uint d_itemID
ID code assigned by client code.
Definition: TreeItem.h:657
CEGUI::TreeItem::d_autoDelete
bool d_autoDelete
true if the system will destroy this item, false if client code will.
Definition: TreeItem.h:665
CEGUI::TreeItem::d_isOpen
bool d_isOpen
true if the this item's tree branch is opened.
Definition: TreeItem.h:683
CEGUI::TreeItem::setFont
void setFont(const String &font_name)
Set the font to be used by this TreeItem.
CEGUI::TreeItem::d_selectBrush
const Image * d_selectBrush
Image used for rendering selection.
Definition: TreeItem.h:673