| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/status_area/status_area_view.h" | 5 #include "ash/status_area/status_area_view.h" |
| 6 | 6 |
| 7 #include "ash/ash_export.h" | 7 #include "ash/ash_export.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/shell_window_ids.h" | 9 #include "ash/shell_window_ids.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 11 #include "grit/ui_resources.h" | 11 #include "grit/ui_resources.h" |
| 12 #include "ui/aura/root_window.h" | 12 #include "ui/aura/root_window.h" |
| 13 #include "ui/base/resource/resource_bundle.h" | 13 #include "ui/base/resource/resource_bundle.h" |
| 14 #include "ui/gfx/canvas.h" | 14 #include "ui/gfx/canvas.h" |
| 15 #include "ui/views/widget/widget.h" | 15 #include "ui/views/widget/widget.h" |
| 16 | 16 |
| 17 namespace aura_shell { | 17 namespace ash { |
| 18 namespace internal { | 18 namespace internal { |
| 19 | 19 |
| 20 StatusAreaView::StatusAreaView() | 20 StatusAreaView::StatusAreaView() |
| 21 : status_mock_(*ResourceBundle::GetSharedInstance().GetBitmapNamed( | 21 : status_mock_(*ResourceBundle::GetSharedInstance().GetBitmapNamed( |
| 22 IDR_AURA_STATUS_MOCK)) { | 22 IDR_AURA_STATUS_MOCK)) { |
| 23 } | 23 } |
| 24 StatusAreaView::~StatusAreaView() { | 24 StatusAreaView::~StatusAreaView() { |
| 25 } | 25 } |
| 26 | 26 |
| 27 gfx::Size StatusAreaView::GetPreferredSize() { | 27 gfx::Size StatusAreaView::GetPreferredSize() { |
| 28 return gfx::Size(status_mock_.width(), status_mock_.height()); | 28 return gfx::Size(status_mock_.width(), status_mock_.height()); |
| 29 } | 29 } |
| 30 | 30 |
| 31 void StatusAreaView::OnPaint(gfx::Canvas* canvas) { | 31 void StatusAreaView::OnPaint(gfx::Canvas* canvas) { |
| 32 canvas->DrawBitmapInt(status_mock_, 0, 0); | 32 canvas->DrawBitmapInt(status_mock_, 0, 0); |
| 33 } | 33 } |
| 34 | 34 |
| 35 ASH_EXPORT views::Widget* CreateStatusArea() { | 35 ASH_EXPORT views::Widget* CreateStatusArea() { |
| 36 StatusAreaView* status_area_view = new StatusAreaView; | 36 StatusAreaView* status_area_view = new StatusAreaView; |
| 37 views::Widget* widget = new views::Widget; | 37 views::Widget* widget = new views::Widget; |
| 38 views::Widget::InitParams params(views::Widget::InitParams::TYPE_CONTROL); | 38 views::Widget::InitParams params(views::Widget::InitParams::TYPE_CONTROL); |
| 39 gfx::Size ps = status_area_view->GetPreferredSize(); | 39 gfx::Size ps = status_area_view->GetPreferredSize(); |
| 40 params.bounds = gfx::Rect(0, 0, ps.width(), ps.height()); | 40 params.bounds = gfx::Rect(0, 0, ps.width(), ps.height()); |
| 41 params.parent = Shell::GetInstance()->GetContainer( | 41 params.parent = Shell::GetInstance()->GetContainer( |
| 42 aura_shell::internal::kShellWindowId_StatusContainer); | 42 ash::internal::kShellWindowId_StatusContainer); |
| 43 params.delegate = status_area_view; | 43 params.delegate = status_area_view; |
| 44 params.transparent = true; | 44 params.transparent = true; |
| 45 widget->Init(params); | 45 widget->Init(params); |
| 46 widget->SetContentsView(status_area_view); | 46 widget->SetContentsView(status_area_view); |
| 47 widget->Show(); | 47 widget->Show(); |
| 48 widget->GetNativeView()->SetName("StatusAreaView"); | 48 widget->GetNativeView()->SetName("StatusAreaView"); |
| 49 return widget; | 49 return widget; |
| 50 } | 50 } |
| 51 | 51 |
| 52 } // namespace internal | 52 } // namespace internal |
| 53 } // namespace aura_shell | 53 } // namespace ash |
| OLD | NEW |