OLD | NEW |
1 // Copyright (c) 2009 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 APP_TREE_MODEL_H_ | 5 #ifndef APP_TREE_MODEL_H_ |
6 #define APP_TREE_MODEL_H_ | 6 #define APP_TREE_MODEL_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/string16.h" |
13 | 14 |
14 class SkBitmap; | 15 class SkBitmap; |
15 | 16 |
16 class TreeModel; | 17 class TreeModel; |
17 | 18 |
18 // TreeModelNode -------------------------------------------------------------- | 19 // TreeModelNode -------------------------------------------------------------- |
19 | 20 |
20 // Type of class returned from the model. | 21 // Type of class returned from the model. |
21 class TreeModelNode { | 22 class TreeModelNode { |
22 public: | 23 public: |
23 // Returns the title for the node. | 24 // Returns the title for the node. |
| 25 // TODO(viettrungluu): remove wstring version and rename string16 version. |
24 virtual std::wstring GetTitle() const = 0; | 26 virtual std::wstring GetTitle() const = 0; |
| 27 virtual const string16& GetTitleAsString16() const = 0; |
25 | 28 |
26 protected: | 29 protected: |
27 virtual ~TreeModelNode() {} | 30 virtual ~TreeModelNode() {} |
28 }; | 31 }; |
29 | 32 |
30 // Observer for the TreeModel. Notified of significant events to the model. | 33 // Observer for the TreeModel. Notified of significant events to the model. |
31 class TreeModelObserver { | 34 class TreeModelObserver { |
32 public: | 35 public: |
33 // Notification that nodes were added to the specified parent. | 36 // Notification that nodes were added to the specified parent. |
34 virtual void TreeNodesAdded(TreeModel* model, | 37 virtual void TreeNodesAdded(TreeModel* model, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 | 75 |
73 // Adds an observer of the model. | 76 // Adds an observer of the model. |
74 virtual void AddObserver(TreeModelObserver* observer) = 0; | 77 virtual void AddObserver(TreeModelObserver* observer) = 0; |
75 | 78 |
76 // Removes an observer of the model. | 79 // Removes an observer of the model. |
77 virtual void RemoveObserver(TreeModelObserver* observer) = 0; | 80 virtual void RemoveObserver(TreeModelObserver* observer) = 0; |
78 | 81 |
79 // Sets the title of the specified node. | 82 // Sets the title of the specified node. |
80 // This is only invoked if the node is editable and the user edits a node. | 83 // This is only invoked if the node is editable and the user edits a node. |
81 virtual void SetTitle(TreeModelNode* node, | 84 virtual void SetTitle(TreeModelNode* node, |
82 const std::wstring& title) { | 85 const string16& title) { |
83 NOTREACHED(); | 86 NOTREACHED(); |
84 } | 87 } |
85 | 88 |
86 // Returns the set of icons for the nodes in the tree. You only need override | 89 // Returns the set of icons for the nodes in the tree. You only need override |
87 // this if you don't want to use the default folder icons. | 90 // this if you don't want to use the default folder icons. |
88 virtual void GetIcons(std::vector<SkBitmap>* icons) {} | 91 virtual void GetIcons(std::vector<SkBitmap>* icons) {} |
89 | 92 |
90 // Returns the index of the icon to use for |node|. Return -1 to use the | 93 // Returns the index of the icon to use for |node|. Return -1 to use the |
91 // default icon. The index is relative to the list of icons returned from | 94 // default icon. The index is relative to the list of icons returned from |
92 // GetIcons. | 95 // GetIcons. |
93 virtual int GetIconIndex(TreeModelNode* node) { return -1; } | 96 virtual int GetIconIndex(TreeModelNode* node) { return -1; } |
94 | 97 |
95 protected: | 98 protected: |
96 virtual ~TreeModel() {} | 99 virtual ~TreeModel() {} |
97 }; | 100 }; |
98 | 101 |
99 #endif // APP_TREE_MODEL_H_ | 102 #endif // APP_TREE_MODEL_H_ |
OLD | NEW |