| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef VIEWS_CONTROLS_TREE_TREE_VIEW_H_ | 5 #ifndef VIEWS_CONTROLS_TREE_TREE_VIEW_H_ |
| 6 #define VIEWS_CONTROLS_TREE_TREE_VIEW_H_ | 6 #define VIEWS_CONTROLS_TREE_TREE_VIEW_H_ |
| 7 | 7 |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #include <commctrl.h> | 9 #include <commctrl.h> |
| 10 | 10 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 virtual ~TreeView(); | 50 virtual ~TreeView(); |
| 51 | 51 |
| 52 // Is dragging enabled? The default is false. | 52 // Is dragging enabled? The default is false. |
| 53 void set_drag_enabled(bool drag_enabled) { drag_enabled_ = drag_enabled; } | 53 void set_drag_enabled(bool drag_enabled) { drag_enabled_ = drag_enabled; } |
| 54 bool drag_enabled() const { return drag_enabled_; } | 54 bool drag_enabled() const { return drag_enabled_; } |
| 55 | 55 |
| 56 // Sets the model. TreeView does not take ownership of the model. | 56 // Sets the model. TreeView does not take ownership of the model. |
| 57 void SetModel(TreeModel* model); | 57 void SetModel(TreeModel* model); |
| 58 TreeModel* model() const { return model_; } | 58 TreeModel* model() const { return model_; } |
| 59 | 59 |
| 60 // Sets whether to automatically expand children when a parent node is |
| 61 // expanded. The default is false. If true, when a node in the tree is |
| 62 // expanded for the first time, its children are also automatically expanded. |
| 63 // If a node is subsequently collapsed and expanded again, the children |
| 64 // will not be automatically expanded. |
| 65 void set_auto_expand_children(bool auto_expand_children) { |
| 66 auto_expand_children_ = auto_expand_children; |
| 67 } |
| 68 |
| 60 // Sets whether the user can edit the nodes. The default is true. If true, | 69 // Sets whether the user can edit the nodes. The default is true. If true, |
| 61 // the Controller is queried to determine if a particular node can be edited. | 70 // the Controller is queried to determine if a particular node can be edited. |
| 62 void SetEditable(bool editable); | 71 void SetEditable(bool editable); |
| 63 | 72 |
| 73 // Sets whether lines are drawn from the root node to child nodes (and |
| 74 // whether plus boxes show up next to the root node.) The default is false. |
| 75 // If root_shown_ is false, the children of the root act as the roots in the |
| 76 // native control, and so this setting takes effect for them. |
| 77 void set_lines_at_root(bool lines_at_root) { |
| 78 lines_at_root_ = lines_at_root; |
| 79 } |
| 80 |
| 64 // Edits the specified node. This cancels the current edit and expands | 81 // Edits the specified node. This cancels the current edit and expands |
| 65 // all parents of node. | 82 // all parents of node. |
| 66 void StartEditing(TreeModelNode* node); | 83 void StartEditing(TreeModelNode* node); |
| 67 | 84 |
| 68 // Cancels the current edit. Does nothing if not editing. | 85 // Cancels the current edit. Does nothing if not editing. |
| 69 void CancelEdit(); | 86 void CancelEdit(); |
| 70 | 87 |
| 71 // Commits the current edit. Does nothing if not editing. | 88 // Commits the current edit. Does nothing if not editing. |
| 72 void CommitEdit(); | 89 void CommitEdit(); |
| 73 | 90 |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 WPARAM w_param, | 267 WPARAM w_param, |
| 251 LPARAM l_param); | 268 LPARAM l_param); |
| 252 | 269 |
| 253 // Handle to the tree window. | 270 // Handle to the tree window. |
| 254 HWND tree_view_; | 271 HWND tree_view_; |
| 255 | 272 |
| 256 // The model, may be null. | 273 // The model, may be null. |
| 257 TreeModel* model_; | 274 TreeModel* model_; |
| 258 | 275 |
| 259 // Maps from id to NodeDetails. | 276 // Maps from id to NodeDetails. |
| 260 std::map<int,NodeDetails*> id_to_details_map_; | 277 std::map<int, NodeDetails*> id_to_details_map_; |
| 261 | 278 |
| 262 // Maps from model entry to NodeDetails. | 279 // Maps from model entry to NodeDetails. |
| 263 std::map<TreeModelNode*,NodeDetails*> node_to_details_map_; | 280 std::map<TreeModelNode*, NodeDetails*> node_to_details_map_; |
| 281 |
| 282 // Whether to automatically expand children when a parent node is expanded. |
| 283 bool auto_expand_children_; |
| 264 | 284 |
| 265 // Whether the user can edit the items. | 285 // Whether the user can edit the items. |
| 266 bool editable_; | 286 bool editable_; |
| 267 | 287 |
| 268 // Next id to create. Any time an item is added this is incremented by one. | 288 // Next id to create. Any time an item is added this is incremented by one. |
| 269 int next_id_; | 289 int next_id_; |
| 270 | 290 |
| 271 // The controller. | 291 // The controller. |
| 272 TreeViewController* controller_; | 292 TreeViewController* controller_; |
| 273 | 293 |
| 274 // Node being edited. If null, not editing. | 294 // Node being edited. If null, not editing. |
| 275 TreeModelNode* editing_node_; | 295 TreeModelNode* editing_node_; |
| 276 | 296 |
| 277 // Whether or not the root is shown in the tree. | 297 // Whether or not the root is shown in the tree. |
| 278 bool root_shown_; | 298 bool root_shown_; |
| 279 | 299 |
| 300 // Whether lines are drawn from the root to the children. |
| 301 bool lines_at_root_; |
| 302 |
| 280 // Whether enter should be processed by the tree when not editing. | 303 // Whether enter should be processed by the tree when not editing. |
| 281 bool process_enter_; | 304 bool process_enter_; |
| 282 | 305 |
| 283 // Whether we notify context menu controller only when mouse is over node | 306 // Whether we notify context menu controller only when mouse is over node |
| 284 // and node is selected. | 307 // and node is selected. |
| 285 bool show_context_menu_only_when_node_selected_; | 308 bool show_context_menu_only_when_node_selected_; |
| 286 | 309 |
| 287 // Whether the selection is changed on right mouse down. | 310 // Whether the selection is changed on right mouse down. |
| 288 bool select_on_right_mouse_down_; | 311 bool select_on_right_mouse_down_; |
| 289 | 312 |
| 290 // A wrapper around 'this', used for subclassing the TreeView control. | 313 // A wrapper around 'this', used for subclassing the TreeView control. |
| 291 TreeViewWrapper wrapper_; | 314 TreeViewWrapper wrapper_; |
| 292 | 315 |
| 293 // Original handler installed on the TreeView. | 316 // Original handler installed on the TreeView. |
| 294 WNDPROC original_handler_; | 317 WNDPROC original_handler_; |
| 295 | 318 |
| 296 bool drag_enabled_; | 319 bool drag_enabled_; |
| 297 | 320 |
| 298 // Did the model return a non-empty set of icons from GetIcons? | 321 // Did the model return a non-empty set of icons from GetIcons? |
| 299 bool has_custom_icons_; | 322 bool has_custom_icons_; |
| 300 | 323 |
| 301 HIMAGELIST image_list_; | 324 HIMAGELIST image_list_; |
| 302 | 325 |
| 303 DISALLOW_COPY_AND_ASSIGN(TreeView); | 326 DISALLOW_COPY_AND_ASSIGN(TreeView); |
| 304 }; | 327 }; |
| 305 | 328 |
| 306 } // namespace views | 329 } // namespace views |
| 307 | 330 |
| 308 #endif // VIEWS_CONTROLS_TREE_TREE_VIEW_H_ | 331 #endif // VIEWS_CONTROLS_TREE_TREE_VIEW_H_ |
| OLD | NEW |