diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-25 23:10:18 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-25 23:10:18 +0000 |
commit | 601160029a2e7d6f4f634e9b26331f510449209b (patch) | |
tree | 2c655d1e53e73a196a8151428505bbd6d482d7b5 /views/window | |
parent | 24d692aa555b5673c3d6eb37252b6eec19f439b5 (diff) | |
download | chromium_src-601160029a2e7d6f4f634e9b26331f510449209b.zip chromium_src-601160029a2e7d6f4f634e9b26331f510449209b.tar.gz chromium_src-601160029a2e7d6f4f634e9b26331f510449209b.tar.bz2 |
Adds a basic NativeWindowViews.
http://crbug.com/83663
TEST=none
Review URL: http://codereview.chromium.org/7069022
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86736 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/window')
-rw-r--r-- | views/window/native_window_gtk.cc | 3 | ||||
-rw-r--r-- | views/window/native_window_views.cc | 171 | ||||
-rw-r--r-- | views/window/native_window_views.h | 74 | ||||
-rw-r--r-- | views/window/native_window_win.cc | 6 | ||||
-rw-r--r-- | views/window/window.cc | 4 |
5 files changed, 251 insertions, 7 deletions
diff --git a/views/window/native_window_gtk.cc b/views/window/native_window_gtk.cc index e54deb9..4e25fb4 100644 --- a/views/window/native_window_gtk.cc +++ b/views/window/native_window_gtk.cc @@ -11,7 +11,6 @@ #include "ui/gfx/rect.h" #include "views/events/event.h" #include "views/screen.h" -#include "views/window/custom_frame_view.h" #include "views/window/hit_test.h" #include "views/window/native_window_delegate.h" #include "views/window/non_client_view.h" @@ -364,7 +363,7 @@ void NativeWindowGtk::SetUseDragFrame(bool use_drag_frame) { } NonClientFrameView* NativeWindowGtk::CreateFrameViewForWindow() { - return new CustomFrameView(delegate_->AsWindow()); + return NULL; } void NativeWindowGtk::SetAlwaysOnTop(bool always_on_top) { diff --git a/views/window/native_window_views.cc b/views/window/native_window_views.cc new file mode 100644 index 0000000..3957835 --- /dev/null +++ b/views/window/native_window_views.cc @@ -0,0 +1,171 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "views/window/native_window_views.h" + +#include "views/view.h" + +namespace views { + +//////////////////////////////////////////////////////////////////////////////// +// NativeWindowViews, public: + +NativeWindowViews::NativeWindowViews(View* host, + internal::NativeWindowDelegate* delegate) + : NativeWidgetViews(host, delegate->AsNativeWidgetDelegate()), + delegate_(delegate) { +} + +NativeWindowViews::~NativeWindowViews() { +} + +//////////////////////////////////////////////////////////////////////////////// +// NativeWindowViews, NativeWindow implementation: + +Window* NativeWindowViews::GetWindow() { + return delegate_->AsWindow(); +} + +const Window* NativeWindowViews::GetWindow() const { + return delegate_->AsWindow(); +} + +NativeWidget* NativeWindowViews::AsNativeWidget() { + return this; +} + +const NativeWidget* NativeWindowViews::AsNativeWidget() const { + return this; +} + +gfx::Rect NativeWindowViews::GetRestoredBounds() const { + NOTIMPLEMENTED(); + return GetView()->bounds(); +} + +void NativeWindowViews::ShowNativeWindow(ShowState state) { + NOTIMPLEMENTED(); + GetView()->SetVisible(true); +} + +void NativeWindowViews::BecomeModal() { + NOTIMPLEMENTED(); +} + +void NativeWindowViews::CenterWindow(const gfx::Size& size) { + // TODO(beng): actually center. + GetView()->SetBounds(0, 0, size.width(), size.height()); +} + +void NativeWindowViews::GetWindowBoundsAndMaximizedState( + gfx::Rect* bounds, + bool* maximized) const { + *bounds = GetView()->bounds(); + *maximized = false; +} + +void NativeWindowViews::EnableClose(bool enable) { +} + +void NativeWindowViews::SetWindowTitle(const std::wstring& title) { +} + +void NativeWindowViews::SetWindowIcons(const SkBitmap& window_icon, + const SkBitmap& app_icon) { +} + +void NativeWindowViews::SetAccessibleName(const std::wstring& name) { +} + +void NativeWindowViews::SetAccessibleRole(ui::AccessibilityTypes::Role role) { +} + +void NativeWindowViews::SetAccessibleState( + ui::AccessibilityTypes::State state) { +} + +void NativeWindowViews::SetWindowBounds(const gfx::Rect& bounds, + gfx::NativeWindow other_window) { + if (other_window) + NOTIMPLEMENTED(); + GetView()->SetBoundsRect(bounds); +} + +void NativeWindowViews::HideWindow() { + GetView()->SetVisible(false); +} + +void NativeWindowViews::Activate() { + NOTIMPLEMENTED(); +} + +void NativeWindowViews::Deactivate() { + NOTIMPLEMENTED(); +} + +void NativeWindowViews::Maximize() { + NOTIMPLEMENTED(); +} + +void NativeWindowViews::Minimize() { + NOTIMPLEMENTED(); +} + +void NativeWindowViews::Restore() { + NOTIMPLEMENTED(); +} + +bool NativeWindowViews::IsActive() const { + NOTIMPLEMENTED(); + return false; +} + +bool NativeWindowViews::IsVisible() const { + return GetView()->IsVisible(); +} + +bool NativeWindowViews::IsMaximized() const { + NOTIMPLEMENTED(); + return false; +} + +bool NativeWindowViews::IsMinimized() const { + NOTIMPLEMENTED(); + return false; +} + +void NativeWindowViews::SetFullscreen(bool fullscreen) { +} + +bool NativeWindowViews::IsFullscreen() const { + NOTIMPLEMENTED(); + return false; +} + +void NativeWindowViews::SetAlwaysOnTop(bool always_on_top) { +} + +void NativeWindowViews::SetUseDragFrame(bool use_drag_frame) { +} + +NonClientFrameView* NativeWindowViews::CreateFrameViewForWindow() { + return NULL; +} + +void NativeWindowViews::UpdateFrameAfterFrameChange() { +} + +gfx::NativeWindow NativeWindowViews::GetNativeWindow() const { + return NULL; +} + +bool NativeWindowViews::ShouldUseNativeFrame() const { + NOTIMPLEMENTED(); + return false; +} + +void NativeWindowViews::FrameTypeChanged() { +} + +} // namespace views diff --git a/views/window/native_window_views.h b/views/window/native_window_views.h new file mode 100644 index 0000000..65a4310 --- /dev/null +++ b/views/window/native_window_views.h @@ -0,0 +1,74 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef VIEWS_WINDOW_NATIVE_WINDOW_VIEWS_H_ +#define VIEWS_WINDOW_NATIVE_WINDOW_VIEWS_H_ +#pragma once + +#include "base/message_loop.h" +#include "views/window/native_window.h" +#include "views/widget/native_widget_views.h" + +namespace views { + +//////////////////////////////////////////////////////////////////////////////// +// NativeWindowViews +// +// A NativeWindow implementation that uses another View as its native widget. +// +class NativeWindowViews : public NativeWidgetViews, + public NativeWindow { + public: + NativeWindowViews(View* host, internal::NativeWindowDelegate* delegate); + virtual ~NativeWindowViews(); + + private: + // Overridden from NativeWindow: + virtual Window* GetWindow() OVERRIDE; + virtual const Window* GetWindow() const OVERRIDE; + virtual NativeWidget* AsNativeWidget() OVERRIDE; + virtual const NativeWidget* AsNativeWidget() const OVERRIDE; + virtual gfx::Rect GetRestoredBounds() const OVERRIDE; + virtual void ShowNativeWindow(ShowState state) OVERRIDE; + virtual void BecomeModal() OVERRIDE; + virtual void CenterWindow(const gfx::Size& size) OVERRIDE; + virtual void GetWindowBoundsAndMaximizedState(gfx::Rect* bounds, + bool* maximized) const OVERRIDE; + virtual void EnableClose(bool enable) OVERRIDE; + virtual void SetWindowTitle(const std::wstring& title) OVERRIDE; + virtual void SetWindowIcons(const SkBitmap& window_icon, + const SkBitmap& app_icon) OVERRIDE; + virtual void SetAccessibleName(const std::wstring& name) OVERRIDE; + virtual void SetAccessibleRole(ui::AccessibilityTypes::Role role) OVERRIDE; + virtual void SetAccessibleState(ui::AccessibilityTypes::State state) OVERRIDE; + virtual void SetWindowBounds(const gfx::Rect& bounds, + gfx::NativeWindow other_window) OVERRIDE; + virtual void HideWindow() OVERRIDE; + virtual void Activate() OVERRIDE; + virtual void Deactivate() OVERRIDE; + virtual void Maximize() OVERRIDE; + virtual void Minimize() OVERRIDE; + virtual void Restore() OVERRIDE; + virtual bool IsActive() const OVERRIDE; + virtual bool IsVisible() const OVERRIDE; + virtual bool IsMaximized() const OVERRIDE; + virtual bool IsMinimized() const OVERRIDE; + virtual void SetFullscreen(bool fullscreen) OVERRIDE; + virtual bool IsFullscreen() const OVERRIDE; + virtual void SetAlwaysOnTop(bool always_on_top) OVERRIDE; + virtual void SetUseDragFrame(bool use_drag_frame) OVERRIDE; + virtual NonClientFrameView* CreateFrameViewForWindow() OVERRIDE; + virtual void UpdateFrameAfterFrameChange() OVERRIDE; + virtual gfx::NativeWindow GetNativeWindow() const OVERRIDE; + virtual bool ShouldUseNativeFrame() const OVERRIDE; + virtual void FrameTypeChanged() OVERRIDE; + + internal::NativeWindowDelegate* delegate_; + + DISALLOW_COPY_AND_ASSIGN(NativeWindowViews); +}; + +} + +#endif // VIEWS_WINDOW_NATIVE_WINDOW_VIEWS_H_ diff --git a/views/window/native_window_win.cc b/views/window/native_window_win.cc index b7708d8..fed8173 100644 --- a/views/window/native_window_win.cc +++ b/views/window/native_window_win.cc @@ -22,7 +22,6 @@ #include "ui/gfx/path.h" #include "views/accessibility/native_view_accessibility_win.h" #include "views/window/client_view.h" -#include "views/window/custom_frame_view.h" #include "views/window/native_window_delegate.h" #include "views/window/native_frame_view.h" #include "views/window/non_client_view.h" @@ -1308,9 +1307,8 @@ void NativeWindowWin::SetUseDragFrame(bool use_drag_frame) { } NonClientFrameView* NativeWindowWin::CreateFrameViewForWindow() { - if (GetWindow()->ShouldUseNativeFrame()) - return new NativeFrameView(GetWindow()); - return new CustomFrameView(GetWindow()); + return GetWindow()->ShouldUseNativeFrame() ? + new NativeFrameView(GetWindow()) : NULL; } void NativeWindowWin::UpdateFrameAfterFrameChange() { diff --git a/views/window/window.cc b/views/window/window.cc index 7af6bfa..f2d51ee 100644 --- a/views/window/window.cc +++ b/views/window/window.cc @@ -14,6 +14,7 @@ #include "ui/gfx/size.h" #include "views/widget/widget.h" #include "views/widget/native_widget.h" +#include "views/window/custom_frame_view.h" #include "views/window/native_window.h" #include "views/window/window_delegate.h" @@ -229,7 +230,8 @@ void Window::SetIsAlwaysOnTop(bool always_on_top) { } NonClientFrameView* Window::CreateFrameViewForWindow() { - return native_window_->CreateFrameViewForWindow(); + NonClientFrameView* frame_view = native_window_->CreateFrameViewForWindow(); + return frame_view ? frame_view : new CustomFrameView(this); } void Window::UpdateFrameAfterFrameChange() { |