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