home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / music / 194 / pascal / newdial.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1987-11-19  |  7.4 KB  |  176 lines

  1. PROGRAM TestDialogRoutines;
  2.  
  3.   Replacement routines for Center_Dialog, Do_Dialog, Redo_Dialog, 
  4.   End_Dialog in Personal Pascal v 2.0, 2.01. Apparently the programmer
  5.   thought that dialogs look better without the ouline, so SOMEHOW he
  6.   chose not to display it (he probably altered the clip values in the
  7.   Obj_Draw call). He must have REALLY GONE OUT OF HIS WAY to do this!
  8.   Anyway, enough hazing. This code implements the following AES routines
  9.   as described in Abacus GEM Prog. Ref. to fix this problem: 
  10.      1. Form_Center 2. Form_Dial 3. Form_Do.
  11.   Note that Form_Dial(3,...) can force a redraw of ALL windows, including
  12.   the desktop window. Useful, for instance, when you draw a "marquee box"
  13.   by the file selector to indicate the action more definitely. If you don't
  14.   do this, and the marquee overlays a window not associated with your
  15.   program, such as an acc or desktop, it doesn't know to redraw itself. So
  16.   you can use Form_Dial(3,...) w/ the dimensions of your marquee, and it
  17.   will get the message (no pun intended). Form_Dial can be used AT ANY TIME
  18.   in this manner. These routines are probably also found in Tackle Box, 
  19.   if you have that (I don't). Incidentally, using this code IN PLACE of the
  20.   library routines shouldn't increase code size. 
  21.   
  22.   If you have any questions, I'm Doug Harrison, PPN 72277,2315.
  23. }
  24.  
  25. (*************************************************************************)
  26. (* Mandatory global declarations; change path as necessary               *) 
  27. (*************************************************************************)
  28.  
  29. {$I d:\pascal\gemsubs}
  30.  
  31. VAR
  32.     fo_x,fo_y,fo_w,fo_h,alert : INTEGER; 
  33.     button,
  34.     ok_btn,
  35.     cancel_btn,
  36.     prompt_item,
  37.     date_item           : integer ;
  38.     dialog              : Dialog_Ptr ;
  39.     int_in              : Int_In_Parms;
  40.     int_out             : Int_Out_Parms;
  41.     addr_in             : Addr_In_Parms;
  42.     addr_out            : Addr_Out_Parms;
  43.  
  44. { The following procedures can be compiled in a module, and declared as
  45.   externals in your main program, with caveats as noted }
  46.  
  47. PROCEDURE Obj_Draw ( dial                        : Dialog_Ptr; 
  48.                      index,depth,
  49.                      x_clip,y_clip,w_clip,h_clip : INTEGER     );
  50.    EXTERNAL;
  51.  
  52. FUNCTION CHANGE_PTR ( tree_ptr : Dialog_Ptr ) : Pointer;
  53.    { Note none of the new AUXSUBS routines will do this! }
  54.    VAR change : RECORD
  55.                      CASE byte OF
  56.                         1 : ( original : Dialog_Ptr );
  57.                         2 : ( final    : Pointer );
  58.                      END;
  59.    BEGIN
  60.        change.original := tree_ptr;
  61.        change_ptr := change.final
  62.    END; { CHANGE_PTR }
  63.  
  64. PROCEDURE Form_Center ( box                     : Dialog_Ptr;
  65.                         VAR fo_x,fo_y,fo_w,fo_h : INTEGER );
  66.    { Like Center_Dialog, but returns the actual screen coordinates of the
  67.      tree when drawn }                     
  68.    BEGIN
  69.        addr_in[0] := change_ptr(box);
  70.        AES_Call(54,int_in,int_out,addr_in,addr_out);
  71.        fo_x := int_out[1];
  72.        fo_y := int_out[2];
  73.        fo_w := int_out[3];
  74.        fo_h := int_out[4]
  75.    END; { Form_Center }
  76.  
  77. PROCEDURE Form_Dial ( fn,little_x,little_y,little_w,little_h,
  78.                          big_x,big_y,big_w,big_h              : INTEGER );
  79.    { fn = 0, reserve memory for window border components;
  80.      fn = 1, draw expanding zoom box;
  81.      fn = 2, draw shrinking zoom box;
  82.      fn = 3, force redraw of ALL workstations under GEM that intersect
  83.              the x,y,w,h values, which should be equal (little_x=big_x,
  84.              etc.). }
  85.    BEGIN
  86.        int_in[0] := fn;
  87.        int_in[1] := little_x;
  88.        int_in[2] := little_y;
  89.        int_in[3] := little_w;
  90.        int_in[4] := little_h;
  91.        int_in[5] := big_x;
  92.        int_in[6] := big_y;
  93.        int_in[7] := big_w;
  94.        int_in[8] := big_h;
  95.        AES_Call(51,int_in,int_out,addr_in,addr_out)
  96.    END; { Form_Dial }
  97.  
  98. FUNCTION Form_Do ( box   : Dialog_Ptr; 
  99.                    index : Tree_Index  ) : Tree_Index;
  100.    { used by FORM_BEGIN and is functionally the same as Redo_Dialog and may
  101.      be used in its place }
  102.    BEGIN
  103.        int_in[0] := index;
  104.        addr_in[0] := change_ptr(box);
  105.        AES_Call(50,int_in,int_out,addr_in,addr_out);
  106.        Form_Do := int_out[0]
  107.    END; { Form_Do }
  108.  
  109. (*************************************************************************)
  110. (*                    Interface to Pascal program                        *)
  111. (*************************************************************************)
  112.  
  113. FUNCTION FORM_BEGIN ( box   : Dialog_Ptr; 
  114.                       index : Tree_Index  ) : Tree_Index;
  115.    { Routine to replace Do_Dialog, should be part of main program. To
  116.      make this an EXTERNAL, you would have to add parms as in Form_Dial
  117.      above }
  118.    BEGIN
  119.        Hide_Mouse;
  120.        { Center the dialog, note this returns the actual x,y,w,h coords
  121.          for the box, as opposed to the OSS Center_Dialog which does not. }
  122.        Form_Center(box,fo_x,fo_y,fo_w,fo_h); 
  123.        { Now reserve some memory for window border components which may be 
  124.          overwritten }
  125.        Form_Dial(0,fo_x,fo_y,fo_w,fo_h,fo_x,fo_y,fo_w,fo_h);
  126.        { OPTIONALLY, you may use Form_Dial(1,...) here to draw the 
  127.          "zoom-box." 
  128.          In high rez, Form_Dial(1,320,200,0,0,fo_x,fo_y,fo_w,fo_h) will
  129.          zoom from the center of the screen to the form margins }
  130.        { draw the tree... }
  131.        Obj_Draw(box,Root,Max_Depth,fo_x,fo_y,fo_w,fo_h);
  132.        Show_Mouse;
  133.        { and pass control to the AES form manager }
  134.        form_begin := Form_Do(box,index)
  135.    END; { FORM_BEGIN }
  136.    
  137. PROCEDURE FORM_END;
  138.    { Same as End_Dialog, except no parms are needed.
  139.      Again can be compiled in a module as long as you pass it Form_Dial
  140.      parms }
  141.    BEGIN
  142.        Hide_Mouse;
  143.        { OPTIONALLY you may call Form_Dial(2,...) to draw the shrinking
  144.          zoom box.
  145.          In high rez, Form_Dial(2,fo_x,fo_y,fo_w,fo_h,320,200,0,0) zooms
  146.          from tree margins to the center of the screen. }
  147.        { Tell GEM I'm through and screen needs to be redrawn }   
  148.        Form_Dial(3,fo_x,fo_y,fo_w,fo_h,fo_x,fo_y,fo_w,fo_h);
  149.        Show_Mouse
  150.    END; { FORM_END }
  151.  
  152. BEGIN { main program }
  153.     IF Init_Gem >= 0 THEN BEGIN
  154.        { the following appears in the GEMDEMOS as DIALOG.PAS }
  155.        dialog := New_Dialog( 4, 0, 0, 26, 8 ) ;
  156.        prompt_item := Add_DItem( dialog, G_String, None, 2, 1, 0, 0, 0, 0 ) ;
  157.        Set_DText( dialog, prompt_item, 'Please enter the date:',
  158.                        System_Font, TE_Left ) ;
  159.        date_item := Add_DItem( dialog, G_FText, None, 2, 3, 10, 1, 0, $1180 );
  160.        Set_DEdit( dialog, date_item, '__/__/__', '999999', '090187',
  161.                        System_Font, TE_Center ) ;
  162.        ok_btn := Add_DItem( dialog, G_Button, Selectable|Exit_Btn|Default,
  163.                        2, 5, 8, 2, 2, $1180 ) ;
  164.        Set_DText( dialog, ok_btn, 'OK', System_Font, TE_Center ) ;
  165.        cancel_btn := Add_DItem( dialog, G_Button, Selectable|Exit_Btn,
  166.                        16, 5, 8, 2, 2, $1180 ) ;
  167.        Set_DText( dialog, cancel_btn, 'Cancel', System_Font, TE_Center ) ;
  168.        button := form_begin(dialog,date_item) ; { = Do_Dialog }
  169.        Obj_SetState(dialog,button,Normal,TRUE);
  170.        alert := Do_Alert('[1][Now I''ll use Form_Do.][ OK ]',1);
  171.        button := Form_Do(dialog,date_item); { = Redo_Dialog }
  172.        Exit_Gem
  173.     END
  174. END.       
  175.