Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this | |
| 2 // source code is governed by a BSD-style license that can be found in the | |
| 3 // LICENSE file. | |
| 4 | |
| 5 #ifndef CONTROLS_MENU_VIEWS_MENU_2_H_ | |
| 6 #define CONTROLS_MENU_VIEWS_MENU_2_H_ | |
| 7 | |
| 8 #include "base/gfx/native_widget_types.h" | |
| 9 | |
| 10 namespace gfx { | |
| 11 class Point; | |
| 12 } | |
| 13 | |
| 14 namespace views { | |
| 15 | |
| 16 class Accelerator; | |
| 17 | |
| 18 // The Menu2Model is an interface implemented by an object that provides the | |
| 19 // content of a menu. | |
| 20 class Menu2Model { | |
| 21 public: | |
| 22 // The type of item. | |
| 23 enum ItemType { | |
| 24 TYPE_COMMAND, | |
| 25 TYPE_CHECK, | |
| 26 TYPE_RADIO, | |
| 27 TYPE_SEPARATOR, | |
| 28 TYPE_SUBMENU | |
| 29 }; | |
| 30 | |
| 31 // Returns the number of items in the menu. | |
| 32 virtual int GetMenuItemCount() const = 0; | |
| 33 | |
| 34 // Returns the type of item at the specified index. | |
| 35 virtual ItemType GetTypeAt(int index) const = 0; | |
| 36 | |
| 37 // Returns the command id of the item at the specified index. | |
| 38 virtual int GetCommandIdAt(int index) const = 0; | |
| 39 | |
| 40 // Returns the label of the item at the specified index. | |
| 41 virtual std::wstring GetLabelAt(int index) const = 0; | |
| 42 | |
| 43 // Gets the acclerator information for the specified index, returning true if | |
| 44 // there is a shortcut accelerator for the item, false otherwise. | |
| 45 virtual bool GetAcceleratorAt(int index, | |
| 46 views::Accelerator* accelerator) const = 0; | |
| 47 | |
| 48 // Returns the checked state of the item at the specified index. | |
| 49 virtual bool IsItemCheckedAt(int index) const = 0; | |
| 50 | |
| 51 // Returns the id of the group of radio items that the item at the specified | |
| 52 // index belongs to. | |
| 53 virtual int GetGroupIDAt(int index) const = 0; | |
|
sky
2009/06/05 15:54:37
nit: ID -> Id (for consistency with GetCommandIdAt
| |
| 54 | |
| 55 // Returns the icon for the item at the specified index. | |
| 56 virtual SkBitmap GetIconAt(int index) const = 0; | |
| 57 | |
| 58 // Returns the enabled state of the item at the specified index. | |
| 59 virtual bool IsEnabledAt(int index) const = 0; | |
| 60 | |
| 61 // Returns the model for the submenu at the specified index. | |
| 62 virtual Menu2Model* GetSubmenuModelAt(int index) const = 0; | |
| 63 }; | |
| 64 | |
| 65 // The Menu2Delegate is an interface implemented by an object that performs | |
| 66 // tasks that the Menu2 cannot itself. | |
| 67 class Menu2Delegate { | |
| 68 public: | |
| 69 // Executes the command with the specified identifier. | |
| 70 virtual void ExecuteCommand(Menu2* menu, int command_id) = 0; | |
| 71 }; | |
| 72 | |
| 73 // The base class of all Menu types. | |
| 74 class Menu2 { | |
| 75 public: | |
| 76 Menu2(Menu2Model* model, Menu2Delegate* delegate); | |
| 77 virtual ~Menu2(); | |
| 78 | |
| 79 // Runs the menu at the specified point. This may or may not block, depending | |
| 80 // on the platform and type of menu in use. | |
| 81 virtual void RunMenuAt(const gfx::Point& point, gfx::NativeView parent) = 0; | |
| 82 | |
| 83 // Accessors. | |
| 84 Menu2Model* model() const { return model_; } | |
| 85 Menu2Delegate* delegate() const { return delegate_; } | |
| 86 | |
| 87 private: | |
| 88 Menu2Model* model_; | |
| 89 Menu2Delegate* delegate_; | |
| 90 | |
| 91 DISALLOW_COPY_AND_ASSIGN(Menu2); | |
| 92 }; | |
| 93 | |
| 94 // A Menu2 subclass that implements a platform-native menu. | |
| 95 class NativeMenu : public Menu2 { | |
| 96 public: | |
| 97 NativeMenu(Menu2Model* model, Menu2Delegate* delegate); | |
| 98 virtual ~NativeMenu(); | |
| 99 | |
| 100 // Overridden from Menu2: | |
| 101 virtual void RunMenuAt(const gfx::Point& point, gfx::NativeView, parent); | |
| 102 | |
| 103 private: | |
| 104 DISALLOW_COPY_AND_ASSIGN(NativeMenu); | |
| 105 }; | |
| 106 | |
| 107 } // namespace views | |
| 108 | |
| 109 #endif // CONTROLS_MENU_VIEWS_MENU_2_H_ | |
| OLD | NEW |