1 (***********************************************************************)
3 (* MLTk, Tcl/Tk interface of Objective Caml *)
5 (* Francois Rouaix, Francois Pessaux, Jun Furuse and Pierre Weis *)
6 (* projet Cristal, INRIA Rocquencourt *)
7 (* Jacques Garrigue, Kyoto University RIMS *)
9 (* Copyright 2002 Institut National de Recherche en Informatique et *)
10 (* en Automatique and Kyoto University. All rights reserved. *)
11 (* This file is distributed under the terms of the GNU Library *)
12 (* General Public License, with the special exception on linking *)
13 (* described in file LICENSE found in the Objective Caml source tree. *)
15 (***********************************************************************)
16 (* This examples is based on Ousterhout's book (fig 16.15) *)
21 let mbar = Frame.create top [Relief Raised; BorderWidth (Pixels 2)]
23 Frame.create top [Width (Centimeters 10.); Height (Centimeters 5.)] in
24 pack [mbar; dummy] [Side Side_Top; Fill Fill_X];
25 let file = Menubutton.create mbar [Text "File"; UnderlinedChar 0]
26 and edit = Menubutton.create mbar [Text "Edit"; UnderlinedChar 0]
27 and graphics = Menubutton.create mbar [Text "Graphics"; UnderlinedChar 0]
28 and text = Menubutton.create mbar [Text "Text"; UnderlinedChar 0]
29 and view = Menubutton.create mbar [Text "View"; UnderlinedChar 0]
30 and help = Menubutton.create mbar [Text "Help"; UnderlinedChar 0] in
31 pack [file;edit;graphics;text;view] [Side Side_Left];
32 pack [help] [Side Side_Right];
33 (* same code as chap16-14 *)
34 let m = Menu.create text [] in
35 let bold = Textvariable.create()
36 and italic = Textvariable.create()
37 and underline = Textvariable.create() in
38 Menu.add_checkbutton m [Label "Bold"; Variable bold];
39 Menu.add_checkbutton m [Label "Italic"; Variable italic];
40 Menu.add_checkbutton m [Label "Underline"; Variable underline];
42 let font = Textvariable.create() in
43 Menu.add_radiobutton m [Label "Times"; Variable font; Value "times"];
44 Menu.add_radiobutton m [Label "Helvetica"; Variable font; Value "helvetica"]
46 Menu.add_radiobutton m [Label "Courier"; Variable font; Value "courier"];
48 Menu.add_command m [Label "Insert Bullet";
49 Command (function () ->
50 print_string "Insert Bullet\n";
52 Menu.add_command m [Label "Margins and Tags...";
53 Command (function () ->
54 print_string "margins\n";
56 Menubutton.configure text [Menu m];
63 Printexc.catch main ()