summaryrefslogtreecommitdiffstats
path: root/ui/base/models/accelerator_cocoa.h
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-14 15:49:40 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-14 15:49:40 +0000
commit44cbd9e3734527f73a83f8a864be0bb5ccae0a7a (patch)
treea997fb0565558d63e0eab62b631ef984de3e9596 /ui/base/models/accelerator_cocoa.h
parent0c1c047d641a599ffffa280ab50d564cedb3e436 (diff)
downloadchromium_src-44cbd9e3734527f73a83f8a864be0bb5ccae0a7a.zip
chromium_src-44cbd9e3734527f73a83f8a864be0bb5ccae0a7a.tar.gz
chromium_src-44cbd9e3734527f73a83f8a864be0bb5ccae0a7a.tar.bz2
Move models from app to ui/base/models
BUG=none TEST=none TBR=brettw git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71446 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/base/models/accelerator_cocoa.h')
-rw-r--r--ui/base/models/accelerator_cocoa.h59
1 files changed, 59 insertions, 0 deletions
diff --git a/ui/base/models/accelerator_cocoa.h b/ui/base/models/accelerator_cocoa.h
new file mode 100644
index 0000000..7c3db16
--- /dev/null
+++ b/ui/base/models/accelerator_cocoa.h
@@ -0,0 +1,59 @@
+// 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 UI_BASE_MODELS_ACCELERATOR_COCOA_H_
+#define UI_BASE_MODELS_ACCELERATOR_COCOA_H_
+#pragma once
+
+#include <Foundation/Foundation.h>
+
+#include "base/scoped_nsobject.h"
+#include "ui/base/models/accelerator.h"
+
+namespace ui {
+
+// This is a subclass of the cross-platform Accelerator, but with more direct
+// support for Cocoa key equivalents. Note that the typical use case for this
+// class is to initialize it with a string literal, which is why it sends
+// |-copy| to the |key_code| paramater in the constructor.
+class AcceleratorCocoa : public Accelerator {
+ public:
+ AcceleratorCocoa(NSString* key_code, NSUInteger mask)
+ : Accelerator(ui::VKEY_UNKNOWN, mask),
+ characters_([key_code copy]) {
+ }
+
+ AcceleratorCocoa(const AcceleratorCocoa& accelerator)
+ : Accelerator(accelerator) {
+ characters_.reset([accelerator.characters_ copy]);
+ }
+
+ AcceleratorCocoa() : Accelerator() {}
+ virtual ~AcceleratorCocoa() {}
+
+ AcceleratorCocoa& operator=(const AcceleratorCocoa& accelerator) {
+ if (this != &accelerator) {
+ *static_cast<Accelerator*>(this) = accelerator;
+ characters_.reset([accelerator.characters_ copy]);
+ }
+ return *this;
+ }
+
+ bool operator==(const AcceleratorCocoa& rhs) const {
+ return [characters_ isEqualToString:rhs.characters_.get()] &&
+ (modifiers_ == rhs.modifiers_);
+ }
+
+ NSString* characters() const {
+ return characters_.get();
+ }
+
+ private:
+ // String of characters for the key equivalent.
+ scoped_nsobject<NSString> characters_;
+};
+
+} // namespace ui
+
+#endif // UI_BASE_MODELS_ACCELERATOR_COCOA_H_