home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Think Class Libraries / WASTE TCL 2.0b2 / WASTE VA / Source / x_CMain.cp < prev    next >
Encoding:
Text File  |  1996-06-16  |  4.8 KB  |  181 lines  |  [TEXT/KAHL]

  1. /******************************************************************************
  2.  x_CMain.cp
  3.  
  4.                 CMain Document Class
  5.     
  6.     Copyright Â© 1996 Dan Crevier. All rights reserved.
  7.  
  8.     Generated by Visual Architectâ„¢ 10:48 AM Sun, Jun 16, 1996
  9.  
  10.     This file is rewritten each time you generate code. You should not
  11.     make changes to this file; changes should go in the CMain.cp
  12.     file, instead.
  13.  
  14.     If you want to change how Visual Architect generates this file, you can
  15.     change the template for this file. It is "_Doc_cp" in the Visual Architect
  16.     Templates folder.
  17.  
  18.  ******************************************************************************/
  19.  
  20. #include "x_CMain.h"
  21.  
  22. #include "CMain.h"
  23.  
  24. #include "MainItems.h"
  25.  
  26. #include "ViewUtilities.h"
  27. #include "CApp.h"
  28.  
  29. #include <CApplication.h>
  30. #include <CBartender.h>
  31. #include <Commands.h>
  32. #include <Constants.h>
  33. #include <CDecorator.h>
  34. #include <CDesktop.h>
  35. #include <CFile.h>
  36. #include <TBUtilities.h>
  37. #include <CWindow.h>
  38.  
  39. extern    CApplication *gApplication;        /* The application                    */
  40. extern CDecorator    *gDecorator;        /* Decorator for arranging windows    */
  41. extern CDesktop        *gDesktop;            /* The visible Desktop                */
  42. extern CBartender    *gBartender;        /* Manages all menus                */
  43.  
  44. #include "CButton.h"
  45. #include "CVAWASTEText.h"
  46. #include "CStaticText.h"
  47. #include "CVAWASTEDlgText.h"
  48.  
  49.     // Define symbols for commands handled by this class
  50.     // Prevents a recompile every time any command changed.
  51.  
  52.  
  53.  
  54. TCL_DEFINE_CLASS_M1(x_CMain, x_CMain_super);
  55.  
  56. /**** C O N S T R U C T I O N / D E S T R U C T I O N   M E T H O D S ****/
  57.  
  58.  
  59. /******************************************************************************
  60.  Ix_CMain
  61.  
  62.     Initialize the document
  63.  ******************************************************************************/
  64.  
  65. void x_CMain::Ix_CMain()
  66.  
  67. {
  68.     IDocument(gApplication, FALSE);
  69.  
  70.         // Initialize data members below.
  71. }
  72.  
  73.  
  74. /******************************************************************************
  75.  MakeNewWindow
  76.  
  77.     Create a new, empty window.  Subclass may override to populate
  78.     the new window.
  79.  ******************************************************************************/
  80.  
  81. void x_CMain::MakeNewWindow(void)
  82.  
  83. {
  84.     itsWindow = TCLGetNamedWindow("\pMain", this);
  85.     
  86.     itsMainPane = (CPane*) TCLGetItemPointer(itsWindow, 0);
  87.  
  88.         // Initialize pointers to the subpanes in the window
  89.  
  90.   fMain_Butn4 = (CButton*) itsWindow->FindViewByID(kMain_Butn4ID);
  91.   ASSERT(member(fMain_Butn4, CButton));
  92.  
  93.   fMain_TextField = (CVAWASTEText*) itsWindow->FindViewByID(kMain_TextFieldID);
  94.   ASSERT(member(fMain_TextField, CVAWASTEText));
  95.  
  96.   fMain_Stat14 = (CStaticText*) itsWindow->FindViewByID(kMain_Stat14ID);
  97.   ASSERT(member(fMain_Stat14, CStaticText));
  98.  
  99.   fMain_DlgText = (CVAWASTEDlgText*) itsWindow->FindViewByID(kMain_DlgTextID);
  100.   ASSERT(member(fMain_DlgText, CVAWASTEDlgText));
  101.  
  102.   fMain_Stat18 = (CStaticText*) itsWindow->FindViewByID(kMain_Stat18ID);
  103.   ASSERT(member(fMain_Stat18, CStaticText));
  104.  
  105. }
  106.  
  107.  
  108. /******************************************************************************
  109.  NewFile {OVERRIDE}
  110.  
  111.     Create and display a new window.
  112.  
  113.     The name of this function is misleading.  NewFile leaves
  114.     itsFile NULL. Since this document doesn't use itsFile,
  115.     it remains NULL.
  116.  
  117.     Most of the work is done in MakeNewWindow.
  118.  ******************************************************************************/
  119.  
  120. void x_CMain::NewFile(void)
  121.  
  122. {
  123.     Str255            title;
  124.  
  125.     MakeNewWindow();                    /* Create window                    */
  126.     MakeNewContents();                    /* And contents                        */
  127.  
  128.     MakeWindowName(title);                /* Set window title                    */
  129.     itsWindow->SetTitle(title);
  130.  
  131.     itsWindow->Select();                /* Make the front window            */
  132. }
  133.  
  134.  
  135. /******************************************************************************
  136.  MakeWindowName
  137.  
  138.     Return a name for a new window.  The process of forming a
  139.     window name is highly application-dependent.  The default function
  140.     returns the file name, if there is a file.  Otherwise, the
  141.     window name, if it has a name, otherwise the Untitled string,
  142.     with the decorator's count appended.  Note that file names
  143.     do not yield unique window names.
  144.     Subclass may override.
  145.  ******************************************************************************/
  146.  
  147. void    x_CMain::MakeWindowName(
  148.     Str255        newName)
  149.  
  150. {
  151.     Str31        count;
  152.  
  153.     if (itsFile != NULL)
  154.         itsFile->GetName(newName);        /* Return file name                    */
  155.     else
  156.     {
  157.                                         /* Append window count to window    */
  158.                                         /*     title (from resource)            */
  159.         itsWindow->GetTitle(newName);
  160.         if (Length(newName) == 0)
  161.             GetIndString(newName, STRcommon, strUNTITLED);
  162.         NumToString(gDecorator->GetWCount(), count);
  163.         ConcatPStrings(newName, (unsigned char *)"\p ");
  164.         ConcatPStrings(newName, count);
  165.     }
  166. }
  167.  
  168.  
  169. /******************************************************************************
  170.  MakeNewContents
  171.  
  172.     Create "blank" document contents.  Subclass should override.
  173.  ******************************************************************************/
  174.  
  175. void x_CMain::MakeNewContents(void)
  176.  
  177. {
  178. }
  179.  
  180.  
  181.