using cairo with gtkd

John Reimer terminal.node at gmail.com
Tue Jan 22 22:07:47 PST 2008


llee wrote:
> llee Wrote:
> 
>> llee Wrote:
>>
>>> A number of functions in Cairo return objects with the following naming conventions, according to the documention on: http://devel.akbkhome.com/gtkd_docs/src/cairoLib:
>>>
>>> cairo_<object name>_t
>>>
>>> When I try to create instances of these objects, I get an error. For example, when I try to instantiate the following:
>>>
>>> cairo_text_extents_t* textExtents
>>>
>>> The compiler says that cairo_text_extents_t is undefined. I tried importing the following modules:
>>>
>>> cairoLib.Cairo, and cairoLib.Types.
>>>
>>> Neither of these resolved the problem. If anyone can tell me how I can use the following functions I'd appreciate it. 
>>>
>>> void textExtents (char[] utf8, cairo_text_extents_t * extents);
>>> void selectFontFace (char[] family, cairo_font_slant_t slant, cairo_font_weight_t weight);
>>>
>>> Thanks in advance.
> 
> I imported gtkc.cairoLibtypes. This stoped the compiler from saying that cairo_text_extents_t is undefined, but the structure is missing data members. When I tried to dereference cairo_text_extents_t.width the compiler says that width is not a recognized data member. I get the same error when I try to dereference Xadvance. I'm really running out of ideas here. Any help would be appreciated.


GtkD uses gtk+ (and related bindings like cairo) that are not full 
definitions of the C counterparts.  This means many of the gtkc structs 
(including cairoLib) are declared as opaque types.  That is, the struct 
members are not defined.  The assumption is that these data members are 
not going to be accessed by the D programmer.  This is sufficient for 
implementing GtkD itself but may not be sufficient for those that want 
to direct access to the complete C header definitions of the struct types.

You could do a couple of things.

(1) You could look in the C Cairo headers and find the complete 
definition of the struct and add the D equivalent to the 
gtkc/cairoLibtypes.d module yourself.  This probably would be a fairly 
simple fix.

or...

(2) You could get the complete gtk+ (including cairo) from the bcd 
generated bindings (www.dsource.org/projects/bcd).  These bindings 
include the full struct definitions for all types.  But, if you need to 
use GtkD, these are not set up to work correctly along side it.

In summary, the GtkD gtk+ bindings are not complete and are insufficient 
  if you want to use them to work with pure gtk+ (this you can do, but 
there is limited support)... they are mostly available to accomodate 
GtkD wrapping and therefore provide the functionality that GtkD needs.

-JJR



More information about the Digitalmars-d mailing list