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

Side by Side Diff: views/controls/button/native_button_win.cc

Issue 114059: Refactors HWNDView, NativeViewHostGtk and NativeViewHost so that they match t... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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 | Annotate | Revision Log
« no previous file with comments | « views/controls/button/native_button_gtk.cc ('k') | views/controls/hwnd_view.h » ('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) 2009 The Chromium Authors. All rights reserved. Use of this 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in the 2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file. 3 // LICENSE file.
4 4
5 #include "views/controls/button/native_button_win.h" 5 #include "views/controls/button/native_button_win.h"
6 6
7 #include <commctrl.h> 7 #include <commctrl.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "views/controls/button/checkbox.h" 10 #include "views/controls/button/checkbox.h"
11 #include "views/controls/button/native_button.h" 11 #include "views/controls/button/native_button.h"
12 #include "views/controls/button/radio_button.h" 12 #include "views/controls/button/radio_button.h"
13 #include "views/widget/widget.h" 13 #include "views/widget/widget.h"
14 14
15 namespace views { 15 namespace views {
16 16
17 //////////////////////////////////////////////////////////////////////////////// 17 ////////////////////////////////////////////////////////////////////////////////
18 // NativeButtonWin, public: 18 // NativeButtonWin, public:
19 19
20 NativeButtonWin::NativeButtonWin(NativeButton* native_button) 20 NativeButtonWin::NativeButtonWin(NativeButton* native_button)
21 : NativeControlWin(), 21 : NativeControlWin(),
22 native_button_(native_button) { 22 native_button_(native_button) {
23 // Associates the actual HWND with the native_button so the native_button is 23 // Associates the actual HWND with the native_button so the native_button is
24 // the one considered as having the focus (not the wrapper) when the HWND is 24 // the one considered as having the focus (not the wrapper) when the HWND is
25 // focused directly (with a click for example). 25 // focused directly (with a click for example).
26 SetAssociatedFocusView(native_button); 26 set_focus_view(native_button);
27 } 27 }
28 28
29 NativeButtonWin::~NativeButtonWin() { 29 NativeButtonWin::~NativeButtonWin() {
30 } 30 }
31 31
32 //////////////////////////////////////////////////////////////////////////////// 32 ////////////////////////////////////////////////////////////////////////////////
33 // NativeButtonWin, NativeButtonWrapper implementation: 33 // NativeButtonWin, NativeButtonWrapper implementation:
34 34
35 void NativeButtonWin::UpdateLabel() { 35 void NativeButtonWin::UpdateLabel() {
36 SetWindowText(GetHWND(), native_button_->label().c_str()); 36 SetWindowText(native_view(), native_button_->label().c_str());
37 } 37 }
38 38
39 void NativeButtonWin::UpdateFont() { 39 void NativeButtonWin::UpdateFont() {
40 SendMessage(GetHWND(), WM_SETFONT, 40 SendMessage(native_view(), WM_SETFONT,
41 reinterpret_cast<WPARAM>(native_button_->font().hfont()), 41 reinterpret_cast<WPARAM>(native_button_->font().hfont()),
42 FALSE); 42 FALSE);
43 } 43 }
44 44
45 void NativeButtonWin::UpdateEnabled() { 45 void NativeButtonWin::UpdateEnabled() {
46 SetEnabled(native_button_->IsEnabled()); 46 SetEnabled(native_button_->IsEnabled());
47 } 47 }
48 48
49 void NativeButtonWin::UpdateDefault() { 49 void NativeButtonWin::UpdateDefault() {
50 if (!IsCheckbox()) { 50 if (!IsCheckbox()) {
51 SendMessage(GetHWND(), BM_SETSTYLE, 51 SendMessage(native_view(), BM_SETSTYLE,
52 native_button_->is_default() ? BS_DEFPUSHBUTTON : BS_PUSHBUTTON, 52 native_button_->is_default() ? BS_DEFPUSHBUTTON : BS_PUSHBUTTON,
53 true); 53 true);
54 } 54 }
55 } 55 }
56 56
57 View* NativeButtonWin::GetView() { 57 View* NativeButtonWin::GetView() {
58 return this; 58 return this;
59 } 59 }
60 60
61 void NativeButtonWin::SetFocus() { 61 void NativeButtonWin::SetFocus() {
62 // Focus the associated HWND. 62 // Focus the associated HWND.
63 Focus(); 63 Focus();
64 } 64 }
65 65
66 //////////////////////////////////////////////////////////////////////////////// 66 ////////////////////////////////////////////////////////////////////////////////
67 // NativeButtonWin, View overrides: 67 // NativeButtonWin, View overrides:
68 68
69 gfx::Size NativeButtonWin::GetPreferredSize() { 69 gfx::Size NativeButtonWin::GetPreferredSize() {
70 SIZE sz = {0}; 70 SIZE sz = {0};
71 SendMessage(GetHWND(), BCM_GETIDEALSIZE, 0, reinterpret_cast<LPARAM>(&sz)); 71 SendMessage(native_view(), BCM_GETIDEALSIZE, 0, reinterpret_cast<LPARAM>(&sz)) ;
72 72
73 return gfx::Size(sz.cx, sz.cy); 73 return gfx::Size(sz.cx, sz.cy);
74 } 74 }
75 75
76 //////////////////////////////////////////////////////////////////////////////// 76 ////////////////////////////////////////////////////////////////////////////////
77 // NativeButtonWin, NativeControlWin overrides: 77 // NativeButtonWin, NativeControlWin overrides:
78 78
79 bool NativeButtonWin::ProcessMessage(UINT message, WPARAM w_param, 79 bool NativeButtonWin::ProcessMessage(UINT message, WPARAM w_param,
80 LPARAM l_param, LRESULT* result) { 80 LPARAM l_param, LRESULT* result) {
81 if (message == WM_COMMAND && HIWORD(w_param) == BN_CLICKED) { 81 if (message == WM_COMMAND && HIWORD(w_param) == BN_CLICKED) {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 // NativeCheckboxWin, View overrides: 135 // NativeCheckboxWin, View overrides:
136 136
137 gfx::Size NativeCheckboxWin::GetPreferredSize() { 137 gfx::Size NativeCheckboxWin::GetPreferredSize() {
138 return gfx::Size(kCheckboxSize, kCheckboxSize); 138 return gfx::Size(kCheckboxSize, kCheckboxSize);
139 } 139 }
140 140
141 //////////////////////////////////////////////////////////////////////////////// 141 ////////////////////////////////////////////////////////////////////////////////
142 // NativeCheckboxWin, NativeButtonWrapper implementation: 142 // NativeCheckboxWin, NativeButtonWrapper implementation:
143 143
144 void NativeCheckboxWin::UpdateChecked() { 144 void NativeCheckboxWin::UpdateChecked() {
145 SendMessage(GetHWND(), BM_SETCHECK, 145 SendMessage(native_view(), BM_SETCHECK,
146 checkbox_->checked() ? BST_CHECKED : BST_UNCHECKED, 0); 146 checkbox_->checked() ? BST_CHECKED : BST_UNCHECKED, 0);
147 } 147 }
148 148
149 void NativeCheckboxWin::SetPushed(bool pushed) { 149 void NativeCheckboxWin::SetPushed(bool pushed) {
150 SendMessage(GetHWND(), BM_SETSTATE, pushed, 0); 150 SendMessage(native_view(), BM_SETSTATE, pushed, 0);
151 } 151 }
152 152
153 bool NativeCheckboxWin::OnKeyDown(int vkey) { 153 bool NativeCheckboxWin::OnKeyDown(int vkey) {
154 // Override the NativeButtonWin behavior which triggers the button on enter 154 // Override the NativeButtonWin behavior which triggers the button on enter
155 // key presses when focused. 155 // key presses when focused.
156 return false; 156 return false;
157 } 157 }
158 158
159 //////////////////////////////////////////////////////////////////////////////// 159 ////////////////////////////////////////////////////////////////////////////////
160 // NativeCheckboxWin, NativeButtonWin overrides: 160 // NativeCheckboxWin, NativeButtonWin overrides:
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 return new NativeCheckboxWin(checkbox); 227 return new NativeCheckboxWin(checkbox);
228 } 228 }
229 229
230 // static 230 // static
231 NativeButtonWrapper* NativeButtonWrapper::CreateRadioButtonWrapper( 231 NativeButtonWrapper* NativeButtonWrapper::CreateRadioButtonWrapper(
232 RadioButton* radio_button) { 232 RadioButton* radio_button) {
233 return new NativeRadioButtonWin(radio_button); 233 return new NativeRadioButtonWin(radio_button);
234 } 234 }
235 235
236 } // namespace views 236 } // namespace views
OLDNEW
« no previous file with comments | « views/controls/button/native_button_gtk.cc ('k') | views/controls/hwnd_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698