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

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

Issue 2800015: GTK: First draft of the unified cut/copy/paste and +/-/Fullscreen menu items. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: estade cleanups Created 10 years, 6 months 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
« no previous file with comments | « app/app_base.gypi ('k') | 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef APP_MENUS_BUTTON_MENU_ITEM_MODEL_H_
6 #define APP_MENUS_BUTTON_MENU_ITEM_MODEL_H_
7
8 #include <vector>
9
10 #include "base/string16.h"
11 #include "third_party/skia/include/core/SkBitmap.h"
12
13 namespace menus {
14
15 // A model representing the rows of buttons that should be inserted in a button
16 // containing menu item.
17 //
18 // TODO(erg): There are still two major pieces missing from this model. It
19 // needs to be able to group buttons together so they all have the same
20 // width. ButtonSides needs to be used to communicate how buttons are squashed
21 // together.
22 class ButtonMenuItemModel {
23 public:
24 // Types of buttons.
25 enum ButtonType {
26 TYPE_SPACE,
27 TYPE_BUTTON
28 };
29
30 // Which sides of the button are visible.
31 enum ButtonSides {
32 SIDE_NONE = 0,
33 SIDE_LEFT = 1 << 0,
34 SIDE_RIGHT = 1 << 1,
35 SIDE_BOTH = SIDE_LEFT | SIDE_RIGHT
36 };
37
38 class Delegate {
39 public:
40 // Some command ids have labels that change over time.
41 virtual bool IsLabelForCommandIdDynamic(int command_id) const {
42 return false;
43 }
44 virtual string16 GetLabelForCommandId(int command_id) const {
45 return string16();
46 }
47
48 // Performs the action associated with the specified command id.
49 virtual void ExecuteCommand(int command_id) = 0;
50 };
51
52 ButtonMenuItemModel(int string_id, ButtonMenuItemModel::Delegate* delegate);
53
54 // Adds a button that will emit |command_id|.
55 void AddItemWithStringId(int command_id, int string_id);
56
57 // Adds a button that has an icon instead of a label.
58 void AddItemWithImage(int command_id, int icon_idr);
59
60 // Adds a small horizontal space.
61 void AddSpace();
62
63 // Returns the number of items for iteration.
64 int GetItemCount() const;
65
66 // Returns what kind of item is at |index|.
67 ButtonType GetTypeAt(int index) const;
68
69 // Changes a position into a command ID.
70 int GetCommandIdAt(int index) const;
71
72 const string16& GetLabelAt(int index) const;
73
74 // If the button at |index| should have an icon instead, returns true and
75 // sets the IDR |icon|.
76 bool GetIconAt(int index, int* icon) const;
77
78 // Called from implementations.
79 void ActivatedCommand(int command_id);
80
81 const string16& label() const { return item_label_; }
82
83 private:
84 // The non-clickable label to the left of the buttons.
85 string16 item_label_;
86
87 struct Item {
88 int command_id;
89 ButtonType type;
90 string16 label;
91 int sides;
92 int icon_idr;
93 };
94 std::vector<Item> items_;
95
96 Delegate* delegate_;
97
98 DISALLOW_COPY_AND_ASSIGN(ButtonMenuItemModel);
99 };
100
101 } // namespace menus
102
103 #endif // APP_MENUS_BUTTON_MENU_ITEM_MODEL_H_
OLDNEW
« no previous file with comments | « app/app_base.gypi ('k') | app/menus/button_menu_item_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698