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
);
91 pango_x_render( wxGlobalDisplay(), drawable
, gc
, font
, glyphs
, x
, y
);
96 x11_draw_layout_line_with_colors( Drawable drawable
,
100 PangoLayoutLine
*line
,
103 PangoRectangle overall_rect
;
104 PangoRectangle logical_rect
;
105 PangoRectangle ink_rect
;
106 PangoContext
*context
;
110 context
= pango_layout_get_context (line
->layout
);
112 pango_layout_line_get_extents (line
,NULL
, &overall_rect
);
114 GSList
*tmp_list
= line
->runs
;
117 PangoUnderline uline
= PANGO_UNDERLINE_NONE
;
118 PangoLayoutRun
*run
= (PangoLayoutRun
*) tmp_list
->data
;
119 PangoColor fg_color
, bg_color
;
120 gboolean strike
, fg_set
, bg_set
, shape_set
;
123 tmp_list
= tmp_list
->next
;
125 x11_pango_get_item_properties (run
->item
, &uline
,
126 &strike
, &rise
, &fg_color
, &fg_set
, &bg_color
, &bg_set
,
127 &shape_set
, &ink_rect
, &logical_rect
);
129 /* we subtract the rise because X coordinates are upside down */
130 risen_y
= y
- rise
/ PANGO_SCALE
;
134 if (uline
== PANGO_UNDERLINE_NONE
)
135 pango_glyph_string_extents (run
->glyphs
, run
->item
->analysis
.font
, NULL
, &logical_rect
);
137 pango_glyph_string_extents (run
->glyphs
, run
->item
->analysis
.font
, &ink_rect
, &logical_rect
);
141 XDrawRectangle( drawable
, gc
, TRUE
,
142 x
+ (x_off
+ logical_rect
.x
) / PANGO_SCALE
,
143 risen_y
+ overall_rect
.y
/ PANGO_SCALE
,
144 logical_rect
.width
/ PANGO_SCALE
,
145 overall_rect
.height
/ PANGO_SCALE
);
150 int gx
= x
+ x_off
/ PANGO_SCALE
;
153 x11_draw_glyphs( drawable
, gc
, run
->item
->analysis
.font
, gx
, gy
, run
->glyphs
, colour
);
156 if (uline
== PANGO_UNDERLINE_SINGLE
)
158 XDrawLine( wxGlobalDisplay(), drawable
, gc
,
159 x
+ (x_off
+ ink_rect
.x
) / PANGO_SCALE
- 1,
161 x
+ (x_off
+ ink_rect
.x
+ ink_rect
.width
) / PANGO_SCALE
,
165 x_off
+= logical_rect
.width
;
170 x11_draw_layout_with_colors( Drawable drawable
,
177 PangoLayoutIter
*iter
= pango_layout_get_iter (layout
);
181 PangoLayoutLine
*line
= pango_layout_iter_get_line (iter
);
183 PangoRectangle logical_rect
;
184 pango_layout_iter_get_line_extents (iter
, NULL
, &logical_rect
);
186 int baseline
= pango_layout_iter_get_baseline (iter
);
188 x11_draw_layout_line_with_colors( drawable
, gc
,
189 x
+ logical_rect
.x
/ PANGO_SCALE
,
190 y
+ baseline
/ PANGO_SCALE
,
194 } while (pango_layout_iter_next_line (iter
));
196 pango_layout_iter_free (iter
);
200 x11_draw_layout( Drawable drawable
,
207 wxCHECK_RET( layout
, wxT("No layout") );
209 x11_draw_layout_with_colors (drawable
, gc
, x
, y
, layout
, colour
);
213 x11_pango_get_item_properties( PangoItem
*item
,
214 PangoUnderline
*uline
,
215 gboolean
*strikethrough
,
217 PangoColor
*fg_color
,
219 PangoColor
*bg_color
,
222 PangoRectangle
*ink_rect
,
223 PangoRectangle
*logical_rect
)
225 GSList
*tmp_list
= item
->analysis
.extra_attrs
;
228 *strikethrough
= FALSE
;
244 PangoAttribute
*attr
= (PangoAttribute
*) tmp_list
->data
;
246 switch (attr
->klass
->type
)
248 case PANGO_ATTR_UNDERLINE
:
250 *uline
= (PangoUnderline
) ((PangoAttrInt
*)attr
)->value
;
253 case PANGO_ATTR_STRIKETHROUGH
:
255 *strikethrough
= ((PangoAttrInt
*)attr
)->value
;
258 case PANGO_ATTR_FOREGROUND
:
260 *fg_color
= ((PangoAttrColor
*)attr
)->color
;
266 case PANGO_ATTR_BACKGROUND
:
268 *bg_color
= ((PangoAttrColor
*)attr
)->color
;
274 case PANGO_ATTR_SHAPE
:
278 *logical_rect
= ((PangoAttrShape
*)attr
)->logical_rect
;
280 *ink_rect
= ((PangoAttrShape
*)attr
)->ink_rect
;
283 case PANGO_ATTR_RISE
:
285 *rise
= ((PangoAttrInt
*)attr
)->value
;
291 tmp_list
= tmp_list
->next
;