]> Pileus Git - ~andy/gtk/blob - gtk/gtkeditable.h
s/refcount/ref_count/.
[~andy/gtk] / gtk / gtkeditable.h
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 Library 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  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library 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 /*
21  * Modified by the GTK+ Team and others 1997-1999.  See the AUTHORS
22  * file for a list of people on the GTK+ Team.  See the ChangeLog
23  * files for a list of changes.  These files are distributed with
24  * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
25  */
26
27 #ifndef __GTK_EDITABLE_H__
28 #define __GTK_EDITABLE_H__
29
30
31 #include <gdk/gdk.h>
32 #include <gtk/gtkwidget.h>
33
34
35 #ifdef __cplusplus
36 extern "C" {
37 #endif /* __cplusplus */
38
39
40 #define GTK_TYPE_EDITABLE            (gtk_editable_get_type ())
41 #define GTK_EDITABLE(obj)            (GTK_CHECK_CAST ((obj), GTK_TYPE_EDITABLE, GtkEditable))
42 #define GTK_EDITABLE_CLASS(klass)    (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_EDITABLE, GtkEditableClass))
43 #define GTK_IS_EDITABLE(obj)         (GTK_CHECK_TYPE ((obj), GTK_TYPE_EDITABLE))
44 #define GTK_IS_EDITABLE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_EDITABLE))
45 #define GTK_EDITABLE_GET_CLASS(obj)  (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_EDITABLE, GtkEditableClass))
46
47
48 typedef struct _GtkEditable       GtkEditable;
49 typedef struct _GtkEditableClass  GtkEditableClass;
50
51 typedef void (*GtkTextFunction) (GtkEditable  *editable, guint32 time);
52
53 struct _GtkEditable
54 {
55   GtkWidget widget;
56
57   /*< public >*/
58   guint      current_pos;
59
60   guint      selection_start_pos;
61   guint      selection_end_pos;
62   guint      has_selection : 1;
63
64   /*< private >*/
65   guint      editable : 1;
66   guint      visible : 1;
67   GdkIC     *ic;
68   GdkICAttr *ic_attr;
69   
70   gchar *clipboard_text;
71 };
72
73 struct _GtkEditableClass
74 {
75   GtkWidgetClass parent_class;
76   
77   /* Signals for notification/filtering of changes */
78   void (* changed)      (GtkEditable    *editable);
79   void (* insert_text)  (GtkEditable    *editable,
80                          const gchar    *text,
81                          gint            length,
82                          gint           *position);
83   void (* delete_text)  (GtkEditable    *editable,
84                          gint            start_pos,
85                          gint            end_pos);
86
87   /* Bindings actions */
88   void (* activate)        (GtkEditable *editable);
89   void (* set_editable)    (GtkEditable *editable,
90                             gboolean     is_editable);
91   void (* move_cursor)     (GtkEditable *editable,
92                             gint         x,
93                             gint         y);
94   void (* move_word)       (GtkEditable *editable,
95                             gint         n);
96   void (* move_page)       (GtkEditable *editable,
97                             gint         x,
98                             gint         y);
99   void (* move_to_row)     (GtkEditable *editable,
100                             gint         row);
101   void (* move_to_column)  (GtkEditable *editable,
102                             gint         row);
103   void (* kill_char)       (GtkEditable *editable,
104                             gint         direction);
105   void (* kill_word)       (GtkEditable *editable,
106                             gint         direction);
107   void (* kill_line)       (GtkEditable *editable,
108                             gint         direction);
109   void (* cut_clipboard)   (GtkEditable *editable);
110   void (* copy_clipboard)  (GtkEditable *editable);
111   void (* paste_clipboard) (GtkEditable *editable);
112
113   /* Virtual functions. get_chars is in paricular not a signal because
114    * it returns malloced memory. The others are not signals because
115    * they would not be particularly useful as such. (All changes to
116    * selection and position do not go through these functions)
117    */
118   void (* update_text)  (GtkEditable    *editable,
119                          gint            start_pos,
120                          gint            end_pos);
121   gchar* (* get_chars)  (GtkEditable    *editable,
122                          gint            start_pos,
123                          gint            end_pos);
124   void (* set_selection)(GtkEditable    *editable,
125                          gint            start_pos,
126                          gint            end_pos);
127   void (* set_position) (GtkEditable    *editable,
128                          gint            position);
129 };
130
131 GtkType    gtk_editable_get_type       (void);
132 void       gtk_editable_select_region  (GtkEditable      *editable,
133                                         gint              start,
134                                         gint              end);
135 void       gtk_editable_insert_text   (GtkEditable       *editable,
136                                         const gchar      *new_text,
137                                         gint              new_text_length,
138                                         gint             *position);
139 void       gtk_editable_delete_text    (GtkEditable      *editable,
140                                         gint              start_pos,
141                                         gint              end_pos);
142 gchar*     gtk_editable_get_chars      (GtkEditable      *editable,
143                                         gint              start_pos,
144                                         gint              end_pos);
145 void       gtk_editable_cut_clipboard  (GtkEditable      *editable);
146 void       gtk_editable_copy_clipboard (GtkEditable      *editable);
147 void       gtk_editable_paste_clipboard (GtkEditable     *editable);
148 void       gtk_editable_claim_selection (GtkEditable     *editable, 
149                                          gboolean         claim, 
150                                          guint32          time);
151 void       gtk_editable_delete_selection (GtkEditable    *editable);
152
153 void       gtk_editable_changed         (GtkEditable    *editable);
154 void       gtk_editable_set_position    (GtkEditable    *editable,
155                                          gint            position);
156 gint       gtk_editable_get_position    (GtkEditable    *editable);
157 void       gtk_editable_set_editable    (GtkEditable    *editable,
158                                          gboolean        is_editable);
159
160
161 #ifdef __cplusplus
162 }
163 #endif /* __cplusplus */
164
165
166 #endif /* __GTK_EDITABLE_H__ */