blob: ed1983629130dce60baa533179f1a4f561b7169c [file] [log] [blame]
[email protected]f8617192010-07-05 07:57:101// 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.
[email protected]420949f2009-03-18 20:40:344
[email protected]2362e4f2009-05-08 00:34:055#ifndef VIEWS_CONTROLS_BUTTON_NATIVE_BUTTON_WIN_H_
6#define VIEWS_CONTROLS_BUTTON_NATIVE_BUTTON_WIN_H_
[email protected]32b76ef2010-07-26 23:08:247#pragma once
[email protected]420949f2009-03-18 20:40:348
[email protected]2362e4f2009-05-08 00:34:059#include "views/controls/native_control_win.h"
10#include "views/controls/button/native_button_wrapper.h"
[email protected]420949f2009-03-18 20:40:3411
12namespace views {
13
14// A View that hosts a native Windows button.
15class NativeButtonWin : public NativeControlWin,
16 public NativeButtonWrapper {
17 public:
[email protected]a8111ce72009-03-23 21:55:5218 explicit NativeButtonWin(NativeButton* native_button);
[email protected]420949f2009-03-18 20:40:3419 virtual ~NativeButtonWin();
20
21 // Overridden from NativeButtonWrapper:
[email protected]ff9b986c2009-03-19 21:18:4422 virtual void UpdateLabel();
23 virtual void UpdateFont();
[email protected]0e6fe112009-03-25 18:27:2624 virtual void UpdateEnabled();
[email protected]ff9b986c2009-03-19 21:18:4425 virtual void UpdateDefault();
[email protected]983592e2010-09-30 18:44:5326 virtual void UpdateAccessibleName();
[email protected]420949f2009-03-18 20:40:3427 virtual View* GetView();
[email protected]3a21be62009-03-25 00:11:4428 virtual void SetFocus();
[email protected]bbcd29e2009-07-24 00:05:0629 virtual bool UsesNativeLabel() const;
[email protected]d0260a92009-09-14 17:34:5130 virtual bool UsesNativeRadioButtonGroup() const;
[email protected]7805c5b92009-06-09 17:07:0531 virtual gfx::NativeView GetTestingHandle() const;
[email protected]420949f2009-03-18 20:40:3432
33 // Overridden from View:
34 virtual gfx::Size GetPreferredSize();
35
36 // Overridden from NativeControlWin:
[email protected]474fd5d2009-03-27 18:07:2537 virtual bool ProcessMessage(UINT message,
38 WPARAM w_param,
39 LPARAM l_param,
40 LRESULT* result);
[email protected]420949f2009-03-18 20:40:3441 virtual bool OnKeyDown(int vkey);
42
43 protected:
[email protected]420949f2009-03-18 20:40:3444 virtual void CreateNativeControl();
45 virtual void NativeControlCreated(HWND control_hwnd);
46
[email protected]37dbc032009-03-20 23:46:4047 // Returns true if this button is actually a checkbox or radio button.
48 virtual bool IsCheckbox() const { return false; }
49
[email protected]420949f2009-03-18 20:40:3450 private:
[email protected]ff9b986c2009-03-19 21:18:4451 // The NativeButton we are bound to.
[email protected]a8111ce72009-03-23 21:55:5252 NativeButton* native_button_;
[email protected]420949f2009-03-18 20:40:3453
[email protected]f8617192010-07-05 07:57:1054 // It's expensive to find the size of a button on windows, so we cache it.
55 mutable gfx::Size button_size_;
56 mutable bool button_size_valid_;
57
[email protected]420949f2009-03-18 20:40:3458 DISALLOW_COPY_AND_ASSIGN(NativeButtonWin);
59};
60
61// A View that hosts a native Windows checkbox.
62class NativeCheckboxWin : public NativeButtonWin {
63 public:
[email protected]a8111ce72009-03-23 21:55:5264 explicit NativeCheckboxWin(Checkbox* native_button);
[email protected]420949f2009-03-18 20:40:3465 virtual ~NativeCheckboxWin();
66
[email protected]37dbc032009-03-20 23:46:4067 // Overridden from View:
68 virtual gfx::Size GetPreferredSize();
69
[email protected]420949f2009-03-18 20:40:3470 // Overridden from NativeButtonWrapper:
[email protected]ff9b986c2009-03-19 21:18:4471 virtual void UpdateChecked();
[email protected]37dbc032009-03-20 23:46:4072 virtual void SetPushed(bool pushed);
[email protected]18305de2009-03-27 17:52:0673 virtual bool OnKeyDown(int vkey);
[email protected]bbcd29e2009-07-24 00:05:0674 virtual bool UsesNativeLabel() const;
[email protected]420949f2009-03-18 20:40:3475
76 // Overridden from NativeControlWin:
[email protected]474fd5d2009-03-27 18:07:2577 virtual bool ProcessMessage(UINT message,
78 WPARAM w_param,
79 LPARAM l_param,
80 LRESULT* result);
[email protected]420949f2009-03-18 20:40:3481
82 protected:
83 virtual void CreateNativeControl();
84 virtual void NativeControlCreated(HWND control_hwnd);
[email protected]37dbc032009-03-20 23:46:4085 virtual bool IsCheckbox() const { return true; }
[email protected]420949f2009-03-18 20:40:3486
[email protected]b2b26af2009-04-24 18:48:4487 // Returns true if this button is actually a radio button.
88 virtual bool IsRadioButton() const { return false; }
89
[email protected]420949f2009-03-18 20:40:3490 private:
[email protected]ff9b986c2009-03-19 21:18:4491 // The Checkbox we are bound to.
[email protected]a8111ce72009-03-23 21:55:5292 Checkbox* checkbox_;
[email protected]420949f2009-03-18 20:40:3493
94 DISALLOW_COPY_AND_ASSIGN(NativeCheckboxWin);
95};
96
97// A View that hosts a native Windows radio button.
98class NativeRadioButtonWin : public NativeCheckboxWin {
99 public:
[email protected]a8111ce72009-03-23 21:55:52100 explicit NativeRadioButtonWin(RadioButton* radio_button);
[email protected]420949f2009-03-18 20:40:34101 virtual ~NativeRadioButtonWin();
102
103 protected:
104 // Overridden from NativeCheckboxWin:
105 virtual void CreateNativeControl();
[email protected]b2b26af2009-04-24 18:48:44106 virtual bool IsRadioButton() const { return true; }
[email protected]420949f2009-03-18 20:40:34107
108 private:
109 DISALLOW_COPY_AND_ASSIGN(NativeRadioButtonWin);
110};
[email protected]37dbc032009-03-20 23:46:40111
[email protected]420949f2009-03-18 20:40:34112} // namespace views
113
[email protected]2362e4f2009-05-08 00:34:05114#endif // #ifndef VIEWS_CONTROLS_BUTTON_NATIVE_BUTTON_WIN_H_