| 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 "ash/shell.h" | 5 #include "ash/shell.h" |
| 6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
| 7 #include "ui/aura/window.h" | 7 #include "ui/aura/window.h" |
| 8 #include "ui/aura/window_event_dispatcher.h" | 8 #include "ui/aura/window_event_dispatcher.h" |
| 9 #include "ui/gfx/canvas.h" | 9 #include "ui/gfx/canvas.h" |
| 10 #include "ui/views/controls/button/checkbox.h" | 10 #include "ui/views/controls/button/checkbox.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 views::RadioButton* radio_button_disabled_; | 50 views::RadioButton* radio_button_disabled_; |
| 51 views::RadioButton* radio_button_selected_; | 51 views::RadioButton* radio_button_selected_; |
| 52 views::RadioButton* radio_button_selected_disabled_; | 52 views::RadioButton* radio_button_selected_disabled_; |
| 53 }; | 53 }; |
| 54 | 54 |
| 55 WidgetsWindow::WidgetsWindow() | 55 WidgetsWindow::WidgetsWindow() |
| 56 : button_(new views::LabelButton(NULL, base::ASCIIToUTF16("Button"))), | 56 : button_(new views::LabelButton(NULL, base::ASCIIToUTF16("Button"))), |
| 57 disabled_button_( | 57 disabled_button_( |
| 58 new views::LabelButton(NULL, base::ASCIIToUTF16("Disabled button"))), | 58 new views::LabelButton(NULL, base::ASCIIToUTF16("Disabled button"))), |
| 59 checkbox_(new views::Checkbox(base::ASCIIToUTF16("Checkbox"))), | 59 checkbox_(new views::Checkbox(base::ASCIIToUTF16("Checkbox"))), |
| 60 checkbox_disabled_(new views::Checkbox( | 60 checkbox_disabled_( |
| 61 base::ASCIIToUTF16("Checkbox disabled"))), | 61 new views::Checkbox(base::ASCIIToUTF16("Checkbox disabled"))), |
| 62 checkbox_checked_(new views::Checkbox( | 62 checkbox_checked_( |
| 63 base::ASCIIToUTF16("Checkbox checked"))), | 63 new views::Checkbox(base::ASCIIToUTF16("Checkbox checked"))), |
| 64 checkbox_checked_disabled_(new views::Checkbox( | 64 checkbox_checked_disabled_( |
| 65 base::ASCIIToUTF16("Checkbox checked disabled"))), | 65 new views::Checkbox(base::ASCIIToUTF16("Checkbox checked disabled"))), |
| 66 radio_button_(new views::RadioButton( | 66 radio_button_( |
| 67 base::ASCIIToUTF16("Radio button"), 0)), | 67 new views::RadioButton(base::ASCIIToUTF16("Radio button"), 0)), |
| 68 radio_button_disabled_(new views::RadioButton( | 68 radio_button_disabled_( |
| 69 base::ASCIIToUTF16("Radio button disabled"), 0)), | 69 new views::RadioButton(base::ASCIIToUTF16("Radio button disabled"), |
| 70 radio_button_selected_(new views::RadioButton( | 70 0)), |
| 71 base::ASCIIToUTF16("Radio button selected"), 0)), | 71 radio_button_selected_( |
| 72 new views::RadioButton(base::ASCIIToUTF16("Radio button selected"), |
| 73 0)), |
| 72 radio_button_selected_disabled_(new views::RadioButton( | 74 radio_button_selected_disabled_(new views::RadioButton( |
| 73 base::ASCIIToUTF16("Radio button selected disabled"), 1)) { | 75 base::ASCIIToUTF16("Radio button selected disabled"), |
| 76 1)) { |
| 74 button_->SetStyle(views::Button::STYLE_BUTTON); | 77 button_->SetStyle(views::Button::STYLE_BUTTON); |
| 75 AddChildView(button_); | 78 AddChildView(button_); |
| 76 disabled_button_->SetEnabled(false); | 79 disabled_button_->SetEnabled(false); |
| 77 disabled_button_->SetStyle(views::Button::STYLE_BUTTON); | 80 disabled_button_->SetStyle(views::Button::STYLE_BUTTON); |
| 78 AddChildView(disabled_button_); | 81 AddChildView(disabled_button_); |
| 79 AddChildView(checkbox_); | 82 AddChildView(checkbox_); |
| 80 checkbox_disabled_->SetEnabled(false); | 83 checkbox_disabled_->SetEnabled(false); |
| 81 AddChildView(checkbox_disabled_); | 84 AddChildView(checkbox_disabled_); |
| 82 checkbox_checked_->SetChecked(true); | 85 checkbox_checked_->SetChecked(true); |
| 83 AddChildView(checkbox_checked_); | 86 AddChildView(checkbox_checked_); |
| 84 checkbox_checked_disabled_->SetChecked(true); | 87 checkbox_checked_disabled_->SetChecked(true); |
| 85 checkbox_checked_disabled_->SetEnabled(false); | 88 checkbox_checked_disabled_->SetEnabled(false); |
| 86 AddChildView(checkbox_checked_disabled_); | 89 AddChildView(checkbox_checked_disabled_); |
| 87 AddChildView(radio_button_); | 90 AddChildView(radio_button_); |
| 88 radio_button_disabled_->SetEnabled(false); | 91 radio_button_disabled_->SetEnabled(false); |
| 89 AddChildView(radio_button_disabled_); | 92 AddChildView(radio_button_disabled_); |
| 90 radio_button_selected_->SetChecked(true); | 93 radio_button_selected_->SetChecked(true); |
| 91 AddChildView(radio_button_selected_); | 94 AddChildView(radio_button_selected_); |
| 92 radio_button_selected_disabled_->SetChecked(true); | 95 radio_button_selected_disabled_->SetChecked(true); |
| 93 radio_button_selected_disabled_->SetEnabled(false); | 96 radio_button_selected_disabled_->SetEnabled(false); |
| 94 AddChildView(radio_button_selected_disabled_); | 97 AddChildView(radio_button_selected_disabled_); |
| 95 } | 98 } |
| 96 | 99 |
| 97 WidgetsWindow::~WidgetsWindow() { | 100 WidgetsWindow::~WidgetsWindow() {} |
| 98 } | |
| 99 | 101 |
| 100 void WidgetsWindow::OnPaint(gfx::Canvas* canvas) { | 102 void WidgetsWindow::OnPaint(gfx::Canvas* canvas) { |
| 101 canvas->FillRect(GetLocalBounds(), SK_ColorWHITE); | 103 canvas->FillRect(GetLocalBounds(), SK_ColorWHITE); |
| 102 } | 104 } |
| 103 | 105 |
| 104 void WidgetsWindow::Layout() { | 106 void WidgetsWindow::Layout() { |
| 105 const int kVerticalPad = 5; | 107 const int kVerticalPad = 5; |
| 106 int left = 5; | 108 int left = 5; |
| 107 int top = kVerticalPad; | 109 int top = kVerticalPad; |
| 108 for (int i = 0; i < child_count(); ++i) { | 110 for (int i = 0; i < child_count(); ++i) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 129 return true; | 131 return true; |
| 130 } | 132 } |
| 131 | 133 |
| 132 } // namespace | 134 } // namespace |
| 133 | 135 |
| 134 namespace ash { | 136 namespace ash { |
| 135 namespace shell { | 137 namespace shell { |
| 136 | 138 |
| 137 void CreateWidgetsWindow() { | 139 void CreateWidgetsWindow() { |
| 138 gfx::Rect bounds(kWindowLeft, kWindowTop, kWindowWidth, kWindowHeight); | 140 gfx::Rect bounds(kWindowLeft, kWindowTop, kWindowWidth, kWindowHeight); |
| 139 views::Widget* widget = | 141 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds( |
| 140 views::Widget::CreateWindowWithContextAndBounds( | 142 new WidgetsWindow, Shell::GetPrimaryRootWindow(), bounds); |
| 141 new WidgetsWindow, Shell::GetPrimaryRootWindow(), bounds); | |
| 142 widget->GetNativeView()->SetName("WidgetsWindow"); | 143 widget->GetNativeView()->SetName("WidgetsWindow"); |
| 143 widget->Show(); | 144 widget->Show(); |
| 144 } | 145 } |
| 145 | 146 |
| 146 } // namespace shell | 147 } // namespace shell |
| 147 } // namespace ash | 148 } // namespace ash |
| OLD | NEW |