Owen Taylor schrieb:
> On Sat, 2007-05-19 at 15:58 +0200, Peter Frentrup
wrote:
>> Hello,
>>
>> I am working on a little text editor using Cairo
and Pango (but without
>> GTK+/GTKTextView, because it does not have a native
look-and-feel on
>> Windows).
>>
>> At first I thought, I could use the pangocairo API,
but it does not give
>> me the possibility to draw selected text in a
different style without
>> setting the background-attribute (which seems to be
slow when changing
>> the selection range).
>> So I read a bit about the PangoRenderer class. I
could write my own
>> subclass of PangoRenderer, but this would basically
be a copy of the
>> PangoCairoRenderer code plus a few additions.
>>
>> So my suggestion is to make PangoCairoRenderer
public to let Pango-users
>> subclass it; or is there another solution for my
problem?
>
> See GdkPangoRenderer for an example of building a
customized renderer
> that backends to Pango/Cairo. (Effectively it "has
a" PangoCairoRenderer
> rather than "is a" PangoCairoRenderer")
>
> But I'm not really sure that it's going to help you
with selection
> at all ... the technique used by the GTK+ widgets for
drawing a
> partially selected paragraph is:
>
> - Draw the paragraph normally
> - Create a clip region based on
pango_layout_line_get_x_ranges()
> - Draw the paragraph in the selection colors
>
> (Optimization to do this only for partially selected
lines is
> possible, but I wouldn't do it before finding the
entire paragraph
> to be a bottleneck..)
>
> The reason that you found setting attributes slow is
probably
> because you were causing a re-layout every time the
user moved
> dragged the mouse a character. Setting attributes also
just doesn't
> work well for selection ... consider selecting only the
'f' of
> a 'fi' ligature. The use of clipping avoids that
problem.
>
> - Owen
Thanks for your quick reply.
I will study the GdkPangoRenderer code.;The idea with
clipping sound
good. I haven't thought of something like this. Maybe I can
adopt that
clipping method for wxWidgets or so.
Regards,
Peter
_______________________________________________
gtk-i18n-list mailing list
gtk-i18n-list gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-i18n-list
|