OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 UI_BASE_MODELS_MENU_MODEL_H_ | 5 #ifndef UI_BASE_MODELS_MENU_MODEL_H_ |
6 #define UI_BASE_MODELS_MENU_MODEL_H_ | 6 #define UI_BASE_MODELS_MENU_MODEL_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/string16.h" | 10 #include "base/string16.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 | 37 |
38 virtual ~MenuModel() {} | 38 virtual ~MenuModel() {} |
39 | 39 |
40 // Returns true if any of the items within the model have icons. Not all | 40 // Returns true if any of the items within the model have icons. Not all |
41 // platforms support icons in menus natively and so this is a hint for | 41 // platforms support icons in menus natively and so this is a hint for |
42 // triggering a custom rendering mode. | 42 // triggering a custom rendering mode. |
43 virtual bool HasIcons() const = 0; | 43 virtual bool HasIcons() const = 0; |
44 | 44 |
45 // Returns the index of the first item. This is 0 for most menus except the | 45 // Returns the index of the first item. This is 0 for most menus except the |
46 // system menu on Windows. |native_menu| is the menu to locate the start index | 46 // system menu on Windows. |native_menu| is the menu to locate the start index |
47 // within. It is guaranteed to be reset to a clean default state. | 47 // within. It is guaranteed to be reset to a clean default state. Some |
| 48 // callers of this method may pass NULL for native_menu. |
48 // IMPORTANT: If the model implementation returns something _other_ than 0 | 49 // IMPORTANT: If the model implementation returns something _other_ than 0 |
49 // here, it must offset the values for |index| it passes to the | 50 // here, it must offset the values for |index| it passes to the |
50 // methods below by this number - this is NOT done automatically! | 51 // methods below by this number - this is NOT done automatically! |
51 virtual int GetFirstItemIndex(gfx::NativeMenu native_menu) const; | 52 virtual int GetFirstItemIndex(gfx::NativeMenu native_menu) const; |
52 | 53 |
53 // Returns the number of items in the menu. | 54 // Returns the number of items in the menu. |
54 virtual int GetItemCount() const = 0; | 55 virtual int GetItemCount() const = 0; |
55 | 56 |
56 // Returns the type of item at the specified index. | 57 // Returns the type of item at the specified index. |
57 virtual ItemType GetTypeAt(int index) const = 0; | 58 virtual ItemType GetTypeAt(int index) const = 0; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 // Retrieves the model and index that contains a specific command id. Returns | 124 // Retrieves the model and index that contains a specific command id. Returns |
124 // true if an item with the specified command id is found. |model| is inout, | 125 // true if an item with the specified command id is found. |model| is inout, |
125 // and specifies the model to start searching from. | 126 // and specifies the model to start searching from. |
126 static bool GetModelAndIndexForCommandId(int command_id, MenuModel** model, | 127 static bool GetModelAndIndexForCommandId(int command_id, MenuModel** model, |
127 int* index); | 128 int* index); |
128 }; | 129 }; |
129 | 130 |
130 } // namespace ui | 131 } // namespace ui |
131 | 132 |
132 #endif // UI_BASE_MODELS_MENU_MODEL_H_ | 133 #endif // UI_BASE_MODELS_MENU_MODEL_H_ |
OLD | NEW |