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
;
130 double actual_height
;
134 bool OverrideLineHeight () { return (strategy
== LineStackingStrategyBlockLineHeight
&& !isnan (line_height
)); }
144 // Property Accessors
146 // Set[Property]() accessors return %true if the extents have
147 // changed or %false otherwise.
150 int GetSelectionLength () { return selection_length
; }
151 int GetSelectionStart () { return selection_start
; }
153 LineStackingStrategy
GetLineStackingStrtegy () { return strategy
; }
154 bool SetLineStackingStrategy (LineStackingStrategy mode
);
156 List
*GetTextAttributes () { return attributes
; }
157 bool SetTextAttributes (List
*attrs
);
159 TextAlignment
GetTextAlignment () { return alignment
; }
160 bool SetTextAlignment (TextAlignment align
);
162 TextWrapping
GetTextWrapping () { return wrapping
; }
163 bool SetTextWrapping (TextWrapping mode
);
165 double GetLineHeight () { return line_height
; }
166 bool SetLineHeight (double height
);
168 double GetMaxHeight () { return max_height
; }
169 bool SetMaxHeight (double height
);
171 double GetAvailableWidth () { return avail_width
; }
172 bool SetAvailableWidth (double width
) { avail_width
= width
; return false; }
174 double GetMaxWidth () { return max_width
; }
175 bool SetMaxWidth (double width
);
177 bool SetText (const char *str
, int len
= -1);
178 const char *GetText () { return text
; }
184 void Render (cairo_t
*cr
, const Point
&origin
, const Point
&offset
);
185 void Select (int start
, int length
, bool byte_offsets
= false);
189 double HorizontalAlignment (double line_width
);
191 TextLayoutLine
*GetLineFromY (const Point
&offset
, double y
, int *index
= NULL
);
192 TextLayoutLine
*GetLineFromIndex (int index
);
193 int GetLineCount () { return lines
->len
; }
195 int GetCursorFromXY (const Point
&offset
, double x
, double y
);
196 Rect
GetCursor (const Point
&offset
, int pos
);
198 void GetActualExtents (double *width
, double *height
);
201 #endif /* __LAYOUT_H__ */