]> Pileus Git - ~andy/gtk/blob - gtk/gtktextlayout.h
Remove all references to offscreen flag which was no longer used.
[~andy/gtk] / gtk / gtktextlayout.h
1 #ifndef GTK_TEXT_LAYOUT_H
2 #define GTK_TEXT_LAYOUT_H
3
4 #ifdef __cplusplus
5 extern "C" {
6 #endif /* __cplusplus */
7
8 /* This is a "semi-private" header; it is intended for
9  * use by the text widget, and the text canvas item,
10  * but that's all. We may have to install it so the
11  * canvas item can use it, but users are not supposed
12  * to use it. 
13  */
14
15 #include <gtk/gtktextbuffer.h>
16 #include <gtk/gtktextiter.h>
17 #include <gtk/gtktextbtree.h>
18
19
20 #define GTK_TYPE_TEXT_LAYOUT             (gtk_text_layout_get_type())
21 #define GTK_TEXT_LAYOUT(obj)             (GTK_CHECK_CAST ((obj), GTK_TYPE_TEXT_LAYOUT, GtkTextLayout))
22 #define GTK_TEXT_LAYOUT_CLASS(klass)     (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_TEXT_LAYOUT, GtkTextLayoutClass))
23 #define GTK_IS_TEXT_LAYOUT(obj)          (GTK_CHECK_TYPE ((obj), GTK_TYPE_TEXT_LAYOUT))
24 #define GTK_IS_TEXT_LAYOUT_CLASS(klass)  (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_TEXT_LAYOUT))
25 #define GTK_TEXT_LAYOUT_GET_CLASS(obj)   (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_TEXT_LAYOUT, GtkTextLayoutClass))
26
27 typedef struct _GtkTextLayoutClass GtkTextLayoutClass;
28 typedef struct _GtkTextLineDisplay GtkTextLineDisplay;
29 typedef struct _GtkTextCursorDisplay GtkTextCursorDisplay;
30 typedef struct _GtkTextAttrAppearance GtkTextAttrAppearance;
31
32 struct _GtkTextLayout
33 {
34   GtkObject parent_instance;
35
36   /* width of the display area on-screen,
37    * i.e. pixels we should wrap to fit inside. */
38   gint screen_width;
39
40   /* width/height of the total logical area being layed out */
41   gint width;
42   gint height;
43
44   GtkTextBuffer *buffer;
45
46   /* Default style used if no tags override it */
47   GtkTextStyleValues *default_style;
48
49   /* Pango contexts used for creating layouts */
50   PangoContext *ltr_context;
51   PangoContext *rtl_context;
52
53   /* A cache of one style; this is used to ensure
54    * we don't constantly regenerate the style
55    * over long runs with the same style. */
56   GtkTextStyleValues *one_style_cache;
57
58   /* A cache of one line display. Getting the same line
59    * many times in a row is the most common case.
60    */
61   GtkTextLineDisplay *one_display_cache;
62   
63   /* Whether we are allowed to wrap right now */
64   gint wrap_loop_count;
65 };
66
67 struct _GtkTextLayoutClass
68 {
69   GtkObjectClass parent_class;
70
71   /* Some portion of the layout was invalidated
72    */
73   void (* invalidated) (GtkTextLayout *layout);
74
75   /* A range of the layout changed appearance and possibly height
76    */
77   void (* changed)  (GtkTextLayout *layout,
78                      gint           y,
79                      gint           old_height,
80                      gint           new_height);
81
82   
83   GtkTextLineData *(* wrap) (GtkTextLayout *layout,
84                              GtkTextLine *line,
85                              /* may be NULL */
86                              GtkTextLineData *line_data);
87   
88   void (* get_log_attrs) (GtkTextLayout  *layout,
89                           GtkTextLine    *line,
90                           PangoLogAttr  **attrs,
91                           gint           *n_attrs);
92   void  (* invalidate)      (GtkTextLayout *layout,
93                              const GtkTextIter *start,
94                              const GtkTextIter *end);
95   void  (* free_line_data) (GtkTextLayout   *layout,
96                             GtkTextLine     *line,
97                             GtkTextLineData *line_data);
98 };
99
100 struct _GtkTextAttrAppearance
101 {
102   PangoAttribute attr;
103   GtkTextAppearance appearance;
104 };
105
106 struct _GtkTextCursorDisplay
107 {
108   gint x;
109   gint y;
110   gint height;
111   guint is_strong : 1;
112   guint is_weak : 1;
113 };
114
115 struct _GtkTextLineDisplay
116 {
117   PangoLayout *layout;
118   GSList *cursors;
119
120   GtkTextDirection direction;
121
122   gint width;                   /* Width of layout */
123   gint total_width;             /* width - margins, if no width set on layout, if width set on layout, -1 */
124   gint height;
125   gint x_offset;                /* Amount layout is shifted from left edge */
126   gint left_margin;
127   gint right_margin;
128   gint top_margin;
129   gint bottom_margin;
130
131   gboolean size_only;
132   GtkTextLine *line;
133 };
134
135 extern PangoAttrType gtk_text_attr_appearance_type;
136
137 GtkType        gtk_text_layout_get_type (void);
138 GtkTextLayout *gtk_text_layout_new      (void);
139
140 void gtk_text_layout_set_buffer            (GtkTextLayout      *layout,
141                                             GtkTextBuffer      *buffer);
142 void gtk_text_layout_set_default_style     (GtkTextLayout      *layout,
143                                             GtkTextStyleValues *values);
144 void gtk_text_layout_set_contexts          (GtkTextLayout      *layout,
145                                             PangoContext       *ltr_context,
146                                             PangoContext       *rtl_context);
147 void gtk_text_layout_default_style_changed (GtkTextLayout      *layout);
148 void gtk_text_layout_set_screen_width      (GtkTextLayout      *layout,
149                                             gint                width);
150
151 /* Getting the size or the lines potentially results in a call to
152  * recompute, which is pretty massively expensive. Thus it should
153  * basically only be done in an idle handler.
154  * 
155  * Long-term, we would really like to be able to do these without
156  * a full recompute so they may get cheaper over time.
157  */
158 void    gtk_text_layout_get_size (GtkTextLayout  *layout,
159                                   gint           *width,
160                                   gint           *height);
161
162
163 GSList *gtk_text_layout_get_lines (GtkTextLayout *layout,
164                                    /* [top_y, bottom_y) */
165                                    gint           top_y, 
166                                    gint           bottom_y,
167                                    gint          *first_line_y);
168
169 void gtk_text_layout_wrap_loop_start (GtkTextLayout  *layout);
170 void gtk_text_layout_wrap_loop_end   (GtkTextLayout  *layout);
171
172 GtkTextLineDisplay *gtk_text_layout_get_line_display  (GtkTextLayout      *layout,
173                                                        GtkTextLine        *line,
174                                                        gboolean            size_only);
175 void                gtk_text_layout_free_line_display (GtkTextLayout      *layout,
176                                                        GtkTextLineDisplay *display);
177
178 void gtk_text_layout_get_line_at_y     (GtkTextLayout     *layout,
179                                         GtkTextIter       *target_iter,
180                                         gint               y,
181                                         gint              *line_top);
182 void gtk_text_layout_get_iter_at_pixel (GtkTextLayout     *layout,
183                                         GtkTextIter       *iter,
184                                         gint               x,
185                                         gint               y);
186 void gtk_text_layout_invalidate        (GtkTextLayout     *layout,
187                                         const GtkTextIter *start,
188                                         const GtkTextIter *end);
189 void gtk_text_layout_free_line_data    (GtkTextLayout     *layout,
190                                         GtkTextLine       *line,
191                                         GtkTextLineData   *line_data);
192
193 gboolean gtk_text_layout_is_valid        (GtkTextLayout *layout);
194 void     gtk_text_layout_validate_yrange (GtkTextLayout *layout,
195                                           GtkTextIter   *anchor_line,
196                                           gint           y0,
197                                           gint           y1);
198 void     gtk_text_layout_validate        (GtkTextLayout *layout,
199                                           gint           max_pixels);
200
201       /* This function should return the passed-in line data,
202          OR remove the existing line data from the line, and
203          return a NEW line data after adding it to the line.
204          That is, invariant after calling the callback is that
205          there should be exactly one line data for this view
206          stored on the btree line. */
207 GtkTextLineData *gtk_text_layout_wrap (GtkTextLayout   *layout,
208                                        GtkTextLine     *line,
209                                          /* may be NULL */
210                                        GtkTextLineData *line_data);
211 void     gtk_text_layout_get_log_attrs (GtkTextLayout  *layout,
212                                         GtkTextLine    *line,
213                                         PangoLogAttr  **attrs,
214                                         gint           *n_attrs);
215 void     gtk_text_layout_changed              (GtkTextLayout     *layout,
216                                                gint               y,
217                                                gint               old_height,
218                                                gint               new_height);
219 void     gtk_text_layout_get_iter_location    (GtkTextLayout     *layout,
220                                                const GtkTextIter *iter,
221                                                GdkRectangle      *rect);
222 gint     gtk_text_layout_get_line_y           (GtkTextLayout     *layout,
223                                                const GtkTextIter *iter);
224 void     gtk_text_layout_get_cursor_locations (GtkTextLayout     *layout,
225                                                GtkTextIter       *iter,
226                                                GdkRectangle      *strong_pos,
227                                                GdkRectangle      *weak_pos);
228 gboolean gtk_text_layout_clamp_iter_to_vrange (GtkTextLayout     *layout,
229                                                GtkTextIter       *iter,
230                                                gint               top,
231                                                gint               bottom);
232
233 void gtk_text_layout_move_iter_to_previous_line (GtkTextLayout *layout,
234                                                  GtkTextIter   *iter);
235 void gtk_text_layout_move_iter_to_next_line     (GtkTextLayout *layout,
236                                                  GtkTextIter   *iter);
237 void gtk_text_layout_move_iter_to_x             (GtkTextLayout *layout,
238                                                  GtkTextIter   *iter,
239                                                  gint           x);
240 void gtk_text_layout_move_iter_visually         (GtkTextLayout *layout,
241                                                  GtkTextIter   *iter,
242                                                  gint           count);
243
244
245 void gtk_text_layout_spew (GtkTextLayout *layout);
246
247 #ifdef __cplusplus
248 }
249 #endif /* __cplusplus */
250
251 #endif