native_widget_mac.mm revision f8ee788a64d60abd8f2d742a5fdedde054ecd910
1// Copyright 2014 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/native_widget_mac.h" 6 7#import <Cocoa/Cocoa.h> 8 9#include "base/mac/scoped_nsobject.h" 10#include "ui/gfx/font_list.h" 11#include "ui/native_theme/native_theme.h" 12#import "ui/views/cocoa/bridged_content_view.h" 13#import "ui/views/cocoa/bridged_native_widget.h" 14 15namespace views { 16 17//////////////////////////////////////////////////////////////////////////////// 18// NativeWidgetMac, public: 19 20NativeWidgetMac::NativeWidgetMac(internal::NativeWidgetDelegate* delegate) 21 : delegate_(delegate), bridge_(new BridgedNativeWidget) { 22} 23 24NativeWidgetMac::~NativeWidgetMac() { 25} 26 27//////////////////////////////////////////////////////////////////////////////// 28// NativeWidgetMac, internal::NativeWidgetPrivate implementation: 29 30void NativeWidgetMac::InitNativeWidget(const Widget::InitParams& params) { 31 // TODO(tapted): Convert position into Cocoa's flipped coordinate space. 32 NSRect content_rect = 33 NSMakeRect(0, 0, params.bounds.width(), params.bounds.height()); 34 // TODO(tapted): Determine a good initial style mask from |params|. 35 NSInteger style_mask = NSTitledWindowMask | NSClosableWindowMask | 36 NSMiniaturizableWindowMask | NSResizableWindowMask; 37 base::scoped_nsobject<NSWindow> window( 38 [[NSWindow alloc] initWithContentRect:content_rect 39 styleMask:style_mask 40 backing:NSBackingStoreBuffered 41 defer:NO]); 42 bridge_->Init(window); 43} 44 45NonClientFrameView* NativeWidgetMac::CreateNonClientFrameView() { 46 return NULL; 47} 48 49bool NativeWidgetMac::ShouldUseNativeFrame() const { 50 return false; 51} 52 53bool NativeWidgetMac::ShouldWindowContentsBeTransparent() const { 54 NOTIMPLEMENTED(); 55 return false; 56} 57 58void NativeWidgetMac::FrameTypeChanged() { 59 NOTIMPLEMENTED(); 60} 61 62Widget* NativeWidgetMac::GetWidget() { 63 return delegate_->AsWidget(); 64} 65 66const Widget* NativeWidgetMac::GetWidget() const { 67 return delegate_->AsWidget(); 68} 69 70gfx::NativeView NativeWidgetMac::GetNativeView() const { 71 return bridge_->ns_view(); 72} 73 74gfx::NativeWindow NativeWidgetMac::GetNativeWindow() const { 75 return bridge_->ns_window(); 76} 77 78Widget* NativeWidgetMac::GetTopLevelWidget() { 79 NOTIMPLEMENTED(); 80 return GetWidget(); 81} 82 83const ui::Compositor* NativeWidgetMac::GetCompositor() const { 84 NOTIMPLEMENTED(); 85 return NULL; 86} 87 88ui::Compositor* NativeWidgetMac::GetCompositor() { 89 NOTIMPLEMENTED(); 90 return NULL; 91} 92 93ui::Layer* NativeWidgetMac::GetLayer() { 94 NOTIMPLEMENTED(); 95 return NULL; 96} 97 98void NativeWidgetMac::ReorderNativeViews() { 99 bridge_->SetRootView(GetWidget()->GetRootView()); 100} 101 102void NativeWidgetMac::ViewRemoved(View* view) { 103 NOTIMPLEMENTED(); 104} 105 106void NativeWidgetMac::SetNativeWindowProperty(const char* name, void* value) { 107 NOTIMPLEMENTED(); 108} 109 110void* NativeWidgetMac::GetNativeWindowProperty(const char* name) const { 111 NOTIMPLEMENTED(); 112 return NULL; 113} 114 115TooltipManager* NativeWidgetMac::GetTooltipManager() const { 116 NOTIMPLEMENTED(); 117 return NULL; 118} 119 120void NativeWidgetMac::SetCapture() { 121 NOTIMPLEMENTED(); 122} 123 124void NativeWidgetMac::ReleaseCapture() { 125 NOTIMPLEMENTED(); 126} 127 128bool NativeWidgetMac::HasCapture() const { 129 NOTIMPLEMENTED(); 130 return false; 131} 132 133InputMethod* NativeWidgetMac::CreateInputMethod() { 134 return bridge_->CreateInputMethod(); 135} 136 137internal::InputMethodDelegate* NativeWidgetMac::GetInputMethodDelegate() { 138 return bridge_.get(); 139} 140 141ui::InputMethod* NativeWidgetMac::GetHostInputMethod() { 142 return bridge_->GetHostInputMethod(); 143} 144 145void NativeWidgetMac::CenterWindow(const gfx::Size& size) { 146 NOTIMPLEMENTED(); 147} 148 149void NativeWidgetMac::GetWindowPlacement(gfx::Rect* bounds, 150 ui::WindowShowState* maximized) const { 151 NOTIMPLEMENTED(); 152} 153 154bool NativeWidgetMac::SetWindowTitle(const base::string16& title) { 155 NOTIMPLEMENTED(); 156 return false; 157} 158 159void NativeWidgetMac::SetWindowIcons(const gfx::ImageSkia& window_icon, 160 const gfx::ImageSkia& app_icon) { 161 NOTIMPLEMENTED(); 162} 163 164void NativeWidgetMac::InitModalType(ui::ModalType modal_type) { 165 NOTIMPLEMENTED(); 166} 167 168gfx::Rect NativeWidgetMac::GetWindowBoundsInScreen() const { 169 NOTIMPLEMENTED(); 170 return gfx::Rect(); 171} 172 173gfx::Rect NativeWidgetMac::GetClientAreaBoundsInScreen() const { 174 NOTIMPLEMENTED(); 175 return gfx::Rect(); 176} 177 178gfx::Rect NativeWidgetMac::GetRestoredBounds() const { 179 NOTIMPLEMENTED(); 180 return gfx::Rect(); 181} 182 183void NativeWidgetMac::SetBounds(const gfx::Rect& bounds) { 184 NOTIMPLEMENTED(); 185} 186 187void NativeWidgetMac::SetSize(const gfx::Size& size) { 188 [bridge_->ns_window() setContentSize:NSMakeSize(size.width(), size.height())]; 189} 190 191void NativeWidgetMac::StackAbove(gfx::NativeView native_view) { 192 NOTIMPLEMENTED(); 193} 194 195void NativeWidgetMac::StackAtTop() { 196 NOTIMPLEMENTED(); 197} 198 199void NativeWidgetMac::StackBelow(gfx::NativeView native_view) { 200 NOTIMPLEMENTED(); 201} 202 203void NativeWidgetMac::SetShape(gfx::NativeRegion shape) { 204 NOTIMPLEMENTED(); 205} 206 207void NativeWidgetMac::Close() { 208 NOTIMPLEMENTED(); 209} 210 211void NativeWidgetMac::CloseNow() { 212 NOTIMPLEMENTED(); 213} 214 215void NativeWidgetMac::Show() { 216 NOTIMPLEMENTED(); 217} 218 219void NativeWidgetMac::Hide() { 220 NOTIMPLEMENTED(); 221} 222 223void NativeWidgetMac::ShowMaximizedWithBounds( 224 const gfx::Rect& restored_bounds) { 225 NOTIMPLEMENTED(); 226} 227 228void NativeWidgetMac::ShowWithWindowState(ui::WindowShowState state) { 229 NOTIMPLEMENTED(); 230} 231 232bool NativeWidgetMac::IsVisible() const { 233 NOTIMPLEMENTED(); 234 return true; 235} 236 237void NativeWidgetMac::Activate() { 238 NOTIMPLEMENTED(); 239} 240 241void NativeWidgetMac::Deactivate() { 242 NOTIMPLEMENTED(); 243} 244 245bool NativeWidgetMac::IsActive() const { 246 NOTIMPLEMENTED(); 247 return true; 248} 249 250void NativeWidgetMac::SetAlwaysOnTop(bool always_on_top) { 251 NOTIMPLEMENTED(); 252} 253 254bool NativeWidgetMac::IsAlwaysOnTop() const { 255 NOTIMPLEMENTED(); 256 return false; 257} 258 259void NativeWidgetMac::SetVisibleOnAllWorkspaces(bool always_visible) { 260 NOTIMPLEMENTED(); 261} 262 263void NativeWidgetMac::Maximize() { 264 NOTIMPLEMENTED(); 265} 266 267void NativeWidgetMac::Minimize() { 268 NOTIMPLEMENTED(); 269} 270 271bool NativeWidgetMac::IsMaximized() const { 272 NOTIMPLEMENTED(); 273 return false; 274} 275 276bool NativeWidgetMac::IsMinimized() const { 277 NOTIMPLEMENTED(); 278 return false; 279} 280 281void NativeWidgetMac::Restore() { 282 NOTIMPLEMENTED(); 283} 284 285void NativeWidgetMac::SetFullscreen(bool fullscreen) { 286 NOTIMPLEMENTED(); 287} 288 289bool NativeWidgetMac::IsFullscreen() const { 290 NOTIMPLEMENTED(); 291 return false; 292} 293 294void NativeWidgetMac::SetOpacity(unsigned char opacity) { 295 NOTIMPLEMENTED(); 296} 297 298void NativeWidgetMac::SetUseDragFrame(bool use_drag_frame) { 299 NOTIMPLEMENTED(); 300} 301 302void NativeWidgetMac::FlashFrame(bool flash_frame) { 303 NOTIMPLEMENTED(); 304} 305 306void NativeWidgetMac::RunShellDrag(View* view, 307 const ui::OSExchangeData& data, 308 const gfx::Point& location, 309 int operation, 310 ui::DragDropTypes::DragEventSource source) { 311 NOTIMPLEMENTED(); 312} 313 314void NativeWidgetMac::SchedulePaintInRect(const gfx::Rect& rect) { 315 // TODO(tapted): This should use setNeedsDisplayInRect:, once the coordinate 316 // system of |rect| has been converted. 317 [bridge_->ns_view() setNeedsDisplay:YES]; 318} 319 320void NativeWidgetMac::SetCursor(gfx::NativeCursor cursor) { 321 NOTIMPLEMENTED(); 322} 323 324bool NativeWidgetMac::IsMouseEventsEnabled() const { 325 NOTIMPLEMENTED(); 326 return true; 327} 328 329void NativeWidgetMac::ClearNativeFocus() { 330 NOTIMPLEMENTED(); 331} 332 333gfx::Rect NativeWidgetMac::GetWorkAreaBoundsInScreen() const { 334 NOTIMPLEMENTED(); 335 return gfx::Rect(); 336} 337 338Widget::MoveLoopResult NativeWidgetMac::RunMoveLoop( 339 const gfx::Vector2d& drag_offset, 340 Widget::MoveLoopSource source, 341 Widget::MoveLoopEscapeBehavior escape_behavior) { 342 NOTIMPLEMENTED(); 343 return Widget::MOVE_LOOP_CANCELED; 344} 345 346void NativeWidgetMac::EndMoveLoop() { 347 NOTIMPLEMENTED(); 348} 349 350void NativeWidgetMac::SetVisibilityChangedAnimationsEnabled(bool value) { 351 NOTIMPLEMENTED(); 352} 353 354ui::NativeTheme* NativeWidgetMac::GetNativeTheme() const { 355 return ui::NativeTheme::instance(); 356} 357 358void NativeWidgetMac::OnRootViewLayout() const { 359 NOTIMPLEMENTED(); 360} 361 362void NativeWidgetMac::RepostNativeEvent(gfx::NativeEvent native_event) { 363 NOTIMPLEMENTED(); 364} 365 366//////////////////////////////////////////////////////////////////////////////// 367// Widget, public: 368 369bool Widget::ConvertRect(const Widget* source, 370 const Widget* target, 371 gfx::Rect* rect) { 372 return false; 373} 374 375namespace internal { 376 377//////////////////////////////////////////////////////////////////////////////// 378// internal::NativeWidgetPrivate, public: 379 380// static 381NativeWidgetPrivate* NativeWidgetPrivate::CreateNativeWidget( 382 internal::NativeWidgetDelegate* delegate) { 383 return new NativeWidgetMac(delegate); 384} 385 386// static 387NativeWidgetPrivate* NativeWidgetPrivate::GetNativeWidgetForNativeView( 388 gfx::NativeView native_view) { 389 NOTIMPLEMENTED(); 390 return NULL; 391} 392 393// static 394NativeWidgetPrivate* NativeWidgetPrivate::GetNativeWidgetForNativeWindow( 395 gfx::NativeWindow native_window) { 396 NOTIMPLEMENTED(); 397 return NULL; 398} 399 400// static 401NativeWidgetPrivate* NativeWidgetPrivate::GetTopLevelNativeWidget( 402 gfx::NativeView native_view) { 403 NOTIMPLEMENTED(); 404 return NULL; 405} 406 407// static 408void NativeWidgetPrivate::GetAllChildWidgets(gfx::NativeView native_view, 409 Widget::Widgets* children) { 410 NOTIMPLEMENTED(); 411} 412 413// static 414void NativeWidgetPrivate::GetAllOwnedWidgets(gfx::NativeView native_view, 415 Widget::Widgets* owned) { 416 NOTIMPLEMENTED(); 417} 418 419// static 420void NativeWidgetPrivate::ReparentNativeView(gfx::NativeView native_view, 421 gfx::NativeView new_parent) { 422 NOTIMPLEMENTED(); 423} 424 425// static 426bool NativeWidgetPrivate::IsMouseButtonDown() { 427 NOTIMPLEMENTED(); 428 return false; 429} 430 431// static 432bool NativeWidgetPrivate::IsTouchDown() { 433 NOTIMPLEMENTED(); 434 return false; 435} 436 437// static 438gfx::FontList NativeWidgetPrivate::GetWindowTitleFontList() { 439 NOTIMPLEMENTED(); 440 return gfx::FontList(); 441} 442 443} // namespace internal 444} // namespace views 445