diff options
author | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-13 23:39:52 +0000 |
---|---|---|
committer | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-13 23:39:52 +0000 |
commit | 8e63df81baee6cc66979255525cd900e00977969 (patch) | |
tree | d93875f1842c02249af3bda5dc18cf43c9f615dc /views | |
parent | 1a2b090f457dc1bcc6dda99fe54639f9d1ad0f20 (diff) | |
download | chromium_src-8e63df81baee6cc66979255525cd900e00977969.zip chromium_src-8e63df81baee6cc66979255525cd900e00977969.tar.gz chromium_src-8e63df81baee6cc66979255525cd900e00977969.tar.bz2 |
Allow different kinds of 'desktops'.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/7315007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@92447 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r-- | views/desktop/desktop_main.cc | 3 | ||||
-rw-r--r-- | views/desktop/desktop_window_view.cc | 44 | ||||
-rw-r--r-- | views/desktop/desktop_window_view.h | 19 | ||||
-rw-r--r-- | views/views.gyp | 1 | ||||
-rw-r--r-- | views/widget/native_widget_views.cc | 4 | ||||
-rw-r--r-- | views/window/native_frame_view.cc | 12 |
6 files changed, 70 insertions, 13 deletions
diff --git a/views/desktop/desktop_main.cc b/views/desktop/desktop_main.cc index 2ea6469..09db616 100644 --- a/views/desktop/desktop_main.cc +++ b/views/desktop/desktop_main.cc @@ -46,7 +46,8 @@ int main(int argc, char** argv) { // Desktop mode only supports a pure-views configuration. views::Widget::SetPureViews(true); - views::desktop::DesktopWindowView::CreateDesktopWindow(); + views::desktop::DesktopWindowView::CreateDesktopWindow( + views::desktop::DesktopWindowView::DESKTOP_DEFAULT); views::desktop::DesktopWindowView::desktop_window_view->CreateTestWindow( L"Sample Window 1", SK_ColorWHITE, gfx::Rect(500, 200, 400, 400), true); views::desktop::DesktopWindowView::desktop_window_view->CreateTestWindow( diff --git a/views/desktop/desktop_window_view.cc b/views/desktop/desktop_window_view.cc index e291bfc..dc99de7 100644 --- a/views/desktop/desktop_window_view.cc +++ b/views/desktop/desktop_window_view.cc @@ -12,6 +12,7 @@ #include "views/widget/native_widget_view.h" #include "views/widget/native_widget_views.h" #include "views/widget/widget.h" +#include "views/window/native_frame_view.h" #if defined(OS_WIN) #include "views/widget/native_widget_win.h" @@ -87,18 +88,30 @@ class TestWindowContentView : public WidgetDelegateView { // static DesktopWindowView* DesktopWindowView::desktop_window_view = NULL; -DesktopWindowView::DesktopWindowView() : active_widget_(NULL) { - set_background(new DesktopBackground); +DesktopWindowView::DesktopWindowView(DesktopType type) + : active_widget_(NULL), + type_(type) { + switch (type_) { + case DESKTOP_DEFAULT: + case DESKTOP_NETBOOK: + set_background(new DesktopBackground); + break; + case DESKTOP_OTHER: + set_background(Background::CreateStandardPanelBackground()); + break; + } } DesktopWindowView::~DesktopWindowView() { } // static -void DesktopWindowView::CreateDesktopWindow() { +void DesktopWindowView::CreateDesktopWindow(DesktopType type) { DCHECK(!desktop_window_view); - desktop_window_view = new DesktopWindowView; + desktop_window_view = new DesktopWindowView(type); views::Widget* window = new DesktopWindow(desktop_window_view); + desktop_window_view->widget_ = window; + views::Widget::InitParams params; params.delegate = desktop_window_view; // In this environment, CreateChromeWindow will default to creating a views- @@ -106,12 +119,13 @@ void DesktopWindowView::CreateDesktopWindow() { // TODO(beng): Replace this with NativeWindow::CreateNativeRootWindow(). #if defined(OS_WIN) params.native_widget = new views::NativeWidgetWin(window); + params.bounds = gfx::Rect(20, 20, 1920, 1200); #elif defined(TOOLKIT_USES_GTK) params.native_widget = new views::NativeWidgetGtk(window); #endif - params.bounds = gfx::Rect(20, 20, 1920, 1200); window->Init(params); window->Show(); + window->Maximize(); } void DesktopWindowView::ActivateWidget(Widget* widget) { @@ -159,6 +173,14 @@ void DesktopWindowView::Layout() { //////////////////////////////////////////////////////////////////////////////// // DesktopWindowView, WidgetDelegate implementation: +Widget* DesktopWindowView::GetWidget() { + return widget_; +} + +const Widget* DesktopWindowView::GetWidget() const { + return widget_; +} + bool DesktopWindowView::CanResize() const { return true; } @@ -191,6 +213,18 @@ View* DesktopWindowView::GetContentsView() { return this; } +NonClientFrameView* DesktopWindowView::CreateNonClientFrameView() { + switch (type_) { + case DESKTOP_DEFAULT: + case DESKTOP_NETBOOK: + return NULL; + + case DESKTOP_OTHER: + return new NativeFrameView(widget_); + } + return NULL; +} + void DesktopWindowView::OnWidgetClosing(Widget* widget) { if (active_widget_ && static_cast<internal::NativeWidgetPrivate*> (active_widget_)->GetWidget() == widget) diff --git a/views/desktop/desktop_window_view.h b/views/desktop/desktop_window_view.h index b222f13..3962281 100644 --- a/views/desktop/desktop_window_view.h +++ b/views/desktop/desktop_window_view.h @@ -17,12 +17,20 @@ namespace desktop { class DesktopWindowView : public WidgetDelegateView, public Widget::Observer { public: + // The look and feel will be slightly different for different kinds of + // desktop. + enum DesktopType { + DESKTOP_DEFAULT, + DESKTOP_NETBOOK, + DESKTOP_OTHER + }; + static DesktopWindowView* desktop_window_view; - DesktopWindowView(); + DesktopWindowView(DesktopType type); virtual ~DesktopWindowView(); - static void CreateDesktopWindow(); + static void CreateDesktopWindow(DesktopType type); // Changes activation to the specified Widget. The currently active Widget // is de-activated. @@ -33,11 +41,15 @@ class DesktopWindowView : public WidgetDelegateView, gfx::Rect initial_bounds, bool rotate); + DesktopType type() const { return type_; } + private: // Overridden from View: virtual void Layout() OVERRIDE; // Overridden from WidgetDelegate: + virtual Widget* GetWidget() OVERRIDE; + virtual const Widget* GetWidget() const OVERRIDE; virtual bool CanResize() const OVERRIDE; virtual bool CanMaximize() const OVERRIDE; virtual std::wstring GetWindowTitle() const OVERRIDE; @@ -46,6 +58,7 @@ class DesktopWindowView : public WidgetDelegateView, virtual bool ShouldShowWindowIcon() const OVERRIDE; virtual void WindowClosing() OVERRIDE; virtual View* GetContentsView() OVERRIDE; + virtual NonClientFrameView* CreateNonClientFrameView() OVERRIDE; // Overridden from Widget::Observer. virtual void OnWidgetClosing(Widget* widget) OVERRIDE; @@ -53,6 +66,8 @@ class DesktopWindowView : public WidgetDelegateView, virtual void OnWidgetActivationChanged(Widget* widget, bool active) OVERRIDE; NativeWidgetViews* active_widget_; + DesktopType type_; + Widget* widget_; DISALLOW_COPY_AND_ASSIGN(DesktopWindowView); }; diff --git a/views/views.gyp b/views/views.gyp index 6b0ca88..9284bea 100644 --- a/views/views.gyp +++ b/views/views.gyp @@ -406,7 +406,6 @@ 'widget/child_window_message_processor.cc', 'widget/child_window_message_processor.h', 'widget/native_widget_win.cc', - 'window/native_frame_view.cc', ], }], ['touchui==1', { diff --git a/views/widget/native_widget_views.cc b/views/widget/native_widget_views.cc index 0a03e77..bbfa8c5 100644 --- a/views/widget/native_widget_views.cc +++ b/views/widget/native_widget_views.cc @@ -77,7 +77,7 @@ void NativeWidgetViews::UpdateFrameAfterFrameChange() { } bool NativeWidgetViews::ShouldUseNativeFrame() const { - NOTIMPLEMENTED(); +// NOTIMPLEMENTED(); return false; } @@ -378,7 +378,7 @@ void NativeWidgetViews::SetFullscreen(bool fullscreen) { } bool NativeWidgetViews::IsFullscreen() const { - NOTIMPLEMENTED(); + // NOTIMPLEMENTED(); return false; } diff --git a/views/window/native_frame_view.cc b/views/window/native_frame_view.cc index 752bdec1f..67b0cbd 100644 --- a/views/window/native_frame_view.cc +++ b/views/window/native_frame_view.cc @@ -1,13 +1,16 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// 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_frame_view.h" #include "views/widget/native_widget.h" -#include "views/widget/native_widget_win.h" #include "views/widget/widget.h" +#if defined(OS_WIN) +#include "views/widget/native_widget_win.h" +#endif + namespace views { //////////////////////////////////////////////////////////////////////////////// @@ -30,12 +33,17 @@ gfx::Rect NativeFrameView::GetBoundsForClientView() const { gfx::Rect NativeFrameView::GetWindowBoundsForClientBounds( const gfx::Rect& client_bounds) const { +#if defined(OS_WIN) RECT rect = client_bounds.ToRECT(); NativeWidgetWin* widget_win = static_cast<NativeWidgetWin*>(frame_->native_widget()); AdjustWindowRectEx(&rect, widget_win->window_style(), FALSE, widget_win->window_ex_style()); return gfx::Rect(rect); +#else + // TODO(sad): + return gfx::Rect(client_bounds); +#endif } int NativeFrameView::NonClientHitTest(const gfx::Point& point) { |