Crazy Eddies GUI System  0.7.0
CEGUITreeItem.h
1 /***********************************************************************
2  filename: CEGUITreeItem.h
3  created: 5-13-07
4  author: Jonathan Welch (Based on Code by David Durant)
5  *************************************************************************/
6 /***************************************************************************
7  * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining
10  * a copy of this software and associated documentation files (the
11  * "Software"), to deal in the Software without restriction, including
12  * without limitation the rights to use, copy, modify, merge, publish,
13  * distribute, sublicense, and/or sell copies of the Software, and to
14  * permit persons to whom the Software is furnished to do so, subject to
15  * the following conditions:
16  *
17  * The above copyright notice and this permission notice shall be
18  * included in all copies or substantial portions of the Software.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
24  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
25  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26  * OTHER DEALINGS IN THE SOFTWARE.
27  ***************************************************************************/
28 #ifndef _CEGUITreeItem_h_
29 #define _CEGUITreeItem_h_
30 
31 #include "../CEGUIBase.h"
32 #include "../CEGUIString.h"
33 #include "../CEGUIColourRect.h"
34 #include "../CEGUIBasicRenderedStringParser.h"
35 
36 #if defined(_MSC_VER)
37 # pragma warning(push)
38 # pragma warning(disable : 4251)
39 #endif
40 
41 // Start of CEGUI namespace section
42 namespace CEGUI
43 {
58 class CEGUIEXPORT TreeItem
59 {
60 public:
61  typedef std::vector<TreeItem*> LBItemList;
62 
63  /*************************************************************************
64  Constants
65  *************************************************************************/
67  static const colour DefaultTextColour;
70 
71  /*************************************************************************
72  Construction and Destruction
73  *************************************************************************/
78  TreeItem(const String& text, uint item_id = 0, void* item_data = 0,
79  bool disabled = false, bool auto_delete = true);
80 
85  virtual ~TreeItem(void) {}
86 
87  /*************************************************************************
88  Accessors
89  *************************************************************************/
100  Font* getFont(void) const;
101 
109  ColourRect getTextColours(void) const
110  { return d_textCols; }
111 
112  /*************************************************************************
113  Manipulator methods
114  *************************************************************************/
125  void setFont(Font* font);
126 
138  void setFont(const String& font_name);
139 
150  void setTextColours(const ColourRect& cols)
151  { d_textCols = cols; }
152 
176  void setTextColours(colour top_left_colour, colour top_right_colour,
177  colour bottom_left_colour, colour bottom_right_colour);
178 
189  void setTextColours(colour col)
190  { setTextColours(col, col, col, col); }
191 
202  const String& getText() const {return d_textLogical;}
203 
205  const String& getTextVisual() const;
206 
215  const String& getTooltipText(void) const
216  { return d_tooltipText; }
217 
228  uint getID(void) const
229  { return d_itemID; }
230 
242  void* getUserData(void) const
243  { return d_itemData; }
244 
253  bool isSelected(void) const
254  { return d_selected; }
255 
264  bool isDisabled(void) const
265  { return d_disabled; }
266 
280  bool isAutoDeleted(void) const
281  { return d_autoDelete; }
282 
293  const Window* getOwnerWindow(void)
294  { return d_owner; }
295 
303  ColourRect getSelectionColours(void) const
304  { return d_selectCols; }
305 
306 
314  const Image* getSelectionBrushImage(void) const
315  { return d_selectBrush; }
316 
317 
318  /*************************************************************************
319  Manipulators
320  *************************************************************************/
334  void setText(const String& text);
335 
347  void setTooltipText(const String& text)
348  { d_tooltipText = text; }
349 
363  void setID(uint item_id)
364  { d_itemID = item_id; }
365 
379  void setUserData(void* item_data)
380  { d_itemData = item_data; }
381 
393  void setSelected(bool setting)
394  { d_selected = setting; }
395 
407  void setDisabled(bool setting)
408  { d_disabled = setting; }
409 
425  void setAutoDeleted(bool setting)
426  { d_autoDelete = setting; }
427 
440  void setOwnerWindow(const Window* owner)
441  { d_owner = owner; }
442 
453  void setSelectionColours(const ColourRect& cols)
454  { d_selectCols = cols; }
455 
456 
480  void setSelectionColours(colour top_left_colour,
481  colour top_right_colour,
482  colour bottom_left_colour,
483  colour bottom_right_colour);
484 
495  void setSelectionColours(colour col)
496  { setSelectionColours(col, col, col, col); }
497 
498 
509  void setSelectionBrushImage(const Image* image)
510  { d_selectBrush = image; }
511 
512 
526  void setSelectionBrushImage(const String& imageset, const String& image);
527 
536  void setButtonLocation(Rect &buttonOffset)
537  { d_buttonLocation = buttonOffset; }
538 
539  Rect &getButtonLocation(void)
540  { return d_buttonLocation; }
541 
542  bool getIsOpen(void)
543  { return d_isOpen; }
544 
545  void toggleIsOpen(void)
546  { d_isOpen = !d_isOpen; }
547 
548  TreeItem *getTreeItemFromIndex(size_t itemIndex);
549 
550  size_t getItemCount(void) const
551  { return d_listItems.size(); }
552 
553  LBItemList &getItemList(void)
554  { return d_listItems; }
555 
556  void addItem(TreeItem* item);
557  void removeItem(const TreeItem* item);
558 
559  void setIcon(const Image &theIcon)
560  { d_iconImage = (Image *) & theIcon; }
561 
562  /*************************************************************************
563  Abstract portion of interface
564  *************************************************************************/
572  virtual Size getPixelSize(void) const;
573 
591  virtual void draw(GeometryBuffer& buffer, const Rect& targetRect,
592  float alpha, const Rect* clipper) const;
593 
594  /*************************************************************************
595  Operators
596  *************************************************************************/
601  virtual bool operator<(const TreeItem& rhs) const
602  { return getText() < rhs.getText(); }
603 
608  virtual bool operator>(const TreeItem& rhs) const
609  { return getText() > rhs.getText(); }
610 
611 protected:
612  /*************************************************************************
613  Implementation methods
614  *************************************************************************/
620  ColourRect getModulateAlphaColourRect(const ColourRect& cols,
621  float alpha) const;
622 
628  colour calculateModulatedAlphaColour(colour col, float alpha) const;
629 
631  void parseTextString() const;
632 
633  /*************************************************************************
634  Implementation Data
635  *************************************************************************/
638 
641  mutable bool d_bidiDataValid;
645  uint d_itemID;
647  void* d_itemData;
657  const Window* d_owner;
669  LBItemList d_listItems;
671  bool d_isOpen;
677  mutable bool d_renderedStringValid;
678 };
679 
680 } // End of CEGUI namespace section
681 
682 #if defined(_MSC_VER)
683 # pragma warning(pop)
684 #endif
685 
686 #endif // end of guard _CEGUITreeItem_h_