| 1 | #ifndef _GTKMM_ACCELKEY_H |
| 2 | #define _GTKMM_ACCELKEY_H |
| 3 | /* menu_elems.h |
| 4 | * |
| 5 | * Copyright (C) 1998-2002 The gtkmm Development Team |
| 6 | * |
| 7 | * This library is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU Lesser General Public |
| 9 | * License as published by the Free Software Foundation; either |
| 10 | * version 2.1 of the License, or (at your option) any later version. |
| 11 | * |
| 12 | * This library is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * Lesser General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU Lesser General Public |
| 18 | * License along with this library; if not, see <https://www.gnu.org/licenses/>. |
| 19 | */ |
| 20 | |
| 21 | #include <gtkmmconfig.h> |
| 22 | |
| 23 | #include <gdk/gdkkeysyms.h> |
| 24 | #include <gdkmm/types.h> |
| 25 | |
| 26 | namespace Gtk |
| 27 | { |
| 28 | |
| 29 | /** Defines accelerator key combinations. |
| 30 | * For instance, pressing Control-Q to activate the File|Quit menu item. |
| 31 | * |
| 32 | * By defining accelerator paths you can allow the user of your application |
| 33 | * to change accelerators himself. An example of an accelerator might be |
| 34 | * "<MainWindow>/File/Open". Modified accelerators may be saved. |
| 35 | * |
| 36 | * Key values are the codes which are sent whenever a key is pressed or released. |
| 37 | * The complete list of key values can be found in the |
| 38 | * <a href="https://gitlab.gnome.org/GNOME/gtk/tree/gtk-3-24/gdk/gdkkeysyms.h">gdk/gdkkeysyms.h</a> |
| 39 | * header file. They are prefixed with <tt>GDK_KEY_</tt>. |
| 40 | * |
| 41 | * @see Gtk::AccelMap |
| 42 | * @ingroup Menus |
| 43 | */ |
| 44 | class GTKMM_API AccelKey |
| 45 | { |
| 46 | public: |
| 47 | AccelKey(); |
| 48 | |
| 49 | /** AccelKey constructor. |
| 50 | * @param accel_key For instance, 'q' |
| 51 | * @param accel_mods For instance, Gdk::CONTROL_MASK |
| 52 | * @param accel_path For instance, "<MainWindow>/File/Open" |
| 53 | */ |
| 54 | AccelKey(guint accel_key, Gdk::ModifierType accel_mods, |
| 55 | const Glib::ustring& accel_path = ""); |
| 56 | |
| 57 | /** AccelKey constructor. |
| 58 | * @param accelerator For instance, "<control>q" - Use |
| 59 | * <control>, <shift>, <alt> and <release>. |
| 60 | * Use F1, F2, etc, for function keys. |
| 61 | * @param accel_path For instance, "<MainWindow>/File/Open" |
| 62 | */ |
| 63 | AccelKey(const Glib::ustring& accelerator, |
| 64 | const Glib::ustring& accel_path = Glib::ustring()); |
| 65 | |
| 66 | AccelKey(const AccelKey& src); |
| 67 | |
| 68 | AccelKey& operator=(const AccelKey& src); |
| 69 | |
| 70 | bool is_null() const; |
| 71 | |
| 72 | /** |
| 73 | * Gets the accelerator key. |
| 74 | */ |
| 75 | guint get_key() const; |
| 76 | /** |
| 77 | * Gets the accelerator modifier. |
| 78 | */ |
| 79 | Gdk::ModifierType get_mod() const; |
| 80 | /** |
| 81 | * Gets the accelerator path. |
| 82 | */ |
| 83 | Glib::ustring get_path() const; |
| 84 | /** |
| 85 | * Gets the accelerator representation for labels. |
| 86 | */ |
| 87 | Glib::ustring get_abbrev() const; |
| 88 | |
| 89 | protected: |
| 90 | guint key_; |
| 91 | Gdk::ModifierType mod_; |
| 92 | Glib::ustring path_; |
| 93 | }; |
| 94 | |
| 95 | } /* namespace Gtk */ |
| 96 | |
| 97 | #endif //_GTKMM_ACCELKEY_H |