| 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
| 11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 12 #include "ui/base/animation/throb_animation.h" | 12 #include "ui/base/animation/throb_animation.h" |
| 13 #include "ui/base/models/combobox_model.h" | 13 #include "ui/base/models/combobox_model.h" |
| 14 #include "ui/gfx/canvas.h" | 14 #include "ui/gfx/canvas.h" |
| 15 #include "views/controls/label.h" |
| 15 #include "views/examples/example_combobox_model.h" | 16 #include "views/examples/example_combobox_model.h" |
| 16 #include "views/controls/label.h" | |
| 17 #include "views/layout/grid_layout.h" | 17 #include "views/layout/grid_layout.h" |
| 18 #include "views/native_theme_painter.h" | 18 #include "views/native_theme_painter.h" |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 const char* kParts[] = { | 22 const char* kParts[] = { |
| 23 "PushButton", | 23 "PushButton", |
| 24 "RadioButton", | 24 "RadioButton", |
| 25 "Checkbox", | 25 "Checkbox", |
| 26 }; | 26 }; |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 return gfx::NativeTheme::kHovered; | 184 return gfx::NativeTheme::kHovered; |
| 185 } | 185 } |
| 186 | 186 |
| 187 gfx::Size ExampleNativeThemeButton::GetPreferredSize() { | 187 gfx::Size ExampleNativeThemeButton::GetPreferredSize() { |
| 188 return painter_.get() == NULL ? gfx::Size() : painter_->GetPreferredSize(); | 188 return painter_.get() == NULL ? gfx::Size() : painter_->GetPreferredSize(); |
| 189 } | 189 } |
| 190 | 190 |
| 191 void ExampleNativeThemeButton::OnPaintBackground(gfx::Canvas* canvas) { | 191 void ExampleNativeThemeButton::OnPaintBackground(gfx::Canvas* canvas) { |
| 192 // Fill the background with a known colour so that we know where the bounds | 192 // Fill the background with a known colour so that we know where the bounds |
| 193 // of the View are. | 193 // of the View are. |
| 194 canvas->FillRectInt(SkColorSetRGB(255, 128, 128), 0, 0, width(), height()); | 194 canvas->FillRect(SkColorSetRGB(255, 128, 128), GetLocalBounds()); |
| 195 CustomButton::OnPaintBackground(canvas); | 195 CustomButton::OnPaintBackground(canvas); |
| 196 } | 196 } |
| 197 | 197 |
| 198 //////////////////////////////////////////////////////////////////////////////// | 198 //////////////////////////////////////////////////////////////////////////////// |
| 199 | 199 |
| 200 NativeThemeButtonExample::NativeThemeButtonExample(ExamplesMain* main) | 200 NativeThemeButtonExample::NativeThemeButtonExample(ExamplesMain* main) |
| 201 : ExampleBase(main, "Native Theme Button") { | 201 : ExampleBase(main, "Native Theme Button") { |
| 202 } | 202 } |
| 203 | 203 |
| 204 NativeThemeButtonExample::~NativeThemeButtonExample() { | 204 NativeThemeButtonExample::~NativeThemeButtonExample() { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 | 246 |
| 247 layout->AddPaddingRow(0, 8); | 247 layout->AddPaddingRow(0, 8); |
| 248 } | 248 } |
| 249 | 249 |
| 250 void NativeThemeButtonExample::ButtonPressed(views::Button* sender, | 250 void NativeThemeButtonExample::ButtonPressed(views::Button* sender, |
| 251 const views::Event& event) { | 251 const views::Event& event) { |
| 252 PrintStatus(button_->MessWithState().c_str()); | 252 PrintStatus(button_->MessWithState().c_str()); |
| 253 } | 253 } |
| 254 | 254 |
| 255 } // namespace examples | 255 } // namespace examples |
| OLD | NEW |