module ComboTextTree: sig .. end
Module for building a set (structured in a tree hierarchy) of dependent combo texts.
Any change of the selected value of a particular node, cause the rebuilding
of the choice list of all its descendents in the tree.
Class definition
class comboTextTree : generator:((string, string) Environment.env -> string list) -> msg:(string, string) Environment.env -> key:string -> callback:(string -> unit) option -> packing:(GObj.widget -> unit) option -> object .. end
A ComboTextTree is a combo with eventually some dependent childs (or slaves).
Constructors and convenient API
type choice = string
A choice is simply a string.
type choices = choice list
The type choices represent a choice list, of course.
val make : generator:((string, choice) Environment.env ->
choice list) ->
msg:(string, choice) Environment.env ->
key:string ->
callback:(choice -> unit) option ->
packing:(GObj.widget -> unit) option -> comboTextTree
The simplest and general constuctor. Simply calls the class constructor and initialize callbacks.
val fromList : ?key:string ->
?callback:(choice -> unit) option ->
?packing:(GObj.widget -> unit) option ->
choices -> comboTextTree
Make a simple combo text with no childs.
You can specify a
key (if you plan to affect some childs to this widget) and an additional
callback
fonction of type
choice -> unit, which will be called every time the user will modify its selection.
You also can specify a packing function. Examples:
Combo chains
Modelling a dependent chain of widgets: master -> slave -> slave -> ..
val fromListWithSlave : ?masterCallback:(choice -> unit) option ->
?masterPacking:(GObj.widget -> unit) option ->
choices ->
?slaveCallback:(choice -> unit) option ->
?slavePacking:(GObj.widget -> unit) option ->
(choice -> choices) ->
comboTextTree
Make a two level chain of dependent combos text. You can access to the slave simply writing
master#slave
(
slave is simply an alias for the child number 0). Example :
let distrib = fromListWithSlave
~masterPacking: (Some (dialog#table#attach ~left:2 ~top:4 ~right:4))
["debian";"redhat";"suse"]
~slavePacking: (Some (dialog#table#attach ~left:2 ~top:5 ~right:4))
MSys.patchListOf ;;
val fromListWithSlaveWithSlave : ?masterCallback:(choice -> unit) option ->
?masterPacking:(GObj.widget -> unit) option ->
choices ->
?slaveCallback:(choice -> unit) option ->
?slavePacking:(GObj.widget -> unit) option ->
(choice -> choices) ->
?slaveSlaveCallback:(choice -> unit) option ->
?slaveSlavePacking:(GObj.widget -> unit) option ->
(choice ->
choice -> choices) ->
comboTextTree
Make a 3 levels chain of dependent combos text. You can access the slave simply writing master#slave,
and the slave of the slave simply writing master#slave#slave.
val fromListWithSlaveWithSlaveWithSlave : ?masterCallback:(choice -> unit) option ->
?masterPacking:(GObj.widget -> unit) option ->
choices ->
?slaveCallback:(choice -> unit) option ->
?slavePacking:(GObj.widget -> unit) option ->
(choice -> choices) ->
?slaveSlaveCallback:(choice -> unit) option ->
?slaveSlavePacking:(GObj.widget -> unit) option ->
(choice ->
choice -> choices) ->
?slaveSlaveSlaveCallback:(choice -> unit) option ->
?slaveSlaveSlavePacking:(GObj.widget -> unit) option ->
(choice ->
choice ->
choice -> choices) ->
comboTextTree
Make a 4 levels chain of dependent combos text. You can access the slave chain simply by
master#slave, master#slave#slave and master#slave#slave#slave.
Simple tree constructor
Modelling a dependent tree of widgets:
master
/ \
slave0 slave1
val fromListWithTwoSlaves : ?masterCallback:(choice -> unit) option ->
?masterPacking:(GObj.widget -> unit) option ->
choices ->
?slave1Callback:(choice -> unit) option ->
?slave1Packing:(GObj.widget -> unit) option ->
(choice -> choices) ->
?slave2Callback:(choice -> unit) option ->
?slave2Packing:(GObj.widget -> unit) option ->
(choice -> choices) ->
comboTextTree
Make a simple tree with 3 nodes: a root combo with two combos (dependent) childs (which can be accessed with the handlers
master#slave0 and master#slave1). This function is in this API as an exemple. See the code in order to easily
define your own comboTextTree.