;Demonstration of Dialog Box Styles

;*****************************************************************************
;*                                                                           *
;* DialogBoxStyles.was                                                       *
;* Copyright (C) 1998 Symantec Corp.							                           *
;* All rights reserved.                                                      *
;*                                                                           *
;* This program demonstrates all combinations of Dialog Box Styles from      *
;* 64 to 95.  The user can click on check boxes for each style and the       *
;* program will create a box with that combination of styles.
;*                                                                           *
;* This ASPECT SCRIPT is intended only as a sample of ASPECT programming.    *
;* Symantec makes no warranty of any kind, express or implied, including  	 *
;* without limitation, any warranties of merchantability and/or fitness      *
;* for a particular purpose.  Use of this program is at your own risk.       *
;*****************************************************************************


;*****************************************************************************
;*   GLOBAL VARIABLES                                                        *
;*****************************************************************************
integer BoxStyle             ;total sum of the Dialog Box Styles

integer ModalChk             ;
integer MoveCapChk           ;These are the indicators for which styles have
integer ModelessChk          ;been checked in the first dialog box.  1 means
integer TrapChk              ;checked and 0 is unchecked.
integer RemvCloseChk         ;
integer CenteredChk
integer SuspendChk

;*****************************************************************************
;*                                                                           *
;* MAIN                                                                      *
;* The Main procedure calls BeginStart to display the first dialog box.      *
;* The WHEN statement for events in dialog Box 0 is also initialized here.   *
;*                                                                           *
;* Calls:BeginStart                                                          *
;* Modifies globals: none                                                    *
;*                                                                           *
;*****************************************************************************
proc Main
   
                   ;When an event happens in Dialog Box , call Handler0. 
   when dialog 0 call Handler0
    
                   ;call BeginStart to display the first Dialog Box
   BeginStart ()
   
endproc



;*****************************************************************************
;*                                                                           *
;* BeginStart                                                                *
;* The procedure BeginStart displays the first Dialog Box.  The user can     *
;* check any combination of dialog box styles.  That style of box will then  *
;* be displayed.                                                             *
;*                                                                           *
;* Calls: none                                                               *
;* Called by: Main, Handler0                                                 *
;* Modifies globals:  ModalChk, MoveCapChk, ModelessChk, TrapChk,            *
;*                    RemvCloseChk, CenteredChk, SuspendChk                  *
;*                                                                           *
;*****************************************************************************
proc BeginStart

                   ;uncheck all the check boxes except for SuspendChk, which
                   ;is a required style
   ModalChk = 0
   MoveCapChk = 0
   ModelessChk = 0
   TrapChk = 0
   RemvCloseChk = 0
   CenteredChk = 0
   SuspendChk = 1
      
                   ;create a dialog box which is style 71
                   ;64 -- suspend Script while dialog box is displayed
                   ; 1 -- centered
                   ; 2 -- movable with caption
                   ; 4 -- modeless
   dialogbox 0 85 24 264 167 71 "Dialog Box Demonstration" 
   	text 13 13 5 165 11 "Check any combination of styles:" left 
   	             ;use CheckBoxes here because any combination of them
   	             ;can be checked
      checkbox 1 23 19 209 11 "  0 = Modal" ModalChk
      checkbox 2 23 53 209 11 "  2 = Movable with Caption" MoveCapChk
      checkbox 3 23 70 209 11 "  4 = Modeless" ModelessChk
      checkbox 4 23 85 209 11 "  8 = Trap Esc, Alt-F4 and Close" TrapChk
      checkbox 5 23 101 209 11 " 16 = Remove Close from System Menu" \
         RemvCloseChk
      checkbox 10 23 36 209 11 "  1 = Centered" CenteredChk
      checkbox 7 23 117 209 11 " 64 = Suspend Script While Dialog Box is \
Displayed (required)" SuspendChk
                   ;The choice to continue is either "OK, show the resulting
                   ;dialog box" or "Exit script"
      pushbutton 9 112 144 40 13 "OK" OK 
      pushbutton 12 196 144 40 13 "Exit" OK 
   enddialog 
 
endproc


;*****************************************************************************
;*                                                                           *
;* Handler0                                                                  *
;* The procedure Handler0 processes events from Dialog Box 0.  There are     *
;* only 2 events that are processed: OK button and Exit button.  If the OK   *
;* button is clicked, then add the Box Styles to get the total.  If the Exit *
;* button is clicked, then exit the script.  Don't take any action if one of *
;* the check boxes is clicked, wait until the OK button is clicked.          *
;*                                                                           *
;* Calls:                                                                    *
;* Called by: Main, WhateverElse                                             *
;* Modifies globals: Var1                                                    *
;*                                                                           *
;*****************************************************************************
proc Handler0
   integer event0            ;which event happened in dialog box 0
   
                   ;query for which event occurred
   dlgevent 0 event0
                   ;initialize the BoxStyle
   BoxStyle = 0

   switch event0
                   ;Element 9 is the OK button so add up the styles which 
                   ;have been checked.
       case 9
      	if ModalChk
      	   BoxStyle = BoxStyle + 0
      	endif
      	if MoveCapChk
      	   BoxStyle = BoxStyle + 2
      	endif
      	if ModelessChk
      	   BoxStyle = BoxStyle + 4
      	endif
      	if TrapChk
      	   BoxStyle = BoxStyle + 8
      	endif
      	if RemvCloseChk
      	   BoxStyle = BoxStyle + 16
      	endif
      	if CenteredChk
      	   BoxStyle = BoxStyle + 1
      	endif
     		if SuspendChk
      	   BoxStyle = BoxStyle + 64
      	endif
      	          ;now call the procedure to draw the demonstration
      	          ;dialog box
    	NewBox ()
      endcase
                   ;Element 12 is the Exit button so exit the script
      case 12
         exit
      endcase
   endswitch
   
endproc



;*****************************************************************************
;*                                                                           *
;* NewBox                                                                    *
;* The procedure NewBox creates the new dialog box with the combination of   *
;* styles that the user checked.  Note that it is necessary to write 32      *
;* dialog box commands because the Style is an integer constant.  If it had  *
;* been an integer variable, this could have been written with only 2 dialog *
;* box commands (one with caption and one without).                          *
;*                                                                           *
;* Calls: BeginStart                                                         *
;* Called by: Handler0                                                       *
;* Modifies globals: none                                                    *
;*                                                                           *
;*****************************************************************************
proc NewBox

                   ;use the BoxStyle as the switch variable because each
                   ;style requires a separate set of dialog box commands
   switch BoxStyle
                   ;Each demonstration dialog box consists of a text string
                   ;describing the style and an OK button.  Read the text to
                   ;see exactly what style of dialog box is being created.
                   ;When the user clicks on the OK button, the demonstration
                   ;dialog box is destroyed.  Since this is all the box is
                   ;supposed to do, there is no need to process events for
                   ;each demonstration dialog box.  The dialog boxes were given
                   ;individual IDs but this wasn't necessary when there are
                   ;no events to keep straight.
       case 64
        dialogbox 64 8 20 229 116 64 
           pushbutton 1 74 37 100 34 "OK" OK 
           text 14 21 12 185 20 "This is 64 = 64 + 0 = suspend script + \
modal" left 
        enddialog 
      endcase
      case 65
         dialogbox 65 8 20 229 116 65 
            pushbutton 1 74 37 100 35 "OK" OK 
            text 14 21 12 185 20 "This is 65 = 64 + 0 + 1 = suspend script +\
 modal + centered" left 
         enddialog 
      endcase
      case 66
         dialogbox 66 8 20 229 116 66 "66"
            pushbutton 1 56 69 100 35 "OK" OK 
            text 14 21 12 185 44 "This is 66 = 64 + 0 + 2 = suspend script +\
 modal + movable with caption" left 
         enddialog 
      endcase
      case 67
         dialogbox 67 8 20 229 116 67 "67" 
            pushbutton 1 56 69 100 34 "OK" OK 
            text 14 21 12 185 44 "This is 67 = 64 + 0 + 1 + 2 = suspend \
script + modal + centered and movable with caption" left 
         enddialog 
      endcase
      case 68
        dialogbox 68 8 20 229 116 68 
           pushbutton 1 74 37 100 34 "OK" OK 
           text 14 21 12 185 20 "This is 68 = 64 + 4 = suspend script + \
modeless" left 
        enddialog 
      endcase
      case 69
        dialogbox 69 8 20 229 116 69 
           pushbutton 1 74 37 100 34 "OK" OK 
           text 14 21 12 185 20 "This is 69 = 64 + 1 + 4 = suspend script \
+ centered + modeless" left 
        enddialog 
      endcase
      case 70
        dialogbox 70 8 20 229 116 70 "70" 
           pushbutton 1 74 37 100 34 "OK" OK 
           text 14 21 12 185 20 "This is 70 = 64 + 2 + 4 = suspend script \
+ movable + modeless" left 
        enddialog 
      endcase
      case 71
        dialogbox 71 8 20 229 116 71 "71" 
           pushbutton 1 74 37 100 34 "OK" OK 
           text 14 21 12 185 20 "This is 71 = 64 + 1 + 2 + 4 = suspend \
script + centered + movable + modeless" left 
        enddialog 
      endcase
      case 72
        dialogbox 72 8 20 229 116 72 
           pushbutton 1 74 37 100 34 "OK" OK 
           text 14 21 12 185 20 "This is 72 = 64 + 0 + 8 = suspend script\
 + modal + trap closings" left 
        enddialog 
      endcase
       case 73
         dialogbox 73 8 20 229 116 73
            pushbutton 1 56 69 100 35 "OK" OK 
            text 14 21 12 185 44 "This is 73 = 64 + 0 + 1 + 8 = suspend \
script + modal + centered + trap closings" left 
         enddialog 
      endcase
       case 74
        dialogbox 74 8 20 229 116 74 "74" 
           pushbutton 1 74 37 100 34 "OK" OK 
           text 14 21 12 185 20 "This is 74 = 64 + 0 + 2 + 8 = suspend \
script + modal + movable + trap closings" left 
        enddialog 
      endcase
      case 75
         dialogbox 75 8 20 229 116 75 "75"
            pushbutton 1 56 69 100 35 "OK" OK 
            text 14 21 12 185 44 "This is 75 = 64 + 0 + 1 + 2 + 8 = suspend\
 script + modal + centered + movable + trap closings" left 
         enddialog 
      endcase
       case 76
        dialogbox 76 8 20 229 116 76 
           pushbutton 1 74 37 100 34 "OK" OK 
           text 14 21 12 185 20 "This is 76 = 64 + 8 + 4 = suspend script \
+ modeless + trap closings" left 
        enddialog 
      endcase
       case 77
        dialogbox 77 8 20 229 116 77 
           pushbutton 1 74 37 100 34 "OK" OK 
           text 14 21 12 185 20 "This is 77 = 64 + 1 + 4 + 8 = suspend \
script + centered + modeless + trap closings" left 
        enddialog 
      endcase
       case 78
        dialogbox 78 8 20 229 116 78 "78" 
           pushbutton 1 74 37 100 34 "OK" OK 
           text 14 21 12 185 20 "This is 78 = 64 + 2 + 4 = suspend script\
 + movable + modeless" left 
        enddialog 
      endcase
       case 79
        dialogbox 79 8 20 229 116 79 "79" 
           pushbutton 1 74 37 100 34 "OK" OK 
           text 14 21 12 185 20 "This is 79 = 64 + 1 + 2 + 4 + 8 = suspend\
 script + centered + movable + modeless + trap closings" left 
        enddialog 
      endcase
       case 80
        dialogbox 80 8 20 229 116 80 
           pushbutton 1 74 37 100 34 "OK" OK 
           text 14 21 12 185 20 "This is 80 = 64 + 0 + 16 = suspend script \
+ modal + remove Close" left 
        enddialog 
      endcase
       case 81
        dialogbox 81 8 20 229 116 81 
           pushbutton 1 74 37 100 34 "OK" OK 
           text 14 21 12 185 20 "This is 81 = 64 + 0 + 1 + 16 = suspend \
script + modal + centered + remove Close" left 
        enddialog 
      endcase
       case 82
        dialogbox 82 8 20 229 116 82 "82"
           pushbutton 1 74 37 100 34 "OK" OK 
           text 14 21 12 185 20 "This is 82 = 64 + 0 + 2 + 16 = suspend \
script + modal + movable + remove Close" left 
        enddialog 
      endcase
      case 83
         dialogbox 83 8 20 229 116 83 "83"
            pushbutton 1 56 69 100 35 "OK" OK 
            text 14 21 12 185 44 "This is 83 = 64 + 0 + 1 + 2 + 16 = suspend\
 script + modal + centered + movable + remove Close" left 
         enddialog 
      endcase
       case 84
        dialogbox 84 8 20 229 116 84 
           pushbutton 1 74 37 100 34 "OK" OK 
           text 14 21 12 185 20 "This is 84 = 64 + 4 + 16 = suspend script\
 + modeless + remove Close" left 
        enddialog 
      endcase
       case 85
        dialogbox 85 8 20 229 116 85 
           pushbutton 1 74 37 100 34 "OK" OK 
           text 14 21 12 185 20 "This is 85 = 64 + 1 + 4 + 16 = suspend \
script + modeless + centered + remove Close" left 
        enddialog 
      endcase
       case 86
        dialogbox 86 8 20 229 116 86 "86" 
           pushbutton 1 74 37 100 34 "OK" OK 
           text 14 21 12 185 20 "This is 86 = 64 + 2 + 4 + 16 = suspend \
script + movable + modeless + remove Close" left 
        enddialog 
      endcase
       case 87
        dialogbox 87 8 20 229 116 87 "87"
           pushbutton 1 74 37 100 34 "OK" OK 
           text 14 21 12 185 20 "This is 87 = 64 + 1 + 2 + 4 + 16 = suspend\
 script + centered + movable + modeless + remove Close" left 
        enddialog 
      endcase
       case 88
        dialogbox 88 8 20 229 116 88  
           pushbutton 1 74 37 100 34 "OK" OK 
           text 14 21 12 185 20 "This is 88 = 64 + 0 + 8 + 16 = suspend \
script + modal + trap closings + remove Close" left 
        enddialog 
      endcase
      case 89
         dialogbox 89 8 20 229 116 89 
            pushbutton 1 74 37 100 35 "OK" OK 
            text 14 21 12 185 44 "This is 89 = 64 + 0 + 1 + 8 + 16 = suspend\
 script + modal + centered + trap closings + remove Close" left 
         enddialog 
      endcase
       case 90
        dialogbox 90 8 20 229 116 90 "90"
           pushbutton 1 74 37 100 34 "OK" OK 
           text 14 21 12 185 20 "This is 90 = 64 + 0 + 2 + 8 + 16 = suspend\
 script + modal + movable + trap closings + remove Close" left 
        enddialog 
      endcase
      case 91
         dialogbox 91 8 20 229 116 91 "91"
            pushbutton 1 56 69 100 35 "OK" OK 
            text 14 21 12 185 44 "This is 91 = 64 + 0 + 1 + 2 + 8 + 16 = \
suspend script + modal + centered + movable + trap closing + remove Close" left 
         enddialog 
      endcase
      case 92
         dialogbox 92 8 20 229 116 92 
            pushbutton 1 56 69 100 35 "OK" OK 
            text 14 21 12 185 44 "This is 92 = 64 + 4 + 8 + 16 = suspend\
 script + modeless + trap closing + remove Close" left 
         enddialog 
      endcase
      case 93
         dialogbox 93 8 20 229 116 93 
            pushbutton 1 56 69 100 35 "OK" OK 
            text 14 21 12 185 44 "This is 93 = 64 + 1 + 4 + 8 + 16 = suspend\
 script + centered + modeless + trap closing + remove Close" left 
         enddialog 
      endcase
      case 94
         dialogbox 94 8 20 229 116 94 "94"
            pushbutton 1 56 69 100 35 "OK" OK 
            text 14 21 12 185 44 "This is 94 = 64 + 2 + 4 + 8 + 16 = suspend\
 script + movable + modeless + trap closing + remove Close" left 
         enddialog 
      endcase
      case 95
         dialogbox 95 8 20 229 116 95 "95"
            pushbutton 1 56 69 100 35 "OK" OK 
            text 14 21 12 185 44 "This is 95 = 64 + 1 + 2 + 4 + 8 + 16 = \
suspend script + centered + movable + modeless + trap closing + remove Close" left 
         enddialog 
      endcase
      default
         usermsg "You chose a combination of %i`n`rThis is not currently \
programmed`n`rCall Tech Support" BoxStyle
      endcase
    endswitch
    
                   ;after each demonstration dialog box is destroyed, go
                   ;back to BeginStart and display the original dialog box.
    BeginStart ()
    
 endproc
 
 
