[Lablgtk] drawing in a textview

Jacques Le Normand rathereasy at gmail.com
Wed May 14 04:18:05 CEST 2008


I'm trying to draw a rectangle on a textview, as in:

http://www.mail-archive.com/gtk-app-devel-list@gnome.org/msg09087.html

and I came up with

open Gobject
let _ =
  let source_window = GWindow.window () in
  let buffer = GText.buffer () in
  let view = GText.view ~buffer:buffer ~packing:source_window#add  () in
    source_window#show ();
    source_window#maximize ();
    let drawing_to = match view#get_window `WIDGET with Some a -> a | None
-> raise (Failure "unexpected") in
    let gc = Gdk.GC.create drawing_to in
    let red = Gdk.Color.alloc (Gdk.Color.get_system_colormap ()) (`NAME
"red") in
      Gdk.GC.set_foreground gc red;
      Gdk.GC.set_background gc red;
      Gdk.GC.set_fill gc `SOLID;
      Gdk.Draw.rectangle drawing_to gc ~x:10 ~y:10 ~width:300 ~height:400
~filled:true ();
      Gdk.Draw.line drawing_to gc 5 5 100 100;
      GMain.Main.main ();

unfortunately, nothing gets drawn. Anyone have any suggestions?
--Jacques
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ocamlcore.org/pipermail/lablgtk-list/attachments/20080513/16ccd554/attachment.htm>
-------------- next part --------------
_______________________________________________
Lablgtk mailing list
Lablgtk at yquem.inria.fr
http://yquem.inria.fr/cgi-bin/mailman/listinfo/lablgtk


More information about the Lablgtk-list mailing list