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