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

Side by Side Diff: views/controls/native_control.cc

Issue 6976048: views: Add OnEnabledChanged() method to View class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix win, move OnEnabledChanged to protected section, add comment Created 9 years, 7 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/native_control.h ('k') | views/controls/native_control_gtk.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) 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 #include "views/controls/native_control.h" 5 #include "views/controls/native_control.h"
6 6
7 #include <atlbase.h> 7 #include <atlbase.h>
8 #include <atlapp.h> 8 #include <atlapp.h>
9 #include <atlcrack.h> 9 #include <atlcrack.h>
10 #include <atlframe.h> 10 #include <atlframe.h>
11 #include <atlmisc.h> 11 #include <atlmisc.h>
12 12
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "ui/base/accessibility/accessibility_types.h" 15 #include "ui/base/accessibility/accessibility_types.h"
16 #include "ui/base/keycodes/keyboard_code_conversion_win.h"
16 #include "ui/base/keycodes/keyboard_codes.h" 17 #include "ui/base/keycodes/keyboard_codes.h"
17 #include "ui/base/keycodes/keyboard_code_conversion_win.h"
18 #include "ui/base/l10n/l10n_util_win.h" 18 #include "ui/base/l10n/l10n_util_win.h"
19 #include "ui/base/view_prop.h" 19 #include "ui/base/view_prop.h"
20 #include "ui/base/win/hwnd_util.h" 20 #include "ui/base/win/hwnd_util.h"
21 #include "views/background.h" 21 #include "views/background.h"
22 #include "views/border.h" 22 #include "views/border.h"
23 #include "views/controls/native/native_view_host.h" 23 #include "views/controls/native/native_view_host.h"
24 #include "views/focus/focus_manager.h" 24 #include "views/focus/focus_manager.h"
25 #include "views/widget/widget.h" 25 #include "views/widget/widget.h"
26 26
27 using ui::ViewProp; 27 using ui::ViewProp;
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 171
172 DISALLOW_COPY_AND_ASSIGN(NativeControlContainer); 172 DISALLOW_COPY_AND_ASSIGN(NativeControlContainer);
173 }; 173 };
174 174
175 NativeControl::NativeControl() : hwnd_view_(NULL), 175 NativeControl::NativeControl() : hwnd_view_(NULL),
176 container_(NULL), 176 container_(NULL),
177 fixed_width_(-1), 177 fixed_width_(-1),
178 horizontal_alignment_(CENTER), 178 horizontal_alignment_(CENTER),
179 fixed_height_(-1), 179 fixed_height_(-1),
180 vertical_alignment_(CENTER) { 180 vertical_alignment_(CENTER) {
181 enabled_ = true; 181 enabled_ = true;
tfarina 2011/05/27 17:10:48 I've removed this. View already initialize this to
182 focusable_ = true; 182 focusable_ = true;
183 } 183 }
184 184
185 NativeControl::~NativeControl() { 185 NativeControl::~NativeControl() {
186 if (container_) { 186 if (container_) {
187 container_->ResetParent(); 187 container_->ResetParent();
188 ::DestroyWindow(*container_); 188 ::DestroyWindow(*container_);
189 } 189 }
190 } 190 }
191 191
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 if (f != IsVisible()) { 305 if (f != IsVisible()) {
306 View::SetVisible(f); 306 View::SetVisible(f);
307 if (!f && container_) { 307 if (!f && container_) {
308 ::DestroyWindow(*container_); 308 ::DestroyWindow(*container_);
309 } else if (f && !container_) { 309 } else if (f && !container_) {
310 ValidateNativeControl(); 310 ValidateNativeControl();
311 } 311 }
312 } 312 }
313 } 313 }
314 314
315 void NativeControl::SetEnabled(bool enabled) { 315 void NativeControl::OnEnabledChanged() {
316 if (enabled_ != enabled) { 316 View::OnEnabledChanged();
317 View::SetEnabled(enabled); 317 if (GetNativeControlHWND())
318 if (GetNativeControlHWND()) { 318 EnableWindow(GetNativeControlHWND(), View::IsEnabled());
319 EnableWindow(GetNativeControlHWND(), enabled_);
320 }
321 }
322 } 319 }
323 320
324 void NativeControl::OnPaint(gfx::Canvas* canvas) { 321 void NativeControl::OnPaint(gfx::Canvas* canvas) {
325 } 322 }
326 323
327 void NativeControl::VisibilityChanged(View* starting_from, bool is_visible) { 324 void NativeControl::VisibilityChanged(View* starting_from, bool is_visible) {
328 SetVisible(is_visible); 325 SetVisible(is_visible);
329 } 326 }
330 327
331 void NativeControl::SetFixedWidth(int width, Alignment alignment) { 328 void NativeControl::SetFixedWidth(int width, Alignment alignment) {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 } else if (message == WM_DESTROY) { 384 } else if (message == WM_DESTROY) {
388 ui::SetWindowProc(window, reinterpret_cast<WNDPROC>(original_handler)); 385 ui::SetWindowProc(window, reinterpret_cast<WNDPROC>(original_handler));
389 native_control->container_->prop_.reset(); 386 native_control->container_->prop_.reset();
390 } 387 }
391 388
392 return CallWindowProc(reinterpret_cast<WNDPROC>(original_handler), window, 389 return CallWindowProc(reinterpret_cast<WNDPROC>(original_handler), window,
393 message, w_param, l_param); 390 message, w_param, l_param);
394 } 391 }
395 392
396 } // namespace views 393 } // namespace views
OLDNEW
« no previous file with comments | « views/controls/native_control.h ('k') | views/controls/native_control_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698