• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List

CEGUITreeItem.h

00001 /***********************************************************************
00002     filename:  CEGUITreeItem.h
00003     created:   5-13-07
00004     author:    Jonathan Welch (Based on Code by David Durant)
00005  *************************************************************************/
00006 /***************************************************************************
00007  *   Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
00008  *
00009  *   Permission is hereby granted, free of charge, to any person obtaining
00010  *   a copy of this software and associated documentation files (the
00011  *   "Software"), to deal in the Software without restriction, including
00012  *   without limitation the rights to use, copy, modify, merge, publish,
00013  *   distribute, sublicense, and/or sell copies of the Software, and to
00014  *   permit persons to whom the Software is furnished to do so, subject to
00015  *   the following conditions:
00016  *
00017  *   The above copyright notice and this permission notice shall be
00018  *   included in all copies or substantial portions of the Software.
00019  *
00020  *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00021  *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00022  *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00023  *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
00024  *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
00025  *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00026  *   OTHER DEALINGS IN THE SOFTWARE.
00027  ***************************************************************************/
00028 #ifndef _CEGUITreeItem_h_
00029 #define _CEGUITreeItem_h_
00030 
00031 #include "../CEGUIBase.h"
00032 #include "../CEGUIString.h"
00033 #include "../CEGUIColourRect.h"
00034 #include "../CEGUIBasicRenderedStringParser.h"
00035 
00036 #if defined(_MSC_VER)
00037 #   pragma warning(push)
00038 #   pragma warning(disable : 4251)
00039 #endif
00040 
00041 // Start of CEGUI namespace section
00042 namespace CEGUI
00043 {
00058 class CEGUIEXPORT TreeItem
00059 {
00060 public:
00061     typedef std::vector<TreeItem*>  LBItemList;
00062 
00063     /*************************************************************************
00064         Constants
00065      *************************************************************************/
00067     static const colour DefaultTextColour;
00069     static const colour DefaultSelectionColour;
00070 
00071     /*************************************************************************
00072         Construction and Destruction
00073      *************************************************************************/
00078     TreeItem(const String& text, uint item_id = 0, void* item_data = 0,
00079              bool disabled = false, bool auto_delete = true);
00080 
00085     virtual ~TreeItem(void);
00086 
00087     /*************************************************************************
00088         Accessors
00089      *************************************************************************/
00100     Font* getFont(void) const;
00101 
00109     ColourRect getTextColours(void) const
00110     { return d_textCols; }
00111 
00112     /*************************************************************************
00113         Manipulator methods
00114      *************************************************************************/
00125     void setFont(Font* font);
00126 
00138     void setFont(const String& font_name);
00139 
00150     void setTextColours(const ColourRect& cols)
00151     { d_textCols = cols; d_renderedStringValid = false; }
00152 
00176     void setTextColours(colour top_left_colour, colour top_right_colour,
00177                         colour bottom_left_colour, colour bottom_right_colour);
00178 
00189     void setTextColours(colour col)
00190     { setTextColours(col, col, col, col); }
00191 
00202     const String& getText() const {return d_textLogical;}
00203 
00205     const String& getTextVisual() const;
00206 
00215     const String& getTooltipText(void) const
00216     { return d_tooltipText; }
00217 
00228     uint getID(void) const
00229     { return d_itemID; }
00230 
00242     void* getUserData(void) const
00243     { return d_itemData; }
00244 
00253     bool isSelected(void) const
00254     { return d_selected; }
00255 
00264     bool isDisabled(void) const
00265     { return d_disabled; }
00266 
00280     bool isAutoDeleted(void) const
00281     { return d_autoDelete; }
00282 
00293     const Window* getOwnerWindow(void)
00294     { return d_owner; }
00295 
00303     ColourRect getSelectionColours(void) const
00304     { return d_selectCols; }
00305 
00306 
00314     const Image* getSelectionBrushImage(void) const
00315     { return d_selectBrush; }
00316 
00317 
00318     /*************************************************************************
00319         Manipulators
00320      *************************************************************************/
00334     void setText(const String& text);
00335 
00347     void setTooltipText(const String& text)
00348     { d_tooltipText = text; }
00349 
00363     void setID(uint item_id)
00364     { d_itemID = item_id; }
00365 
00379     void setUserData(void* item_data)
00380     { d_itemData = item_data; }
00381 
00393     void setSelected(bool setting)
00394     { d_selected = setting; }
00395 
00407     void setDisabled(bool setting)
00408     { d_disabled = setting; }
00409 
00425     void setAutoDeleted(bool setting)
00426     { d_autoDelete = setting; }
00427 
00440     void setOwnerWindow(const Window* owner)
00441     { d_owner = owner; }
00442 
00453     void setSelectionColours(const ColourRect& cols)
00454     { d_selectCols = cols; }
00455 
00456 
00480     void setSelectionColours(colour top_left_colour,
00481                              colour top_right_colour,
00482                              colour bottom_left_colour,
00483                              colour bottom_right_colour);
00484 
00495     void setSelectionColours(colour col)
00496     { setSelectionColours(col, col, col, col); }
00497 
00498 
00509     void setSelectionBrushImage(const Image* image)
00510     { d_selectBrush = image; }
00511 
00512 
00526     void setSelectionBrushImage(const String& imageset, const String& image);
00527 
00536     void setButtonLocation(Rect &buttonOffset)
00537     { d_buttonLocation = buttonOffset; }
00538 
00539     Rect &getButtonLocation(void)
00540     { return d_buttonLocation; }
00541 
00542     bool getIsOpen(void)
00543     { return d_isOpen; }
00544 
00545     void toggleIsOpen(void)
00546     { d_isOpen = !d_isOpen; }
00547 
00548     TreeItem *getTreeItemFromIndex(size_t itemIndex);
00549 
00550     size_t getItemCount(void) const
00551     { return d_listItems.size(); }
00552 
00553     LBItemList &getItemList(void)
00554     { return d_listItems; }
00555 
00556     void addItem(TreeItem* item);
00557     void removeItem(const TreeItem* item);
00558 
00559     void setIcon(const Image &theIcon)
00560     { d_iconImage = (Image *) & theIcon; }
00561 
00562     /*************************************************************************
00563         Abstract portion of interface
00564      *************************************************************************/
00572     virtual Size getPixelSize(void) const;
00573 
00591     virtual void draw(GeometryBuffer& buffer, const Rect& targetRect,
00592                       float alpha, const Rect* clipper) const;
00593 
00594     /*************************************************************************
00595         Operators
00596      *************************************************************************/
00601     virtual bool operator<(const TreeItem& rhs) const
00602     { return getText() < rhs.getText(); }
00603 
00608     virtual bool operator>(const TreeItem& rhs) const
00609     { return getText() > rhs.getText(); }
00610 
00611 protected:
00612     /*************************************************************************
00613         Implementation methods
00614      *************************************************************************/
00620     ColourRect getModulateAlphaColourRect(const ColourRect& cols,
00621                                           float alpha) const;
00622 
00628     colour calculateModulatedAlphaColour(colour col, float alpha) const;
00629 
00631     void parseTextString() const;
00632 
00633     /*************************************************************************
00634         Implementation Data
00635      *************************************************************************/
00637     String               d_textLogical;            
00638 
00639     BiDiVisualMapping* d_bidiVisualMapping;
00641     mutable bool d_bidiDataValid;
00643     String d_tooltipText;
00645     uint d_itemID;
00647     void* d_itemData;
00649     bool d_selected;
00651     bool d_disabled;
00653     bool d_autoDelete;
00655     Rect d_buttonLocation;
00657     const Window* d_owner;
00659     ColourRect d_selectCols;
00661     const Image* d_selectBrush;
00663     ColourRect d_textCols;
00665     Font* d_font;
00667     Image* d_iconImage;
00669     LBItemList d_listItems;
00671     bool d_isOpen;
00673     static BasicRenderedStringParser d_stringParser;
00675     mutable RenderedString  d_renderedString;
00677     mutable bool d_renderedStringValid;
00678 };
00679 
00680 } // End of  CEGUI namespace section
00681 
00682 #if defined(_MSC_VER)
00683 #   pragma warning(pop)
00684 #endif
00685 
00686 #endif   // end of guard _CEGUITreeItem_h_

Generated on Fri Nov 19 2010 12:01:20 for Crazy Eddies GUI System by  doxygen 1.7.2