Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef GUI_WIDGETS_TREE_VIEW_NODE_HPP_INCLUDED
00017 #define GUI_WIDGETS_TREE_VIEW_NODE_HPP_INCLUDED
00018
00019 #include "gui/auxiliary/window_builder/tree_view.hpp"
00020
00021 #include <boost/ptr_container/ptr_vector.hpp>
00022
00023 namespace gui2 {
00024
00025 class tselectable_;
00026 class ttoggle_button;
00027 class ttree_view;
00028
00029 class ttree_view_node
00030 : public twidget
00031 {
00032 friend struct ttree_view_node_implementation;
00033 friend class ttree_view;
00034
00035 public:
00036
00037 typedef implementation::tbuilder_tree_view::tnode tnode_definition;
00038 ttree_view_node(const std::string& id
00039 , const std::vector<tnode_definition>& node_definitions
00040 , ttree_view_node* parent_node
00041 , ttree_view& parent_tree_view
00042 , const std::map<std::string /* widget id */, string_map>& data);
00043
00044 ~ttree_view_node();
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061 ttree_view_node& add_child(const std::string& id
00062 , const std::map<std::string /* widget id */, string_map>& data
00063 , const int index = -1);
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078 ttree_view_node& add_sibling(const std::string& id
00079 , const std::map<std::string /* widget id */, string_map>& data)
00080 {
00081 assert(!is_root_node());
00082 return parent_node().add_child(id, data);
00083 }
00084
00085
00086
00087
00088
00089
00090
00091
00092 bool is_root_node() const { return parent_node_ == NULL; }
00093
00094
00095
00096
00097
00098
00099 unsigned get_indention_level() const;
00100
00101
00102 bool empty() const { return children_.empty(); }
00103
00104
00105 bool is_folded() const;
00106
00107 #if 0
00108 enum texpand_mode
00109 {
00110 recursive_restore
00111 , recursive_expand
00112 , not_recursive
00113 };
00114
00115
00116
00117
00118
00119
00120
00121
00122 #endif
00123
00124
00125
00126
00127
00128
00129 virtual iterator::twalker_* create_walker() { return NULL; }
00130
00131
00132 twidget* find_at(const tpoint& coordinate, const bool must_be_active);
00133
00134
00135 const twidget* find_at(
00136 const tpoint& coordinate
00137 , const bool must_be_active) const;
00138
00139
00140 twidget* find(const std::string& id, const bool must_be_active)
00141 {
00142 twidget* result = twidget::find(id, must_be_active);
00143 return result ? result : grid_.find(id, must_be_active);
00144 }
00145
00146
00147 const twidget* find(const std::string& id
00148 , const bool must_be_active) const
00149 {
00150 const twidget* result = twidget::find(id, must_be_active);
00151 return result ? result : grid_.find(id, must_be_active);
00152 }
00153
00154
00155
00156
00157
00158
00159 size_t size() const { return children_.size(); }
00160
00161
00162
00163
00164 void clear();
00165
00166
00167
00168
00169
00170
00171
00172
00173 ttree_view_node& parent_node();
00174
00175
00176 const ttree_view_node& parent_node() const;
00177
00178 ttree_view& tree_view();
00179
00180 const ttree_view& tree_view() const;
00181
00182 private:
00183
00184
00185 void request_reduce_width(const unsigned ) {}
00186
00187
00188
00189
00190
00191
00192 ttree_view_node* parent_node_;
00193
00194
00195 ttree_view& tree_view_;
00196
00197
00198 tgrid grid_;
00199
00200
00201
00202
00203
00204
00205 boost::ptr_vector<ttree_view_node> children_;
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215 const std::vector<tnode_definition>& node_definitions_;
00216
00217
00218 ttoggle_button* icon_;
00219
00220
00221 tselectable_* label_;
00222
00223
00224
00225
00226
00227
00228 void impl_populate_dirty_list(twindow& caller,
00229 const std::vector<twidget*>& call_stack);
00230
00231 tpoint calculate_best_size() const;
00232
00233 bool disable_click_dismiss() const { return true; }
00234
00235 tpoint calculate_best_size(const int indention_level
00236 , const unsigned indention_step_size) const;
00237
00238 tpoint get_current_size() const;
00239 tpoint get_folded_size() const;
00240 tpoint get_unfolded_size() const;
00241
00242 void set_origin(const tpoint& origin);
00243
00244 void place(const tpoint& origin, const tpoint& size);
00245
00246 unsigned place(
00247 const unsigned indention_step_size
00248 , tpoint origin
00249 , unsigned width);
00250
00251 void set_visible_area(const SDL_Rect& area);
00252
00253 void impl_draw_children(surface& frame_buffer);
00254 void impl_draw_children(surface& frame_buffer, int x_offset, int y_offset);
00255
00256
00257 void signal_handler_left_button_click(const event::tevent event);
00258
00259 void signal_handler_label_left_button_click(
00260 const event::tevent event
00261 , bool& handled
00262 , bool& halt);
00263
00264 void init_grid(tgrid* grid
00265 , const std::map<
00266 std::string , string_map>& data);
00267
00268 const std::string& get_control_type() const;
00269 };
00270
00271 }
00272
00273 #endif
00274
00275