1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
6 * Moonlight List (moonlight-list@lists.ximian.com)
8 * Copyright 2008 Novell, Inc. (http://www.novell.com)
10 * See the LICENSE file included with the distribution for details.
27 class ITextAttributes
{
29 virtual ~ITextAttributes () {};
30 virtual TextFontDescription
*FontDescription () = 0;
31 virtual TextDecorations
Decorations () = 0;
32 virtual Brush
*Background (bool selected
) = 0;
33 virtual Brush
*Foreground (bool selected
) = 0;
36 class TextLayoutAttributes
: public List::Node
{
38 ITextAttributes
*source
;
41 TextLayoutAttributes (ITextAttributes
*source
, int start
)
43 this->source
= source
;
47 Brush
*Background (bool selected
)
49 return source
->Background (selected
);
52 Brush
*Foreground (bool selected
)
54 return source
->Foreground (selected
);
59 return source
->FontDescription ()->GetFont ();
64 return (source
->Decorations () & TextDecorationsUnderline
);
68 struct TextLayoutGlyphCluster
{
75 TextLayoutGlyphCluster (int start
, int length
);
76 ~TextLayoutGlyphCluster ();
78 void Render (cairo_t
*cr
, const Point
&origin
, TextLayoutAttributes
*attrs
, const char *text
, double x
, double y
, bool uline_full
);
81 struct TextLayoutLine
{
82 int start
, length
, offset
, count
;
90 TextLayoutLine (TextLayout
*layout
, int start
, int offset
);
93 void Render (cairo_t
*cr
, const Point
&origin
, double left
, double top
);
95 int GetCursorFromX (const Point
&offset
, double x
);
98 struct TextLayoutRun
{
99 TextLayoutAttributes
*attrs
;
100 int start
, length
, count
;
101 TextLayoutLine
*line
;
105 TextLayoutRun (TextLayoutLine
*line
, TextLayoutAttributes
*attrs
, int start
);
108 void Render (cairo_t
*cr
, const Point
&origin
, double x
, double y
, bool is_last_run
);
109 void GenerateCache ();
114 LineStackingStrategy strategy
;
115 TextAlignment alignment
;
116 TextWrapping wrapping
;
117 int selection_length
;
132 double actual_height
;
136 bool OverrideLineHeight () { return (strategy
== LineStackingStrategyBlockLineHeight
&& line_height
!= 0); }
137 double LineHeightOverride ();
138 double DescendOverride ();
148 // Property Accessors
150 // Set[Property]() accessors return %true if the extents have
151 // changed or %false otherwise.
154 int GetSelectionLength () { return selection_length
; }
155 int GetSelectionStart () { return selection_start
; }
157 LineStackingStrategy
GetLineStackingStrtegy () { return strategy
; }
158 bool SetLineStackingStrategy (LineStackingStrategy mode
);
160 List
*GetTextAttributes () { return attributes
; }
161 bool SetTextAttributes (List
*attrs
);
163 TextAlignment
GetTextAlignment () { return alignment
; }
164 bool SetTextAlignment (TextAlignment align
);
166 TextWrapping
GetTextWrapping () { return wrapping
; }
167 bool SetTextWrapping (TextWrapping mode
);
169 double GetLineHeight () { return line_height
; }
170 bool SetLineHeight (double height
);
172 double GetMaxHeight () { return max_height
; }
173 bool SetMaxHeight (double height
);
175 double GetAvailableWidth () { return avail_width
; }
176 bool SetAvailableWidth (double width
) { avail_width
= width
; return false; }
178 double GetMaxWidth () { return max_width
; }
179 bool SetMaxWidth (double width
);
181 bool SetText (const char *str
, int len
= -1);
182 const char *GetText () { return text
; }
184 void SetBaseFont (const TextFont
*font
);
190 void Render (cairo_t
*cr
, const Point
&origin
, const Point
&offset
);
191 void Select (int start
, int length
, bool byte_offsets
= false);
195 double HorizontalAlignment (double line_width
);
197 TextLayoutLine
*GetLineFromY (const Point
&offset
, double y
, int *index
= NULL
);
198 TextLayoutLine
*GetLineFromIndex (int index
);
199 int GetLineCount () { return lines
->len
; }
201 int GetCursorFromXY (const Point
&offset
, double x
, double y
);
202 Rect
GetCursor (const Point
&offset
, int pos
);
204 void GetActualExtents (double *width
, double *height
);
207 #endif /* __LAYOUT_H__ */