Re: [gtkmm] problems with pango
- From: MHL Schulze t-online de (Martin Schulze)
- To: Morus Walter <morus walter web de>
- Cc: gtkmm-list gnome org
- Subject: Re: [gtkmm] problems with pango
- Date: Wed, 23 Oct 2002 19:55:51 +0200
Am 2002.10.22 20:44 schrieb(en) Morus Walter:
Hi,
I want to do a low level drawing of some text string on a drawing area using
pango.
I was successful to do so using the c api but I want to use the c++
wrappers.
Now when I tried to rewrite the c program in c++ I found two problems
I wasn't able to solve:
After calling Pango::Context::itemize I get a list of items I must loop
over. Now itemize returns a Glib::ListHandle<Pango::Item*> and I can
iterate over this list using
for ( Glib::ListHandle<Pango::Item*>::iterator it = items.begin();
it != items.end() ; it++ )
But I could not figure out, how to reference the items in the list
using the iterator.
The API doc says that there is `value_type operator* () const' for
Glib::Container_Helpers::ListHandleIterator< Tr > Class Template Reference
So it should be something like
Pango::Item* item = *it;
but I get an error
/usr/local/include/gtkmm-2.0/glibmm/containerhandle_shared.h:138: cannot
convert `Item(false)' from type `Pango::Item' to type `Pango::Item *'
There is no way to reference the items. You can think of them as
children of the list returned by Context::itemize. If the list gets
out of scope all children are deleted. (The reason for this lies in
the pango c API: you cannot reference a PangoItem object either.)
However, Item has a copy constructor so that you can write
Pango::Item item(*it);
to store a specific item beyond the scope of the listhandle.
std::list<Item> stl_items = items;
is a possibility to copy all items into an stl list.
Note that *it returns a Item object rather than a Item* pointer.
This is not obvious from the documentation. (@All: How can this
be improved?)
The second problem is, that I call the pango_shape function in c for
each item and I cannot find the c++ binding for that function. It's not
clear which classes method it should be, but I cannot find anything
apropriate at all.
Item::shape() is what you're looking for. This is also mentioned
in the class description of Item:
http://www.gtkmm.org/gtkmm2/docs/reference/html/classPango_1_1Item.html#_details
Unfortunately I didn't find anything in the samples that uses
Glib::ListHandle<> or pango.
Glib::ListHandle<> is easy enough to use. If you find it hard or
impossible to use it directly (it is not meant to provide a full
stl style list API) then you can easily convert it into an
std::vector, std::deque or std::list using the conversion
operators as shown above. The only thing non-obvious is
that "value_type" is always the dereferenced pointer.
As for pango examples, we would be happy if some people could
contribute some real world code. Post it on the mailing list
or even better (if you feel like it) create a pangomm example
from it and attach a patch to some bugreport on bugzilla!
Myself, I could only make up some theoretical test code without
any practical use because I'm not using pangomm in the moment.
Regards,
Martin
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]