summaryrefslogtreecommitdiff
path: root/libs/gtkmm2/pango/pangomm/layoutiter.h
blob: ccb24ded81fde47979c61139db68e9bde705a727 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
// -*- c++ -*-
// Generated by gtkmmproc -- DO NOT MODIFY!
#ifndef _PANGOMM_LAYOUTITER_H
#define _PANGOMM_LAYOUTITER_H

#include <glibmm.h>

/* $Id$ */

/* layoutiter.h
 *
 * Copyright 2001-2002 The gtkmm Development Team
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the Free
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include <pangomm/layoutline.h>
#include <pangomm/layoutrun.h>
#include <pango/pango-layout.h>


namespace Pango
{

/** A Pango::LayoutIter can be used to iterate over the visual extents of a Pango::Layout.
 */
class LayoutIter
{
  public:
#ifndef DOXYGEN_SHOULD_SKIP_THIS
  typedef LayoutIter CppObjectType;
  typedef PangoLayoutIter BaseObjectType;
#endif /* DOXYGEN_SHOULD_SKIP_THIS */

private:

  
public:
  // There's no other ctor, and the default ctor creates an invalid object.
  // Therefore, Pango::LayoutIter is usable only as output argument.
  LayoutIter();
  ~LayoutIter();

  
  /** Gets the current byte index. Note that iterating forward by char
   * moves in visual order, not logical order, so indexes may not be
   * sequential. Also, the index may be equal to the length of the text
   * in the layout, if on the <tt>0</tt> run (see pango_layout_iter_get_run()).
   * @return Current byte index.
   */
  int get_index() const;
  
  /** Gets the current run. When iterating by run, at the end of each
   * line, there's a position with a <tt>0</tt> run, so this function can return
   * <tt>0</tt>. The <tt>0</tt> run at the end of each line ensures that all lines have
   * at least one run, even lines consisting of only a newline.
   * @return The current run.
   */
  LayoutRun get_run() const;
  
  /** Gets the current line.
   * @return The current line.
   */
  Glib::RefPtr<LayoutLine> get_line() const;
  
  /** Determines whether @a iter  is on the last line of the layout.
   * @return <tt>true</tt> if @a iter  is on the last line.
   */
  bool at_last_line() const;

  
  /** Moves @a iter  forward to the next character in visual order. If @a iter  was already at
   * the end of the layout, returns <tt>false</tt>.
   * @return Whether motion was possible.
   */
  bool next_char();
  
  /** Moves @a iter  forward to the next cluster in visual order. If @a iter 
   * was already at the end of the layout, returns <tt>false</tt>.
   * @return Whether motion was possible.
   */
  bool next_cluster();
  
  /** Moves @a iter  forward to the next run in visual order. If @a iter  was
   * already at the end of the layout, returns <tt>false</tt>.
   * @return Whether motion was possible.
   */
  bool next_run();
  
  /** Moves @a iter  forward to the start of the next line. If @a iter  is
   * already on the last line, returns <tt>false</tt>.
   * @return Whether motion was possible.
   */
  bool next_line();

  /** Gets the extents of the current character, in layout coordinates (origin is the top left of the entire layout).
   * Only logical extents can sensibly be obtained for characters; ink extents make sense only down to the level of clusters.
   * @return The logical extents of the current character.
   */
  Rectangle get_char_extents() const;

  
  /** Gets the extents of the current cluster, in layout coordinates
   * (origin is the top left of the entire layout).
   * @param ink_rect Rectangle to fill with ink extents.
   * @param logical_rect Rectangle to fill with logical extents.
   */
  void get_cluster_extents(Rectangle& ink_rect, Rectangle& logical_rect) const;

  /** Gets the ink extents of the current cluster, in layout coordinates (origin is the top left of the entire layout).
   * @return The extents of the current cluster as drawn.
   */
  Rectangle get_cluster_ink_extents() const;

  /** Gets the logical extents of the current cluster, in layout coordinates (origin is the top left of the entire layout).
   * @return The logical extents of the current cluster.
   */
  Rectangle get_cluster_logical_extents() const;

  
  /** Gets the extents of the current run in layout coordinates
   * (origin is the top left of the entire layout).
   * @param ink_rect Rectangle to fill with ink extents.
   * @param logical_rect Rectangle to fill with logical extents.
   */
  void get_run_extents(Rectangle& ink_rect, Rectangle& logical_rect) const;

  /** Gets the ink extents of the current run in layout coordinates (origin is the top left of the entire layout).
   * @return The extents of the current run as drawn.
   */
  Rectangle get_run_ink_extents() const;

  /** Gets the logical extents of the current run in layout coordinates (origin is the top left of the entire layout).
   * @return The logical extents of the current run.
   */
  Rectangle get_run_logical_extents() const;

  
  /** Obtains the extents of the current line. @a ink_rect  or @a logical_rect 
   * can be <tt>0</tt> if you aren't interested in them. Extents are in layout
   * coordinates (origin is the top-left corner of the entire
   * Pango::Layout).  Thus the extents returned by this function will be
   * the same width/height but not at the same x/y as the extents
   * returned from pango_layout_line_get_extents().
   * @param ink_rect Rectangle to fill with ink extents.
   * @param logical_rect Rectangle to fill with logical extents.
   */
  void get_line_extents(Rectangle& ink_rect, Rectangle& logical_rect) const;

  /** Obtains the ink extents of the current line.
   * @return The extents of the current line as drawn.
   */
  Rectangle get_line_ink_extents() const;

  /** Obtains the logical extents of the current line.
   * @return The logical extents of the current line.
   */
  Rectangle get_line_logical_extents() const;

  
  /** Divides the vertical space in the Pango::Layout being iterated over
   * between the lines in the layout, and returns the space belonging to
   * the current line.  A line's range includes the line's logical
   * extents, plus half of the spacing above and below the line, if
   * pango_layout_set_spacing() has been called to set layout spacing.
   * The y positions are in layout coordinates (origin at top left of the
   * entire layout).
   * @param y0 Start of line.
   * @param y1 End of line.
   */
  void get_line_yrange(int& y0, int& y1) const;

  
  /** Obtains the extents of the Pango::Layout being iterated
   * over. @a ink_rect  or @a logical_rect  can be <tt>0</tt> if you
   * aren't interested in them.
   * @param ink_rect Rectangle to fill with ink extents.
   * @param logical_rect Rectangle to fill with logical extents.
   */
  void get_layout_extents(Rectangle& ink_rect, Rectangle& logical_rect) const;

  /** Obtains the ink extents of the Pango::Layout being iterated over.
   * @return The extents of the layout as drawn.
   */
  Rectangle get_layout_ink_extents() const;

  /** Obtains the logical extents of the Pango::Layout being iterated over.
   * @return The logical extents of the layout.
   */
  Rectangle get_layout_logical_extents() const;

  
  /** Gets the y position of the current line's baseline, in layout
   * coordinates (origin at top left of the entire layout).
   * @return Baseline of current line.
   */
  int get_baseline() const;

  /// Provides access to the underlying C GObject.  
  PangoLayoutIter*       gobj()       { return gobject_; }
  /// Provides access to the underlying C GObject.
  const PangoLayoutIter* gobj() const { return gobject_; }

#ifndef DOXYGEN_SHOULD_SKIP_THIS
  void assign_gobj(PangoLayoutIter* src);
#endif

protected:
  PangoLayoutIter* gobject_;

private:
  // noncopyable
  LayoutIter(const LayoutIter&);
  LayoutIter& operator=(const LayoutIter&);


};

} //namespace Pango


#endif /* _PANGOMM_LAYOUTITER_H */