| 1 |
/* Copyright (C) 1998-2002 The gtkmm Development Team |
| 2 |
* |
| 3 |
* This library is free software; you can redistribute it and/or |
| 4 |
* modify it under the terms of the GNU Lesser General Public |
| 5 |
* License as published by the Free Software Foundation; either |
| 6 |
* version 2.1 of the License, or (at your option) any later version. |
| 7 |
* |
| 8 |
* This library is distributed in the hope that it will be useful, |
| 9 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 11 |
* Lesser General Public License for more details. |
| 12 |
* |
| 13 |
* You should have received a copy of the GNU Lesser General Public |
| 14 |
* License along with this library; if not, see <https://www.gnu.org/licenses/>. |
| 15 |
*/ |
| 16 |
|
| 17 |
_CONFIGINCLUDE(gtkmmconfig.h) |
| 18 |
|
| 19 |
|
| 20 |
_DEFS(gtkmm,gtk) |
| 21 |
_PINCLUDE(glibmm/private/object_p.h) |
| 22 |
|
| 23 |
#include <gdkmm/types.h> |
| 24 |
#include <glibmm/object.h> |
| 25 |
|
| 26 |
|
| 27 |
namespace Gtk |
| 28 |
{ |
| 29 |
|
| 30 |
/** A Gtk::AccelGroup represents a group of keyboard accelerators, typically |
| 31 |
* attached to a toplevel Gtk::Window (with Gtk::Window::add_accel_group()). |
| 32 |
* Usually you won't need to create a Gtk::AccelGroup directly; instead, gtkmm |
| 33 |
* automatically sets up the accelerators for your menus. Note that |
| 34 |
* accelerators are different from mnemonics. Accelerators are shortcuts for |
| 35 |
* activating a menu item; they appear alongside the menu item for which |
| 36 |
* they're a shortcut. For example "Ctrl+Q" might appear alongside the "Quit" |
| 37 |
* menu item. Mnemonics are shortcuts for GUI elements such as text entries or |
| 38 |
* buttons; they appear as underlined characters. See the Gtk::Label |
| 39 |
* constructor. Menu items can have both accelerators and mnemonics, of course. |
| 40 |
* |
| 41 |
* Key values are the codes which are sent whenever a key is pressed or released. |
| 42 |
* The complete list of key values can be found in the |
| 43 |
* <a href="https://gitlab.gnome.org/GNOME/gtk/tree/gtk-3-24/gdk/gdkkeysyms.h">gdk/gdkkeysyms.h</a> |
| 44 |
* header file. They are prefixed with <tt>GDK_KEY_</tt>. |
| 45 |
*/ |
| 46 |
class GTKMM_API AccelGroup : public Glib::Object |
| 47 |
{ |
| 48 |
_CLASS_GOBJECT(AccelGroup, GtkAccelGroup, GTK_ACCEL_GROUP,Glib::Object,GObject,,,GTKMM_API) |
| 49 |
_IGNORE(gtk_accel_group_connect, gtk_accel_group_connect_by_path, gtk_accel_group_disconnect, |
| 50 |
gtk_accel_group_query) |
| 51 |
_IGNORE_SIGNAL(accel_activate) |
| 52 |
protected: |
| 53 |
_CTOR_DEFAULT |
| 54 |
|
| 55 |
public: |
| 56 |
/** Creates a new Gtk::AccelGroup object. |
| 57 |
* @return A Glib::RefPtr<> to a newly created Gtk::AccelGroup object. |
| 58 |
*/ |
| 59 |
_WRAP_CREATE() |
| 60 |
|
| 61 |
_WRAP_METHOD(bool get_is_locked() const, gtk_accel_group_get_is_locked) |
| 62 |
_WRAP_METHOD(Gdk::ModifierType get_modifier_mask() const, gtk_accel_group_get_modifier_mask) |
| 63 |
|
| 64 |
_WRAP_METHOD(void lock(), gtk_accel_group_lock) |
| 65 |
_WRAP_METHOD(void unlock(), gtk_accel_group_unlock) |
| 66 |
_WRAP_METHOD(bool disconnect_key(guint accel_key, Gdk::ModifierType accel_mods), gtk_accel_group_disconnect_key) |
| 67 |
|
| 68 |
/** Determines whether a given keyval and modifier mask constitute |
| 69 |
* a valid keyboard accelerator. For example, the 'a' keyval |
| 70 |
* plus Gdk::CONTROL_MASK is valid - this is a "Ctrl+a" accelerator. |
| 71 |
* But you can't, for instance, use the GDK_Control_L keyval |
| 72 |
* as an accelerator. |
| 73 |
*/ |
| 74 |
static bool valid(guint keyval, Gdk::ModifierType modifiers); |
| 75 |
|
| 76 |
/** Parse the accelerator string. |
| 77 |
* @param accelerator See the Gtk::AccelKey constructor for the format. |
| 78 |
* @param accelerator_key Output argument |
| 79 |
* @param accelerator_mods Output argument |
| 80 |
*/ |
| 81 |
static void parse(const Glib::ustring& accelerator, guint& accelerator_key, Gdk::ModifierType& accelerator_mods); |
| 82 |
|
| 83 |
/** Converts an accelerator keyval and modifier mask |
| 84 |
* into a string parseable by parse(). |
| 85 |
* For example, if you pass in 'q' and Gdk::CONTROL_MASK, it returns "<Control>q". |
| 86 |
*/ |
| 87 |
static Glib::ustring name(guint accelerator_key, Gdk::ModifierType accelerator_mods); |
| 88 |
|
| 89 |
_WRAP_METHOD(static Glib::ustring get_label(guint accelerator_key, Gdk::ModifierType accelerator_mods), gtk_accelerator_get_label) |
| 90 |
|
| 91 |
/** Sets the modifiers that will be considered significant for keyboard |
| 92 |
* accelerators. The default mod mask is Gdk::CONTROL_MASK | |
| 93 |
* Gdk::SHIFT_MASK | Gdk::MOD1_MASK, that is, Control, Shift, and Alt. |
| 94 |
* Other modifiers will ignored by default. |
| 95 |
* You must include at least the three default modifiers in any |
| 96 |
* value you pass to this function. |
| 97 |
* |
| 98 |
* The default mod mask should be changed on application startup, |
| 99 |
* before using any accelerator groups. |
| 100 |
*/ |
| 101 |
static void set_default_mod_mask(Gdk::ModifierType default_mod_mask); |
| 102 |
|
| 103 |
/// See set_default_mod_mask(). |
| 104 |
static Gdk::ModifierType get_default_mod_mask(); |
| 105 |
|
| 106 |
//TODO: Add an overload that takes a ustring instead of a GQuark. |
| 107 |
_WRAP_METHOD(bool activate(GQuark accel_quark, const Glib::RefPtr<Glib::Object>& acceleratable, guint accel_key, Gdk::ModifierType accel_mods), gtk_accel_group_activate) |
| 108 |
|
| 109 |
_IGNORE(gtk_accel_group_find) |
| 110 |
//Let's not wrap this, because the GtkAccelGroupFindFunc callback uses GClosures, and it's not clear that this is useful. |
| 111 |
//AccelKey find(const SlotFind& slot); |
| 112 |
//GtkAccelKey* gtk_accel_group_find(GtkAccelGroup* accel_group, GtkAccelGroupFindFunc find_func, gpointer data); |
| 113 |
|
| 114 |
//TODO: _WRAP_METHOD(static bool activate(Object& object, guint accel_key, Gdk::ModifierType accel_mods), gtk_accel_groups_activate) |
| 115 |
|
| 116 |
#m4 _CONVERSION(`GObject*',`const Glib::RefPtr<Glib::Object>&',`Glib::wrap($3, true)') |
| 117 |
_WRAP_SIGNAL(bool accel_activate(const Glib::RefPtr<Glib::Object>& acceleratable, guint keyval, Gdk::ModifierType modifier), "accel_activate", no_default_handler, |
| 118 |
deprecated "This signal is not meant to be used by applications.") |
| 119 |
|
| 120 |
//TODO: The C type is unpleasant: |
| 121 |
//This has C docs, but it isn't worth mentioning them for such a useless signal. murrayc. |
| 122 |
_WRAP_SIGNAL(void accel_changed(guint keyval, Gdk::ModifierType modifier, GClosure* accel_closure), "accel_changed", no_default_handler, |
| 123 |
detail_name accel_name, two_signal_methods) |
| 124 |
|
| 125 |
_WRAP_PROPERTY("is-locked", bool) |
| 126 |
_WRAP_PROPERTY("modifier-mask", Gdk::ModifierType) |
| 127 |
}; |
| 128 |
|
| 129 |
} // namespace Gtk |