1/* gtktextattributes.h - text attributes
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_ATTRIBUTES_H__
51#define __GTK_TEXT_ATTRIBUTES_H__
52
53
54#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
55#error "Only <gtk/gtk.h> can be included directly."
56#endif
57
58#include <gdk/gdk.h>
59#include <gtk/gtkenums.h>
60
61
62G_BEGIN_DECLS
63
64typedef struct _GtkTextAttributes GtkTextAttributes;
65
66#define GTK_TYPE_TEXT_ATTRIBUTES (gtk_text_attributes_get_type ())
67
68typedef struct _GtkTextAppearance GtkTextAppearance;
69
70/**
71 * GtkTextAppearance:
72 * @bg_color: Background #GdkColor.
73 * @fg_color: Foreground #GdkColor.
74 * @rise: Super/subscript rise, can be negative.
75 * @underline: #PangoUnderline
76 * @strikethrough: Strikethrough style
77 * @draw_bg: Whether to use background-related values; this is
78 * irrelevant for the values struct when in a tag, but is used for
79 * the composite values struct; it’s true if any of the tags being
80 * composited had background stuff set.
81 * @inside_selection: This are only used when we are actually laying
82 * out and rendering a paragraph; not when a #GtkTextAppearance is
83 * part of a #GtkTextAttributes.
84 * @is_text: This are only used when we are actually laying
85 * out and rendering a paragraph; not when a #GtkTextAppearance is
86 * part of a #GtkTextAttributes.
87 * @rgba: #GdkRGBA
88 */
89struct _GtkTextAppearance
90{
91 /*< public >*/
92 GdkColor bg_color; /* pixel is taken for underline color */
93 GdkColor fg_color; /* pixel is taken for strikethrough color */
94
95 /* super/subscript rise, can be negative */
96 gint rise;
97
98 guint underline : 4; /* PangoUnderline */
99 guint strikethrough : 1;
100
101 /* Whether to use background-related values; this is irrelevant for
102 * the values struct when in a tag, but is used for the composite
103 * values struct; it's true if any of the tags being composited
104 * had background stuff set.
105 */
106 guint draw_bg : 1;
107
108 /* These are only used when we are actually laying out and rendering
109 * a paragraph; not when a GtkTextAppearance is part of a
110 * GtkTextAttributes.
111 */
112 guint inside_selection : 1;
113 guint is_text : 1;
114
115 /* For the sad story of this bit of code, see
116 * https://bugzilla.gnome.org/show_bug.cgi?id=711158
117 */
118#ifdef __GI_SCANNER__
119 /* The scanner should only see the transparent union, so that its
120 * content does not vary across architectures.
121 */
122 union {
123 GdkRGBA *rgba[2];
124 /*< private >*/
125 guint padding[4];
126 };
127#else
128 GdkRGBA *rgba[2];
129#if (defined(__SIZEOF_INT__) && defined(__SIZEOF_POINTER__)) && (__SIZEOF_INT__ == __SIZEOF_POINTER__)
130 /* unusable, just for ABI compat */
131 /*< private >*/
132 guint padding[2];
133#endif
134#endif
135};
136
137/**
138 * GtkTextAttributes:
139 * @appearance: #GtkTextAppearance for text.
140 * @justification: #GtkJustification for text.
141 * @direction: #GtkTextDirection for text.
142 * @font: #PangoFontDescription for text.
143 * @font_scale: Font scale factor.
144 * @left_margin: Width of the left margin in pixels.
145 * @right_margin: Width of the right margin in pixels.
146 * @indent: Amount to indent the paragraph, in pixels.
147 * @pixels_above_lines: Pixels of blank space above paragraphs.
148 * @pixels_below_lines: Pixels of blank space below paragraphs.
149 * @pixels_inside_wrap: Pixels of blank space between wrapped lines in
150 * a paragraph.
151 * @tabs: Custom #PangoTabArray for this text.
152 * @wrap_mode: #GtkWrapMode for text.
153 * @language: #PangoLanguage for text.
154 * @invisible: Hide the text.
155 * @bg_full_height: Background is fit to full line height rather than
156 * baseline +/- ascent/descent (font height).
157 * @editable: Can edit this text.
158 * @no_fallback: Whether to disable font fallback.
159 * @letter_spacing: Extra space to insert between graphemes, in Pango units
160 *
161 * Using #GtkTextAttributes directly should rarely be necessary.
162 * It’s primarily useful with gtk_text_iter_get_attributes().
163 * As with most GTK+ structs, the fields in this struct should only
164 * be read, never modified directly.
165 */
166struct _GtkTextAttributes
167{
168 /*< private >*/
169 guint refcount;
170
171 /*< public >*/
172 GtkTextAppearance appearance;
173
174 GtkJustification justification;
175 GtkTextDirection direction;
176
177 PangoFontDescription *font;
178
179 gdouble font_scale;
180
181 gint left_margin;
182 gint right_margin;
183 gint indent;
184
185 gint pixels_above_lines;
186 gint pixels_below_lines;
187 gint pixels_inside_wrap;
188
189 PangoTabArray *tabs;
190
191 GtkWrapMode wrap_mode;
192
193 PangoLanguage *language;
194
195 /*< private >*/
196 GdkColor *pg_bg_color;
197
198 /*< public >*/
199 guint invisible : 1;
200 guint bg_full_height : 1;
201 guint editable : 1;
202 guint no_fallback: 1;
203
204 /*< private >*/
205 GdkRGBA *pg_bg_rgba;
206
207 /*< public >*/
208 gint letter_spacing;
209
210#ifdef __GI_SCANNER__
211 /* The scanner should only see the transparent union, so that its
212 * content does not vary across architectures.
213 */
214 union {
215 gchar *font_features;
216 /*< private >*/
217 guint padding[2];
218 };
219#else
220 gchar *font_features;
221#if (defined(__SIZEOF_INT__) && defined(__SIZEOF_POINTER__)) && (__SIZEOF_INT__ == __SIZEOF_POINTER__)
222 /* unusable, just for ABI compat */
223 /*< private >*/
224 guint padding[1];
225#endif
226#endif
227};
228
229GDK_AVAILABLE_IN_ALL
230GtkTextAttributes* gtk_text_attributes_new (void);
231GDK_AVAILABLE_IN_ALL
232GtkTextAttributes* gtk_text_attributes_copy (GtkTextAttributes *src);
233GDK_AVAILABLE_IN_ALL
234void gtk_text_attributes_copy_values (GtkTextAttributes *src,
235 GtkTextAttributes *dest);
236GDK_AVAILABLE_IN_ALL
237void gtk_text_attributes_unref (GtkTextAttributes *values);
238GDK_AVAILABLE_IN_ALL
239GtkTextAttributes *gtk_text_attributes_ref (GtkTextAttributes *values);
240
241GDK_AVAILABLE_IN_ALL
242GType gtk_text_attributes_get_type (void) G_GNUC_CONST;
243
244
245G_END_DECLS
246
247#endif
248
249

source code of include/gtk-3.0/gtk/gtktextattributes.h