Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

GuiTree.h

Go to the documentation of this file.
00001 
00002 //
00003 // $Id: GuiTree.h,v 1.9 2008/03/09 10:41:08 rhatcher Exp $
00004 //
00005 // GuiTree
00006 //
00007 // Package: MIDAD
00008 //
00009 // Wraps a TGListTree
00010 //
00011 // Contact: bv@bnl.gov
00012 //
00013 // Created on: Fri Mar 15 10:43:15 2002
00014 //
00016 
00017 #ifndef GUITREE_H
00018 #define GUITREE_H
00019 
00020 #include <Midad/Gui/GuiBase.h>
00021 #include <TGListTree.h>
00022 
00023 // A class to encapsulate information about an entry in the tree as
00024 // well as provide a clicked signal.  This is created and memory
00025 // managed by the underlying TGListTree.  The only real reason to wrap
00026 // it is to provide the signal.  When using methods from the base
00027 // class, you should be able to dynamic_cast<GuiTreeEntry*> any
00028 // returned TGListTreeItem (eg, parent, sibling, etc) in order to get
00029 // at the Signal.  Same goes for methods of TGListTree which return
00030 // items.
00031 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,19,01)
00032 class GuiTreeEntry : public TGListTreeItemStd {
00033 #else
00034 class GuiTreeEntry : public TGListTreeItem {
00035 #endif
00036 
00037 
00038 public:
00039 
00040     SigC::Signal0<void> clicked, on_mouse_over;
00041 
00042     ~GuiTreeEntry();
00043     
00044 private:
00045     friend class GuiTree;
00046     GuiTreeEntry(TGClient* client, const char* name, 
00047                  const TGPicture* opened,const TGPicture* closed);
00048 
00049 };
00050 
00051 class GuiTree : public TGListTree, public GuiBase
00052 {
00053 
00054 public:
00055 
00056     GuiTree(TGWindow& parent, UInt_t options = kHorizontalFrame);
00057     virtual ~GuiTree();
00058 
00059     // parent=0 for top level addition
00060     GuiTreeEntry* AddEntry(GuiTreeEntry* parent, const char* label);
00061     
00062     // override baseclass signal - still calls base signal but also
00063     // triggers associated GuiTreeEntry's clicked sig.  These also
00064     // provide some default behavior (ie. DoubleClicked toggles
00065     // open/closed)
00066     virtual void Clicked(TGListTreeItem* item, Int_t btn);
00067     virtual void DoubleClicked(TGListTreeItem* item, Int_t btn);
00068     virtual void OnMouseOver(TGListTreeItem* entry);
00069 
00070     void DeleteAllItems();
00071 
00072 private:
00073 
00074     // copy constructor, assignment:
00075     GuiTree(const GuiTree& rhs); // copy constructor
00076     GuiTree& operator=(const GuiTree& rhs); // assignment
00077 
00078     // Don't let user call these since they create TGListTreeItems
00079     // instead of GuiListEntrys.  Use AddEntry() instead
00080     TGListTreeItem* AddItem(TGListTreeItem* parent, const char* string,
00081                             const TGPicture* open = 0, 
00082                             const TGPicture* closed = 0);
00083     TGListTreeItem* AddItem(TGListTreeItem* parent, const char* string,
00084                             void* userData, const TGPicture* open = 0,
00085                             const TGPicture* closed = 0);
00086 
00087     // ROOT defines this (as empty???).  Do same to avoid warnings:
00088     void OnMouseOver(TGFrame*) {}
00089     void Clicked(TGListTreeItem*, int, int, int) {}
00090     void Clicked(TGFrame*, int, int, int) {}
00091     void Clicked(TGFrame*, int) {}
00092 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,19,01)
00093     void Clicked(TGListTreeItem *, Int_t, UInt_t, Int_t, Int_t) {}
00094 #endif
00095     void DoubleClicked(TGListTreeItem*, int, int, int) {}
00096     void DoubleClicked(TGFrame*, int, int, int) {}
00097     void DoubleClicked(TGFrame*, int) {}
00098 };                              // end of class GuiTree
00099 
00100 #endif  // GUITREE_H

Generated on Mon Feb 15 11:06:47 2010 for loon by  doxygen 1.3.9.1