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
,
20 x11_draw_layout_line_with_colors( Drawable drawable
,
24 PangoLayoutLine
*line
,
28 x11_draw_layout_with_colors( Drawable drawable
,
36 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
,
68 if (PANGO_XFT_IS_FONT (font
))
70 Display
* xdisplay
= wxGlobalDisplay();
71 int xscreen
= DefaultScreen( xdisplay
);
72 Visual
* xvisual
= DefaultVisual( xdisplay
, xscreen
);
74 Colormap xcolormap
= DefaultColormapOfScreen( XScreenOfDisplay( xdisplay
, xscreen
) );
76 XftDraw
*draw
= XftDrawCreate( xdisplay
, drawable
, xvisual
, xcolormap
);
79 color
.color
.red
= colour
.Red() << 8;
80 color
.color
.green
= colour
.Green() << 8;
81 color
.color
.blue
= colour
.Blue() << 8;
82 color
.color
.alpha
= 65000;
83 pango_xft_render( draw
, &color
, font
, glyphs
, x
, y
);
85 XftDrawDestroy( draw
);
90 pango_x_render( wxGlobalDisplay(), drawable
, gc
, font
, glyphs
, x
, y
);
95 x11_draw_layout_line_with_colors( Drawable drawable
,
99 PangoLayoutLine
*line
,
102 PangoRectangle overall_rect
;
103 PangoRectangle logical_rect
;
104 PangoRectangle ink_rect
;
105 PangoContext
*context
;
109 context
= pango_layout_get_context (line
->layout
);
111 pango_layout_line_get_extents (line
,NULL
, &overall_rect
);
113 GSList
*tmp_list
= line
->runs
;
116 PangoUnderline uline
= PANGO_UNDERLINE_NONE
;
117 PangoLayoutRun
*run
= (PangoLayoutRun
*) tmp_list
->data
;
118 PangoColor fg_color
, bg_color
;
119 gboolean strike
, fg_set
, bg_set
, shape_set
;
122 tmp_list
= tmp_list
->next
;
124 x11_pango_get_item_properties (run
->item
, &uline
,
125 &strike
, &rise
, &fg_color
, &fg_set
, &bg_color
, &bg_set
,
126 &shape_set
, &ink_rect
, &logical_rect
);
128 /* we subtract the rise because X coordinates are upside down */
129 risen_y
= y
- rise
/ PANGO_SCALE
;
133 if (uline
== PANGO_UNDERLINE_NONE
)
134 pango_glyph_string_extents (run
->glyphs
, run
->item
->analysis
.font
, NULL
, &logical_rect
);
136 pango_glyph_string_extents (run
->glyphs
, run
->item
->analysis
.font
, &ink_rect
, &logical_rect
);
140 XDrawRectangle( drawable
, gc
, TRUE
,
141 x
+ (x_off
+ logical_rect
.x
) / PANGO_SCALE
,
142 risen_y
+ overall_rect
.y
/ PANGO_SCALE
,
143 logical_rect
.width
/ PANGO_SCALE
,
144 overall_rect
.height
/ PANGO_SCALE
);
149 int gx
= x
+ x_off
/ PANGO_SCALE
;
152 x11_draw_glyphs( drawable
, gc
, run
->item
->analysis
.font
, gx
, gy
, run
->glyphs
, colour
);
155 if (uline
== PANGO_UNDERLINE_SINGLE
)
157 XDrawLine( wxGlobalDisplay(), drawable
, gc
,
158 x
+ (x_off
+ ink_rect
.x
) / PANGO_SCALE
- 1,
160 x
+ (x_off
+ ink_rect
.x
+ ink_rect
.width
) / PANGO_SCALE
,
164 x_off
+= logical_rect
.width
;
169 x11_draw_layout_with_colors( Drawable drawable
,
176 PangoLayoutIter
*iter
= pango_layout_get_iter (layout
);
180 PangoLayoutLine
*line
= pango_layout_iter_get_line (iter
);
182 PangoRectangle logical_rect
;
183 pango_layout_iter_get_line_extents (iter
, NULL
, &logical_rect
);
185 int baseline
= pango_layout_iter_get_baseline (iter
);
187 x11_draw_layout_line_with_colors( drawable
, gc
,
188 x
+ logical_rect
.x
/ PANGO_SCALE
,
189 y
+ baseline
/ PANGO_SCALE
,
193 } while (pango_layout_iter_next_line (iter
));
195 pango_layout_iter_free (iter
);
199 x11_draw_layout( Drawable drawable
,
206 wxCHECK_RET( layout
, wxT("No layout") );
208 x11_draw_layout_with_colors (drawable
, gc
, x
, y
, layout
, colour
);
212 x11_pango_get_item_properties( PangoItem
*item
,
213 PangoUnderline
*uline
,
214 gboolean
*strikethrough
,
216 PangoColor
*fg_color
,
218 PangoColor
*bg_color
,
221 PangoRectangle
*ink_rect
,
222 PangoRectangle
*logical_rect
)
224 GSList
*tmp_list
= item
->analysis
.extra_attrs
;
227 *strikethrough
= FALSE
;
243 PangoAttribute
*attr
= (PangoAttribute
*) tmp_list
->data
;
245 switch (attr
->klass
->type
)
247 case PANGO_ATTR_UNDERLINE
:
249 *uline
= (PangoUnderline
) ((PangoAttrInt
*)attr
)->value
;
252 case PANGO_ATTR_STRIKETHROUGH
:
254 *strikethrough
= ((PangoAttrInt
*)attr
)->value
;
257 case PANGO_ATTR_FOREGROUND
:
259 *fg_color
= ((PangoAttrColor
*)attr
)->color
;
265 case PANGO_ATTR_BACKGROUND
:
267 *bg_color
= ((PangoAttrColor
*)attr
)->color
;
273 case PANGO_ATTR_SHAPE
:
277 *logical_rect
= ((PangoAttrShape
*)attr
)->logical_rect
;
279 *ink_rect
= ((PangoAttrShape
*)attr
)->ink_rect
;
282 case PANGO_ATTR_RISE
:
284 *rise
= ((PangoAttrInt
*)attr
)->value
;
290 tmp_list
= tmp_list
->next
;