]> Pileus Git - ~andy/gtk/blob - gtk/gtkimcontext.h
Add: - A ::retrieve_surrounding signal that asks the widget for context
[~andy/gtk] / gtk / gtkimcontext.h
1 /* GTK - The GIMP Toolkit
2  * Copyright (C) 2000 Red Hat Software
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 #ifndef __GTK_IM_CONTEXT_H__
21 #define __GTK_IM_CONTEXT_H__
22
23 #include <gdk/gdk.h>
24 #include <gtk/gtkobject.h>
25 #include <pango/pango.h>
26
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif /* __cplusplus */
31
32 #define GTK_TYPE_IM_CONTEXT              (gtk_im_context_get_type ())
33 #define GTK_IM_CONTEXT(obj)              (GTK_CHECK_CAST ((obj), GTK_TYPE_IM_CONTEXT, GtkIMContext))
34 #define GTK_IM_CONTEXT_CLASS(klass)      (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_IM_CONTEXT, GtkIMContextClass))
35 #define GTK_IS_IM_CONTEXT(obj)           (GTK_CHECK_TYPE ((obj), GTK_TYPE_IM_CONTEXT))
36 #define GTK_IS_IM_CONTEXT_CLASS(klass)   (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_IM_CONTEXT))
37 #define GTK_IM_CONTEXT_GET_CLASS(obj)    (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_IM_CONTEXT, GtkIMContextClass))
38
39
40 typedef struct _GtkIMContext       GtkIMContext;
41 typedef struct _GtkIMContextClass  GtkIMContextClass;
42
43 struct _GtkIMContext
44 {
45   GObject parent_instance;
46 };
47
48 struct _GtkIMContextClass
49 {
50   GtkObjectClass parent_class;
51
52   /* Signals */
53   void     (*preedit_start)        (GtkIMContext *context);
54   void     (*preedit_end)          (GtkIMContext *context);
55   void     (*preedit_changed)      (GtkIMContext *context);
56   void     (*commit)               (GtkIMContext *context, const gchar *str);
57   gboolean (*retrieve_surrounding) (GtkIMContext *context);
58   gboolean (*delete_surrounding)   (GtkIMContext *context,
59                                     gint          offset,
60                                     gint          n_chars);
61
62   /* Virtual functions */
63   void     (*set_client_window)   (GtkIMContext   *context,
64                                    GdkWindow      *window);
65   void     (*get_preedit_string)  (GtkIMContext   *context,
66                                    gchar         **str,
67                                    PangoAttrList **attrs,
68                                    gint           *cursor_pos);
69   gboolean (*filter_keypress)     (GtkIMContext   *context,
70                                    GdkEventKey    *event);
71   void     (*focus_in)            (GtkIMContext   *context);
72   void     (*focus_out)           (GtkIMContext   *context);
73   void     (*reset)               (GtkIMContext   *context);
74   void     (*set_cursor_location) (GtkIMContext   *context,
75                                    GdkRectangle   *area);
76   void     (*set_use_preedit)     (GtkIMContext   *context,
77                                    gboolean        use_preedit);
78   void     (*set_surrounding)     (GtkIMContext   *context,
79                                    const gchar    *text,
80                                    gint            len,
81                                    gint            cursor_index);
82   gboolean (*get_surrounding)     (GtkIMContext   *context,
83                                    gchar         **text,
84                                    gint           *cursor_index);
85 };
86
87 GtkType       gtk_im_context_get_type           (void) G_GNUC_CONST;
88
89 void     gtk_im_context_set_client_window   (GtkIMContext   *context,
90                                              GdkWindow      *window);
91 void     gtk_im_context_get_preedit_string  (GtkIMContext   *context,
92                                              gchar         **str,
93                                              PangoAttrList **attrs,
94                                              gint           *cursor_pos);
95 gboolean gtk_im_context_filter_keypress     (GtkIMContext   *context,
96                                              GdkEventKey    *event);
97 void     gtk_im_context_focus_in            (GtkIMContext   *context);
98 void     gtk_im_context_focus_out           (GtkIMContext   *context);
99 void     gtk_im_context_reset               (GtkIMContext   *context);
100 void     gtk_im_context_set_cursor_location (GtkIMContext   *context,
101                                              GdkRectangle   *area);
102 void     gtk_im_context_set_use_preedit     (GtkIMContext   *context,
103                                              gboolean        use_preedit);
104 void     gtk_im_context_set_surrounding     (GtkIMContext   *context,
105                                              const gchar    *text,
106                                              gint            len,
107                                              gint            cursor_index);
108 gboolean gtk_im_context_get_surrounding     (GtkIMContext   *context,
109                                              gchar         **text,
110                                              gint           *cursor_index);
111 gboolean gtk_im_context_delete_surrounding  (GtkIMContext   *context,
112                                              gint            offset,
113                                              gint            n_chars);
114
115 #ifdef __cplusplus
116 }
117 #endif /* __cplusplus */
118
119
120 #endif /* __GTK_IM_CONTEXT_H__ */