RE : drawing in a textview

"MONATE Benjamin 205998" <[email protected]>
Newsgroups gmane.comp.lang.ocaml.lib.gtk
Message-ID <[email protected]>
Hi,

Here is your example working as expected :

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 _ =
    view#event#connect#expose (fun _ ->
     let drawing_to = match view#get_window `TEXT 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; false)
      in
      GMain.Main.main ()



Benjamin Monate
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.