Crazy Eddies GUI System  0.6.2
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 "CEGUIRenderCache.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  { d_font = font; }
127 
139  void setFont(const String& font_name);
140 
151  void setTextColours(const ColourRect& cols)
152  { d_textCols = cols; }
153 
177  void setTextColours(colour top_left_colour, colour top_right_colour,
178  colour bottom_left_colour, colour bottom_right_colour);
179 
190  void setTextColours(colour col)
191  { setTextColours(col, col, col, col); }
192 
203  const String& getText(void) const
204  { return d_itemText; }
205 
214  const String& getTooltipText(void) const
215  { return d_tooltipText; }
216 
227  uint getID(void) const
228  { return d_itemID; }
229 
241  void* getUserData(void) const
242  { return d_itemData; }
243 
252  bool isSelected(void) const
253  { return d_selected; }
254 
263  bool isDisabled(void) const
264  { return d_disabled; }
265 
279  bool isAutoDeleted(void) const
280  { return d_autoDelete; }
281 
292  const Window* getOwnerWindow(void)
293  { return d_owner; }
294 
302  ColourRect getSelectionColours(void) const
303  { return d_selectCols; }
304 
305 
313  const Image* getSelectionBrushImage(void) const
314  { return d_selectBrush; }
315 
316 
317  /*************************************************************************
318  Manipulators
319  *************************************************************************/
333  void setText(const String& text)
334  { d_itemText = 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(const Vector3& position, float alpha,
592  const Rect& clipper) const;
593 
594  virtual void draw(RenderCache& cache,const Rect& targetRect, float zBase,
595  float alpha, const Rect* clipper) const;
596 
597  /*************************************************************************
598  Operators
599  *************************************************************************/
604  virtual bool operator<(const TreeItem& rhs) const
605  { return d_itemText < rhs.getText(); }
606 
611  virtual bool operator>(const TreeItem& rhs) const
612  { return d_itemText > rhs.getText(); }
613 
614 protected:
615  /*************************************************************************
616  Implementation methods
617  *************************************************************************/
623  ColourRect getModulateAlphaColourRect(const ColourRect& cols,
624  float alpha) const;
625 
631  colour calculateModulatedAlphaColour(colour col, float alpha) const;
632 
633  /*************************************************************************
634  Implementation Data
635  *************************************************************************/
641  uint d_itemID;
643  void* d_itemData;
653  const Window* d_owner;
665  LBItemList d_listItems;
667  bool d_isOpen;
668 };
669 
670 } // End of CEGUI namespace section
671 
672 #if defined(_MSC_VER)
673 # pragma warning(pop)
674 #endif
675 
676 #endif // end of guard _CEGUITreeItem_h_