diff options
author | pinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-04 17:50:26 +0000 |
---|---|---|
committer | pinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-04 17:50:26 +0000 |
commit | b284843ba6a1e90c12f91eaf796726433dc2537d (patch) | |
tree | 96edc5a4528e4d685c89544bfc13712e2984964a /views/accelerator.h | |
parent | e83ce1e3f2fcacb3d400287d78567d22a2a06cae (diff) | |
download | chromium_src-b284843ba6a1e90c12f91eaf796726433dc2537d.zip chromium_src-b284843ba6a1e90c12f91eaf796726433dc2537d.tar.gz chromium_src-b284843ba6a1e90c12f91eaf796726433dc2537d.tar.bz2 |
Refactor the menu model to live outside views/ so it can be shared
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/465005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33827 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/accelerator.h')
-rw-r--r-- | views/accelerator.h | 54 |
1 files changed, 4 insertions, 50 deletions
diff --git a/views/accelerator.h b/views/accelerator.h index 4aab592..a8d4c16 100644 --- a/views/accelerator.h +++ b/views/accelerator.h @@ -13,16 +13,16 @@ #include <string> -#include "base/keyboard_codes.h" +#include "app/menus/accelerator.h" #include "views/event.h" namespace views { -class Accelerator { +class Accelerator : public menus::Accelerator { public: Accelerator(base::KeyboardCode keycode, - bool shift_pressed, bool ctrl_pressed, bool alt_pressed) - : key_code_(keycode) { + bool shift_pressed, bool ctrl_pressed, bool alt_pressed) { + key_code_ = keycode; modifiers_ = 0; if (shift_pressed) modifiers_ |= Event::EF_SHIFT_DOWN; @@ -32,37 +32,6 @@ class Accelerator { modifiers_ |= Event::EF_ALT_DOWN; } - Accelerator(const Accelerator& accelerator) { - key_code_ = accelerator.key_code_; - modifiers_ = accelerator.modifiers_; - } - - ~Accelerator() { } - - Accelerator& operator=(const Accelerator& accelerator) { - if (this != &accelerator) { - key_code_ = accelerator.key_code_; - modifiers_ = accelerator.modifiers_; - } - return *this; - } - - // We define the < operator so that the KeyboardShortcut can be used as a key - // in a std::map. - bool operator <(const Accelerator& rhs) const { - if (key_code_ != rhs.key_code_) - return key_code_ < rhs.key_code_; - return modifiers_ < rhs.modifiers_; - } - - bool operator ==(const Accelerator& rhs) const { - return (key_code_ == rhs.key_code_) && (modifiers_ == rhs.modifiers_); - } - - bool operator !=(const Accelerator& rhs) const { - return !(*this == rhs); - } - bool IsShiftDown() const { return (modifiers_ & Event::EF_SHIFT_DOWN) == Event::EF_SHIFT_DOWN; } @@ -75,23 +44,8 @@ class Accelerator { return (modifiers_ & Event::EF_ALT_DOWN) == Event::EF_ALT_DOWN; } - base::KeyboardCode GetKeyCode() const { - return key_code_; - } - - int modifiers() const { - return modifiers_; - } - // Returns a string with the localized shortcut if any. std::wstring GetShortcutText() const; - - private: - // The window keycode (VK_...). - base::KeyboardCode key_code_; - - // The state of the Shift/Ctrl/Alt keys (see event.h). - int modifiers_; }; // An interface that classes that want to register for keyboard accelerators |