| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "ui/views/widget/widget_delegate.h" | |
| 6 | |
| 7 #include "base/utf_string_conversions.h" | |
| 8 #include "third_party/skia/include/core/SkBitmap.h" | |
| 9 #include "ui/views/bubble/bubble_delegate.h" | |
| 10 #include "ui/views/widget/widget.h" | |
| 11 #include "ui/views/window/client_view.h" | |
| 12 #include "views/view.h" | |
| 13 #include "views/views_delegate.h" | |
| 14 | |
| 15 namespace views { | |
| 16 | |
| 17 //////////////////////////////////////////////////////////////////////////////// | |
| 18 // WidgetDelegate: | |
| 19 | |
| 20 WidgetDelegate::WidgetDelegate() : default_contents_view_(NULL) { | |
| 21 } | |
| 22 | |
| 23 void WidgetDelegate::OnWidgetMove() { | |
| 24 } | |
| 25 | |
| 26 void WidgetDelegate::OnDisplayChanged() { | |
| 27 } | |
| 28 | |
| 29 void WidgetDelegate::OnWorkAreaChanged() { | |
| 30 } | |
| 31 | |
| 32 View* WidgetDelegate::GetInitiallyFocusedView() { | |
| 33 return NULL; | |
| 34 } | |
| 35 | |
| 36 BubbleDelegateView* WidgetDelegate::AsBubbleDelegate() { | |
| 37 return NULL; | |
| 38 } | |
| 39 | |
| 40 DialogDelegate* WidgetDelegate::AsDialogDelegate() { | |
| 41 return NULL; | |
| 42 } | |
| 43 | |
| 44 bool WidgetDelegate::CanResize() const { | |
| 45 return false; | |
| 46 } | |
| 47 | |
| 48 bool WidgetDelegate::CanMaximize() const { | |
| 49 return false; | |
| 50 } | |
| 51 | |
| 52 bool WidgetDelegate::CanActivate() const { | |
| 53 return true; | |
| 54 } | |
| 55 | |
| 56 bool WidgetDelegate::IsModal() const { | |
| 57 return false; | |
| 58 } | |
| 59 | |
| 60 ui::AccessibilityTypes::Role WidgetDelegate::GetAccessibleWindowRole() const { | |
| 61 return ui::AccessibilityTypes::ROLE_WINDOW; | |
| 62 } | |
| 63 | |
| 64 ui::AccessibilityTypes::State WidgetDelegate::GetAccessibleWindowState() const { | |
| 65 return 0; | |
| 66 } | |
| 67 | |
| 68 string16 WidgetDelegate::GetAccessibleWindowTitle() const { | |
| 69 return GetWindowTitle(); | |
| 70 } | |
| 71 | |
| 72 string16 WidgetDelegate::GetWindowTitle() const { | |
| 73 return string16(); | |
| 74 } | |
| 75 | |
| 76 bool WidgetDelegate::ShouldShowWindowTitle() const { | |
| 77 return true; | |
| 78 } | |
| 79 | |
| 80 bool WidgetDelegate::ShouldShowClientEdge() const { | |
| 81 return true; | |
| 82 } | |
| 83 | |
| 84 SkBitmap WidgetDelegate::GetWindowAppIcon() { | |
| 85 // Use the window icon as app icon by default. | |
| 86 return GetWindowIcon(); | |
| 87 } | |
| 88 | |
| 89 // Returns the icon to be displayed in the window. | |
| 90 SkBitmap WidgetDelegate::GetWindowIcon() { | |
| 91 return SkBitmap(); | |
| 92 } | |
| 93 | |
| 94 bool WidgetDelegate::ShouldShowWindowIcon() const { | |
| 95 return false; | |
| 96 } | |
| 97 | |
| 98 bool WidgetDelegate::ExecuteWindowsCommand(int command_id) { | |
| 99 return false; | |
| 100 } | |
| 101 | |
| 102 std::string WidgetDelegate::GetWindowName() const { | |
| 103 return std::string(); | |
| 104 } | |
| 105 | |
| 106 void WidgetDelegate::SaveWindowPlacement(const gfx::Rect& bounds, | |
| 107 ui::WindowShowState show_state) { | |
| 108 std::string window_name = GetWindowName(); | |
| 109 if (!ViewsDelegate::views_delegate || window_name.empty()) | |
| 110 return; | |
| 111 | |
| 112 ViewsDelegate::views_delegate->SaveWindowPlacement( | |
| 113 GetWidget(), window_name, bounds, show_state); | |
| 114 } | |
| 115 | |
| 116 bool WidgetDelegate::GetSavedWindowPlacement( | |
| 117 gfx::Rect* bounds, | |
| 118 ui::WindowShowState* show_state) const { | |
| 119 std::string window_name = GetWindowName(); | |
| 120 if (!ViewsDelegate::views_delegate || window_name.empty()) | |
| 121 return false; | |
| 122 | |
| 123 return ViewsDelegate::views_delegate->GetSavedWindowPlacement( | |
| 124 window_name, bounds, show_state); | |
| 125 } | |
| 126 | |
| 127 bool WidgetDelegate::ShouldRestoreWindowSize() const { | |
| 128 return true; | |
| 129 } | |
| 130 | |
| 131 View* WidgetDelegate::GetContentsView() { | |
| 132 if (!default_contents_view_) | |
| 133 default_contents_view_ = new View; | |
| 134 return default_contents_view_; | |
| 135 } | |
| 136 | |
| 137 ClientView* WidgetDelegate::CreateClientView(Widget* widget) { | |
| 138 return new ClientView(widget, GetContentsView()); | |
| 139 } | |
| 140 | |
| 141 NonClientFrameView* WidgetDelegate::CreateNonClientFrameView() { | |
| 142 return NULL; | |
| 143 } | |
| 144 | |
| 145 bool WidgetDelegate::WillProcessWorkAreaChange() const { | |
| 146 return false; | |
| 147 } | |
| 148 | |
| 149 //////////////////////////////////////////////////////////////////////////////// | |
| 150 // WidgetDelegateView: | |
| 151 | |
| 152 WidgetDelegateView::WidgetDelegateView() { | |
| 153 } | |
| 154 | |
| 155 WidgetDelegateView::~WidgetDelegateView() { | |
| 156 } | |
| 157 | |
| 158 Widget* WidgetDelegateView::GetWidget() { | |
| 159 return View::GetWidget(); | |
| 160 } | |
| 161 | |
| 162 const Widget* WidgetDelegateView::GetWidget() const { | |
| 163 return View::GetWidget(); | |
| 164 } | |
| 165 | |
| 166 } // namespace views | |
| OLD | NEW |