home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Utilities / Ph 1.1.1 / PhClient / tran.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-25  |  2.5 KB  |  100 lines  |  [TEXT/MPS ]

  1. /*_____________________________________________________________________
  2.  
  3.       tran.c - Server Transaction Movable Modal Dialog.
  4. _____________________________________________________________________*/
  5.  
  6. #pragma load "precompile"
  7. #include "rez.h"
  8. #include "tran.h"
  9. #include "utl.h"
  10. #include "glob.h"
  11. #include "oop.h"
  12. #include "mtcp.h"
  13. #include "wstm.h"
  14.  
  15. /*_____________________________________________________________________
  16.  
  17.     Global Variables.
  18. _____________________________________________________________________*/
  19.  
  20. static DialogPtr            Window;            /* ptr to dialog window */
  21.  
  22. static oop_Dispatch    dispatch = {
  23.                                 tran_DoPeriodic,
  24.                                 oop_DoClick,
  25.                                 oop_DoKey,
  26.                                 oop_DoUpdate,
  27.                                 oop_DoActivate,
  28.                                 oop_DoDeactivate,
  29.                                 oop_DoGrow,
  30.                                 oop_DoZoom,
  31.                                 oop_DoClose,
  32.                                 oop_DoCommand
  33.                             };
  34.  
  35. /*_____________________________________________________________________
  36.  
  37.     tran_DoPeriodic - Do Periodic Tasks.
  38.     
  39.     Entry:    w = pointer to window record.
  40. _____________________________________________________________________*/
  41.  
  42. void tran_DoPeriodic (WindowPtr w)
  43.  
  44. {
  45. #pragma unused (w)
  46.  
  47.     utl_SpinCursor();
  48.     if (oop_GetWindItemHit(Window) || Done) {
  49.         mtcp_CancelTransaction();
  50.         oop_ClearWindItemHit(Window);
  51.     }
  52. }
  53.  
  54. /*_____________________________________________________________________
  55.  
  56.     tran_BeginTransaction - Begin Server Transaction.
  57.     
  58.     Entry:    msgIndex = index in STR# of wait message.
  59.                 p0 = param to plug into wait message, or nil if none.
  60. _____________________________________________________________________*/
  61.  
  62. void tran_BeginTransaction (short msgIndex, Str255 p0)
  63.  
  64. {
  65.     Str255        msg;                    /* wait message */
  66.     Str255        tmpl;                    /* wait message template */
  67.     short            itemType;            /* item type */
  68.     Handle        item;                    /* handle to item */
  69.     Rect            box;                    /* item rectangle */
  70.  
  71.     utl_InitSpinCursor(BBArray, numBB, intervalBB);
  72.     ShowCursor();
  73.     Window = wstm_Restore(true, tranID, nil, &TranState);
  74.     SetPort(Window);
  75.     TextFont(0);
  76.     TextSize(12);
  77.     GetIndString(tmpl, stringsID, msgIndex);
  78.     utl_PlugParams(tmpl, msg, p0, nil, nil, nil);
  79.     GetDItem(Window, tranMsg, &itemType, &item, &box);
  80.     SetIText(item, msg);
  81.     oop_NewDialog(Window, tranModal, nil, &dispatch, true, 0, tranAbortBtn);
  82.     ShowWindow(Window);
  83.     oop_UpdateAll();
  84.     mtcp_BeginTransaction();
  85. }
  86.  
  87. /*_____________________________________________________________________
  88.  
  89.     tran_EndTransaction - End Server Transaction.
  90. _____________________________________________________________________*/
  91.  
  92. void tran_EndTransaction (void)
  93.  
  94. {
  95.     wstm_Save(Window, &TranState);
  96.     oop_DoClose(Window);
  97.     InitCursor();
  98.     oop_UpdateAll();
  99. }
  100.