Commit e133f95e authored by sky@chromium.org's avatar sky@chromium.org

Makes MenuButton compile and fixes bug in GtkWidget I happened upon.

BUG=none
TEST=none

Review URL: http://codereview.chromium.org/115826

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17018 0039d316-1c4b-4281-b951-d872f2087c98
parent b059d497
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include "app/gfx/canvas.h" #include "app/gfx/canvas.h"
#include "app/l10n_util.h" #include "app/l10n_util.h"
#include "app/resource_bundle.h" #include "app/resource_bundle.h"
#include "app/win_util.h"
#include "grit/app_strings.h" #include "grit/app_strings.h"
#include "grit/app_resources.h" #include "grit/app_resources.h"
#include "views/controls/button/button.h" #include "views/controls/button/button.h"
...@@ -17,6 +16,10 @@ ...@@ -17,6 +16,10 @@
#include "views/widget/root_view.h" #include "views/widget/root_view.h"
#include "views/widget/widget.h" #include "views/widget/widget.h"
#if defined(OS_WIN)
#include "app/win_util.h"
#endif
using base::Time; using base::Time;
using base::TimeDelta; using base::TimeDelta;
...@@ -109,6 +112,7 @@ int MenuButton::GetMaximumScreenXCoordinate() { ...@@ -109,6 +112,7 @@ int MenuButton::GetMaximumScreenXCoordinate() {
return 0; return 0;
} }
#if defined(OS_WIN)
HWND hwnd = widget->GetNativeView(); HWND hwnd = widget->GetNativeView();
RECT t; RECT t;
::GetWindowRect(hwnd, &t); ::GetWindowRect(hwnd, &t);
...@@ -116,6 +120,10 @@ int MenuButton::GetMaximumScreenXCoordinate() { ...@@ -116,6 +120,10 @@ int MenuButton::GetMaximumScreenXCoordinate() {
gfx::Rect r(t); gfx::Rect r(t);
gfx::Rect monitor_rect = win_util::GetMonitorBoundsForRect(r); gfx::Rect monitor_rect = win_util::GetMonitorBoundsForRect(r);
return monitor_rect.x() + monitor_rect.width() - 1; return monitor_rect.x() + monitor_rect.width() - 1;
#else
NOTIMPLEMENTED();
return 1000000;
#endif
} }
bool MenuButton::Activate() { bool MenuButton::Activate() {
...@@ -205,9 +213,13 @@ void MenuButton::OnMouseReleased(const MouseEvent& e, ...@@ -205,9 +213,13 @@ void MenuButton::OnMouseReleased(const MouseEvent& e,
// When the space bar or the enter key is pressed we need to show the menu. // When the space bar or the enter key is pressed we need to show the menu.
bool MenuButton::OnKeyReleased(const KeyEvent& e) { bool MenuButton::OnKeyReleased(const KeyEvent& e) {
#if defined(OS_WIN)
if ((e.GetCharacter() == VK_SPACE) || (e.GetCharacter() == VK_RETURN)) { if ((e.GetCharacter() == VK_SPACE) || (e.GetCharacter() == VK_RETURN)) {
return Activate(); return Activate();
} }
#else
NOTIMPLEMENTED();
#endif
return true; return true;
} }
......
...@@ -232,7 +232,6 @@ ...@@ -232,7 +232,6 @@
'accessibility/view_accessibility_wrapper.cc', 'accessibility/view_accessibility_wrapper.cc',
'controls/scrollbar/bitmap_scroll_bar.cc', 'controls/scrollbar/bitmap_scroll_bar.cc',
'controls/button/button_dropdown.cc', 'controls/button/button_dropdown.cc',
'controls/button/menu_button.cc',
'controls/button/radio_button.cc', 'controls/button/radio_button.cc',
'controls/combo_box.cc', 'controls/combo_box.cc',
'controls/hwnd_view.cc', 'controls/hwnd_view.cc',
......
...@@ -13,8 +13,7 @@ namespace views { ...@@ -13,8 +13,7 @@ namespace views {
// Returns the position of a widget on screen. // Returns the position of a widget on screen.
static void GetWidgetPositionOnScreen(GtkWidget* widget, int* x, int *y) { static void GetWidgetPositionOnScreen(GtkWidget* widget, int* x, int *y) {
GtkWidget* parent = widget; while (widget) {
while (parent) {
if (GTK_IS_WINDOW(widget)) { if (GTK_IS_WINDOW(widget)) {
int window_x, window_y; int window_x, window_y;
gtk_window_get_position(GTK_WINDOW(widget), &window_x, &window_y); gtk_window_get_position(GTK_WINDOW(widget), &window_x, &window_y);
...@@ -25,7 +24,7 @@ static void GetWidgetPositionOnScreen(GtkWidget* widget, int* x, int *y) { ...@@ -25,7 +24,7 @@ static void GetWidgetPositionOnScreen(GtkWidget* widget, int* x, int *y) {
// Not a window. // Not a window.
*x += widget->allocation.x; *x += widget->allocation.x;
*y += widget->allocation.y; *y += widget->allocation.y;
parent = gtk_widget_get_parent(parent); widget = gtk_widget_get_parent(widget);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment