]> Pileus Git - ~andy/gtk/blob - gtk/gtktexttag.h
gtktexttag: Move public members to private header
[~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 #if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
51 #error "Only <gtk/gtk.h> can be included directly."
52 #endif
53
54 #ifndef __GTK_TEXT_TAG_H__
55 #define __GTK_TEXT_TAG_H__
56
57
58 #include <gdk/gdk.h>
59 #include <gtk/gtkenums.h>
60
61
62 G_BEGIN_DECLS
63
64 typedef struct _GtkTextIter GtkTextIter;
65 typedef struct _GtkTextTagTable GtkTextTagTable;
66
67 typedef struct _GtkTextAttributes GtkTextAttributes;
68
69 #define GTK_TYPE_TEXT_TAG            (gtk_text_tag_get_type ())
70 #define GTK_TEXT_TAG(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_TEXT_TAG, GtkTextTag))
71 #define GTK_TEXT_TAG_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_TEXT_TAG, GtkTextTagClass))
72 #define GTK_IS_TEXT_TAG(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_TEXT_TAG))
73 #define GTK_IS_TEXT_TAG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_TEXT_TAG))
74 #define GTK_TEXT_TAG_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_TEXT_TAG, GtkTextTagClass))
75
76 #define GTK_TYPE_TEXT_ATTRIBUTES     (gtk_text_attributes_get_type ())
77
78 typedef struct _GtkTextTag             GtkTextTag;
79 typedef struct _GtkTextTagPrivate      GtkTextTagPrivate;
80 typedef struct _GtkTextTagClass        GtkTextTagClass;
81
82 struct _GtkTextTag
83 {
84   GObject parent_instance;
85
86   GtkTextTagPrivate *priv;
87 };
88
89 struct _GtkTextTagClass
90 {
91   GObjectClass parent_class;
92
93   gboolean (* event) (GtkTextTag        *tag,
94                       GObject           *event_object, /* widget, canvas item, whatever */
95                       GdkEvent          *event,        /* the event itself */
96                       const GtkTextIter *iter);        /* location of event in buffer */
97
98   /* Padding for future expansion */
99   void (*_gtk_reserved1) (void);
100   void (*_gtk_reserved2) (void);
101   void (*_gtk_reserved3) (void);
102   void (*_gtk_reserved4) (void);
103 };
104
105 GType        gtk_text_tag_get_type     (void) G_GNUC_CONST;
106 GtkTextTag  *gtk_text_tag_new          (const gchar       *name);
107 gint         gtk_text_tag_get_priority (GtkTextTag        *tag);
108 void         gtk_text_tag_set_priority (GtkTextTag        *tag,
109                                         gint               priority);
110 gboolean     gtk_text_tag_event        (GtkTextTag        *tag,
111                                         GObject           *event_object,
112                                         GdkEvent          *event,
113                                         const GtkTextIter *iter);
114
115 /*
116  * Style object created by folding a set of tags together
117  */
118
119 typedef struct _GtkTextAppearance GtkTextAppearance;
120
121 struct _GtkTextAppearance
122 {
123   /*< public >*/
124   GdkColor bg_color;
125   GdkColor fg_color;
126
127   /* super/subscript rise, can be negative */
128   gint rise;
129
130   /*< private >*/
131   /* I'm not sure this can really be used without breaking some things
132    * an app might do :-/
133    */
134   gpointer padding1;
135
136   /*< public >*/
137   guint underline : 4;          /* PangoUnderline */
138   guint strikethrough : 1;
139
140   /* Whether to use background-related values; this is irrelevant for
141    * the values struct when in a tag, but is used for the composite
142    * values struct; it's true if any of the tags being composited
143    * had background stuff set.
144    */
145   guint draw_bg : 1;
146   
147   /* These are only used when we are actually laying out and rendering
148    * a paragraph; not when a GtkTextAppearance is part of a
149    * GtkTextAttributes.
150    */
151   guint inside_selection : 1;
152   guint is_text : 1;
153
154   /*< private >*/
155   guint pad1 : 1;
156   guint pad2 : 1;
157   guint pad3 : 1;
158   guint pad4 : 1;
159 };
160
161 struct _GtkTextAttributes
162 {
163   /*< private >*/
164   guint refcount;
165
166   /*< public >*/
167   GtkTextAppearance appearance;
168
169   GtkJustification justification;
170   GtkTextDirection direction;
171
172   /* Individual chunks of this can be set/unset as a group */
173   PangoFontDescription *font;
174
175   gdouble font_scale;
176   
177   gint left_margin;
178
179   gint indent;  
180
181   gint right_margin;
182
183   gint pixels_above_lines;
184
185   gint pixels_below_lines;
186
187   gint pixels_inside_wrap;
188
189   PangoTabArray *tabs;
190
191   GtkWrapMode wrap_mode;        /* How to handle wrap-around for this tag.
192                                  * Must be GTK_WRAPMODE_CHAR,
193                                  * GTK_WRAPMODE_NONE, GTK_WRAPMODE_WORD
194                                  */
195
196   PangoLanguage *language;
197
198   /*< private >*/
199   GdkColor *pg_bg_color;
200
201   /*< public >*/
202   /* hide the text  */
203   guint invisible : 1;
204
205   /* Background is fit to full line height rather than
206    * baseline +/- ascent/descent (font height)
207    */
208   guint bg_full_height : 1;
209
210   /* can edit this text */
211   guint editable : 1;
212
213   /*< private >*/
214   guint pad1 : 1;
215   guint pad2 : 1;
216   guint pad3 : 1;
217   guint pad4 : 1;
218 };
219
220 GtkTextAttributes* gtk_text_attributes_new         (void);
221 GtkTextAttributes* gtk_text_attributes_copy        (GtkTextAttributes *src);
222 void               gtk_text_attributes_copy_values (GtkTextAttributes *src,
223                                                     GtkTextAttributes *dest);
224 void               gtk_text_attributes_unref       (GtkTextAttributes *values);
225 GtkTextAttributes *gtk_text_attributes_ref         (GtkTextAttributes *values);
226
227 GType              gtk_text_attributes_get_type    (void) G_GNUC_CONST;
228
229
230 G_END_DECLS
231
232 #endif
233