/home/koen/project/wt/cvs/wt/examples/treelist/TreeNode.h

Go to the documentation of this file.
00001 // This may look like C code, but it's really -*- C++ -*-
00002 /*
00003  * Copyright (C) 2008 Emweb bvba, Kessel-Lo, Belgium.
00004  *
00005  * See the LICENSE file for terms of use.
00006  */
00007 #ifndef TREENODE_H_
00008 #define TREENODE_H_
00009 
00010 #include <Wt/WCompositeWidget>
00011 #include <Wt/WText>
00012 
00013 class IconPair;
00014 
00015 namespace Wt {
00016   class WTable;
00017   class WImage;
00018 }
00019 
00024 
00055 class TreeNode : public Wt::WCompositeWidget
00056 {
00057 public:
00068   TreeNode(const std::wstring labelText,
00069            Wt::WText::Formatting labelFormatting,
00070            IconPair *labelIcon, Wt::WContainerWidget *parent = 0);
00071 
00074   void addChildNode(TreeNode *node);
00075 
00078   void removeChildNode(TreeNode *node);
00079 
00082   const std::vector<TreeNode *>& childNodes() const { return childNodes_; }
00083 
00084 public slots:
00087   void collapse();
00088 
00091   void expand();
00092 
00093 private:
00095   std::vector<TreeNode *> childNodes_;
00096 
00098   TreeNode                 *parentNode_;
00099 
00101   Wt::WTable               *layout_;
00102 
00104   IconPair                 *expandIcon_;
00105 
00107   Wt::WImage               *noExpandIcon_;
00108 
00110   IconPair                 *labelIcon_;
00111 
00113   Wt::WText                *labelText_;
00114 
00116   Wt::WText                *childCountLabel_;
00117 
00119   Wt::WContainerWidget     *expandedContent_;
00120 
00122   void adjustExpandIcon();
00123 
00125   bool isLastChildNode() const;
00126 
00128   void childNodesChanged();
00129 
00131   bool wasCollapsed_;
00132 
00134   void undoCollapse();
00135 
00137   void undoExpand();
00138 
00140   enum ImageIndex { Middle = 0, Last = 1 };
00141 
00142   static std::string imageLine_[];
00143   static std::string imagePlus_[];
00144   static std::string imageMin_[];
00145 }; //
00146 
00149 #endif // WTREENODE_H_

Generated on Fri Jul 25 17:05:59 2008 for Wt by doxygen 1.5.3