home *** CD-ROM | disk | FTP | other *** search
/ Windoware / WINDOWARE_1_6.iso / miscprog / wzall / wz003.txt < prev    next >
Text File  |  1991-01-24  |  9KB  |  167 lines

  1.                                INFORMIX SOFTWARE, INC., LENEXA, KS
  2.                          Wingz Technical Support Bulletin Number 003
  3.        
  4.        
  5.        Title:    Guidelines for the creation of dialog boxes
  6.        Date:     January 23, 1989
  7.        
  8.        Dialog  boxes  are  how Macintoshes obtain information  from  the 
  9.        user.   One  of Wingz'  more powerful features is the ability  to 
  10.        create  and  customize  your own dialog boxes for use  within  an 
  11.        application.    This  bulletin  will  cover  some  of  the  basic 
  12.        guidelines that should be followed when designing your own boxes.
  13.        
  14.        Following is an abbreviated example format:
  15.        
  16.        define doit,vars
  17.        
  18.        function myfunc()
  19.        
  20.        new modal dialog box at (-1,-1) (3 inches,3 inches)
  21.        
  22.        add  push  button "OK","Cancel"  at (.5 inches,  2.5 inches)  +(2 
  23.        inches,.5 inches)
  24.        dialog cancel push button
  25.        
  26.        select control 1
  27.        dialog default push button
  28.        script "filename:doit = 1 filename:vars = ctvalue(3,0)"
  29.        
  30.        add  radio  button  "Yes","No"   at  (.5  inches,.5  inches)  +(2 
  31.        inches,1.5 inches)
  32.        
  33.        use dialog box
  34.        
  35.        if doit
  36.             commands
  37.        end if
  38.        
  39.        end function
  40.        
  41.        Step 1:  Define your variables
  42.        
  43.        Your  variables need to be defined before they can be used.  This 
  44.        is  accomplished with the DEFINE command.   Wingz uses both local 
  45.        and global variables.   Local means that when a function or event 
  46.        is finished,  any space allocated for those variables within that 
  47.        function or event is deallocated and released.  Global means that 
  48.        the  variable  will  exist  in memory as long as  the  script  or 
  49.        worksheet in which they were 
  50.        defined  from is in memory.    Load scripts into memory with  the 
  51.        GET  SCRIPT command.   Variables defined within sheet scripts are 
  52.        loaded as long as the sheet is open.   The variables  can then be 
  53.        accessed  by  a worksheet,  another  script,  another  event,  or 
  54.        another function.   Space is not deallocated when the function or 
  55.        event is finished.  In the example above,  they have been defined 
  56.        as  global  because  the  DEFINE  statement  is  outside  of  the 
  57.        function.  Depending on your application, they can be either way.
  58.        
  59.        Step 2:  Create the box
  60.        
  61.        The  line,  NEW  MODAL DIALOG BOX AT (-1,-1) (3 INCHES,3  INCHES) 
  62.        will  start  the  creation of the box.   There are two  types  of 
  63.        dialog  boxes  available in Wingz;  modal  and  modeless.   Modal 
  64.        dialog  boxes are used when you do not want to allow the user  to 
  65.        access  any  other commands or do anything else until they  clear 
  66.        the  dialog box from the screen.   When they try to access a menu 
  67.        command,  for  example,  their  error message  will  play.   With 
  68.        modeless  dialog boxes,  the menu commands are available for  use 
  69.        and the user has access to the sheet.  In many ways, it acts just 
  70.        like  another open window.   You can move it,  leave it and go to 
  71.        another  window,  and close it with the close box.   It cannot be 
  72.        resized.   Our  example  here will deal with modal dialog  boxes.  
  73.        The command for a modeless box is:
  74.        
  75.        NEW MODELESS DIALOG BOX "name" AT (-1,-1) (3 inches,3 inches)
  76.        
  77.        The  coordinates  (-1,-1)  tells Wingz to center the box  in  the 
  78.        middle of your screen,  no matter what type or size.   The second 
  79.        set of coordinates specifies the size of the box itself.  In this 
  80.        case,  three  inches  by  three inches.   You can  specify  exact 
  81.        coordinates  to place the box anywhere on your screen.  The first 
  82.        set of coordinates places the top left corner of the box measured 
  83.        from  the bottom of the menu bar on the left side of the  screen. 
  84.        The  second set places the bottom right corner of the box.   If a 
  85.        "+"  is  used  in  front  of the  second  set,  then  the  second 
  86.        coordinates are measured in relation to the first set.  If you do 
  87.        not  use the "+",  then the second coordinates are measured using 
  88.        the same origin point the first set is measured from.
  89.        
  90.        Step 3:  Place the controls
  91.        
  92.        Once you have the dialog box location and size defined,  then you 
  93.        need to place your controls such as radio buttons or check boxes.  
  94.        For  placing  controls,  the  point of origin is the  upper  left 
  95.        corner  of the box and the "+"  works the same way when used with 
  96.        the second coordinate set.  In the first 
  97.        example presented,  two buttons are placed in the box.   The left 
  98.        point for the controls is placed a half inch from the left of the 
  99.        box and 2.5 inches down.  Since the "+" is used, the ending point 
  100.        of  the  controls is 2 inches to the right and a half  inch  down 
  101.        from the starting point of the controls.  If the "+" wasn't used, 
  102.        the  ending point would be 2 inches from the left of the box  and 
  103.        .5  inches  down.  Even though just one command line was used  to 
  104.        place  the  two  buttons,  they are considered  as  two  distinct 
  105.        controls.   The "OK"  button, the first one listed,  is the first 
  106.        control,  and "Cancel" the second.  Since it was listed last,  it 
  107.        is the currently selected control.   Control 1 had to be selected 
  108.        in order to attach a script to it.
  109.        
  110.        DIALOG  CANCEL  PUSH  BUTTON assigns certain  attributes  to  the 
  111.        button  that is selected when the command is executed.   Whenever 
  112.        that button is pressed, it will clear the box from the screen and 
  113.        deallocate any memory assigned for that box.
  114.        
  115.        DIALOG  DEFAULT PUSH BUTTON is a command that will make  pressing 
  116.        the  return perform the same action as clicking the "OK"  button.  
  117.        It  will  also  highlight  that  button.    Any  memory  will  be 
  118.        deallocated when the box is cleared from the screen.
  119.        
  120.        Both DIALOG DEFAULT PUSH BUTTON and DIALOG CANCEL PUSH BUTTON has 
  121.        the command QUIT DIALOG BOX inherent to them.   If you do not use 
  122.        these  commands,  it would be necessary to use QUIT DIALOG BOX in 
  123.        your scripts attached to the "OK" and "Cancel" buttons.
  124.        
  125.        A third control is added in the above example.   The control is a 
  126.        radio button with two choices, "Yes" and "No".
  127.        
  128.        Step 4:  Use the box
  129.        
  130.        The  command  USE DIALOG BOX is the command that puts  everything 
  131.        together and makes the box available to the user.
  132.        
  133.        Dialog boxes follow this procedure when they are created:
  134.        
  135.        1)   Memory  is allocated for the dialog box when the NEW  DIALOG 
  136.        BOX command is executed.  
  137.        
  138.        2)  Additional memory is allocated for any controls in the dialog 
  139.        box.  
  140.        
  141.        3)   The  box is displayed on the screen with the USE DIALOG  BOX 
  142.        command.  
  143.        
  144.        4)  The user may or may not manipulate any of the controls. 
  145.        
  146.        5a)  The user presses the "Cancel"  button.  If this happens, all 
  147.        memory is deallocated and control passes to the next command line 
  148.        after  USE  DIALOG  BOX.   If there is a script attached  to  the 
  149.        button it would be executed.  
  150.        
  151.        5b).   The user clicks the "OK" button or presses the return key.  
  152.        When  this  happens,  the  script  attached  to  this  button  is 
  153.        executed.    This   generally  stores  the  control  settings  to 
  154.        variables and sets a flag.  In the above example, the flag set is 
  155.        called  "doit".   All variables need to be referenced as external 
  156.        variables because the script attached to the button is considered 
  157.        a  separate  script.   Control  settings  need to  be  stored  to 
  158.        variables  because when the box is cleared,  the controls can  no 
  159.        longer  be  referenced.   Script control passes to the next  line 
  160.        after USE DIALOG BOX.
  161.        
  162.        The  use  of  a  variable flag is  not  mandatory.   It  is  used 
  163.        primarily  to  keep  any commands from being  executed  when  the 
  164.        "Cancel" button is pressed instead of the "Ok" button.  If a flag 
  165.        like  "doit"  is not set,  then any commands after USE DIALOG BOX 
  166.        would be executed and could potentially create errors.
  167.