1/* GDK - The GIMP Drawing Kit
2 * Copyright (C) 2000 Red Hat, Inc.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 */
19
20/*
21 * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
22 * file for a list of people on the GTK+ Team. See the ChangeLog
23 * files for a list of changes. These files are distributed with
24 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
25 */
26
27#ifndef __GDK_KEYS_H__
28#define __GDK_KEYS_H__
29
30#if defined(GTK_DISABLE_SINGLE_INCLUDES) && !defined (__GDK_H_INSIDE__) && !defined (GDK_COMPILATION)
31#error "Only <gdk/gdk.h> can be included directly."
32#endif
33
34#include <gdk/gdktypes.h>
35
36G_BEGIN_DECLS
37
38typedef struct _GdkKeymapKey GdkKeymapKey;
39
40/* GdkKeymapKey is a hardware key that can be mapped to a keyval */
41struct _GdkKeymapKey
42{
43 guint keycode;
44 gint group;
45 gint level;
46};
47
48/* A GdkKeymap defines the translation from keyboard state
49 * (including a hardware key, a modifier mask, and active keyboard group)
50 * to a keyval. This translation has two phases. The first phase is
51 * to determine the effective keyboard group and level for the keyboard
52 * state; the second phase is to look up the keycode/group/level triplet
53 * in the keymap and see what keyval it corresponds to.
54 */
55
56typedef struct _GdkKeymap GdkKeymap;
57typedef struct _GdkKeymapClass GdkKeymapClass;
58
59#define GDK_TYPE_KEYMAP (gdk_keymap_get_type ())
60#define GDK_KEYMAP(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_KEYMAP, GdkKeymap))
61#define GDK_KEYMAP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_KEYMAP, GdkKeymapClass))
62#define GDK_IS_KEYMAP(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_KEYMAP))
63#define GDK_IS_KEYMAP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_KEYMAP))
64#define GDK_KEYMAP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_KEYMAP, GdkKeymapClass))
65
66struct _GdkKeymap
67{
68 GObject parent_instance;
69 GdkDisplay *GSEAL (display);
70};
71
72struct _GdkKeymapClass
73{
74 GObjectClass parent_class;
75
76 void (*direction_changed) (GdkKeymap *keymap);
77 void (*keys_changed) (GdkKeymap *keymap);
78 void (*state_changed) (GdkKeymap *keymap);
79};
80
81GType gdk_keymap_get_type (void) G_GNUC_CONST;
82
83#ifndef GDK_MULTIHEAD_SAFE
84GdkKeymap* gdk_keymap_get_default (void);
85#endif
86GdkKeymap* gdk_keymap_get_for_display (GdkDisplay *display);
87
88
89guint gdk_keymap_lookup_key (GdkKeymap *keymap,
90 const GdkKeymapKey *key);
91gboolean gdk_keymap_translate_keyboard_state (GdkKeymap *keymap,
92 guint hardware_keycode,
93 GdkModifierType state,
94 gint group,
95 guint *keyval,
96 gint *effective_group,
97 gint *level,
98 GdkModifierType *consumed_modifiers);
99gboolean gdk_keymap_get_entries_for_keyval (GdkKeymap *keymap,
100 guint keyval,
101 GdkKeymapKey **keys,
102 gint *n_keys);
103gboolean gdk_keymap_get_entries_for_keycode (GdkKeymap *keymap,
104 guint hardware_keycode,
105 GdkKeymapKey **keys,
106 guint **keyvals,
107 gint *n_entries);
108PangoDirection gdk_keymap_get_direction (GdkKeymap *keymap);
109gboolean gdk_keymap_have_bidi_layouts (GdkKeymap *keymap);
110gboolean gdk_keymap_get_caps_lock_state (GdkKeymap *keymap);
111void gdk_keymap_add_virtual_modifiers (GdkKeymap *keymap,
112 GdkModifierType *state);
113gboolean gdk_keymap_map_virtual_modifiers (GdkKeymap *keymap,
114 GdkModifierType *state);
115
116/* Key values
117 */
118gchar* gdk_keyval_name (guint keyval) G_GNUC_CONST;
119guint gdk_keyval_from_name (const gchar *keyval_name);
120void gdk_keyval_convert_case (guint symbol,
121 guint *lower,
122 guint *upper);
123guint gdk_keyval_to_upper (guint keyval) G_GNUC_CONST;
124guint gdk_keyval_to_lower (guint keyval) G_GNUC_CONST;
125gboolean gdk_keyval_is_upper (guint keyval) G_GNUC_CONST;
126gboolean gdk_keyval_is_lower (guint keyval) G_GNUC_CONST;
127
128guint32 gdk_keyval_to_unicode (guint keyval) G_GNUC_CONST;
129guint gdk_unicode_to_keyval (guint32 wc) G_GNUC_CONST;
130
131
132G_END_DECLS
133
134#endif /* __GDK_KEYS_H__ */
135