Crazy Eddie's GUI System  0.8.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
TreeItem.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 "../Base.h"
32 #include "../String.h"
33 #include "../ColourRect.h"
34 #include "../BasicRenderedStringParser.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 : public
59  AllocatedObject<TreeItem>
60 {
61 public:
62  typedef std::vector<TreeItem*
63  CEGUI_VECTOR_ALLOC(TreeItem*)> LBItemList;
64 
65  /*************************************************************************
66  Constants
67  *************************************************************************/
69  static const Colour DefaultTextColour;
72 
73  /*************************************************************************
74  Construction and Destruction
75  *************************************************************************/
80  TreeItem(const String& text, uint item_id = 0, void* item_data = 0,
81  bool disabled = false, bool auto_delete = true);
82 
87  virtual ~TreeItem(void);
88 
89  /*************************************************************************
90  Accessors
91  *************************************************************************/
102  const Font* getFont(void) const;
103 
111  ColourRect getTextColours(void) const
112  { return d_textCols; }
113 
114  /*************************************************************************
115  Manipulator methods
116  *************************************************************************/
127  void setFont(const Font* font);
128 
140  void setFont(const String& font_name);
141 
152  void setTextColours(const ColourRect& cols)
153  { d_textCols = cols; d_renderedStringValid = false; }
154 
178  void setTextColours(Colour top_left_colour, Colour top_right_colour,
179  Colour bottom_left_colour, Colour bottom_right_colour);
180 
191  void setTextColours(Colour col)
192  { setTextColours(col, col, col, col); }
193 
204  const String& getText() const {return d_textLogical;}
205 
207  const String& getTextVisual() const;
208 
217  const String& getTooltipText(void) const
218  { return d_tooltipText; }
219 
230  uint getID(void) const
231  { return d_itemID; }
232 
244  void* getUserData(void) const
245  { return d_itemData; }
246 
255  bool isSelected(void) const
256  { return d_selected; }
257 
266  bool isDisabled(void) const
267  { return d_disabled; }
268 
282  bool isAutoDeleted(void) const
283  { return d_autoDelete; }
284 
295  const Window* getOwnerWindow(void)
296  { return d_owner; }
297 
305  ColourRect getSelectionColours(void) const
306  { return d_selectCols; }
307 
308 
316  const Image* getSelectionBrushImage(void) const
317  { return d_selectBrush; }
318 
319 
320  /*************************************************************************
321  Manipulators
322  *************************************************************************/
336  void setText(const String& text);
337 
349  void setTooltipText(const String& text)
350  { d_tooltipText = text; }
351 
365  void setID(uint item_id)
366  { d_itemID = item_id; }
367 
381  void setUserData(void* item_data)
382  { d_itemData = item_data; }
383 
395  void setSelected(bool setting)
396  { d_selected = setting; }
397 
409  void setDisabled(bool setting)
410  { d_disabled = setting; }
411 
427  void setAutoDeleted(bool setting)
428  { d_autoDelete = setting; }
429 
442  void setOwnerWindow(const Window* owner)
443  { d_owner = owner; }
444 
455  void setSelectionColours(const ColourRect& cols)
456  { d_selectCols = cols; }
457 
458 
482  void setSelectionColours(Colour top_left_colour,
483  Colour top_right_colour,
484  Colour bottom_left_colour,
485  Colour bottom_right_colour);
486 
497  void setSelectionColours(Colour col)
498  { setSelectionColours(col, col, col, col); }
499 
500 
511  void setSelectionBrushImage(const Image* image)
512  { d_selectBrush = image; }
513 
514 
525  void setSelectionBrushImage(const String& name);
526 
535  void setButtonLocation(Rectf& buttonOffset)
536  { d_buttonLocation = buttonOffset; }
537 
538  Rectf& getButtonLocation(void)
539  { return d_buttonLocation; }
540 
541  bool getIsOpen(void)
542  { return d_isOpen; }
543 
544  void toggleIsOpen(void)
545  { d_isOpen = !d_isOpen; }
546 
547  TreeItem *getTreeItemFromIndex(size_t itemIndex);
548 
549  size_t getItemCount(void) const
550  { return d_listItems.size(); }
551 
552  LBItemList &getItemList(void)
553  { return d_listItems; }
554 
555  void addItem(TreeItem* item);
556  void removeItem(const TreeItem* item);
557 
558  void setIcon(const Image &theIcon)
559  { d_iconImage = &theIcon; }
560 
561  /*************************************************************************
562  Abstract portion of interface
563  *************************************************************************/
571  virtual Sizef getPixelSize(void) const;
572 
590  virtual void draw(GeometryBuffer& buffer, const Rectf& targetRect,
591  float alpha, const Rectf* clipper) const;
592 
605  virtual bool handleFontRenderSizeChange(const Font* const font);
606 
607  /*************************************************************************
608  Operators
609  *************************************************************************/
614  virtual bool operator<(const TreeItem& rhs) const
615  { return getText() < rhs.getText(); }
616 
621  virtual bool operator>(const TreeItem& rhs) const
622  { return getText() > rhs.getText(); }
623 
624 protected:
625  /*************************************************************************
626  Implementation methods
627  *************************************************************************/
633  ColourRect getModulateAlphaColourRect(const ColourRect& cols,
634  float alpha) const;
635 
641  Colour calculateModulatedAlphaColour(Colour col, float alpha) const;
642 
644  void parseTextString() const;
645 
646  /*************************************************************************
647  Implementation Data
648  *************************************************************************/
651 
654  mutable bool d_bidiDataValid;
658  uint d_itemID;
660  void* d_itemData;
670  const Window* d_owner;
678  const Font* d_font;
682  LBItemList d_listItems;
684  bool d_isOpen;
690  mutable bool d_renderedStringValid;
691 };
692 
693 } // End of CEGUI namespace section
694 
695 #if defined(_MSC_VER)
696 # pragma warning(pop)
697 #endif
698 
699 #endif // end of guard _CEGUITreeItem_h_