alternative to assert
[gtkD.git] / src / gtk / IMContext.d
blob42d4240cbe94fa5d6a36dcdc493cbf684e0ba775
1 /*
2 * This file is part of duit.
4 * duit is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * duit 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
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with duit; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = GtkIMContext.html
26 * outPack = gtk
27 * outFile = IMContext
28 * strct = GtkIMContext
29 * realStrct=
30 * ctorStrct=
31 * clss = IMContext
32 * interf =
33 * class Code: No
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - gtk_im_context_
40 * - gtk_
41 * omit structs:
42 * omit prefixes:
43 * omit code:
44 * imports:
45 * - glib.Str
46 * - gdk.Window
47 * - gdk.Rectangle
48 * structWrap:
49 * - GdkRectangle* -> Rectangle
50 * - GdkWindow* -> Window
51 * local aliases:
54 module gtk.IMContext;
56 private import gtk.gtktypes;
58 private import lib.gtk;
60 private import glib.Str;
61 private import gdk.Window;
62 private import gdk.Rectangle;
64 /**
65 * Description
67 private import gobject.ObjectG;
68 public class IMContext : ObjectG
71 /** the main Gtk struct */
72 protected GtkIMContext* gtkIMContext;
75 public GtkIMContext* getIMContextStruct()
77 return gtkIMContext;
81 /** the main Gtk struct as a void* */
82 protected void* getStruct()
84 return cast(void*)gtkIMContext;
87 /**
88 * Sets our main struct and passes it to the parent class
90 public this (GtkIMContext* gtkIMContext)
92 super(cast(GObject*)gtkIMContext);
93 this.gtkIMContext = gtkIMContext;
96 /**
99 // imports for the signal processing
100 private import gobject.Signals;
101 private import gdk.gdktypes;
102 int[char[]] connectedSignals;
104 void delegate(char[], IMContext)[] onCommitListeners;
105 void addOnCommit(void delegate(char[], IMContext) dlg)
107 if ( !("commit" in connectedSignals) )
109 Signals.connectData(
110 getStruct(),
111 "commit",
112 cast(GCallback)&callBackCommit,
113 this,
114 null,
115 cast(ConnectFlags)0);
116 connectedSignals["commit"] = 1;
118 onCommitListeners ~= dlg;
120 extern(C) static void callBackCommit(GtkIMContext* imcontextStruct, gchar* arg1, IMContext iMContext)
122 bit consumed = false;
124 foreach ( void delegate(char[], IMContext) dlg ; iMContext.onCommitListeners )
126 dlg(Str.toString(arg1), iMContext);
129 return consumed;
132 gboolean delegate(gint, gint, IMContext)[] onDeleteSurroundingListeners;
133 void addOnDeleteSurrounding(gboolean delegate(gint, gint, IMContext) dlg)
135 if ( !("delete-surrounding" in connectedSignals) )
137 Signals.connectData(
138 getStruct(),
139 "delete-surrounding",
140 cast(GCallback)&callBackDeleteSurrounding,
141 this,
142 null,
143 cast(ConnectFlags)0);
144 connectedSignals["delete-surrounding"] = 1;
146 onDeleteSurroundingListeners ~= dlg;
148 extern(C) static void callBackDeleteSurrounding(GtkIMContext* imcontextStruct, gint arg1, gint arg2, IMContext iMContext)
150 bit consumed = false;
152 foreach ( gboolean delegate(gint, gint, IMContext) dlg ; iMContext.onDeleteSurroundingListeners )
154 dlg(arg1, arg2, iMContext);
157 return consumed;
160 void delegate(IMContext)[] onPreeditChangedListeners;
161 void addOnPreeditChanged(void delegate(IMContext) dlg)
163 if ( !("preedit-changed" in connectedSignals) )
165 Signals.connectData(
166 getStruct(),
167 "preedit-changed",
168 cast(GCallback)&callBackPreeditChanged,
169 this,
170 null,
171 cast(ConnectFlags)0);
172 connectedSignals["preedit-changed"] = 1;
174 onPreeditChangedListeners ~= dlg;
176 extern(C) static void callBackPreeditChanged(GtkIMContext* imcontextStruct, IMContext iMContext)
178 bit consumed = false;
180 foreach ( void delegate(IMContext) dlg ; iMContext.onPreeditChangedListeners )
182 dlg(iMContext);
185 return consumed;
188 void delegate(IMContext)[] onPreeditEndListeners;
189 void addOnPreeditEnd(void delegate(IMContext) dlg)
191 if ( !("preedit-end" in connectedSignals) )
193 Signals.connectData(
194 getStruct(),
195 "preedit-end",
196 cast(GCallback)&callBackPreeditEnd,
197 this,
198 null,
199 cast(ConnectFlags)0);
200 connectedSignals["preedit-end"] = 1;
202 onPreeditEndListeners ~= dlg;
204 extern(C) static void callBackPreeditEnd(GtkIMContext* imcontextStruct, IMContext iMContext)
206 bit consumed = false;
208 foreach ( void delegate(IMContext) dlg ; iMContext.onPreeditEndListeners )
210 dlg(iMContext);
213 return consumed;
216 void delegate(IMContext)[] onPreeditStartListeners;
217 void addOnPreeditStart(void delegate(IMContext) dlg)
219 if ( !("preedit-start" in connectedSignals) )
221 Signals.connectData(
222 getStruct(),
223 "preedit-start",
224 cast(GCallback)&callBackPreeditStart,
225 this,
226 null,
227 cast(ConnectFlags)0);
228 connectedSignals["preedit-start"] = 1;
230 onPreeditStartListeners ~= dlg;
232 extern(C) static void callBackPreeditStart(GtkIMContext* imcontextStruct, IMContext iMContext)
234 bit consumed = false;
236 foreach ( void delegate(IMContext) dlg ; iMContext.onPreeditStartListeners )
238 dlg(iMContext);
241 return consumed;
244 gboolean delegate(IMContext)[] onRetrieveSurroundingListeners;
245 void addOnRetrieveSurrounding(gboolean delegate(IMContext) dlg)
247 if ( !("retrieve-surrounding" in connectedSignals) )
249 Signals.connectData(
250 getStruct(),
251 "retrieve-surrounding",
252 cast(GCallback)&callBackRetrieveSurrounding,
253 this,
254 null,
255 cast(ConnectFlags)0);
256 connectedSignals["retrieve-surrounding"] = 1;
258 onRetrieveSurroundingListeners ~= dlg;
260 extern(C) static void callBackRetrieveSurrounding(GtkIMContext* imcontextStruct, IMContext iMContext)
262 bit consumed = false;
264 foreach ( gboolean delegate(IMContext) dlg ; iMContext.onRetrieveSurroundingListeners )
266 dlg(iMContext);
269 return consumed;
275 * Set the client window for the input context; this is the
276 * GdkWindow in which the input appears. This window is
277 * used in order to correctly position status windows, and may
278 * also be used for purposes internal to the input method.
279 * context:
280 * a GtkIMContext
281 * window:
282 * the client window. This may be NULL to indicate
283 * that the previous client window no longer exists.
285 public void setClientWindow(Window window)
287 // void gtk_im_context_set_client_window (GtkIMContext *context, GdkWindow *window);
288 gtk_im_context_set_client_window(gtkIMContext, (window is null) ? null : window.getWindowStruct());
292 * Retrieve the current preedit string for the input context,
293 * and a list of attributes to apply to the string.
294 * This string should be displayed inserted at the insertion
295 * point.
296 * context:
297 * a GtkIMContext
298 * str:
299 * location to store the retrieved string. The
300 * string retrieved must be freed with g_free().
301 * attrs:
302 * location to store the retrieved attribute list.
303 * When you are done with this list, you must
304 * unreference it with pango_attr_list_unref().
305 * cursor_pos:
306 * location to store position of cursor (in characters)
307 * within the preedit string.
309 public void getPreeditString(char** str, PangoAttrList** attrs, int* cursorPos)
311 // void gtk_im_context_get_preedit_string (GtkIMContext *context, gchar **str, PangoAttrList **attrs, gint *cursor_pos);
312 gtk_im_context_get_preedit_string(gtkIMContext, str, attrs, cursorPos);
316 * Allow an input method to internally handle key press and release
317 * events. If this function returns TRUE, then no further processing
318 * should be done for this key event.
319 * context:
320 * a GtkIMContext
321 * event:
322 * the key event
323 * Returns:
324 * TRUE if the input method handled the key event.
326 public int filterKeypress(GdkEventKey* event)
328 // gboolean gtk_im_context_filter_keypress (GtkIMContext *context, GdkEventKey *event);
329 return gtk_im_context_filter_keypress(gtkIMContext, event);
333 * Notify the input method that the widget to which this
334 * input context corresponds has gained focus. The input method
335 * may, for example, change the displayed feedback to reflect
336 * this change.
337 * context:
338 * a GtkIMContext
340 public void focusIn()
342 // void gtk_im_context_focus_in (GtkIMContext *context);
343 gtk_im_context_focus_in(gtkIMContext);
347 * Notify the input method that the widget to which this
348 * input context corresponds has lost focus. The input method
349 * may, for example, change the displayed feedback or reset the contexts
350 * state to reflect this change.
351 * context:
352 * a GtkIMContext
354 public void focusOut()
356 // void gtk_im_context_focus_out (GtkIMContext *context);
357 gtk_im_context_focus_out(gtkIMContext);
361 * Notify the input method that a change such as a change in cursor
362 * position has been made. This will typically cause the input
363 * method to clear the preedit state.
364 * context:
365 * a GtkIMContext
367 public void reset()
369 // void gtk_im_context_reset (GtkIMContext *context);
370 gtk_im_context_reset(gtkIMContext);
374 * Notify the input method that a change in cursor
375 * position has been made. The location is relative to the client
376 * window.
377 * context:
378 * a GtkIMContext
379 * area:
380 * new location
382 public void setCursorLocation(Rectangle area)
384 // void gtk_im_context_set_cursor_location (GtkIMContext *context, GdkRectangle *area);
385 gtk_im_context_set_cursor_location(gtkIMContext, (area is null) ? null : area.getRectangleStruct());
389 * Sets whether the IM context should use the preedit string
390 * to display feedback. If use_preedit is FALSE (default
391 * is TRUE), then the IM context may use some other method to display
392 * feedback, such as displaying it in a child of the root window.
393 * context:
394 * a GtkIMContext
395 * use_preedit:
396 * whether the IM context should use the preedit string.
398 public void setUsePreedit(int usePreedit)
400 // void gtk_im_context_set_use_preedit (GtkIMContext *context, gboolean use_preedit);
401 gtk_im_context_set_use_preedit(gtkIMContext, usePreedit);
405 * Sets surrounding context around the insertion point and preedit
406 * string. This function is expected to be called in response to the
407 * GtkIMContext::retrieve_surrounding signal, and will likely have no
408 * effect if called at other times.
409 * context:
410 * a GtkIMContext
411 * text:
412 * text surrounding the insertion point, as UTF-8.
413 * the preedit string should not be included within
414 * text.
415 * len:
416 * the length of text, or -1 if text is nul-terminated
417 * cursor_index:
418 * the byte index of the insertion cursor within text.
420 public void setSurrounding(char[] text, int len, int cursorIndex)
422 // void gtk_im_context_set_surrounding (GtkIMContext *context, const gchar *text, gint len, gint cursor_index);
423 gtk_im_context_set_surrounding(gtkIMContext, Str.toStringz(text), len, cursorIndex);
427 * Retrieves context around the insertion point. Input methods
428 * typically want context in order to constrain input text based on
429 * existing text; this is important for languages such as Thai where
430 * only some sequences of characters are allowed.
431 * This function is implemented by emitting the
432 * GtkIMContext::retrieve_surrounding signal on the input method; in
433 * response to this signal, a widget should provide as much context as
434 * is available, up to an entire paragraph, by calling
435 * gtk_im_context_set_surrounding(). Note that there is no obligation
436 * for a widget to respond to the ::retrieve_surrounding signal, so input
437 * methods must be prepared to function without context.
438 * context:
439 * a GtkIMContext
440 * text:
441 * location to store a UTF-8 encoded string of text
442 * holding context around the insertion point.
443 * If the function returns TRUE, then you must free
444 * the result stored in this location with g_free().
445 * cursor_index:
446 * location to store byte index of the insertion cursor
447 * within text.
448 * Returns:
449 * TRUE if surrounding text was provided; in this case
450 * you must free the result stored in *text.
452 public int getSurrounding(char** text, int* cursorIndex)
454 // gboolean gtk_im_context_get_surrounding (GtkIMContext *context, gchar **text, gint *cursor_index);
455 return gtk_im_context_get_surrounding(gtkIMContext, text, cursorIndex);
459 * Asks the widget that the input context is attached to to delete
460 * characters around the cursor position by emitting the
461 * GtkIMContext::delete_surrounding signal. Note that offset and n_chars
462 * are in characters not in bytes which differs from the usage other
463 * places in GtkIMContext.
464 * In order to use this function, you should first call
465 * gtk_im_context_get_surrounding() to get the current context, and
466 * call this function immediately afterwards to make sure that you
467 * know what you are deleting. You should also account for the fact
468 * that even if the signal was handled, the input context might not
469 * have deleted all the characters that were requested to be deleted.
470 * This function is used by an input method that wants to make
471 * subsitutions in the existing text in response to new input. It is
472 * not useful for applications.
473 * context:
474 * a GtkIMContext
475 * offset:
476 * offset from cursor position in chars;
477 * a negative value means start before the cursor.
478 * n_chars:
479 * number of characters to delete.
480 * Returns:
481 * TRUE if the signal was handled.
482 * Signal Details
483 * The "commit" signal
484 * void user_function (GtkIMContext *imcontext,
485 * gchar *arg1,
486 * gpointer user_data) : Run last
487 * imcontext:
488 * the object which received the signal.
489 * arg1:
490 * user_data:
491 * user data set when the signal handler was connected.
493 public int deleteSurrounding(int offset, int nChars)
495 // gboolean gtk_im_context_delete_surrounding (GtkIMContext *context, gint offset, gint n_chars);
496 return gtk_im_context_delete_surrounding(gtkIMContext, offset, nChars);