2 * This file gets included from dcclient.cpp and implements
3 * the X11 interface to Pango.
4 * Copyright (C) Owen Taylor and Robert Roebling.
10 x11_draw_glyphs( Drawable drawable
,
15 PangoGlyphString
*glyphs
);
18 x11_draw_layout_line_with_colors( Drawable drawable
,
22 PangoLayoutLine
*line
,
27 x11_draw_layout_with_colors( Drawable drawable
,
36 x11_draw_layout( Drawable drawable
,
43 x11_pango_get_item_properties( PangoItem
*item
,
44 PangoUnderline
*uline
,
45 gboolean
*strikethrough
,
52 PangoRectangle
*ink_rect
,
53 PangoRectangle
*logical_rect
);
58 x11_draw_glyphs( Drawable drawable
,
63 PangoGlyphString
*glyphs
)
65 if (PANGO_XFT_IS_FONT (font
))
67 pango_xft_picture_render( wxGlobalDisplay(), drawable
, drawable
, font
, glyphs
, x
, y
);
71 pango_x_render( wxGlobalDisplay(), drawable
, gc
, font
, glyphs
, x
, y
);
76 x11_draw_layout_line_with_colors( Drawable drawable
,
80 PangoLayoutLine
*line
,
84 PangoRectangle overall_rect
;
85 PangoRectangle logical_rect
;
86 PangoRectangle ink_rect
;
87 PangoContext
*context
;
91 context
= pango_layout_get_context (line
->layout
);
93 pango_layout_line_get_extents (line
,NULL
, &overall_rect
);
95 GSList
*tmp_list
= line
->runs
;
98 PangoUnderline uline
= PANGO_UNDERLINE_NONE
;
99 PangoLayoutRun
*run
= (PangoLayoutRun
*) tmp_list
->data
;
100 PangoColor fg_color
, bg_color
;
101 gboolean strike
, fg_set
, bg_set
, shape_set
;
104 tmp_list
= tmp_list
->next
;
106 x11_pango_get_item_properties (run
->item
, &uline
,
107 &strike
, &rise
, &fg_color
, &fg_set
, &bg_color
, &bg_set
,
108 &shape_set
, &ink_rect
, &logical_rect
);
110 /* we subtract the rise because X coordinates are upside down */
111 risen_y
= y
- rise
/ PANGO_SCALE
;
115 if (uline
== PANGO_UNDERLINE_NONE
)
116 pango_glyph_string_extents (run
->glyphs
, run
->item
->analysis
.font
, NULL
, &logical_rect
);
118 pango_glyph_string_extents (run
->glyphs
, run
->item
->analysis
.font
, &ink_rect
, &logical_rect
);
122 XDrawRectangle( drawable
, gc
, TRUE
,
123 x
+ (x_off
+ logical_rect
.x
) / PANGO_SCALE
,
124 risen_y
+ overall_rect
.y
/ PANGO_SCALE
,
125 logical_rect
.width
/ PANGO_SCALE
,
126 overall_rect
.height
/ PANGO_SCALE
);
131 int gx
= x
+ x_off
/ PANGO_SCALE
;
134 x11_draw_glyphs( drawable
, gc
, run
->item
->analysis
.font
, gx
, gy
, run
->glyphs
);
137 if (uline
== PANGO_UNDERLINE_SINGLE
)
139 XDrawLine( wxGlobalDisplay(), drawable
, gc
,
140 x
+ (x_off
+ ink_rect
.x
) / PANGO_SCALE
- 1,
142 x
+ (x_off
+ ink_rect
.x
+ ink_rect
.width
) / PANGO_SCALE
,
146 x_off
+= logical_rect
.width
;
151 x11_draw_layout_with_colors( Drawable drawable
,
159 PangoLayoutIter
*iter
= pango_layout_get_iter (layout
);
163 PangoLayoutLine
*line
= pango_layout_iter_get_line (iter
);
165 PangoRectangle logical_rect
;
166 pango_layout_iter_get_line_extents (iter
, NULL
, &logical_rect
);
168 int baseline
= pango_layout_iter_get_baseline (iter
);
170 x11_draw_layout_line_with_colors( drawable
, gc
,
171 x
+ logical_rect
.x
/ PANGO_SCALE
,
172 y
+ baseline
/ PANGO_SCALE
,
177 } while (pango_layout_iter_next_line (iter
));
179 pango_layout_iter_free (iter
);
183 x11_draw_layout( Drawable drawable
,
189 wxCHECK_RET( layout
, wxT("No layout") );
191 x11_draw_layout_with_colors (drawable
, gc
, x
, y
, layout
, NULL
, NULL
);
195 x11_pango_get_item_properties( PangoItem
*item
,
196 PangoUnderline
*uline
,
197 gboolean
*strikethrough
,
199 PangoColor
*fg_color
,
201 PangoColor
*bg_color
,
204 PangoRectangle
*ink_rect
,
205 PangoRectangle
*logical_rect
)
207 GSList
*tmp_list
= item
->analysis
.extra_attrs
;
210 *strikethrough
= FALSE
;
226 PangoAttribute
*attr
= (PangoAttribute
*) tmp_list
->data
;
228 switch (attr
->klass
->type
)
230 case PANGO_ATTR_UNDERLINE
:
232 *uline
= (PangoUnderline
) ((PangoAttrInt
*)attr
)->value
;
235 case PANGO_ATTR_STRIKETHROUGH
:
237 *strikethrough
= ((PangoAttrInt
*)attr
)->value
;
240 case PANGO_ATTR_FOREGROUND
:
242 *fg_color
= ((PangoAttrColor
*)attr
)->color
;
248 case PANGO_ATTR_BACKGROUND
:
250 *bg_color
= ((PangoAttrColor
*)attr
)->color
;
256 case PANGO_ATTR_SHAPE
:
260 *logical_rect
= ((PangoAttrShape
*)attr
)->logical_rect
;
262 *ink_rect
= ((PangoAttrShape
*)attr
)->ink_rect
;
265 case PANGO_ATTR_RISE
:
267 *rise
= ((PangoAttrInt
*)attr
)->value
;
273 tmp_list
= tmp_list
->next
;