OLD | NEW |
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/examples/native_theme_button_example.h" | 5 #include "views/examples/native_theme_button_example.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "ui/base/animation/throb_animation.h" | 10 #include "ui/base/animation/throb_animation.h" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 return gfx::NativeTheme::kRadio; | 130 return gfx::NativeTheme::kRadio; |
131 case 2: | 131 case 2: |
132 return gfx::NativeTheme::kCheckbox; | 132 return gfx::NativeTheme::kCheckbox; |
133 default: | 133 default: |
134 DCHECK(false); | 134 DCHECK(false); |
135 } | 135 } |
136 return gfx::NativeTheme::kPushButton; | 136 return gfx::NativeTheme::kPushButton; |
137 } | 137 } |
138 | 138 |
139 gfx::Rect ExampleNativeThemeButton::GetThemePaintRect() const { | 139 gfx::Rect ExampleNativeThemeButton::GetThemePaintRect() const { |
140 return GetLocalBounds(); | 140 gfx::NativeTheme::ExtraParams extra; |
| 141 gfx::NativeTheme::State state = GetThemeState(&extra); |
| 142 gfx::Size size(gfx::NativeTheme::instance()->GetPartSize(GetThemePart(), |
| 143 state, |
| 144 extra)); |
| 145 gfx::Rect rect(size); |
| 146 rect.set_x(GetMirroredXForRect(rect)); |
| 147 return rect; |
141 } | 148 } |
142 | 149 |
143 gfx::NativeTheme::State ExampleNativeThemeButton::GetThemeState( | 150 gfx::NativeTheme::State ExampleNativeThemeButton::GetThemeState( |
144 gfx::NativeTheme::ExtraParams* params) const { | 151 gfx::NativeTheme::ExtraParams* params) const { |
145 GetExtraParams(params); | 152 GetExtraParams(params); |
146 | 153 |
147 int selected = cb_state_->selected_item(); | 154 int selected = cb_state_->selected_item(); |
148 if (selected > 3) { | 155 if (selected > 3) { |
149 switch(state()) { | 156 switch(state()) { |
150 case BS_DISABLED: | 157 case BS_DISABLED: |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 | 276 |
270 layout->AddPaddingRow(0, 8); | 277 layout->AddPaddingRow(0, 8); |
271 } | 278 } |
272 | 279 |
273 void NativeThemeButtonExample::ButtonPressed(views::Button* sender, | 280 void NativeThemeButtonExample::ButtonPressed(views::Button* sender, |
274 const views::Event& event) { | 281 const views::Event& event) { |
275 PrintStatus(button_->MessWithState().c_str()); | 282 PrintStatus(button_->MessWithState().c_str()); |
276 } | 283 } |
277 | 284 |
278 } // namespace examples | 285 } // namespace examples |
OLD | NEW |