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

  1. /******************************************************************************
  2.     CEditPane.c
  3.     
  4.     Methods for a text editing pane.
  5.         
  6.     Copyright © 1989 Symantec Corporation. All rights reserved.
  7.  
  8.  ******************************************************************************/
  9.  
  10.  
  11. #include "CEditPane.h"
  12. #include "Commands.h"
  13. #include "CDocument.h"
  14. #include "CBartender.h"
  15. #include "Constants.h"
  16.  
  17. extern    CBartender    *gBartender;
  18.  
  19. void CEditPane::IEditPane(CView *anEnclosure, CBureaucrat *aSupervisor)
  20.  
  21. {
  22.     Rect    margin;
  23.  
  24.     CWASTEText::IWASTEText(anEnclosure, aSupervisor, 1, 1, 0, 0,
  25.                         sizELASTIC, sizELASTIC, -1);
  26.     FitToEnclosure(TRUE, TRUE);
  27.  
  28.         /**
  29.          **    Give the edit pane a little margin.
  30.          **    Each element of the margin rectangle
  31.          **    specifies by how much to change that
  32.          **    edge. Positive values are down and to
  33.          **    right, negative values are up and to
  34.          **    the left.
  35.          **
  36.          **/
  37.  
  38. //    SetRect(&margin, 3, 3, -3, -3); // margins increased for drag and drop
  39. //    ChangeSize(&margin, FALSE);
  40.  
  41.     SetTextMargin(4);
  42.  
  43. #ifdef WASTE11
  44.     InstallDragHandlers(); // to enable drag and drop
  45. #endif
  46. }
  47.  
  48. void CEditPane::DoCommand(long theCommand)
  49.  
  50. {
  51.     
  52.     if (((theCommand == cmdPaste) || (theCommand == cmdCut)) && 
  53.         !((CDocument *)itsSupervisor)->dirty) {
  54.         
  55.         ((CDocument *)itsSupervisor)->dirty = TRUE;
  56.         gBartender->EnableCmd(cmdSave);
  57.         gBartender->EnableCmd(cmdSaveAs);
  58.     }
  59.  
  60.     inherited::DoCommand(theCommand);
  61. }
  62.  
  63. /* not necessary -- handled by CWASTETCL
  64.  
  65. void CEditPane::DoKeyDown(char theChar, Byte keyCode, EventRecord *macEvent)
  66.  
  67. {
  68.     
  69.     inherited::DoKeyDown(theChar, keyCode, macEvent);
  70.  
  71.     switch (keyCode) {
  72.     
  73.         case KeyHome:
  74.         case KeyEnd:
  75.         case KeyPageUp:
  76.         case KeyPageDown:
  77.             break;
  78.             
  79.         default:    
  80.             if (!((CDocument *)itsSupervisor)->dirty) {
  81.                 ((CDocument *)itsSupervisor)->dirty = TRUE;
  82.                 gBartender->EnableCmd(cmdSave);
  83.                 gBartender->EnableCmd(cmdSaveAs);
  84.             }
  85.             break;
  86.     }
  87. }
  88.  
  89.  
  90. void CEditPane::DoAutoKey(char theChar, Byte keyCode, EventRecord *macEvent)
  91.  
  92. {
  93.     
  94.     inherited::DoAutoKey(theChar, keyCode, macEvent);
  95.  
  96.     switch (keyCode) {
  97.     
  98.         case KeyHome:
  99.         case KeyEnd:
  100.         case KeyPageUp:
  101.         case KeyPageDown:
  102.             break;
  103.             
  104.         default:    
  105.             if (!((CDocument *)itsSupervisor)->dirty) {
  106.                 ((CDocument *)itsSupervisor)->dirty = TRUE;
  107.                 gBartender->EnableCmd(cmdSave);
  108.                 gBartender->EnableCmd(cmdSaveAs);
  109.             }
  110.             break;
  111.     }
  112. }
  113.  
  114. */