Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: ui/views/examples/button_example.cc

Issue 103493005: Rename View::set_focusable and View::set_accessibility_focusable (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added a few missing files Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/views/controls/tree/tree_view.cc ('k') | ui/views/examples/tree_view_example.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 } 42 }
43 43
44 ButtonExample::~ButtonExample() { 44 ButtonExample::~ButtonExample() {
45 } 45 }
46 46
47 void ButtonExample::CreateExampleView(View* container) { 47 void ButtonExample::CreateExampleView(View* container) {
48 container->set_background(Background::CreateSolidBackground(SK_ColorWHITE)); 48 container->set_background(Background::CreateSolidBackground(SK_ColorWHITE));
49 container->SetLayoutManager(new BoxLayout(BoxLayout::kVertical, 10, 10, 10)); 49 container->SetLayoutManager(new BoxLayout(BoxLayout::kVertical, 10, 10, 10));
50 50
51 text_button_ = new TextButton(this, ASCIIToUTF16(kTextButton)); 51 text_button_ = new TextButton(this, ASCIIToUTF16(kTextButton));
52 text_button_->set_focusable(true); 52 text_button_->SetFocusable(true);
53 container->AddChildView(text_button_); 53 container->AddChildView(text_button_);
54 54
55 label_button_ = new LabelButton(this, ASCIIToUTF16(kLabelButton)); 55 label_button_ = new LabelButton(this, ASCIIToUTF16(kLabelButton));
56 label_button_->set_focusable(true); 56 label_button_->SetFocusable(true);
57 container->AddChildView(label_button_); 57 container->AddChildView(label_button_);
58 58
59 LabelButton* disabled_button = 59 LabelButton* disabled_button =
60 new LabelButton(this, ASCIIToUTF16("Disabled Button")); 60 new LabelButton(this, ASCIIToUTF16("Disabled Button"));
61 disabled_button->SetStyle(Button::STYLE_BUTTON); 61 disabled_button->SetStyle(Button::STYLE_BUTTON);
62 disabled_button->SetState(Button::STATE_DISABLED); 62 disabled_button->SetState(Button::STATE_DISABLED);
63 container->AddChildView(disabled_button); 63 container->AddChildView(disabled_button);
64 64
65 container->AddChildView(new BlueButton(this, ASCIIToUTF16("Blue Button"))); 65 container->AddChildView(new BlueButton(this, ASCIIToUTF16("Blue Button")));
66 66
67 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 67 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
68 image_button_ = new ImageButton(this); 68 image_button_ = new ImageButton(this);
69 image_button_->set_focusable(true); 69 image_button_->SetFocusable(true);
70 image_button_->SetImage(ImageButton::STATE_NORMAL, 70 image_button_->SetImage(ImageButton::STATE_NORMAL,
71 rb.GetImageNamed(IDR_CLOSE).ToImageSkia()); 71 rb.GetImageNamed(IDR_CLOSE).ToImageSkia());
72 image_button_->SetImage(ImageButton::STATE_HOVERED, 72 image_button_->SetImage(ImageButton::STATE_HOVERED,
73 rb.GetImageNamed(IDR_CLOSE_H).ToImageSkia()); 73 rb.GetImageNamed(IDR_CLOSE_H).ToImageSkia());
74 image_button_->SetImage(ImageButton::STATE_PRESSED, 74 image_button_->SetImage(ImageButton::STATE_PRESSED,
75 rb.GetImageNamed(IDR_CLOSE_P).ToImageSkia()); 75 rb.GetImageNamed(IDR_CLOSE_P).ToImageSkia());
76 image_button_->SetOverlayImage(rb.GetImageNamed( 76 image_button_->SetOverlayImage(rb.GetImageNamed(
77 IDR_MENU_CHECK).ToImageSkia()); 77 IDR_MENU_CHECK).ToImageSkia());
78 container->AddChildView(image_button_); 78 container->AddChildView(image_button_);
79 } 79 }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 label_button_->SetImage(Button::STATE_NORMAL, 154 label_button_->SetImage(Button::STATE_NORMAL,
155 label_button_->GetImage(Button::STATE_NORMAL).isNull() ? 155 label_button_->GetImage(Button::STATE_NORMAL).isNull() ?
156 *icon_ : gfx::ImageSkia()); 156 *icon_ : gfx::ImageSkia());
157 } else { 157 } else {
158 label_button_->SetHorizontalAlignment( 158 label_button_->SetHorizontalAlignment(
159 static_cast<gfx::HorizontalAlignment>( 159 static_cast<gfx::HorizontalAlignment>(
160 (label_button_->GetHorizontalAlignment() + 1) % 3)); 160 (label_button_->GetHorizontalAlignment() + 1) % 3));
161 } 161 }
162 } else if (event.IsShiftDown()) { 162 } else if (event.IsShiftDown()) {
163 if (event.IsAltDown()) { 163 if (event.IsAltDown()) {
164 label_button_->set_focusable(!label_button_->focusable()); 164 label_button_->SetFocusable(!label_button_->focusable());
165 } else { 165 } else {
166 label_button_->SetStyle(static_cast<Button::ButtonStyle>( 166 label_button_->SetStyle(static_cast<Button::ButtonStyle>(
167 (label_button_->style() + 1) % Button::STYLE_COUNT)); 167 (label_button_->style() + 1) % Button::STYLE_COUNT));
168 } 168 }
169 } else if (event.IsAltDown()) { 169 } else if (event.IsAltDown()) {
170 label_button_->SetIsDefault(!label_button_->is_default()); 170 label_button_->SetIsDefault(!label_button_->is_default());
171 } else { 171 } else {
172 label_button_->set_min_size(gfx::Size()); 172 label_button_->set_min_size(gfx::Size());
173 } 173 }
174 example_view()->GetLayoutManager()->Layout(example_view()); 174 example_view()->GetLayoutManager()->Layout(example_view());
175 } 175 }
176 176
177 void ButtonExample::ButtonPressed(Button* sender, const ui::Event& event) { 177 void ButtonExample::ButtonPressed(Button* sender, const ui::Event& event) {
178 if (sender == text_button_) 178 if (sender == text_button_)
179 TextButtonPressed(event); 179 TextButtonPressed(event);
180 else if (sender == label_button_) 180 else if (sender == label_button_)
181 LabelButtonPressed(event); 181 LabelButtonPressed(event);
182 else 182 else
183 PrintStatus("Image Button Pressed! count: %d", ++count_); 183 PrintStatus("Image Button Pressed! count: %d", ++count_);
184 } 184 }
185 185
186 } // namespace examples 186 } // namespace examples
187 } // namespace views 187 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/tree/tree_view.cc ('k') | ui/views/examples/tree_view_example.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698