Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

gtkentry.h 15 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. /* GTK - The GIMP Toolkit
  2. * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
  3. *
  4. * Copyright (C) 2004-2006 Christian Hammond
  5. * Copyright (C) 2008 Cody Russell
  6. * Copyright (C) 2008 Red Hat, Inc.
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2 of the License, or (at your option) any later version.
  12. *
  13. * This library is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with this library; if not, write to the
  20. * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  21. * Boston, MA 02111-1307, USA.
  22. */
  23. /*
  24. * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
  25. * file for a list of people on the GTK+ Team. See the ChangeLog
  26. * files for a list of changes. These files are distributed with
  27. * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
  28. */
  29. #if defined(GTK_DISABLE_SINGLE_INCLUDES) && !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
  30. #error "Only <gtk/gtk.h> can be included directly."
  31. #endif
  32. #ifndef __GTK_ENTRY_H__
  33. #define __GTK_ENTRY_H__
  34. #include <gtk/gtkeditable.h>
  35. #include <gtk/gtkimcontext.h>
  36. #include <gtk/gtkmenu.h>
  37. #include <gtk/gtkentrybuffer.h>
  38. #include <gtk/gtkentrycompletion.h>
  39. #include <gtk/gtkimage.h>
  40. #include <gtk/gtkselection.h>
  41. G_BEGIN_DECLS
  42. #define GTK_TYPE_ENTRY (gtk_entry_get_type ())
  43. #define GTK_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_ENTRY, GtkEntry))
  44. #define GTK_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_ENTRY, GtkEntryClass))
  45. #define GTK_IS_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_ENTRY))
  46. #define GTK_IS_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_ENTRY))
  47. #define GTK_ENTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_ENTRY, GtkEntryClass))
  48. typedef enum
  49. {
  50. GTK_ENTRY_ICON_PRIMARY,
  51. GTK_ENTRY_ICON_SECONDARY
  52. } GtkEntryIconPosition;
  53. typedef struct _GtkEntry GtkEntry;
  54. typedef struct _GtkEntryClass GtkEntryClass;
  55. struct _GtkEntry
  56. {
  57. GtkWidget widget;
  58. gchar *GSEAL (text); /* COMPAT: Deprecated, not used. Remove in GTK+ 3.x */
  59. guint GSEAL (editable) : 1;
  60. guint GSEAL (visible) : 1;
  61. guint GSEAL (overwrite_mode) : 1;
  62. guint GSEAL (in_drag) : 1; /* FIXME: Should be private?
  63. Dragging within the selection */
  64. guint16 GSEAL (text_length); /* COMPAT: Deprecated, not used. Remove in GTK+ 3.x */
  65. guint16 GSEAL (text_max_length); /* COMPAT: Deprecated, not used. Remove in GTK+ 3.x */
  66. /*< private >*/
  67. GdkWindow *GSEAL (text_area);
  68. GtkIMContext *GSEAL (im_context);
  69. GtkWidget *GSEAL (popup_menu);
  70. gint GSEAL (current_pos);
  71. gint GSEAL (selection_bound);
  72. PangoLayout *GSEAL (cached_layout);
  73. guint GSEAL (cache_includes_preedit) : 1;
  74. guint GSEAL (need_im_reset) : 1;
  75. guint GSEAL (has_frame) : 1;
  76. guint GSEAL (activates_default) : 1;
  77. guint GSEAL (cursor_visible) : 1;
  78. guint GSEAL (in_click) : 1; /* Flag so we don't select all when clicking in entry to focus in */
  79. guint GSEAL (is_cell_renderer) : 1;
  80. guint GSEAL (editing_canceled) : 1; /* Only used by GtkCellRendererText */
  81. guint GSEAL (mouse_cursor_obscured) : 1;
  82. guint GSEAL (select_words) : 1;
  83. guint GSEAL (select_lines) : 1;
  84. guint GSEAL (resolved_dir) : 4; /* PangoDirection */
  85. guint GSEAL (truncate_multiline) : 1;
  86. guint GSEAL (button);
  87. guint GSEAL (blink_timeout);
  88. guint GSEAL (recompute_idle);
  89. gint GSEAL (scroll_offset);
  90. gint GSEAL (ascent); /* font ascent in pango units */
  91. gint GSEAL (descent); /* font descent in pango units */
  92. guint16 GSEAL (x_text_size); /* allocated size, in bytes */
  93. guint16 GSEAL (x_n_bytes); /* length in use, in bytes */
  94. guint16 GSEAL (preedit_length); /* length of preedit string, in bytes */
  95. guint16 GSEAL (preedit_cursor); /* offset of cursor within preedit string, in chars */
  96. gint GSEAL (dnd_position); /* In chars, -1 == no DND cursor */
  97. gint GSEAL (drag_start_x);
  98. gint GSEAL (drag_start_y);
  99. gunichar GSEAL (invisible_char);
  100. gint GSEAL (width_chars);
  101. };
  102. struct _GtkEntryClass
  103. {
  104. GtkWidgetClass parent_class;
  105. /* Hook to customize right-click popup */
  106. void (* populate_popup) (GtkEntry *entry,
  107. GtkMenu *menu);
  108. /* Action signals
  109. */
  110. void (* activate) (GtkEntry *entry);
  111. void (* move_cursor) (GtkEntry *entry,
  112. GtkMovementStep step,
  113. gint count,
  114. gboolean extend_selection);
  115. void (* insert_at_cursor) (GtkEntry *entry,
  116. const gchar *str);
  117. void (* delete_from_cursor) (GtkEntry *entry,
  118. GtkDeleteType type,
  119. gint count);
  120. void (* backspace) (GtkEntry *entry);
  121. void (* cut_clipboard) (GtkEntry *entry);
  122. void (* copy_clipboard) (GtkEntry *entry);
  123. void (* paste_clipboard) (GtkEntry *entry);
  124. void (* toggle_overwrite) (GtkEntry *entry);
  125. /* hook to add other objects beside the entry (like in GtkSpinButton) */
  126. void (* get_text_area_size) (GtkEntry *entry,
  127. gint *x,
  128. gint *y,
  129. gint *width,
  130. gint *height);
  131. /* Padding for future expansion */
  132. void (*_gtk_reserved1) (void);
  133. void (*_gtk_reserved2) (void);
  134. };
  135. GType gtk_entry_get_type (void) G_GNUC_CONST;
  136. GtkWidget* gtk_entry_new (void);
  137. GtkWidget* gtk_entry_new_with_buffer (GtkEntryBuffer *buffer);
  138. GtkEntryBuffer* gtk_entry_get_buffer (GtkEntry *entry);
  139. void gtk_entry_set_buffer (GtkEntry *entry,
  140. GtkEntryBuffer *buffer);
  141. GdkWindow *gtk_entry_get_text_window (GtkEntry *entry);
  142. void gtk_entry_set_visibility (GtkEntry *entry,
  143. gboolean visible);
  144. gboolean gtk_entry_get_visibility (GtkEntry *entry);
  145. void gtk_entry_set_invisible_char (GtkEntry *entry,
  146. gunichar ch);
  147. gunichar gtk_entry_get_invisible_char (GtkEntry *entry);
  148. void gtk_entry_unset_invisible_char (GtkEntry *entry);
  149. void gtk_entry_set_has_frame (GtkEntry *entry,
  150. gboolean setting);
  151. gboolean gtk_entry_get_has_frame (GtkEntry *entry);
  152. void gtk_entry_set_inner_border (GtkEntry *entry,
  153. const GtkBorder *border);
  154. G_CONST_RETURN GtkBorder* gtk_entry_get_inner_border (GtkEntry *entry);
  155. void gtk_entry_set_overwrite_mode (GtkEntry *entry,
  156. gboolean overwrite);
  157. gboolean gtk_entry_get_overwrite_mode (GtkEntry *entry);
  158. /* text is truncated if needed */
  159. void gtk_entry_set_max_length (GtkEntry *entry,
  160. gint max);
  161. gint gtk_entry_get_max_length (GtkEntry *entry);
  162. guint16 gtk_entry_get_text_length (GtkEntry *entry);
  163. void gtk_entry_set_activates_default (GtkEntry *entry,
  164. gboolean setting);
  165. gboolean gtk_entry_get_activates_default (GtkEntry *entry);
  166. void gtk_entry_set_width_chars (GtkEntry *entry,
  167. gint n_chars);
  168. gint gtk_entry_get_width_chars (GtkEntry *entry);
  169. /* Somewhat more convenient than the GtkEditable generic functions
  170. */
  171. void gtk_entry_set_text (GtkEntry *entry,
  172. const gchar *text);
  173. /* returns a reference to the text */
  174. G_CONST_RETURN gchar* gtk_entry_get_text (GtkEntry *entry);
  175. PangoLayout* gtk_entry_get_layout (GtkEntry *entry);
  176. void gtk_entry_get_layout_offsets (GtkEntry *entry,
  177. gint *x,
  178. gint *y);
  179. void gtk_entry_set_alignment (GtkEntry *entry,
  180. gfloat xalign);
  181. gfloat gtk_entry_get_alignment (GtkEntry *entry);
  182. void gtk_entry_set_completion (GtkEntry *entry,
  183. GtkEntryCompletion *completion);
  184. GtkEntryCompletion *gtk_entry_get_completion (GtkEntry *entry);
  185. gint gtk_entry_layout_index_to_text_index (GtkEntry *entry,
  186. gint layout_index);
  187. gint gtk_entry_text_index_to_layout_index (GtkEntry *entry,
  188. gint text_index);
  189. /* For scrolling cursor appropriately
  190. */
  191. void gtk_entry_set_cursor_hadjustment (GtkEntry *entry,
  192. GtkAdjustment *adjustment);
  193. GtkAdjustment* gtk_entry_get_cursor_hadjustment (GtkEntry *entry);
  194. /* Progress API
  195. */
  196. void gtk_entry_set_progress_fraction (GtkEntry *entry,
  197. gdouble fraction);
  198. gdouble gtk_entry_get_progress_fraction (GtkEntry *entry);
  199. void gtk_entry_set_progress_pulse_step (GtkEntry *entry,
  200. gdouble fraction);
  201. gdouble gtk_entry_get_progress_pulse_step (GtkEntry *entry);
  202. void gtk_entry_progress_pulse (GtkEntry *entry);
  203. /* Setting and managing icons
  204. */
  205. void gtk_entry_set_icon_from_pixbuf (GtkEntry *entry,
  206. GtkEntryIconPosition icon_pos,
  207. GdkPixbuf *pixbuf);
  208. void gtk_entry_set_icon_from_stock (GtkEntry *entry,
  209. GtkEntryIconPosition icon_pos,
  210. const gchar *stock_id);
  211. void gtk_entry_set_icon_from_icon_name (GtkEntry *entry,
  212. GtkEntryIconPosition icon_pos,
  213. const gchar *icon_name);
  214. void gtk_entry_set_icon_from_gicon (GtkEntry *entry,
  215. GtkEntryIconPosition icon_pos,
  216. GIcon *icon);
  217. GtkImageType gtk_entry_get_icon_storage_type (GtkEntry *entry,
  218. GtkEntryIconPosition icon_pos);
  219. GdkPixbuf* gtk_entry_get_icon_pixbuf (GtkEntry *entry,
  220. GtkEntryIconPosition icon_pos);
  221. const gchar* gtk_entry_get_icon_stock (GtkEntry *entry,
  222. GtkEntryIconPosition icon_pos);
  223. const gchar* gtk_entry_get_icon_name (GtkEntry *entry,
  224. GtkEntryIconPosition icon_pos);
  225. GIcon* gtk_entry_get_icon_gicon (GtkEntry *entry,
  226. GtkEntryIconPosition icon_pos);
  227. void gtk_entry_set_icon_activatable (GtkEntry *entry,
  228. GtkEntryIconPosition icon_pos,
  229. gboolean activatable);
  230. gboolean gtk_entry_get_icon_activatable (GtkEntry *entry,
  231. GtkEntryIconPosition icon_pos);
  232. void gtk_entry_set_icon_sensitive (GtkEntry *entry,
  233. GtkEntryIconPosition icon_pos,
  234. gboolean sensitive);
  235. gboolean gtk_entry_get_icon_sensitive (GtkEntry *entry,
  236. GtkEntryIconPosition icon_pos);
  237. gint gtk_entry_get_icon_at_pos (GtkEntry *entry,
  238. gint x,
  239. gint y);
  240. void gtk_entry_set_icon_tooltip_text (GtkEntry *entry,
  241. GtkEntryIconPosition icon_pos,
  242. const gchar *tooltip);
  243. gchar * gtk_entry_get_icon_tooltip_text (GtkEntry *entry,
  244. GtkEntryIconPosition icon_pos);
  245. void gtk_entry_set_icon_tooltip_markup (GtkEntry *entry,
  246. GtkEntryIconPosition icon_pos,
  247. const gchar *tooltip);
  248. gchar * gtk_entry_get_icon_tooltip_markup (GtkEntry *entry,
  249. GtkEntryIconPosition icon_pos);
  250. void gtk_entry_set_icon_drag_source (GtkEntry *entry,
  251. GtkEntryIconPosition icon_pos,
  252. GtkTargetList *target_list,
  253. GdkDragAction actions);
  254. gint gtk_entry_get_current_icon_drag_source (GtkEntry *entry);
  255. GdkWindow * gtk_entry_get_icon_window (GtkEntry *entry,
  256. GtkEntryIconPosition icon_pos);
  257. gboolean gtk_entry_im_context_filter_keypress (GtkEntry *entry,
  258. GdkEventKey *event);
  259. void gtk_entry_reset_im_context (GtkEntry *entry);
  260. /* Deprecated compatibility functions
  261. */
  262. #ifndef GTK_DISABLE_DEPRECATED
  263. GtkWidget* gtk_entry_new_with_max_length (gint max);
  264. void gtk_entry_append_text (GtkEntry *entry,
  265. const gchar *text);
  266. void gtk_entry_prepend_text (GtkEntry *entry,
  267. const gchar *text);
  268. void gtk_entry_set_position (GtkEntry *entry,
  269. gint position);
  270. void gtk_entry_select_region (GtkEntry *entry,
  271. gint start,
  272. gint end);
  273. void gtk_entry_set_editable (GtkEntry *entry,
  274. gboolean editable);
  275. #endif /* GTK_DISABLE_DEPRECATED */
  276. G_END_DECLS
  277. #endif /* __GTK_ENTRY_H__ */