Integrate the notification database with the normal code path.
[chromium-blink-merge.git] / ash / shell / panel_window.cc
blobf092aa8ce376244c9b425e1a6773d303fc54544d
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/panel_window.h"
7 #include "ash/screen_util.h"
8 #include "ash/shell.h"
9 #include "ash/wm/panels/panel_frame_view.h"
10 #include "base/strings/utf_string_conversions.h"
11 #include "ui/aura/window.h"
12 #include "ui/aura/window_event_dispatcher.h"
13 #include "ui/gfx/canvas.h"
14 #include "ui/views/widget/widget.h"
16 namespace {
17 const int kMinWidth = 100;
18 const int kMinHeight = 100;
19 const int kDefaultWidth = 200;
20 const int kDefaultHeight = 300;
23 namespace ash {
25 // static
26 views::Widget* PanelWindow::CreatePanelWindow(const gfx::Rect& rect) {
27 PanelWindow* panel_window = new PanelWindow("Example Panel Window");
28 panel_window->params().bounds = rect;
29 panel_window->params().context = Shell::GetPrimaryRootWindow();
30 return panel_window->CreateWidget();
33 PanelWindow::PanelWindow(const std::string& name)
34 : name_(name),
35 params_(views::Widget::InitParams::TYPE_PANEL) {
36 params_.delegate = this;
39 PanelWindow::~PanelWindow() {
42 views::Widget* PanelWindow::CreateWidget() {
43 views::Widget* widget = new views::Widget;
45 if (params().bounds.width() == 0)
46 params().bounds.set_width(kDefaultWidth);
47 if (params().bounds.height() == 0)
48 params().bounds.set_height(kDefaultHeight);
49 params().bounds = ScreenUtil::ConvertRectToScreen(
50 Shell::GetTargetRootWindow(),
51 params().bounds);
53 widget->Init(params());
54 widget->GetNativeView()->SetName(name_);
55 widget->Show();
57 return widget;
60 gfx::Size PanelWindow::GetPreferredSize() const {
61 return gfx::Size(kMinWidth, kMinHeight);
64 void PanelWindow::OnPaint(gfx::Canvas* canvas) {
65 canvas->FillRect(GetLocalBounds(), SK_ColorGREEN);
68 base::string16 PanelWindow::GetWindowTitle() const {
69 return base::ASCIIToUTF16(name_);
72 views::View* PanelWindow::GetContentsView() {
73 return this;
76 bool PanelWindow::CanResize() const {
77 return true;
80 bool PanelWindow::CanMaximize() const {
81 return false;
84 bool PanelWindow::CanMinimize() const {
85 return false;
88 views::NonClientFrameView* PanelWindow::CreateNonClientFrameView(
89 views::Widget* widget) {
90 return new PanelFrameView(widget, PanelFrameView::FRAME_NONE);
93 } // namespace ash