summaryrefslogtreecommitdiffstats
path: root/views/controls/menu
diff options
context:
space:
mode:
authortfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-23 17:03:30 +0000
committertfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-23 17:03:30 +0000
commitd928570ffba669f58d7c0b7a6d2707c6b702be31 (patch)
tree2ee50374e4e509a6c418eafcfbbc9ad800139a6e /views/controls/menu
parentaca8ac48a381254b79a28cc4562f40bb8e7dce99 (diff)
downloadchromium_src-d928570ffba669f58d7c0b7a6d2707c6b702be31.zip
chromium_src-d928570ffba669f58d7c0b7a6d2707c6b702be31.tar.gz
chromium_src-d928570ffba669f58d7c0b7a6d2707c6b702be31.tar.bz2
views: Factor out MenuListener into its own header file.
R=sky@chromium.org Review URL: http://codereview.chromium.org/7969011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@102512 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/controls/menu')
-rw-r--r--views/controls/menu/menu_2.cc6
-rw-r--r--views/controls/menu/menu_2.h22
-rw-r--r--views/controls/menu/menu_listener.h25
-rw-r--r--views/controls/menu/menu_wrapper.h8
-rw-r--r--views/controls/menu/native_menu_aura.cc1
-rw-r--r--views/controls/menu/native_menu_gtk.cc1
-rw-r--r--views/controls/menu/native_menu_gtk.h22
-rw-r--r--views/controls/menu/native_menu_linux.cc2
-rw-r--r--views/controls/menu/native_menu_linux.h31
-rw-r--r--views/controls/menu/native_menu_win.cc1
-rw-r--r--views/controls/menu/native_menu_win.h20
11 files changed, 87 insertions, 52 deletions
diff --git a/views/controls/menu/menu_2.cc b/views/controls/menu/menu_2.cc
index 4fa5851..accd581 100644
--- a/views/controls/menu/menu_2.cc
+++ b/views/controls/menu/menu_2.cc
@@ -1,11 +1,11 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "views/controls/menu/menu_2.h"
-#include "base/compiler_specific.h"
-#include "views/controls/menu/menu_wrapper.h"
+#include "ui/base/models/menu_model.h"
+#include "views/controls/menu/menu_listener.h"
namespace views {
diff --git a/views/controls/menu/menu_2.h b/views/controls/menu/menu_2.h
index 5a93179..4460eea 100644
--- a/views/controls/menu/menu_2.h
+++ b/views/controls/menu/menu_2.h
@@ -6,8 +6,9 @@
#define VIEWS_CONTROLS_MENU_MENU_2_H_
#pragma once
+#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
-#include "ui/base/models/menu_model.h"
+#include "ui/gfx/native_widget_types.h"
#include "views/controls/menu/menu_wrapper.h"
#include "views/views_export.h"
@@ -15,10 +16,13 @@ namespace gfx {
class Point;
}
+namespace ui {
+class MenuModel;
+}
+
namespace views {
class NativeMenuGtk;
-class View;
// A menu. Populated from a model, and relies on a delegate to execute commands.
//
@@ -27,6 +31,13 @@ class View;
// ActivatedAt is never invoked.
class VIEWS_EXPORT Menu2 {
public:
+ // How the menu is aligned relative to the point it is shown at.
+ // The alignment is reversed by menu if text direction is right to left.
+ enum Alignment {
+ ALIGN_TOPLEFT,
+ ALIGN_TOPRIGHT
+ };
+
// Creates a new menu populated with the contents of |model|.
// WARNING: this populates the menu on construction by invoking methods on
// the model. As such, it is typically not safe to use this as the model
@@ -36,13 +47,6 @@ class VIEWS_EXPORT Menu2 {
explicit Menu2(ui::MenuModel* model);
virtual ~Menu2();
- // How the menu is aligned relative to the point it is shown at.
- // The alignment is reversed by menu if text direction is right to left.
- enum Alignment {
- ALIGN_TOPLEFT,
- ALIGN_TOPRIGHT
- };
-
// Runs the menu at the specified point. This method blocks until done.
// RunContextMenuAt is the same, but the alignment is the default for a
// context menu.
diff --git a/views/controls/menu/menu_listener.h b/views/controls/menu/menu_listener.h
new file mode 100644
index 0000000..332eee7
--- /dev/null
+++ b/views/controls/menu/menu_listener.h
@@ -0,0 +1,25 @@
+// 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_CONTROLS_MENU_MENU_LISTENER_H_
+#define VIEWS_CONTROLS_MENU_MENU_LISTENER_H_
+#pragma once
+
+#include "views/views_export.h"
+
+namespace views {
+
+// An interface for clients that want a notification when a menu is opened.
+class VIEWS_EXPORT MenuListener {
+ public:
+ // This will be called after the menu has actually opened.
+ virtual void OnMenuOpened() = 0;
+
+ protected:
+ virtual ~MenuListener() {}
+};
+
+} // namespace views
+
+#endif // VIEWS_CONTROLS_MENU_MENU_LISTENER_H_
diff --git a/views/controls/menu/menu_wrapper.h b/views/controls/menu/menu_wrapper.h
index 9281e70..ad171e4 100644
--- a/views/controls/menu/menu_wrapper.h
+++ b/views/controls/menu/menu_wrapper.h
@@ -16,13 +16,7 @@ class Point;
namespace views {
class Menu2;
-
-// An interface for clients that want a notification when a menu is opened.
-class MenuListener {
- public:
- // This will be called after the menu has actually opened.
- virtual void OnMenuOpened() = 0;
-};
+class MenuListener;
// An interface that wraps an object that implements a menu.
class VIEWS_EXPORT MenuWrapper {
diff --git a/views/controls/menu/native_menu_aura.cc b/views/controls/menu/native_menu_aura.cc
index d441712..602e9d1 100644
--- a/views/controls/menu/native_menu_aura.cc
+++ b/views/controls/menu/native_menu_aura.cc
@@ -6,6 +6,7 @@
#include "base/logging.h"
#include "views/controls/menu/menu_2.h"
+#include "views/controls/menu/menu_listener.h"
#include "views/controls/menu/menu_wrapper.h"
namespace views {
diff --git a/views/controls/menu/native_menu_gtk.cc b/views/controls/menu/native_menu_gtk.cc
index 7e60d45..d661d7f 100644
--- a/views/controls/menu/native_menu_gtk.cc
+++ b/views/controls/menu/native_menu_gtk.cc
@@ -20,6 +20,7 @@
#include "ui/gfx/gtk_util.h"
#include "views/accelerator.h"
#include "views/controls/menu/menu_2.h"
+#include "views/controls/menu/menu_listener.h"
#include "views/controls/menu/nested_dispatcher_gtk.h"
#include "views/views_delegate.h"
#include "views/widget/native_widget_gtk.h"
diff --git a/views/controls/menu/native_menu_gtk.h b/views/controls/menu/native_menu_gtk.h
index de9ff7e..9d90cb5 100644
--- a/views/controls/menu/native_menu_gtk.h
+++ b/views/controls/menu/native_menu_gtk.h
@@ -8,6 +8,8 @@
#include <gtk/gtk.h>
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
#include "base/message_loop.h"
#include "base/observer_list.h"
#include "ui/base/gtk/gtk_signal.h"
@@ -37,18 +39,18 @@ class NativeMenuGtk : public MenuWrapper,
virtual ~NativeMenuGtk();
// Overridden from MenuWrapper:
- virtual void RunMenuAt(const gfx::Point& point, int alignment);
- virtual void CancelMenu();
- virtual void Rebuild();
- virtual void UpdateStates();
- virtual gfx::NativeMenu GetNativeMenu() const;
- virtual MenuAction GetMenuAction() const;
- virtual void AddMenuListener(MenuListener* listener);
- virtual void RemoveMenuListener(MenuListener* listener);
- virtual void SetMinimumWidth(int width);
+ virtual void RunMenuAt(const gfx::Point& point, int alignment) OVERRIDE;
+ virtual void CancelMenu() OVERRIDE;
+ virtual void Rebuild() OVERRIDE;
+ virtual void UpdateStates() OVERRIDE;
+ virtual gfx::NativeMenu GetNativeMenu() const OVERRIDE;
+ virtual MenuAction GetMenuAction() const OVERRIDE;
+ virtual void AddMenuListener(MenuListener* listener) OVERRIDE;
+ virtual void RemoveMenuListener(MenuListener* listener) OVERRIDE;
+ virtual void SetMinimumWidth(int width) OVERRIDE;
// Overriden from MessageLoopForUI::Dispatcher:
- virtual bool Dispatch(GdkEvent* event);
+ virtual bool Dispatch(GdkEvent* event) OVERRIDE;
private:
CHROMEGTK_CALLBACK_0(NativeMenuGtk, void, OnMenuHidden);
diff --git a/views/controls/menu/native_menu_linux.cc b/views/controls/menu/native_menu_linux.cc
index 7556874..f1f2b7b 100644
--- a/views/controls/menu/native_menu_linux.cc
+++ b/views/controls/menu/native_menu_linux.cc
@@ -9,6 +9,8 @@
#include "ui/gfx/canvas_skia.h"
#include "ui/gfx/skia_util.h"
#include "views/controls/menu/menu_2.h"
+#include "views/controls/menu/menu_item_view.h"
+#include "views/controls/menu/menu_listener.h"
#include "views/controls/menu/menu_runner.h"
#include "views/controls/menu/submenu_view.h"
diff --git a/views/controls/menu/native_menu_linux.h b/views/controls/menu/native_menu_linux.h
index bfec464..131080d 100644
--- a/views/controls/menu/native_menu_linux.h
+++ b/views/controls/menu/native_menu_linux.h
@@ -6,8 +6,10 @@
#define VIEWS_CONTROLS_MENU_NATIVE_MENU_LINUX_H_
#pragma once
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "base/memory/scoped_ptr.h"
#include "views/controls/menu/menu_delegate.h"
-#include "views/controls/menu/menu_item_view.h"
#include "views/controls/menu/menu_wrapper.h"
namespace ui {
@@ -16,6 +18,7 @@ class MenuModel;
namespace views {
+class MenuItemView;
class MenuRunner;
// A non-GTK implementation of MenuWrapper, used currently for touchui.
@@ -26,21 +29,21 @@ class NativeMenuLinux : public MenuWrapper,
virtual ~NativeMenuLinux();
// Overridden from MenuWrapper:
- virtual void RunMenuAt(const gfx::Point& point, int alignment);
- virtual void CancelMenu();
- virtual void Rebuild();
- virtual void UpdateStates();
- virtual gfx::NativeMenu GetNativeMenu() const;
- virtual MenuAction GetMenuAction() const;
- virtual void AddMenuListener(MenuListener* listener);
- virtual void RemoveMenuListener(MenuListener* listener);
- virtual void SetMinimumWidth(int width);
+ virtual void RunMenuAt(const gfx::Point& point, int alignment) OVERRIDE;
+ virtual void CancelMenu() OVERRIDE;
+ virtual void Rebuild() OVERRIDE;
+ virtual void UpdateStates() OVERRIDE;
+ virtual gfx::NativeMenu GetNativeMenu() const OVERRIDE;
+ virtual MenuAction GetMenuAction() const OVERRIDE;
+ virtual void AddMenuListener(MenuListener* listener) OVERRIDE;
+ virtual void RemoveMenuListener(MenuListener* listener) OVERRIDE;
+ virtual void SetMinimumWidth(int width) OVERRIDE;
// Overridden from MenuDelegate:
- virtual bool IsItemChecked(int id) const;
- virtual bool IsCommandEnabled(int id) const;
- virtual void ExecuteCommand(int id);
- virtual bool GetAccelerator(int id, views::Accelerator* accelerator);
+ virtual bool IsItemChecked(int id) const OVERRIDE;
+ virtual bool IsCommandEnabled(int id) const OVERRIDE;
+ virtual void ExecuteCommand(int id) OVERRIDE;
+ virtual bool GetAccelerator(int id, views::Accelerator* accelerator) OVERRIDE;
private:
void AddMenuItemsFromModel(MenuItemView* parent, ui::MenuModel* model);
diff --git a/views/controls/menu/native_menu_win.cc b/views/controls/menu/native_menu_win.cc
index 55cfefe..fd82353 100644
--- a/views/controls/menu/native_menu_win.cc
+++ b/views/controls/menu/native_menu_win.cc
@@ -23,6 +23,7 @@
#include "views/accelerator.h"
#include "views/controls/menu/menu_2.h"
#include "views/controls/menu/menu_config.h"
+#include "views/controls/menu/menu_listener.h"
using gfx::NativeTheme;
diff --git a/views/controls/menu/native_menu_win.h b/views/controls/menu/native_menu_win.h
index 489cbd3..7419196 100644
--- a/views/controls/menu/native_menu_win.h
+++ b/views/controls/menu/native_menu_win.h
@@ -8,6 +8,8 @@
#include <vector>
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
#include "base/observer_list.h"
#include "ui/base/models/simple_menu_model.h"
@@ -27,15 +29,15 @@ class VIEWS_EXPORT NativeMenuWin : public MenuWrapper {
virtual ~NativeMenuWin();
// Overridden from MenuWrapper:
- virtual void RunMenuAt(const gfx::Point& point, int alignment);
- virtual void CancelMenu();
- virtual void Rebuild();
- virtual void UpdateStates();
- virtual gfx::NativeMenu GetNativeMenu() const;
- virtual MenuAction GetMenuAction() const;
- virtual void AddMenuListener(MenuListener* listener);
- virtual void RemoveMenuListener(MenuListener* listener);
- virtual void SetMinimumWidth(int width);
+ virtual void RunMenuAt(const gfx::Point& point, int alignment) OVERRIDE;
+ virtual void CancelMenu() OVERRIDE;
+ virtual void Rebuild() OVERRIDE;
+ virtual void UpdateStates() OVERRIDE;
+ virtual gfx::NativeMenu GetNativeMenu() const OVERRIDE;
+ virtual MenuAction GetMenuAction() const OVERRIDE;
+ virtual void AddMenuListener(MenuListener* listener) OVERRIDE;
+ virtual void RemoveMenuListener(MenuListener* listener) OVERRIDE;
+ virtual void SetMinimumWidth(int width) OVERRIDE;
private:
// IMPORTANT: Note about indices.