Crazy Eddies GUI System  0.6.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 "CEGUIRenderCache.h"
35 
36 // Start of CEGUI namespace section
37 namespace CEGUI
38 {
43 class CEGUIEXPORT TreeItem
44  {
45 public:
46  typedef std::vector<TreeItem*> LBItemList;
47 
48  /*************************************************************************
49  Constants
50  *************************************************************************/
51  static const colour DefaultTextColour;
53 
54 
55  /*************************************************************************
56  Construction and Destruction
57  *************************************************************************/
62  TreeItem(const String& text, uint item_id = 0, void* item_data = 0, bool disabled = false, bool auto_delete = true);
63 
64 
69  virtual ~TreeItem(void) {}
70 
71 
72  /*************************************************************************
73  Accessors
74  *************************************************************************/
85  Font* getFont(void) const;
86 
87 
95  ColourRect getTextColours(void) const {return d_textCols;}
96 
97 
98  /*************************************************************************
99  Manipulator methods
100  *************************************************************************/
111  void setFont(Font* font) {d_font = font;}
112 
113 
124  void setFont(const String& font_name);
125 
126 
137  void setTextColours(const ColourRect& cols) {d_textCols = cols;}
138 
139 
159  void setTextColours(colour top_left_colour, colour top_right_colour, colour bottom_left_colour, colour bottom_right_colour);
160 
161 
172  void setTextColours(colour col) {setTextColours(col, col, col, col);}
173 
174 
185  const String& getText(void) const {return d_itemText;}
186  const String& getTooltipText(void) const {return d_tooltipText;}
187 
198  uint getID(void) const {return d_itemID;}
199 
200 
211  void* getUserData(void) const {return d_itemData;}
212 
213 
221  bool isSelected(void) const {return d_selected;}
222 
223 
231  bool isDisabled(void) const {return d_disabled;}
232 
233 
244  bool isAutoDeleted(void) const {return d_autoDelete;}
245 
246 
256 // const Window* getOwnerWindow(const Window* owner) {return d_owner;}
257  const Window* getOwnerWindow(void) {return d_owner;}
258 
259 
267  ColourRect getSelectionColours(void) const {return d_selectCols;}
268 
269 
277  const Image* getSelectionBrushImage(void) const {return d_selectBrush;}
278 
279 
280  /*************************************************************************
281  Manipulators
282  *************************************************************************/
296  void setText(const String& text) {d_itemText = text;}
297 
298  void setTooltipText(const String& text) {d_tooltipText = text;}
299 
313  void setID(uint item_id) {d_itemID = item_id;}
314 
315 
329  void setUserData(void* item_data) {d_itemData = item_data;}
330 
331 
342  void setSelected(bool setting) {d_selected = setting;}
343 
344 
355  void setDisabled(bool setting) {d_disabled = setting;}
356 
370  void setAutoDeleted(bool setting) {d_autoDelete = setting;}
371 
372 
384  void setOwnerWindow(const Window* owner) {d_owner = owner;}
385 
386 
397  void setSelectionColours(const ColourRect& cols) {d_selectCols = cols;}
398 
399 
419  void setSelectionColours(colour top_left_colour, colour top_right_colour, colour bottom_left_colour, colour bottom_right_colour);
420 
421 
432  void setSelectionColours(colour col) {setSelectionColours(col, col, col, col);}
433 
434 
445  void setSelectionBrushImage(const Image* image) {d_selectBrush = image;}
446 
447 
461  void setSelectionBrushImage(const String& imageset, const String& image);
462 
471  void setButtonLocation(Rect &buttonOffset) { d_buttonLocation = buttonOffset; }
472 
473  Rect &getButtonLocation(void) { return d_buttonLocation; }
474  bool getIsOpen(void) { return d_isOpen; }
475  void toggleIsOpen(void) { d_isOpen = !d_isOpen; }
476  TreeItem *getTreeItemFromIndex(size_t itemIndex);
477  size_t getItemCount(void) const {return d_listItems.size();}
478  LBItemList &getItemList(void) { return d_listItems; }
479  void addItem(TreeItem* item);
480  void setIcon(const Image &theIcon) { d_iconImage = (Image *)&theIcon; }
481 
482 
483  /*************************************************************************
484  Abstract portion of interface
485  *************************************************************************/
493  virtual Size getPixelSize(void) const;
494 
495 
512  virtual void draw(const Vector3& position, float alpha, const Rect& clipper) const;
513 
514  virtual void draw(RenderCache& cache,const Rect& targetRect, float zBase, float alpha, const Rect* clipper) const;
515 
516  /*************************************************************************
517  Operators
518  *************************************************************************/
523  virtual bool operator<(const TreeItem& rhs) const {return d_itemText < rhs.getText();}
524 
525 
530  virtual bool operator>(const TreeItem& rhs) const {return d_itemText > rhs.getText();}
531 
532 
533 protected:
534  /*************************************************************************
535  Implementation methods
536  *************************************************************************/
542  ColourRect getModulateAlphaColourRect(const ColourRect& cols, float alpha) const;
543 
544 
550  colour calculateModulatedAlphaColour(colour col, float alpha) const;
551 
552 
553  /*************************************************************************
554  Implementation Data
555  *************************************************************************/
558  uint d_itemID;
559  void * d_itemData;
560  bool d_selected;
561  bool d_disabled;
563  Rect d_buttonLocation;
564  const Window * d_owner;
570  LBItemList d_listItems;
571  bool d_isOpen;
572  };
573 
574 } // End of CEGUI namespace section
575 
576 
577 #endif // end of guard _CEGUITreeItem_h_