Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef UI_BASE_ACCELERATORS_ACCELERATOR_GTK_H_ | 5 #ifndef UI_BASE_ACCELERATORS_ACCELERATOR_GTK_H_ |
| 6 #define UI_BASE_ACCELERATORS_ACCELERATOR_GTK_H_ | 6 #define UI_BASE_ACCELERATORS_ACCELERATOR_GTK_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <gdk/gdk.h> | 9 #include <gdk/gdk.h> |
| 10 | 10 |
| 11 #include "ui/base/accelerators/accelerator.h" | 11 #include "ui/base/accelerators/accelerator.h" |
| 12 #include "ui/base/keycodes/keyboard_code_conversion_gtk.h" | 12 #include "ui/base/ui_export.h" |
| 13 #include "ui/base/keycodes/keyboard_codes_posix.h" | |
| 14 | 13 |
| 15 namespace ui { | 14 namespace ui { |
| 16 | 15 |
| 17 class AcceleratorGtk : public Accelerator { | 16 class UI_EXPORT AcceleratorGtk : public Accelerator { |
| 18 public: | 17 public: |
| 19 AcceleratorGtk(ui::KeyboardCode key_code, | 18 AcceleratorGtk(); |
| 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 | 19 |
| 32 AcceleratorGtk(guint keyval, GdkModifierType modifier_type) { | 20 AcceleratorGtk(guint key_code, GdkModifierType modifier_type); |
| 33 key_code_ = ui::WindowsKeyCodeForGdkKeyCode(keyval); | |
| 34 gdk_keyval_ = keyval; | |
| 35 modifiers_ = modifier_type; | |
| 36 } | |
| 37 | 21 |
| 38 AcceleratorGtk() : gdk_keyval_(0) { } | 22 AcceleratorGtk(KeyboardCode key_code, |
| 39 virtual ~AcceleratorGtk() { } | 23 bool shift_pressed, |
| 24 bool ctrl_pressed, | |
| 25 bool alt_pressed); | |
| 40 | 26 |
| 41 guint GetGdkKeyCode() const { | 27 virtual ~AcceleratorGtk(); |
| 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 | 28 |
| 48 GdkModifierType gdk_modifier_type() const { | 29 guint GetGdkKeyCode() const; |
|
sky
2012/04/02 15:12:16
unix_hacker_style is fine for this.
tfarina
2012/04/02 20:25:16
Done.
| |
| 49 return static_cast<GdkModifierType>(modifiers()); | 30 |
| 50 } | 31 GdkModifierType GetGdkModifierType() const; |
| 51 | 32 |
| 52 private: | 33 private: |
| 53 // The GDK keycode. | 34 guint gdk_key_code_; |
| 54 guint gdk_keyval_; | 35 |
| 36 // Copy and assign is allowed. | |
| 55 }; | 37 }; |
| 56 | 38 |
| 57 } // namespace ui | 39 } // namespace ui |
| 58 | 40 |
| 59 #endif // UI_BASE_ACCELERATORS_ACCELERATOR_GTK_H_ | 41 #endif // UI_BASE_ACCELERATORS_ACCELERATOR_GTK_H_ |
| OLD | NEW |