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 | #include <gdk/gdk.h> |
55 | #include <gtk/gtkenums.h> |
56 | |
57 | |
58 | G_BEGIN_DECLS |
59 | |
60 | typedef struct _GtkTextAttributes GtkTextAttributes; |
61 | typedef struct _GtkTextAppearance GtkTextAppearance; |
62 | |
63 | struct _GtkTextAppearance |
64 | { |
65 | GdkRGBA *bg_rgba; |
66 | GdkRGBA *fg_rgba; |
67 | GdkRGBA *underline_rgba; |
68 | GdkRGBA *overline_rgba; |
69 | GdkRGBA *strikethrough_rgba; |
70 | |
71 | /* super/subscript rise, can be negative */ |
72 | int rise; |
73 | |
74 | guint underline : 4; /* PangoUnderline */ |
75 | guint overline : 2; /* PangoOverline */ |
76 | guint strikethrough : 1; |
77 | |
78 | /* Whether to use background-related values; this is irrelevant for |
79 | * the values struct when in a tag, but is used for the composite |
80 | * values struct; it's true if any of the tags being composited |
81 | * had background stuff set. |
82 | */ |
83 | guint draw_bg : 1; |
84 | |
85 | /* These are only used when we are actually laying out and rendering |
86 | * a paragraph; not when a GtkTextAppearance is part of a |
87 | * GtkTextAttributes. |
88 | */ |
89 | guint inside_selection : 1; |
90 | guint is_text : 1; |
91 | }; |
92 | |
93 | /** |
94 | * GtkTextAttributes: |
95 | * @appearance: GtkTextAppearance for text. |
96 | * @justification: GtkJustification for text. |
97 | * @direction: GtkTextDirection for text. |
98 | * @font: `PangoFontDescription` for text. |
99 | * @font_scale: Font scale factor. |
100 | * @left_margin: Width of the left margin in pixels. |
101 | * @right_margin: Width of the right margin in pixels. |
102 | * @indent: Amount to indent the paragraph, in pixels. |
103 | * @pixels_above_lines: Pixels of blank space above paragraphs. |
104 | * @pixels_below_lines: Pixels of blank space below paragraphs. |
105 | * @pixels_inside_wrap: Pixels of blank space between wrapped lines in |
106 | * a paragraph. |
107 | * @tabs: Custom `PangoTabArray` for this text. |
108 | * @wrap_mode: `GtkWrapMode` for text. |
109 | * @language: `PangoLanguage` for text. |
110 | * @invisible: Hide the text. |
111 | * @bg_full_height: Background is fit to full line height rather than |
112 | * baseline +/- ascent/descent (font height). |
113 | * @editable: Can edit this text. |
114 | * @no_fallback: Whether to disable font fallback. |
115 | * @letter_spacing: Extra space to insert between graphemes, in Pango units |
116 | * |
117 | * Using GtkTextAttributes directly should rarely be necessary. |
118 | * It’s primarily useful with gtk_text_iter_get_attributes(). |
119 | * As with most GTK structs, the fields in this struct should only |
120 | * be read, never modified directly. |
121 | */ |
122 | struct _GtkTextAttributes |
123 | { |
124 | guint refcount; |
125 | |
126 | GtkJustification justification; |
127 | GtkTextDirection direction; |
128 | GtkWrapMode wrap_mode; |
129 | |
130 | GtkTextAppearance appearance; |
131 | |
132 | PangoFontDescription *font; |
133 | char *font_features; |
134 | |
135 | GdkRGBA *pg_bg_rgba; |
136 | |
137 | PangoTabArray *tabs; |
138 | PangoLanguage *language; |
139 | |
140 | double font_scale; |
141 | |
142 | int left_margin; |
143 | int right_margin; |
144 | int indent; |
145 | |
146 | int pixels_above_lines; |
147 | int pixels_below_lines; |
148 | int pixels_inside_wrap; |
149 | |
150 | float line_height; |
151 | |
152 | int letter_spacing; |
153 | |
154 | guint invisible : 1; |
155 | guint bg_full_height : 1; |
156 | guint editable : 1; |
157 | guint no_fallback: 1; |
158 | guint no_breaks : 1; |
159 | guint show_spaces : 3; /* PangoShowFlags */ |
160 | guint no_hyphens : 1; |
161 | guint line_height_is_absolute : 1; |
162 | guint text_transform : 3; /* PangoTextTransform */ |
163 | guint word : 1; |
164 | guint sentence : 1; |
165 | }; |
166 | |
167 | GtkTextAttributes* gtk_text_attributes_new (void); |
168 | GtkTextAttributes* gtk_text_attributes_copy (GtkTextAttributes *src); |
169 | void gtk_text_attributes_copy_values (GtkTextAttributes *src, |
170 | GtkTextAttributes *dest); |
171 | void gtk_text_attributes_unref (GtkTextAttributes *values); |
172 | GtkTextAttributes *gtk_text_attributes_ref (GtkTextAttributes *values); |
173 | |
174 | G_END_DECLS |
175 | |
176 | #endif |
177 | |