Ardour  9.0-pre0-384-ga76afae0e9
gtktextlayout.h
Go to the documentation of this file.
1 /* GTK - The GIMP Toolkit
2  * gtktextlayout.h
3  *
4  * Copyright (c) 1992-1994 The Regents of the University of California.
5  * Copyright (c) 1994-1997 Sun Microsystems, Inc.
6  * Copyright (c) 2000 Red Hat, Inc.
7  * Tk->Gtk port by Havoc Pennington
8  * Pango support by Owen Taylor
9  *
10  * This file can be used under your choice of two licenses, the LGPL
11  * and the original Tk license.
12  *
13  * LGPL:
14  *
15  * This library is free software; you can redistribute it and/or
16  * modify it under the terms of the GNU Lesser General Public
17  * License as published by the Free Software Foundation; either
18  * version 2 of the License, or (at your option) any later version.
19  *
20  * This library is distributed in the hope that it will be useful,
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23  * Lesser General Public License for more details.
24  *
25  * You should have received a copy of the GNU Lesser General Public
26  * License along with this library; if not, write to the Free
27  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28  *
29  * Original Tk license:
30  *
31  * This software is copyrighted by the Regents of the University of
32  * California, Sun Microsystems, Inc., and other parties. The
33  * following terms apply to all files associated with the software
34  * unless explicitly disclaimed in individual files.
35  *
36  * The authors hereby grant permission to use, copy, modify,
37  * distribute, and license this software and its documentation for any
38  * purpose, provided that existing copyright notices are retained in
39  * all copies and that this notice is included verbatim in any
40  * distributions. No written agreement, license, or royalty fee is
41  * required for any of the authorized uses. Modifications to this
42  * software may be copyrighted by their authors and need not follow
43  * the licensing terms described here, provided that the new terms are
44  * clearly indicated on the first page of each file where they apply.
45  *
46  * IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY
47  * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
48  * DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION,
49  * OR ANY DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED
50  * OF THE POSSIBILITY OF SUCH DAMAGE.
51  *
52  * THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
53  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
54  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
55  * NON-INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS,
56  * AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE
57  * MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
58  *
59  * GOVERNMENT USE: If you are acquiring this software on behalf of the
60  * U.S. government, the Government shall have only "Restricted Rights"
61  * in the software and related documentation as defined in the Federal
62  * Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2). If you
63  * are acquiring the software on behalf of the Department of Defense,
64  * the software shall be classified as "Commercial Computer Software"
65  * and the Government shall have only "Restricted Rights" as defined
66  * in Clause 252.227-7013 (c) (1) of DFARs. Notwithstanding the
67  * foregoing, the authors grant the U.S. Government and others acting
68  * in its behalf permission to use and distribute the software in
69  * accordance with the terms specified in this license.
70  *
71  */
72 /*
73  * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
74  * file for a list of people on the GTK+ Team. See the ChangeLog
75  * files for a list of changes. These files are distributed with
76  * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
77  */
78 
79 #ifndef __GTK_TEXT_LAYOUT_H__
80 #define __GTK_TEXT_LAYOUT_H__
81 
82 /* This is a "semi-private" header; it is intended for
83  * use by the text widget, and the text canvas item,
84  * but that's all. We may have to install it so the
85  * canvas item can use it, but users are not supposed
86  * to use it.
87  */
88 #ifndef GTK_TEXT_USE_INTERNAL_UNSUPPORTED_API
89 #error "You are not supposed to be including this file; the equivalent public API is in gtktextview.h"
90 #endif
91 
92 #include <gtk/gtk.h>
93 
94 G_BEGIN_DECLS
95 
96 /* forward declarations that have to be here to avoid including
97  * gtktextbtree.h
98  */
99 typedef struct _GtkTextLine GtkTextLine;
100 typedef struct _GtkTextLineData GtkTextLineData;
101 
102 #define GTK_TYPE_TEXT_LAYOUT (gtk_text_layout_get_type ())
103 #define GTK_TEXT_LAYOUT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_TEXT_LAYOUT, GtkTextLayout))
104 #define GTK_TEXT_LAYOUT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_TEXT_LAYOUT, GtkTextLayoutClass))
105 #define GTK_IS_TEXT_LAYOUT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_TEXT_LAYOUT))
106 #define GTK_IS_TEXT_LAYOUT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_TEXT_LAYOUT))
107 #define GTK_TEXT_LAYOUT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_TEXT_LAYOUT, GtkTextLayoutClass))
108 
109 typedef struct _GtkTextLayout GtkTextLayout;
114 
116 {
118 
119  /* width of the display area on-screen,
120  * i.e. pixels we should wrap to fit inside. */
122 
123  /* width/height of the total logical area being layed out */
124  gint width;
125  gint height;
126 
127  /* Pixel offsets from the left and from the top to be used when we
128  * draw; these allow us to create left/top margins. We don't need
129  * anything special for bottom/right margins, because those don't
130  * affect drawing.
131  */
132  /* gint left_edge; */
133  /* gint top_edge; */
134 
136 
137  /* Default style used if no tags override it */
139 
140  /* Pango contexts used for creating layouts */
141  PangoContext *ltr_context;
142  PangoContext *rtl_context;
143 
144  /* A cache of one style; this is used to ensure
145  * we don't constantly regenerate the style
146  * over long runs with the same style. */
148 
149  /* A cache of one line display. Getting the same line
150  * many times in a row is the most common case.
151  */
153 
154  /* Whether we are allowed to wrap right now */
156 
157  /* Whether to show the insertion cursor */
158  guint cursor_visible : 1;
159 
160  /* For what GtkTextDirection to draw cursor GTK_TEXT_DIR_NONE -
161  * means draw both cursors.
162  */
163  guint cursor_direction : 2;
164 
165  /* The keyboard direction is used to default the alignment when
166  there are no strong characters.
167  */
169 
170  /* The preedit string and attributes, if any */
171 
173  PangoAttrList *preedit_attrs;
176 
177  guint overwrite_mode : 1;
178 };
179 
181 {
182  GObjectClass parent_class;
183 
184  /* Some portion of the layout was invalidated
185  */
186  void (*invalidated) (GtkTextLayout *layout);
187 
188  /* A range of the layout changed appearance and possibly height
189  */
190  void (*changed) (GtkTextLayout *layout,
191  gint y,
192  gint old_height,
193  gint new_height);
194  GtkTextLineData* (*wrap) (GtkTextLayout *layout,
195  GtkTextLine *line,
196  GtkTextLineData *line_data); /* may be NULL */
197  void (*get_log_attrs) (GtkTextLayout *layout,
198  GtkTextLine *line,
199  PangoLogAttr **attrs,
200  gint *n_attrs);
201  void (*invalidate) (GtkTextLayout *layout,
202  const GtkTextIter *start,
203  const GtkTextIter *end);
204  void (*free_line_data) (GtkTextLayout *layout,
205  GtkTextLine *line,
206  GtkTextLineData *line_data);
207 
208  void (*allocate_child) (GtkTextLayout *layout,
209  GtkWidget *child,
210  gint x,
211  gint y);
212 
214  const GtkTextIter *start,
215  const GtkTextIter *end);
216 
217  /* Padding for future expansion */
218  void (*_gtk_reserved1) (void);
219  void (*_gtk_reserved2) (void);
220  void (*_gtk_reserved3) (void);
221 };
222 
224 {
225  PangoAttribute attr;
227 };
229 {
230  gint x;
231  gint y;
232  gint height;
233  guint is_strong : 1;
234  guint is_weak : 1;
235 };
237 {
238  PangoLayout *layout;
239  GSList *cursors;
240  GSList *shaped_objects; /* Only for backwards compatibility */
241 
243 
244  gint width; /* Width of layout */
245  gint total_width; /* width - margins, if no width set on layout, if width set on layout, -1 */
246  gint height;
247  /* Amount layout is shifted from left edge - this is the left margin
248  * plus any other factors, such as alignment or indentation.
249  */
250  gint x_offset;
255  gint insert_index; /* Byte index of insert cursor within para or -1 */
256 
257  gboolean size_only;
259 
261 
263  guint cursors_invalid : 1;
264  guint has_block_cursor : 1;
266 };
267 
268 extern PangoAttrType gtk_text_attr_appearance_type;
269 
270 GType gtk_text_layout_get_type (void) G_GNUC_CONST;
271 
274  GtkTextBuffer *buffer);
277  GtkTextAttributes *values);
279  PangoContext *ltr_context,
280  PangoContext *rtl_context);
282  GtkTextDirection direction);
284  gboolean overwrite);
286  GtkTextDirection keyboard_dir);
288 
290  gint width);
292  const gchar *preedit_string,
293  PangoAttrList *preedit_attrs,
294  gint cursor_pos);
295 
297  gboolean cursor_visible);
299 
300 /* Getting the size or the lines potentially results in a call to
301  * recompute, which is pretty massively expensive. Thus it should
302  * basically only be done in an idle handler.
303  *
304  * Long-term, we would really like to be able to do these without
305  * a full recompute so they may get cheaper over time.
306  */
308  gint *width,
309  gint *height);
311  /* [top_y, bottom_y) */
312  gint top_y,
313  gint bottom_y,
314  gint *first_line_y);
315 
318 
320  GtkTextLine *line,
321  gboolean size_only);
323  GtkTextLineDisplay *display);
324 
326  GtkTextIter *target_iter,
327  gint y,
328  gint *line_top);
330  GtkTextIter *iter,
331  gint x,
332  gint y);
334  GtkTextIter *iter,
335  gint *trailing,
336  gint x,
337  gint y);
339  const GtkTextIter *start,
340  const GtkTextIter *end);
342  const GtkTextIter *start,
343  const GtkTextIter *end);
345  GtkTextLine *line,
346  GtkTextLineData *line_data);
347 
350  GtkTextIter *anchor_line,
351  gint y0_,
352  gint y1_);
354  gint max_pixels);
355 
356 /* This function should return the passed-in line data,
357  * OR remove the existing line data from the line, and
358  * return a NEW line data after adding it to the line.
359  * That is, invariant after calling the callback is that
360  * there should be exactly one line data for this view
361  * stored on the btree line.
362  */
364  GtkTextLine *line,
365  GtkTextLineData *line_data); /* may be NULL */
367  gint y,
368  gint old_height,
369  gint new_height);
371  gint y,
372  gint old_height,
373  gint new_height);
375  const GtkTextIter *iter,
376  GdkRectangle *rect);
378  const GtkTextIter *iter,
379  gint *y,
380  gint *height);
382  const GtkTextIter *iter,
383  gint *x,
384  gint *width);
386  GtkTextIter *iter,
387  GdkRectangle *strong_pos,
388  GdkRectangle *weak_pos);
390  GdkRectangle *pos);
392  GtkTextIter *iter,
393  gint top,
394  gint bottom);
395 
397  GtkTextIter *iter,
398  gint direction);
400  GtkTextIter *iter);
402  GtkTextIter *iter);
404  GtkTextIter *iter,
405  gint x);
407  GtkTextIter *iter,
408  gint count);
409 
411  const GtkTextIter *iter);
412 
414  GtkTextIter *iter,
415  GtkTextLine *line,
416  gint byte_offset);
417 
418 /* Don't use these. Use gtk_text_view_add_child_at_anchor().
419  * These functions are defined in gtktextchild.c, but here
420  * since they are semi-public and require GtkTextLayout to
421  * be declared.
422  */
424  GtkWidget *child,
425  GtkTextLayout *layout);
427  GtkWidget *child);
428 
430  GtkTextLayout *layout);
431 
433  GtkTextLayout *layout);
434 
436 
437 G_END_DECLS
438 
439 #endif /* __GTK_TEXT_LAYOUT_H__ */
GtkTextDirection
Definition: gtkenums.h:174
typedefG_BEGIN_DECLS struct _GtkTextChildAnchor GtkTextChildAnchor
Definition: gtktextchild.h:45
gboolean gtk_text_layout_clamp_iter_to_vrange(GtkTextLayout *layout, GtkTextIter *iter, gint top, gint bottom)
gboolean gtk_text_layout_is_valid(GtkTextLayout *layout)
gboolean gtk_text_layout_move_iter_to_previous_line(GtkTextLayout *layout, GtkTextIter *iter)
void gtk_text_layout_invalidate(GtkTextLayout *layout, const GtkTextIter *start, const GtkTextIter *end)
GtkTextLayout * gtk_text_layout_new(void)
void gtk_text_layout_cursors_changed(GtkTextLayout *layout, gint y, gint old_height, gint new_height)
gboolean _gtk_text_layout_get_block_cursor(GtkTextLayout *layout, GdkRectangle *pos)
void gtk_text_layout_wrap_loop_start(GtkTextLayout *layout)
void gtk_text_layout_validate_yrange(GtkTextLayout *layout, GtkTextIter *anchor_line, gint y0_, gint y1_)
gboolean gtk_text_layout_move_iter_to_next_line(GtkTextLayout *layout, GtkTextIter *iter)
typedefG_BEGIN_DECLS struct _GtkTextLine GtkTextLine
Definition: gtktextlayout.h:99
void gtk_text_layout_get_line_yrange(GtkTextLayout *layout, const GtkTextIter *iter, gint *y, gint *height)
PangoAttrType gtk_text_attr_appearance_type
void gtk_text_layout_changed(GtkTextLayout *layout, gint y, gint old_height, gint new_height)
void gtk_text_layout_set_preedit_string(GtkTextLayout *layout, const gchar *preedit_string, PangoAttrList *preedit_attrs, gint cursor_pos)
void gtk_text_layout_get_size(GtkTextLayout *layout, gint *width, gint *height)
void gtk_text_layout_invalidate_cursors(GtkTextLayout *layout, const GtkTextIter *start, const GtkTextIter *end)
void gtk_text_child_anchor_register_child(GtkTextChildAnchor *anchor, GtkWidget *child, GtkTextLayout *layout)
void gtk_text_layout_set_overwrite_mode(GtkTextLayout *layout, gboolean overwrite)
void gtk_text_layout_set_contexts(GtkTextLayout *layout, PangoContext *ltr_context, PangoContext *rtl_context)
void gtk_text_layout_set_cursor_visible(GtkTextLayout *layout, gboolean cursor_visible)
GSList * gtk_text_layout_get_lines(GtkTextLayout *layout, gint top_y, gint bottom_y, gint *first_line_y)
void gtk_text_layout_validate(GtkTextLayout *layout, gint max_pixels)
gboolean gtk_text_layout_move_iter_visually(GtkTextLayout *layout, GtkTextIter *iter, gint count)
gboolean gtk_text_layout_get_cursor_visible(GtkTextLayout *layout)
GType gtk_text_layout_get_type(void) G_GNUC_CONST
void gtk_text_layout_get_iter_at_pixel(GtkTextLayout *layout, GtkTextIter *iter, gint x, gint y)
void gtk_text_layout_get_line_at_y(GtkTextLayout *layout, GtkTextIter *target_iter, gint y, gint *line_top)
void _gtk_text_layout_get_line_xrange(GtkTextLayout *layout, const GtkTextIter *iter, gint *x, gint *width)
GtkTextBuffer * gtk_text_layout_get_buffer(GtkTextLayout *layout)
void gtk_text_anchored_child_set_layout(GtkWidget *child, GtkTextLayout *layout)
void gtk_text_layout_free_line_data(GtkTextLayout *layout, GtkTextLine *line, GtkTextLineData *line_data)
void gtk_text_layout_get_cursor_locations(GtkTextLayout *layout, GtkTextIter *iter, GdkRectangle *strong_pos, GdkRectangle *weak_pos)
void gtk_text_layout_get_iter_at_position(GtkTextLayout *layout, GtkTextIter *iter, gint *trailing, gint x, gint y)
void gtk_text_layout_wrap_loop_end(GtkTextLayout *layout)
void gtk_text_layout_get_iter_location(GtkTextLayout *layout, const GtkTextIter *iter, GdkRectangle *rect)
void gtk_text_layout_get_iter_at_line(GtkTextLayout *layout, GtkTextIter *iter, GtkTextLine *line, gint byte_offset)
void gtk_text_layout_move_iter_to_x(GtkTextLayout *layout, GtkTextIter *iter, gint x)
GtkTextLineDisplay * gtk_text_layout_get_line_display(GtkTextLayout *layout, GtkTextLine *line, gboolean size_only)
void gtk_text_layout_set_keyboard_direction(GtkTextLayout *layout, GtkTextDirection keyboard_dir)
gboolean gtk_text_layout_iter_starts_line(GtkTextLayout *layout, const GtkTextIter *iter)
void gtk_text_layout_set_cursor_direction(GtkTextLayout *layout, GtkTextDirection direction)
void gtk_text_layout_set_default_style(GtkTextLayout *layout, GtkTextAttributes *values)
void gtk_text_layout_default_style_changed(GtkTextLayout *layout)
void gtk_text_layout_spew(GtkTextLayout *layout)
void gtk_text_layout_set_buffer(GtkTextLayout *layout, GtkTextBuffer *buffer)
void gtk_text_layout_free_line_display(GtkTextLayout *layout, GtkTextLineDisplay *display)
void gtk_text_child_anchor_unregister_child(GtkTextChildAnchor *anchor, GtkWidget *child)
GtkTextLineData * gtk_text_layout_wrap(GtkTextLayout *layout, GtkTextLine *line, GtkTextLineData *line_data)
gboolean gtk_text_layout_move_iter_to_line_end(GtkTextLayout *layout, GtkTextIter *iter, gint direction)
void gtk_text_child_anchor_queue_resize(GtkTextChildAnchor *anchor, GtkTextLayout *layout)
void gtk_text_layout_set_screen_width(GtkTextLayout *layout, gint width)
typedefG_BEGIN_DECLS struct _GtkTextIter GtkTextIter
Definition: gtktexttag.h:67
PBD::PropertyDescriptor< timepos_t > start
GtkTextAppearance appearance
void(* _gtk_reserved1)(void)
void(* invalidated)(GtkTextLayout *layout)
void(* changed)(GtkTextLayout *layout, gint y, gint old_height, gint new_height)
void(* get_log_attrs)(GtkTextLayout *layout, GtkTextLine *line, PangoLogAttr **attrs, gint *n_attrs)
void(* _gtk_reserved3)(void)
GObjectClass parent_class
void(* invalidate_cursors)(GtkTextLayout *layout, const GtkTextIter *start, const GtkTextIter *end)
void(* _gtk_reserved2)(void)
void(* free_line_data)(GtkTextLayout *layout, GtkTextLine *line, GtkTextLineData *line_data)
void(* allocate_child)(GtkTextLayout *layout, GtkWidget *child, gint x, gint y)
void(* invalidate)(GtkTextLayout *layout, const GtkTextIter *start, const GtkTextIter *end)
gchar * preedit_string
guint cursor_direction
PangoAttrList * preedit_attrs
GtkTextAttributes * one_style_cache
GObject parent_instance
GtkTextBuffer * buffer
GtkTextAttributes * default_style
GtkTextLineDisplay * one_display_cache
PangoContext * ltr_context
guint keyboard_direction
PangoContext * rtl_context
GtkTextLine * line
GdkRectangle block_cursor
GdkColor * pg_bg_color
GtkTextDirection direction
PangoLayout * layout
gint height
Definition: xcursors.h:1
gint width
Definition: xcursors.h:1