home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1998 October A
/
Pcwk10a98.iso
/
Corel
/
Ventura8
/
Ventura
/
Scripts
/
GuideWizard.csc
< prev
next >
Wrap
Text File
|
1998-07-08
|
34KB
|
829 lines
REM Sets up guidelines [CorelSCRIPT 8]
REM GuideWizard.csc February 6, 1998
REM ⌐ 1998 Corel Corporation. All rights reserved.
REM **************************************************************************************
REM This script creates guidelines. The user can choose from a selection of pre-defined
REM grids, or create their own custom look.
REM **************************************************************************************
' Create a temporary folder to provide a path for the include files
' -this enables the include files to be located
#addfol "..\..\Scripts"
#include "ScpConst.csi"
#include "VPConst.csi"
' Embed bitmaps if script is to be compiled into exe or csb formats
' -this will eliminate the need to include these files
#ADDRESBMP IntroBMP "Bitmaps\IntroBMP.bmp"
#ADDRESBMP Step2BMP "Bitmaps\Step2BMP.bmp"
#ADDRESBMP Grid1BMP "Bitmaps\Grid1.bmp"
#ADDRESBMP Grid2BMP "Bitmaps\Grid2.bmp"
#ADDRESBMP Grid3BMP "Bitmaps\Grid3.bmp"
#ADDRESBMP Grid4BMP "Bitmaps\Grid4.bmp"
#ADDRESBMP Grid5BMP "Bitmaps\Grid5.bmp"
#ADDRESBMP Grid6BMP "Bitmaps\Grid6.bmp"
'Constants for Dialog Return Values
GLOBAL CONST DIALOG_RETURN_CANCEL% = 2
GLOBAL CONST DIALOG_RETURN_NEXT% = 3
GLOBAL CONST DIALOG_RETURN_BACK% = 4
'Constants for pre-defined grids or style
GLOBAL CONST COLS3_ROWS6% = 0 '3 columns, 5 rows
GLOBAL CONST COLS3_ROWS5% = 1 '3 columns, 5 rows
GLOBAL CONST COLS4_ROWS5% = 2 '4 columns, 5 rows
GLOBAL CONST COLS12_ROWS9% = 3 '12 columns, 9 rows
GLOBAL CONST COLS6_ROWS17% = 4 '6 columns, 17 rows
GLOBAL CONST COLS7_ROWS9% = 5 '7 columns, 9 rows
GLOBAL CONST CUSTOM_GUIDES% = 6 'Custom
'Constants for unit selection
GLOBAL CONST UNITS_INCHES% = 1
GLOBAL CONST UNITS_MILLIMETERS% = 2
GLOBAL CONST UNITS_PICAS_POINTS% = 3
GLOBAL CONST UNITS_POINTS% = 4
GLOBAL CONST UNITS_CICEROS_DIDOTS% = 5
GLOBAL CONST UNITS_DIDOTS% = 6
'Constants for page view
GLOBAL CONST PAGE_CURRENT% = 0
GLOBAL CONST PAGE_MASTER% = 1
'/////FUNCTION & SUBROUTINE DECLARATIONS/////////////////////////////////////////
DECLARE SUB RegQuery()
DECLARE SUB MakeGuides()
DECLARE FUNCTION ShowIntro%()
DECLARE FUNCTION GetStyle%()
DECLARE FUNCTION GetCustom%()
DECLARE FUNCTION ShowFinish%()
DECLARE FUNCTION ToCicerosDidots#(Value#)
DECLARE FUNCTION FromCicerosDidots&(Value#)
DECLARE FUNCTION ToPicasPoints#(Value#)
DECLARE FUNCTION FromPicasPoints&(Value#)
'/////GLOBAL VARIABLES //////////////////////////////////////////////////////////
GLOBAL VenturaRoot$ 'root directory where Ventura is installed
GLOBAL StyleOption& 'identifes which style (or pre-defined grid) to create
GLOBAL Columns% 'number of guide columns
GLOBAL Rows% 'number of guide rows
GLOBAL LeftMargin# 'spacing for the left margin
GLOBAL RightMargin# 'spacing for the right margin
GLOBAL TopMargin# 'spacing for the top margin
GLOBAL BottomMargin# 'spacing for the bottom margin
GLOBAL HorzGutter# 'spacing for horizontal gutters
GLOBAL VertGutter# 'spacing for vertical gutters
GLOBAL GutterUnits% 'units specifying gutter spacing
GLOBAL PrevGutterUnits% 'previous units specifying gutter spacing (used for conversions)
GLOBAL SpinDoubleMode AS BOOLEAN 'flag indicating mode of spin box: TRUE enable double mode; FALSE disable double mode
GLOBAL SpinPrecision& 'identifies amount of precision for spin control
GLOBAL SpinIncrement# 'identifes amount of increment for spin control
GLOBAL ShowGuides& 'indicates whether guides are shown: 1-show guides; 0-don't show guides
GLOBAL LockGuides& 'indicates whether guides are locked: 1-lock guides; 0-don't lock guides
GLOBAL PageOption& 'identifies the page view to use: 0-Page Layout; 1-Master Page
GLOBAL UseImage$ 'identifies the image to display in dialog box (represents user's selection of pre-defined guide)
GLOBAL RemoveExisting& 'indicates whether existing guides are to be removed: 1-remove existing guides; 0-don't remove existing guides
GLOBAL Units$(6) 'array containing list of available units
Units$(1) = "inches"
Units$(2) = "millimeters"
Units$(3) = "picas, points"
Units$(4) = "points"
Units$(5) = "ciceros, didots"
Units$(6) = "didots"
Rows% = 1 'initialize number of guide rows to 1
Columns% = 1 'initialize number of guide columns to 1
GutterUnits% = 1 'initialize units to first element - inches
HorzGutter# = FROMINCHES(0.05) 'initialize horizontal gutter to .05 of an inch
VertGutter# = FROMINCHES(0.05) 'initialize vertical gutter to .05 of an inch
ShowGuides& = 1 'initialize guides to be shown
RemoveExisting& = 1 'initialize existing guides to be removed
'////// LOCAL VARIABLES //////////////////////////////////////////////////////////////////////////////
MAXSTEP = 4 'maximum number of pages in the Wizard
DIM DialogReturn% 'identifies user's selection for next step in Wizard
DIM NextStep% 'specifies which page appears next in the Wizard
' **************************************************************************************
' MAIN
' **************************************************************************************
ON ERROR GOTO ErrorHandler
RegQuery 'get root directory where Ventura is installed
'this section controls traversal through the dialog pages
NextStep% = 1
DO
SELECT CASE NextStep%
CASE 1: DialogReturn% = ShowIntro() 'Show Intro dialog
CASE 2: DialogReturn% = GetStyle() 'Get style of grid to apply
CASE 3: DialogReturn% = GetCustom() 'custom style - get custom information
CASE 4: DialogReturn% = ShowFinish() 'Show finish dialog
END SELECT
NextStep% = NextStep%+ DialogReturn%
LOOP UNTIL NextStep% = MAXSTEP + 1
MakeGuides
ExitScript:
STOP
ErrorHandler:
SELECT CASE ErrNum
CASE 800
MESSAGE "FATAL ERROR" & CHR(13) & "Script will now exit."
RESUME AT ExitScript
CASE ELSE
MESSAGE "ERROR: " & STR(ErrNum) & CHR(13) & "Script will now exit."
RESUME AT ExitScript
END SELECT
' **************************************************************************************
' MakeGuides
' This function creates the guides lines in the selected style (or custom).
'
' PARAMS: None
'
' RETURNS: ShowIntro AS INTEGER - Integer indicating dialog return value(user selection)
' **************************************************************************************
SUB MakeGuides()
DIM PageOrientation AS BOOLEAN
'set columns, rows and gutters to appropriate values based on the selected style
SELECT CASE StyleOption&
CASE COLS3_ROWS6 '3 columns, 5 rows
Columns% = 3
Rows% = 6
VertGutter# = FROMINCHES(0.05)
HorzGutter# = FROMINCHES(0.05)
CASE COLS3_ROWS5 '3 columns, 5 rows
Columns% = 3
Rows% = 5
VertGutter# = FROMINCHES(0.05)
HorzGutter# = FROMINCHES(0.05)
CASE COLS4_ROWS5 '4 columns, 5 rows
Columns% = 3
Rows% = 5
VertGutter# = FROMINCHES(0.05)
HorzGutter# = FROMINCHES(0.05)
CASE COLS12_ROWS9 '12 columns, 9 rows
Columns% = 12
Rows% = 9
VertGutter# = FROMINCHES(0.05)
HorzGutter# = FROMINCHES(0.05)
CASE COLS6_ROWS17 '6 columns, 17 rows
Columns% = 6
Rows% = 17
VertGutter# = FROMINCHES(0.05)
HorzGutter# = FROMINCHES(0.05)
CASE COLS7_ROWS9 '7 columns, 9 rows
Columns% = 7
Rows% = 9
VertGutter# = FROMINCHES(0.05)
HorzGutter# = FROMINCHES(0.05)
CASE CUSTOM_GUIDES 'Custom"
END SELECT
WITHOBJECT OBJECT_VENTURA8
.SetVisible TRUE
'IF there aren't any open pubs, open one
IF .CountWindows() = 0 THEN .FileNew
'IF master page is selected, apply to both sides and switch view to MP
IF PageOption& = PAGE_MASTER THEN
.ViewMasterPage
MasterPageName$ = .CurrentMasterPage()
.ViewGotoMasterPage MasterPageName$, FALSE, 4
MasterPageFlag = TRUE
ELSEIF PageOption& = PAGE_CURRENT THEN
.ViewPageLayout
ENDIF
GuideStart:
'IF there are existing guides, and the user wants to, remove them
IF RemoveExisting& = 1 THEN
.PageFirstLine
IF .PageGuidelineCount(TRUE)>0 OR .PageGuidelineCount(FALSE)>0 THEN .PageGuidelineDelete , , TRUE
ENDIF
.FrameFirst TRUE
.FormatFrameMarginsInsideGet 3, LeftMarg&, RightMarg&, TopMarg&, BottomMarg&
LeftMargin# = CDBL(LeftMarg&) : RightMargin# = CDBL(RightMarg&)
TopMargin# = CDBL(TopMarg&) : BottomMargin# = CDBL(BottomMarg&)
.PageFirstLine
.FormatMasterPageGet PageOrientation, PaperType&, PageWidth&, PageHeight&
'create Vertical Guides
ColumnSpace& = (PageWidth& - (LeftMargin#+RightMargin#)-((Columns%-1)*VertGutter#)) / Columns%
.PageGuideLineAdd LeftMargin#, TRUE
Guide& = LeftMargin#
FOR i% = 1 TO Columns%-1
Guide& = Guide& + ColumnSpace&
.PageGuideLineAdd Guide&, TRUE
Guide& = Guide& + VertGutter#
.PageGuideLineAdd Guide&, TRUE
NEXT i%
.PageGuideLineAdd PageWidth&-RightMargin#, TRUE
IF StyleOption& = COLS4_ROWS5 THEN
.PageGuideLineAdd (PageWidth&*0.5)-(VertGutter#*0.5), TRUE
.PageGuideLineAdd (PageWidth&*0.5)+(VertGutter#*0.5), TRUE
ENDIF
'create Horizontal Guides
RowSpace& = (PageHeight& - (TopMargin#+BottomMargin#)-((Rows%-1)*HorzGutter#)) / Rows%
.PageGuideLineAdd TopMargin#, FALSE
Guide& = TopMargin#
FOR i% = 1 TO Rows%-1
Guide& = Guide& + RowSpace&
.PageGuideLineAdd Guide&, FALSE
Guide& = Guide& + HorzGutter#
.PageGuideLineAdd Guide&, FALSE
IF StyleOption& = COLS7_ROWS9 THEN
IF i% = 1 OR i% = 2 THEN
.PageGuidelineDelete Guide&, FALSE
.PageGuidelineDelete Guide&- HorzGutter#, FALSE
ENDIF
ENDIF
NEXT i%
.PageGuideLineAdd PageHeight&-BottomMargin#, FALSE
.PageGuideline CBOL(ShowGuides), CBOL(LockGuides&)
'IF master page is selected, draw lines on both sides
IF PageOption& = PAGE_MASTER AND MasterPageFlag = TRUE THEN
MasterPageFlag = FALSE
.ViewGotoMasterPage MasterPageName$, TRUE, 4
GOTO GuideStart
ENDIF
END WITHOBJECT
END SUB
' *******************************************************************************
' RegQuery
' This subroutine queries the Registry to determine the root directory where
' Ventura is installed.
' *******************************************************************************
SUB RegQuery
ON ERROR GOTO ErrorHandler
'get Ventura config directory
VentDir$ = REGISTRYQUERY(HKEY_LOCAL_MACHINE,VENTURA_REGQUERY_CONST,"ConfigDir")
'isolate Ventura root directory from Ventura config directory
first% = 1
pos% = 1
DO WHILE first <> 0
first = INSTR(VentDir$, "\", first )
IF first <> 0 THEN
pos = first
first = first + 1
END IF
LOOP
VenturaRoot$ = LEFT(VentDir$, pos - 1) 'root directory where Ventura is installed
EXIT SUB
ErrorHandler:
MESSAGE "Error reading registry:" & CHR(13) & RegString$
ErrNum = 800
END SUB
' *******************************************************************************
' ShowIntro
' This function displays the introduction dialog.
'
' PARAMS: None
'
' RETURNS: ShowIntro AS INTEGER - Integer indicating dialog return value.
' *******************************************************************************
FUNCTION ShowIntro%
BEGIN DIALOG OBJECT IntroDialog 290, 180, "Guidelines Wizard", SUB IntroDialogEventHandler
PUSHBUTTON 181, 160, 46, 14, .NextButton, "&Next >"
CANCELBUTTON 234, 160, 46, 14, .CancelButton
PUSHBUTTON 135, 160, 46, 14, .BackButton, "< &Back"
TEXT 95, 10, 185, 20, .Text2, "This wizard offers a selection of preset guidelines, or you can create your own custom guidelines."
TEXT 95, 40, 185, 12, .Text3, "To begin, click Next."
IMAGE 10, 10, 75, 130, .IntroImage
GROUPBOX 10, 150, 270, 5, .LineGroupBox
END DIALOG
IntroDialog.IntroImage.SetImage "#IntroBMP"
IntroDialog.IntroImage.SetStyle STYLE_IMAGE_CENTERED
IntroRet%=DIALOG(IntroDialog)
IF IntroRet% = DIALOG_RETURN_CANCEL THEN STOP
IF IntroRet% = DIALOG_RETURN_NEXT THEN ShowIntro = 1
END FUNCTION
' *******************************************************************************
' IntroDialogEventHandler
' This subroutine responds to user interface with the introduction dialog.
'
' PARAMS: BYVAL ControlID% - Integer indicating the dialog control that is
' generating a dialog event.
' BYVAL Event% - Integer indicating the dialog event that has occurred.
' *******************************************************************************
SUB IntroDialogEventHandler(BYVAL ControlID%, BYVAL Event%)
IF Event% = EVENT_INITIALIZATION THEN
IntroDialog.BackButton.Enable FALSE
ENDIF
IF Event% = EVENT_MOUSE_CLICK THEN
SELECT CASE ControlID%
CASE IntroDialog.NextButton.GetID()
IntroDialog.CloseDialog DIALOG_RETURN_NEXT
CASE IntroDialog.CancelButton.GetID()
IntroDialog.CloseDialog DIALOG_RETURN_CANCEL
END SELECT
ENDIF
END FUNCTION
' *******************************************************************************
' GetStyle
' This function prompts the user to select which style of guides to use: one of
' the pre-defined styles, or a user specified custom style.
'
' PARAMS: None
'
' RETURNS: GetStyle AS INTEGER - Integer indicating dialog return value.
' *******************************************************************************
FUNCTION GetStyle
BEGIN DIALOG OBJECT StyleDialog 290, 180, "Guidelines Wizard", SUB StyleDialogEventHandler
PUSHBUTTON 135, 160, 46, 14, .BackButton, "< &Back"
PUSHBUTTON 181, 160, 46, 14, .NextButton, "&Next >"
CANCELBUTTON 234, 160, 46, 14, .CancelButton
IMAGE 10, 10, 75, 130, .StyleImage
GROUPBOX 10, 150, 270, 5, .LineGroupBox
TEXT 95, 10, 185, 12, .Text5, "Select a preset style, or create a customized style."
OPTIONGROUP .StyleOptionGroup%
OPTIONBUTTON 115, 25, 100, 12, .Style1OptionButton, "3 columns, 6 rows"
OPTIONBUTTON 115, 40, 100, 12, .Style2OptionButton, "3 columns, 5 rows"
OPTIONBUTTON 115, 55, 100, 12, .Style3OptionButton, "4 columns, 5 rows"
OPTIONBUTTON 115, 70, 100, 12, .Style4OptionButton, "12 columns, 9 rows"
OPTIONBUTTON 115, 85, 100, 12, .Style5OptionButton, "6 columns, 17 rows"
OPTIONBUTTON 115, 100, 100, 12, .Style6OptionButton, "7 columns, 7 rows"
OPTIONBUTTON 115, 115, 100, 12, .CustomOptionButton, "Custom"
END DIALOG
SELECT CASE StyleOption&
CASE COLS3_ROWS6 '3 columns, 5 rows
UseImage$ = "#Grid1BMP"
CASE COLS3_ROWS5 '3 columns, 5 rows
UseImage$ = "#Grid2BMP"
CASE COLS4_ROWS5 '4 columns, 5 rows
UseImage$ = "#Grid3BMP"
CASE COLS12_ROWS9 '12 columns, 9 rows
UseImage$ = "#Grid4BMP"
CASE COLS6_ROWS17 '6 columns, 17 rows
UseImage$ = "#Grid5BMP"
CASE COLS7_ROWS9 '7 columns, 9 rows
UseImage$ = "#Grid6BMP"
CASE CUSTOM_GUIDES 'Custom"
UseImage$ = "#Grid1BMP"
END SELECT
StyleDialog.StyleImage.SetImage UseImage$
StyleDialog.StyleImage.SetStyle STYLE_IMAGE_CENTERED
StyleRet%=DIALOG(StyleDialog)
SELECT CASE StyleRet%
CASE DIALOG_RETURN_CANCEL
STOP
CASE DIALOG_RETURN_NEXT
StyleOption& = StyleDialog.StyleOptionGroup.GetValue()
IF StyleOption& = CUSTOM_GUIDES THEN
GetStyle = 1
ELSE
GetStyle = 2
ENDIF
CASE DIALOG_RETURN_BACK
GetStyle = -1
END SELECT
END FUNCTION
' *******************************************************************************
' StyleDialogEventHandler
' This subroutine responds to user interface with the style dialog.
'
' PARAMS: BYVAL ControlID% - Integer indicating the dialog control that is
' generating a dialog event.
' BYVAL Event% - Integer indicating the dialog event that has occurred.
' *******************************************************************************
SUB StyleDialogEventHandler(BYVAL ControlID%, BYVAL Event%)
IF Event% = EVENT_MOUSE_CLICK THEN
SELECT CASE ControlID%
CASE StyleDialog.NextButton.GetID()
StyleDialog.closedialog DIALOG_RETURN_NEXT
CASE StyleDialog.BackButton.GetID()
StyleDialog.closedialog DIALOG_RETURN_BACK
CASE StyleDialog.CancelButton.GetID()
StyleDialog.closedialog DIALOG_RETURN_CANCEL
CASE StyleDialog.Style1OptionButton.GetID()
UseImage$ = "#Grid1BMP"
CASE StyleDialog.Style2OptionButton.GetID()
UseImage$ = "#Grid2BMP"
CASE StyleDialog.Style3OptionButton.GetID()
UseImage$ = "#Grid3BMP"
CASE StyleDialog.Style4OptionButton.GetID()
UseImage$ = "#Grid4BMP"
CASE StyleDialog.Style5OptionButton.GetID()
UseImage$ = "#Grid5BMP"
CASE StyleDialog.Style6OptionButton.GetID()
UseImage$ = "#Grid6BMP"
CASE StyleDialog.CustomOptionButton.GetID()
UseImage$ = "#Step2BMP"
END SELECT
StyleDialog.StyleImage.SetImage UseImage$
ENDIF
END SUB
' *******************************************************************************
' GetCustom
' This function prompts the user for information for custom guidelines.
'
' PARAMS: None
'
' RETURNS: GetCustom AS INTEGER - Integer indicating dialog return value.
' *******************************************************************************
FUNCTION GetCustom
BEGIN DIALOG OBJECT CustomDialog 290, 180, "Guidelines Wizard", SUB CustomDialogEventHandler
TEXT 100, 40, 25, 12, .Text1, "R&ows:"
SPINCONTROL 130, 40, 40, 12, .RowSpin
TEXT 190, 40, 32, 12, .Text2, "&Columns:"
SPINCONTROL 230, 40, 40, 12, .ColumnSpin
TEXT 100, 105, 38, 8, .Text3, "Hori&zontal:"
SPINCONTROL 145, 102, 50, 12, .HorizontalSpin
DDLISTBOX 205, 101, 70, 60, .GutterUnitsDDListBox
TEXT 100, 125, 38, 8, .Text4, "&Vertical:"
SPINCONTROL 145, 121, 50, 12, .VerticalSpin
PUSHBUTTON 134, 160, 46, 14, .BackButton, "< &Back"
PUSHBUTTON 181, 160, 46, 14, .NextButton, "&Next >"
CANCELBUTTON 234, 160, 46, 14, .CancelButton
GROUPBOX 10, 150, 270, 5, .LineGroupBox
GROUPBOX 95, 90, 185, 50, .GroupBox3, "Gutters:"
TEXT 205, 125, 70, 12, .Text9, ""
IMAGE 10, 10, 75, 130, .CustomImage
TEXT 95, 10, 180, 16, .Text13, "Specify the number of rows and columns you would like to insert."
TEXT 95, 75, 185, 12, .Text7, "Specify the gutter settings that you would like to use."
END DIALOG
CustomDialog.CustomImage.SetImage UseImage$
CustomDialog.CustomImage.SetStyle STYLE_IMAGE_CENTERED
CustomDialog.RowSpin.SetMinRange 1
CustomDialog.RowSpin.SetValue Rows%
CustomDialog.ColumnSpin.SetMinRange 1
CustomDialog.ColumnSpin.SetValue Columns%
CustomDialog.HorizontalSpin.SetMinRange 0
CustomDialog.VerticalSpin.SetMinRange 0
CustomDialog.GutterUnitsDDListBox.SetArray Units$
CustomDialog.GutterUnitsDDListBox.SetSelect GutterUnits%
SELECT CASE GutterUnits%
CASE UNITS_INCHES
SpinDoubleMode = TRUE
SpinPrecision& = 5
CustomDialog.HorizontalSpin.SetValue TOINCHES(HorzGutter#)
CustomDialog.VerticalSpin.SetValue TOINCHES(VertGutter#)
CASE UNITS_MILLIMETERS
SpinDoubleMode = TRUE
SpinPrecision& = 3
CustomDialog.HorizontalSpin.SetValue HorzGutter#/10000
CustomDialog.VerticalSpin.SetValue VertGutter#/10000
CASE UNITS_PICAS_POINTS
SpinDoubleMode = TRUE
SpinPrecision& = 1
CustomDialog.HorizontalSpin.SetValue ToPicasPoints(HorzGutter#)
CustomDialog.VerticalSpin.SetValue ToPicasPoints(VertGutter#)
CASE UNITS_POINTS
SpinDoubleMode = TRUE
SpinPrecision& = 3
CustomDialog.HorizontalSpin.SetValue TOPOINTS(HorzGutter#)
CustomDialog.VerticalSpin.SetValue TOPOINTS(VertGutter#)
CASE UNITS_CICEROS_DIDOTS
SpinDoubleMode = TRUE
SpinPrecision& = 2
CustomDialog.HorizontalSpin.SetValue ToCicerosDidots(HorzGutter#)
CustomDialog.VerticalSpin.SetValue ToCicerosDidots(VertGutter#)
CASE UNITS_DIDOTS
SpinDoubleMode = TRUE
SpinPrecision& = 3
CustomDialog.HorizontalSpin.SetValue TODIDOTS(HorzGutter#)
CustomDialog.VerticalSpin.SetValue TODIDOTS(VertGutter#)
END SELECT
CustomDialog.HorizontalSpin.SetDoubleMode SpinDoubleMode
CustomDialog.HorizontalSpin.SetPrecision SpinPrecision&
CustomDialog.VerticalSpin.SetDoubleMode SpinDoubleMode
CustomDialog.VerticalSpin.SetPrecision SpinPrecision&
PrevGutterUnits% = GutterUnits%
CustomRet%=DIALOG(CustomDialog)
SELECT CASE CustomRet%
CASE DIALOG_RETURN_CANCEL
STOP
CASE DIALOG_RETURN_NEXT
GetCustom = 1
CASE DIALOG_RETURN_BACK
GetCustom = -1
END SELECT
END FUNCTION
' *******************************************************************************
' CustomDialogEventHandler
' This subroutine handles events for the custom dialog.
'
' PARAMS: BYVAL ControlID% - Integer indicating the dialog control that is
' generating a dialog event.
' BYVAL Event% - Integer indicating the dialog event that has occurred.
' *******************************************************************************
SUB CustomDialogEventHandler(BYVAL ControlID%, BYVAL Event%)
IF Event% = EVENT_INITIALIZATION THEN
GutterUnits% = CustomDialog.GutterUnitsDDListBox.GetSelect()
CustomDialog.Text9.SetText Units$(GutterUnits%)
ENDIF
IF Event% = EVENT_CHANGE_IN_CONTENT THEN
SELECT CASE ControlID%
CASE CustomDialog.HorizontalSpin.GetID()
IF GutterUnits% = UNITS_CICEROS_DIDOTS OR GutterUnits% = UNITS_PICAS_POINTS THEN
SpinVal# = CustomDialog.HorizontalSpin.GetValue()
IF SpinVal# - INT(SpinVal#) > 0.111 THEN
CustomDialog.HorizontalSpin.SetValue INT(SpinVal#) + 1
ENDIF
IF SpinVal# - INT(SpinVal#) > 0.90 THEN
CustomDialog.HorizontalSpin.SetValue INT(SpinVal#) + 0.11
ENDIF
ENDIF
CASE CustomDialog.VerticalSpin.GetID()
IF GutterUnits% = UNITS_CICEROS_DIDOTS OR GutterUnits% = UNITS_PICAS_POINTS THEN
SpinVal# = CustomDialog.VerticalSpin.GetValue()
IF SpinVal# - INT(SpinVal#) > 0.111 THEN
CustomDialog.VerticalSpin.SetValue INT(SpinVal#) + 1
ENDIF
IF SpinVal# - INT(SpinVal#) > 0.90 THEN
CustomDialog.VerticalSpin.SetValue INT(SpinVal#) + 0.11
ENDIF
ENDIF
END SELECT
ENDIF
IF Event% = EVENT_MOUSE_CLICK THEN
SELECT CASE ControlID%
CASE CustomDialog.NextButton.GetID()
Rows% = CustomDialog.RowSpin.GetValue()
Columns% = CustomDialog.ColumnSpin.GetValue()
SELECT CASE GutterUnits%
CASE UNITS_INCHES
VertGutter# = FROMINCHES(CustomDialog.VerticalSpin.GetValue())
HorzGutter# = FROMINCHES(CustomDialog.HorizontalSpin.GetValue())
CASE UNITS_MILLIMETERS
VertGutter# = (CustomDialog.VerticalSpin.GetValue())*10000
HorzGutter# = (CustomDialog.HorizontalSpin.GetValue())*10000
CASE UNITS_PICAS_POINTS
VertGutter# = FromPicasPoints(CustomDialog.VerticalSpin.GetValue())
HorzGutter# = FromPicasPoints(CustomDialog.HorizontalSpin.GetValue())
CASE UNITS_POINTS
VertGutter# = FROMPOINTS(CustomDialog.VerticalSpin.GetValue())
HorzGutter# = FROMPOINTS(CustomDialog.HorizontalSpin.GetValue())
CASE UNITS_CICEROS_DIDOTS
VertGutter# = FromCicerosDidots(CustomDialog.VerticalSpin.GetValue())
HorzGutter# = FromCicerosDidots(CustomDialog.HorizontalSpin.GetValue())
CASE UNITS_DIDOTS
VertGutter# = FROMDIDOTS(CustomDialog.VerticalSpin.GetValue())
HorzGutter# = FROMDIDOTS(CustomDialog.HorizontalSpin.GetValue())
END SELECT
CustomDialog.closedialog DIALOG_RETURN_NEXT
CASE CustomDialog.BackButton.GetID()
CustomDialog.closedialog DIALOG_RETURN_BACK
CASE CustomDialog.CancelButton.GetID() 'Cancel
CustomDialog.closedialog DIALOG_RETURN_CANCEL
CASE CustomDialog.HorizontalSpin.GetID()
IF GutterUnits% = UNITS_CICEROS_DIDOTS OR GutterUnits% = UNITS_PICAS_POINTS THEN
SpinVal# = CustomDialog.HorizontalSpin.GetValue()
IF SpinVal# - INT(SpinVal#) > 0.111 THEN
CustomDialog.HorizontalSpin.SetValue INT(SpinVal#) + 1
ENDIF
IF SpinVal# - INT(SpinVal#) > 0.90 THEN
CustomDialog.HorizontalSpin.SetValue INT(SpinVal#) + 0.11
ENDIF
ENDIF
CASE CustomDialog.VerticalSpin.GetID()
IF GutterUnits% = UNITS_CICEROS_DIDOTS OR GutterUnits% = UNITS_PICAS_POINTS THEN
SpinVal# = CustomDialog.VerticalSpin.GetValue()
IF SpinVal# - INT(SpinVal#) > 0.111 THEN
CustomDialog.VerticalSpin.SetValue INT(SpinVal#) + 1
ENDIF
IF SpinVal# - INT(SpinVal#) > 0.90 THEN
CustomDialog.VerticalSpin.SetValue INT(SpinVal#) + 0.11
ENDIF
ENDIF
CASE CustomDialog.GutterUnitsDDListBox.GetID()
GutterUnits% = CustomDialog.GutterUnitsDDListBox.GetSelect()
CustomDialog.Text9.SetText Units$(GutterUnits%)
'get current readings and convert to tenths of a micron
SELECT CASE PrevGutterUnits%
CASE UNITS_INCHES
HorzGutter# = FROMINCHES(CustomDialog.HorizontalSpin.GetValue())
VertGutter# = FROMINCHES(CustomDialog.VerticalSpin.GetValue())
CASE UNITS_MILLIMETERS
HorzGutter# = (CustomDialog.HorizontalSpin.GetValue())*10000
VertGutter# = (CustomDialog.VerticalSpin.GetValue())*10000
CASE UNITS_PICAS_POINTS
HorzGutter# = FromPicasPoints(CustomDialog.HorizontalSpin.GetValue())
VertGutter# = FromPicasPoints(CustomDialog.VerticalSpin.GetValue())
CASE UNITS_POINTS
HorzGutter# = FROMPOINTS(CustomDialog.HorizontalSpin.GetValue())
VertGutter# = FROMPOINTS(CustomDialog.VerticalSpin.GetValue())
CASE UNITS_CICEROS_DIDOTS
HorzGutter# = FromCicerosDidots(CustomDialog.HorizontalSpin.GetValue())
VertGutter# = FromCicerosDidots(CustomDialog.VerticalSpin.GetValue())
CASE UNITS_DIDOTS
HorzGutter# = FROMDIDOTS(CustomDialog.HorizontalSpin.GetValue())
VertGutter# = FROMDIDOTS(CustomDialog.VerticalSpin.GetValue())
END SELECT
'display current readings in specified units
SELECT CASE GutterUnits%
CASE UNITS_INCHES
SpinDoubleMode = TRUE
SpinPrecision& = 5
CustomDialog.HorizontalSpin.SetValue TOINCHES(HorzGutter#)
CustomDialog.VerticalSpin.SetValue TOINCHES(VertGutter#)
CASE UNITS_MILLIMETERS
SpinDoubleMode = TRUE
SpinPrecision& = 3
CustomDialog.HorizontalSpin.SetValue HorzGutter#/10000
CustomDialog.VerticalSpin.SetValue VertGutter#/10000
CASE UNITS_PICAS_POINTS
SpinDoubleMode = TRUE
SpinPrecision& = 1
CustomDialog.HorizontalSpin.SetValue ToPicasPoints(HorzGutter#)
CustomDialog.VerticalSpin.SetValue ToPicasPoints(VertGutter#)
CASE UNITS_POINTS
SpinDoubleMode = TRUE
SpinPrecision& = 3
CustomDialog.HorizontalSpin.SetValue TOPOINTS(HorzGutter#)
CustomDialog.VerticalSpin.SetValue TOPOINTS(VertGutter#)
CASE UNITS_CICEROS_DIDOTS
SpinDoubleMode = TRUE
SpinPrecision& = 2
CustomDialog.HorizontalSpin.SetValue ToCicerosDidots(HorzGutter#)
CustomDialog.VerticalSpin.SetValue ToCicerosDidots(VertGutter#)
CASE UNITS_DIDOTS
SpinDoubleMode = TRUE
SpinPrecision& = 3
CustomDialog.HorizontalSpin.SetValue TODIDOTS(HorzGutter#)
CustomDialog.VerticalSpin.SetValue TODIDOTS(VertGutter#)
END SELECT
CustomDialog.HorizontalSpin.SetDoubleMode SpinDoubleMode
CustomDialog.HorizontalSpin.SetPrecision SpinPrecision&
CustomDialog.VerticalSpin.SetDoubleMode SpinDoubleMode
CustomDialog.VerticalSpin.SetPrecision SpinPrecision&
PrevGutterUnits% = GutterUnits%
END SELECT
ENDIF
END SUB
' *******************************************************************************
' ShowFinish
' This function displays the finish dialog.
'
' PARAMS: None
'
' RETURNS: ShowFinish AS INTEGER - Integer indicating dialog return value.
' *******************************************************************************
FUNCTION ShowFinish
BEGIN DIALOG OBJECT FinishDialog 290, 180, "Guidelines Wizard", SUB FinishDialogEventHandler
OPTIONGROUP .PageOptionGroup%
OPTIONBUTTON 120, 42, 100, 10, .OptionButton1, "Apply to ¤t page only"
OPTIONBUTTON 120, 55, 111, 10, .OptionButton2, "Apply to &page tag"
CHECKBOX 120, 98, 90, 12, .ShowGuidesCheckBox, "&Show Guidelines"
CHECKBOX 120, 114, 89, 12, .LockGuidesCheckBox, "&Lock Guidelines"
CHECKBOX 119, 129, 128, 12, .RemoveExistingCheckBox, "&Remove existing guidelines"
PUSHBUTTON 135, 160, 46, 14, .BackButton, "< &Back"
PUSHBUTTON 181, 160, 46, 14, .NextButton, "&Apply"
CANCELBUTTON 234, 160, 46, 14, .CancelButton
IMAGE 10, 10, 75, 130, .FinishImage
GROUPBOX 10, 150, 270, 5, .LineGroupBox
TEXT 95, 10, 185, 12, .Text5, "The Guidelines Wizard is now ready to apply guidelines."
GROUPBOX 100, 34, 175, 36, .GroupBox2
GROUPBOX 100, 89, 175, 55, .GroupBox3
TEXT 100, 25, 180, 12, .Text2, "Where do you want the guidelines applied?"
TEXT 100, 80, 180, 12, .Text3, "Do you want the Guidelines Wizard to:"
END DIALOG
FinishDialog.FinishImage.SetImage UseImage$
FinishDialog.FinishImage.SetStyle STYLE_IMAGE_CENTERED
FinishDialog.ShowGuidesCheckBox.SetThreeState FALSE
FinishDialog.LockGuidesCheckBox.SetThreeState FALSE
FinishDialog.RemoveExistingCheckBox.SetThreeState FALSE
FinishDialog.ShowGuidesCheckBox.SetValue ShowGuides&
FinishDialog.LockGuidesCheckBox.SetValue LockGuides&
FinishDialog.PageOptionGroup.SetValue PageOption&
FinishDialog.RemoveExistingCheckBox.SetValue RemoveExisting&
FinishRet%=DIALOG(FinishDialog)
SELECT CASE FinishRet%
CASE DIALOG_RETURN_CANCEL
STOP
CASE DIALOG_RETURN_NEXT
PageOption& = FinishDialog.PageOptionGroup.GetValue()
ShowFinish = 1
CASE DIALOG_RETURN_BACK
PageOption& = FinishDialog.PageOptionGroup.GetValue()
IF StyleOption& = CUSTOM_GUIDES THEN
ShowFinish = -1
ELSE
ShowFinish = -2
ENDIF
END SELECT
END FUNCTION
' *******************************************************************************
' FinishDialogEventHandler
' This subroutine handles events for the finish dialog.
'
' PARAMS: BYVAL ControlID% - Integer indicating the dialog control that is
' generating a dialog event.
' BYVAL Event% - Integer indicating the dialog event that has occurred.
' *******************************************************************************
SUB FinishDialogEventHandler(BYVAL ControlID%, BYVAL Event%)
IF Event% = EVENT_MOUSE_CLICK THEN
SELECT CASE ControlID%
CASE FinishDialog.NextButton.GetID()
ShowGuides& = FinishDialog.ShowGuidesCheckBox.GetValue()
LockGuides& = FinishDialog.LockGuidesCheckBox.GetValue()
RemoveExisting& = FinishDialog.RemoveExistingCheckBox.GetValue()
FinishDialog.closedialog DIALOG_RETURN_NEXT
CASE FinishDialog.BackButton.GetID()
FinishDialog.closedialog DIALOG_RETURN_BACK
CASE FinishDialog.CancelButton.GetID()
FinishDialog.closedialog DIALOG_RETURN_CANCEL
END SELECT
ENDIF
END SUB
' *******************************************************************************
' ToCicerosDidots
' This function converts a numeric expression to a double representing ciceros
' and didots.
' *******************************************************************************
FUNCTION ToCicerosDidots#(Value#)
TempValue# = TOCICEROS(Value#) 'convert value to ciceros
CicerosValue& = FIX(TempValue#) 'obtain ciceros portion
DidotsValue# = -(CicerosValue& - TempValue#) 'obtain didots portion [remainder of conversion]
DidotsValue# = INT(LENGTHCONVERT(LC_CICEROS, LC_DIDOTS, DidotsValue#)) 'convert remainder to didots
ToCicerosDidots# = CicerosValue& + (DidotsValue#/100) 'display ciceros as whole number, didots as decimal portion
END FUNCTION
' *******************************************************************************
' FromCicerosDidots
' This function converts a double representing ciceros, didots to a numeric
' expression in tenths of a micron.
' *******************************************************************************
FUNCTION FromCicerosDidots&(Value#)
CicerosValue& = FIX(Value#)
DidotsValue& = -(CicerosValue& - Value#) * 100
DidotsValueInMicrons& = FROMDIDOTS(DidotsValue&)
CicerosValueInMicrons& = FROMCICEROS(CicerosValue&)
FromCicerosDidots& = CicerosValueInMicrons& + DidotsValueInMicrons&
END FUNCTION
' *******************************************************************************
' ToPicasPoints
' This function converts a numeric expression to a double representing picas and
' points.
' *******************************************************************************
FUNCTION ToPicasPoints#(Value#)
Value# = Value# + 1.0e-9
TempValue# = TOPICAS(Value#) 'convert value to picas
PicasValue& = FIX(TempValue#) 'obtain picas portion
PointsValue# = -(PicasValue& - TempValue#) 'obtain points portion [remainder of conversion]
PointsValue# = INT(LENGTHCONVERT(LC_PICAS, LC_POINTS, DidotsValue#)) 'convert remainder to points
ToPicasPoints# = PicasValue& + (PointsValue#/100) 'display picas as whole number, points as decimal portion
END FUNCTION
' *******************************************************************************
' FromPicasPoints
' This function converts a double representing picas, points to a numeric
' expression in tenths of a micron.
' *******************************************************************************
FUNCTION FromPicasPoints&(Value#)
PicasValue& = FIX(Value#)
PointsValue& = -(PicasValue& - Value#) * 100
FromPicasPoints& = FROMPOINTS(PointsValue&) + FROMPICAS(PicasValue&)
END FUNCTION