Chromium Code Reviews| Index: views/controls/menu/menu_2.h |
| =================================================================== |
| --- views/controls/menu/menu_2.h (revision 0) |
| +++ views/controls/menu/menu_2.h (revision 0) |
| @@ -0,0 +1,109 @@ |
| +// Copyright (c) 2009 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 CONTROLS_MENU_VIEWS_MENU_2_H_ |
| +#define CONTROLS_MENU_VIEWS_MENU_2_H_ |
| + |
| +#include "base/gfx/native_widget_types.h" |
| + |
| +namespace gfx { |
| +class Point; |
| +} |
| + |
| +namespace views { |
| + |
| +class Accelerator; |
| + |
| +// The Menu2Model is an interface implemented by an object that provides the |
| +// content of a menu. |
| +class Menu2Model { |
| + public: |
| + // The type of item. |
| + enum ItemType { |
| + TYPE_COMMAND, |
| + TYPE_CHECK, |
| + TYPE_RADIO, |
| + TYPE_SEPARATOR, |
| + TYPE_SUBMENU |
| + }; |
| + |
| + // Returns the number of items in the menu. |
| + virtual int GetMenuItemCount() const = 0; |
| + |
| + // Returns the type of item at the specified index. |
| + virtual ItemType GetTypeAt(int index) const = 0; |
| + |
| + // Returns the command id of the item at the specified index. |
| + virtual int GetCommandIdAt(int index) const = 0; |
| + |
| + // Returns the label of the item at the specified index. |
| + virtual std::wstring GetLabelAt(int index) const = 0; |
| + |
| + // Gets the acclerator information for the specified index, returning true if |
| + // there is a shortcut accelerator for the item, false otherwise. |
| + virtual bool GetAcceleratorAt(int index, |
| + views::Accelerator* accelerator) const = 0; |
| + |
| + // Returns the checked state of the item at the specified index. |
| + virtual bool IsItemCheckedAt(int index) const = 0; |
| + |
| + // Returns the id of the group of radio items that the item at the specified |
| + // index belongs to. |
| + virtual int GetGroupIDAt(int index) const = 0; |
|
sky
2009/06/05 15:54:37
nit: ID -> Id (for consistency with GetCommandIdAt
|
| + |
| + // Returns the icon for the item at the specified index. |
| + virtual SkBitmap GetIconAt(int index) const = 0; |
| + |
| + // Returns the enabled state of the item at the specified index. |
| + virtual bool IsEnabledAt(int index) const = 0; |
| + |
| + // Returns the model for the submenu at the specified index. |
| + virtual Menu2Model* GetSubmenuModelAt(int index) const = 0; |
| +}; |
| + |
| +// The Menu2Delegate is an interface implemented by an object that performs |
| +// tasks that the Menu2 cannot itself. |
| +class Menu2Delegate { |
| + public: |
| + // Executes the command with the specified identifier. |
| + virtual void ExecuteCommand(Menu2* menu, int command_id) = 0; |
| +}; |
| + |
| +// The base class of all Menu types. |
| +class Menu2 { |
| + public: |
| + Menu2(Menu2Model* model, Menu2Delegate* delegate); |
| + virtual ~Menu2(); |
| + |
| + // Runs the menu at the specified point. This may or may not block, depending |
| + // on the platform and type of menu in use. |
| + virtual void RunMenuAt(const gfx::Point& point, gfx::NativeView parent) = 0; |
| + |
| + // Accessors. |
| + Menu2Model* model() const { return model_; } |
| + Menu2Delegate* delegate() const { return delegate_; } |
| + |
| + private: |
| + Menu2Model* model_; |
| + Menu2Delegate* delegate_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(Menu2); |
| +}; |
| + |
| +// A Menu2 subclass that implements a platform-native menu. |
| +class NativeMenu : public Menu2 { |
| + public: |
| + NativeMenu(Menu2Model* model, Menu2Delegate* delegate); |
| + virtual ~NativeMenu(); |
| + |
| + // Overridden from Menu2: |
| + virtual void RunMenuAt(const gfx::Point& point, gfx::NativeView, parent); |
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(NativeMenu); |
| +}; |
| + |
| +} // namespace views |
| + |
| +#endif // CONTROLS_MENU_VIEWS_MENU_2_H_ |