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
,
19 x11_draw_layout_line_with_colors( Drawable drawable
,
23 PangoLayoutLine
*line
,
27 x11_draw_layout_with_colors( Drawable drawable
,
35 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
,
66 if (PANGO_XFT_IS_FONT (font
))
68 Display
* xdisplay
= wxGlobalDisplay();
69 int xscreen
= DefaultScreen( xdisplay
);
70 Visual
* xvisual
= DefaultVisual( xdisplay
, xscreen
);
72 Colormap xcolormap
= DefaultColormapOfScreen( XScreenOfDisplay( xdisplay
, xscreen
) );
74 XftDraw
*draw
= XftDrawCreate( xdisplay
, drawable
, xvisual
, xcolormap
);
77 color
.color
.red
= colour
.Red() << 8;
78 color
.color
.green
= colour
.Green() << 8;
79 color
.color
.blue
= colour
.Blue() << 8;
80 color
.color
.alpha
= 65000;
81 pango_xft_render( draw
, &color
, font
, glyphs
, x
, y
);
83 XftDrawDestroy( draw
);
87 pango_x_render( wxGlobalDisplay(), drawable
, gc
, font
, glyphs
, x
, y
);
92 x11_draw_layout_line_with_colors( Drawable drawable
,
96 PangoLayoutLine
*line
,
99 PangoRectangle overall_rect
;
100 PangoRectangle logical_rect
;
101 PangoRectangle ink_rect
;
102 PangoContext
*context
;
106 context
= pango_layout_get_context (line
->layout
);
108 pango_layout_line_get_extents (line
,NULL
, &overall_rect
);
110 GSList
*tmp_list
= line
->runs
;
113 PangoUnderline uline
= PANGO_UNDERLINE_NONE
;
114 PangoLayoutRun
*run
= (PangoLayoutRun
*) tmp_list
->data
;
115 PangoColor fg_color
, bg_color
;
116 gboolean strike
, fg_set
, bg_set
, shape_set
;
119 tmp_list
= tmp_list
->next
;
121 x11_pango_get_item_properties (run
->item
, &uline
,
122 &strike
, &rise
, &fg_color
, &fg_set
, &bg_color
, &bg_set
,
123 &shape_set
, &ink_rect
, &logical_rect
);
125 /* we subtract the rise because X coordinates are upside down */
126 risen_y
= y
- rise
/ PANGO_SCALE
;
130 if (uline
== PANGO_UNDERLINE_NONE
)
131 pango_glyph_string_extents (run
->glyphs
, run
->item
->analysis
.font
, NULL
, &logical_rect
);
133 pango_glyph_string_extents (run
->glyphs
, run
->item
->analysis
.font
, &ink_rect
, &logical_rect
);
137 XDrawRectangle( drawable
, gc
, TRUE
,
138 x
+ (x_off
+ logical_rect
.x
) / PANGO_SCALE
,
139 risen_y
+ overall_rect
.y
/ PANGO_SCALE
,
140 logical_rect
.width
/ PANGO_SCALE
,
141 overall_rect
.height
/ PANGO_SCALE
);
146 int gx
= x
+ x_off
/ PANGO_SCALE
;
149 x11_draw_glyphs( drawable
, gc
, run
->item
->analysis
.font
, gx
, gy
, run
->glyphs
, colour
);
152 if (uline
== PANGO_UNDERLINE_SINGLE
)
154 XDrawLine( wxGlobalDisplay(), drawable
, gc
,
155 x
+ (x_off
+ ink_rect
.x
) / PANGO_SCALE
- 1,
157 x
+ (x_off
+ ink_rect
.x
+ ink_rect
.width
) / PANGO_SCALE
,
161 x_off
+= logical_rect
.width
;
166 x11_draw_layout_with_colors( Drawable drawable
,
173 PangoLayoutIter
*iter
= pango_layout_get_iter (layout
);
177 PangoLayoutLine
*line
= pango_layout_iter_get_line (iter
);
179 PangoRectangle logical_rect
;
180 pango_layout_iter_get_line_extents (iter
, NULL
, &logical_rect
);
182 int baseline
= pango_layout_iter_get_baseline (iter
);
184 x11_draw_layout_line_with_colors( drawable
, gc
,
185 x
+ logical_rect
.x
/ PANGO_SCALE
,
186 y
+ baseline
/ PANGO_SCALE
,
190 } while (pango_layout_iter_next_line (iter
));
192 pango_layout_iter_free (iter
);
196 x11_draw_layout( Drawable drawable
,
203 wxCHECK_RET( layout
, wxT("No layout") );
205 x11_draw_layout_with_colors (drawable
, gc
, x
, y
, layout
, colour
);
209 x11_pango_get_item_properties( PangoItem
*item
,
210 PangoUnderline
*uline
,
211 gboolean
*strikethrough
,
213 PangoColor
*fg_color
,
215 PangoColor
*bg_color
,
218 PangoRectangle
*ink_rect
,
219 PangoRectangle
*logical_rect
)
221 GSList
*tmp_list
= item
->analysis
.extra_attrs
;
224 *strikethrough
= FALSE
;
240 PangoAttribute
*attr
= (PangoAttribute
*) tmp_list
->data
;
242 switch (attr
->klass
->type
)
244 case PANGO_ATTR_UNDERLINE
:
246 *uline
= (PangoUnderline
) ((PangoAttrInt
*)attr
)->value
;
249 case PANGO_ATTR_STRIKETHROUGH
:
251 *strikethrough
= ((PangoAttrInt
*)attr
)->value
;
254 case PANGO_ATTR_FOREGROUND
:
256 *fg_color
= ((PangoAttrColor
*)attr
)->color
;
262 case PANGO_ATTR_BACKGROUND
:
264 *bg_color
= ((PangoAttrColor
*)attr
)->color
;
270 case PANGO_ATTR_SHAPE
:
274 *logical_rect
= ((PangoAttrShape
*)attr
)->logical_rect
;
276 *ink_rect
= ((PangoAttrShape
*)attr
)->ink_rect
;
279 case PANGO_ATTR_RISE
:
281 *rise
= ((PangoAttrInt
*)attr
)->value
;
287 tmp_list
= tmp_list
->next
;