1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
6
* Moonlight List (moonlight-list@lists.ximian.com)
8
* Copyright 2007 Novell, Inc. (http://www.novell.com)
10
* See the LICENSE file included with the distribution for details.
19
#include <frameworkelement.h>
20
#include <downloader.h>
21
#include <moon-path.h>
23
#include <thickness.h>
29
#define TEXTBLOCK_FONT_FAMILY "Portable User Interface"
30
#define TEXTBLOCK_FONT_STRETCH FontStretchesNormal
31
#define TEXTBLOCK_FONT_WEIGHT FontWeightsNormal
32
#define TEXTBLOCK_FONT_STYLE FontStylesNormal
33
#define TEXTBLOCK_FONT_SIZE 14.666666984558105
37
void text_shutdown (void);
42
/* @Namespace=System.Windows.Documents */
43
class Inline : public DependencyObject {
48
/* @PropertyType=string,DefaultValue=TEXTBLOCK_FONT_FAMILY,ManagedPropertyType=FontFamily */
49
static DependencyProperty *FontFamilyProperty;
50
/* @PropertyType=double,DefaultValue=TEXTBLOCK_FONT_SIZE,GenerateAccessors */
51
static DependencyProperty *FontSizeProperty;
52
/* @PropertyType=FontStretch,DefaultValue=TEXTBLOCK_FONT_STRETCH,GenerateAccessors */
53
static DependencyProperty *FontStretchProperty;
54
/* @PropertyType=FontStyle,DefaultValue=TEXTBLOCK_FONT_STYLE,GenerateAccessors */
55
static DependencyProperty *FontStyleProperty;
56
/* @PropertyType=FontWeight,DefaultValue=TEXTBLOCK_FONT_WEIGHT,GenerateAccessors */
57
static DependencyProperty *FontWeightProperty;
58
/* @PropertyType=Brush,GenerateAccessors */
59
static DependencyProperty *ForegroundProperty;
60
/* @PropertyType=TextDecorations,DefaultValue=TextDecorationsNone,ManagedPropertyType=TextDecorationCollection */
61
static DependencyProperty *TextDecorationsProperty;
62
/* @PropertyType=string,DefaultValue=\"en-US\",Version=2.0,ManagedPropertyType=XmlLanguage */
63
static DependencyProperty *LanguageProperty;
65
/* Member variables should be considered private, for use only with the parent TextBlock */
66
TextFontDescription *font;
70
/* @GenerateCBinding,GeneratePInvoke,ManagedAccess=Protected */
73
virtual Type::Kind GetObjectType () { return Type::INLINE; }
75
virtual Value *GetDefaultValue (DependencyProperty *prop);
76
virtual void OnPropertyChanged (PropertyChangedEventArgs *args);
77
virtual void OnSubPropertyChanged (DependencyProperty *prop, DependencyObject *obj, PropertyChangedEventArgs *subobj_args);
80
double GetFontSize ();
81
void SetFontSize (double value);
83
FontStretches GetFontStretch ();
84
void SetFontStretch (FontStretches value);
86
FontStyles GetFontStyle ();
87
void SetFontStyle (FontStyles value);
89
FontWeights GetFontWeight ();
90
void SetFontWeight (FontWeights value);
92
Brush* GetForeground ();
93
void SetForeground (Brush* value);
97
/* @Namespace=System.Windows.Documents */
98
class LineBreak : public Inline {
100
virtual ~LineBreak () {}
103
/* @GenerateCBinding,GeneratePInvoke */
106
virtual Type::Kind GetObjectType () { return Type::LINEBREAK; }
110
/* @ContentProperty="Text" */
111
/* @Namespace=System.Windows.Documents */
112
class Run : public Inline {
117
/* @PropertyType=string,ManagedFieldAccess=Internal,GenerateAccessors */
118
static DependencyProperty *TextProperty;
120
/* @GenerateCBinding,GeneratePInvoke */
123
virtual Type::Kind GetObjectType () { return Type::RUN; }
126
// Property Accessors
128
void SetText (const char *text);
129
const char *GetText ();
133
/* @ContentProperty="Inlines" */
134
/* @Namespace=System.Windows.Controls */
135
class TextBlock : public FrameworkElement {
136
TextFontDescription *font;
137
TextLayoutHints *hints;
139
Downloader *downloader;
141
double actual_height;
146
void SetActualHeight (double height);
147
void SetActualWidth (double width);
149
void CalcActualWidthHeight (cairo_t *cr);
150
void Layout (cairo_t *cr);
151
void Paint (cairo_t *cr);
153
char *GetTextInternal ();
154
bool SetTextInternal (const char *text);
156
double GetBoundingWidth ()
158
double actual = GetActualWidth ();
161
if (!(value = GetValueNoDefault (FrameworkElement::WidthProperty)))
164
if (value->AsDouble () > actual)
165
return value->AsDouble ();
170
double GetBoundingHeight ()
172
double actual = GetActualHeight ();
175
if (!(value = GetValueNoDefault (FrameworkElement::HeightProperty)))
178
if (value->AsDouble () > actual)
179
return value->AsDouble ();
184
void DownloaderComplete ();
186
static void data_write (void *data, gint32 offset, gint32 n, void *closure);
187
static void downloader_complete (EventObject *sender, EventArgs *calldata, gpointer closure);
188
static void size_notify (gint64 size, gpointer data);
191
virtual ~TextBlock ();
194
/* @PropertyType=double,ReadOnly */
195
static DependencyProperty *ActualHeightProperty;
196
/* @PropertyType=double,ReadOnly */
197
static DependencyProperty *ActualWidthProperty;
198
/* @PropertyType=string,DefaultValue=TEXTBLOCK_FONT_FAMILY,ManagedPropertyType=FontFamily,GenerateAccessors */
199
static DependencyProperty *FontFamilyProperty;
200
/* @PropertyType=double,DefaultValue=TEXTBLOCK_FONT_SIZE,GenerateAccessors */
201
static DependencyProperty *FontSizeProperty;
202
/* @PropertyType=FontStretch,DefaultValue=TEXTBLOCK_FONT_STRETCH,GenerateAccessors */
203
static DependencyProperty *FontStretchProperty;
204
/* @PropertyType=FontStyle,DefaultValue=TEXTBLOCK_FONT_STYLE,GenerateAccessors */
205
static DependencyProperty *FontStyleProperty;
206
/* @PropertyType=FontWeight,DefaultValue=TEXTBLOCK_FONT_WEIGHT,GenerateAccessors */
207
static DependencyProperty *FontWeightProperty;
208
/* @PropertyType=Brush,GenerateAccessors */
209
static DependencyProperty *ForegroundProperty;
210
/* @PropertyType=InlineCollection,ManagedFieldAccess=Internal,ManagedSetterAccess=Internal,GenerateAccessors */
211
static DependencyProperty *InlinesProperty;
212
/* @PropertyType=string,GenerateAccessors */
213
static DependencyProperty *TextProperty;
214
/* @PropertyType=double,DefaultValue=NAN,Version=2.0,GenerateAccessors */
215
static DependencyProperty *LineHeightProperty;
216
/* @PropertyType=LineStackingStrategy,DefaultValue=LineStackingStrategyMaxHeight,Version=2.0,GenerateAccessors */
217
static DependencyProperty *LineStackingStrategyProperty;
218
/* @PropertyType=Thickness,DefaultValue=Thickness (0),Version=2.0,GenerateAccessors */
219
static DependencyProperty *PaddingProperty;
220
/* @PropertyType=TextAlignment,DefaultValue=TextAlignmentLeft,Version=2.0,GenerateAccessors */
221
static DependencyProperty *TextAlignmentProperty;
222
/* @PropertyType=TextDecorations,DefaultValue=TextDecorationsNone,ManagedPropertyType=TextDecorationCollection,GenerateAccessors */
223
static DependencyProperty *TextDecorationsProperty;
224
/* @PropertyType=TextWrapping,DefaultValue=TextWrappingNoWrap,GenerateAccessors */
225
static DependencyProperty *TextWrappingProperty;
227
/* @GenerateCBinding,GeneratePInvoke */
230
virtual Type::Kind GetObjectType () { return Type::TEXTBLOCK; }
232
void SetFontSource (Downloader *downloader);
237
virtual void Render (cairo_t *cr, int x, int y, int width, int height);
238
virtual void GetSizeForBrush (cairo_t *cr, double *width, double *height);
239
virtual void ComputeBounds ();
240
virtual bool InsideObject (cairo_t *cr, double x, double y);
241
virtual Point GetTransformOrigin ();
242
virtual void OnPropertyChanged (PropertyChangedEventArgs *args);
243
virtual void OnSubPropertyChanged (DependencyProperty *prop, DependencyObject *obj, PropertyChangedEventArgs *subobj_args);
244
virtual void OnCollectionItemChanged (Collection *col, DependencyObject *obj, PropertyChangedEventArgs *args);
245
virtual void OnCollectionChanged (Collection *col, CollectionChangedEventArgs *args);
247
virtual Value *GetValue (DependencyProperty *property);
250
// Property Accessors
252
double GetActualWidth ()
255
CalcActualWidthHeight (NULL);
259
double GetActualHeight ()
262
CalcActualWidthHeight (NULL);
263
return actual_height;
266
void SetFontFamily (const char *family);
267
const char *GetFontFamily ();
269
void SetFontSize (double size);
270
double GetFontSize ();
272
void SetFontStretch (FontStretches stretch);
273
FontStretches GetFontStretch ();
275
void SetFontStyle (FontStyles style);
276
FontStyles GetFontStyle ();
278
void SetFontWeight (FontWeights weight);
279
FontWeights GetFontWeight ();
281
void SetForeground (Brush *fg);
282
Brush *GetForeground ();
284
void SetInlines (InlineCollection *inlines);
285
InlineCollection *GetInlines ();
287
void SetLineHeight (double height);
288
double GetLineHeight ();
290
void SetLineStackingStrategy (LineStackingStrategy strategy);
291
LineStackingStrategy GetLineStackingStrategy ();
293
void SetPadding (Thickness *padding);
294
Thickness *GetPadding ();
296
void SetText (const char *text);
297
const char *GetText ();
299
void SetTextAlignment (TextAlignment alignment);
300
TextAlignment GetTextAlignment ();
302
void SetTextDecorations (TextDecorations decorations);
303
TextDecorations GetTextDecorations ();
305
void SetTextWrapping (TextWrapping wrapping);
306
TextWrapping GetTextWrapping ();
310
/* @Namespace=System.Windows.Documents */
311
class Glyphs : public FrameworkElement {
312
TextFontDescription *desc;
313
Downloader *downloader;
328
int origin_y_specified:1;
329
int simulation_none:1;
335
void SetIndicesInternal (const char *in);
337
void DownloaderComplete ();
339
static void data_write (void *data, gint32 offset, gint32 n, void *closure);
340
static void downloader_complete (EventObject *sender, EventArgs *calldata, gpointer closure);
341
static void size_notify (gint64 size, gpointer data);
343
void DownloadFont (Surface *surface, const char *url);
349
/* @PropertyType=Brush */
350
static DependencyProperty *FillProperty;
351
/* @PropertyType=double,DefaultValue=0.0,GenerateAccessors */
352
static DependencyProperty *FontRenderingEmSizeProperty;
353
/* @PropertyType=string,ManagedPropertyType=Uri,GenerateAccessors */
354
static DependencyProperty *FontUriProperty;
355
/* @PropertyType=string,GenerateAccessors */
356
static DependencyProperty *IndicesProperty;
357
/* @PropertyType=double,DefaultValue=0.0,GenerateAccessors */
358
static DependencyProperty *OriginXProperty;
359
/* @PropertyType=double,DefaultValue=0.0,GenerateAccessors */
360
static DependencyProperty *OriginYProperty;
361
/* @PropertyType=StyleSimulations,DefaultValue=StyleSimulationsNone,GenerateAccessors */
362
static DependencyProperty *StyleSimulationsProperty;
363
/* @PropertyType=string,GenerateAccessors */
364
static DependencyProperty *UnicodeStringProperty;
366
/* @GenerateCBinding,GeneratePInvoke */
369
virtual Type::Kind GetObjectType () { return Type::GLYPHS; };
371
virtual void GetSizeForBrush (cairo_t *cr, double *width, double *height);
372
virtual void Render (cairo_t *cr, int x, int y, int width, int height);
373
virtual void ComputeBounds ();
374
virtual bool InsideObject (cairo_t *cr, double x, double y);
375
virtual Point GetTransformOrigin ();
376
virtual Point GetOriginPoint ();
377
virtual void SetSurface (Surface *surface);
378
virtual void OnPropertyChanged (PropertyChangedEventArgs *args);
379
virtual void OnSubPropertyChanged (DependencyProperty *prop, DependencyObject *obj, PropertyChangedEventArgs *subobj_args);
382
// Property Accessors
384
void SetFill (Brush *fill);
387
void SetFontRenderingEmSize (double size);
388
double GetFontRenderingEmSize ();
390
void SetFontUri (const char *uri);
391
const char *GetFontUri ();
393
void SetIndices (const char *indices);
394
const char *GetIndices ();
396
void SetOriginX (double origin);
397
double GetOriginX ();
399
void SetOriginY (double origin);
400
double GetOriginY ();
402
void SetStyleSimulations (StyleSimulations style);
403
StyleSimulations GetStyleSimulations ();
405
void SetUnicodeString (const char *unicode);
406
const char *GetUnicodeString ();
409
#endif /* __TEXT_H__ */