REM ======================================================== REM scprtl20.DLL demonstration script. REM Color Preview REM (C) 1999 by Alex Vakulenko, http://www.vakcer.com/oberon REM ======================================================== #include "scprtl20.csi" ' =========== Script private declarations DECLARE SUB BuildPreview GLOBAL ImageFile$,r1&,g1&,b1&,r2&,g2&,b2&,r3&,g3&,b3& ' BMP image file to store previewa ImageFile$=GetTempFolder()+"demo_temp.bmp" ' ========== Main Dialog description BEGIN DIALOG OBJECT MainDialog 229, 178, "Color Selector", SUB MainDlgFunc GROUPBOX 4, 3, 173, 55, .GroupBox1, "Color1" TEXT 10, 15, 10, 8, .Text1, "R:" TEXT 10, 29, 10, 8, .Text2, "G:" TEXT 10, 43, 10, 8, .Text3, "B:" HSLIDER 20, 15, 66, 11, .R1 HSLIDER 20, 29, 66, 11, .G1 HSLIDER 20, 43, 66, 11, .B1 IMAGE 107, 16, 39, 35, .Color1 GROUPBOX 4, 61, 173, 55, .GroupBox2, "Color2" TEXT 10, 73, 10, 8, .Text4, "R:" TEXT 10, 87, 10, 8, .Text5, "G:" TEXT 10, 101, 10, 8, .Text6, "B:" HSLIDER 20, 73, 66, 11, .R2 HSLIDER 20, 87, 66, 11, .G2 HSLIDER 20, 101, 66, 11, .B2 IMAGE 107, 74, 39, 35, .Color2 GROUPBOX 4, 119, 174, 55, .GroupBox3, "Color3" TEXT 10, 131, 10, 8, .Text7, "R:" TEXT 10, 145, 10, 8, .Text8, "G:" TEXT 10, 159, 10, 8, .Text9, "B:" HSLIDER 20, 131, 66, 11, .R3 HSLIDER 20, 145, 66, 11, .G3 HSLIDER 20, 159, 66, 11, .B3 IMAGE 107, 132, 39, 35, .Color3 OKBUTTON 183, 8, 40, 14, .OK1 CANCELBUTTON 183, 29, 40, 14, .Cancel1 TEXT 97, 29, 8, 8, .Text10, "1:" TEXT 97, 79, 8, 8, .Text11, "2:" TEXT 89, 97, 15, 8, .Text12, "1+2:" TEXT 97, 136, 8, 8, .Text13, "1:" TEXT 149, 136, 8, 8, .Text14, ":2" TEXT 97, 155, 8, 8, .Text15, "3:" TEXT 149, 155, 25, 8, .Text16, ":1+2+3" END DIALOG '===== Dialog box even handler SUB MainDlgFunc(BYVAL ControlID%, BYVAL EventCode%) SELECT CASE EventCode CASE 0 BuildPreview ' Create preview CASE 2 SELECT CASE ControlID CASE MainDialog.R1.GETID() TO MainDialog.B1.GETID(), \\ MainDialog.R2.GETID() TO MainDialog.B2.GETID(), \\ MainDialog.R3.GETID() TO MainDialog.B3.GETID() r1=MainDialog.R1.GetValue() g1=MainDialog.G1.GetValue() b1=MainDialog.B1.GetValue() r2=MainDialog.R2.GetValue() g2=MainDialog.G2.GetValue() b2=MainDialog.B2.GetValue() r3=MainDialog.R3.GetValue() g3=MainDialog.G3.GetValue() b3=MainDialog.B3.GetValue() BuildPreview END SELECT END SELECT END SUB '=========================== Main Script Body ===================================== ' Initialize all dialog controls MainDialog.Color1.SetStyle 24 'Border and stretch image to fit MainDialog.Color2.SetStyle 24 MainDialog.Color3.SetStyle 24 MainDialog.R1.SetMinRange 0 MainDialog.R1.SetMaxRange 255 MainDialog.R1.SetIncrement 10 MainDialog.G1.SetMinRange 0 MainDialog.G1.SetMaxRange 255 MainDialog.G1.SetIncrement 10 MainDialog.B1.SetMinRange 0 MainDialog.B1.SetMaxRange 255 MainDialog.B1.SetIncrement 10 MainDialog.R2.SetMinRange 0 MainDialog.R2.SetMaxRange 255 MainDialog.R2.SetIncrement 10 MainDialog.G2.SetMinRange 0 MainDialog.G2.SetMaxRange 255 MainDialog.G2.SetIncrement 10 MainDialog.B2.SetMinRange 0 MainDialog.B2.SetMaxRange 255 MainDialog.B2.SetIncrement 10 MainDialog.R3.SetMinRange 0 MainDialog.R3.SetMaxRange 255 MainDialog.R3.SetIncrement 10 MainDialog.G3.SetMinRange 0 MainDialog.G3.SetMaxRange 255 MainDialog.G3.SetIncrement 10 MainDialog.B3.SetMinRange 0 MainDialog.B3.SetMaxRange 255 MainDialog.B3.SetIncrement 10 DIALOG MainDialog ' Display dialog box STOP ' ======= Create preview of the selected font SUB BuildPreview MakeColor ImageFile,r1,g1,b1 ' Make 1x1 BMP image MainDialog.Color1.SetImage ImageFile ' Display the image in dialog box IMAGE control MakeColor2 ImageFile,r2,g2,b2,(r1+r2)\2,(g1+g2)\2,(b1+b2)\2 ' Make 2x1 BMP image MainDialog.Color2.SetImage ImageFile ' Display the image in dialog box IMAGE control MakeColor4 ImageFile,r1,g1,b1,r2,g2,b2,r3,g3,b3,(r1+r2+r3)\3,(g1+g2+g3)\3,(b1+b2+b3)\3 ' Make 2x2 BMP image MainDialog.Color3.SetImage ImageFile ' Display the image in dialog box IMAGE control END SUB