WNGZWZSC0110֕!!!$(OO84#0You must have a sheet open to use this function.?@@? @ @ ? @ 4@-@ 4@-@,RQ@!@-4@"@-RQ@-4@#.@R@ 0@ 0@!0@!0@@ 0@!0@@ 0@!0@@ 0@!0@o@ 0@!0@-4@-4@9??>7D@#?@p`@ gWidth @<= >?> Default  Custom @ @e Cell Size@%!CALL CellSize.scz:DefaultSize()>>7J99.,@,@9.,4@,4@n9.,|n@,|n@:6#2Cannot change Cell Size, current_units are unknown@ 99\ @ 0@ @ 0@92@@9 @#0 0@ @#0 0@  ={Gz??< >  ={Gz??< >  9b92@@9\ @"0 @"0e9\ @#0 @#0 =?< > =?< > 99\ @!0@ @!0@9 @"0!0@ @"0!0@;92@@  ={Gz??< >  ={Gz??< >@ 9O9p@?"0@?"0  >  >9T@?@?  >  >y9p@?#0@?#0  >  >9D > 0@ > 0@{9(  >  >M9D >!0@ >!0@9@>@>7s@?"0@?"0@ 9 (@ 9 9@>@>7W@?@?@ 9 (@ 9 9@>@>7s@?#0@?#0@ 9 (@ 9  ok_button cell_height cell_width user_height user_widthcurrent_units IN_INCHES IN_POINTSIN_CMS INCH_BUTTON POINT_BUTTON CMS_BUTTON DEFAULT_BUTTON CUSTOM_BUTTON STND_HEIGHT_IN_INCHSTND_HEIGHT_IN_PTSSTND_HEIGHT_IN_CMSSTND_WIDTH_IN_INCHSTND_WIDTH_IN_PTSSTND_WIDTH_IN_CMSMIN_WIDTH_IN_INCHMIN_WIDTH_IN_PTSMIN_WIDTH_IN_CMSMIN_HEIGHT_IN_INCHMIN_HEIGHT_IN_PTSMIN_HEIGHT_IN_CMSMAX_WIDTH_IN_INCHMAX_WIDTH_IN_PTSMAX_WIDTH_IN_CMSMAX_HEIGHT_IN_INCHMAX_HEIGHT_IN_PTSMAX_HEIGHT_IN_CMS PtsToInch PtsToCm! InchToPts"CmToPts# CellSizeConvertUnits DefaultSize~ FreeTime { CellSize() This script was developed by Informix to demonstrate how to design a dialog box, save information from the dialog after it is closed, attach functions to controls, use the ON MOUSEUP event, and change the cell height and width. There are several functions in this file: CellSize - this is the main function, it displays the dialog and calls all of the other functions DefaultSize - this function is called when either the Default or or Custom buttons are pushed, it saves and restores the default value of the number wheels FreeTime - this function is called when a MOUSEUP occurs ConvertUnits - this function is called when the user presses either the Points or Inches buttons, and it converts the units in the number wheels Conventions: HyperScript keywords and functions are in all capital letters, user functions are in proper case, and variables are in lower case. Some variables are used as constants (i.e. they are defined and initialized, but are never changed), these always appear in all capital letters. TO USE THIS SCRIPT: To add this function to a menu, add the following to your Startup script: SELECT MENU "~Sheet"; ADD MENUITEM "Set Cell Size..." COMMAND "GET SCRIPT ""/usr/lpp/Wingz/Examples/CellSize.scz""; CALL CellSize.scz:CellSize(); REMOVE SCRIPT ""CellSize.scz"";"; You can then access the function by going to the "Sheet" menu and selecting the command from the menu. } { Variable List } DEFINE ok_button { A flag to hold the status of the } { OK button when the dialog closes. } { It is equal to TRUE() or FALSE(). } DEFINE cell_height { Store the value of the number wheels} DEFINE cell_width { in these vars if the OK button is } { pressed. This is so we can remember } { what size to make the cell after } { the dialog box is gone. } DEFINE user_height { These hold the values of the number } DEFINE user_width { wheels while the dialog is active } DEFINE current_units { Holds the current units being used } { in the number wheels, it is equal to} { either IN_INCHES,IN_POINTS or IN_CMS} { Variables used as Constants } DEFINE IN_INCHES { These constants are used to keep } DEFINE IN_POINTS { track of what units the values in } DEFINE IN_CMS { wheels are currently displayed in. } DEFINE INCH_BUTTON { These constants are used in IF's } DEFINE POINT_BUTTON { that involve testing which button is} DEFINE CMS_BUTTON { currently active. We don't have to } { setup constants for this, but it is } DEFINE DEFAULT_BUTTON { clearer when you read the code to } DEFINE CUSTOM_BUTTON { see a button name instead of just } { seeing a number. } DEFINE STND_HEIGHT_IN_INCH { These constants are initialized } DEFINE STND_HEIGHT_IN_PTS { to the Standard Height/Width of a } DEFINE STND_HEIGHT_IN_CMS { cell, if you have a startup script } DEFINE STND_WIDTH_IN_INCH { that defines a different cell size } DEFINE STND_WIDTH_IN_PTS { you should change the initialization} DEFINE STND_WIDTH_IN_CMS { of STND_HEIGHT_IN_PTS and } { STND_WIDTH_IN_PTS. } DEFINE MIN_WIDTH_IN_INCH { These constants define the } DEFINE MIN_WIDTH_IN_PTS { minimum cell width and height } DEFINE MIN_WIDTH_IN_CMS { allowed. If you want a different } DEFINE MIN_HEIGHT_IN_INCH { valid range, change the initiali- } DEFINE MIN_HEIGHT_IN_PTS { zation of MIN_HEIGHT_IN_PTS and } DEFINE MIN_HEIGHT_IN_CMS { MIN_WIDTH_IN_PTS. } DEFINE MAX_WIDTH_IN_INCH { These constants define the } DEFINE MAX_WIDTH_IN_PTS { maximum cell width and height } DEFINE MAX_WIDTH_IN_CMS { allowed. If you want a different } DEFINE MAX_HEIGHT_IN_INCH { valid range, change the initiali- } DEFINE MAX_HEIGHT_IN_PTS { zation of MAX_HEIGHT_IN_PTS and } DEFINE MAX_HEIGHT_IN_CMS { MAX_WIDTH_IN_PTS. } DEFINE PtsToInch, PtsToCm { These are conversion constants used } DEFINE InchToPts { when switching between units. } DEFINE CmToPts { It is not any faster to use a } { variable in the conversion } { equations, but it is a clearer when } { you are looking at the equation. } CALL CellSize(); { CellSize() This function displays the dialog box which gives the user the option of defining the cell size in either Points, Inches, or Centimeters. These options are defined with Radio Buttons. The user can define the Height and Width by using the Number Wheels or typing the values in. The user can also reset the cell size to the default size by pressing the Default button or recall the last Custom size defined before the Default button was pushed. The height and width of the current cell (or upper-left cell of a range) are displayed in the number wheels. If the values in the number wheels ever equal the standard or default size the Default button is activated to indicate that the current values are the defaults. } FUNCTION CellSize() IF (ISERR(NAME())) { check if there is a sheet open } MESSAGE "You must have a sheet open to use this function." EXIT SCRIPT END IF IN_POINTS = 1 { Initialize the constants used with } IN_INCHES = 2 { the current_units flag. } IN_CMS = 3 POINT_BUTTON = 1 { Initialize the constants used for } INCH_BUTTON = 2 { testing the active units button. } CMS_BUTTON = 3 DEFAULT_BUTTON = 1 { Initialize the constants used for } CUSTOM_BUTTON = 2 { testing which Cell Size button is on } { Initialize the conversion constants. } { When you define anything about the } { screen in Wingz, like control } { placement, it is done in TWIPS. To } { make converting clearer we can use } PtsToInch = 20 / 1440 { these constants. } PtsToCm = 20 / 1440 * 2.54 { There are 20 TWIPS / Point } InchToPts = 1440 / 20 { 1440 TWIPS / Inch } CmToPts = 1440 / 2.54 / 20 { 2.54 Centimeters / Inch } { Initialize the standard or default } { height and width of a cell. Define } { the size in points and then calculate } { the default size in inches & cm. } { These are used with the buttons that } { save/restore the default size in } { the ON MOUSEUP function FreeTime(). } STND_HEIGHT_IN_PTS = 15 STND_WIDTH_IN_PTS = 74 STND_HEIGHT_IN_INCH = ROUND((STND_HEIGHT_IN_PTS * PtsToInch),2) STND_WIDTH_IN_INCH = ROUND((STND_WIDTH_IN_PTS * PtsToInch),2) STND_HEIGHT_IN_CMS = ROUND((STND_HEIGHT_IN_PTS * PtsToCm),2) STND_WIDTH_IN_CMS = ROUND((STND_WIDTH_IN_PTS * PtsToCm),2) MIN_WIDTH_IN_PTS = 6 MIN_WIDTH_IN_INCH = ROUND((MIN_WIDTH_IN_PTS * PtsToInch),2) MIN_WIDTH_IN_CMS = ROUND((MIN_WIDTH_IN_PTS * PtsToCm),2) MIN_HEIGHT_IN_PTS = 6 MIN_HEIGHT_IN_INCH = ROUND((MIN_HEIGHT_IN_PTS * PtsToInch),2) MIN_HEIGHT_IN_CMS = ROUND((MIN_HEIGHT_IN_PTS * PtsToCm),2) MAX_WIDTH_IN_PTS = 512 MAX_WIDTH_IN_INCH = ROUND((MAX_WIDTH_IN_PTS * PtsToInch),2) MAX_WIDTH_IN_CMS = ROUND((MAX_WIDTH_IN_PTS * PtsToCm),2) MAX_HEIGHT_IN_PTS = 255 MAX_HEIGHT_IN_INCH = ROUND((MAX_HEIGHT_IN_PTS * PtsToInch),2) MAX_HEIGHT_IN_CMS = ROUND((MAX_HEIGHT_IN_PTS * PtsToCm),2) { Get the size of the current cell and } { use these values for the Custom value.} { By convention in this script, the } { user defined height/width are stored } { in points and converted to inches or } { cm as needed. } { Divide the result returned } { by ROWHEIGHT and COLUMNWIDTH by 20, } { because those functions return the } { cell size in TWIPS and there are 20 } { TWIPS in 1 Point. } user_height = ROUND(ROWHEIGHT()/20,0) user_width = ROUND(COLUMNWIDTH()/20,0) IF ((NRSELECTIONS() = 0) { Test if at least one cell is selected } OR (SELECTIONTYPE(1) <> 1)) MESSAGE "You must select a cell range before executing this function." EXIT SCRIPT END IF { END IF an invalid range is selected. } { Define the dialog box here. } { This box will have ... } { -a title with a line under it } { -radio buttons to select the units } { being used to define the size of } { the cell } { -number wheels to define the height } { and width of the cell } { -radio buttons to select either the } { the default cell size or a user- } { defined custom size. } { -OK and Cancel buttons } { Define a dialog box of the specified } { height and width that is centered on } { the screen. } { The (-1,-1) means center this box on } { the screen. The second set of } { coordinates specify the size of the } { box. } NEW MODAL DIALOG BOX AT (-1,-1) (4inch,3inch) NAME DIALOG BOX "Set Cell Size" { Give a title to the dialog box } { Define a MOUSEUP function, it is } { called when the mouse button is } { released } SCRIPT "ON MOUSEUP CALL CellSize.scz:FreeTime() END MOUSEUP" { Add two buttons, the OK and CANCEL } { buttons in the specified } { rectangle, these will be controls } { one and two. } { CONTROLS 1 and 2 } ADD PUSH BUTTON "OK@","Cancel@" AT (0.5inch,2.5inch) (3.5inch,2.9inch) DIALOG CANCEL PUSH BUTTON { Specify an action for the CANCEL } { button, which is the current control } { because it was the last one added. } SELECT CONTROL 1 { Select the OK button. It was the } { first control added so it has the } { control number of 1. Make the OK } DIALOG DEFAULT PUSH BUTTON { button the default control, which } { means it will have a wider border } { and can be selected by pressing the } { Enter key. } { Specify what should happen when the } { OK button is pressed } { -set the OK flag } { -save the current value of the } { wheels. } SCRIPT "CellSize.scz:ok_button = TRUE() "& "CellSize.scz:cell_height = CTVALUE(5,0) "& "CellSize.scz:cell_width = CTVALUE(6,0) " { Add radio buttons so the user can } { select the units to use to define the } { cell size. When any of the buttons } { are pressed, the function } { ConvertUnits will be called. } { CONTROL 3 } ADD RADIO BUTTON "Points", "Inches", "Centi@meters" AT (0.1inch,0.1inch) (1.9inch,1.3inch) SHOW CONTROL TITLE "Units@" OUTLINE 2 BORDER SCRIPT "CALL CellSize.scz:ConvertUnits() " { CONTROL 4 } ADD CUSTOM BUTTON AT (2.1inch,0.1inch) (3.9inch,2.3inch) SHOW CONTROL TITLE "Size@" OUTLINE 2 BORDER DISABLE CONTROL { When the dialog is first activated, } { display the cell size in Points. } { If we wanted to come up in Inches or } { Cm, we would use the RADIO BUTTON # } { statement to set a different button } { on, we would also have to initialize } { current_units to the appropriate } current_units = IN_POINTS { units constant. } { Add a label for the first number } { wheel. We could add a title } { when we define the wheel, but by } { defining the text separately, we have } { more control over the placement of } { text in the dialog. } { Define the number wheel that will } { control the cell height. Because we } { decided to default to displaying the } { cell size in Points, we use the } { minimum/maximum constants that are } { in points to define the range of the } { wheel. Because points are always } { integer values, we set the precision } { to 0 and the step to 1. } { CONTROL 5 } ADD NUMBER WHEEL AT (2.2inch,0.65inch) (3.8inch,1.15inch) SHOW CONTROL NAME "Height@" NUMBER WHEEL RANGE MIN_HEIGHT_IN_PTS TO MAX_HEIGHT_IN_PTS NUMBER WHEEL STEP 1 NUMBER WHEEL POSITION user_height NUMBER WHEEL PRECISION 0 { Dulplicate the code used to add the } { height title and number wheel, except } { that we use the WIDTH constants. } { CONTROL 6 } ADD NUMBER WHEEL AT (2.2inch,1.5inch) (3.8inch,2inch) SHOW CONTROL NAME "Width @" NUMBER WHEEL RANGE MIN_WIDTH_IN_PTS TO MAX_WIDTH_IN_PTS NUMBER WHEEL STEP 1 NUMBER WHEEL POSITION user_width NUMBER WHEEL PRECISION 0 { Add two buttons so the user can } { select to either have the wheels } { equal the default size or a custom } { value. When either of the buttons } { are pressed, the function } { DefaultSize will be called. } { CONTROL 7 } ADD RADIO BUTTON "Default ","Custom " AT (0.1inch,1.4inch) (1.9inch,2.3inch) SHOW CONTROL TITLE "Cell Size@" OUTLINE 2 BORDER SCRIPT "CALL CellSize.scz:DefaultSize()" IF (user_height <> STND_HEIGHT_IN_PTS) OR (user_width <> STND_WIDTH_IN_PTS) RADIO BUTTON 2 END IF USE DIALOG BOX { Now that we have the dialog defined, } { we tell Wingz to display it. This } { dialog will stay on the screen until } { the user selects either the OK or } { CANCEL button. } { The user has exited the dialog box } { by either pressing the OK or CANCEL } { button, if they selected the OK } { button, the variable ok_button will } { be set to TRUE (because the script } { attached to the OK button sets it } { to TRUE and saves the values of the } { number wheels) thus we should change } IF (ok_button = TRUE()) { the cell size. } { At this point we know we want to } { change the cell size, but we have to } { convert from whatever the current } CASE (current_units) { units the user was using into TWIPS. } WHEN (IN_INCHES) { If the user was defining the size in } { inches, we multiply by 1440 becuase } { there are 1440 TWIPS / Inch. } ROW HEIGHT cell_height * 1440 COLUMN WIDTH cell_width * 1440 WHEN (IN_POINTS) { If the user was defining the size in } { points, we multiply by 20 becuase } { there are 20 TWIPS / Point. } ROW HEIGHT cell_height * 20 COLUMN WIDTH cell_width * 20 WHEN (IN_CMS) { If the user was defining the size in } { centimeters, we multiply by 566.9 } { because there are that many TWIPS / } { centimeter. } ROW HEIGHT (cell_height * 566.929134) COLUMN WIDTH (cell_width * 566.929134) OTHERWISE { This part of the CASE should never } { be executed because one of the above } { WHEN's should always be TRUE, but } { we will display a message to the } { user in the unlikely event that all } { of the WHEN's fail. } MESSAGE "Cannot change Cell Size, current_units are unknown" END CASE END IF { END IF the user pushed the OK button } END FUNCTION { END FUNCTION CellSize() } { ConvertUnits() This function handles the conversion of the number wheels between the available units and sets the wheels to the appropriate values. Because this function is called everytime any of the buttons are pushed, we have to make sure the user hasn't pressed the same button that was already on, if we did this we would be trying to convert from the current units to the same units and the size would be incorrect. } FUNCTION ConvertUnits() DEFINE c_height, c_width { Converted_HEIGHT, Converted_WIDTH } { These are temporary variables used } { when converting between the } { different units. } CASE (CTVALUE(3,0)) { Determine which button is pushed. } WHEN (INCH_BUTTON) { Now we know what button is down, } { next we need to determine the units } { currently being used and do the } { appropriate conversion (or none if } { we are already in inches). } CASE (current_units) WHEN (IN_POINTS) { Convert Points to Inches } SELECT CONTROL 5 c_height = ROUND((CTVALUE(5,0)*PtsToInch),2) SELECT CONTROL 6 c_width = ROUND((CTVALUE(6,0)*PtsToInch),2) WHEN (IN_INCHES) { We don't need to convert, we are } { already in inches so just read the } { current wheel values into the vars } { that hold the converted values. } { We have to initialize the local vars } { because we always position the } { wheels after this CASE stmt. If } { we didn't put something in the vars } { here, we would end up trying to set } { the wheels to 0. } c_height = CTVALUE(5,0) c_width = CTVALUE(6,0) WHEN (IN_CMS) { Convert Centimeters to Points and } { then convert Points to Inches. This } { roundabout way of converting is to } { avoid a rounding error caused by } { going directly from cm to inches. } SELECT CONTROL 5 c_height = ROUND((CTVALUE(5,0)*CmToPts),0) c_height = ROUND((c_height*PtsToInch),2) SELECT CONTROL 6 c_width = ROUND((CTVALUE(6,0)*CmToPts),0) c_width = ROUND((c_width*PtsToInch),2) END CASE { END CASE current_units } { Regardless of what type of } { conversion happens, the STEP, PREC, } { and RANGE need to be set for Inches. } SELECT CONTROL 5 NUMBER WHEEL STEP .01 NUMBER WHEEL PRECISION 2 NUMBER WHEEL RANGE MIN_HEIGHT_IN_INCH TO MAX_HEIGHT_IN_INCH NUMBER WHEEL POSITION c_height SELECT CONTROL 6 NUMBER WHEEL STEP .01 NUMBER WHEEL PRECISION 2 NUMBER WHEEL RANGE MIN_WIDTH_IN_INCH TO MAX_WIDTH_IN_INCH NUMBER WHEEL POSITION c_width current_units = IN_INCHES { Set the current_units flag to inches. } WHEN (POINT_BUTTON) { Same as the WHEN (INCH_BUTTON) logic. } CASE (current_units) WHEN (IN_POINTS) { See the comments in WHEN(INCH_BUTTON).} c_height = CTVALUE(5,0) c_width = CTVALUE(6,0) WHEN (IN_INCHES) { Convert Inches to Points. } SELECT CONTROL 5 c_height = ROUND((CTVALUE(5,0)*InchToPts),0) SELECT CONTROL 6 c_width = ROUND((CTVALUE(6,0)*InchToPts),0) WHEN (IN_CMS) { Convert Centimeters to Points. } SELECT CONTROL 5 c_height = ROUND((CTVALUE(5,0)*CmToPts),0) SELECT CONTROL 6 c_width = ROUND((CTVALUE(6,0)*CmToPts),0) END CASE { END CASE current_units } { Regardless of what type of } { conversion happens, the STEP, PREC, } { and RANGE need to be set for Points. } SELECT CONTROL 5 NUMBER WHEEL STEP 1 NUMBER WHEEL PRECISION 0 NUMBER WHEEL RANGE MIN_HEIGHT_IN_PTS TO MAX_HEIGHT_IN_PTS NUMBER WHEEL POSITION c_height SELECT CONTROL 6 NUMBER WHEEL STEP 1 NUMBER WHEEL PRECISION 0 NUMBER WHEEL RANGE MIN_WIDTH_IN_PTS TO MAX_WIDTH_IN_PTS NUMBER WHEEL POSITION c_width current_units = IN_POINTS { Set the current_units flag to points. } WHEN (CMS_BUTTON) { Same as the WHEN (INCH_BUTTON) logic. } CASE (current_units) WHEN (IN_POINTS) { Convert Points to Centimeters. } SELECT CONTROL 5 c_height = ROUND((CTVALUE(5,0)*PtsToCm),2) SELECT CONTROL 6 c_width = ROUND((CTVALUE(6,0)*PtsToCm),2) WHEN (IN_INCHES) { Convert Inches to Points and then } { convert Points to Centimeters. This } { roundabout way of converting is to } { avoid a rounding error caused by } { going from inches to cm. } SELECT CONTROL 5 c_height = ROUND((CTVALUE(5,0)*InchToPts),0) c_height = ROUND((c_height*PtsToCm),2) SELECT CONTROL 6 c_width = ROUND((CTVALUE(6,0)*InchToPts),0) c_width = ROUND((c_width*PtsToCm),2) WHEN (IN_CMS) { See the comments in WHEN(INCH_BUTTON).} c_height = CTVALUE(5,0) c_width = CTVALUE(6,0) END CASE { END CASE current_units } { Regardless of what type of } { conversion happens, the STEP, PREC, } { and RANGE need to be set for Cm. } SELECT CONTROL 5 NUMBER WHEEL STEP .01 NUMBER WHEEL PRECISION 2 NUMBER WHEEL RANGE MIN_HEIGHT_IN_CMS TO MAX_HEIGHT_IN_CMS NUMBER WHEEL POSITION c_height SELECT CONTROL 6 NUMBER WHEEL STEP .01 NUMBER WHEEL PRECISION 2 NUMBER WHEEL RANGE MIN_WIDTH_IN_CMS TO MAX_WIDTH_IN_CMS NUMBER WHEEL POSITION c_width current_units = IN_CMS { Set the current_units flag to cm } END CASE { END CASE of which Units button is } { currently active. } END FUNCTION { END FUNCTION ConvertUnits() } { DefaultSize() This function toggles the values in the number wheels between the default cell size and the last non-default size that was in the wheel. For example, if the user positions the wheels to 1 inch tall and 3 inches wide, and then presses the Default button, the current values are saved and then the wheels will be positioned using the variables STND_HEIGHT_IN_INCH and STND_WIDTH_IN_INCH. If the user then presses the Custom button, the wheels will be positioned using the variables user_height and user_width. } FUNCTION DefaultSize() IF (CTVALUE(7,0) = DEFAULT_BUTTON) { The Default button is pushed so we } { need to save the current user } { settings and set the wheels to the } { default values. } { Because the user could be using any } { units when this button is pushed, } { we will use the convention of } { always saving the current "user" } { setting in points, and then when } { restoring we can check to see what } { the current units are and convert. } CASE (current_units) WHEN (IN_INCHES) { Convert to points and save the user } { defined size. } user_height = ROUND((CTVALUE(5,1)*InchToPts),0) user_width = ROUND((CTVALUE(6,1)*InchToPts),0) SELECT CONTROL 5 { Restore the wheels to stnd inches. } NUMBER WHEEL POSITION STND_HEIGHT_IN_INCH SELECT CONTROL 6 NUMBER WHEEL POSITION STND_WIDTH_IN_INCH WHEN (IN_POINTS) user_height = CTVALUE(5,1) { Save the user's settings. } user_width = CTVALUE(6,1) SELECT CONTROL 5 { Restore the wheels to stnd points } NUMBER WHEEL POSITION STND_HEIGHT_IN_PTS SELECT CONTROL 6 NUMBER WHEEL POSITION STND_WIDTH_IN_PTS WHEN (IN_CMS) { Convert to points and save the user } { defined size. } user_height = ROUND((CTVALUE(5,1)*CmToPts),0) user_width = ROUND((CTVALUE(6,1)*CmToPts),0) SELECT CONTROL 5 { Restore the wheels to stnd cm. } NUMBER WHEEL POSITION STND_HEIGHT_IN_CMS SELECT CONTROL 6 NUMBER WHEEL POSITION STND_WIDTH_IN_CMS END CASE ELSE { The Custom button is pushed. } CASE (current_units) { We need to figure out which units to } { restore the wheels to. } WHEN (IN_INCHES) SELECT CONTROL 5 NUMBER WHEEL POSITION ROUND((user_height*PtsToInch),2) SELECT CONTROL 6 NUMBER WHEEL POSITION ROUND((user_width*PtsToInch),2) WHEN (IN_POINTS) SELECT CONTROL 5 NUMBER WHEEL POSITION user_height SELECT CONTROL 6 NUMBER WHEEL POSITION user_width WHEN (IN_CMS) SELECT CONTROL 5 NUMBER WHEEL POSITION ROUND((user_height*PtsToCm),2) SELECT CONTROL 6 NUMBER WHEEL POSITION ROUND((user_width*PtsToCm),2) END CASE END IF { END IF the Default button was on } END FUNCTION { END FUNCTION DefaultSize() } { FreeTime() During "a mouseup", we will check the values in the number wheels and update the status of the Default and Custom buttons. If the values in the wheels are BOTH equal to the Default Cell Size and the Default button has not already been activated, we will push it. Also, we will save the values of the wheels if they are anything EXCEPT the default values, this way we will always have the current value the user has selected in case we switch to the Default size and later want to switch back to the custom values. } FUNCTION FreeTime() { The CASE construct is used so we } { know what the current units in the } { wheels are so we can test them } { appropriatly. } { All of the WHEN's are basically the } { the same, first we test the wheels } { for nondefault values, if they are } { anything but the defaults, } { we save the current settings and } { then check to see if the Custom } { button is pushed. } CASE (current_units) WHEN (IN_INCHES) { If either of the wheels are "custom" } { or non-default values, save both the } { wheel values into the user_height } { and user_width variables and push } { the Custom button. } IF ((VALUE(CTSTRING(5,0)) <> STND_HEIGHT_IN_INCH) OR (VALUE(CTSTRING(6,0)) <> STND_WIDTH_IN_INCH)) user_height = ROUND((CTVALUE(5,1)*InchToPts),0) user_width = ROUND((CTVALUE(6,1)*InchToPts),0) IF (CTVALUE(7,0) = DEFAULT_BUTTON) SELECT CONTROL 7 RADIO BUTTON 2 { Push the Custom button } END IF { If BOTH of the wheels were equal to } { the default values, check to see if } { the Default button is pushed, if } { not, go ahead and push it. } ELSEIF (CTVALUE(7,0) = CUSTOM_BUTTON) SELECT CONTROL 7 RADIO BUTTON 1 { Push the Default button. } END IF WHEN (IN_POINTS) { Same logic as WHEN (IN_INCHES) } IF ((VALUE(CTSTRING(5,0)) <> STND_HEIGHT_IN_PTS) OR (VALUE(CTSTRING(6,0)) <> STND_WIDTH_IN_PTS)) user_height = CTVALUE(5,1) user_width = CTVALUE(6,1) IF (CTVALUE(7,0) = DEFAULT_BUTTON) SELECT CONTROL 7 RADIO BUTTON 2 { Push the Custom button. } END IF { Same logic as WHEN (IN_INCHES). } ELSEIF (CTVALUE(7,0) = CUSTOM_BUTTON) SELECT CONTROL 7 RADIO BUTTON 1 { Push the Default button. } END IF WHEN (IN_CMS) { Same logic as WHEN (IN_INCHES). } IF ((VALUE(CTSTRING(5,0)) <> STND_HEIGHT_IN_CMS) OR (VALUE(CTSTRING(6,0)) <> STND_WIDTH_IN_CMS)) user_height = ROUND((CTVALUE(5,1)*CmToPts),0) user_width = ROUND((CTVALUE(6,1)*CmToPts),0) IF (CTVALUE(7,0) = DEFAULT_BUTTON) SELECT CONTROL 7 RADIO BUTTON 2 { Push the Custom button. } END IF { Same logic as WHEN (IN_INCHES). } ELSEIF (CTVALUE(7,0) = CUSTOM_BUTTON) SELECT CONTROL 7 RADIO BUTTON 1 { Push the Default button. } END IF END CASE { END CASE current_units } END FUNCTION { END FUNCTION FreeTime() }