home *** CD-ROM | disk | FTP | other *** search
- PROGRAM TestDialogRoutines;
-
- {
- Replacement routines for Center_Dialog, Do_Dialog, Redo_Dialog,
- End_Dialog in Personal Pascal v 2.0, 2.01. Apparently the programmer
- thought that dialogs look better without the ouline, so SOMEHOW he
- chose not to display it (he probably altered the clip values in the
- Obj_Draw call). He must have REALLY GONE OUT OF HIS WAY to do this!
- Anyway, enough hazing. This code implements the following AES routines
- as described in Abacus GEM Prog. Ref. to fix this problem:
- 1. Form_Center 2. Form_Dial 3. Form_Do.
- Note that Form_Dial(3,...) can force a redraw of ALL windows, including
- the desktop window. Useful, for instance, when you draw a "marquee box"
- by the file selector to indicate the action more definitely. If you don't
- do this, and the marquee overlays a window not associated with your
- program, such as an acc or desktop, it doesn't know to redraw itself. So
- you can use Form_Dial(3,...) w/ the dimensions of your marquee, and it
- will get the message (no pun intended). Form_Dial can be used AT ANY TIME
- in this manner. These routines are probably also found in Tackle Box,
- if you have that (I don't). Incidentally, using this code IN PLACE of the
- library routines shouldn't increase code size.
-
- If you have any questions, I'm Doug Harrison, PPN 72277,2315.
- }
-
- (*************************************************************************)
- (* Mandatory global declarations; change path as necessary *)
- (*************************************************************************)
-
- {$I d:\pascal\gemsubs}
-
- VAR
- fo_x,fo_y,fo_w,fo_h,alert : INTEGER;
- button,
- ok_btn,
- cancel_btn,
- prompt_item,
- date_item : integer ;
- dialog : Dialog_Ptr ;
- int_in : Int_In_Parms;
- int_out : Int_Out_Parms;
- addr_in : Addr_In_Parms;
- addr_out : Addr_Out_Parms;
-
- { The following procedures can be compiled in a module, and declared as
- externals in your main program, with caveats as noted }
-
- PROCEDURE Obj_Draw ( dial : Dialog_Ptr;
- index,depth,
- x_clip,y_clip,w_clip,h_clip : INTEGER );
- EXTERNAL;
-
- FUNCTION CHANGE_PTR ( tree_ptr : Dialog_Ptr ) : Pointer;
- { Note none of the new AUXSUBS routines will do this! }
- VAR change : RECORD
- CASE byte OF
- 1 : ( original : Dialog_Ptr );
- 2 : ( final : Pointer );
- END;
- BEGIN
- change.original := tree_ptr;
- change_ptr := change.final
- END; { CHANGE_PTR }
-
- PROCEDURE Form_Center ( box : Dialog_Ptr;
- VAR fo_x,fo_y,fo_w,fo_h : INTEGER );
- { Like Center_Dialog, but returns the actual screen coordinates of the
- tree when drawn }
- BEGIN
- addr_in[0] := change_ptr(box);
- AES_Call(54,int_in,int_out,addr_in,addr_out);
- fo_x := int_out[1];
- fo_y := int_out[2];
- fo_w := int_out[3];
- fo_h := int_out[4]
- END; { Form_Center }
-
- PROCEDURE Form_Dial ( fn,little_x,little_y,little_w,little_h,
- big_x,big_y,big_w,big_h : INTEGER );
- { fn = 0, reserve memory for window border components;
- fn = 1, draw expanding zoom box;
- fn = 2, draw shrinking zoom box;
- fn = 3, force redraw of ALL workstations under GEM that intersect
- the x,y,w,h values, which should be equal (little_x=big_x,
- etc.). }
- BEGIN
- int_in[0] := fn;
- int_in[1] := little_x;
- int_in[2] := little_y;
- int_in[3] := little_w;
- int_in[4] := little_h;
- int_in[5] := big_x;
- int_in[6] := big_y;
- int_in[7] := big_w;
- int_in[8] := big_h;
- AES_Call(51,int_in,int_out,addr_in,addr_out)
- END; { Form_Dial }
-
- FUNCTION Form_Do ( box : Dialog_Ptr;
- index : Tree_Index ) : Tree_Index;
- { used by FORM_BEGIN and is functionally the same as Redo_Dialog and may
- be used in its place }
- BEGIN
- int_in[0] := index;
- addr_in[0] := change_ptr(box);
- AES_Call(50,int_in,int_out,addr_in,addr_out);
- Form_Do := int_out[0]
- END; { Form_Do }
-
- (*************************************************************************)
- (* Interface to Pascal program *)
- (*************************************************************************)
-
- FUNCTION FORM_BEGIN ( box : Dialog_Ptr;
- index : Tree_Index ) : Tree_Index;
- { Routine to replace Do_Dialog, should be part of main program. To
- make this an EXTERNAL, you would have to add parms as in Form_Dial
- above }
- BEGIN
- Hide_Mouse;
- { Center the dialog, note this returns the actual x,y,w,h coords
- for the box, as opposed to the OSS Center_Dialog which does not. }
- Form_Center(box,fo_x,fo_y,fo_w,fo_h);
- { Now reserve some memory for window border components which may be
- overwritten }
- Form_Dial(0,fo_x,fo_y,fo_w,fo_h,fo_x,fo_y,fo_w,fo_h);
- { OPTIONALLY, you may use Form_Dial(1,...) here to draw the
- "zoom-box."
- In high rez, Form_Dial(1,320,200,0,0,fo_x,fo_y,fo_w,fo_h) will
- zoom from the center of the screen to the form margins }
- { draw the tree... }
- Obj_Draw(box,Root,Max_Depth,fo_x,fo_y,fo_w,fo_h);
- Show_Mouse;
- { and pass control to the AES form manager }
- form_begin := Form_Do(box,index)
- END; { FORM_BEGIN }
-
- PROCEDURE FORM_END;
- { Same as End_Dialog, except no parms are needed.
- Again can be compiled in a module as long as you pass it Form_Dial
- parms }
- BEGIN
- Hide_Mouse;
- { OPTIONALLY you may call Form_Dial(2,...) to draw the shrinking
- zoom box.
- In high rez, Form_Dial(2,fo_x,fo_y,fo_w,fo_h,320,200,0,0) zooms
- from tree margins to the center of the screen. }
- { Tell GEM I'm through and screen needs to be redrawn }
- Form_Dial(3,fo_x,fo_y,fo_w,fo_h,fo_x,fo_y,fo_w,fo_h);
- Show_Mouse
- END; { FORM_END }
-
- BEGIN { main program }
- IF Init_Gem >= 0 THEN BEGIN
- { the following appears in the GEMDEMOS as DIALOG.PAS }
- dialog := New_Dialog( 4, 0, 0, 26, 8 ) ;
- prompt_item := Add_DItem( dialog, G_String, None, 2, 1, 0, 0, 0, 0 ) ;
- Set_DText( dialog, prompt_item, 'Please enter the date:',
- System_Font, TE_Left ) ;
- date_item := Add_DItem( dialog, G_FText, None, 2, 3, 10, 1, 0, $1180 );
- Set_DEdit( dialog, date_item, '__/__/__', '999999', '090187',
- System_Font, TE_Center ) ;
- ok_btn := Add_DItem( dialog, G_Button, Selectable|Exit_Btn|Default,
- 2, 5, 8, 2, 2, $1180 ) ;
- Set_DText( dialog, ok_btn, 'OK', System_Font, TE_Center ) ;
- cancel_btn := Add_DItem( dialog, G_Button, Selectable|Exit_Btn,
- 16, 5, 8, 2, 2, $1180 ) ;
- Set_DText( dialog, cancel_btn, 'Cancel', System_Font, TE_Center ) ;
- button := form_begin(dialog,date_item) ; { = Do_Dialog }
- Obj_SetState(dialog,button,Normal,TRUE);
- alert := Do_Alert('[1][Now I''ll use Form_Do.][ OK ]',1);
- button := Form_Do(dialog,date_item); { = Redo_Dialog }
- Exit_Gem
- END
- END.
-