summaryrefslogtreecommitdiff
path: root/otherlibs/labltk/frx/frx_lbutton.ml
blob: c4d51f7b595aca1c8bf5c1dda35a268a5948889d (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
(***********************************************************************)
(*                                                                     *)
(*                 MLTk, Tcl/Tk interface of Objective Caml            *)
(*                                                                     *)
(*    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 Objective Caml source tree. *)
(*                                                                     *)
(***********************************************************************)
open Camltk

open Widget


let version = "$Id$"

(*
 * Simulate a button with a bitmap AND a label
 *)

let rec sort_options but lab com = function
    [] -> but,lab,com
  |(Command f as o)::l -> sort_options (o::but) lab com l
  |(Bitmap b as o)::l -> sort_options (o::but) lab com l
  |(Text t as o)::l -> sort_options but (o::lab) com l
  |o::l -> sort_options but lab (o::com) l

let create parent options =
  let but,lab,com = sort_options [] [] [] options in
  let f = Frame.create parent com in
  let b = Button.create f (but@com)
  and l = Label.create f (lab@com) in
    pack [b;l][];
    bind l [[],ButtonPressDetail 1] (BindSet ([],(function _ -> Button.invoke b)));
    f

let configure f options =
  let but,lab,com = sort_options [] [] [] options in
  match Pack.slaves f with
    [b;l] ->
      Frame.configure f com;
      Button.configure b (but@com);
      Label.configure l (lab@com)
  | _ -> raise (Invalid_argument "lbutton configure")