summaryrefslogtreecommitdiffstats
path: root/views
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-13 21:56:26 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-13 21:56:26 +0000
commit2fdd00a4c6a07856180347c6d147b27c10ae14ff (patch)
treefc1634a77f397665cdf20526b96fcb9801c8d144 /views
parentf25b8052531b1d4668d1d9ed60b1151af4ca3ab2 (diff)
downloadchromium_src-2fdd00a4c6a07856180347c6d147b27c10ae14ff.zip
chromium_src-2fdd00a4c6a07856180347c6d147b27c10ae14ff.tar.gz
chromium_src-2fdd00a4c6a07856180347c6d147b27c10ae14ff.tar.bz2
Eliminate Window completely.
BUG=72040 TEST=none Review URL: http://codereview.chromium.org/7108047 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@88905 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r--views/controls/button/button_dropdown.cc1
-rw-r--r--views/controls/button/menu_button.cc1
-rw-r--r--views/controls/combobox/native_combobox_views.cc2
-rw-r--r--views/controls/scrollbar/bitmap_scroll_bar.cc1
-rw-r--r--views/controls/scrollbar/native_scroll_bar_win.cc10
-rw-r--r--views/controls/tabbed_pane/tabbed_pane_unittest.cc11
-rw-r--r--views/controls/table/table_view_unittest.cc24
-rw-r--r--views/controls/textfield/native_textfield_views.cc1
-rw-r--r--views/desktop/desktop_views_delegate.cc17
-rw-r--r--views/desktop/desktop_views_delegate.h6
-rw-r--r--views/desktop/desktop_window.cc40
-rw-r--r--views/desktop/desktop_window.h6
-rw-r--r--views/desktop/desktop_window_root_view.cc4
-rw-r--r--views/desktop/desktop_window_root_view.h2
-rw-r--r--views/examples/examples_main.cc18
-rw-r--r--views/examples/examples_main.h14
-rw-r--r--views/examples/native_window_views_example.cc91
-rw-r--r--views/examples/native_window_views_example.h32
-rw-r--r--views/focus/accelerator_handler_gtk_unittest.cc19
-rw-r--r--views/focus/focus_manager_unittest.cc23
-rw-r--r--views/mouse_watcher.cc2
-rw-r--r--views/test/test_views_delegate.cc4
-rw-r--r--views/test/test_views_delegate.h8
-rw-r--r--views/view.cc1
-rw-r--r--views/view.h1
-rw-r--r--views/view_unittest.cc49
-rw-r--r--views/views.gyp15
-rw-r--r--views/views_delegate.h8
-rw-r--r--views/widget/native_widget.h6
-rw-r--r--views/widget/native_widget_gtk.cc29
-rw-r--r--views/widget/native_widget_gtk.h17
-rw-r--r--views/widget/native_widget_views.cc10
-rw-r--r--views/widget/native_widget_views.h4
-rw-r--r--views/widget/native_widget_win.cc78
-rw-r--r--views/widget/native_widget_win.h21
-rw-r--r--views/widget/native_widget_win_unittest.cc47
-rw-r--r--views/widget/root_view.cc1
-rw-r--r--views/widget/widget.cc48
-rw-r--r--views/widget/widget.h23
-rw-r--r--views/widget/widget_delegate.cc44
-rw-r--r--views/widget/widget_delegate.h35
-rw-r--r--views/window/client_view.cc4
-rw-r--r--views/window/client_view.h1
-rw-r--r--views/window/custom_frame_view.cc6
-rw-r--r--views/window/dialog_client_view.cc4
-rw-r--r--views/window/dialog_client_view.h1
-rw-r--r--views/window/dialog_delegate.cc32
-rw-r--r--views/window/dialog_delegate.h25
-rw-r--r--views/window/native_window.h51
-rw-r--r--views/window/native_window_delegate.h36
-rw-r--r--views/window/native_window_gtk.cc59
-rw-r--r--views/window/native_window_gtk.h44
-rw-r--r--views/window/native_window_views.cc46
-rw-r--r--views/window/native_window_views.h41
-rw-r--r--views/window/native_window_win.cc107
-rw-r--r--views/window/native_window_win.h60
-rw-r--r--views/window/native_window_win_unittest.cc58
-rw-r--r--views/window/non_client_view.cc1
-rw-r--r--views/window/window.cc82
-rw-r--r--views/window/window.h82
-rw-r--r--views/window/window_delegate.cc15
-rw-r--r--views/window/window_delegate.h32
62 files changed, 428 insertions, 1133 deletions
diff --git a/views/controls/button/button_dropdown.cc b/views/controls/button/button_dropdown.cc
index 0eb6d2f..dc893df 100644
--- a/views/controls/button/button_dropdown.cc
+++ b/views/controls/button/button_dropdown.cc
@@ -14,7 +14,6 @@
#include "views/controls/menu/menu_item_view.h"
#include "views/controls/menu/menu_model_adapter.h"
#include "views/widget/widget.h"
-#include "views/window/window.h"
namespace views {
diff --git a/views/controls/button/menu_button.cc b/views/controls/button/menu_button.cc
index 0e5d702..3c8bbed 100644
--- a/views/controls/button/menu_button.cc
+++ b/views/controls/button/menu_button.cc
@@ -18,7 +18,6 @@
#include "views/screen.h"
#include "views/widget/root_view.h"
#include "views/widget/widget.h"
-#include "views/window/window.h"
using base::Time;
using base::TimeDelta;
diff --git a/views/controls/combobox/native_combobox_views.cc b/views/controls/combobox/native_combobox_views.cc
index 10e197f..cf34ac1 100644
--- a/views/controls/combobox/native_combobox_views.cc
+++ b/views/controls/combobox/native_combobox_views.cc
@@ -20,7 +20,7 @@
#include "views/controls/focusable_border.h"
#include "views/controls/menu/submenu_view.h"
#include "views/widget/root_view.h"
-#include "views/window/window.h"
+#include "views/widget/widget.h"
#if defined(OS_LINUX)
#include "ui/gfx/gtk_util.h"
diff --git a/views/controls/scrollbar/bitmap_scroll_bar.cc b/views/controls/scrollbar/bitmap_scroll_bar.cc
index 20a1a96..2785987 100644
--- a/views/controls/scrollbar/bitmap_scroll_bar.cc
+++ b/views/controls/scrollbar/bitmap_scroll_bar.cc
@@ -21,7 +21,6 @@
#include "views/controls/menu/menu.h"
#include "views/controls/scroll_view.h"
#include "views/widget/widget.h"
-#include "views/window/window.h"
#undef min
#undef max
diff --git a/views/controls/scrollbar/native_scroll_bar_win.cc b/views/controls/scrollbar/native_scroll_bar_win.cc
index 7c1b5d7..e46e52a 100644
--- a/views/controls/scrollbar/native_scroll_bar_win.cc
+++ b/views/controls/scrollbar/native_scroll_bar_win.cc
@@ -75,11 +75,11 @@ class ScrollBarContainer : public ui::WindowImpl {
private:
LRESULT OnCreate(LPCREATESTRUCT create_struct) {
- scrollbar_ = CreateWindow(L"SCROLLBAR", L"",
- WS_CHILD | (parent_->IsHorizontal() ?
- SBS_HORZ : SBS_VERT),
- 0, 0, parent_->width(), parent_->height(),
- hwnd(), NULL, NULL, NULL);
+ scrollbar_ = CreateWindowW(L"SCROLLBAR", L"",
+ WS_CHILD | (parent_->IsHorizontal() ?
+ SBS_HORZ : SBS_VERT),
+ 0, 0, parent_->width(), parent_->height(),
+ hwnd(), NULL, NULL, NULL);
ui::CheckWindowCreated(scrollbar_);
ShowWindow(scrollbar_, SW_SHOW);
return 1;
diff --git a/views/controls/tabbed_pane/tabbed_pane_unittest.cc b/views/controls/tabbed_pane/tabbed_pane_unittest.cc
index 1ceef86..12f82a5 100644
--- a/views/controls/tabbed_pane/tabbed_pane_unittest.cc
+++ b/views/controls/tabbed_pane/tabbed_pane_unittest.cc
@@ -5,8 +5,8 @@
#include "base/message_loop.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "views/controls/tabbed_pane/tabbed_pane.h"
-#include "views/window/window.h"
-#include "views/window/window_delegate.h"
+#include "views/widget/widget.h"
+#include "views/widget/widget_delegate.h"
namespace views {
@@ -26,7 +26,8 @@ class FixedSizeView : public View {
DISALLOW_COPY_AND_ASSIGN(FixedSizeView);
};
-class TabbedPaneTest : public testing::Test, WindowDelegate {
+class TabbedPaneTest : public testing::Test,
+ public WidgetDelegate {
public:
TabbedPaneTest() {}
@@ -39,7 +40,7 @@ class TabbedPaneTest : public testing::Test, WindowDelegate {
private:
virtual void SetUp() {
tabbed_pane_ = new TabbedPane();
- window_ = Window::CreateChromeWindow(NULL, gfx::Rect(0, 0, 100, 100), this);
+ window_ = Widget::CreateWindowWithBounds(this, gfx::Rect(0, 0, 100, 100));
window_->Show();
}
@@ -53,7 +54,7 @@ class TabbedPaneTest : public testing::Test, WindowDelegate {
}
MessageLoopForUI message_loop_;
- Window* window_;
+ Widget* window_;
DISALLOW_COPY_AND_ASSIGN(TabbedPaneTest);
};
diff --git a/views/controls/table/table_view_unittest.cc b/views/controls/table/table_view_unittest.cc
index 572ace2..ee6734b 100644
--- a/views/controls/table/table_view_unittest.cc
+++ b/views/controls/table/table_view_unittest.cc
@@ -20,8 +20,8 @@
#include "ui/base/models/table_model_observer.h"
#include "views/controls/table/table_view.h"
#include "views/controls/table/table_view2.h"
-#include "views/window/window.h"
-#include "views/window/window_delegate.h"
+#include "views/widget/widget.h"
+#include "views/widget/widget_delegate.h"
using ui::TableModel;
using ui::TableModelObserver; // TODO(beng): remove these
@@ -139,7 +139,7 @@ int TestTableModel::CompareValues(int row1, int row2, int column_id) {
// TableViewTest ---------------------------------------------------------------
-class TableViewTest : public testing::Test, views::WindowDelegate {
+class TableViewTest : public testing::Test, views::WidgetDelegate {
public:
virtual void SetUp();
virtual void TearDown();
@@ -174,7 +174,7 @@ class TableViewTest : public testing::Test, views::WindowDelegate {
private:
MessageLoopForUI message_loop_;
- views::Window* window_;
+ views::Widget* window_;
};
void TableViewTest::SetUp() {
@@ -186,9 +186,9 @@ void TableViewTest::SetUp() {
columns[1].id = 1;
table_ = new TableView(model_.get(), columns, views::ICON_AND_TEXT,
false, false, false);
- window_ =
- views::Window::CreateChromeWindow(NULL, gfx::Rect(100, 100, 512, 512),
- this);
+ window_ = views::Widget::CreateWindowWithBounds(
+ this,
+ gfx::Rect(100, 100, 512, 512));
}
void TableViewTest::TearDown() {
@@ -466,7 +466,7 @@ TEST_F(NullModelTableViewTest, DISABLED_NullModel) {
////////////////////////////////////////////////////////////////////////////////
// TableView2 Tests
-class TableView2Test : public testing::Test, views::WindowDelegate {
+class TableView2Test : public testing::Test, views::WidgetDelegate {
public:
virtual void SetUp();
virtual void TearDown();
@@ -493,7 +493,7 @@ class TableView2Test : public testing::Test, views::WindowDelegate {
private:
MessageLoopForUI message_loop_;
- views::Window* window_;
+ views::Widget* window_;
};
void TableView2Test::SetUp() {
@@ -507,9 +507,9 @@ void TableView2Test::SetUp() {
columns[1].id = 1;
table_ = new views::TableView2(model_.get(), columns, GetTableType(),
views::TableView2::NONE);
- window_ = views::Window::CreateChromeWindow(NULL,
- gfx::Rect(100, 100, 512, 512),
- this);
+ window_ = views::Widget::CreateWindowWithBounds(
+ this,
+ gfx::Rect(100, 100, 512, 512));
window_->Show();
}
diff --git a/views/controls/textfield/native_textfield_views.cc b/views/controls/textfield/native_textfield_views.cc
index 2204913..423b6eb 100644
--- a/views/controls/textfield/native_textfield_views.cc
+++ b/views/controls/textfield/native_textfield_views.cc
@@ -30,7 +30,6 @@
#include "views/metrics.h"
#include "views/views_delegate.h"
#include "views/widget/widget.h"
-#include "views/window/window.h"
#if defined(OS_LINUX)
#include "ui/gfx/gtk_util.h"
diff --git a/views/desktop/desktop_views_delegate.cc b/views/desktop/desktop_views_delegate.cc
index 00a2014..98adee5 100644
--- a/views/desktop/desktop_views_delegate.cc
+++ b/views/desktop/desktop_views_delegate.cc
@@ -27,21 +27,22 @@ ui::Clipboard* DesktopViewsDelegate::GetClipboard() const {
return NULL;
}
-void DesktopViewsDelegate::SaveWindowPlacement(views::Window* window,
- const std::wstring& window_name,
- const gfx::Rect& bounds,
- bool maximized) {
+void DesktopViewsDelegate::SaveWindowPlacement(const Widget* widget,
+ const std::wstring& window_name,
+ const gfx::Rect& bounds,
+ bool maximized) {
}
-bool DesktopViewsDelegate::GetSavedWindowBounds(views::Window* window,
+bool DesktopViewsDelegate::GetSavedWindowBounds(const Widget* widget,
const std::wstring& window_name,
gfx::Rect* bounds) const {
return false;
}
-bool DesktopViewsDelegate::GetSavedMaximizedState(views::Window* window,
- const std::wstring& window_name,
- bool* maximized) const {
+bool DesktopViewsDelegate::GetSavedMaximizedState(
+ const Widget* widget,
+ const std::wstring& window_name,
+ bool* maximized) const {
return false;
}
diff --git a/views/desktop/desktop_views_delegate.h b/views/desktop/desktop_views_delegate.h
index fdc2fe0..cf7fa3d 100644
--- a/views/desktop/desktop_views_delegate.h
+++ b/views/desktop/desktop_views_delegate.h
@@ -19,14 +19,14 @@ class DesktopViewsDelegate : public ViewsDelegate {
private:
// Overridden from ViewsDelegate:
virtual ui::Clipboard* GetClipboard() const OVERRIDE;
- virtual void SaveWindowPlacement(views::Window* window,
+ virtual void SaveWindowPlacement(const Widget* widget,
const std::wstring& window_name,
const gfx::Rect& bounds,
bool maximized) OVERRIDE;
- virtual bool GetSavedWindowBounds(views::Window* window,
+ virtual bool GetSavedWindowBounds(const Widget* widget,
const std::wstring& window_name,
gfx::Rect* bounds) const OVERRIDE;
- virtual bool GetSavedMaximizedState(views::Window* window,
+ virtual bool GetSavedMaximizedState(const Widget* widget,
const std::wstring& window_name,
bool* maximized) const OVERRIDE;
virtual void NotifyAccessibilityEvent(
diff --git a/views/desktop/desktop_window.cc b/views/desktop/desktop_window.cc
index b59fc5d..c0999fb 100644
--- a/views/desktop/desktop_window.cc
+++ b/views/desktop/desktop_window.cc
@@ -9,20 +9,20 @@
#include "views/desktop/desktop_background.h"
#include "views/desktop/desktop_window_root_view.h"
#include "views/widget/native_widget_view.h"
-#include "views/window/native_window_views.h"
-#include "views/window/window.h"
+#include "views/widget/native_widget_views.h"
+#include "views/widget/widget.h"
#if defined(OS_WIN)
-#include "views/window/native_window_win.h"
+#include "views/widget/native_widget_win.h"
#elif defined(TOOLKIT_USES_GTK)
-#include "views/window/native_window_gtk.h"
+#include "views/widget/native_widget_gtk.h"
#endif
namespace views {
namespace desktop {
// TODO(beng): resolve naming!
-class DesktopWindowWindow : public Window {
+class DesktopWindowWindow : public Widget {
public:
explicit DesktopWindowWindow(DesktopWindow* desktop_window)
: desktop_window_(desktop_window) {}
@@ -40,7 +40,7 @@ class DesktopWindowWindow : public Window {
};
class TestWindowContentView : public View,
- public WindowDelegate {
+ public WidgetDelegate {
public:
TestWindowContentView(const std::wstring& title, SkColor color)
: title_(title),
@@ -81,18 +81,19 @@ DesktopWindow::~DesktopWindow() {
// static
void DesktopWindow::CreateDesktopWindow() {
DesktopWindow* desktop = new DesktopWindow;
- views::Window* window = new DesktopWindowWindow(desktop);
- views::Window::InitParams params(desktop);
+ views::Widget* window = new DesktopWindowWindow(desktop);
+ views::Widget::InitParams params;
+ params.delegate = desktop;
// In this environment, CreateChromeWindow will default to creating a views-
- // window, so we need to construct a NativeWindowWin by hand.
+ // window, so we need to construct a NativeWidgetWin by hand.
// TODO(beng): Replace this with NativeWindow::CreateNativeRootWindow().
#if defined(OS_WIN)
- params.native_window = new views::NativeWindowWin(window);
+ params.native_widget = new views::NativeWidgetWin(window);
#elif defined(TOOLKIT_USES_GTK)
- params.native_window = new views::NativeWindowGtk(window);
+ params.native_widget = new views::NativeWidgetGtk(window);
#endif
- params.widget_init_params.bounds = gfx::Rect(20, 20, 1920, 1200);
- window->InitWindow(params);
+ params.bounds = gfx::Rect(20, 20, 1920, 1200);
+ window->Init(params);
window->Show();
desktop->CreateTestWindow(L"Sample Window 1", SK_ColorWHITE,
@@ -161,12 +162,13 @@ void DesktopWindow::CreateTestWindow(const std::wstring& title,
SkColor color,
gfx::Rect initial_bounds,
bool rotate) {
- views::Window* window = new views::Window;
- views::NativeWindowViews* nwv = new views::NativeWindowViews(this, window);
- views::Window::InitParams params(new TestWindowContentView(title, color));
- params.native_window = nwv;
- params.widget_init_params.bounds = initial_bounds;
- window->InitWindow(params);
+ views::Widget* window = new views::Widget;
+ views::NativeWidgetViews* nwv = new views::NativeWidgetViews(this, window);
+ views::Widget::InitParams params;
+ params.delegate = new TestWindowContentView(title, color);
+ params.native_widget = nwv;
+ params.bounds = initial_bounds;
+ window->Init(params);
window->Show();
if (rotate) {
diff --git a/views/desktop/desktop_window.h b/views/desktop/desktop_window.h
index 8cd943a..453030c 100644
--- a/views/desktop/desktop_window.h
+++ b/views/desktop/desktop_window.h
@@ -6,7 +6,7 @@
#define VIEWS_DESKTOP_DESKTOP_WINDOW_H_
#include "views/view.h"
-#include "views/window/window_delegate.h"
+#include "views/widget/widget_delegate.h"
namespace views {
class NativeWidgetViews;
@@ -14,7 +14,7 @@ class NativeWidgetViews;
namespace desktop {
class DesktopWindow : public View,
- public WindowDelegate {
+ public WidgetDelegate {
public:
DesktopWindow();
virtual ~DesktopWindow();
@@ -29,7 +29,7 @@ class DesktopWindow : public View,
// Overridden from View:
virtual void Layout() OVERRIDE;
- // Overridden from WindowDelegate:
+ // Overridden from WidgetDelegate:
virtual bool CanResize() const OVERRIDE;
virtual bool CanMaximize() const OVERRIDE;
virtual std::wstring GetWindowTitle() const OVERRIDE;
diff --git a/views/desktop/desktop_window_root_view.cc b/views/desktop/desktop_window_root_view.cc
index 5639cb5..fec23fb 100644
--- a/views/desktop/desktop_window_root_view.cc
+++ b/views/desktop/desktop_window_root_view.cc
@@ -6,7 +6,7 @@
#include "views/desktop/desktop_window.h"
#include "views/widget/native_widget_view.h"
-#include "views/window/window.h"
+#include "views/widget/widget.h"
namespace views {
namespace desktop {
@@ -15,7 +15,7 @@ namespace desktop {
// DesktopWindowRootView, public:
DesktopWindowRootView::DesktopWindowRootView(DesktopWindow* desktop_window,
- Window* window)
+ Widget* window)
: internal::RootView(window),
desktop_window_(desktop_window) {
}
diff --git a/views/desktop/desktop_window_root_view.h b/views/desktop/desktop_window_root_view.h
index 9ad5f1c..1896942 100644
--- a/views/desktop/desktop_window_root_view.h
+++ b/views/desktop/desktop_window_root_view.h
@@ -14,7 +14,7 @@ class DesktopWindow;
class DesktopWindowRootView : public internal::RootView {
public:
- DesktopWindowRootView(DesktopWindow* desktop_window, Window* window);
+ DesktopWindowRootView(DesktopWindow* desktop_window, Widget* window);
virtual ~DesktopWindowRootView();
private:
diff --git a/views/examples/examples_main.cc b/views/examples/examples_main.cc
index 7e123aa..2e95b65 100644
--- a/views/examples/examples_main.cc
+++ b/views/examples/examples_main.cc
@@ -22,7 +22,6 @@
#include "views/examples/native_theme_button_example.h"
#include "views/examples/native_theme_checkbox_example.h"
#include "views/examples/native_widget_views_example.h"
-#include "views/examples/native_window_views_example.h"
#include "views/examples/radio_button_example.h"
#include "views/examples/scroll_view_example.h"
#include "views/examples/single_split_view_example.h"
@@ -34,7 +33,6 @@
#include "views/focus/accelerator_handler.h"
#include "views/layout/grid_layout.h"
#include "views/widget/widget.h"
-#include "views/window/window.h"
#include "views/test/test_views_delegate.h"
#if defined(OS_WIN)
@@ -60,6 +58,14 @@ void ExamplesMain::WindowClosing() {
MessageLoopForUI::current()->Quit();
}
+views::Widget* ExamplesMain::GetWidget() {
+ return contents_->GetWidget();
+}
+
+const views::Widget* ExamplesMain::GetWidget() const {
+ return contents_->GetWidget();
+}
+
void ExamplesMain::SetStatus(const std::wstring& status) {
status_label_->SetText(status);
}
@@ -101,8 +107,8 @@ void ExamplesMain::Run() {
// TODO(satorux): The window is getting wide. Eventually, we would have
// the second tabbed pane.
- views::Window* window =
- views::Window::CreateChromeWindow(NULL, gfx::Rect(0, 0, 850, 300), this);
+ views::Widget* window =
+ views::Widget::CreateWindowWithBounds(this, gfx::Rect(0, 0, 850, 300));
examples::NativeThemeCheckboxExample native_theme_checkbox_example(this);
tabbed_pane->AddTab(native_theme_checkbox_example.GetExampleTitle(),
@@ -116,10 +122,6 @@ void ExamplesMain::Run() {
tabbed_pane->AddTab(native_widget_views_example.GetExampleTitle(),
native_widget_views_example.GetExampleView());
- examples::NativeWindowViewsExample native_window_views_example(this);
- tabbed_pane->AddTab(native_window_views_example.GetExampleTitle(),
- native_window_views_example.GetExampleView());
-
examples::TextfieldExample textfield_example(this);
tabbed_pane->AddTab(textfield_example.GetExampleTitle(),
textfield_example.GetExampleView());
diff --git a/views/examples/examples_main.h b/views/examples/examples_main.h
index db4b86c..ce2124d 100644
--- a/views/examples/examples_main.h
+++ b/views/examples/examples_main.h
@@ -9,7 +9,7 @@
#include <string>
#include "base/basictypes.h"
-#include "views/window/window_delegate.h"
+#include "views/widget/widget_delegate.h"
namespace views {
class Label;
@@ -19,15 +19,17 @@ class View;
namespace examples {
// ExamplesMainBase creates all view examples and start event loop.
-class ExamplesMain : public views::WindowDelegate {
+class ExamplesMain : public views::WidgetDelegate {
public:
ExamplesMain();
virtual ~ExamplesMain();
- // views::WindowDelegate implementation:
- virtual bool CanResize() const;
- virtual views::View* GetContentsView();
- virtual void WindowClosing();
+ // views::WidgetDelegate implementation:
+ virtual bool CanResize() const OVERRIDE;
+ virtual views::View* GetContentsView() OVERRIDE;
+ virtual void WindowClosing() OVERRIDE;
+ virtual views::Widget* GetWidget() OVERRIDE;
+ virtual const views::Widget* GetWidget() const OVERRIDE;
// Prints a message in the status area, at the bottom of the window.
void SetStatus(const std::wstring& status);
diff --git a/views/examples/native_window_views_example.cc b/views/examples/native_window_views_example.cc
deleted file mode 100644
index b5291de..0000000
--- a/views/examples/native_window_views_example.cc
+++ /dev/null
@@ -1,91 +0,0 @@
-// 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/examples/native_window_views_example.h"
-
-#include "ui/gfx/canvas.h"
-#include "views/examples/example_base.h"
-#include "views/controls/button/text_button.h"
-#include "views/controls/label.h"
-#include "views/layout/grid_layout.h"
-#include "views/view.h"
-#include "views/window/native_window_views.h"
-#include "views/window/window.h"
-#include "views/window/window_delegate.h"
-
-namespace examples {
-
-class WindowContentView : public views::View,
- public views::WindowDelegate,
- public views::ButtonListener {
- public:
- WindowContentView()
- : ALLOW_THIS_IN_INITIALIZER_LIST(
- button_(new views::TextButton(this, L"Click me!"))),
- label_(new views::Label(L"Some label")) {
- views::GridLayout* layout = new views::GridLayout(this);
- views::ColumnSet* columns = layout->AddColumnSet(0);
- columns->AddColumn(views::GridLayout::FILL,
- views::GridLayout::FILL,
- 1,
- views::GridLayout::USE_PREF,
- 0,
- 0);
- SetLayoutManager(layout);
- layout->StartRow(0, 0);
- layout->AddView(button_);
- layout->StartRow(1, 0);
- layout->AddView(label_);
- }
- virtual ~WindowContentView() {}
-
- // Overridden from views::View:
- virtual void OnPaint(gfx::Canvas* canvas) {
- canvas->FillRectInt(SK_ColorWHITE, 0, 0, width(), height());
- }
-
- // Overridden from views::WindowDelegate:
- virtual std::wstring GetWindowTitle() const {
- return L"Example NativeWindowViews";
- }
- virtual View* GetContentsView() {
- return this;
- }
-
- // Overridden from views::ButtonListener:
- virtual void ButtonPressed(views::Button* sender, const views::Event& event) {
- if (sender == button_)
- label_->SetText(L"Button Clicked!");
- }
-
- private:
- views::TextButton* button_;
- views::Label* label_;
-
- DISALLOW_COPY_AND_ASSIGN(WindowContentView);
-};
-
-NativeWindowViewsExample::NativeWindowViewsExample(ExamplesMain* main)
- : ExampleBase(main) {
-}
-
-NativeWindowViewsExample::~NativeWindowViewsExample() {
-}
-
-std::wstring NativeWindowViewsExample::GetExampleTitle() {
- return L"NativeWindowViews";
-}
-
-void NativeWindowViewsExample::CreateExampleView(views::View* container) {
- views::Window* window = new views::Window;
- views::NativeWindowViews* nwv =
- new views::NativeWindowViews(container, window);
- views::Window::InitParams params(new WindowContentView);
- params.native_window = nwv;
- params.widget_init_params.bounds = gfx::Rect(20, 20, 600, 300);
- window->InitWindow(params);
- window->Show();
-}
-
-} // namespace examples
diff --git a/views/examples/native_window_views_example.h b/views/examples/native_window_views_example.h
deleted file mode 100644
index 361fdf8..0000000
--- a/views/examples/native_window_views_example.h
+++ /dev/null
@@ -1,32 +0,0 @@
-// 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_EXAMPLES_NATIVE_WINDOW_VIEWS_EXAMPLE_H_
-#define VIEWS_EXAMPLES_NATIVE_WINDOW_VIEWS_EXAMPLE_H_
-#pragma once
-
-#include <string>
-
-#include "base/basictypes.h"
-#include "base/compiler_specific.h"
-#include "views/examples/example_base.h"
-
-namespace examples {
-
-class NativeWindowViewsExample : public ExampleBase {
- public:
- explicit NativeWindowViewsExample(ExamplesMain* main);
- virtual ~NativeWindowViewsExample();
-
- // Overridden from ExampleBase:
- virtual std::wstring GetExampleTitle() OVERRIDE;
- virtual void CreateExampleView(views::View* container) OVERRIDE;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(NativeWindowViewsExample);
-};
-
-} // namespace examples
-
-#endif // VIEWS_EXAMPLES_NATIVE_WINDOW_VIEWS_EXAMPLE_H_
diff --git a/views/focus/accelerator_handler_gtk_unittest.cc b/views/focus/accelerator_handler_gtk_unittest.cc
index 3996e77..6a3eebaf 100644
--- a/views/focus/accelerator_handler_gtk_unittest.cc
+++ b/views/focus/accelerator_handler_gtk_unittest.cc
@@ -9,14 +9,14 @@
#include "views/focus/accelerator_handler.h"
#include "views/focus/focus_manager.h"
#include "views/view.h"
-#include "views/window/window.h"
-#include "views/window/window_delegate.h"
+#include "views/widget/widget.h"
+#include "views/widget/widget_delegate.h"
namespace views {
class AcceleratorHandlerGtkTest
: public testing::Test,
- public WindowDelegate,
+ public WidgetDelegate,
public AcceleratorTarget {
public:
AcceleratorHandlerGtkTest()
@@ -26,8 +26,7 @@ class AcceleratorHandlerGtkTest
}
virtual void SetUp() {
- window_ = Window::CreateChromeWindow(
- NULL, gfx::Rect(0, 0, 500, 500), this);
+ window_ = Widget::CreateWindowWithBounds(this, gfx::Rect(0, 0, 500, 500));
window_->Show();
FocusManager* focus_manager = window_->GetFocusManager();
focus_manager->RegisterAccelerator(kMenuAccelerator, this);
@@ -67,12 +66,18 @@ class AcceleratorHandlerGtkTest
return true;
}
- // WindowDelegate Implementation.
+ // WidgetDelegate Implementation.
virtual View* GetContentsView() {
if (!content_view_)
content_view_ = new View();
return content_view_;
}
+ virtual const views::Widget* GetWidget() const {
+ return content_view_->GetWidget();
+ }
+ virtual views::Widget* GetWidget() {
+ return content_view_->GetWidget();
+ }
virtual void InitContentView() {
}
@@ -84,7 +89,7 @@ class AcceleratorHandlerGtkTest
private:
Accelerator kMenuAccelerator;
Accelerator kHomepageAccelerator;
- Window* window_;
+ Widget* window_;
View* content_view_;
MessageLoopForUI message_loop_;
DISALLOW_COPY_AND_ASSIGN(AcceleratorHandlerGtkTest);
diff --git a/views/focus/focus_manager_unittest.cc b/views/focus/focus_manager_unittest.cc
index a40b6c3..7ea323e 100644
--- a/views/focus/focus_manager_unittest.cc
+++ b/views/focus/focus_manager_unittest.cc
@@ -28,9 +28,9 @@
#include "views/controls/textfield/textfield.h"
#include "views/focus/accelerator_handler.h"
#include "views/widget/root_view.h"
+#include "views/widget/widget.h"
+#include "views/widget/widget_delegate.h"
#include "views/window/non_client_view.h"
-#include "views/window/window.h"
-#include "views/window/window_delegate.h"
#if defined(OS_LINUX)
#include "ui/base/keycodes/keyboard_code_conversion_gtk.h"
@@ -99,7 +99,7 @@ const int kThumbnailSuperStarID = count++;
namespace views {
-class FocusManagerTest : public testing::Test, public WindowDelegate {
+class FocusManagerTest : public testing::Test, public WidgetDelegate {
public:
FocusManagerTest()
: window_(NULL),
@@ -117,7 +117,7 @@ class FocusManagerTest : public testing::Test, public WindowDelegate {
}
virtual void SetUp() {
- window_ = Window::CreateChromeWindow(NULL, bounds(), this);
+ window_ = Widget::CreateWindowWithBounds(this, bounds());
InitContentView();
window_->Show();
}
@@ -151,7 +151,7 @@ class FocusManagerTest : public testing::Test, public WindowDelegate {
#endif
}
- // WindowDelegate Implementation.
+ // WidgetDelegate Implementation.
virtual View* GetContentsView() {
if (!content_view_)
content_view_ = new View();
@@ -188,7 +188,7 @@ class FocusManagerTest : public testing::Test, public WindowDelegate {
MessageLoopForUI* message_loop() { return &message_loop_; }
- Window* window_;
+ Widget* window_;
View* content_view_;
void AddFocusChangeListener(FocusChangeListener* listener) {
@@ -1664,15 +1664,16 @@ class FocusManagerDtorTest : public FocusManagerTest {
DtorTrackVector* dtor_tracker_;
};
- class WindowDtorTracked : public Window {
+ class WindowDtorTracked : public Widget {
public:
- WindowDtorTracked(WindowDelegate* window_delegate,
+ WindowDtorTracked(WidgetDelegate* widget_delegate,
DtorTrackVector* dtor_tracker)
: dtor_tracker_(dtor_tracker) {
tracked_focus_manager_ = new FocusManagerDtorTracked(this, dtor_tracker_);
- Window::InitParams params(window_delegate);
- params.widget_init_params.bounds = gfx::Rect(0, 0, 100, 100);
- InitWindow(params);
+ Widget::InitParams params;
+ params.delegate = widget_delegate;
+ params.bounds = gfx::Rect(0, 0, 100, 100);
+ Init(params);
ReplaceFocusManager(tracked_focus_manager_);
}
diff --git a/views/mouse_watcher.cc b/views/mouse_watcher.cc
index f5a4726..09aaa8a 100644
--- a/views/mouse_watcher.cc
+++ b/views/mouse_watcher.cc
@@ -9,7 +9,7 @@
#include "base/task.h"
#include "views/screen.h"
#include "views/view.h"
-#include "views/window/window.h"
+#include "views/widget/widget.h"
namespace views {
diff --git a/views/test/test_views_delegate.cc b/views/test/test_views_delegate.cc
index 37a7797..077f6f0 100644
--- a/views/test/test_views_delegate.cc
+++ b/views/test/test_views_delegate.cc
@@ -23,13 +23,13 @@ ui::Clipboard* TestViewsDelegate::GetClipboard() const {
}
-bool TestViewsDelegate::GetSavedWindowBounds(views::Window* window,
+bool TestViewsDelegate::GetSavedWindowBounds(const views::Widget* window,
const std::wstring& window_name,
gfx::Rect* bounds) const {
return false;
}
-bool TestViewsDelegate::GetSavedMaximizedState(views::Window* window,
+bool TestViewsDelegate::GetSavedMaximizedState(const views::Widget* window,
const std::wstring& window_name,
bool* maximized) const {
return false;
diff --git a/views/test/test_views_delegate.h b/views/test/test_views_delegate.h
index b7ffabe..45a2341 100644
--- a/views/test/test_views_delegate.h
+++ b/views/test/test_views_delegate.h
@@ -11,7 +11,7 @@
#include "views/views_delegate.h"
namespace views {
-class Window;
+class Widget;
}
class TestViewsDelegate : public views::ViewsDelegate {
@@ -21,15 +21,15 @@ class TestViewsDelegate : public views::ViewsDelegate {
// Overridden from views::ViewsDelegate:
virtual ui::Clipboard* GetClipboard() const;
- virtual void SaveWindowPlacement(views::Window* window,
+ virtual void SaveWindowPlacement(const views::Widget* window,
const std::wstring& window_name,
const gfx::Rect& bounds,
bool maximized) OVERRIDE { }
- virtual bool GetSavedWindowBounds(views::Window* window,
+ virtual bool GetSavedWindowBounds(const views::Widget* window,
const std::wstring& window_name,
gfx::Rect* bounds) const;
- virtual bool GetSavedMaximizedState(views::Window* window,
+ virtual bool GetSavedMaximizedState(const views::Widget* window,
const std::wstring& window_name,
bool* maximized) const;
diff --git a/views/view.cc b/views/view.cc
index ddf81bf..edc0178 100644
--- a/views/view.cc
+++ b/views/view.cc
@@ -24,7 +24,6 @@
#include "views/widget/root_view.h"
#include "views/widget/tooltip_manager.h"
#include "views/widget/widget.h"
-#include "views/window/window.h"
#if defined(OS_WIN)
#include "base/win/scoped_gdi_object.h"
diff --git a/views/view.h b/views/view.h
index 30efeac0..618c53d 100644
--- a/views/view.h
+++ b/views/view.h
@@ -55,7 +55,6 @@ class LayoutManager;
class ScrollView;
class TextInputClient;
class Widget;
-class Window;
namespace internal {
class RootView;
diff --git a/views/view_unittest.cc b/views/view_unittest.cc
index 7cb8266..b6dc1ed 100644
--- a/views/view_unittest.cc
+++ b/views/view_unittest.cc
@@ -28,7 +28,6 @@
#include "views/widget/native_widget.h"
#include "views/widget/root_view.h"
#include "views/window/dialog_delegate.h"
-#include "views/window/window.h"
#if defined(OS_WIN)
#include "views/controls/button/native_button_win.h"
@@ -1076,9 +1075,9 @@ class TestViewWithControls : public View {
Textfield* text_field_;
};
-class SimpleWindowDelegate : public WindowDelegate {
+class SimpleWidgetDelegate : public WidgetDelegate {
public:
- explicit SimpleWindowDelegate(View* contents) : contents_(contents) { }
+ explicit SimpleWidgetDelegate(View* contents) : contents_(contents) { }
virtual void DeleteDelegate() { delete this; }
@@ -1099,15 +1098,15 @@ class SimpleWindowDelegate : public WindowDelegate {
// area that it opens the test windows. --beng
TEST_F(ViewTest, DISABLED_RerouteMouseWheelTest) {
TestViewWithControls* view_with_controls = new TestViewWithControls();
- Window* window1 = Window::CreateChromeWindow(
- NULL, gfx::Rect(0, 0, 100, 100),
- new SimpleWindowDelegate(view_with_controls));
+ Widget* window1 = Widget::CreateWindowWithBounds(
+ new SimpleWidgetDelegate(view_with_controls),
+ gfx::Rect(0, 0, 100, 100));
window1->Show();
ScrollView* scroll_view = new ScrollView();
scroll_view->SetContents(new ScrollableTestView());
- Window* window2 = Window::CreateChromeWindow(
- NULL, gfx::Rect(200, 200, 100, 100),
- new SimpleWindowDelegate(scroll_view));
+ Widget* window2 = Widget::CreateWindowWithBounds(
+ new SimpleWidgetDelegate(scroll_view),
+ gfx::Rect(200, 200, 100, 100));
window2->Show();
EXPECT_EQ(0, scroll_view->GetVisibleRect().y());
@@ -1197,11 +1196,11 @@ class TestDialog : public DialogDelegate, public ButtonListener {
}
// DialogDelegate implementation:
- virtual int GetDefaultDialogButton() const {
+ virtual int GetDefaultDialogButton() const OVERRIDE {
return MessageBoxFlags::DIALOGBUTTON_OK;
}
- virtual View* GetContentsView() {
+ virtual View* GetContentsView() OVERRIDE {
if (!contents_) {
contents_ = new View();
button1_ = new NativeButtonBase(this, L"Button1");
@@ -1218,17 +1217,24 @@ class TestDialog : public DialogDelegate, public ButtonListener {
// Prevent the dialog from really closing (so we can click the OK/Cancel
// buttons to our heart's content).
- virtual bool Cancel() {
+ virtual bool Cancel() OVERRIDE {
canceled_ = true;
return false;
}
- virtual bool Accept() {
+ virtual bool Accept() OVERRIDE {
oked_ = true;
return false;
}
+ virtual Widget* GetWidget() OVERRIDE {
+ return widget_;
+ }
+ virtual const Widget* GetWidget() const OVERRIDE {
+ return widget_;
+ }
+
// ButtonListener implementation.
- virtual void ButtonPressed(Button* sender, const Event& event) {
+ virtual void ButtonPressed(Button* sender, const Event& event) OVERRIDE {
last_pressed_button_ = sender;
}
@@ -1259,6 +1265,7 @@ class TestDialog : public DialogDelegate, public ButtonListener {
bool canceled_;
bool oked_;
+ Widget* widget_;
};
class DefaultButtonTest : public ViewTest {
@@ -1280,8 +1287,9 @@ class DefaultButtonTest : public ViewTest {
virtual void SetUp() {
test_dialog_ = new TestDialog(NULL);
- Window* window = Window::CreateChromeWindow(NULL, gfx::Rect(0, 0, 100, 100),
- test_dialog_);
+ Widget* window =
+ Widget::CreateWindowWithBounds(test_dialog_, gfx::Rect(0, 0, 100, 100));
+ test_dialog_->widget_ = window;
window->Show();
focus_manager_ = test_dialog_->contents_->GetFocusManager();
ASSERT_TRUE(focus_manager_ != NULL);
@@ -1384,8 +1392,9 @@ class ButtonDropDownTest : public ViewTest {
virtual void SetUp() {
test_dialog_ = new TestDialog(&mock_menu_model_);
- Window* window = Window::CreateChromeWindow(NULL, gfx::Rect(0, 0, 100, 100),
- test_dialog_);
+ Widget* window =
+ Widget::CreateWindowWithBounds(test_dialog_, gfx::Rect(0, 0, 100, 100));
+ test_dialog_->widget_ = window;
window->Show();
test_dialog_->button_drop_->SetBounds(0, 0, 100, 100);
// We have to cast the button back into a View in order to invoke it's
@@ -1479,7 +1488,7 @@ class TestChangeNativeViewHierarchy {
host_->GetRootView()->AddChildView(native_host_);
for (size_t i = 0; i < TestNativeViewHierarchy::kTotalViews; ++i) {
windows_[i] = new Widget;
- Widget::InitParams params(Widget::InitParams::TYPE_POPUP);
+ Widget::InitParams params(Widget::InitParams::TYPE_CONTROL);
params.parent = host_->GetNativeView();
params.bounds = gfx::Rect(0, 0, 500, 300);
windows_[i]->Init(params);
@@ -1499,7 +1508,7 @@ class TestChangeNativeViewHierarchy {
}
void CheckEnumeratingNativeWidgets() {
- if (!host_->GetContainingWindow())
+ if (!host_->GetTopLevelWidget())
return;
NativeWidget::NativeWidgets widgets;
NativeWidget::GetAllNativeWidgets(host_->GetNativeView(), &widgets);
diff --git a/views/views.gyp b/views/views.gyp
index 162d920..eeb67ee 100644
--- a/views/views.gyp
+++ b/views/views.gyp
@@ -388,20 +388,8 @@
'window/dialog_delegate.h',
'window/native_frame_view.cc',
'window/native_frame_view.h',
- 'window/native_window.h',
- 'window/native_window_delegate.h',
- 'window/native_window_gtk.cc',
- 'window/native_window_gtk.h',
- 'window/native_window_views.cc',
- 'window/native_window_views.h',
- 'window/native_window_win.cc',
- 'window/native_window_win.h',
'window/non_client_view.cc',
'window/non_client_view.h',
- 'window/window.cc',
- 'window/window.h',
- 'window/window_delegate.h',
- 'window/window_delegate.cc',
'window/window_resources.h',
'window/window_shape.cc',
'window/window_shape.h',
@@ -512,7 +500,6 @@
'widget/native_widget_test_utils_win.cc',
'widget/native_widget_unittest.cc',
'widget/native_widget_win_unittest.cc',
- 'window/native_window_win_unittest.cc',
'<(SHARED_INTERMEDIATE_DIR)/app/app_resources/app_resources.rc',
],
@@ -587,8 +574,6 @@
'examples/native_theme_checkbox_example.h',
'examples/native_widget_views_example.cc',
'examples/native_widget_views_example.h',
- 'examples/native_window_views_example.cc',
- 'examples/native_window_views_example.h',
'examples/radio_button_example.cc',
'examples/radio_button_example.h',
'examples/scroll_view_example.cc',
diff --git a/views/views_delegate.h b/views/views_delegate.h
index 3b53b67..e9f9113 100644
--- a/views/views_delegate.h
+++ b/views/views_delegate.h
@@ -24,7 +24,7 @@ class Clipboard;
namespace views {
class View;
-class Window;
+class Widget;
// ViewsDelegate is an interface implemented by an object using the views
// framework. It is used to obtain various high level application utilities
@@ -41,20 +41,20 @@ class ViewsDelegate {
// Saves the position, size and maximized state for the window with the
// specified name.
- virtual void SaveWindowPlacement(views::Window* window,
+ virtual void SaveWindowPlacement(const Widget* widget,
const std::wstring& window_name,
const gfx::Rect& bounds,
bool maximized) = 0;
// Retrieves the saved position and size for the window with the specified
// name.
- virtual bool GetSavedWindowBounds(views::Window* window,
+ virtual bool GetSavedWindowBounds(const Widget* widget,
const std::wstring& window_name,
gfx::Rect* bounds) const = 0;
// Retrieves the saved maximized state for the window with the specified
// name.
- virtual bool GetSavedMaximizedState(views::Window* window,
+ virtual bool GetSavedMaximizedState(const Widget* widget,
const std::wstring& window_name,
bool* maximized) const = 0;
diff --git a/views/widget/native_widget.h b/views/widget/native_widget.h
index c410110..1e5b2df 100644
--- a/views/widget/native_widget.h
+++ b/views/widget/native_widget.h
@@ -83,10 +83,6 @@ class NativeWidget {
virtual gfx::NativeView GetNativeView() const = 0;
virtual gfx::NativeWindow GetNativeWindow() const = 0;
- // Returns the enclosing Window, or NULL if there is no enclosing Window.
- virtual Window* GetContainingWindow() = 0;
- virtual const Window* GetContainingWindow() const = 0;
-
// Notifies the NativeWidget that a view was removed from the Widget's view
// hierarchy.
virtual void ViewRemoved(View* view) = 0;
@@ -95,7 +91,7 @@ class NativeWidget {
// Returns NULL if the property does not exist. Setting the property value to
// NULL removes the property.
virtual void SetNativeWindowProperty(const char* name, void* value) = 0;
- virtual void* GetNativeWindowProperty(const char* name) = 0;
+ virtual void* GetNativeWindowProperty(const char* name) const = 0;
// Returns the native widget's tooltip manager. Called from the View hierarchy
// to update tooltips.
diff --git a/views/widget/native_widget_gtk.cc b/views/widget/native_widget_gtk.cc
index 251177c..c54e96e 100644
--- a/views/widget/native_widget_gtk.cc
+++ b/views/widget/native_widget_gtk.cc
@@ -38,7 +38,6 @@
#include "views/widget/tooltip_manager_gtk.h"
#include "views/widget/widget_delegate.h"
#include "views/window/hit_test.h"
-#include "views/window/native_window_gtk.h"
#if defined(TOUCH_UI)
#if defined(HAVE_XINPUT2)
@@ -353,9 +352,7 @@ GtkWidget* NativeWidgetGtk::null_parent_ = NULL;
// NativeWidgetGtk, public:
NativeWidgetGtk::NativeWidgetGtk(internal::NativeWidgetDelegate* delegate)
- : is_window_(false),
- window_state_(GDK_WINDOW_STATE_WITHDRAWN),
- delegate_(delegate),
+ : delegate_(delegate),
widget_(NULL),
window_contents_(NULL),
child_(false),
@@ -366,6 +363,7 @@ NativeWidgetGtk::NativeWidgetGtk(internal::NativeWidgetDelegate* delegate)
ignore_drag_leave_(false),
opacity_(255),
drag_data_(NULL),
+ window_state_(GDK_WINDOW_STATE_WITHDRAWN),
is_active_(false),
transient_to_parent_(false),
got_initial_focus_in_(false),
@@ -851,14 +849,6 @@ gfx::NativeWindow NativeWidgetGtk::GetNativeWindow() const {
return child_ ? NULL : GTK_WINDOW(widget_);
}
-Window* NativeWidgetGtk::GetContainingWindow() {
- return GetWindowImpl(widget_);
-}
-
-const Window* NativeWidgetGtk::GetContainingWindow() const {
- return GetWindowImpl(widget_);
-}
-
void NativeWidgetGtk::ViewRemoved(View* view) {
if (drop_target_.get())
drop_target_->ResetTargetViewIfEquals(view);
@@ -868,7 +858,7 @@ void NativeWidgetGtk::SetNativeWindowProperty(const char* name, void* value) {
g_object_set_data(G_OBJECT(widget_), name, value);
}
-void* NativeWidgetGtk::GetNativeWindowProperty(const char* name) {
+void* NativeWidgetGtk::GetNativeWindowProperty(const char* name) const {
return g_object_get_data(G_OBJECT(widget_), name);
}
@@ -1774,19 +1764,6 @@ gboolean NativeWidgetGtk::ChildExposeHandler(GtkWidget* widget,
return false;
}
-// static
-Window* NativeWidgetGtk::GetWindowImpl(GtkWidget* widget) {
- GtkWidget* parent = widget;
- while (parent) {
- NativeWidgetGtk* widget_gtk = static_cast<NativeWidgetGtk*>(
- NativeWidget::GetNativeWidgetForNativeView(parent));
- if (widget_gtk && widget_gtk->is_window_)
- return static_cast<NativeWindowGtk*>(widget_gtk)->GetWindow();
- parent = gtk_widget_get_parent(parent);
- }
- return NULL;
-}
-
void NativeWidgetGtk::CreateGtkWidget(const Widget::InitParams& params) {
// We turn off double buffering for two reasons:
// 1. We draw to a canvas then composite to the screen, which means we're
diff --git a/views/widget/native_widget_gtk.h b/views/widget/native_widget_gtk.h
index 85426aa..559d98c 100644
--- a/views/widget/native_widget_gtk.h
+++ b/views/widget/native_widget_gtk.h
@@ -163,11 +163,9 @@ class NativeWidgetGtk : public NativeWidget,
virtual const Widget* GetWidget() const OVERRIDE;
virtual gfx::NativeView GetNativeView() const OVERRIDE;
virtual gfx::NativeWindow GetNativeWindow() const OVERRIDE;
- virtual Window* GetContainingWindow() OVERRIDE;
- virtual const Window* GetContainingWindow() const OVERRIDE;
virtual void ViewRemoved(View* view) OVERRIDE;
virtual void SetNativeWindowProperty(const char* name, void* value) OVERRIDE;
- virtual void* GetNativeWindowProperty(const char* name) OVERRIDE;
+ virtual void* GetNativeWindowProperty(const char* name) const OVERRIDE;
virtual TooltipManager* GetTooltipManager() const OVERRIDE;
virtual bool IsScreenReaderActive() const OVERRIDE;
virtual void SendNativeAccessibilityEvent(
@@ -301,13 +299,6 @@ class NativeWidgetGtk : public NativeWidget,
// when a window holding grab is closed without releasing grab.
virtual void HandleXGrabBroke();
- // Are we a subclass of NativeWindowGtk?
- bool is_window_;
-
- // State of the window, such as fullscreen, hidden...
- // TODO(beng): move to private once NativeWindowGtk no longer refers to it.
- GdkWindowState window_state_;
-
private:
class DropObserver;
friend class DropObserver;
@@ -329,9 +320,6 @@ class NativeWidgetGtk : public NativeWidget,
void OnChildExpose(GtkWidget* child);
static gboolean ChildExposeHandler(GtkWidget* widget, GdkEventExpose* event);
- // Returns the first ancestor of |widget| that is a window.
- static Window* GetWindowImpl(GtkWidget* widget);
-
// Creates the GtkWidget.
void CreateGtkWidget(const Widget::InitParams& params);
@@ -403,6 +391,9 @@ class NativeWidgetGtk : public NativeWidget,
// region to be painted to flash in red.
static bool debug_paint_enabled_;
+ // State of the window, such as fullscreen, hidden...
+ GdkWindowState window_state_;
+
// Are we active?
bool is_active_;
diff --git a/views/widget/native_widget_views.cc b/views/widget/native_widget_views.cc
index f46f0e6..3f400c4 100644
--- a/views/widget/native_widget_views.cc
+++ b/views/widget/native_widget_views.cc
@@ -79,14 +79,6 @@ gfx::NativeWindow NativeWidgetViews::GetNativeWindow() const {
return GetParentNativeWidget()->GetNativeWindow();
}
-Window* NativeWidgetViews::GetContainingWindow() {
- return view_->GetWidget()->AsWindow();
-}
-
-const Window* NativeWidgetViews::GetContainingWindow() const {
- return view_->GetWidget()->AsWindow();
-}
-
void NativeWidgetViews::ViewRemoved(View* view) {
return GetParentNativeWidget()->ViewRemoved(view);
}
@@ -95,7 +87,7 @@ void NativeWidgetViews::SetNativeWindowProperty(const char* name, void* value) {
NOTIMPLEMENTED();
}
-void* NativeWidgetViews::GetNativeWindowProperty(const char* name) {
+void* NativeWidgetViews::GetNativeWindowProperty(const char* name) const {
NOTIMPLEMENTED();
return NULL;
}
diff --git a/views/widget/native_widget_views.h b/views/widget/native_widget_views.h
index cbc910a..1b0a47f 100644
--- a/views/widget/native_widget_views.h
+++ b/views/widget/native_widget_views.h
@@ -43,11 +43,9 @@ class NativeWidgetViews : public NativeWidget {
virtual const Widget* GetWidget() const OVERRIDE;
virtual gfx::NativeView GetNativeView() const OVERRIDE;
virtual gfx::NativeWindow GetNativeWindow() const OVERRIDE;
- virtual Window* GetContainingWindow() OVERRIDE;
- virtual const Window* GetContainingWindow() const OVERRIDE;
virtual void ViewRemoved(View* view) OVERRIDE;
virtual void SetNativeWindowProperty(const char* name, void* value) OVERRIDE;
- virtual void* GetNativeWindowProperty(const char* name) OVERRIDE;
+ virtual void* GetNativeWindowProperty(const char* name) const OVERRIDE;
virtual TooltipManager* GetTooltipManager() const OVERRIDE;
virtual bool IsScreenReaderActive() const OVERRIDE;
virtual void SendNativeAccessibilityEvent(
diff --git a/views/widget/native_widget_win.cc b/views/widget/native_widget_win.cc
index d06b47e..997d50f 100644
--- a/views/widget/native_widget_win.cc
+++ b/views/widget/native_widget_win.cc
@@ -42,7 +42,6 @@
#include "views/widget/root_view.h"
#include "views/widget/widget_delegate.h"
#include "views/window/native_frame_view.h"
-#include "views/window/native_window_win.h"
#pragma comment(lib, "dwmapi.lib")
@@ -50,6 +49,47 @@ using ui::ViewProp;
namespace views {
+namespace internal {
+
+void EnsureRectIsVisibleInRect(const gfx::Rect& parent_rect,
+ gfx::Rect* child_rect,
+ int padding) {
+ DCHECK(child_rect);
+
+ // We use padding here because it allows some of the original web page to
+ // bleed through around the edges.
+ int twice_padding = padding * 2;
+
+ // FIRST, clamp width and height so we don't open child windows larger than
+ // the containing parent.
+ if (child_rect->width() > (parent_rect.width() + twice_padding))
+ child_rect->set_width(std::max(0, parent_rect.width() - twice_padding));
+ if (child_rect->height() > parent_rect.height() + twice_padding)
+ child_rect->set_height(std::max(0, parent_rect.height() - twice_padding));
+
+ // SECOND, clamp x,y position to padding,padding so we don't position child
+ // windows in hyperspace.
+ // TODO(mpcomplete): I don't see what the second check in each 'if' does that
+ // isn't handled by the LAST set of 'ifs'. Maybe we can remove it.
+ if (child_rect->x() < parent_rect.x() ||
+ child_rect->x() > parent_rect.right()) {
+ child_rect->set_x(parent_rect.x() + padding);
+ }
+ if (child_rect->y() < parent_rect.y() ||
+ child_rect->y() > parent_rect.bottom()) {
+ child_rect->set_y(parent_rect.y() + padding);
+ }
+
+ // LAST, nudge the window back up into the client area if its x,y position is
+ // within the parent bounds but its width/height place it off-screen.
+ if (child_rect->bottom() > parent_rect.bottom())
+ child_rect->set_y(parent_rect.bottom() - child_rect->height() - padding);
+ if (child_rect->right() > parent_rect.right())
+ child_rect->set_x(parent_rect.right() - child_rect->width() - padding);
+}
+
+} // namespace internal
+
namespace {
// Returns whether the specified window is the current active window.
@@ -328,8 +368,7 @@ class NativeWidgetWin::ScopedRedrawLock {
// NativeWidgetWin, public:
NativeWidgetWin::NativeWidgetWin(internal::NativeWidgetDelegate* delegate)
- : is_window_(false),
- delegate_(delegate),
+ : delegate_(delegate),
close_widget_factory_(this),
active_mouse_tracking_flags_(0),
use_layered_buffer_(false),
@@ -514,14 +553,6 @@ gfx::NativeWindow NativeWidgetWin::GetNativeWindow() const {
return WindowImpl::hwnd();
}
-Window* NativeWidgetWin::GetContainingWindow() {
- return GetWindowImpl(hwnd());
-}
-
-const Window* NativeWidgetWin::GetContainingWindow() const {
- return GetWindowImpl(hwnd());
-}
-
void NativeWidgetWin::ViewRemoved(View* view) {
if (drop_target_.get())
drop_target_->ResetTargetViewIfEquals(view);
@@ -542,7 +573,7 @@ void NativeWidgetWin::SetNativeWindowProperty(const char* name, void* value) {
props_.push_back(new ViewProp(hwnd(), name, value));
}
-void* NativeWidgetWin::GetNativeWindowProperty(const char* name) {
+void* NativeWidgetWin::GetNativeWindowProperty(const char* name) const {
return ViewProp::GetValue(hwnd(), name);
}
@@ -1156,8 +1187,8 @@ LRESULT NativeWidgetWin::OnCreate(CREATESTRUCT* create_struct) {
// Windows special DWM window frame requires a special tooltip manager so
// that window controls in Chrome windows don't flicker when you move your
// mouse over them. See comment in aero_tooltip_manager.h.
- Window* window = GetWidget()->GetContainingWindow();
- if (window && window->ShouldUseNativeFrame()) {
+ Widget* widget = GetWidget()->GetTopLevelWidget();
+ if (widget && widget->ShouldUseNativeFrame()) {
tooltip_manager_.reset(new AeroTooltipManager(GetWidget()));
} else {
tooltip_manager_.reset(new TooltipManagerWin(GetWidget()));
@@ -2094,21 +2125,6 @@ void NativeWidgetWin::ExecuteSystemMenuCommand(int command) {
// NativeWidgetWin, private:
// static
-Window* NativeWidgetWin::GetWindowImpl(HWND hwnd) {
- // NOTE: we can't use GetAncestor here as constrained windows are a Window,
- // but not a top level window.
- HWND parent = hwnd;
- while (parent) {
- NativeWidgetWin* widget =
- reinterpret_cast<NativeWidgetWin*>(ui::GetWindowUserData(parent));
- if (widget && widget->is_window_)
- return static_cast<NativeWindowWin*>(widget)->GetWindow();
- parent = ::GetParent(parent);
- }
- return NULL;
-}
-
-// static
void NativeWidgetWin::PostProcessActivateMessage(NativeWidgetWin* widget,
int activation_state) {
if (!widget->delegate_->HasFocusManager()) {
@@ -2257,8 +2273,8 @@ void NativeWidgetWin::UnlockUpdates() {
void NativeWidgetWin::ClientAreaSizeChanged() {
RECT r;
- Window* window = GetWidget()->GetContainingWindow();
- if (IsZoomed() || (window && window->ShouldUseNativeFrame()))
+ Widget* widget = GetWidget()->GetTopLevelWidget();
+ if (IsZoomed() || (widget && widget->ShouldUseNativeFrame()))
GetClientRect(&r);
else
GetWindowRect(&r);
diff --git a/views/widget/native_widget_win.h b/views/widget/native_widget_win.h
index 524fd84..5162988 100644
--- a/views/widget/native_widget_win.h
+++ b/views/widget/native_widget_win.h
@@ -39,11 +39,17 @@ namespace views {
class DropTargetWin;
class RootView;
class TooltipManagerWin;
-class Window;
namespace internal {
class NativeWidgetDelegate;
-}
+
+// This is exposed only for testing
+// Adjusts the value of |child_rect| if necessary to ensure that it is
+// completely visible within |parent_rect|.
+void EnsureRectIsVisibleInRect(const gfx::Rect& parent_rect,
+ gfx::Rect* child_rect,
+ int padding);
+} // namespace internal
// A Windows message reflected from other windows. This message is sent
// with the following arguments:
@@ -191,11 +197,9 @@ class NativeWidgetWin : public ui::WindowImpl,
virtual const Widget* GetWidget() const OVERRIDE;
virtual gfx::NativeView GetNativeView() const OVERRIDE;
virtual gfx::NativeWindow GetNativeWindow() const OVERRIDE;
- virtual Window* GetContainingWindow() OVERRIDE;
- virtual const Window* GetContainingWindow() const OVERRIDE;
virtual void ViewRemoved(View* view) OVERRIDE;
virtual void SetNativeWindowProperty(const char* name, void* value) OVERRIDE;
- virtual void* GetNativeWindowProperty(const char* name) OVERRIDE;
+ virtual void* GetNativeWindowProperty(const char* name) const OVERRIDE;
virtual TooltipManager* GetTooltipManager() const OVERRIDE;
virtual bool IsScreenReaderActive() const OVERRIDE;
virtual void SendNativeAccessibilityEvent(
@@ -469,9 +473,6 @@ class NativeWidgetWin : public ui::WindowImpl,
scoped_refptr<DropTargetWin> drop_target_;
- // Are a subclass of NativeWindowWin?
- bool is_window_;
-
const gfx::Rect& invalid_rect() const { return invalid_rect_; }
// Saved window information from before entering fullscreen mode.
@@ -481,10 +482,6 @@ class NativeWidgetWin : public ui::WindowImpl,
private:
typedef ScopedVector<ui::ViewProp> ViewProps;
- // Implementation of GetWindow. Ascends the parents of |hwnd| returning the
- // first ancestor that is a Window.
- static Window* GetWindowImpl(HWND hwnd);
-
// Called after the WM_ACTIVATE message has been processed by the default
// windows procedure.
static void PostProcessActivateMessage(NativeWidgetWin* widget,
diff --git a/views/widget/native_widget_win_unittest.cc b/views/widget/native_widget_win_unittest.cc
index f2465f4..d53ee59 100644
--- a/views/widget/native_widget_win_unittest.cc
+++ b/views/widget/native_widget_win_unittest.cc
@@ -82,5 +82,52 @@ TEST_F(NativeWidgetWinTest, SetBoundsForZoomedWindow) {
window2->CloseNow();
}
+TEST_F(NativeWidgetWinTest, EnsureRectIsVisibleInRect) {
+ gfx::Rect parent_rect(0, 0, 500, 400);
+
+ {
+ // Child rect x < 0
+ gfx::Rect child_rect(-50, 20, 100, 100);
+ internal::EnsureRectIsVisibleInRect(parent_rect, &child_rect, 10);
+ EXPECT_EQ(gfx::Rect(10, 20, 100, 100), child_rect);
+ }
+
+ {
+ // Child rect y < 0
+ gfx::Rect child_rect(20, -50, 100, 100);
+ internal::EnsureRectIsVisibleInRect(parent_rect, &child_rect, 10);
+ EXPECT_EQ(gfx::Rect(20, 10, 100, 100), child_rect);
+ }
+
+ {
+ // Child rect right > parent_rect.right
+ gfx::Rect child_rect(450, 20, 100, 100);
+ internal::EnsureRectIsVisibleInRect(parent_rect, &child_rect, 10);
+ EXPECT_EQ(gfx::Rect(390, 20, 100, 100), child_rect);
+ }
+
+ {
+ // Child rect bottom > parent_rect.bottom
+ gfx::Rect child_rect(20, 350, 100, 100);
+ internal::EnsureRectIsVisibleInRect(parent_rect, &child_rect, 10);
+ EXPECT_EQ(gfx::Rect(20, 290, 100, 100), child_rect);
+ }
+
+ {
+ // Child rect width > parent_rect.width
+ gfx::Rect child_rect(20, 20, 700, 100);
+ internal::EnsureRectIsVisibleInRect(parent_rect, &child_rect, 10);
+ EXPECT_EQ(gfx::Rect(20, 20, 480, 100), child_rect);
+ }
+
+ {
+ // Child rect height > parent_rect.height
+ gfx::Rect child_rect(20, 20, 100, 700);
+ internal::EnsureRectIsVisibleInRect(parent_rect, &child_rect, 10);
+ EXPECT_EQ(gfx::Rect(20, 20, 100, 380), child_rect);
+ }
+}
+
+
} // namespace
} // namespace views
diff --git a/views/widget/root_view.cc b/views/widget/root_view.cc
index ce9cc7a..1136908 100644
--- a/views/widget/root_view.cc
+++ b/views/widget/root_view.cc
@@ -15,7 +15,6 @@
#include "views/focus/view_storage.h"
#include "views/layout/fill_layout.h"
#include "views/widget/widget.h"
-#include "views/window/window.h"
#if defined(TOUCH_UI)
#include "views/touchui/gesture_manager.h"
diff --git a/views/widget/widget.cc b/views/widget/widget.cc
index 8638f7d..f282823 100644
--- a/views/widget/widget.cc
+++ b/views/widget/widget.cc
@@ -113,6 +113,38 @@ Widget::~Widget() {
}
// static
+Widget* Widget::CreateWindow(WidgetDelegate* delegate) {
+ return CreateWindowWithParentAndBounds(delegate, NULL, gfx::Rect());
+}
+
+// static
+Widget* Widget::CreateWindowWithParent(WidgetDelegate* delegate,
+ gfx::NativeWindow parent) {
+ return CreateWindowWithParentAndBounds(delegate, parent, gfx::Rect());
+}
+
+// static
+Widget* Widget::CreateWindowWithBounds(WidgetDelegate* delegate,
+ const gfx::Rect& bounds) {
+ return CreateWindowWithParentAndBounds(delegate, NULL, bounds);
+}
+
+// static
+Widget* Widget::CreateWindowWithParentAndBounds(WidgetDelegate* delegate,
+ gfx::NativeWindow parent,
+ const gfx::Rect& bounds) {
+ Widget* widget = new Widget;
+ Widget::InitParams params;
+ params.delegate = delegate;
+#if defined(OS_WIN)
+ params.parent = parent;
+#endif
+ params.bounds = bounds;
+ widget->Init(params);
+ return widget;
+}
+
+// static
void Widget::SetPureViews(bool pure) {
use_pure_views = pure;
}
@@ -186,14 +218,6 @@ bool Widget::GetAccelerator(int cmd_id, ui::Accelerator* accelerator) {
return false;
}
-Window* Widget::GetContainingWindow() {
- return native_widget_->GetContainingWindow();
-}
-
-const Window* Widget::GetContainingWindow() const {
- return native_widget_->GetContainingWindow();
-}
-
void Widget::ViewHierarchyChanged(bool is_add, View* parent, View* child) {
if (!is_add) {
if (child == dragged_view_)
@@ -219,14 +243,6 @@ void Widget::NotifyNativeViewHierarchyChanged(bool attached,
root_view_->NotifyNativeViewHierarchyChanged(attached, native_view);
}
-Window* Widget::AsWindow() {
- return NULL;
-}
-
-const Window* Widget::AsWindow() const {
- return NULL;
-}
-
// Converted methods (see header) ----------------------------------------------
Widget* Widget::GetTopLevelWidget() {
diff --git a/views/widget/widget.h b/views/widget/widget.h
index 9916d95c..42866f6 100644
--- a/views/widget/widget.h
+++ b/views/widget/widget.h
@@ -26,6 +26,9 @@
#if defined(IsMinimized)
#undef IsMinimized
#endif
+#if defined(CreateWindow)
+#undef CreateWindow
+#endif
#endif
namespace gfx {
@@ -52,7 +55,6 @@ class NonClientFrameView;
class TooltipManager;
class View;
class WidgetDelegate;
-class Window;
namespace internal {
class RootView;
}
@@ -143,6 +145,16 @@ class Widget : public internal::NativeWidgetDelegate,
Widget();
virtual ~Widget();
+ // Creates a decorated window Widget with the specified properties.
+ static Widget* CreateWindow(WidgetDelegate* delegate);
+ static Widget* CreateWindowWithParent(WidgetDelegate* delegate,
+ gfx::NativeWindow parent);
+ static Widget* CreateWindowWithBounds(WidgetDelegate* delegate,
+ const gfx::Rect& bounds);
+ static Widget* CreateWindowWithParentAndBounds(WidgetDelegate* delegate,
+ gfx::NativeWindow parent,
+ const gfx::Rect& bounds);
+
// Enumerates all windows pertaining to us and notifies their
// view hierarchies that the locale has changed.
static void NotifyLocaleChanged();
@@ -196,11 +208,6 @@ class Widget : public internal::NativeWidgetDelegate,
// no accelerator associated with a given id, which is a common condition.
virtual bool GetAccelerator(int cmd_id, ui::Accelerator* accelerator);
- // Returns the Window containing this Widget, or NULL if not contained in a
- // window.
- Window* GetContainingWindow();
- const Window* GetContainingWindow() const;
-
// Forwarded from the RootView so that the widget can do any cleanup.
void ViewHierarchyChanged(bool is_add, View* parent, View* child);
@@ -454,10 +461,6 @@ class Widget : public internal::NativeWidgetDelegate,
const NativeWidget* native_widget() const { return native_widget_; }
NativeWidget* native_widget() { return native_widget_; }
- // TODO(beng): remove once Window is folded in.
- virtual Window* AsWindow();
- virtual const Window* AsWindow() const;
-
// Overridden from NativeWidgetDelegate:
virtual bool IsModal() const OVERRIDE;
virtual bool IsDialogBox() const OVERRIDE;
diff --git a/views/widget/widget_delegate.cc b/views/widget/widget_delegate.cc
index f58e891..aecf12f 100644
--- a/views/widget/widget_delegate.cc
+++ b/views/widget/widget_delegate.cc
@@ -6,13 +6,16 @@
#include "views/view.h"
#include "views/views_delegate.h"
+#include "views/widget/widget.h"
#include "views/window/client_view.h"
-#include "views/window/window.h"
#include "third_party/skia/include/core/SkBitmap.h"
namespace views {
-WidgetDelegate::WidgetDelegate() : window_(NULL) {
+////////////////////////////////////////////////////////////////////////////////
+// WidgetDelegate:
+
+WidgetDelegate::WidgetDelegate() : default_contents_view_(NULL) {
}
void WidgetDelegate::OnWidgetActivated(bool active) {
@@ -104,35 +107,43 @@ void WidgetDelegate::SaveWindowPlacement(const gfx::Rect& bounds,
return;
ViewsDelegate::views_delegate->SaveWindowPlacement(
- window_, window_name, bounds, maximized);
+ GetWidget(), window_name, bounds, maximized);
}
bool WidgetDelegate::GetSavedWindowBounds(gfx::Rect* bounds) const {
- DCHECK(window_);
std::wstring window_name = GetWindowName();
if (!ViewsDelegate::views_delegate || window_name.empty())
return false;
return ViewsDelegate::views_delegate->GetSavedWindowBounds(
- window_, window_name, bounds);
+ GetWidget(), window_name, bounds);
}
bool WidgetDelegate::GetSavedMaximizedState(bool* maximized) const {
- DCHECK(window_);
std::wstring window_name = GetWindowName();
if (!ViewsDelegate::views_delegate || window_name.empty())
return false;
return ViewsDelegate::views_delegate->GetSavedMaximizedState(
- window_, window_name, maximized);
+ GetWidget(), window_name, maximized);
}
bool WidgetDelegate::ShouldRestoreWindowSize() const {
return true;
}
+Widget* WidgetDelegate::GetWidget() {
+ return NULL;
+}
+
+const Widget* WidgetDelegate::GetWidget() const {
+ return NULL;
+}
+
View* WidgetDelegate::GetContentsView() {
- return new View;
+ if (!default_contents_view_)
+ default_contents_view_ = new View;
+ return default_contents_view_;
}
ClientView* WidgetDelegate::CreateClientView(Widget* widget) {
@@ -147,5 +158,22 @@ bool WidgetDelegate::WillProcessWorkAreaChange() const {
return false;
}
+////////////////////////////////////////////////////////////////////////////////
+// WidgetDelegateView:
+
+WidgetDelegateView::WidgetDelegateView() {
+}
+
+WidgetDelegateView::~WidgetDelegateView() {
+}
+
+Widget* WidgetDelegateView::GetWidget() {
+ return View::GetWidget();
+}
+
+const Widget* WidgetDelegateView::GetWidget() const {
+ return View::GetWidget();
+}
+
} // namespace views
diff --git a/views/widget/widget_delegate.h b/views/widget/widget_delegate.h
index a985051..8c9e069 100644
--- a/views/widget/widget_delegate.h
+++ b/views/widget/widget_delegate.h
@@ -10,6 +10,7 @@
#include "base/memory/scoped_ptr.h"
#include "ui/base/accessibility/accessibility_types.h"
+#include "views/view.h"
class SkBitmap;
@@ -23,7 +24,6 @@ class DialogDelegate;
class NonClientFrameView;
class View;
class Widget;
-class Window;
// WidgetDelegate interface
// Handles events on Widgets in context-specific ways.
@@ -134,10 +134,14 @@ class WidgetDelegate {
virtual void OnWindowBeginUserBoundsChange() {}
virtual void OnWindowEndUserBoundsChange() {}
- // Returns the View that is contained within this Window.
+ // Returns the Widget associated with this delegate.
+ virtual Widget* GetWidget();
+ virtual const Widget* GetWidget() const;
+
+ // Returns the View that is contained within this Widget.
virtual View* GetContentsView();
- // Called by the Window to create the Client View used to host the contents
+ // Called by the Widget to create the Client View used to host the contents
// of the widget.
virtual ClientView* CreateClientView(Widget* widget);
@@ -151,15 +155,30 @@ class WidgetDelegate {
// manage the positions by ourselves.
virtual bool WillProcessWorkAreaChange() const;
- Window* window() const { return window_; }
-
protected:
virtual ~WidgetDelegate() {}
private:
- friend class Window;
- // The Window this delegate is bound to. Weak reference.
- Window* window_;
+ View* default_contents_view_;
+
+ DISALLOW_COPY_AND_ASSIGN(WidgetDelegate);
+};
+
+// A WidgetDelegate implementation that is-a View. Used to override GetWidget()
+// to call View's GetWidget() for the common case where a WidgetDelegate
+// implementation is-a View.
+class WidgetDelegateView : public WidgetDelegate,
+ public View {
+ public:
+ WidgetDelegateView();
+ virtual ~WidgetDelegateView();
+
+ // Overridden from WidgetDelegate:
+ virtual Widget* GetWidget() OVERRIDE;
+ virtual const Widget* GetWidget() const OVERRIDE;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(WidgetDelegateView);
};
} // namespace views
diff --git a/views/window/client_view.cc b/views/window/client_view.cc
index bbea28c..6646727 100644
--- a/views/window/client_view.cc
+++ b/views/window/client_view.cc
@@ -33,6 +33,10 @@ DialogClientView* ClientView::AsDialogClientView() {
return NULL;
}
+const DialogClientView* ClientView::AsDialogClientView() const {
+ return NULL;
+}
+
bool ClientView::CanClose() {
return true;
}
diff --git a/views/window/client_view.h b/views/window/client_view.h
index de1ca7e..0af791e 100644
--- a/views/window/client_view.h
+++ b/views/window/client_view.h
@@ -35,6 +35,7 @@ class ClientView : public View {
// Manual RTTI ftw.
virtual DialogClientView* AsDialogClientView();
+ virtual const DialogClientView* AsDialogClientView() const;
// Returns true to signal that the Widget can be closed. Specialized
// ClientView subclasses can override this default behavior to allow the
diff --git a/views/window/custom_frame_view.cc b/views/window/custom_frame_view.cc
index 6f9bb8f..ff59913 100644
--- a/views/window/custom_frame_view.cc
+++ b/views/window/custom_frame_view.cc
@@ -12,16 +12,16 @@
#include "ui/gfx/canvas.h"
#include "ui/gfx/font.h"
#include "ui/gfx/path.h"
+#include "views/widget/widget_delegate.h"
#include "views/window/client_view.h"
#include "views/window/window_shape.h"
-#include "views/window/window_delegate.h"
#if defined(OS_LINUX)
#include "views/window/hit_test.h"
#endif
#if defined(OS_WIN)
-#include "views/window/native_window_win.h"
+#include "views/widget/native_widget_win.h"
#endif
namespace views {
@@ -568,7 +568,7 @@ void CustomFrameView::InitClass() {
static bool initialized = false;
if (!initialized) {
#if defined(OS_WIN)
- title_font_ = new gfx::Font(NativeWindowWin::GetWindowTitleFont());
+ title_font_ = new gfx::Font(NativeWidgetWin::GetWindowTitleFont());
#elif defined(OS_LINUX)
// TODO(ben): need to resolve what font this is.
title_font_ = new gfx::Font();
diff --git a/views/window/dialog_client_view.cc b/views/window/dialog_client_view.cc
index f4a3985..b17f370 100644
--- a/views/window/dialog_client_view.cc
+++ b/views/window/dialog_client_view.cc
@@ -302,6 +302,10 @@ DialogClientView* DialogClientView::AsDialogClientView() {
return this;
}
+const DialogClientView* DialogClientView::AsDialogClientView() const {
+ return this;
+}
+
////////////////////////////////////////////////////////////////////////////////
// DialogClientView, View overrides:
diff --git a/views/window/dialog_client_view.h b/views/window/dialog_client_view.h
index 27365b5..ad72e77 100644
--- a/views/window/dialog_client_view.h
+++ b/views/window/dialog_client_view.h
@@ -73,6 +73,7 @@ class DialogClientView : public ClientView,
virtual void WidgetClosing() OVERRIDE;
virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE;
virtual DialogClientView* AsDialogClientView() OVERRIDE;
+ virtual const DialogClientView* AsDialogClientView() const OVERRIDE;
// FocusChangeListener implementation:
virtual void FocusWillChange(View* focused_before,
diff --git a/views/window/dialog_delegate.cc b/views/window/dialog_delegate.cc
index ee22c12..13ff590 100644
--- a/views/window/dialog_delegate.cc
+++ b/views/window/dialog_delegate.cc
@@ -6,11 +6,12 @@
#include "base/logging.h"
#include "views/controls/button/native_button.h"
-#include "views/window/window.h"
+#include "views/widget/widget.h"
namespace views {
-// Overridden from WindowDelegate:
+////////////////////////////////////////////////////////////////////////////////
+// DialogDelegate:
DialogDelegate* DialogDelegate::AsDialogDelegate() { return this; }
@@ -72,7 +73,7 @@ bool DialogDelegate::Accept() {
View* DialogDelegate::GetInitiallyFocusedView() {
// Focus the default button if any.
- DialogClientView* dcv = GetDialogClientView();
+ const DialogClientView* dcv = GetDialogClientView();
int default_button = GetDefaultDialogButton();
if (default_button == MessageBoxFlags::DIALOGBUTTON_NONE)
return NULL;
@@ -94,12 +95,33 @@ ClientView* DialogDelegate::CreateClientView(Widget* widget) {
return new DialogClientView(widget, GetContentsView());
}
-DialogClientView* DialogDelegate::GetDialogClientView() const {
- return window()->client_view()->AsDialogClientView();
+const DialogClientView* DialogDelegate::GetDialogClientView() const {
+ return GetWidget()->client_view()->AsDialogClientView();
+}
+
+DialogClientView* DialogDelegate::GetDialogClientView() {
+ return GetWidget()->client_view()->AsDialogClientView();
}
ui::AccessibilityTypes::Role DialogDelegate::GetAccessibleWindowRole() const {
return ui::AccessibilityTypes::ROLE_DIALOG;
}
+////////////////////////////////////////////////////////////////////////////////
+// DialogDelegateView:
+
+DialogDelegateView::DialogDelegateView() {
+}
+
+DialogDelegateView::~DialogDelegateView() {
+}
+
+Widget* DialogDelegateView::GetWidget() {
+ return View::GetWidget();
+}
+
+const Widget* DialogDelegateView::GetWidget() const {
+ return View::GetWidget();
+}
+
} // namespace views
diff --git a/views/window/dialog_delegate.h b/views/window/dialog_delegate.h
index 607132b..bfcec75 100644
--- a/views/window/dialog_delegate.h
+++ b/views/window/dialog_delegate.h
@@ -8,8 +8,8 @@
#include "ui/base/accessibility/accessibility_types.h"
#include "ui/base/message_box_flags.h"
+#include "views/widget/widget_delegate.h"
#include "views/window/dialog_client_view.h"
-#include "views/window/window_delegate.h"
using ui::MessageBoxFlags;
@@ -27,7 +27,7 @@ class View;
// certain events.
//
///////////////////////////////////////////////////////////////////////////////
-class DialogDelegate : public WindowDelegate {
+class DialogDelegate : public WidgetDelegate {
public:
virtual DialogDelegate* AsDialogDelegate();
@@ -104,13 +104,32 @@ class DialogDelegate : public WindowDelegate {
// A helper for accessing the DialogClientView object contained by this
// delegate's Window.
- DialogClientView* GetDialogClientView() const;
+ const DialogClientView* GetDialogClientView() const;
+ DialogClientView* GetDialogClientView();
protected:
// Overridden from WindowDelegate:
virtual ui::AccessibilityTypes::Role GetAccessibleWindowRole() const OVERRIDE;
};
+// A DialogDelegate implementation that is-a View. Used to override GetWidget()
+// to call View's GetWidget() for the common case where a DialogDelegate
+// implementation is-a View.
+class DialogDelegateView : public DialogDelegate,
+ public View {
+ public:
+ DialogDelegateView();
+ virtual ~DialogDelegateView();
+
+ // Overridden from DialogDelegate:
+ virtual Widget* GetWidget() OVERRIDE;
+ virtual const Widget* GetWidget() const OVERRIDE;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(DialogDelegateView);
+};
+
+
} // namespace views
#endif // VIEWS_WINDOW_DIALOG_DELEGATE_H_
diff --git a/views/window/native_window.h b/views/window/native_window.h
deleted file mode 100644
index de5cce8..0000000
--- a/views/window/native_window.h
+++ /dev/null
@@ -1,51 +0,0 @@
-// 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_WIDGET_NATIVE_WINDOW_H_
-#define VIEWS_WIDGET_NATIVE_WINDOW_H_
-#pragma once
-
-#include "ui/base/accessibility/accessibility_types.h"
-#include "ui/gfx/native_widget_types.h"
-#include "views/window/window.h"
-
-class SkBitmap;
-
-namespace gfx {
-class Rect;
-class Size;
-}
-
-namespace views {
-
-class NativeWidget;
-class NonClientFrameView;
-
-////////////////////////////////////////////////////////////////////////////////
-// NativeWindow interface
-//
-// An interface implemented by an object that encapsulates a native window.
-//
-class NativeWindow {
- public:
- virtual ~NativeWindow() {}
-
- // Creates an appropriate default NativeWindow implementation for the current
- // OS/circumstance.
- static NativeWindow* CreateNativeWindow(
- internal::NativeWindowDelegate* delegate);
-
- virtual Window* GetWindow() = 0;
- virtual const Window* GetWindow() const = 0;
-
- virtual NativeWidget* AsNativeWidget() = 0;
- virtual const NativeWidget* AsNativeWidget() const = 0;
-
- protected:
- friend class Window;
-};
-
-} // namespace views
-
-#endif // VIEWS_WIDGET_NATIVE_WINDOW_H_
diff --git a/views/window/native_window_delegate.h b/views/window/native_window_delegate.h
deleted file mode 100644
index 41621ac..0000000
--- a/views/window/native_window_delegate.h
+++ /dev/null
@@ -1,36 +0,0 @@
-// 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_WIDGET_NATIVE_WINDOW_DELEGATE_H_
-#define VIEWS_WIDGET_NATIVE_WINDOW_DELEGATE_H_
-#pragma once
-
-namespace ui {
-class ThemeProvider;
-}
-
-namespace views {
-namespace internal {
-
-////////////////////////////////////////////////////////////////////////////////
-// NativeWindowDelegate interface
-//
-// An interface implemented by an object that receives notifications from a
-// NativeWindow implementation.
-//
-class NativeWindowDelegate {
- public:
- virtual ~NativeWindowDelegate() {}
-
- //
- virtual Window* AsWindow() = 0;
-
- //
- virtual NativeWidgetDelegate* AsNativeWidgetDelegate() = 0;
-};
-
-} // namespace internal
-} // namespace views
-
-#endif // VIEWS_WIDGET_NATIVE_WINDOW_DELEGATE_H_
diff --git a/views/window/native_window_gtk.cc b/views/window/native_window_gtk.cc
deleted file mode 100644
index 2ca707a..0000000
--- a/views/window/native_window_gtk.cc
+++ /dev/null
@@ -1,59 +0,0 @@
-// 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_gtk.h"
-
-#include "base/i18n/rtl.h"
-#include "base/utf_string_conversions.h"
-#include "ui/gfx/path.h"
-#include "ui/gfx/rect.h"
-#include "views/events/event.h"
-#include "views/window/hit_test.h"
-#include "views/window/native_window_delegate.h"
-#include "views/window/non_client_view.h"
-#include "views/window/window_delegate.h"
-
-namespace views {
-
-NativeWindowGtk::NativeWindowGtk(internal::NativeWindowDelegate* delegate)
- : NativeWidgetGtk(delegate->AsNativeWidgetDelegate()),
- delegate_(delegate) {
- is_window_ = true;
-}
-
-NativeWindowGtk::~NativeWindowGtk() {
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// NativeWindowGtk, NativeWindow implementation:
-
-NativeWidget* NativeWindowGtk::AsNativeWidget() {
- return this;
-}
-
-const NativeWidget* NativeWindowGtk::AsNativeWidget() const {
- return this;
-}
-
-Window* NativeWindowGtk::GetWindow() {
- return delegate_->AsWindow();
-}
-
-const Window* NativeWindowGtk::GetWindow() const {
- return delegate_->AsWindow();
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// NativeWindowGtk, private:
-
-////////////////////////////////////////////////////////////////////////////////
-// NativeWindow, public:
-
-// static
-NativeWindow* NativeWindow::CreateNativeWindow(
- internal::NativeWindowDelegate* delegate) {
- return new NativeWindowGtk(delegate);
-}
-
-} // namespace views
diff --git a/views/window/native_window_gtk.h b/views/window/native_window_gtk.h
deleted file mode 100644
index 9988a23..0000000
--- a/views/window/native_window_gtk.h
+++ /dev/null
@@ -1,44 +0,0 @@
-// 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_GTK_H_
-#define VIEWS_WINDOW_NATIVE_WINDOW_GTK_H_
-#pragma once
-
-#include "base/basictypes.h"
-#include "views/widget/native_widget_gtk.h"
-#include "views/window/native_window.h"
-
-namespace views {
-namespace internal {
-class NativeWindowDelegate;
-}
-
-// Window implementation for Gtk.
-class NativeWindowGtk : public NativeWidgetGtk, public NativeWindow {
- public:
- explicit NativeWindowGtk(internal::NativeWindowDelegate* delegate);
- virtual ~NativeWindowGtk();
-
- virtual Window* GetWindow() OVERRIDE;
- virtual const Window* GetWindow() const OVERRIDE;
-
- protected:
- // Overridden from NativeWindow:
- virtual NativeWidget* AsNativeWidget() OVERRIDE;
- virtual const NativeWidget* AsNativeWidget() const OVERRIDE;
-
- // For the constructor.
- friend class Window;
-
- private:
- // A delegate implementation that handles events received here.
- internal::NativeWindowDelegate* delegate_;
-
- DISALLOW_COPY_AND_ASSIGN(NativeWindowGtk);
-};
-
-} // namespace views
-
-#endif // VIEWS_WINDOW_NATIVE_WINDOW_GTK_H_
diff --git a/views/window/native_window_views.cc b/views/window/native_window_views.cc
deleted file mode 100644
index 409380c..0000000
--- a/views/window/native_window_views.cc
+++ /dev/null
@@ -1,46 +0,0 @@
-// 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;
-}
-
-void NativeWindowViews::BecomeModal() {
- NOTIMPLEMENTED();
-}
-
-} // namespace views
diff --git a/views/window/native_window_views.h b/views/window/native_window_views.h
deleted file mode 100644
index f944c00..0000000
--- a/views/window/native_window_views.h
+++ /dev/null
@@ -1,41 +0,0 @@
-// 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 void BecomeModal() 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
deleted file mode 100644
index a902d10..0000000
--- a/views/window/native_window_win.cc
+++ /dev/null
@@ -1,107 +0,0 @@
-// 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_win.h"
-
-#include "base/i18n/rtl.h"
-#include "ui/base/accessibility/accessibility_types.h"
-#include "ui/base/keycodes/keyboard_code_conversion_win.h"
-#include "ui/base/l10n/l10n_util_win.h"
-#include "ui/base/theme_provider.h"
-#include "ui/base/win/hwnd_util.h"
-#include "ui/gfx/font.h"
-#include "ui/gfx/path.h"
-#include "views/accessibility/native_view_accessibility_win.h"
-#include "views/window/client_view.h"
-#include "views/window/native_window_delegate.h"
-#include "views/window/non_client_view.h"
-#include "views/window/window_delegate.h"
-
-namespace views {
-namespace internal {
-
-void EnsureRectIsVisibleInRect(const gfx::Rect& parent_rect,
- gfx::Rect* child_rect,
- int padding) {
- DCHECK(child_rect);
-
- // We use padding here because it allows some of the original web page to
- // bleed through around the edges.
- int twice_padding = padding * 2;
-
- // FIRST, clamp width and height so we don't open child windows larger than
- // the containing parent.
- if (child_rect->width() > (parent_rect.width() + twice_padding))
- child_rect->set_width(std::max(0, parent_rect.width() - twice_padding));
- if (child_rect->height() > parent_rect.height() + twice_padding)
- child_rect->set_height(std::max(0, parent_rect.height() - twice_padding));
-
- // SECOND, clamp x,y position to padding,padding so we don't position child
- // windows in hyperspace.
- // TODO(mpcomplete): I don't see what the second check in each 'if' does that
- // isn't handled by the LAST set of 'ifs'. Maybe we can remove it.
- if (child_rect->x() < parent_rect.x() ||
- child_rect->x() > parent_rect.right()) {
- child_rect->set_x(parent_rect.x() + padding);
- }
- if (child_rect->y() < parent_rect.y() ||
- child_rect->y() > parent_rect.bottom()) {
- child_rect->set_y(parent_rect.y() + padding);
- }
-
- // LAST, nudge the window back up into the client area if its x,y position is
- // within the parent bounds but its width/height place it off-screen.
- if (child_rect->bottom() > parent_rect.bottom())
- child_rect->set_y(parent_rect.bottom() - child_rect->height() - padding);
- if (child_rect->right() > parent_rect.right())
- child_rect->set_x(parent_rect.right() - child_rect->width() - padding);
-}
-
-} // namespace internal
-
-////////////////////////////////////////////////////////////////////////////////
-// NativeWindowWin, public:
-
-NativeWindowWin::NativeWindowWin(internal::NativeWindowDelegate* delegate)
- : NativeWidgetWin(delegate->AsNativeWidgetDelegate()),
- delegate_(delegate) {
- is_window_ = true;
- // Initialize these values to 0 so that subclasses can override the default
- // behavior before calling Init.
- set_window_style(0);
- set_window_ex_style(0);
-}
-
-NativeWindowWin::~NativeWindowWin() {
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// NativeWindowWin, NativeWindow implementation:
-
-Window* NativeWindowWin::GetWindow() {
- return delegate_->AsWindow();
-}
-
-const Window* NativeWindowWin::GetWindow() const {
- return delegate_->AsWindow();
-}
-
-NativeWidget* NativeWindowWin::AsNativeWidget() {
- return this;
-}
-
-const NativeWidget* NativeWindowWin::AsNativeWidget() const {
- return this;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// NativeWindow, public:
-
-// static
-NativeWindow* NativeWindow::CreateNativeWindow(
- internal::NativeWindowDelegate* delegate) {
- return new NativeWindowWin(delegate);
-}
-
-} // namespace views
diff --git a/views/window/native_window_win.h b/views/window/native_window_win.h
deleted file mode 100644
index 956a3ac..0000000
--- a/views/window/native_window_win.h
+++ /dev/null
@@ -1,60 +0,0 @@
-// 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_WIN_H_
-#define VIEWS_WINDOW_NATIVE_WINDOW_WIN_H_
-#pragma once
-
-#include "views/widget/native_widget_win.h"
-#include "views/window/native_window.h"
-
-namespace views {
-namespace internal {
-class NativeWindowDelegate;
-
-// This is exposed only for testing
-// Adjusts the value of |child_rect| if necessary to ensure that it is
-// completely visible within |parent_rect|.
-void EnsureRectIsVisibleInRect(const gfx::Rect& parent_rect,
- gfx::Rect* child_rect,
- int padding);
-
-} // namespace internal
-
-////////////////////////////////////////////////////////////////////////////////
-//
-// NativeWindowWin
-//
-// A NativeWindowWin is a NativeWidgetWin that encapsulates a window with a
-// frame. The frame may or may not be rendered by the operating system. The
-// window may or may not be top level.
-//
-////////////////////////////////////////////////////////////////////////////////
-class NativeWindowWin : public NativeWidgetWin,
- public NativeWindow {
- public:
- explicit NativeWindowWin(internal::NativeWindowDelegate* delegate);
- virtual ~NativeWindowWin();
-
- // Overridden from NativeWindow:
- virtual Window* GetWindow() OVERRIDE;
- virtual const Window* GetWindow() const OVERRIDE;
-
- protected:
- friend Window;
-
- // Overridden from NativeWindow:
- virtual NativeWidget* AsNativeWidget() OVERRIDE;
- virtual const NativeWidget* AsNativeWidget() const OVERRIDE;
-
- private:
- // A delegate implementation that handles events received here.
- internal::NativeWindowDelegate* delegate_;
-
- DISALLOW_COPY_AND_ASSIGN(NativeWindowWin);
-};
-
-} // namespace views
-
-#endif // VIEWS_WINDOW_NATIVE_WINDOW_WIN_H_
diff --git a/views/window/native_window_win_unittest.cc b/views/window/native_window_win_unittest.cc
deleted file mode 100644
index a612af5..0000000
--- a/views/window/native_window_win_unittest.cc
+++ /dev/null
@@ -1,58 +0,0 @@
-// 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_win.h"
-
-#include "testing/gtest/include/gtest/gtest.h"
-#include "ui/gfx/rect.h"
-
-namespace views {
-
-TEST(NativeWindowWinTest, EnsureRectIsVisibleInRect) {
- gfx::Rect parent_rect(0, 0, 500, 400);
-
- {
- // Child rect x < 0
- gfx::Rect child_rect(-50, 20, 100, 100);
- internal::EnsureRectIsVisibleInRect(parent_rect, &child_rect, 10);
- EXPECT_EQ(gfx::Rect(10, 20, 100, 100), child_rect);
- }
-
- {
- // Child rect y < 0
- gfx::Rect child_rect(20, -50, 100, 100);
- internal::EnsureRectIsVisibleInRect(parent_rect, &child_rect, 10);
- EXPECT_EQ(gfx::Rect(20, 10, 100, 100), child_rect);
- }
-
- {
- // Child rect right > parent_rect.right
- gfx::Rect child_rect(450, 20, 100, 100);
- internal::EnsureRectIsVisibleInRect(parent_rect, &child_rect, 10);
- EXPECT_EQ(gfx::Rect(390, 20, 100, 100), child_rect);
- }
-
- {
- // Child rect bottom > parent_rect.bottom
- gfx::Rect child_rect(20, 350, 100, 100);
- internal::EnsureRectIsVisibleInRect(parent_rect, &child_rect, 10);
- EXPECT_EQ(gfx::Rect(20, 290, 100, 100), child_rect);
- }
-
- {
- // Child rect width > parent_rect.width
- gfx::Rect child_rect(20, 20, 700, 100);
- internal::EnsureRectIsVisibleInRect(parent_rect, &child_rect, 10);
- EXPECT_EQ(gfx::Rect(20, 20, 480, 100), child_rect);
- }
-
- {
- // Child rect height > parent_rect.height
- gfx::Rect child_rect(20, 20, 100, 700);
- internal::EnsureRectIsVisibleInRect(parent_rect, &child_rect, 10);
- EXPECT_EQ(gfx::Rect(20, 20, 100, 380), child_rect);
- }
-}
-
-} // namespace views
diff --git a/views/window/non_client_view.cc b/views/window/non_client_view.cc
index fdf4230..1f7effa 100644
--- a/views/window/non_client_view.cc
+++ b/views/window/non_client_view.cc
@@ -8,7 +8,6 @@
#include "views/widget/root_view.h"
#include "views/widget/widget.h"
#include "views/window/client_view.h"
-#include "views/window/window.h"
#if !defined(OS_WIN)
#include "views/window/hit_test.h"
diff --git a/views/window/window.cc b/views/window/window.cc
deleted file mode 100644
index ecfaa57..0000000
--- a/views/window/window.cc
+++ /dev/null
@@ -1,82 +0,0 @@
-// 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/window.h"
-
-#include "base/string_util.h"
-#include "third_party/skia/include/core/SkBitmap.h"
-#include "ui/gfx/font.h"
-#include "ui/gfx/rect.h"
-#include "ui/gfx/size.h"
-#include "views/widget/widget.h"
-#include "views/widget/native_widget.h"
-#include "views/window/native_window.h"
-#include "views/window/window_delegate.h"
-
-namespace views {
-
-////////////////////////////////////////////////////////////////////////////////
-// Window, public:
-
-Window::InitParams::InitParams(WindowDelegate* window_delegate)
- : window_delegate(window_delegate),
- parent_window(NULL),
- native_window(NULL),
- widget_init_params(Widget::InitParams::TYPE_WINDOW) {
-}
-
-Window::Window()
- : native_window_(NULL) {
-}
-
-Window::~Window() {
-}
-
-// static
-Window* Window::CreateChromeWindow(gfx::NativeWindow parent,
- const gfx::Rect& bounds,
- WindowDelegate* window_delegate) {
- Window* window = new Window;
- Window::InitParams params(window_delegate);
- params.parent_window = parent;
-#if defined(OS_WIN)
- params.widget_init_params.parent = parent;
-#endif
- params.widget_init_params.bounds = bounds;
- window->InitWindow(params);
- return window;
-}
-
-void Window::InitWindow(const InitParams& params) {
- native_window_ =
- params.native_window ? params.native_window
- : NativeWindow::CreateNativeWindow(this);
- InitParams modified_params = params;
- modified_params.widget_init_params.delegate = params.window_delegate;
- DCHECK(!modified_params.widget_init_params.delegate->window_);
- modified_params.widget_init_params.delegate->window_ = this;
- modified_params.widget_init_params.native_widget =
- native_window_->AsNativeWidget();
- Init(modified_params.widget_init_params);
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// Window, Widget overrides:
-
-Window* Window::AsWindow() {
- return this;
-}
-
-const Window* Window::AsWindow() const {
- return this;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// Window, internal::NativeWindowDelegate implementation:
-
-internal::NativeWidgetDelegate* Window::AsNativeWidgetDelegate() {
- return this;
-}
-
-} // namespace views
diff --git a/views/window/window.h b/views/window/window.h
deleted file mode 100644
index e3a36d5..0000000
--- a/views/window/window.h
+++ /dev/null
@@ -1,82 +0,0 @@
-// 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_WINDOW_H_
-#define VIEWS_WINDOW_WINDOW_H_
-#pragma once
-
-#include "ui/gfx/native_widget_types.h"
-#include "views/widget/widget.h"
-#include "views/window/native_window_delegate.h"
-
-namespace gfx {
-class Rect;
-class Size;
-} // namespace gfx
-
-namespace views {
-
-class NativeWindow;
-class Widget;
-class WindowDelegate;
-
-////////////////////////////////////////////////////////////////////////////////
-// Window class
-//
-// Encapsulates window-like behavior. See WindowDelegate.
-//
-class Window : public Widget,
- public internal::NativeWindowDelegate {
- public:
- struct InitParams {
- // |window_delegate| cannot be NULL.
- explicit InitParams(WindowDelegate* window_delegate);
-
- WindowDelegate* window_delegate;
- gfx::NativeWindow parent_window;
- NativeWindow* native_window;
- Widget::InitParams widget_init_params;
- };
-
- Window();
- virtual ~Window();
-
- // Creates an instance of an object implementing this interface.
- // TODO(beng): create a version of this function that takes a NativeView, for
- // constrained windows.
- static Window* CreateChromeWindow(gfx::NativeWindow parent,
- const gfx::Rect& bounds,
- WindowDelegate* window_delegate);
-
- // Initializes the window. Must be called before any post-configuration
- // operations are performed.
- void InitWindow(const InitParams& params);
-
- // Overridden from Widget:
- virtual Window* AsWindow() OVERRIDE;
- virtual const Window* AsWindow() const OVERRIDE;
-
- WindowDelegate* window_delegate() {
- return const_cast<WindowDelegate*>(
- const_cast<const Window*>(this)->window_delegate());
- }
- const WindowDelegate* window_delegate() const {
- return reinterpret_cast<WindowDelegate*>(widget_delegate());
- }
-
- NativeWindow* native_window() { return native_window_; }
-
- protected:
- // Overridden from NativeWindowDelegate:
- virtual internal::NativeWidgetDelegate* AsNativeWidgetDelegate() OVERRIDE;
-
- private:
- NativeWindow* native_window_;
-
- DISALLOW_COPY_AND_ASSIGN(Window);
-};
-
-} // namespace views
-
-#endif // #ifndef VIEWS_WINDOW_WINDOW_H_
diff --git a/views/window/window_delegate.cc b/views/window/window_delegate.cc
deleted file mode 100644
index d75f881..0000000
--- a/views/window/window_delegate.cc
+++ /dev/null
@@ -1,15 +0,0 @@
-// 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/window_delegate.h"
-
-namespace views {
-
-WindowDelegate::WindowDelegate() {
-}
-
-WindowDelegate::~WindowDelegate() {
-}
-
-} // namespace views
diff --git a/views/window/window_delegate.h b/views/window/window_delegate.h
deleted file mode 100644
index a7715ab..0000000
--- a/views/window/window_delegate.h
+++ /dev/null
@@ -1,32 +0,0 @@
-// 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_WINDOW_DELEGATE_H_
-#define VIEWS_WINDOW_WINDOW_DELEGATE_H_
-#pragma once
-
-#include "views/widget/widget_delegate.h"
-
-namespace views {
-
-///////////////////////////////////////////////////////////////////////////////
-//
-// WindowDelegate
-//
-// WindowDelegate is an interface implemented by objects that wish to show a
-// Window. The window that is displayed uses this interface to determine how
-// it should be displayed and notify the delegate object of certain events.
-//
-class WindowDelegate : public WidgetDelegate {
- public:
- WindowDelegate();
- virtual ~WindowDelegate();
-
- private:
- DISALLOW_COPY_AND_ASSIGN(WindowDelegate);
-};
-
-} // namespace views
-
-#endif // VIEWS_WINDOW_WINDOW_DELEGATE_H_