[email protected] | f861719 | 2010-07-05 07:57:10 | [diff] [blame] | 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. | ||||
[email protected] | 420949f | 2009-03-18 20:40:34 | [diff] [blame] | 4 | |
[email protected] | 2362e4f | 2009-05-08 00:34:05 | [diff] [blame] | 5 | #ifndef VIEWS_CONTROLS_BUTTON_NATIVE_BUTTON_WIN_H_ |
6 | #define VIEWS_CONTROLS_BUTTON_NATIVE_BUTTON_WIN_H_ | ||||
[email protected] | 32b76ef | 2010-07-26 23:08:24 | [diff] [blame] | 7 | #pragma once |
[email protected] | 420949f | 2009-03-18 20:40:34 | [diff] [blame] | 8 | |
[email protected] | 2362e4f | 2009-05-08 00:34:05 | [diff] [blame] | 9 | #include "views/controls/native_control_win.h" |
10 | #include "views/controls/button/native_button_wrapper.h" | ||||
[email protected] | 420949f | 2009-03-18 20:40:34 | [diff] [blame] | 11 | |
12 | namespace views { | ||||
13 | |||||
14 | // A View that hosts a native Windows button. | ||||
15 | class NativeButtonWin : public NativeControlWin, | ||||
16 | public NativeButtonWrapper { | ||||
17 | public: | ||||
[email protected] | a8111ce7 | 2009-03-23 21:55:52 | [diff] [blame] | 18 | explicit NativeButtonWin(NativeButton* native_button); |
[email protected] | 420949f | 2009-03-18 20:40:34 | [diff] [blame] | 19 | virtual ~NativeButtonWin(); |
20 | |||||
21 | // Overridden from NativeButtonWrapper: | ||||
[email protected] | ff9b986c | 2009-03-19 21:18:44 | [diff] [blame] | 22 | virtual void UpdateLabel(); |
23 | virtual void UpdateFont(); | ||||
[email protected] | 0e6fe11 | 2009-03-25 18:27:26 | [diff] [blame] | 24 | virtual void UpdateEnabled(); |
[email protected] | ff9b986c | 2009-03-19 21:18:44 | [diff] [blame] | 25 | virtual void UpdateDefault(); |
[email protected] | 983592e | 2010-09-30 18:44:53 | [diff] [blame^] | 26 | virtual void UpdateAccessibleName(); |
[email protected] | 420949f | 2009-03-18 20:40:34 | [diff] [blame] | 27 | virtual View* GetView(); |
[email protected] | 3a21be6 | 2009-03-25 00:11:44 | [diff] [blame] | 28 | virtual void SetFocus(); |
[email protected] | bbcd29e | 2009-07-24 00:05:06 | [diff] [blame] | 29 | virtual bool UsesNativeLabel() const; |
[email protected] | d0260a9 | 2009-09-14 17:34:51 | [diff] [blame] | 30 | virtual bool UsesNativeRadioButtonGroup() const; |
[email protected] | 7805c5b9 | 2009-06-09 17:07:05 | [diff] [blame] | 31 | virtual gfx::NativeView GetTestingHandle() const; |
[email protected] | 420949f | 2009-03-18 20:40:34 | [diff] [blame] | 32 | |
33 | // Overridden from View: | ||||
34 | virtual gfx::Size GetPreferredSize(); | ||||
35 | |||||
36 | // Overridden from NativeControlWin: | ||||
[email protected] | 474fd5d | 2009-03-27 18:07:25 | [diff] [blame] | 37 | virtual bool ProcessMessage(UINT message, |
38 | WPARAM w_param, | ||||
39 | LPARAM l_param, | ||||
40 | LRESULT* result); | ||||
[email protected] | 420949f | 2009-03-18 20:40:34 | [diff] [blame] | 41 | virtual bool OnKeyDown(int vkey); |
42 | |||||
43 | protected: | ||||
[email protected] | 420949f | 2009-03-18 20:40:34 | [diff] [blame] | 44 | virtual void CreateNativeControl(); |
45 | virtual void NativeControlCreated(HWND control_hwnd); | ||||
46 | |||||
[email protected] | 37dbc03 | 2009-03-20 23:46:40 | [diff] [blame] | 47 | // Returns true if this button is actually a checkbox or radio button. |
48 | virtual bool IsCheckbox() const { return false; } | ||||
49 | |||||
[email protected] | 420949f | 2009-03-18 20:40:34 | [diff] [blame] | 50 | private: |
[email protected] | ff9b986c | 2009-03-19 21:18:44 | [diff] [blame] | 51 | // The NativeButton we are bound to. |
[email protected] | a8111ce7 | 2009-03-23 21:55:52 | [diff] [blame] | 52 | NativeButton* native_button_; |
[email protected] | 420949f | 2009-03-18 20:40:34 | [diff] [blame] | 53 | |
[email protected] | f861719 | 2010-07-05 07:57:10 | [diff] [blame] | 54 | // 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] | 420949f | 2009-03-18 20:40:34 | [diff] [blame] | 58 | DISALLOW_COPY_AND_ASSIGN(NativeButtonWin); |
59 | }; | ||||
60 | |||||
61 | // A View that hosts a native Windows checkbox. | ||||
62 | class NativeCheckboxWin : public NativeButtonWin { | ||||
63 | public: | ||||
[email protected] | a8111ce7 | 2009-03-23 21:55:52 | [diff] [blame] | 64 | explicit NativeCheckboxWin(Checkbox* native_button); |
[email protected] | 420949f | 2009-03-18 20:40:34 | [diff] [blame] | 65 | virtual ~NativeCheckboxWin(); |
66 | |||||
[email protected] | 37dbc03 | 2009-03-20 23:46:40 | [diff] [blame] | 67 | // Overridden from View: |
68 | virtual gfx::Size GetPreferredSize(); | ||||
69 | |||||
[email protected] | 420949f | 2009-03-18 20:40:34 | [diff] [blame] | 70 | // Overridden from NativeButtonWrapper: |
[email protected] | ff9b986c | 2009-03-19 21:18:44 | [diff] [blame] | 71 | virtual void UpdateChecked(); |
[email protected] | 37dbc03 | 2009-03-20 23:46:40 | [diff] [blame] | 72 | virtual void SetPushed(bool pushed); |
[email protected] | 18305de | 2009-03-27 17:52:06 | [diff] [blame] | 73 | virtual bool OnKeyDown(int vkey); |
[email protected] | bbcd29e | 2009-07-24 00:05:06 | [diff] [blame] | 74 | virtual bool UsesNativeLabel() const; |
[email protected] | 420949f | 2009-03-18 20:40:34 | [diff] [blame] | 75 | |
76 | // Overridden from NativeControlWin: | ||||
[email protected] | 474fd5d | 2009-03-27 18:07:25 | [diff] [blame] | 77 | virtual bool ProcessMessage(UINT message, |
78 | WPARAM w_param, | ||||
79 | LPARAM l_param, | ||||
80 | LRESULT* result); | ||||
[email protected] | 420949f | 2009-03-18 20:40:34 | [diff] [blame] | 81 | |
82 | protected: | ||||
83 | virtual void CreateNativeControl(); | ||||
84 | virtual void NativeControlCreated(HWND control_hwnd); | ||||
[email protected] | 37dbc03 | 2009-03-20 23:46:40 | [diff] [blame] | 85 | virtual bool IsCheckbox() const { return true; } |
[email protected] | 420949f | 2009-03-18 20:40:34 | [diff] [blame] | 86 | |
[email protected] | b2b26af | 2009-04-24 18:48:44 | [diff] [blame] | 87 | // Returns true if this button is actually a radio button. |
88 | virtual bool IsRadioButton() const { return false; } | ||||
89 | |||||
[email protected] | 420949f | 2009-03-18 20:40:34 | [diff] [blame] | 90 | private: |
[email protected] | ff9b986c | 2009-03-19 21:18:44 | [diff] [blame] | 91 | // The Checkbox we are bound to. |
[email protected] | a8111ce7 | 2009-03-23 21:55:52 | [diff] [blame] | 92 | Checkbox* checkbox_; |
[email protected] | 420949f | 2009-03-18 20:40:34 | [diff] [blame] | 93 | |
94 | DISALLOW_COPY_AND_ASSIGN(NativeCheckboxWin); | ||||
95 | }; | ||||
96 | |||||
97 | // A View that hosts a native Windows radio button. | ||||
98 | class NativeRadioButtonWin : public NativeCheckboxWin { | ||||
99 | public: | ||||
[email protected] | a8111ce7 | 2009-03-23 21:55:52 | [diff] [blame] | 100 | explicit NativeRadioButtonWin(RadioButton* radio_button); |
[email protected] | 420949f | 2009-03-18 20:40:34 | [diff] [blame] | 101 | virtual ~NativeRadioButtonWin(); |
102 | |||||
103 | protected: | ||||
104 | // Overridden from NativeCheckboxWin: | ||||
105 | virtual void CreateNativeControl(); | ||||
[email protected] | b2b26af | 2009-04-24 18:48:44 | [diff] [blame] | 106 | virtual bool IsRadioButton() const { return true; } |
[email protected] | 420949f | 2009-03-18 20:40:34 | [diff] [blame] | 107 | |
108 | private: | ||||
109 | DISALLOW_COPY_AND_ASSIGN(NativeRadioButtonWin); | ||||
110 | }; | ||||
[email protected] | 37dbc03 | 2009-03-20 23:46:40 | [diff] [blame] | 111 | |
[email protected] | 420949f | 2009-03-18 20:40:34 | [diff] [blame] | 112 | } // namespace views |
113 | |||||
[email protected] | 2362e4f | 2009-05-08 00:34:05 | [diff] [blame] | 114 | #endif // #ifndef VIEWS_CONTROLS_BUTTON_NATIVE_BUTTON_WIN_H_ |