Wt examples
3.2.0
|
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::string labelText, 00069 Wt::TextFormat labelFormat, 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 00086 void collapse(); 00087 00090 void expand(); 00091 00092 private: 00094 std::vector<TreeNode *> childNodes_; 00095 00097 TreeNode *parentNode_; 00098 00100 Wt::WTable *layout_; 00101 00103 IconPair *expandIcon_; 00104 00106 Wt::WImage *noExpandIcon_; 00107 00109 IconPair *labelIcon_; 00110 00112 Wt::WText *labelText_; 00113 00115 Wt::WText *childCountLabel_; 00116 00118 Wt::WContainerWidget *expandedContent_; 00119 00121 void adjustExpandIcon(); 00122 00124 bool isLastChildNode() const; 00125 00127 void childNodesChanged(); 00128 00130 bool wasCollapsed_; 00131 00133 void undoCollapse(); 00134 00136 void undoExpand(); 00137 00139 enum ImageIndex { Middle = 0, Last = 1 }; 00140 00141 static std::string imageLine_[]; 00142 static std::string imagePlus_[]; 00143 static std::string imageMin_[]; 00144 }; // 00145 00148 #endif // WTREENODE_H_