home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1997: The Complete Utilities Toolkit / macworld-complete-utilities-1997.iso / Programming / Little Smalltalk v3.1.5 / C Source / Sources / CLStDoc.cp < prev    next >
Encoding:
Text File  |  1995-06-20  |  4.3 KB  |  146 lines  |  [TEXT/KAHL]

  1. //=============================================================================
  2. //    Little Smalltalk, version 3
  3. //    Written by Tim Budd, Oregon State University, July 1988
  4. //
  5. //    Symantec Think Class Library interface code 
  6. //        ©Julian Barkway, April 1994, all rights reserved.
  7. //
  8. //    CLStDoc.cp
  9. //    ----------
  10. //    This class provides basic document related functions.
  11. //
  12. //    
  13. //    Version History
  14. //    ---------------
  15. //    3.1.4 - First general release
  16. //    3.1.5 - Modified to allow specification of non-closeable windows
  17. //=============================================================================
  18.  
  19. #include <string.h>
  20. #include "Global.h"
  21. #include "Commands.h"
  22. #include "CApplication.h"
  23. #include "CBartender.h"
  24. #include "CDataFile.h"
  25. #include "CDecorator.h"
  26. #include "CDesktop.h"
  27. #include "CError.h"
  28. #include "CPanorama.h"
  29. #include "TBUtilities.h"
  30. #include "CLStDoc.h"
  31. #include "CTextPane.h"
  32. #include "CLStWindow.h"
  33. #include "CLStApp.h"
  34. #include "LStResources.h"
  35.  
  36. #define    LSTWIN_MIN        75
  37.  
  38. extern    CApplication     *gApplication;    /* The application */
  39. extern    CBartender        *gBartender;    /* The menu handling object */
  40. extern    CDecorator        *gDecorator;    /* Window dressing object    */
  41. extern    CDesktop        *gDesktop;        /* The enclosure for all windows */
  42. extern    CBureaucrat        *gGopher;        /* The current boss in the chain of command */
  43. extern    OSType            gSignature;        /* The application's signature */
  44. extern    CError            *gError;        /* The error handling object */
  45.  
  46. extern CLStApp        *gSmalltalk;
  47.  
  48.  
  49. //==============================================================================
  50. // Initialise a Document object.
  51. //==============================================================================
  52. void CLStDoc::ILStDoc (CApplication *super, Boolean printable)
  53. {
  54.     CDocument::IDocument (super, printable);
  55. }
  56.  
  57.  
  58. //==============================================================================
  59. // Make a window.
  60. // Amended 10.3.95 for v3.1.5 to allow specification of non-closeable windows.
  61. //==============================================================================
  62. CWindow *CLStDoc::BuildWindow (char *title, 
  63.                                Point *wPosition, Point *wSize, Boolean noClose)
  64. {
  65.     Str255    wTitle;
  66.     Rect    sr;
  67.     
  68.     itsWindow = new    (CLStWindow);
  69.     
  70.     if (noClose) {
  71.         Rect    bounds = {100, 100, 100, 100};    /* We'll do proper sizing and positioning later */
  72.         itsWindow->INewWindow (&bounds, FALSE, 0, FALSE, FALSE, gDesktop, this);
  73.     }
  74.     else
  75.         itsWindow->IWindow (WTemplate, FALSE, gDesktop, this);
  76.         
  77.     if (title != NULL) {
  78.         strcpy  ((char *)wTitle, title);
  79.         CtoPstr ((char *)wTitle);
  80.         itsWindow->SetTitle (wTitle);
  81.     }
  82.     
  83.     SetRect (&sr, LSTWIN_MIN, LSTWIN_MIN, 
  84.              screenBits.bounds.right, screenBits.bounds.bottom);    
  85.     itsWindow->SetSizeRect (&sr);
  86.     
  87.     gDecorator->PlaceNewWindow (itsWindow);
  88.  
  89.     if (wPosition != NULL)
  90.         itsWindow->Move (wPosition->h, wPosition->v);
  91.         
  92.     if (wSize != NULL)
  93.         itsWindow->ChangeSize (wSize->h, wSize->v);
  94.         
  95.     itsWindow->Select ();
  96.     ((CLStWindow *)itsWindow)->itsDocument = this;
  97.     return itsWindow;
  98. }
  99.  
  100.  
  101. //==============================================================================
  102. // Set the file type for this document. Allows specification of types other than
  103. // 'TEXT'
  104. //==============================================================================
  105. void CLStDoc::SetFileType (long fType)
  106. {
  107.     fileType = fType;
  108. }
  109.  
  110.  
  111. //==============================================================================
  112. // Return the document's window.
  113. //==============================================================================
  114. CWindow *CLStDoc::GetWindow (void)
  115. {
  116.     return itsMainPane->GetWindow ();
  117. }
  118.  
  119.  
  120. //==============================================================================
  121. // Process the standard file requester.
  122. //==============================================================================
  123. void CLStDoc::AskFileName (char *promptString, Boolean save, StandardFileReply *sfReply,
  124.                            SFTypeList fTypes, short numFTypes)
  125. {
  126.     Point            location;
  127.     Str255            str;
  128.         
  129.     if (save) {
  130.         strcpy    ((char *)str, promptString);
  131.         CtoPstr   ((char *)str);
  132.         StandardPutFile (str, "\p", sfReply);
  133.     }
  134.     else
  135.         StandardGetFile (NULL, numFTypes, fTypes, sfReply);
  136. }
  137.  
  138.  
  139. //={OVERRIDE}==================================================================
  140. // Close confirmation handled by Smalltalk.
  141. //=============================================================================
  142. Boolean    CLStDoc::ConfirmClose (Boolean quitting)
  143. {
  144.     return TRUE;
  145. }
  146.