OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 APP_TREE_MODEL_H_ | 5 #ifndef APP_TREE_MODEL_H_ |
6 #define APP_TREE_MODEL_H_ | 6 #define APP_TREE_MODEL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 | 12 |
13 class SkBitmap; | 13 class SkBitmap; |
14 | 14 |
15 class TreeModel; | 15 class TreeModel; |
16 | 16 |
17 // TreeModelNode -------------------------------------------------------------- | 17 // TreeModelNode -------------------------------------------------------------- |
18 | 18 |
19 // Type of class returned from the model. | 19 // Type of class returned from the model. |
20 class TreeModelNode { | 20 class TreeModelNode { |
21 public: | 21 public: |
22 // Returns the title for the node. | 22 // Returns the title for the node. |
23 virtual const std::wstring& GetTitle() const = 0; | 23 virtual const std::wstring& GetTitle() const = 0; |
24 | |
25 protected: | |
26 ~TreeModelNode() {} | |
27 }; | 24 }; |
28 | 25 |
29 // Observer for the TreeModel. Notified of significant events to the model. | 26 // Observer for the TreeModel. Notified of significant events to the model. |
30 class TreeModelObserver { | 27 class TreeModelObserver { |
31 public: | 28 public: |
32 // Notification that nodes were added to the specified parent. | 29 // Notification that nodes were added to the specified parent. |
33 virtual void TreeNodesAdded(TreeModel* model, | 30 virtual void TreeNodesAdded(TreeModel* model, |
34 TreeModelNode* parent, | 31 TreeModelNode* parent, |
35 int start, | 32 int start, |
36 int count) = 0; | 33 int count) = 0; |
37 | 34 |
38 // Notification that nodes were removed from the specified parent. | 35 // Notification that nodes were removed from the specified parent. |
39 virtual void TreeNodesRemoved(TreeModel* model, | 36 virtual void TreeNodesRemoved(TreeModel* model, |
40 TreeModelNode* parent, | 37 TreeModelNode* parent, |
41 int start, | 38 int start, |
42 int count) = 0; | 39 int count) = 0; |
43 | 40 |
44 // Notification the children of |parent| have been reordered. Note, only | 41 // Notification the children of |parent| have been reordered. Note, only |
45 // the direct children of |parent| have been reordered, not descendants. | 42 // the direct children of |parent| have been reordered, not descendants. |
46 virtual void TreeNodeChildrenReordered(TreeModel* model, | 43 virtual void TreeNodeChildrenReordered(TreeModel* model, |
47 TreeModelNode* parent) = 0; | 44 TreeModelNode* parent) = 0; |
48 | 45 |
49 // Notification that the contents of a node has changed. | 46 // Notification that the contents of a node has changed. |
50 virtual void TreeNodeChanged(TreeModel* model, TreeModelNode* node) = 0; | 47 virtual void TreeNodeChanged(TreeModel* model, TreeModelNode* node) = 0; |
51 | |
52 protected: | |
53 ~TreeModelObserver() {} | |
54 }; | 48 }; |
55 | 49 |
56 // TreeModel ------------------------------------------------------------------ | 50 // TreeModel ------------------------------------------------------------------ |
57 | 51 |
58 // The model for TreeView. | 52 // The model for TreeView. |
59 class TreeModel { | 53 class TreeModel { |
60 public: | 54 public: |
61 // Returns the root of the tree. This may or may not be shown in the tree, | 55 // Returns the root of the tree. This may or may not be shown in the tree, |
62 // see SetRootShown for details. | 56 // see SetRootShown for details. |
63 virtual TreeModelNode* GetRoot() = 0; | 57 virtual TreeModelNode* GetRoot() = 0; |
(...skipping 18 matching lines...) Expand all Loading... |
82 } | 76 } |
83 | 77 |
84 // Returns the set of icons for the nodes in the tree. You only need override | 78 // Returns the set of icons for the nodes in the tree. You only need override |
85 // this if you don't want to use the default folder icons. | 79 // this if you don't want to use the default folder icons. |
86 virtual void GetIcons(std::vector<SkBitmap>* icons) {} | 80 virtual void GetIcons(std::vector<SkBitmap>* icons) {} |
87 | 81 |
88 // Returns the index of the icon to use for |node|. Return -1 to use the | 82 // Returns the index of the icon to use for |node|. Return -1 to use the |
89 // default icon. The index is relative to the list of icons returned from | 83 // default icon. The index is relative to the list of icons returned from |
90 // GetIcons. | 84 // GetIcons. |
91 virtual int GetIconIndex(TreeModelNode* node) { return -1; } | 85 virtual int GetIconIndex(TreeModelNode* node) { return -1; } |
92 | |
93 protected: | |
94 ~TreeModel() {} | |
95 }; | 86 }; |
96 | 87 |
97 #endif // APP_TREE_TREE_MODEL_H_ | 88 #endif // APP_TREE_TREE_MODEL_H_ |
OLD | NEW |