How to modify the Gdk.gc of a GDraw.pixmap ?

Jacques Garrigue garrigue at math.nagoya-u.ac.jp
Fri Oct 13 10:20:21 CEST 2006


From: Stalkern 2 <stalkern2 at tin.it>

> > I would say to do a GC.create call supplying the drawable (pixmap in
> > this case) that you want to work with.
> > 
> > Also, if it helps, a pixmap does not "have" a gc in the sense of owning
> > one - you create a gc with an exemplar pixmap for the purpose of [for
> > example] drawing into that pixmap - or others like it.
> > 
> > Finally, note that set_dashes is just setting an attribute (a "value" in
> > Gdk-land)... you will need to supply that gc along with a compatible
> > drawable to a "draw" function to actually get your dotted lines.
> > 
> 
> OK, now I see, I have to draw with a function accepting a Gdk.gc, like
> 
> 	Gdk.Draw.line : [> `drawable ] Gobject.obj -> Gdk.gc -> x:int -> y:int
> -> x:int -> y:int -> unit
> 
> Thanks A LOT (thanks A DOT?)

You can also rewrap the pixmap, with a new GC, in a new wrapper object
that lets you access (and modify) this GC.

class add_gc (pm : #GDraw.pixmap) =
  object
    inherit GDraw.pixmap pm#pixmap ?mask:pm#mask
    method color = pm#color
    method gc = gc
  end

There should probably be methods to access the gc and the colormap in
the original drawable class, this would avoid all these problems...
Even bettern, one could be allowed to switch gc's.

Jacques




More information about the Lablgtk-list mailing list