| 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/utf_string_conversions.h" // ASCIIToUTF16 | 6 #include "base/utf_string_conversions.h" // ASCIIToUTF16 |
| 7 #include "ui/aura/root_window.h" | 7 #include "ui/aura/root_window.h" |
| 8 #include "ui/aura/window.h" | 8 #include "ui/aura/window.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" |
| 11 #include "ui/views/controls/button/label_button.h" |
| 11 #include "ui/views/controls/button/radio_button.h" | 12 #include "ui/views/controls/button/radio_button.h" |
| 12 #include "ui/views/controls/button/text_button.h" | |
| 13 #include "ui/views/widget/widget.h" | 13 #include "ui/views/widget/widget.h" |
| 14 #include "ui/views/widget/widget_delegate.h" | 14 #include "ui/views/widget/widget_delegate.h" |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 // Default window position. | 18 // Default window position. |
| 19 const int kWindowLeft = 170; | 19 const int kWindowLeft = 170; |
| 20 const int kWindowTop = 200; | 20 const int kWindowTop = 200; |
| 21 | 21 |
| 22 // Default window size. | 22 // Default window size. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 33 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 33 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; |
| 34 virtual void Layout() OVERRIDE; | 34 virtual void Layout() OVERRIDE; |
| 35 virtual gfx::Size GetPreferredSize() OVERRIDE; | 35 virtual gfx::Size GetPreferredSize() OVERRIDE; |
| 36 | 36 |
| 37 // Overridden from views::WidgetDelegate: | 37 // Overridden from views::WidgetDelegate: |
| 38 virtual views::View* GetContentsView() OVERRIDE; | 38 virtual views::View* GetContentsView() OVERRIDE; |
| 39 virtual string16 GetWindowTitle() const OVERRIDE; | 39 virtual string16 GetWindowTitle() const OVERRIDE; |
| 40 virtual bool CanResize() const OVERRIDE; | 40 virtual bool CanResize() const OVERRIDE; |
| 41 | 41 |
| 42 private: | 42 private: |
| 43 views::NativeTextButton* button_; | 43 views::LabelButton* button_; |
| 44 views::NativeTextButton* disabled_button_; | 44 views::LabelButton* disabled_button_; |
| 45 views::Checkbox* checkbox_; | 45 views::Checkbox* checkbox_; |
| 46 views::Checkbox* checkbox_disabled_; | 46 views::Checkbox* checkbox_disabled_; |
| 47 views::Checkbox* checkbox_checked_; | 47 views::Checkbox* checkbox_checked_; |
| 48 views::Checkbox* checkbox_checked_disabled_; | 48 views::Checkbox* checkbox_checked_disabled_; |
| 49 views::RadioButton* radio_button_; | 49 views::RadioButton* radio_button_; |
| 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::NativeTextButton(NULL, ASCIIToUTF16("Button"))), | 56 : button_(new views::LabelButton(NULL, ASCIIToUTF16("Button"))), |
| 57 disabled_button_( | 57 disabled_button_( |
| 58 new views::NativeTextButton(NULL, ASCIIToUTF16("Disabled button"))), | 58 new views::LabelButton(NULL, ASCIIToUTF16("Disabled button"))), |
| 59 checkbox_(new views::Checkbox(ASCIIToUTF16("Checkbox"))), | 59 checkbox_(new views::Checkbox(ASCIIToUTF16("Checkbox"))), |
| 60 checkbox_disabled_(new views::Checkbox( | 60 checkbox_disabled_(new views::Checkbox( |
| 61 ASCIIToUTF16("Checkbox disabled"))), | 61 ASCIIToUTF16("Checkbox disabled"))), |
| 62 checkbox_checked_(new views::Checkbox(ASCIIToUTF16("Checkbox checked"))), | 62 checkbox_checked_(new views::Checkbox(ASCIIToUTF16("Checkbox checked"))), |
| 63 checkbox_checked_disabled_(new views::Checkbox( | 63 checkbox_checked_disabled_(new views::Checkbox( |
| 64 ASCIIToUTF16("Checkbox checked disabled"))), | 64 ASCIIToUTF16("Checkbox checked disabled"))), |
| 65 radio_button_(new views::RadioButton(ASCIIToUTF16("Radio button"), 0)), | 65 radio_button_(new views::RadioButton(ASCIIToUTF16("Radio button"), 0)), |
| 66 radio_button_disabled_(new views::RadioButton( | 66 radio_button_disabled_(new views::RadioButton( |
| 67 ASCIIToUTF16("Radio button disabled"), 0)), | 67 ASCIIToUTF16("Radio button disabled"), 0)), |
| 68 radio_button_selected_(new views::RadioButton( | 68 radio_button_selected_(new views::RadioButton( |
| 69 ASCIIToUTF16("Radio button selected"), 0)), | 69 ASCIIToUTF16("Radio button selected"), 0)), |
| 70 radio_button_selected_disabled_(new views::RadioButton( | 70 radio_button_selected_disabled_(new views::RadioButton( |
| 71 ASCIIToUTF16("Radio button selected disabled"), 1)) { | 71 ASCIIToUTF16("Radio button selected disabled"), 1)) { |
| 72 button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); |
| 72 AddChildView(button_); | 73 AddChildView(button_); |
| 73 disabled_button_->SetEnabled(false); | 74 disabled_button_->SetEnabled(false); |
| 75 disabled_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); |
| 74 AddChildView(disabled_button_); | 76 AddChildView(disabled_button_); |
| 75 AddChildView(checkbox_); | 77 AddChildView(checkbox_); |
| 76 checkbox_disabled_->SetEnabled(false); | 78 checkbox_disabled_->SetEnabled(false); |
| 77 AddChildView(checkbox_disabled_); | 79 AddChildView(checkbox_disabled_); |
| 78 checkbox_checked_->SetChecked(true); | 80 checkbox_checked_->SetChecked(true); |
| 79 AddChildView(checkbox_checked_); | 81 AddChildView(checkbox_checked_); |
| 80 checkbox_checked_disabled_->SetChecked(true); | 82 checkbox_checked_disabled_->SetChecked(true); |
| 81 checkbox_checked_disabled_->SetEnabled(false); | 83 checkbox_checked_disabled_->SetEnabled(false); |
| 82 AddChildView(checkbox_checked_disabled_); | 84 AddChildView(checkbox_checked_disabled_); |
| 83 AddChildView(radio_button_); | 85 AddChildView(radio_button_); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 gfx::Rect bounds(kWindowLeft, kWindowTop, kWindowWidth, kWindowHeight); | 136 gfx::Rect bounds(kWindowLeft, kWindowTop, kWindowWidth, kWindowHeight); |
| 135 views::Widget* widget = | 137 views::Widget* widget = |
| 136 views::Widget::CreateWindowWithContextAndBounds( | 138 views::Widget::CreateWindowWithContextAndBounds( |
| 137 new WidgetsWindow, Shell::GetPrimaryRootWindow(), bounds); | 139 new WidgetsWindow, Shell::GetPrimaryRootWindow(), bounds); |
| 138 widget->GetNativeView()->SetName("WidgetsWindow"); | 140 widget->GetNativeView()->SetName("WidgetsWindow"); |
| 139 widget->Show(); | 141 widget->Show(); |
| 140 } | 142 } |
| 141 | 143 |
| 142 } // namespace shell | 144 } // namespace shell |
| 143 } // namespace ash | 145 } // namespace ash |
| OLD | NEW |