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
3 // found in the LICENSE file.
5 #include "ash/shell/toplevel_window.h"
7 #include "ash/display/display_controller.h"
8 #include "ash/screen_ash.h"
10 #include "ash/wm/property_util.h"
11 #include "base/strings/utf_string_conversions.h"
12 #include "ui/aura/root_window.h"
13 #include "ui/aura/window.h"
14 #include "ui/gfx/canvas.h"
15 #include "ui/views/widget/widget.h"
20 ToplevelWindow::CreateParams::CreateParams()
26 void ToplevelWindow::CreateToplevelWindow(const CreateParams
& params
) {
28 int x
= count
== 0 ? 150 : 750;
29 count
= (count
+ 1) % 2;
31 gfx::Rect
bounds(x
, 150, 300, 300);
32 gfx::Display display
=
33 ash::Shell::GetScreen()->GetDisplayMatching(bounds
);
34 aura::RootWindow
* root
= ash::Shell::GetInstance()->display_controller()->
35 GetRootWindowForDisplayId(display
.id());
36 views::Widget
* widget
= views::Widget::CreateWindowWithContextAndBounds(
37 new ToplevelWindow(params
), root
, bounds
);
38 widget
->GetNativeView()->SetName("Examples:ToplevelWindow");
42 ToplevelWindow::ToplevelWindow(const CreateParams
& params
) : params_(params
) {
45 ToplevelWindow::~ToplevelWindow() {
48 void ToplevelWindow::OnPaint(gfx::Canvas
* canvas
) {
49 canvas
->FillRect(GetLocalBounds(), SK_ColorDKGRAY
);
52 base::string16
ToplevelWindow::GetWindowTitle() const {
53 return ASCIIToUTF16("Examples: Toplevel Window");
56 views::View
* ToplevelWindow::GetContentsView() {
60 bool ToplevelWindow::CanResize() const {
61 return params_
.can_resize
;
64 bool ToplevelWindow::CanMaximize() const {
65 return params_
.can_maximize
;