Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Side by Side Diff: app/menus/button_menu_item_model.h

Issue 5697005: Change SimpleMenuModel on OSX to support dynamic icons (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update after merge Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | app/menus/button_menu_item_model.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 APP_MENUS_BUTTON_MENU_ITEM_MODEL_H_ 5 #ifndef APP_MENUS_BUTTON_MENU_ITEM_MODEL_H_
6 #define APP_MENUS_BUTTON_MENU_ITEM_MODEL_H_ 6 #define APP_MENUS_BUTTON_MENU_ITEM_MODEL_H_
7 #pragma once 7 #pragma once
8 8
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/string16.h" 11 #include "base/string16.h"
12 12
13 namespace menus { 13 namespace menus {
14 14
15 // A model representing the rows of buttons that should be inserted in a button 15 // A model representing the rows of buttons that should be inserted in a button
16 // containing menu item. 16 // containing menu item.
17 class ButtonMenuItemModel { 17 class ButtonMenuItemModel {
18 public: 18 public:
19 // Types of buttons. 19 // Types of buttons.
20 enum ButtonType { 20 enum ButtonType {
21 TYPE_SPACE, 21 TYPE_SPACE,
22 TYPE_BUTTON, 22 TYPE_BUTTON,
23 TYPE_BUTTON_LABEL 23 TYPE_BUTTON_LABEL
24 }; 24 };
25 25
26 class Delegate { 26 class Delegate {
27 public: 27 public:
28 // Some command ids have labels that change over time. 28 // Some command ids have labels that change over time.
29 virtual bool IsLabelForCommandIdDynamic(int command_id) const; 29 virtual bool IsItemForCommandIdDynamic(int command_id) const;
30 virtual string16 GetLabelForCommandId(int command_id) const; 30 virtual string16 GetLabelForCommandId(int command_id) const;
31 31
32 // Performs the action associated with the specified command id. 32 // Performs the action associated with the specified command id.
33 virtual void ExecuteCommand(int command_id) = 0; 33 virtual void ExecuteCommand(int command_id) = 0;
34 virtual bool IsCommandIdEnabled(int command_id) const; 34 virtual bool IsCommandIdEnabled(int command_id) const;
35 virtual bool DoesCommandIdDismissMenu(int command_id) const; 35 virtual bool DoesCommandIdDismissMenu(int command_id) const;
36 36
37 protected: 37 protected:
38 virtual ~Delegate() {} 38 virtual ~Delegate() {}
39 }; 39 };
40 40
41 ButtonMenuItemModel(int string_id, ButtonMenuItemModel::Delegate* delegate); 41 ButtonMenuItemModel(int string_id, ButtonMenuItemModel::Delegate* delegate);
42 ~ButtonMenuItemModel(); 42 ~ButtonMenuItemModel();
43 43
44 // Adds a button that will emit |command_id|. All buttons created through 44 // Adds a button that will emit |command_id|. All buttons created through
45 // this method will have the same size, based on the largest button. 45 // this method will have the same size, based on the largest button.
46 void AddGroupItemWithStringId(int command_id, int string_id); 46 void AddGroupItemWithStringId(int command_id, int string_id);
47 47
48 // Adds a button that has an icon instead of a label. 48 // Adds a button that has an icon instead of a label.
49 void AddItemWithImage(int command_id, int icon_idr); 49 void AddItemWithImage(int command_id, int icon_idr);
50 50
51 // Adds a non-clickable button with a desensitized label that doesn't do 51 // Adds a non-clickable button with a desensitized label that doesn't do
52 // anything. Usually combined with IsLabelForCommandIdDynamic() to add 52 // anything. Usually combined with IsItemForCommandIdDynamic() to add
53 // information. 53 // information.
54 void AddButtonLabel(int command_id, int string_id); 54 void AddButtonLabel(int command_id, int string_id);
55 55
56 // Adds a small horizontal space. 56 // Adds a small horizontal space.
57 void AddSpace(); 57 void AddSpace();
58 58
59 // Returns the number of items for iteration. 59 // Returns the number of items for iteration.
60 int GetItemCount() const; 60 int GetItemCount() const;
61 61
62 // Returns what kind of item is at |index|. 62 // Returns what kind of item is at |index|.
63 ButtonType GetTypeAt(int index) const; 63 ButtonType GetTypeAt(int index) const;
64 64
65 // Changes a position into a command ID. 65 // Changes a position into a command ID.
66 int GetCommandIdAt(int index) const; 66 int GetCommandIdAt(int index) const;
67 67
68 // Whether the label for item |index| changes. 68 // Whether the label for item |index| changes.
69 bool IsLabelDynamicAt(int index) const; 69 bool IsItemDynamicAt(int index) const;
70 70
71 // Returns the current label value for the button at |index|. 71 // Returns the current label value for the button at |index|.
72 string16 GetLabelAt(int index) const; 72 string16 GetLabelAt(int index) const;
73 73
74 // If the button at |index| should have an icon instead, returns true and 74 // If the button at |index| should have an icon instead, returns true and
75 // sets the IDR |icon|. 75 // sets the IDR |icon|.
76 bool GetIconAt(int index, int* icon) const; 76 bool GetIconAt(int index, int* icon) const;
77 77
78 // If the button at |index| should have its size equalized along with all 78 // If the button at |index| should have its size equalized along with all
79 // other items that have their PartOfGroup bit set. 79 // other items that have their PartOfGroup bit set.
(...skipping 24 matching lines...) Expand all
104 std::vector<Item> items_; 104 std::vector<Item> items_;
105 105
106 Delegate* delegate_; 106 Delegate* delegate_;
107 107
108 DISALLOW_COPY_AND_ASSIGN(ButtonMenuItemModel); 108 DISALLOW_COPY_AND_ASSIGN(ButtonMenuItemModel);
109 }; 109 };
110 110
111 } // namespace menus 111 } // namespace menus
112 112
113 #endif // APP_MENUS_BUTTON_MENU_ITEM_MODEL_H_ 113 #endif // APP_MENUS_BUTTON_MENU_ITEM_MODEL_H_
OLDNEW
« no previous file with comments | « no previous file | app/menus/button_menu_item_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698