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
,
67 if (PANGO_XFT_IS_FONT (font
))
69 Display
* xdisplay
= wxGlobalDisplay();
70 int xscreen
= DefaultScreen( xdisplay
);
71 Visual
* xvisual
= DefaultVisual( xdisplay
, xscreen
);
73 Colormap xcolormap
= DefaultColormapOfScreen( XScreenOfDisplay( xdisplay
, xscreen
) );
75 XftDraw
*draw
= XftDrawCreate( xdisplay
, drawable
, xvisual
, xcolormap
);
78 color
.color
.red
= colour
.Red() << 8;
79 color
.color
.green
= colour
.Green() << 8;
80 color
.color
.blue
= colour
.Blue() << 8;
81 color
.color
.alpha
= 65000;
82 pango_xft_render( draw
, &color
, font
, glyphs
, x
, y
);
84 XftDrawDestroy( draw
);
88 pango_x_render( wxGlobalDisplay(), drawable
, gc
, font
, glyphs
, x
, y
);
93 x11_draw_layout_line_with_colors( Drawable drawable
,
97 PangoLayoutLine
*line
,
100 PangoRectangle overall_rect
;
101 PangoRectangle logical_rect
;
102 PangoRectangle ink_rect
;
103 PangoContext
*context
;
107 context
= pango_layout_get_context (line
->layout
);
109 pango_layout_line_get_extents (line
,NULL
, &overall_rect
);
111 GSList
*tmp_list
= line
->runs
;
114 PangoUnderline uline
= PANGO_UNDERLINE_NONE
;
115 PangoLayoutRun
*run
= (PangoLayoutRun
*) tmp_list
->data
;
116 PangoColor fg_color
, bg_color
;
117 gboolean strike
, fg_set
, bg_set
, shape_set
;
120 tmp_list
= tmp_list
->next
;
122 x11_pango_get_item_properties (run
->item
, &uline
,
123 &strike
, &rise
, &fg_color
, &fg_set
, &bg_color
, &bg_set
,
124 &shape_set
, &ink_rect
, &logical_rect
);
126 /* we subtract the rise because X coordinates are upside down */
127 risen_y
= y
- rise
/ PANGO_SCALE
;
131 if (uline
== PANGO_UNDERLINE_NONE
)
132 pango_glyph_string_extents (run
->glyphs
, run
->item
->analysis
.font
, NULL
, &logical_rect
);
134 pango_glyph_string_extents (run
->glyphs
, run
->item
->analysis
.font
, &ink_rect
, &logical_rect
);
138 XDrawRectangle( drawable
, gc
, TRUE
,
139 x
+ (x_off
+ logical_rect
.x
) / PANGO_SCALE
,
140 risen_y
+ overall_rect
.y
/ PANGO_SCALE
,
141 logical_rect
.width
/ PANGO_SCALE
,
142 overall_rect
.height
/ PANGO_SCALE
);
147 int gx
= x
+ x_off
/ PANGO_SCALE
;
150 x11_draw_glyphs( drawable
, gc
, run
->item
->analysis
.font
, gx
, gy
, run
->glyphs
, colour
);
153 if (uline
== PANGO_UNDERLINE_SINGLE
)
155 XDrawLine( wxGlobalDisplay(), drawable
, gc
,
156 x
+ (x_off
+ ink_rect
.x
) / PANGO_SCALE
- 1,
158 x
+ (x_off
+ ink_rect
.x
+ ink_rect
.width
) / PANGO_SCALE
,
162 x_off
+= logical_rect
.width
;
167 x11_draw_layout_with_colors( Drawable drawable
,
174 PangoLayoutIter
*iter
= pango_layout_get_iter (layout
);
178 PangoLayoutLine
*line
= pango_layout_iter_get_line (iter
);
180 PangoRectangle logical_rect
;
181 pango_layout_iter_get_line_extents (iter
, NULL
, &logical_rect
);
183 int baseline
= pango_layout_iter_get_baseline (iter
);
185 x11_draw_layout_line_with_colors( drawable
, gc
,
186 x
+ logical_rect
.x
/ PANGO_SCALE
,
187 y
+ baseline
/ PANGO_SCALE
,
191 } while (pango_layout_iter_next_line (iter
));
193 pango_layout_iter_free (iter
);
197 x11_draw_layout( Drawable drawable
,
204 wxCHECK_RET( layout
, wxT("No layout") );
206 x11_draw_layout_with_colors (drawable
, gc
, x
, y
, layout
, colour
);
210 x11_pango_get_item_properties( PangoItem
*item
,
211 PangoUnderline
*uline
,
212 gboolean
*strikethrough
,
214 PangoColor
*fg_color
,
216 PangoColor
*bg_color
,
219 PangoRectangle
*ink_rect
,
220 PangoRectangle
*logical_rect
)
222 GSList
*tmp_list
= item
->analysis
.extra_attrs
;
225 *strikethrough
= FALSE
;
241 PangoAttribute
*attr
= (PangoAttribute
*) tmp_list
->data
;
243 switch (attr
->klass
->type
)
245 case PANGO_ATTR_UNDERLINE
:
247 *uline
= (PangoUnderline
) ((PangoAttrInt
*)attr
)->value
;
250 case PANGO_ATTR_STRIKETHROUGH
:
252 *strikethrough
= ((PangoAttrInt
*)attr
)->value
;
255 case PANGO_ATTR_FOREGROUND
:
257 *fg_color
= ((PangoAttrColor
*)attr
)->color
;
263 case PANGO_ATTR_BACKGROUND
:
265 *bg_color
= ((PangoAttrColor
*)attr
)->color
;
271 case PANGO_ATTR_SHAPE
:
275 *logical_rect
= ((PangoAttrShape
*)attr
)->logical_rect
;
277 *ink_rect
= ((PangoAttrShape
*)attr
)->ink_rect
;
280 case PANGO_ATTR_RISE
:
282 *rise
= ((PangoAttrInt
*)attr
)->value
;
288 tmp_list
= tmp_list
->next
;