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 virtual ~WidgetsWindow(); | 30 virtual ~WidgetsWindow(); |
31 | 31 |
32 // Overridden from views::View: | 32 // Overridden from views::View: |
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() const 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 base::string16 GetWindowTitle() const OVERRIDE; | 39 virtual base::string16 GetWindowTitle() const OVERRIDE; |
40 virtual bool CanResize() const OVERRIDE; | 40 virtual bool CanResize() const OVERRIDE; |
41 | 41 |
42 private: | 42 private: |
43 views::LabelButton* button_; | 43 views::LabelButton* button_; |
44 views::LabelButton* disabled_button_; | 44 views::LabelButton* disabled_button_; |
45 views::Checkbox* checkbox_; | 45 views::Checkbox* checkbox_; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 int left = 5; | 106 int left = 5; |
107 int top = kVerticalPad; | 107 int top = kVerticalPad; |
108 for (int i = 0; i < child_count(); ++i) { | 108 for (int i = 0; i < child_count(); ++i) { |
109 views::View* view = child_at(i); | 109 views::View* view = child_at(i); |
110 gfx::Size preferred = view->GetPreferredSize(); | 110 gfx::Size preferred = view->GetPreferredSize(); |
111 view->SetBounds(left, top, preferred.width(), preferred.height()); | 111 view->SetBounds(left, top, preferred.width(), preferred.height()); |
112 top += preferred.height() + kVerticalPad; | 112 top += preferred.height() + kVerticalPad; |
113 } | 113 } |
114 } | 114 } |
115 | 115 |
116 gfx::Size WidgetsWindow::GetPreferredSize() { | 116 gfx::Size WidgetsWindow::GetPreferredSize() const { |
117 return gfx::Size(kWindowWidth, kWindowHeight); | 117 return gfx::Size(kWindowWidth, kWindowHeight); |
118 } | 118 } |
119 | 119 |
120 views::View* WidgetsWindow::GetContentsView() { | 120 views::View* WidgetsWindow::GetContentsView() { |
121 return this; | 121 return this; |
122 } | 122 } |
123 | 123 |
124 base::string16 WidgetsWindow::GetWindowTitle() const { | 124 base::string16 WidgetsWindow::GetWindowTitle() const { |
125 return base::ASCIIToUTF16("Examples: Widgets"); | 125 return base::ASCIIToUTF16("Examples: Widgets"); |
126 } | 126 } |
(...skipping 11 matching lines...) Expand all Loading... |
138 gfx::Rect bounds(kWindowLeft, kWindowTop, kWindowWidth, kWindowHeight); | 138 gfx::Rect bounds(kWindowLeft, kWindowTop, kWindowWidth, kWindowHeight); |
139 views::Widget* widget = | 139 views::Widget* widget = |
140 views::Widget::CreateWindowWithContextAndBounds( | 140 views::Widget::CreateWindowWithContextAndBounds( |
141 new WidgetsWindow, Shell::GetPrimaryRootWindow(), bounds); | 141 new WidgetsWindow, Shell::GetPrimaryRootWindow(), bounds); |
142 widget->GetNativeView()->SetName("WidgetsWindow"); | 142 widget->GetNativeView()->SetName("WidgetsWindow"); |
143 widget->Show(); | 143 widget->Show(); |
144 } | 144 } |
145 | 145 |
146 } // namespace shell | 146 } // namespace shell |
147 } // namespace ash | 147 } // namespace ash |
OLD | NEW |