2002-04-26 05:16:26 -07:00
|
|
|
##ifdef CAMLTK
|
|
|
|
|
|
|
|
let cCAMLtoTKxEvent = function
|
|
|
|
| Activate -> "Activate"
|
|
|
|
| ButtonPress -> "ButtonPress"
|
|
|
|
| ButtonPressDetail n -> "ButtonPress-"^string_of_int n
|
|
|
|
| ButtonRelease -> "ButtonRelease"
|
|
|
|
| ButtonReleaseDetail n -> "ButtonRelease-"^string_of_int n
|
|
|
|
| Circulate -> "Circulate"
|
|
|
|
| ColorMap -> "Colormap"
|
|
|
|
| Configure -> "Configure"
|
|
|
|
| Deactivate -> "Deactivate"
|
|
|
|
| Destroy -> "Destroy"
|
|
|
|
| Enter -> "Enter"
|
|
|
|
| Expose -> "Expose"
|
|
|
|
| FocusIn -> "FocusIn"
|
|
|
|
| FocusOut -> "FocusOut"
|
|
|
|
| Gravity -> "Gravity"
|
|
|
|
| KeyPress -> "KeyPress"
|
|
|
|
| KeyPressDetail s -> "KeyPress-"^s
|
|
|
|
| KeyRelease -> "KeyRelease"
|
|
|
|
| KeyReleaseDetail s -> "KeyRelease-"^s
|
|
|
|
| Leave -> "Leave"
|
|
|
|
| Map -> "Map"
|
|
|
|
| Motion -> "Motion"
|
|
|
|
| Property -> "Property"
|
|
|
|
| Reparent -> "Reparent"
|
|
|
|
| Unmap -> "Unmap"
|
2010-01-22 04:48:24 -08:00
|
|
|
| Visibility -> "Visibility"
|
2002-04-26 05:16:26 -07:00
|
|
|
| Virtual s -> "<"^s^">"
|
|
|
|
;;
|
|
|
|
|
|
|
|
let cCAMLtoTKmodifier = function
|
|
|
|
| Control -> "Control-"
|
|
|
|
| Shift -> "Shift-"
|
|
|
|
| Lock -> "Lock-"
|
|
|
|
| Button1 -> "Button1-"
|
|
|
|
| Button2 -> "Button2-"
|
|
|
|
| Button3 -> "Button3-"
|
|
|
|
| Button4 -> "Button4-"
|
|
|
|
| Button5 -> "Button5-"
|
|
|
|
| Double -> "Double-"
|
|
|
|
| Triple -> "Triple-"
|
|
|
|
| Mod1 -> "Mod1-"
|
|
|
|
| Mod2 -> "Mod2-"
|
|
|
|
| Mod3 -> "Mod3-"
|
|
|
|
| Mod4 -> "Mod4-"
|
|
|
|
| Mod5 -> "Mod5-"
|
|
|
|
| Meta -> "Meta-"
|
|
|
|
| Alt -> "Alt-"
|
|
|
|
;;
|
|
|
|
|
|
|
|
exception IllegalVirtualEvent
|
|
|
|
|
|
|
|
(* type event = modifier list * xEvent *)
|
|
|
|
let cCAMLtoTKevent (ml, xe) =
|
|
|
|
match xe with
|
2010-01-22 04:48:24 -08:00
|
|
|
| Virtual s ->
|
2002-04-26 05:16:26 -07:00
|
|
|
if ml = [] then "<<"^s^">>"
|
|
|
|
else raise IllegalVirtualEvent
|
|
|
|
| _ ->
|
2010-01-22 04:48:24 -08:00
|
|
|
"<" ^ (String.concat " " (List.map cCAMLtoTKmodifier ml))
|
2002-04-26 05:16:26 -07:00
|
|
|
^ (cCAMLtoTKxEvent xe) ^ ">"
|
|
|
|
;;
|
2010-01-22 04:48:24 -08:00
|
|
|
|
2002-04-26 05:16:26 -07:00
|
|
|
(* type eventSequence == (modifier list * xEvent) list *)
|
|
|
|
let cCAMLtoTKeventSequence l =
|
|
|
|
TkToken(List.fold_left (^) "" (List.map cCAMLtoTKevent l))
|
|
|
|
|
|
|
|
##else
|
|
|
|
|
1999-12-16 00:37:38 -08:00
|
|
|
let cCAMLtoTKmodifier : modifier -> string = function
|
2000-02-16 03:51:37 -08:00
|
|
|
| `Control -> "Control-"
|
1999-12-16 00:37:38 -08:00
|
|
|
| `Shift -> "Shift-"
|
|
|
|
| `Lock -> "Lock-"
|
|
|
|
| `Button1 -> "Button1-"
|
|
|
|
| `Button2 -> "Button2-"
|
|
|
|
| `Button3 -> "Button3-"
|
|
|
|
| `Button4 -> "Button4-"
|
|
|
|
| `Button5 -> "Button5-"
|
|
|
|
| `Double -> "Double-"
|
|
|
|
| `Triple -> "Triple-"
|
|
|
|
| `Mod1 -> "Mod1-"
|
|
|
|
| `Mod2 -> "Mod2-"
|
|
|
|
| `Mod3 -> "Mod3-"
|
|
|
|
| `Mod4 -> "Mod4-"
|
|
|
|
| `Mod5 -> "Mod5-"
|
|
|
|
| `Meta -> "Meta-"
|
|
|
|
| `Alt -> "Alt-"
|
2002-04-26 05:16:26 -07:00
|
|
|
;;
|
|
|
|
|
|
|
|
exception IllegalVirtualEvent
|
1999-12-16 00:37:38 -08:00
|
|
|
|
|
|
|
let cCAMLtoTKevent (ev : event) =
|
2002-04-26 05:16:26 -07:00
|
|
|
let modified = ref false in
|
1999-12-16 00:37:38 -08:00
|
|
|
let rec convert = function
|
2002-04-26 05:16:26 -07:00
|
|
|
| `Activate -> "Activate"
|
|
|
|
| `ButtonPress -> "ButtonPress"
|
|
|
|
| `ButtonPressDetail n -> "ButtonPress-"^string_of_int n
|
|
|
|
| `ButtonRelease -> "ButtonRelease"
|
|
|
|
| `ButtonReleaseDetail n -> "ButtonRelease-"^string_of_int n
|
|
|
|
| `Circulate -> "Circulate"
|
|
|
|
| `Colormap -> "Colormap"
|
|
|
|
| `Configure -> "Configure"
|
|
|
|
| `Deactivate -> "Deactivate"
|
|
|
|
| `Destroy -> "Destroy"
|
|
|
|
| `Enter -> "Enter"
|
|
|
|
| `Expose -> "Expose"
|
|
|
|
| `FocusIn -> "FocusIn"
|
|
|
|
| `FocusOut -> "FocusOut"
|
|
|
|
| `Gravity -> "Gravity"
|
|
|
|
| `KeyPress -> "KeyPress"
|
|
|
|
| `KeyPressDetail s -> "KeyPress-"^s
|
|
|
|
| `KeyRelease -> "KeyRelease"
|
|
|
|
| `KeyReleaseDetail s -> "KeyRelease-"^s
|
|
|
|
| `Leave -> "Leave"
|
|
|
|
| `Map -> "Map"
|
|
|
|
| `Motion -> "Motion"
|
|
|
|
| `Property -> "Property"
|
|
|
|
| `Reparent -> "Reparent"
|
|
|
|
| `Unmap -> "Unmap"
|
|
|
|
| `Visibility -> "Visibility"
|
2010-01-22 04:48:24 -08:00
|
|
|
| `Virtual s ->
|
2002-07-23 07:12:03 -07:00
|
|
|
if !modified then raise IllegalVirtualEvent else "<"^s^">"
|
2002-04-26 05:16:26 -07:00
|
|
|
| `Modified(ml, ev) ->
|
2002-07-23 07:12:03 -07:00
|
|
|
modified := true;
|
|
|
|
String.concat ~sep:"" (List.map ~f:cCAMLtoTKmodifier ml)
|
|
|
|
^ convert ev
|
1999-12-16 00:37:38 -08:00
|
|
|
in "<" ^ convert ev ^ ">"
|
2002-04-26 05:16:26 -07:00
|
|
|
;;
|
1999-11-30 06:59:39 -08:00
|
|
|
|
2010-01-22 04:48:24 -08:00
|
|
|
let cCAMLtoTKeventSequence (l : event list) =
|
2000-04-11 20:43:25 -07:00
|
|
|
TkToken(String.concat ~sep:"" (List.map ~f:cCAMLtoTKevent l))
|
2002-04-26 05:16:26 -07:00
|
|
|
;;
|
1999-11-30 06:59:39 -08:00
|
|
|
|
2002-04-26 05:16:26 -07:00
|
|
|
##endif
|