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 14 matching lines...) Expand all Loading... |
25 | 25 |
26 // A window showing samples of commonly used widgets. | 26 // A window showing samples of commonly used widgets. |
27 class WidgetsWindow : public views::WidgetDelegateView { | 27 class WidgetsWindow : public views::WidgetDelegateView { |
28 public: | 28 public: |
29 WidgetsWindow(); | 29 WidgetsWindow(); |
30 ~WidgetsWindow() override; | 30 ~WidgetsWindow() override; |
31 | 31 |
32 // Overridden from views::View: | 32 // Overridden from views::View: |
33 void OnPaint(gfx::Canvas* canvas) override; | 33 void OnPaint(gfx::Canvas* canvas) override; |
34 void Layout() override; | 34 void Layout() override; |
35 gfx::Size GetPreferredSize() const override; | 35 gfx::Size CalculatePreferredSize() const override; |
36 | 36 |
37 // Overridden from views::WidgetDelegate: | 37 // Overridden from views::WidgetDelegate: |
38 base::string16 GetWindowTitle() const override; | 38 base::string16 GetWindowTitle() const override; |
39 bool CanResize() const override; | 39 bool CanResize() const override; |
40 | 40 |
41 private: | 41 private: |
42 views::LabelButton* button_; | 42 views::LabelButton* button_; |
43 views::LabelButton* disabled_button_; | 43 views::LabelButton* disabled_button_; |
44 views::Checkbox* checkbox_; | 44 views::Checkbox* checkbox_; |
45 views::Checkbox* checkbox_disabled_; | 45 views::Checkbox* checkbox_disabled_; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 int left = 5; | 107 int left = 5; |
108 int top = kVerticalPad; | 108 int top = kVerticalPad; |
109 for (int i = 0; i < child_count(); ++i) { | 109 for (int i = 0; i < child_count(); ++i) { |
110 views::View* view = child_at(i); | 110 views::View* view = child_at(i); |
111 gfx::Size preferred = view->GetPreferredSize(); | 111 gfx::Size preferred = view->GetPreferredSize(); |
112 view->SetBounds(left, top, preferred.width(), preferred.height()); | 112 view->SetBounds(left, top, preferred.width(), preferred.height()); |
113 top += preferred.height() + kVerticalPad; | 113 top += preferred.height() + kVerticalPad; |
114 } | 114 } |
115 } | 115 } |
116 | 116 |
117 gfx::Size WidgetsWindow::GetPreferredSize() const { | 117 gfx::Size WidgetsWindow::CalculatePreferredSize() const { |
118 return gfx::Size(kWindowWidth, kWindowHeight); | 118 return gfx::Size(kWindowWidth, kWindowHeight); |
119 } | 119 } |
120 | 120 |
121 base::string16 WidgetsWindow::GetWindowTitle() const { | 121 base::string16 WidgetsWindow::GetWindowTitle() const { |
122 return base::ASCIIToUTF16("Examples: Widgets"); | 122 return base::ASCIIToUTF16("Examples: Widgets"); |
123 } | 123 } |
124 | 124 |
125 bool WidgetsWindow::CanResize() const { | 125 bool WidgetsWindow::CanResize() const { |
126 return true; | 126 return true; |
127 } | 127 } |
128 | 128 |
129 } // namespace | 129 } // namespace |
130 | 130 |
131 namespace ash { | 131 namespace ash { |
132 namespace shell { | 132 namespace shell { |
133 | 133 |
134 void CreateWidgetsWindow() { | 134 void CreateWidgetsWindow() { |
135 gfx::Rect bounds(kWindowLeft, kWindowTop, kWindowWidth, kWindowHeight); | 135 gfx::Rect bounds(kWindowLeft, kWindowTop, kWindowWidth, kWindowHeight); |
136 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds( | 136 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds( |
137 new WidgetsWindow, Shell::GetPrimaryRootWindow(), bounds); | 137 new WidgetsWindow, Shell::GetPrimaryRootWindow(), bounds); |
138 widget->GetNativeView()->SetName("WidgetsWindow"); | 138 widget->GetNativeView()->SetName("WidgetsWindow"); |
139 widget->Show(); | 139 widget->Show(); |
140 } | 140 } |
141 | 141 |
142 } // namespace shell | 142 } // namespace shell |
143 } // namespace ash | 143 } // namespace ash |
OLD | NEW |