OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <windows.h> | 9 #include <windows.h> |
10 #include <commctrl.h> | 10 #include <commctrl.h> |
11 | 11 |
12 #include <map> | 12 #include <map> |
13 | 13 |
14 #include "app/tree_model.h" | 14 #include "app/tree_model.h" |
15 #include "base/basictypes.h" | 15 #include "base/basictypes.h" |
16 #include "base/keyboard_codes.h" | 16 #include "base/keyboard_codes.h" |
17 #include "base/logging.h" | |
18 #include "views/controls/native_control.h" | 17 #include "views/controls/native_control.h" |
19 | 18 |
20 namespace views { | 19 namespace views { |
21 | 20 |
22 class TreeView; | 21 class TreeView; |
23 | 22 |
24 // TreeViewController --------------------------------------------------------- | 23 // TreeViewController --------------------------------------------------------- |
25 | 24 |
26 // Controller for the treeview. | 25 // Controller for the treeview. |
27 class TreeViewController { | 26 class TreeViewController { |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 // the model. | 235 // the model. |
237 void CreateItem(HTREEITEM parent_item, HTREEITEM after, TreeModelNode* node); | 236 void CreateItem(HTREEITEM parent_item, HTREEITEM after, TreeModelNode* node); |
238 | 237 |
239 // Removes entries from the map for item. This method will also | 238 // Removes entries from the map for item. This method will also |
240 // remove the items from the TreeView because the process of | 239 // remove the items from the TreeView because the process of |
241 // deleting an item will send an TVN_GETDISPINFO message, consulting | 240 // deleting an item will send an TVN_GETDISPINFO message, consulting |
242 // our internal map data. | 241 // our internal map data. |
243 void RecursivelyDelete(NodeDetails* node); | 242 void RecursivelyDelete(NodeDetails* node); |
244 | 243 |
245 // Returns the NodeDetails by node from the model. | 244 // Returns the NodeDetails by node from the model. |
246 NodeDetails* GetNodeDetails(TreeModelNode* node) { | 245 NodeDetails* GetNodeDetails(TreeModelNode* node); |
247 DCHECK(node && | |
248 node_to_details_map_.find(node) != node_to_details_map_.end()); | |
249 return node_to_details_map_[node]; | |
250 } | |
251 | 246 |
252 // Returns the NodeDetails by identifier (lparam of the HTREEITEM). | 247 // Returns the NodeDetails by identifier (lparam of the HTREEITEM). |
253 NodeDetails* GetNodeDetailsByID(int id) { | 248 NodeDetails* GetNodeDetailsByID(int id); |
254 DCHECK(id_to_details_map_.find(id) != id_to_details_map_.end()); | |
255 return id_to_details_map_[id]; | |
256 } | |
257 | 249 |
258 // Returns the NodeDetails by HTREEITEM. | 250 // Returns the NodeDetails by HTREEITEM. |
259 NodeDetails* GetNodeDetailsByTreeItem(HTREEITEM tree_item); | 251 NodeDetails* GetNodeDetailsByTreeItem(HTREEITEM tree_item); |
260 | 252 |
261 // Creates the image list to use for the tree. | 253 // Creates the image list to use for the tree. |
262 HIMAGELIST CreateImageList(); | 254 HIMAGELIST CreateImageList(); |
263 | 255 |
264 // Returns the HTREEITEM for |node|. This is intended to be called when a | 256 // Returns the HTREEITEM for |node|. This is intended to be called when a |
265 // model mutation event occur with |node| as the parent. This returns null | 257 // model mutation event occur with |node| as the parent. This returns null |
266 // if the user has never expanded |node| or all of its parents. | 258 // if the user has never expanded |node| or all of its parents. |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 bool has_custom_icons_; | 319 bool has_custom_icons_; |
328 | 320 |
329 HIMAGELIST image_list_; | 321 HIMAGELIST image_list_; |
330 | 322 |
331 DISALLOW_COPY_AND_ASSIGN(TreeView); | 323 DISALLOW_COPY_AND_ASSIGN(TreeView); |
332 }; | 324 }; |
333 | 325 |
334 } // namespace views | 326 } // namespace views |
335 | 327 |
336 #endif // VIEWS_CONTROLS_TREE_TREE_VIEW_H_ | 328 #endif // VIEWS_CONTROLS_TREE_TREE_VIEW_H_ |
OLD | NEW |