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 "CEGUIRenderCache.h"
00035 
00036 // Start of CEGUI namespace section
00037 namespace CEGUI
00038 {
00043 class CEGUIEXPORT TreeItem
00044    {
00045 public:
00046   typedef std::vector<TreeItem*>  LBItemList;
00047 
00048    /*************************************************************************
00049       Constants
00050    *************************************************************************/
00051    static const colour  DefaultTextColour;         
00052    static const colour  DefaultSelectionColour;    
00053 
00054 
00055    /*************************************************************************
00056       Construction and Destruction
00057    *************************************************************************/
00062    TreeItem(const String& text, uint item_id = 0, void* item_data = 0, bool disabled = false, bool auto_delete = true);
00063 
00064 
00069    virtual ~TreeItem(void) {}
00070 
00071 
00072    /*************************************************************************
00073       Accessors
00074    *************************************************************************/
00085    Font* getFont(void) const;
00086 
00087 
00095    ColourRect  getTextColours(void) const    {return d_textCols;}
00096 
00097 
00098    /*************************************************************************
00099       Manipulator methods
00100    *************************************************************************/
00111    void  setFont(Font* font)     {d_font = font;}
00112 
00113 
00124    void  setFont(const String& font_name);
00125 
00126 
00137    void  setTextColours(const ColourRect& cols)       {d_textCols = cols;}
00138 
00139 
00159    void  setTextColours(colour top_left_colour, colour top_right_colour, colour bottom_left_colour, colour bottom_right_colour);
00160 
00161 
00172    void  setTextColours(colour col)    {setTextColours(col, col, col, col);}
00173 
00174 
00185    const String&  getText(void) const     {return d_itemText;}
00186    const String&  getTooltipText(void) const    {return d_tooltipText;}
00187 
00198    uint  getID(void) const       {return d_itemID;}
00199 
00200 
00211    void* getUserData(void) const    {return d_itemData;}
00212 
00213 
00221    bool  isSelected(void) const     {return d_selected;}
00222 
00223 
00231    bool  isDisabled(void) const     {return d_disabled;}
00232 
00233 
00244    bool  isAutoDeleted(void) const  {return d_autoDelete;}
00245 
00246 
00256 //   const Window*  getOwnerWindow(const Window* owner)    {return d_owner;}
00257    const Window*  getOwnerWindow(void)    {return d_owner;}
00258 
00259 
00267    ColourRect  getSelectionColours(void) const     {return d_selectCols;}
00268 
00269 
00277    const Image*   getSelectionBrushImage(void) const     {return d_selectBrush;}
00278 
00279 
00280    /*************************************************************************
00281       Manipulators
00282    *************************************************************************/
00296    void  setText(const String& text)      {d_itemText = text;}
00297 
00298    void  setTooltipText(const String& text)     {d_tooltipText = text;}
00299 
00313    void  setID(uint item_id)     {d_itemID = item_id;}
00314 
00315 
00329    void  setUserData(void* item_data)  {d_itemData = item_data;}
00330 
00331 
00342    void  setSelected(bool setting)     {d_selected = setting;}
00343 
00344 
00355    void  setDisabled(bool setting)     {d_disabled = setting;}
00356 
00370    void  setAutoDeleted(bool setting)     {d_autoDelete = setting;}
00371 
00372 
00384    void  setOwnerWindow(const Window* owner)    {d_owner = owner;}
00385 
00386 
00397    void  setSelectionColours(const ColourRect& cols)     {d_selectCols = cols;}
00398 
00399 
00419    void  setSelectionColours(colour top_left_colour, colour top_right_colour, colour bottom_left_colour, colour bottom_right_colour);
00420 
00421 
00432    void  setSelectionColours(colour col)     {setSelectionColours(col, col, col, col);}
00433 
00434 
00445    void  setSelectionBrushImage(const Image* image)      {d_selectBrush = image;}
00446 
00447 
00461    void  setSelectionBrushImage(const String& imageset, const String& image);
00462 
00471    void  setButtonLocation(Rect &buttonOffset) { d_buttonLocation = buttonOffset; }
00472 
00473    Rect &getButtonLocation(void) { return d_buttonLocation; }
00474    bool  getIsOpen(void) { return d_isOpen; }
00475    void  toggleIsOpen(void) { d_isOpen = !d_isOpen; }
00476    TreeItem *getTreeItemFromIndex(size_t itemIndex);
00477    size_t          getItemCount(void) const {return d_listItems.size();}
00478    LBItemList &getItemList(void) { return d_listItems; }
00479    void  addItem(TreeItem* item);
00480    void  setIcon(const Image &theIcon) { d_iconImage = (Image *)&theIcon; }
00481 
00482 
00483    /*************************************************************************
00484       Abstract portion of interface
00485    *************************************************************************/
00493    virtual  Size  getPixelSize(void) const;
00494 
00495 
00512    virtual  void  draw(const Vector3& position, float alpha, const Rect& clipper) const;
00513 
00514     virtual void    draw(RenderCache& cache,const Rect& targetRect, float zBase,  float alpha, const Rect* clipper) const;
00515 
00516    /*************************************************************************
00517       Operators
00518    *************************************************************************/
00523    virtual  bool  operator<(const TreeItem& rhs) const      {return d_itemText < rhs.getText();}
00524 
00525 
00530    virtual  bool  operator>(const TreeItem& rhs) const      {return d_itemText > rhs.getText();}
00531 
00532 
00533 protected:
00534    /*************************************************************************
00535       Implementation methods
00536    *************************************************************************/
00542    ColourRect getModulateAlphaColourRect(const ColourRect& cols, float alpha) const;
00543 
00544 
00550    colour calculateModulatedAlphaColour(colour col, float alpha) const;
00551 
00552 
00553    /*************************************************************************
00554       Implementation Data
00555    *************************************************************************/
00556    String   d_itemText;    
00557    String   d_tooltipText; 
00558    uint     d_itemID;      
00559    void *   d_itemData;    
00560    bool     d_selected;    
00561    bool     d_disabled;    
00562    bool     d_autoDelete;  
00563    Rect     d_buttonLocation; 
00564    const Window * d_owner; 
00565    ColourRect     d_selectCols;     
00566    const Image *  d_selectBrush;    
00567    ColourRect     d_textCols;       
00568    Font *   d_font;           
00569    Image *        d_iconImage;      
00570    LBItemList     d_listItems;      
00571    bool           d_isOpen;         
00572    };
00573 
00574 } // End of  CEGUI namespace section
00575 
00576 
00577 #endif   // end of guard _CEGUITreeItem_h_

Generated on Sat Jun 28 14:35:44 2008 for Crazy Eddies GUI System by  doxygen 1.5.4