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 = GtkEntry.html
46 * - gtk.EntryCompletion
48 * - GtkEntryCompletion* -> EntryCompletion
54 private import gtk
.gtktypes
;
56 private import lib
.gtk
;
58 private import glib
.Str
;
59 private import gtk
.EntryCompletion
;
63 * The GtkEntry widget is a single line text entry
64 * widget. A fairly large set of key bindings are supported
65 * by default. If the entered text is longer than the allocation
66 * of the widget, the widget will scroll so that the cursor
67 * position is visible.
69 private import gtk
.Widget
;
70 public class Entry
: Widget
73 /** the main Gtk struct */
74 protected GtkEntry
* gtkEntry
;
77 public GtkEntry
* getEntryStruct()
83 /** the main Gtk struct as a void* */
84 protected void* getStruct()
86 return cast(void*)gtkEntry
;
90 * Sets our main struct and passes it to the parent class
92 public this (GtkEntry
* gtkEntry
)
94 super(cast(GtkWidget
*)gtkEntry
);
95 this.gtkEntry
= gtkEntry
;
98 public this (char[] text
)
104 public this (char[] text
, int max
)
113 // imports for the signal processing
114 private import gobject
.Signals
;
115 private import gdk
.gdktypes
;
116 int[char[]] connectedSignals
;
118 void delegate(Entry
)[] onActivateListeners
;
119 void addOnActivate(void delegate(Entry
) dlg
)
121 if ( !("activate" in connectedSignals
) )
126 cast(GCallback
)&callBackActivate
,
129 cast(ConnectFlags
)0);
130 connectedSignals
["activate"] = 1;
132 onActivateListeners
~= dlg
;
134 extern(C
) static void callBackActivate(GtkEntry
* entryStruct
, Entry entry
)
136 bit consumed
= false;
138 foreach ( void delegate(Entry
) dlg
; entry
.onActivateListeners
)
146 void delegate(Entry
)[] onBackspaceListeners
;
147 void addOnBackspace(void delegate(Entry
) dlg
)
149 if ( !("backspace" in connectedSignals
) )
154 cast(GCallback
)&callBackBackspace
,
157 cast(ConnectFlags
)0);
158 connectedSignals
["backspace"] = 1;
160 onBackspaceListeners
~= dlg
;
162 extern(C
) static void callBackBackspace(GtkEntry
* entryStruct
, Entry entry
)
164 bit consumed
= false;
166 foreach ( void delegate(Entry
) dlg
; entry
.onBackspaceListeners
)
174 void delegate(Entry
)[] onCopyClipboardListeners
;
175 void addOnCopyClipboard(void delegate(Entry
) dlg
)
177 if ( !("copy-clipboard" in connectedSignals
) )
182 cast(GCallback
)&callBackCopyClipboard
,
185 cast(ConnectFlags
)0);
186 connectedSignals
["copy-clipboard"] = 1;
188 onCopyClipboardListeners
~= dlg
;
190 extern(C
) static void callBackCopyClipboard(GtkEntry
* entryStruct
, Entry entry
)
192 bit consumed
= false;
194 foreach ( void delegate(Entry
) dlg
; entry
.onCopyClipboardListeners
)
202 void delegate(Entry
)[] onCutClipboardListeners
;
203 void addOnCutClipboard(void delegate(Entry
) dlg
)
205 if ( !("cut-clipboard" in connectedSignals
) )
210 cast(GCallback
)&callBackCutClipboard
,
213 cast(ConnectFlags
)0);
214 connectedSignals
["cut-clipboard"] = 1;
216 onCutClipboardListeners
~= dlg
;
218 extern(C
) static void callBackCutClipboard(GtkEntry
* entryStruct
, Entry entry
)
220 bit consumed
= false;
222 foreach ( void delegate(Entry
) dlg
; entry
.onCutClipboardListeners
)
230 void delegate(GtkDeleteType
, gint
, Entry
)[] onDeleteFromCursorListeners
;
231 void addOnDeleteFromCursor(void delegate(GtkDeleteType
, gint
, Entry
) dlg
)
233 if ( !("delete-from-cursor" in connectedSignals
) )
237 "delete-from-cursor",
238 cast(GCallback
)&callBackDeleteFromCursor
,
241 cast(ConnectFlags
)0);
242 connectedSignals
["delete-from-cursor"] = 1;
244 onDeleteFromCursorListeners
~= dlg
;
246 extern(C
) static void callBackDeleteFromCursor(GtkEntry
* entryStruct
, GtkDeleteType arg1
, gint arg2
, Entry entry
)
248 bit consumed
= false;
250 foreach ( void delegate(GtkDeleteType
, gint
, Entry
) dlg
; entry
.onDeleteFromCursorListeners
)
252 dlg(arg1
, arg2
, entry
);
258 void delegate(char[], Entry
)[] onInsertAtCursorListeners
;
259 void addOnInsertAtCursor(void delegate(char[], Entry
) dlg
)
261 if ( !("insert-at-cursor" in connectedSignals
) )
266 cast(GCallback
)&callBackInsertAtCursor
,
269 cast(ConnectFlags
)0);
270 connectedSignals
["insert-at-cursor"] = 1;
272 onInsertAtCursorListeners
~= dlg
;
274 extern(C
) static void callBackInsertAtCursor(GtkEntry
* entryStruct
, gchar
* arg1
, Entry entry
)
276 bit consumed
= false;
278 foreach ( void delegate(char[], Entry
) dlg
; entry
.onInsertAtCursorListeners
)
280 dlg(Str
.toString(arg1
), entry
);
286 void delegate(GtkMovementStep
, gint
, gboolean
, Entry
)[] onMoveCursorListeners
;
287 void addOnMoveCursor(void delegate(GtkMovementStep
, gint
, gboolean
, Entry
) dlg
)
289 if ( !("move-cursor" in connectedSignals
) )
294 cast(GCallback
)&callBackMoveCursor
,
297 cast(ConnectFlags
)0);
298 connectedSignals
["move-cursor"] = 1;
300 onMoveCursorListeners
~= dlg
;
302 extern(C
) static void callBackMoveCursor(GtkEntry
* entryStruct
, GtkMovementStep arg1
, gint arg2
, gboolean arg3
, Entry entry
)
304 bit consumed
= false;
306 foreach ( void delegate(GtkMovementStep
, gint
, gboolean
, Entry
) dlg
; entry
.onMoveCursorListeners
)
308 dlg(arg1
, arg2
, arg3
, entry
);
314 void delegate(Entry
)[] onPasteClipboardListeners
;
315 void addOnPasteClipboard(void delegate(Entry
) dlg
)
317 if ( !("paste-clipboard" in connectedSignals
) )
322 cast(GCallback
)&callBackPasteClipboard
,
325 cast(ConnectFlags
)0);
326 connectedSignals
["paste-clipboard"] = 1;
328 onPasteClipboardListeners
~= dlg
;
330 extern(C
) static void callBackPasteClipboard(GtkEntry
* entryStruct
, Entry entry
)
332 bit consumed
= false;
334 foreach ( void delegate(Entry
) dlg
; entry
.onPasteClipboardListeners
)
342 void delegate(GtkMenu
*, Entry
)[] onPopulatePopupListeners
;
343 void addOnPopulatePopup(void delegate(GtkMenu
*, Entry
) dlg
)
345 if ( !("populate-popup" in connectedSignals
) )
350 cast(GCallback
)&callBackPopulatePopup
,
353 cast(ConnectFlags
)0);
354 connectedSignals
["populate-popup"] = 1;
356 onPopulatePopupListeners
~= dlg
;
358 extern(C
) static void callBackPopulatePopup(GtkEntry
* entryStruct
, GtkMenu
* arg1
, Entry entry
)
360 bit consumed
= false;
362 foreach ( void delegate(GtkMenu
*, Entry
) dlg
; entry
.onPopulatePopupListeners
)
370 void delegate(Entry
)[] onToggleOverwriteListeners
;
371 void addOnToggleOverwrite(void delegate(Entry
) dlg
)
373 if ( !("toggle-overwrite" in connectedSignals
) )
378 cast(GCallback
)&callBackToggleOverwrite
,
381 cast(ConnectFlags
)0);
382 connectedSignals
["toggle-overwrite"] = 1;
384 onToggleOverwriteListeners
~= dlg
;
386 extern(C
) static void callBackToggleOverwrite(GtkEntry
* entryStruct
, Entry entry
)
388 bit consumed
= false;
390 foreach ( void delegate(Entry
) dlg
; entry
.onToggleOverwriteListeners
)
401 * Creates a new entry.
407 // GtkWidget* gtk_entry_new (void);
408 this(cast(GtkEntry
*)gtk_entry_new() );
413 * gtk_entry_new_with_max_length is deprecated and should not be used in newly-written code.
414 * Creates a new GtkEntry widget with the given maximum length.
415 * Note: the existence of this function is inconsistent
416 * with the rest of the GTK+ API. The normal setup would
417 * be to just require the user to make an extra call
418 * to gtk_entry_set_max_length() instead. It is not
419 * expected that this function will be removed, but
420 * it would be better practice not to use it.
422 * the maximum length of the entry, or 0 for no maximum.
423 * (other than the maximum length of entries.) The value passed in will
424 * be clamped to the range 0-65536.
428 public this (int max
)
430 // GtkWidget* gtk_entry_new_with_max_length (gint max);
431 this(cast(GtkEntry
*)gtk_entry_new_with_max_length(max
) );
435 * Sets the text in the widget to the given
436 * value, replacing the current contents.
442 public void setText(char[] text
)
444 // void gtk_entry_set_text (GtkEntry *entry, const gchar *text);
445 gtk_entry_set_text(gtkEntry
, Str
.toStringz(text
));
450 * gtk_entry_append_text is deprecated and should not be used in newly-written code.
451 * Appends the given text to the contents of the widget.
455 * the text to append.
457 public void appendText(char[] text
)
459 // void gtk_entry_append_text (GtkEntry *entry, const gchar *text);
460 gtk_entry_append_text(gtkEntry
, Str
.toStringz(text
));
465 * gtk_entry_prepend_text is deprecated and should not be used in newly-written code.
466 * Prepends the given text to the contents of th ewidget.
470 * the text to prepend.
472 public void prependText(char[] text
)
474 // void gtk_entry_prepend_text (GtkEntry *entry, const gchar *text);
475 gtk_entry_prepend_text(gtkEntry
, Str
.toStringz(text
));
480 * gtk_entry_set_position is deprecated and should not be used in newly-written code.
481 * Sets the cursor position in an entry to the given
482 * value. This function is obsolete. You should use
483 * gtk_editable_set_position() instead.
487 * the position of the cursor. The cursor is displayed
488 * before the character with the given (base 0) index
489 * in the widget. The value must be less than or
490 * equal to the number of characters in the widget.
491 * A value of -1 indicates that the position should
492 * be set after the last character in the entry.
493 * Note that this position is in characters, not in
496 public void setPosition(int position
)
498 // void gtk_entry_set_position (GtkEntry *entry, gint position);
499 gtk_entry_set_position(gtkEntry
, position
);
503 * Retrieves the contents of the entry widget.
504 * See also gtk_editable_get_chars().
508 * a pointer to the contents of the widget as a
509 * string. This string points to internally allocated
510 * storage in the widget and must not be freed, modified or
513 public char[] getText()
515 // const gchar* gtk_entry_get_text (GtkEntry *entry);
516 return Str
.toString(gtk_entry_get_text(gtkEntry
) );
521 * gtk_entry_select_region is deprecated and should not be used in newly-written code.
522 * Selects a region of text. The characters that
523 * are selected are those characters at positions from
524 * start_pos up to, but not including end_pos. If
525 * end_pos is negative, then the the characters selected
526 * will be those characters from start_pos to the end
527 * of the text. This function is obsolete. You should
528 * use gtk_editable_select_region() instead.
532 * the starting position.
536 public void selectRegion(int start
, int end
)
538 // void gtk_entry_select_region (GtkEntry *entry, gint start, gint end);
539 gtk_entry_select_region(gtkEntry
, start
, end
);
543 * Sets whether the contents of the entry are visible or
544 * not. When visibility is set to FALSE, characters
545 * are displayed as the invisible char, and will also appear
546 * that way when the text in the entry widget is copied
548 * The default invisible char is the asterisk '*', but it can
549 * be changed with gtk_entry_set_invisible_char().
553 * TRUE if the contents of the entry are displayed
556 public void setVisibility(int visible
)
558 // void gtk_entry_set_visibility (GtkEntry *entry, gboolean visible);
559 gtk_entry_set_visibility(gtkEntry
, visible
);
563 * Sets the character to use in place of the actual text when
564 * gtk_entry_set_visibility() has been called to set text visibility
565 * to FALSE. i.e. this is the character used in "password mode" to
566 * show the user how many characters have been typed. The default
567 * invisible char is an asterisk ('*'). If you set the invisible char
568 * to 0, then the user will get no feedback at all; there will be
569 * no text on the screen as they type.
573 * a Unicode character
575 public void setInvisibleChar(gunichar ch
)
577 // void gtk_entry_set_invisible_char (GtkEntry *entry, gunichar ch);
578 gtk_entry_set_invisible_char(gtkEntry
, ch
);
583 * gtk_entry_set_editable is deprecated and should not be used in newly-written code.
584 * Determines if the user can edit the text in the editable
585 * widget or not. This function is obsolete. You should
586 * use gtk_editable_set_editable() instead.
590 * TRUE if the user is allowed to edit the text
593 public void setEditable(int editable
)
595 // void gtk_entry_set_editable (GtkEntry *entry, gboolean editable);
596 gtk_entry_set_editable(gtkEntry
, editable
);
600 * Sets the maximum allowed length of the contents of the widget. If
601 * the current contents are longer than the given length, then they
602 * will be truncated to fit.
606 * the maximum length of the entry, or 0 for no maximum.
607 * (other than the maximum length of entries.) The value passed in will
608 * be clamped to the range 0-65536.
610 public void setMaxLength(int max
)
612 // void gtk_entry_set_max_length (GtkEntry *entry, gint max);
613 gtk_entry_set_max_length(gtkEntry
, max
);
617 * Retrieves the value set by gtk_entry_set_activates_default().
621 * TRUE if the entry will activate the default widget
623 public int getActivatesDefault()
625 // gboolean gtk_entry_get_activates_default (GtkEntry *entry);
626 return gtk_entry_get_activates_default(gtkEntry
);
630 * Gets the value set by gtk_entry_set_has_frame().
634 * whether the entry has a beveled frame
636 public int getHasFrame()
638 // gboolean gtk_entry_get_has_frame (GtkEntry *entry);
639 return gtk_entry_get_has_frame(gtkEntry
);
643 * This function returns the entry's inner-border property. See
644 * gtk_entry_set_inner_border() for more information.
648 * the entry's GtkBorder, or NULL if none was set.
651 public GtkBorder
* getInnerBorder()
653 // const GtkBorder* gtk_entry_get_inner_border (GtkEntry *entry);
654 return gtk_entry_get_inner_border(gtkEntry
);
658 * Gets the value set by gtk_entry_set_width_chars().
662 * number of chars to request space for, or negative if unset
664 public int getWidthChars()
666 // gint gtk_entry_get_width_chars (GtkEntry *entry);
667 return gtk_entry_get_width_chars(gtkEntry
);
671 * If setting is TRUE, pressing Enter in the entry will activate the default
672 * widget for the window containing the entry. This usually means that
673 * the dialog box containing the entry will be closed, since the default
674 * widget is usually one of the dialog buttons.
675 * (For experts: if setting is TRUE, the entry calls
676 * gtk_window_activate_default() on the window containing the entry, in
677 * the default handler for the "activate" signal.)
681 * TRUE to activate window's default widget on Enter keypress
683 public void setActivatesDefault(int setting
)
685 // void gtk_entry_set_activates_default (GtkEntry *entry, gboolean setting);
686 gtk_entry_set_activates_default(gtkEntry
, setting
);
690 * Sets whether the entry has a beveled frame around it.
696 public void setHasFrame(int setting
)
698 // void gtk_entry_set_has_frame (GtkEntry *entry, gboolean setting);
699 gtk_entry_set_has_frame(gtkEntry
, setting
);
703 * Sets entry's inner-border property to border, or clears it if NULL
704 * is passed. The inner-border is the area around the entry's text, but
706 * If set, this property overrides the inner-border style property.
707 * Overriding the style-provided border is useful when you want to do
708 * in-place editing of some text in a canvas or list widget, where
709 * pixel-exact positioning of the entry is important.
713 * a GtkBorder, or NULL
716 public void setInnerBorder(GtkBorder
* border
)
718 // void gtk_entry_set_inner_border (GtkEntry *entry, const GtkBorder *border);
719 gtk_entry_set_inner_border(gtkEntry
, border
);
723 * Changes the size request of the entry to be about the right size
724 * for n_chars characters. Note that it changes the size
725 * request, the size can still be affected by
726 * how you pack the widget into containers. If n_chars is -1, the
727 * size reverts to the default entry size.
733 public void setWidthChars(int nChars
)
735 // void gtk_entry_set_width_chars (GtkEntry *entry, gint n_chars);
736 gtk_entry_set_width_chars(gtkEntry
, nChars
);
740 * Retrieves the character displayed in place of the real characters
741 * for entries with visisbility set to false. See gtk_entry_set_invisible_char().
745 * the current invisible char, or 0, if the entry does not
746 * show invisible text at all.
748 public gunichar
getInvisibleChar()
750 // gunichar gtk_entry_get_invisible_char (GtkEntry *entry);
751 return gtk_entry_get_invisible_char(gtkEntry
);
755 * Sets the alignment for the contents of the entry. This controls
756 * the horizontal positioning of the contents when the displayed
757 * text is shorter than the width of the entry.
761 * The horizontal alignment, from 0 (left) to 1 (right).
762 * Reversed for RTL layouts
765 public void setAlignment(float xalign
)
767 // void gtk_entry_set_alignment (GtkEntry *entry, gfloat xalign);
768 gtk_entry_set_alignment(gtkEntry
, xalign
);
772 * Gets the value set by gtk_entry_set_alignment().
779 public float getAlignment()
781 // gfloat gtk_entry_get_alignment (GtkEntry *entry);
782 return gtk_entry_get_alignment(gtkEntry
);
786 * Gets the PangoLayout used to display the entry.
787 * The layout is useful to e.g. convert text positions to
788 * pixel positions, in combination with gtk_entry_get_layout_offsets().
789 * The returned layout is owned by the entry and must not be
790 * modified or freed by the caller.
791 * Keep in mind that the layout text may contain a preedit string, so
792 * gtk_entry_layout_index_to_text_index() and
793 * gtk_entry_text_index_to_layout_index() are needed to convert byte
794 * indices in the layout to byte indices in the entry contents.
798 * the PangoLayout for this entry
800 public PangoLayout
* getLayout()
802 // PangoLayout* gtk_entry_get_layout (GtkEntry *entry);
803 return gtk_entry_get_layout(gtkEntry
);
807 * Obtains the position of the PangoLayout used to render text
808 * in the entry, in widget coordinates. Useful if you want to line
809 * up the text in an entry with some other text, e.g. when using the
810 * entry to implement editable cells in a sheet widget.
811 * Also useful to convert mouse events into coordinates inside the
812 * PangoLayout, e.g. to take some action if some part of the entry text
814 * Note that as the user scrolls around in the entry the offsets will
815 * change; you'll need to connect to the "notify::scroll-offset"
816 * signal to track this. Remember when using the PangoLayout
817 * functions you need to convert to and from pixels using
818 * PANGO_PIXELS() or PANGO_SCALE.
819 * Keep in mind that the layout text may contain a preedit string, so
820 * gtk_entry_layout_index_to_text_index() and
821 * gtk_entry_text_index_to_layout_index() are needed to convert byte
822 * indices in the layout to byte indices in the entry contents.
826 * location to store X offset of layout, or NULL
828 * location to store Y offset of layout, or NULL
830 public void getLayoutOffsets(int* x
, int* y
)
832 // void gtk_entry_get_layout_offsets (GtkEntry *entry, gint *x, gint *y);
833 gtk_entry_get_layout_offsets(gtkEntry
, x
, y
);
837 * Converts from a position in the entry contents (returned
838 * by gtk_entry_get_text()) to a position in the
839 * entry's PangoLayout (returned by gtk_entry_get_layout(),
840 * with text retrieved via pango_layout_get_text()).
844 * byte index into the entry layout text
846 * byte index into the entry contents
848 public int layoutIndexToTextIndex(int layoutIndex
)
850 // gint gtk_entry_layout_index_to_text_index (GtkEntry *entry, gint layout_index);
851 return gtk_entry_layout_index_to_text_index(gtkEntry
, layoutIndex
);
855 * Converts from a position in the entry's PangoLayout (returned by
856 * gtk_entry_get_layout()) to a position in the entry contents
857 * (returned by gtk_entry_get_text()).
861 * byte index into the entry contents
863 * byte index into the entry layout text
865 public int textIndexToLayoutIndex(int textIndex
)
867 // gint gtk_entry_text_index_to_layout_index (GtkEntry *entry, gint text_index);
868 return gtk_entry_text_index_to_layout_index(gtkEntry
, textIndex
);
872 * Retrieves the maximum allowed length of the text in
873 * entry. See gtk_entry_set_max_length().
877 * the maximum allowed number of characters
878 * in GtkEntry, or 0 if there is no maximum.
880 public int getMaxLength()
882 // gint gtk_entry_get_max_length (GtkEntry *entry);
883 return gtk_entry_get_max_length(gtkEntry
);
887 * Retrieves whether the text in entry is visible. See
888 * gtk_entry_set_visibility().
892 * TRUE if the text is currently visible
894 public int getVisibility()
896 // gboolean gtk_entry_get_visibility (GtkEntry *entry);
897 return gtk_entry_get_visibility(gtkEntry
);
901 * Sets completion to be the auxiliary completion object to use with entry.
902 * All further configuration of the completion mechanism is done on
903 * completion using the GtkEntryCompletion API. Completion is disabled if
904 * completion is set to NULL.
908 * The GtkEntryCompletion or NULL.
911 public void setCompletion(EntryCompletion completion
)
913 // void gtk_entry_set_completion (GtkEntry *entry, GtkEntryCompletion *completion);
914 gtk_entry_set_completion(gtkEntry
, (completion
is null) ?
null : completion
.getEntryCompletionStruct());
918 * Returns the auxiliary completion object currently in use by entry.
922 * The auxiliary completion object currently in use by entry.
925 * The "activates-default" property
926 * "activates-default" gboolean : Read / Write
927 * Whether to activate the default widget (such as the default button in a dialog) when Enter is pressed.
928 * Default value: FALSE
930 public EntryCompletion
getCompletion()
932 // GtkEntryCompletion* gtk_entry_get_completion (GtkEntry *entry);
933 return new EntryCompletion( gtk_entry_get_completion(gtkEntry
) );