RolloutCreator Functions

RolloutCreator is a structure of functions for dynamically creating rollouts. The functions are implemented by a script located under stdplugs\stdscripts\baseLib\rolloutCreator.ms

Here are the implemented functions and their usage:

rolloutCreator <rollout_name> <rollout_caption> 	 

Creates an instance of rolloutCreator, assign it to a variable,

FOR EXAMPLE

rci = rolloutCreator "myRollout" "My Rollout"

   

<rollout_creator>.begin()   

This function needs to be called immediately after the instance is created, this does the initialization

   

<rollout_creator>.addControl <control_type> <control_name> <control_caption> [  paramStr:<string>] 

Adds a control to the rollout:

   

<control_type> 

can be any of named rolloutControls eg: #button, #spinner, #activeXControl etc.

   

<control_name> 

variable name of the control by which it is referred eg: #btnButton

   

<control_caption> 

caption of the control "My Button"

   

[paramStr:] 

an optional string representation of all the keyword parameters that needs to be passed to the control, for example: "width:100 height:20 align:#right"

FOR EXAMPLE

rci.addControl #button #myButton "My Button"

   

<rollout_creator>.addHandler <control_name> <event_type> [paramStr:<string>] [codeStr:<string>] [filter:<boolean>] 

Adds an event handler for the controls previously added:

   

<control_name> 

the variable passed during the control creation

   

<event_type> 

any of the events supported by the control, eg: #changed, #pressed, #selected

   

[paramStr:<string>] 

   

[codeStr:<string>] 

a string representation of the event handler code, if the string contains sub-strings, enclose them in two '@' characters and pass on\true to the filter: parameter

FOR EXAMPLE

rci.addHandler #myButton #pressed codeStr: "MessageBox @Hey@" filter:on

This will add an event handler for button named "myButton". When the button is clicked, a messagebox pops up with the text "hey" in it. The final result inside the rollout definition will look like this:

on myButton presseddoMessageBox "Hey"

ANOTHER EXAMPLE

rci.addHandler #myCheckbox #changed paramStr:"val" codeStr:"myOtherCheckbox.state = not val"

This will add an event handler for checkbox named "myCheckbox". When the state of the checkbox is changed, the state of another previously defined checkbox called "myOtherCheckbox" will also be changed to the inverted boolean value of the argument variable "val" which is passed the actual state of "myCheckbox". The final result inside the rollout definition will look like this:

on myCheckbox changed val do myOtherCheckbox.state = not val

   

<rollout_creator>.end() 

This function has to be called whenever all the required controls and their event handlers are called. This function forms the rollout string, evaluates it and returns the definition which can be passed to createDialog and addRollout functions.

   

<rollout_creator>.addLocal <string> [init:<value>] 

This function can be used to add local variables to the rollout definitions. The variable’s value can be initialized by passing the init: value

   

<string> 

Name of local variable

   

init: 

Specifies initialization value of local

   

<rollout_creator>.addText <string> [filter:<boolean>] 

This function is useful for adding functions to the rollout definitions. If the string contains sub-strings, enclose them in two '@' characters and pass true to the filter : parameter

   

<string> 

String added to rollout definition.

COMPLETE EXAMPLE:

rci = rolloutCreator "myRollout" "My Rollout"
rci.begin()
rci.addControl #button #myButton "My Button"
rci.addHandler #myButton #pressed filter:on codeStr:"MessageBox @Isn't this cool@ title:@Wow@"
createDialog (rci.end())

ANOTHER EXAMPLE:

rfTest = rolloutCreator "rfTestN" "rfTestC"
-- Start creating the rollout
rfTest.begin()
rfTest.addControl #button #myButton "My Button" -- add a button
rfTest.addHandler #myButton #pressed filter:on codeStr:"MessageBox @Look to the \@Light\@ thing@"
rfTest.end()
createDialog rfTest.def