]> Pileus Git - ~andy/gtk/blob - gtk/gtktexttag.h
Translation updated by Ivar Smolin.
[~andy/gtk] / gtk / gtktexttag.h
1 /* gtktexttag.c - text tag object
2  *
3  * Copyright (c) 1992-1994 The Regents of the University of California.
4  * Copyright (c) 1994-1997 Sun Microsystems, Inc.
5  * Copyright (c) 2000      Red Hat, Inc.
6  * Tk -> Gtk port by Havoc Pennington <hp@redhat.com>
7  *
8  * This software is copyrighted by the Regents of the University of
9  * California, Sun Microsystems, Inc., and other parties.  The
10  * following terms apply to all files associated with the software
11  * unless explicitly disclaimed in individual files.
12  *
13  * The authors hereby grant permission to use, copy, modify,
14  * distribute, and license this software and its documentation for any
15  * purpose, provided that existing copyright notices are retained in
16  * all copies and that this notice is included verbatim in any
17  * distributions. No written agreement, license, or royalty fee is
18  * required for any of the authorized uses.  Modifications to this
19  * software may be copyrighted by their authors and need not follow
20  * the licensing terms described here, provided that the new terms are
21  * clearly indicated on the first page of each file where they apply.
22  *
23  * IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY
24  * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
25  * DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION,
26  * OR ANY DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED
27  * OF THE POSSIBILITY OF SUCH DAMAGE.
28  *
29  * THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
30  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
31  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
32  * NON-INFRINGEMENT.  THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS,
33  * AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE
34  * MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
35  *
36  * GOVERNMENT USE: If you are acquiring this software on behalf of the
37  * U.S. government, the Government shall have only "Restricted Rights"
38  * in the software and related documentation as defined in the Federal
39  * Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2).  If you
40  * are acquiring the software on behalf of the Department of Defense,
41  * the software shall be classified as "Commercial Computer Software"
42  * and the Government shall have only "Restricted Rights" as defined
43  * in Clause 252.227-7013 (c) (1) of DFARs.  Notwithstanding the
44  * foregoing, the authors grant the U.S. Government and others acting
45  * in its behalf permission to use and distribute the software in
46  * accordance with the terms specified in this license.
47  *
48  */
49
50 #ifndef __GTK_TEXT_TAG_H__
51 #define __GTK_TEXT_TAG_H__
52
53 #include <glib-object.h>
54 #include <gdk/gdk.h>
55 #include <gtk/gtkenums.h>
56
57 /* Not needed, retained for compatibility -Yosh */
58 #include <gtk/gtkobject.h>
59
60 G_BEGIN_DECLS
61
62 typedef struct _GtkTextIter GtkTextIter;
63 typedef struct _GtkTextTagTable GtkTextTagTable;
64
65 typedef struct _GtkTextAttributes GtkTextAttributes;
66
67 #define GTK_TYPE_TEXT_TAG            (gtk_text_tag_get_type ())
68 #define GTK_TEXT_TAG(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_TEXT_TAG, GtkTextTag))
69 #define GTK_TEXT_TAG_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_TEXT_TAG, GtkTextTagClass))
70 #define GTK_IS_TEXT_TAG(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_TEXT_TAG))
71 #define GTK_IS_TEXT_TAG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_TEXT_TAG))
72 #define GTK_TEXT_TAG_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_TEXT_TAG, GtkTextTagClass))
73
74 #define GTK_TYPE_TEXT_ATTRIBUTES     (gtk_text_attributes_get_type ())
75
76 typedef struct _GtkTextTag GtkTextTag;
77 typedef struct _GtkTextTagClass GtkTextTagClass;
78
79 struct _GtkTextTag
80 {
81   GObject parent_instance;
82
83   GtkTextTagTable *table;
84
85   char *name;                   /* Name of this tag.  This field is actually
86                                  * a pointer to the key from the entry in
87                                  * tkxt->tagTable, so it needn't be freed
88                                  * explicitly. */
89   int priority;         /* Priority of this tag within widget.  0
90                          * means lowest priority.  Exactly one tag
91                          * has each integer value between 0 and
92                          * numTags-1. */
93   /*
94    * Information for displaying text with this tag.  The information
95    * belows acts as an override on information specified by lower-priority
96    * tags.  If no value is specified, then the next-lower-priority tag
97    * on the text determins the value.  The text widget itself provides
98    * defaults if no tag specifies an override.
99    */
100
101   GtkTextAttributes *values;
102   
103   /* Flags for whether a given value is set; if a value is unset, then
104    * this tag does not affect it.
105    */
106   guint bg_color_set : 1;
107   guint bg_stipple_set : 1;
108   guint fg_color_set : 1;
109   guint scale_set : 1;
110   guint fg_stipple_set : 1;
111   guint justification_set : 1;
112   guint left_margin_set : 1;
113   guint indent_set : 1;
114   guint rise_set : 1;
115   guint strikethrough_set : 1;
116   guint right_margin_set : 1;
117   guint pixels_above_lines_set : 1;
118   guint pixels_below_lines_set : 1;
119   guint pixels_inside_wrap_set : 1;
120   guint tabs_set : 1;
121   guint underline_set : 1;
122   guint wrap_mode_set : 1;
123   guint bg_full_height_set : 1;
124   guint invisible_set : 1;
125   guint editable_set : 1;
126   guint language_set : 1;
127   guint pg_bg_color_set : 1;
128   guint pad1 : 1;
129   guint pad2 : 1;
130 };
131
132 struct _GtkTextTagClass
133 {
134   GObjectClass parent_class;
135
136   gboolean (* event) (GtkTextTag        *tag,
137                       GObject           *event_object, /* widget, canvas item, whatever */
138                       GdkEvent          *event,        /* the event itself */
139                       const GtkTextIter *iter);        /* location of event in buffer */
140
141   /* Padding for future expansion */
142   void (*_gtk_reserved1) (void);
143   void (*_gtk_reserved2) (void);
144   void (*_gtk_reserved3) (void);
145   void (*_gtk_reserved4) (void);
146 };
147
148 GType        gtk_text_tag_get_type     (void) G_GNUC_CONST;
149 GtkTextTag  *gtk_text_tag_new          (const gchar       *name);
150 gint         gtk_text_tag_get_priority (GtkTextTag        *tag);
151 void         gtk_text_tag_set_priority (GtkTextTag        *tag,
152                                         gint               priority);
153 gboolean     gtk_text_tag_event        (GtkTextTag        *tag,
154                                         GObject           *event_object,
155                                         GdkEvent          *event,
156                                         const GtkTextIter *iter);
157
158 /*
159  * Style object created by folding a set of tags together
160  */
161
162 typedef struct _GtkTextAppearance GtkTextAppearance;
163
164 struct _GtkTextAppearance
165 {
166   /*< public >*/
167   GdkColor bg_color;
168   GdkColor fg_color;
169   GdkBitmap *bg_stipple;
170   GdkBitmap *fg_stipple;
171
172   /* super/subscript rise, can be negative */
173   gint rise;
174
175   /*< private >*/
176   /* I'm not sure this can really be used without breaking some things
177    * an app might do :-/
178    */
179   gpointer padding1;
180
181   /*< public >*/
182   guint underline : 4;          /* PangoUnderline */
183   guint strikethrough : 1;
184
185   /* Whether to use background-related values; this is irrelevant for
186    * the values struct when in a tag, but is used for the composite
187    * values struct; it's true if any of the tags being composited
188    * had background stuff set.
189    */
190   guint draw_bg : 1;
191   
192   /* These are only used when we are actually laying out and rendering
193    * a paragraph; not when a GtkTextAppearance is part of a
194    * GtkTextAttributes.
195    */
196   guint inside_selection : 1;
197   guint is_text : 1;
198
199   /*< private >*/
200   guint pad1 : 1;
201   guint pad2 : 1;
202   guint pad3 : 1;
203   guint pad4 : 1;
204 };
205
206 struct _GtkTextAttributes
207 {
208   /*< private >*/
209   guint refcount;
210
211   /*< public >*/
212   GtkTextAppearance appearance;
213
214   GtkJustification justification;
215   GtkTextDirection direction;
216
217   /* Individual chunks of this can be set/unset as a group */
218   PangoFontDescription *font;
219
220   gdouble font_scale;
221   
222   gint left_margin;
223
224   gint indent;  
225
226   gint right_margin;
227
228   gint pixels_above_lines;
229
230   gint pixels_below_lines;
231
232   gint pixels_inside_wrap;
233
234   PangoTabArray *tabs;
235
236   GtkWrapMode wrap_mode;        /* How to handle wrap-around for this tag.
237                                  * Must be GTK_WRAPMODE_CHAR,
238                                  * GTK_WRAPMODE_NONE, GTK_WRAPMODE_WORD
239                                  */
240
241   PangoLanguage *language;
242
243   /*< private >*/
244   GdkColor *pg_bg_color;
245
246   /*< public >*/
247   /* hide the text  */
248   guint invisible : 1;
249
250   /* Background is fit to full line height rather than
251    * baseline +/- ascent/descent (font height)
252    */
253   guint bg_full_height : 1;
254
255   /* can edit this text */
256   guint editable : 1;
257
258   /* colors are allocated etc. */
259   guint realized : 1;
260
261   /*< private >*/
262   guint pad1 : 1;
263   guint pad2 : 1;
264   guint pad3 : 1;
265   guint pad4 : 1;
266 };
267
268 GtkTextAttributes* gtk_text_attributes_new         (void);
269 GtkTextAttributes* gtk_text_attributes_copy        (GtkTextAttributes *src);
270 void               gtk_text_attributes_copy_values (GtkTextAttributes *src,
271                                                     GtkTextAttributes *dest);
272 void               gtk_text_attributes_unref       (GtkTextAttributes *values);
273 void               gtk_text_attributes_ref         (GtkTextAttributes *values);
274
275 GType              gtk_text_attributes_get_type    (void) G_GNUC_CONST;
276
277
278 G_END_DECLS
279
280 #endif
281