type string_state =
View_only
| Editable
| Edited
;;
type string_type =
Gr_string
| Gr_natural
| Gr_int
| Gr_hexa
| Gr_float
| Gr_password
;;
type gr_string =
{ st_window : gr_window
; mutable st_top : int
; mutable st_left : int
; mutable st_width : int
; mutable st_type : string_type
; mutable st_name : string
; mutable st_cursor : int
; mutable st_1st_char : int
; mutable st_state : string_state
; mutable st_callback : gr_string -> event -> bool
}
;;
An object of type gr_string is a line where the user can
edit a text or a number. The user clicks on the object with the mouse
button. Then he can edit the text with the keyboard (functions
keys or mouse can be use to set the cursor place). The management of
the object depends on the value of the variable st_type:
- st_type=Gr_natural. the user can only use the digit keys.
The up and down keys increase or decrease the value of the
displayed number,
- st_type=Gr_int. The user can use the digit keys and the
minus key. As with natural, the up and down keys increase or
decrease the number value,
- st_type=Gr_float. The user can only type a floating point
number.
- st_type=Gr_string. The user can type any string,
- st_type=Gr_password. The user can type any string, but the
character '*' is displayed instead of the typed keys.
The input line objects are defined by:
- the attached window (st_window)
- the coordinates of lower left corner (st_left, st_top),
- the width (st_width),
- the type of string that can be typed, as described above
(st_type),
- the contents of the edited line (st_name),
- the present position of the cursor (st_cursor),
- the number of the first char of the string that is
displayed (st_1st_char),
- the state of the object (st_state), that can take the
values:
- View_only, when the user can't modify the line,
- Editable, when the user can modify the line, but is not
doing this at the present time,
- Edited, when the user is modifying the line.
- the callback function, which is called when the user
presses the return key (st_callback).
The functions linked with gr_string are:
gr_draw_string : gr_string -> unit
- gr_draw_string String draws the object String.
gr_string_managed : gr_string -> event -> bool
- is the function used by Camlwin to manage the input line objects.