| 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/strings/utf_string_conversions.h" | 7 #include "base/strings/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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 label_button_->SetImage(Button::STATE_NORMAL, | 156 label_button_->SetImage(Button::STATE_NORMAL, |
| 157 label_button_->GetImage(Button::STATE_NORMAL).isNull() ? | 157 label_button_->GetImage(Button::STATE_NORMAL).isNull() ? |
| 158 *icon_ : gfx::ImageSkia()); | 158 *icon_ : gfx::ImageSkia()); |
| 159 } else { | 159 } else { |
| 160 label_button_->SetHorizontalAlignment( | 160 label_button_->SetHorizontalAlignment( |
| 161 static_cast<gfx::HorizontalAlignment>( | 161 static_cast<gfx::HorizontalAlignment>( |
| 162 (label_button_->GetHorizontalAlignment() + 1) % 3)); | 162 (label_button_->GetHorizontalAlignment() + 1) % 3)); |
| 163 } | 163 } |
| 164 } else if (event.IsShiftDown()) { | 164 } else if (event.IsShiftDown()) { |
| 165 if (event.IsAltDown()) { | 165 if (event.IsAltDown()) { |
| 166 label_button_->SetFocusable(!label_button_->focusable()); | 166 label_button_->SetFocusable(!label_button_->IsFocusable()); |
| 167 } else { | 167 } else { |
| 168 label_button_->SetStyle(static_cast<Button::ButtonStyle>( | 168 label_button_->SetStyle(static_cast<Button::ButtonStyle>( |
| 169 (label_button_->style() + 1) % Button::STYLE_COUNT)); | 169 (label_button_->style() + 1) % Button::STYLE_COUNT)); |
| 170 } | 170 } |
| 171 } else if (event.IsAltDown()) { | 171 } else if (event.IsAltDown()) { |
| 172 label_button_->SetIsDefault(!label_button_->is_default()); | 172 label_button_->SetIsDefault(!label_button_->is_default()); |
| 173 } else { | 173 } else { |
| 174 label_button_->set_min_size(gfx::Size()); | 174 label_button_->set_min_size(gfx::Size()); |
| 175 } | 175 } |
| 176 example_view()->GetLayoutManager()->Layout(example_view()); | 176 example_view()->GetLayoutManager()->Layout(example_view()); |
| 177 } | 177 } |
| 178 | 178 |
| 179 void ButtonExample::ButtonPressed(Button* sender, const ui::Event& event) { | 179 void ButtonExample::ButtonPressed(Button* sender, const ui::Event& event) { |
| 180 if (sender == text_button_) | 180 if (sender == text_button_) |
| 181 TextButtonPressed(event); | 181 TextButtonPressed(event); |
| 182 else if (sender == label_button_) | 182 else if (sender == label_button_) |
| 183 LabelButtonPressed(event); | 183 LabelButtonPressed(event); |
| 184 else | 184 else |
| 185 PrintStatus("Image Button Pressed! count: %d", ++count_); | 185 PrintStatus("Image Button Pressed! count: %d", ++count_); |
| 186 } | 186 } |
| 187 | 187 |
| 188 } // namespace examples | 188 } // namespace examples |
| 189 } // namespace views | 189 } // namespace views |
| OLD | NEW |