| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/views/examples/button_example.h" | 5 #include "ui/views/examples/button_example.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "grit/ui_resources.h" | 8 #include "grit/ui_resources.h" |
| 9 #include "ui/base/resource/resource_bundle.h" | 9 #include "ui/base/resource/resource_bundle.h" |
| 10 #include "ui/gfx/image/image.h" | 10 #include "ui/gfx/image/image.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 void ButtonExample::CreateExampleView(View* container) { | 38 void ButtonExample::CreateExampleView(View* container) { |
| 39 container->SetLayoutManager( | 39 container->SetLayoutManager( |
| 40 new BoxLayout(BoxLayout::kVertical, 0, 0, kLayoutSpacing)); | 40 new BoxLayout(BoxLayout::kVertical, 0, 0, kLayoutSpacing)); |
| 41 | 41 |
| 42 text_button_ = new TextButton(this, ASCIIToUTF16("Text Button")); | 42 text_button_ = new TextButton(this, ASCIIToUTF16("Text Button")); |
| 43 container->AddChildView(text_button_); | 43 container->AddChildView(text_button_); |
| 44 | 44 |
| 45 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 45 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 46 image_button_ = new ImageButton(this); | 46 image_button_ = new ImageButton(this); |
| 47 image_button_->SetImage(ImageButton::BS_NORMAL, | 47 image_button_->SetImage(ImageButton::BS_NORMAL, |
| 48 rb.GetImageNamed(IDR_CLOSE).ToSkBitmap()); | 48 rb.GetImageNamed(IDR_CLOSE).ToImageSkia()); |
| 49 image_button_->SetImage(ImageButton::BS_HOT, | 49 image_button_->SetImage(ImageButton::BS_HOT, |
| 50 rb.GetImageNamed(IDR_CLOSE_H).ToSkBitmap()); | 50 rb.GetImageNamed(IDR_CLOSE_H).ToImageSkia()); |
| 51 image_button_->SetImage(ImageButton::BS_PUSHED, | 51 image_button_->SetImage(ImageButton::BS_PUSHED, |
| 52 rb.GetImageNamed(IDR_CLOSE_P).ToSkBitmap()); | 52 rb.GetImageNamed(IDR_CLOSE_P).ToImageSkia()); |
| 53 image_button_->SetOverlayImage(rb.GetImageNamed(IDR_MENU_CHECK).ToSkBitmap()); | 53 image_button_->SetOverlayImage(rb.GetImageNamed(IDR_MENU_CHECK).ToSkBitmap()); |
| 54 container->AddChildView(image_button_); | 54 container->AddChildView(image_button_); |
| 55 } | 55 } |
| 56 | 56 |
| 57 void ButtonExample::ButtonPressed(Button* sender, const Event& event) { | 57 void ButtonExample::ButtonPressed(Button* sender, const Event& event) { |
| 58 PrintStatus("Pressed! count: %d", ++count_); | 58 PrintStatus("Pressed! count: %d", ++count_); |
| 59 | 59 |
| 60 if (event.IsControlDown()) { | 60 if (event.IsControlDown()) { |
| 61 if (event.IsShiftDown()) { | 61 if (event.IsShiftDown()) { |
| 62 if (event.IsAltDown()) { | 62 if (event.IsAltDown()) { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 text_button_->set_border(new TextButtonBorder()); | 117 text_button_->set_border(new TextButtonBorder()); |
| 118 } | 118 } |
| 119 } else if (event.IsAltDown()) { | 119 } else if (event.IsAltDown()) { |
| 120 text_button_->SetIsDefault(!text_button_->is_default()); | 120 text_button_->SetIsDefault(!text_button_->is_default()); |
| 121 } | 121 } |
| 122 example_view()->GetLayoutManager()->Layout(example_view()); | 122 example_view()->GetLayoutManager()->Layout(example_view()); |
| 123 } | 123 } |
| 124 | 124 |
| 125 } // namespace examples | 125 } // namespace examples |
| 126 } // namespace views | 126 } // namespace views |
| OLD | NEW |