How to modify the Gdk.gc of a GDraw.pixmap ?
stalkern2 at tin.it
Fri Oct 13 09:26:23 CEST 2006
Robert Roessler wrote:
> Stalkern 2 wrote:
>> I'm in trouble when trying to draw dotted lines and the like.
>> I have a GDraw.pixmap and I would like to use the function
>> Gdk.GC.set_dashes : Gdk.gc -> offset:int -> int list -> unit
>> on it.
>> But how do I access the Gdk.gc of a GDraw.pixmap _directly_?
>> Shall I create a new GC and then... ?
>> I feel like there is something that in spite of my copy of ocamlbrowser,
>> I can't browse very clearly yet ;-))
>> Thx for _any_ hint!
> 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.
> Robert Roessler
> robertr at rftp.com
Thanks for the hint. Now, I am attempting to do so, but code like this
let newGC =
Gdk.GC.create (Gdk.Drawable.cast (mypixmap#pixmap))
let () =
Gdk.GC.set_dashes newGC ~offset:0 [1;1]
(mypixmap #set_line_attributes ~style:`ON_OFF_DASH () )
does not allow me to go on with the new GC: after this code, the pixmap
shows not to use this "newGC", but its old one. What am I missing?
Thank you for any idea.
More information about the Lablgtk-list