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

Side by Side Diff: base/popup_menu.h

Issue 624713003: Keep only base/extractor.[cc|h]. (Closed) Base URL: https://chromium.googlesource.com/external/omaha.git@master
Patch Set: Created 6 years, 2 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 | « base/pe_utils_unittest.cc ('k') | base/popup_menu.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 2005-2009 Google Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 // ========================================================================
15
16 #ifndef OMAHA_COMMON_POPUP_MENU_H_
17 #define OMAHA_COMMON_POPUP_MENU_H_
18
19 #include "omaha/base/debug.h"
20 #include "omaha/base/scoped_any.h"
21
22 namespace omaha {
23
24 struct MenuItemDrawStyle {
25 bool is_bold;
26 HICON icon;
27
28 MenuItemDrawStyle() : is_bold(false), icon(NULL) {}
29 };
30
31
32 class PopupMenu {
33 public:
34 PopupMenu();
35 PopupMenu(HINSTANCE inst, const TCHAR* name);
36
37 ~PopupMenu();
38
39 // Load from resource
40 bool LoadFromResource(HINSTANCE inst, const TCHAR* name);
41
42 // Append menu item
43 bool AppendMenuItem(int menu_item_id, const TCHAR* text);
44 bool AppendMenuItem(int menu_item_id,
45 const TCHAR* text,
46 const MenuItemDrawStyle* style);
47
48 // Append separator
49 bool AppendSeparator();
50
51 // Helper function that populates the MENUITEMINFO structure and sets
52 // accelerator keys for OWNERDRAW menu items
53 MENUITEMINFO PrepareMenuItemInfo(int menu_item_id,
54 const TCHAR* text,
55 const MenuItemDrawStyle* style);
56
57 // Insert menu item
58 bool InsertMenuItem(int menu_item_id,
59 int before_item,
60 bool by_pos,
61 const TCHAR* text);
62
63 bool InsertMenuItem(int menu_item_id,
64 int before_item,
65 bool by_pos,
66 const TCHAR* text,
67 const MenuItemDrawStyle* style);
68
69 // Insert separator
70 bool InsertSeparator(int before_item, bool by_pos);
71
72 // Modify a given menu item
73 bool ModifyMenuItem(int menu_item,
74 bool by_pos,
75 const TCHAR* text,
76 const MenuItemDrawStyle* style);
77
78 // Remove menu item
79 bool RemoveMenuItem(int menu_item, bool by_pos);
80
81 // Enable menu item
82 bool EnableMenuItem(int menu_item, bool by_pos, bool enabled);
83
84 // Get menu state
85 bool GetMenuState(int menu_item, bool by_pos, int* menu_state);
86
87 // Exists a menu item
88 bool ExistsMenuItem(int menu_item_id);
89
90 // Get menu pos from ID
91 int GetMenuPosFromID(int id);
92
93 // Attach to the window
94 void AttachToWindow(HWND wnd) {
95 ASSERT1(wnd);
96 wnd_ = wnd;
97 }
98
99 // Redraw menu
100 bool Redraw();
101
102 // Track menu
103 bool Track();
104
105 // Handle WM_MEASUREITEM message
106 bool OnMeasureItem(MEASUREITEMSTRUCT* mi);
107
108 // Handle WM_MDRAWITEM message
109 bool OnDrawItem(DRAWITEMSTRUCT* di);
110
111 // Handle WM_MENUCHAR message
112 int OnMenuChar(TCHAR key);
113
114 private:
115 // Get bold font
116 HFONT GetBoldFont();
117
118 // Draw the text
119 bool DrawText(const CString& text,
120 DRAWITEMSTRUCT* di,
121 int fg_color_idx,
122 int bg_color_idx);
123
124 HWND wnd_; // HWND associated with this menu
125 scoped_hmenu menu_; // HMENU associated with this menu
126
127 // Bold font used in owner draw menu-item
128 scoped_hfont bold_font_;
129
130 // Accelerator key used in owner draw menu-item
131 CSimpleMap<TCHAR, int> accelerator_keys_;
132
133 DISALLOW_EVIL_CONSTRUCTORS(PopupMenu);
134 };
135
136 } // namespace omaha
137
138 #endif // OMAHA_COMMON_POPUP_MENU_H_
139
OLDNEW
« no previous file with comments | « base/pe_utils_unittest.cc ('k') | base/popup_menu.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698