1/* GTK - The GIMP Toolkit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
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, see <http://www.gnu.org/licenses/>.
16 */
17
18/*
19 * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
20 * file for a list of people on the GTK+ Team. See the ChangeLog
21 * files for a list of changes. These files are distributed with
22 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
23 */
24
25#ifndef __GTK_EDITABLE_H__
26#define __GTK_EDITABLE_H__
27
28
29#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
30#error "Only <gtk/gtk.h> can be included directly."
31#endif
32
33#include <gtk/gtkwidget.h>
34
35
36G_BEGIN_DECLS
37
38#define GTK_TYPE_EDITABLE (gtk_editable_get_type ())
39#define GTK_EDITABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_EDITABLE, GtkEditable))
40#define GTK_IS_EDITABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_EDITABLE))
41#define GTK_EDITABLE_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GTK_TYPE_EDITABLE, GtkEditableInterface))
42
43typedef struct _GtkEditable GtkEditable; /* Dummy typedef */
44typedef struct _GtkEditableInterface GtkEditableInterface;
45
46struct _GtkEditableInterface
47{
48 GTypeInterface base_iface;
49
50 /* signals */
51 void (* insert_text) (GtkEditable *editable,
52 const char *text,
53 int length,
54 int *position);
55 void (* delete_text) (GtkEditable *editable,
56 int start_pos,
57 int end_pos);
58 void (* changed) (GtkEditable *editable);
59
60 /* vtable */
61 const char * (* get_text) (GtkEditable *editable);
62 void (* do_insert_text) (GtkEditable *editable,
63 const char *text,
64 int length,
65 int *position);
66 void (* do_delete_text) (GtkEditable *editable,
67 int start_pos,
68 int end_pos);
69
70 gboolean (* get_selection_bounds) (GtkEditable *editable,
71 int *start_pos,
72 int *end_pos);
73 void (* set_selection_bounds) (GtkEditable *editable,
74 int start_pos,
75 int end_pos);
76 GtkEditable * (* get_delegate) (GtkEditable *editable);
77};
78
79GDK_AVAILABLE_IN_ALL
80GType gtk_editable_get_type (void) G_GNUC_CONST;
81
82GDK_AVAILABLE_IN_ALL
83const char * gtk_editable_get_text (GtkEditable *editable);
84GDK_AVAILABLE_IN_ALL
85void gtk_editable_set_text (GtkEditable *editable,
86 const char *text);
87GDK_AVAILABLE_IN_ALL
88char * gtk_editable_get_chars (GtkEditable *editable,
89 int start_pos,
90 int end_pos) G_GNUC_MALLOC;
91GDK_AVAILABLE_IN_ALL
92void gtk_editable_insert_text (GtkEditable *editable,
93 const char *text,
94 int length,
95 int *position);
96GDK_AVAILABLE_IN_ALL
97void gtk_editable_delete_text (GtkEditable *editable,
98 int start_pos,
99 int end_pos);
100
101GDK_AVAILABLE_IN_ALL
102gboolean gtk_editable_get_selection_bounds (GtkEditable *editable,
103 int *start_pos,
104 int *end_pos);
105GDK_AVAILABLE_IN_ALL
106void gtk_editable_delete_selection (GtkEditable *editable);
107GDK_AVAILABLE_IN_ALL
108void gtk_editable_select_region (GtkEditable *editable,
109 int start_pos,
110 int end_pos);
111
112GDK_AVAILABLE_IN_ALL
113void gtk_editable_set_position (GtkEditable *editable,
114 int position);
115GDK_AVAILABLE_IN_ALL
116int gtk_editable_get_position (GtkEditable *editable);
117
118GDK_AVAILABLE_IN_ALL
119gboolean gtk_editable_get_editable (GtkEditable *editable);
120GDK_AVAILABLE_IN_ALL
121void gtk_editable_set_editable (GtkEditable *editable,
122 gboolean is_editable);
123
124GDK_AVAILABLE_IN_ALL
125float gtk_editable_get_alignment (GtkEditable *editable);
126GDK_AVAILABLE_IN_ALL
127void gtk_editable_set_alignment (GtkEditable *editable,
128 float xalign);
129
130GDK_AVAILABLE_IN_ALL
131int gtk_editable_get_width_chars (GtkEditable *editable);
132GDK_AVAILABLE_IN_ALL
133void gtk_editable_set_width_chars (GtkEditable *editable,
134 int n_chars);
135
136GDK_AVAILABLE_IN_ALL
137int gtk_editable_get_max_width_chars (GtkEditable *editable);
138GDK_AVAILABLE_IN_ALL
139void gtk_editable_set_max_width_chars (GtkEditable *editable,
140 int n_chars);
141GDK_AVAILABLE_IN_ALL
142gboolean gtk_editable_get_enable_undo (GtkEditable *editable);
143GDK_AVAILABLE_IN_ALL
144void gtk_editable_set_enable_undo (GtkEditable *editable,
145 gboolean enable_undo);
146
147/* api for implementations */
148
149/**
150 * GtkEditableProperties:
151 * @GTK_EDITABLE_PROP_TEXT: the property id for [property@Gtk.Editable:text]
152 * @GTK_EDITABLE_PROP_CURSOR_POSITION: the property id for [property@Gtk.Editable:cursor-position]
153 * @GTK_EDITABLE_PROP_SELECTION_BOUND: the property id for [property@Gtk.Editable:selection-bound]
154 * @GTK_EDITABLE_PROP_EDITABLE: the property id for [property@Gtk.Editable:editable]
155 * @GTK_EDITABLE_PROP_WIDTH_CHARS: the property id for [property@Gtk.Editable:width-chars]
156 * @GTK_EDITABLE_PROP_MAX_WIDTH_CHARS: the property id for [property@Gtk.Editable:max-width-chars]
157 * @GTK_EDITABLE_PROP_XALIGN: the property id for [property@Gtk.Editable:xalign]
158 * @GTK_EDITABLE_PROP_ENABLE_UNDO: the property id for [property@Gtk.Editable:enable-undo]
159 * @GTK_EDITABLE_NUM_PROPERTIES: the number of properties
160 *
161 * The identifiers for [iface@Gtk.Editable] properties.
162 *
163 * See [func@Gtk.Editable.install_properties] for details on how to
164 * implement the `GtkEditable` interface.
165 */
166typedef enum {
167 GTK_EDITABLE_PROP_TEXT,
168 GTK_EDITABLE_PROP_CURSOR_POSITION,
169 GTK_EDITABLE_PROP_SELECTION_BOUND,
170 GTK_EDITABLE_PROP_EDITABLE,
171 GTK_EDITABLE_PROP_WIDTH_CHARS,
172 GTK_EDITABLE_PROP_MAX_WIDTH_CHARS,
173 GTK_EDITABLE_PROP_XALIGN,
174 GTK_EDITABLE_PROP_ENABLE_UNDO,
175 GTK_EDITABLE_NUM_PROPERTIES
176} GtkEditableProperties;
177
178GDK_AVAILABLE_IN_ALL
179guint gtk_editable_install_properties (GObjectClass *object_class,
180 guint first_prop);
181GDK_AVAILABLE_IN_ALL
182GtkEditable *gtk_editable_get_delegate (GtkEditable *editable);
183GDK_AVAILABLE_IN_ALL
184void gtk_editable_init_delegate (GtkEditable *editable);
185GDK_AVAILABLE_IN_ALL
186void gtk_editable_finish_delegate (GtkEditable *editable);
187GDK_AVAILABLE_IN_ALL
188gboolean gtk_editable_delegate_set_property (GObject *object,
189 guint prop_id,
190 const GValue *value,
191 GParamSpec *pspec);
192GDK_AVAILABLE_IN_ALL
193gboolean gtk_editable_delegate_get_property (GObject *object,
194 guint prop_id,
195 GValue *value,
196 GParamSpec *pspec);
197
198
199G_END_DECLS
200
201#endif /* __GTK_EDITABLE_H__ */
202

source code of gtk/gtk/gtkeditable.h