diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-12 19:22:26 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-12 19:22:26 +0000 |
commit | d6d6d586d2a91d13d06a8bce53a2d03f2458f9c2 (patch) | |
tree | f662039f70110c555ec6fb096b389b73af31af2d /views/controls | |
parent | 7587ee0fa4399ed0485559559b0ee9228daf0337 (diff) | |
download | chromium_src-d6d6d586d2a91d13d06a8bce53a2d03f2458f9c2.zip chromium_src-d6d6d586d2a91d13d06a8bce53a2d03f2458f9c2.tar.gz chromium_src-d6d6d586d2a91d13d06a8bce53a2d03f2458f9c2.tar.bz2 |
Converts some uses of native_view to native_window. This is necessitated
by wanting to parent bookmarkeditor to browserwindow, which returns a
native_window.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/270067
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28728 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/controls')
-rw-r--r-- | views/controls/button/menu_button.cc | 27 | ||||
-rw-r--r-- | views/controls/menu/menu_controller.cc | 6 | ||||
-rw-r--r-- | views/controls/menu/menu_controller.h | 4 | ||||
-rw-r--r-- | views/controls/menu/menu_host_gtk.cc | 8 | ||||
-rw-r--r-- | views/controls/menu/menu_host_gtk.h | 4 | ||||
-rw-r--r-- | views/controls/menu/menu_host_win.h | 2 | ||||
-rw-r--r-- | views/controls/menu/menu_item_view.cc | 4 | ||||
-rw-r--r-- | views/controls/menu/menu_item_view.h | 4 | ||||
-rw-r--r-- | views/controls/menu/submenu_view.cc | 6 | ||||
-rw-r--r-- | views/controls/menu/submenu_view.h | 6 | ||||
-rw-r--r-- | views/controls/menu/view_menu_delegate.h | 4 |
11 files changed, 34 insertions, 41 deletions
diff --git a/views/controls/button/menu_button.cc b/views/controls/button/menu_button.cc index 5b353f3..7f1daf7 100644 --- a/views/controls/button/menu_button.cc +++ b/views/controls/button/menu_button.cc @@ -13,12 +13,10 @@ #include "views/controls/button/button.h" #include "views/controls/menu/view_menu_delegate.h" #include "views/event.h" +#include "views/screen.h" #include "views/widget/root_view.h" #include "views/widget/widget.h" - -#if defined(OS_WIN) -#include "app/win_util.h" -#endif +#include "views/window/window.h" using base::Time; using base::TimeDelta; @@ -105,25 +103,14 @@ void MenuButton::Paint(gfx::Canvas* canvas, bool for_drag) { //////////////////////////////////////////////////////////////////////////////// int MenuButton::GetMaximumScreenXCoordinate() { - Widget* widget = GetWidget(); - - if (!widget) { + if (!GetWindow()) { NOTREACHED(); return 0; } -#if defined(OS_WIN) - HWND hwnd = widget->GetNativeView(); - RECT t; - ::GetWindowRect(hwnd, &t); - - gfx::Rect r(t); - gfx::Rect monitor_rect = win_util::GetMonitorBoundsForRect(r); - return monitor_rect.x() + monitor_rect.width() - 1; -#else - NOTIMPLEMENTED(); - return 1000000; -#endif + gfx::Rect monitor_bounds = + Screen::GetMonitorWorkAreaNearestWindow(GetWindow()->GetNativeWindow()); + return monitor_bounds.right() - 1; } bool MenuButton::Activate() { @@ -162,7 +149,7 @@ bool MenuButton::Activate() { GetRootView()->SetMouseHandler(NULL); menu_visible_ = true; - menu_delegate_->RunMenu(this, menu_position, GetWidget()->GetNativeView()); + menu_delegate_->RunMenu(this, menu_position); menu_visible_ = false; menu_closed_time_ = Time::Now(); diff --git a/views/controls/menu/menu_controller.cc b/views/controls/menu/menu_controller.cc index 3df3030..6175e62 100644 --- a/views/controls/menu/menu_controller.cc +++ b/views/controls/menu/menu_controller.cc @@ -142,7 +142,7 @@ static int instance_count = 0; static int nested_depth = 0; #endif -MenuItemView* MenuController::Run(gfx::NativeView parent, +MenuItemView* MenuController::Run(gfx::NativeWindow parent, MenuItemView* root, const gfx::Rect& bounds, MenuItemView::AnchorPosition position, @@ -1329,8 +1329,8 @@ void MenuController::RepostEvent(SubmenuView* source, SubmenuView* submenu = state_.item->GetRootMenuItem()->GetSubmenu(); submenu->ReleaseCapture(); - if (submenu->native_view() && submenu->native_view() && - GetWindowThreadProcessId(submenu->native_view(), NULL) != + if (submenu->native_window() && submenu->native_window() && + GetWindowThreadProcessId(submenu->native_window(), NULL) != GetWindowThreadProcessId(window, NULL)) { // Even though we have mouse capture, windows generates a mouse event // if the other window is in a separate thread. Don't generate an event in diff --git a/views/controls/menu/menu_controller.h b/views/controls/menu/menu_controller.h index eb6e87e..bc57036 100644 --- a/views/controls/menu/menu_controller.h +++ b/views/controls/menu/menu_controller.h @@ -43,7 +43,7 @@ class MenuController : public MessageLoopForUI::Dispatcher { // Runs the menu at the specified location. If the menu was configured to // block, the selected item is returned. If the menu does not block this // returns NULL immediately. - MenuItemView* Run(gfx::NativeView parent, + MenuItemView* Run(gfx::NativeWindow parent, MenuItemView* root, const gfx::Rect& bounds, MenuItemView::AnchorPosition position, @@ -353,7 +353,7 @@ class MenuController : public MessageLoopForUI::Dispatcher { MenuDelegate::DropPosition drop_position_; // Owner of child windows. - gfx::NativeView owner_; + gfx::NativeWindow owner_; // Indicates a possible drag operation. bool possible_drag_; diff --git a/views/controls/menu/menu_host_gtk.cc b/views/controls/menu/menu_host_gtk.cc index aee0d17..11033c4 100644 --- a/views/controls/menu/menu_host_gtk.cc +++ b/views/controls/menu/menu_host_gtk.cc @@ -30,11 +30,11 @@ MenuHost::MenuHost(SubmenuView* submenu) } } -void MenuHost::Init(gfx::NativeView parent, +void MenuHost::Init(gfx::NativeWindow parent, const gfx::Rect& bounds, View* contents_view, bool do_capture) { - WidgetGtk::Init(parent, bounds); + WidgetGtk::Init(GTK_WIDGET(parent), bounds); SetContentsView(contents_view); // TODO(sky): see if there is some way to show without changing focus. Show(); @@ -65,6 +65,10 @@ void MenuHost::Init(gfx::NativeView parent, } } +gfx::NativeWindow MenuHost::GetNativeWindow() { + return GTK_WINDOW(GetNativeView()); +} + void MenuHost::Show() { WidgetGtk::Show(); } diff --git a/views/controls/menu/menu_host_gtk.h b/views/controls/menu/menu_host_gtk.h index b3e1f75..8e69ce8 100644 --- a/views/controls/menu/menu_host_gtk.h +++ b/views/controls/menu/menu_host_gtk.h @@ -17,11 +17,13 @@ class MenuHost : public WidgetGtk { public: explicit MenuHost(SubmenuView* submenu); - void Init(gfx::NativeView parent, + void Init(gfx::NativeWindow parent, const gfx::Rect& bounds, View* contents_view, bool do_capture); + gfx::NativeWindow GetNativeWindow(); + void Show(); virtual void Hide(); virtual void HideWindow(); diff --git a/views/controls/menu/menu_host_win.h b/views/controls/menu/menu_host_win.h index 49cc13b..6e645d2 100644 --- a/views/controls/menu/menu_host_win.h +++ b/views/controls/menu/menu_host_win.h @@ -22,6 +22,8 @@ class MenuHost : public WidgetWin { View* contents_view, bool do_capture); + gfx::NativeWindow GetNativeWindow() { return GetNativeView(); } + void Show(); virtual void Hide(); virtual void HideWindow(); diff --git a/views/controls/menu/menu_item_view.cc b/views/controls/menu/menu_item_view.cc index 7a6056f..4d5b3ae 100644 --- a/views/controls/menu/menu_item_view.cc +++ b/views/controls/menu/menu_item_view.cc @@ -82,7 +82,7 @@ MenuItemView::~MenuItemView() { delete submenu_; } -void MenuItemView::RunMenuAt(gfx::NativeView parent, +void MenuItemView::RunMenuAt(gfx::NativeWindow parent, const gfx::Rect& bounds, AnchorPosition anchor, bool has_mnemonics) { @@ -134,7 +134,7 @@ void MenuItemView::RunMenuAt(gfx::NativeView parent, delegate_->ExecuteCommand(result->GetCommand(), mouse_event_flags); } -void MenuItemView::RunMenuForDropAt(gfx::NativeView parent, +void MenuItemView::RunMenuForDropAt(gfx::NativeWindow parent, const gfx::Rect& bounds, AnchorPosition anchor) { PrepareForRun(false); diff --git a/views/controls/menu/menu_item_view.h b/views/controls/menu/menu_item_view.h index 86b1bbf..ecb3b78 100644 --- a/views/controls/menu/menu_item_view.h +++ b/views/controls/menu/menu_item_view.h @@ -81,11 +81,11 @@ class MenuItemView : public View { // a rectangle, which is used to position the menu. |has_mnemonics| indicates // whether the items have mnemonics. Mnemonics are identified by way of the // character following the '&'. - void RunMenuAt(gfx::NativeView parent, + void RunMenuAt(gfx::NativeWindow parent, const gfx::Rect& bounds, AnchorPosition anchor, bool has_mnemonics); - void RunMenuForDropAt(gfx::NativeView parent, + void RunMenuForDropAt(gfx::NativeWindow parent, const gfx::Rect& bounds, AnchorPosition anchor); diff --git a/views/controls/menu/submenu_view.cc b/views/controls/menu/submenu_view.cc index 36495c9..d08de6f 100644 --- a/views/controls/menu/submenu_view.cc +++ b/views/controls/menu/submenu_view.cc @@ -216,7 +216,7 @@ bool SubmenuView::IsShowing() { return host_ && host_->IsVisible(); } -void SubmenuView::ShowAt(gfx::NativeView parent, +void SubmenuView::ShowAt(gfx::NativeWindow parent, const gfx::Rect& bounds, bool do_capture) { if (host_) { @@ -280,8 +280,8 @@ MenuScrollViewContainer* SubmenuView::GetScrollViewContainer() { return scroll_view_container_; } -gfx::NativeView SubmenuView::native_view() const { - return host_ ? host_->GetNativeView() : NULL; +gfx::NativeWindow SubmenuView::native_window() const { + return host_ ? host_->GetNativeWindow() : NULL; } void SubmenuView::PaintDropIndicator(gfx::Canvas* canvas, diff --git a/views/controls/menu/submenu_view.h b/views/controls/menu/submenu_view.h index c8bce96..8cc4461 100644 --- a/views/controls/menu/submenu_view.h +++ b/views/controls/menu/submenu_view.h @@ -74,7 +74,7 @@ class SubmenuView : public View { // Shows the menu at the specified location. Coordinates are in screen // coordinates. max_width gives the max width the view should be. - void ShowAt(gfx::NativeView parent, const gfx::Rect& bounds, bool do_capture); + void ShowAt(gfx::NativeWindow parent, const gfx::Rect& bounds, bool do_capture); // Closes the menu, destroying the host. void Close(); @@ -112,8 +112,8 @@ class SubmenuView : public View { // Returns the container for the SubmenuView. MenuScrollViewContainer* GetScrollViewContainer(); - // Returns the NativeView host of the menu, or NULL if not showing. - gfx::NativeView native_view() const; + // Returns the NativeWindow host of the menu, or NULL if not showing. + gfx::NativeWindow native_window() const; // Padding around the edges of the submenu. static const int kSubmenuBorderSize; diff --git a/views/controls/menu/view_menu_delegate.h b/views/controls/menu/view_menu_delegate.h index c267e9b..9a3a447 100644 --- a/views/controls/menu/view_menu_delegate.h +++ b/views/controls/menu/view_menu_delegate.h @@ -28,9 +28,7 @@ class ViewMenuDelegate { public: // Create and show a menu at the specified position. Source is the view the // ViewMenuDelegate was set on. - virtual void RunMenu(View* source, - const gfx::Point& pt, - gfx::NativeView hwnd) = 0; + virtual void RunMenu(View* source, const gfx::Point& pt) = 0; }; } // namespace views |