COMMUTER.OMS
Script File:
# Description:
# Illustrates the use of the available GUI controls in O-Matrix.
#
#
dialogHandle = "Campus Commuter Form"
# call back to print dialog control values
function showControls() begin
for i = 1 to arg(0) begin
print getcontrol( arg(i) )
end
end
# create a dialog window
width = 450
height = 370
adddialog(dialogHandle,[100,0,width,height],"","normal");
# Use a radiobutton control to select the commuter type
rh = addcontrol(dialogHandle,[5,height/3,90,25], ...
"radiobuttons", ...
{"Student","Staff","Faculty"})
# Use check box controls to select commute days
ch1 = addcontrol(dialogHandle,[95,height/3,100,25],"checkbox","Monday")
ch2 = addcontrol(dialogHandle,[95,height/3+25,100,25],"checkbox","Tuesday")
ch3 = addcontrol(dialogHandle,[95,height/3+50,100,25],"checkbox","Wednesday")
ch4 = addcontrol(dialogHandle,[95,height/3+75,100,25],"checkbox","Thursday")
ch5 = addcontrol(dialogHandle,[95,height/3+100,100,25],"checkbox","Friday")
# Use a textfield control to get the commuter's name
addcontrol(dialogHandle,[220,height/3,50,25],"label","Name:");
f1=addcontrol(dialogHandle,[280,height/3,100,25],"textfield","Jane Doe")
# load a bitmap
bitmapWidth = 110
bitmapHeight = 110
addcontrol(dialogHandle, ...
[width/2-bitmapWidth/2,5,bitmapWidth,bitmapHeight], ...
"bitmap",[OM_INSTALL,"\example\gui\commuter.bmp"]);
# a popup menu to list the available parking lots
addcontrol(dialogHandle,[220,height/3+30,50,25],"label","Mail:");
p1=addcontrol(dialogHandle, ...
[280,height/3+30,100,80], ...
"popupmenu", ...
{"HN10","HW4","GH6","GK11","JR15"}, 1)
# label controls to display the commuter's travel distance
addcontrol(dialogHandle,[20,height/3+150,150,40], ...
"label","Commute Distance:");
labelHandle = addcontrol(dialogHandle,[170,height/3+150,30,25], ...
"label","1")
# a call back to adjust the commute distance field when the
# slider control is adjusted
function slider(labelHandle, sliderHandle) begin
setcontrol(labelHandle, ntoa(getcontrol(sliderHandle)) );
end
# a horizontal slider control ranging from 1 to 50
# to read the commuter's travel distance
sliderHandle = addcontrol(dialogHandle,[210,height/3+150,175,15], ...
"slider",1,50,"slider(labelHandle,sliderHandle)")
# a push button to print the control values and close the dialog
addcontrol(dialogHandle, ...
[width/2 - 30,height - 70,60,20], ...
"pushbutton","Done", ...
"done(dialogHandle)");
# call back to close the dialog window
function done() begin
# display the control' values
global rh,ch1,ch2,ch3,ch4,ch5,f1,p1,sliderHandle
showControls(rh,ch1,ch2,ch3,ch4,ch5,f1,p1,sliderHandle)
# delete the dialog
delwin(arg(1))
end
Output:
|