Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: ui/base/models/accelerator_gtk.h

Issue 8695005: Move accelerator related files to ui/base/accelerators (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/base/models/accelerator_cocoa.mm ('k') | ui/base/ui_base_exports.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef UI_BASE_MODELS_ACCELERATOR_GTK_H_
6 #define UI_BASE_MODELS_ACCELERATOR_GTK_H_
7 #pragma once
8
9 #include <gdk/gdk.h>
10
11 #include "ui/base/keycodes/keyboard_code_conversion_gtk.h"
12 #include "ui/base/keycodes/keyboard_codes_posix.h"
13 #include "ui/base/models/accelerator.h"
14
15 namespace ui {
16
17 class AcceleratorGtk : public Accelerator {
18 public:
19 AcceleratorGtk(ui::KeyboardCode key_code,
20 bool shift_pressed, bool ctrl_pressed, bool alt_pressed)
21 : gdk_keyval_(0) {
22 key_code_ = key_code;
23 modifiers_ = 0;
24 if (shift_pressed)
25 modifiers_ |= GDK_SHIFT_MASK;
26 if (ctrl_pressed)
27 modifiers_ |= GDK_CONTROL_MASK;
28 if (alt_pressed)
29 modifiers_ |= GDK_MOD1_MASK;
30 }
31
32 AcceleratorGtk(guint keyval, GdkModifierType modifier_type) {
33 key_code_ = ui::WindowsKeyCodeForGdkKeyCode(keyval);
34 gdk_keyval_ = keyval;
35 modifiers_ = modifier_type;
36 }
37
38 AcceleratorGtk() : gdk_keyval_(0) { }
39 virtual ~AcceleratorGtk() { }
40
41 guint GetGdkKeyCode() const {
42 return gdk_keyval_ > 0 ?
43 // The second parameter is false because accelerator keys are
44 // expressed in terms of the non-shift-modified key.
45 gdk_keyval_ : ui::GdkKeyCodeForWindowsKeyCode(key_code_, false);
46 }
47
48 GdkModifierType gdk_modifier_type() const {
49 return static_cast<GdkModifierType>(modifiers());
50 }
51
52 private:
53 // The GDK keycode.
54 guint gdk_keyval_;
55 };
56
57 } // namespace ui
58
59 #endif // UI_BASE_MODELS_ACCELERATOR_GTK_H_
OLDNEW
« no previous file with comments | « ui/base/models/accelerator_cocoa.mm ('k') | ui/base/ui_base_exports.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698