2 * This file gets included from dcclient.cpp and implements
3 * the X11 interface to Pango.
4 * Copyright (C) Owen Taylor and Robert Roebling.
5 * Licence: The wxWindows licence
11 x11_draw_glyphs( Drawable drawable
,
16 PangoGlyphString
*glyphs
);
19 x11_draw_layout_line_with_colors( Drawable drawable
,
23 PangoLayoutLine
*line
,
28 x11_draw_layout_with_colors( Drawable drawable
,
37 x11_draw_layout( Drawable drawable
,
44 x11_pango_get_item_properties( PangoItem
*item
,
45 PangoUnderline
*uline
,
46 gboolean
*strikethrough
,
53 PangoRectangle
*ink_rect
,
54 PangoRectangle
*logical_rect
);
59 x11_draw_glyphs( Drawable drawable
,
64 PangoGlyphString
*glyphs
)
66 if (PANGO_XFT_IS_FONT (font
))
68 pango_xft_picture_render( wxGlobalDisplay(), drawable
, drawable
, font
, glyphs
, x
, y
);
72 pango_x_render( wxGlobalDisplay(), drawable
, gc
, font
, glyphs
, x
, y
);
77 x11_draw_layout_line_with_colors( Drawable drawable
,
81 PangoLayoutLine
*line
,
85 PangoRectangle overall_rect
;
86 PangoRectangle logical_rect
;
87 PangoRectangle ink_rect
;
88 PangoContext
*context
;
92 context
= pango_layout_get_context (line
->layout
);
94 pango_layout_line_get_extents (line
,NULL
, &overall_rect
);
96 GSList
*tmp_list
= line
->runs
;
99 PangoUnderline uline
= PANGO_UNDERLINE_NONE
;
100 PangoLayoutRun
*run
= (PangoLayoutRun
*) tmp_list
->data
;
101 PangoColor fg_color
, bg_color
;
102 gboolean strike
, fg_set
, bg_set
, shape_set
;
105 tmp_list
= tmp_list
->next
;
107 x11_pango_get_item_properties (run
->item
, &uline
,
108 &strike
, &rise
, &fg_color
, &fg_set
, &bg_color
, &bg_set
,
109 &shape_set
, &ink_rect
, &logical_rect
);
111 /* we subtract the rise because X coordinates are upside down */
112 risen_y
= y
- rise
/ PANGO_SCALE
;
116 if (uline
== PANGO_UNDERLINE_NONE
)
117 pango_glyph_string_extents (run
->glyphs
, run
->item
->analysis
.font
, NULL
, &logical_rect
);
119 pango_glyph_string_extents (run
->glyphs
, run
->item
->analysis
.font
, &ink_rect
, &logical_rect
);
123 XDrawRectangle( drawable
, gc
, TRUE
,
124 x
+ (x_off
+ logical_rect
.x
) / PANGO_SCALE
,
125 risen_y
+ overall_rect
.y
/ PANGO_SCALE
,
126 logical_rect
.width
/ PANGO_SCALE
,
127 overall_rect
.height
/ PANGO_SCALE
);
132 int gx
= x
+ x_off
/ PANGO_SCALE
;
135 x11_draw_glyphs( drawable
, gc
, run
->item
->analysis
.font
, gx
, gy
, run
->glyphs
);
138 if (uline
== PANGO_UNDERLINE_SINGLE
)
140 XDrawLine( wxGlobalDisplay(), drawable
, gc
,
141 x
+ (x_off
+ ink_rect
.x
) / PANGO_SCALE
- 1,
143 x
+ (x_off
+ ink_rect
.x
+ ink_rect
.width
) / PANGO_SCALE
,
147 x_off
+= logical_rect
.width
;
152 x11_draw_layout_with_colors( Drawable drawable
,
160 PangoLayoutIter
*iter
= pango_layout_get_iter (layout
);
164 PangoLayoutLine
*line
= pango_layout_iter_get_line (iter
);
166 PangoRectangle logical_rect
;
167 pango_layout_iter_get_line_extents (iter
, NULL
, &logical_rect
);
169 int baseline
= pango_layout_iter_get_baseline (iter
);
171 x11_draw_layout_line_with_colors( drawable
, gc
,
172 x
+ logical_rect
.x
/ PANGO_SCALE
,
173 y
+ baseline
/ PANGO_SCALE
,
178 } while (pango_layout_iter_next_line (iter
));
180 pango_layout_iter_free (iter
);
184 x11_draw_layout( Drawable drawable
,
190 wxCHECK_RET( layout
, wxT("No layout") );
192 x11_draw_layout_with_colors (drawable
, gc
, x
, y
, layout
, NULL
, NULL
);
196 x11_pango_get_item_properties( PangoItem
*item
,
197 PangoUnderline
*uline
,
198 gboolean
*strikethrough
,
200 PangoColor
*fg_color
,
202 PangoColor
*bg_color
,
205 PangoRectangle
*ink_rect
,
206 PangoRectangle
*logical_rect
)
208 GSList
*tmp_list
= item
->analysis
.extra_attrs
;
211 *strikethrough
= FALSE
;
227 PangoAttribute
*attr
= (PangoAttribute
*) tmp_list
->data
;
229 switch (attr
->klass
->type
)
231 case PANGO_ATTR_UNDERLINE
:
233 *uline
= (PangoUnderline
) ((PangoAttrInt
*)attr
)->value
;
236 case PANGO_ATTR_STRIKETHROUGH
:
238 *strikethrough
= ((PangoAttrInt
*)attr
)->value
;
241 case PANGO_ATTR_FOREGROUND
:
243 *fg_color
= ((PangoAttrColor
*)attr
)->color
;
249 case PANGO_ATTR_BACKGROUND
:
251 *bg_color
= ((PangoAttrColor
*)attr
)->color
;
257 case PANGO_ATTR_SHAPE
:
261 *logical_rect
= ((PangoAttrShape
*)attr
)->logical_rect
;
263 *ink_rect
= ((PangoAttrShape
*)attr
)->ink_rect
;
266 case PANGO_ATTR_RISE
:
268 *rise
= ((PangoAttrInt
*)attr
)->value
;
274 tmp_list
= tmp_list
->next
;