home *** CD-ROM | disk | FTP | other *** search
/ Carousel Volume 2 #1 / carousel.iso / mactosh / tech / protocol.hqx / ProtocolSources.pit / UProtocol.inc1.p < prev    next >
Encoding:
Text File  |  1985-07-10  |  13.9 KB  |  651 lines

  1. {copyright 1986 by Herb Barad}
  2. {Protocol is a program to produce a PICT representation of a class}
  3. {hierarchy from a textual description.}
  4. {parts from Flow MacApp sample - Copyright 1985, 1986 by Apple Computer, Inc.}
  5.  
  6. CONST
  7.     myFileType = 'TEXT';
  8.  
  9.    {Command numbers}
  10.     cOutline    =    1000;
  11.     cChart        =    1001;
  12.     cShadow     =    1010;
  13.     {Do my own About... since I have >1 Alerts}
  14.     cAbout        =    1234;
  15.     phAboutApp1    =    5678;
  16.     phAboutApp2    =    5679;
  17.     phAboutApp3    =    5680;
  18.  
  19.     cSizeBase    =    1100;
  20.     cSizeMin    =    1109;
  21.     cSizeMax    =    1124;
  22.     {1101-1199 reserved for font sizes 1-99 pts.}
  23.  
  24.     cSavePICT    =    2000;
  25.  
  26.     kKeywords    =    1000;
  27.  
  28.    {Menu numbers}
  29.     mView        = 4;
  30.     mFont        = 5;
  31.     mSize        = 6;
  32.     mKeyword    = 7;
  33.  
  34.     kStaggerAmount    = 16;
  35.  
  36.     VAR
  37.         gFont:        INTEGER; {Font number}
  38.         gSize:        INTEGER; {Font Size in points}
  39.         gStaggerCount:    INTEGER;
  40.  
  41. {$S Protocol}
  42.     PROCEDURE OutlineSizes(fontNum: INTEGER);
  43.         VAR c:    CmdNumber;
  44.     BEGIN
  45.         FOR c := cSizeMin TO cSizeMax DO
  46.             BEGIN
  47.             IF RealFont(fontNum, c - cSizeBase) THEN
  48.                 SetStyle(c, [outline])
  49.             ELSE
  50.                 SetStyle(c, []);
  51.             END;
  52.     END;
  53.  
  54.  
  55.     PROCEDURE TProtocolApplication.IProtocolApplication;
  56.         LABEL    1;
  57.  
  58.         VAR fntName:    Str255;
  59.             strIndex:    INTEGER;
  60.             i:            INTEGER;
  61.             s:            Str255;
  62.             key:        KeyStr;
  63.             shape:        KShape;
  64.             alignment:    KAlignment;
  65.             aStyle:     Style;
  66.  
  67.             kMenu:        MenuHandle;
  68.             x:            INTEGER;
  69.  
  70.             FUNCTION  DeleteWord(VAR s: Str255): BOOLEAN; {return TRUE if string ends up empty}
  71.                 VAR x:    INTEGER;
  72.             BEGIN
  73.                 x := POS(' ', s);
  74.                 IF x <= 0 THEN
  75.                     BEGIN
  76.                     s := '';
  77.                     DeleteWord := TRUE;
  78.                     END
  79.                 ELSE
  80.                     BEGIN
  81.                     DELETE(s, 1, x);
  82.  
  83.                     WHILE (s <> '') & (s[1] = ' ') DO
  84.                         DELETE(s, 1, 1);
  85.                     DeleteWord := s = '';
  86.                     END;
  87.             END;
  88.  
  89.     BEGIN
  90.         IApplication(myFileType);
  91.  
  92.         InitProtocolchart;
  93.  
  94.         kMenu := GetMHandle(mKeyword);
  95.  
  96.         strIndex := 1;
  97.         WHILE TRUE DO
  98.             BEGIN
  99.             GetIndString(s, kKeywords, strIndex);
  100.             IF s = '' THEN LEAVE;
  101.  
  102.                 {uppercase string}
  103.             FOR i := 1 TO LENGTH(s) DO
  104.                 IF (s[i] >= 'a') & (s[i] <= 'z') THEN
  105.                     s[i] := CHR(ORD(s[i]) - 32);
  106.  
  107.                 {delete leading blanks}
  108.             WHILE (s <> '') & (s[1] = ' ') DO
  109.                 DELETE(s, 1, 1);
  110.             IF s = '' THEN GOTO 1;
  111.  
  112.                 {find end of keyword}
  113.             x := POS(' ', s);
  114.             IF x <= 0 THEN GOTO 1
  115.             ELSE
  116.                 BEGIN
  117.                 key := COPY(s, 1, x-1);
  118.  
  119.                     {delete keyword}
  120.                 IF DeleteWord(s) THEN GOTO 1;
  121.  
  122.                 CASE s[1] OF
  123.                     'N':    shape := shNone;
  124.                     'O':    shape := shOval;
  125.                     'D':    shape := shDRect;
  126.                     'R':    IF (s[2] = 'R') OR (s[2] = 'O') THEN
  127.                                 shape := shRoundRect
  128.                             ELSE
  129.                                 shape := shRect;
  130.                     OTHERWISE
  131.                             GOTO 1;
  132.                     END;
  133.  
  134.                     {delete shape spec}
  135.                 IF DeleteWord(s) THEN GOTO 1;
  136.  
  137.                 CASE s[1] OF
  138.                     'L':        alignment := alLeft;
  139.                     'M', 'C':    alignment := alMiddle;
  140.                     'R':        alignment := alRight;
  141.                     OTHERWISE    GOTO 1;
  142.                     END;
  143.  
  144.                     {delete alignment spec}
  145.                 IF DeleteWord(s) THEN ;
  146.  
  147.                 aStyle := [];
  148.                 WHILE s <> '' DO
  149.                     BEGIN
  150.                     CASE s[1] OF
  151.                         'B':    aStyle := aStyle + [bold];
  152.                         'I':    aStyle := aStyle + [italic];
  153.                         'U':    aStyle := aStyle + [underline];
  154.                         'O':    aStyle := aStyle + [outline];
  155.                         'S':    aStyle := aStyle + [shadow];
  156.                         'C':    aStyle := aStyle + [condense];
  157.                         'E':    aStyle := aStyle + [extend];
  158.                         OTHERWISE
  159.                                 GOTO 1
  160.                         END;
  161.                     IF DeleteWord(s) THEN ;
  162.                     END;
  163.  
  164.                 AddKeyword(key, shape, alignment, aStyle);
  165.  
  166.                 AppendMenu(kMenu, key);
  167.                 END;
  168. 1:
  169.             strIndex := strIndex + 1;
  170.             END;
  171.  
  172.         AddResMenu(GetMHandle(mFont), 'FONT');
  173.  
  174.         {Find out what applFont maps to, so that we set gFont to a real font number.
  175.          This code is inefficient but does not depend on absolute memory locations.
  176.          The other approach is to look at the low memory global that contains the right value.}
  177.         GetFontName(applFont, fntName);
  178.         GetFNum(fntName, gFont);
  179.         OutlineSizes(gFont);
  180.         gSize := 10;
  181.         gStaggerCount := 0;
  182.     END;
  183.  
  184.  
  185.     FUNCTION  TProtocolApplication.DoMakeDocument(itsCmdNumber: CmdNumber): TDocument;
  186.         VAR flowDocument:  TProtocolDocument;
  187.     BEGIN
  188.         New(flowDocument);
  189.         flowDocument.IProtocolDocument;
  190.         DoMakeDocument := flowDocument;
  191.     END;
  192.  
  193.  
  194.     FUNCTION  TProtocolApplication.DoMenuCommand(aCmdNumber: CmdNumber): TCommand;
  195.         VAR aName:    Str255;
  196.             menu:    INTEGER;
  197.             item:    INTEGER;
  198.  
  199.         PROCEDURE TellDocToGen(aProtocolDoc: TProtocolDocument);
  200.         BEGIN
  201.             IF aProtocolDoc.fChartView.fFrame <> NIL THEN
  202.                 aProtocolDoc.fChartView.GeneratePict;
  203.         END;
  204.  
  205.         PROCEDURE TellDocSizeChanged(aDoc: TDocument);
  206.             VAR aProtocolDoc:    TProtocolDocument;
  207.         BEGIN
  208.             aProtocolDoc := TProtocolDocument(aDoc);
  209.             IF aProtocolDoc.fTree <> NIL THEN
  210.                 BEGIN
  211.                 aProtocolDoc.fTree.SetSize(gSize);
  212.                 TellDocToGen(aProtocolDoc);
  213.                 END;
  214.         END;
  215.  
  216.  
  217.         PROCEDURE TellDocFontChanged(aDoc: TDocument);
  218.             VAR aProtocolDoc:    TProtocolDocument;
  219.         BEGIN
  220.             aProtocolDoc := TProtocolDocument(aDoc);
  221.             IF aProtocolDoc.fTree <> NIL THEN
  222.                 BEGIN
  223.                 aProtocolDoc.fTree.SetFont(gFont);
  224.                 TellDocToGen(aProtocolDoc);
  225.                 END;
  226.         END;
  227.  
  228.     BEGIN
  229.         DoMenuCommand := gNoChanges;
  230.         CmdToMenuItem(aCmdNumber, menu, item);
  231.         IF (aCmdNumber = cAbout) THEN
  232.             BEGIN
  233.             StdAlert(phAboutApp1);
  234.             StdAlert(phAboutApp2);
  235.             StdAlert(phAboutApp3);
  236.             END
  237.         ELSE IF (cSizeMin <= aCmdNumber) AND (aCmdNumber <= cSizeMax) THEN
  238.             BEGIN
  239.             gSize := aCmdNumber - cSizeBase;
  240.             ForAllDocumentsDo(TellDocSizeChanged);
  241.             END
  242.         ELSE IF menu = mFont THEN
  243.             BEGIN
  244.             GetItem(GetMHandle(menu), item, aName);
  245.             GetFNum(aName, gFont);
  246.             ForAllDocumentsDo(TellDocFontChanged);
  247.             OutlineSizes(gFont);
  248.             END
  249.         ELSE
  250.             DoMenuCommand := INHERITED DoMenuCommand(aCmdNumber);
  251.     END;
  252.  
  253.  
  254.     PROCEDURE TProtocolApplication.DoSetupMenus;
  255.         VAR item, fnt, c:    INTEGER;
  256.             aName:            Str255;
  257.             aMenuHandle:    MenuHandle;
  258.     BEGIN
  259.         INHERITED DoSetupMenus;
  260.  
  261.         aMenuHandle := GetMHandle(mFont);
  262.         FOR item := 1 TO CountMItems(aMenuHandle) DO
  263.             BEGIN
  264.             GetItem(aMenuHandle, item, aName);
  265.             GetFNum(aName, fnt);
  266.             EnableItem(aMenuHandle, item);
  267.             CheckItem(aMenuHandle, item, fnt = gFont);
  268.             END;
  269.  
  270.         FOR c := cSizeMin TO cSizeMax DO
  271.             EnableCheck(c, TRUE, (c - cSizeBase) = gSize);
  272.     END;
  273.  
  274.  
  275.  
  276.     PROCEDURE TProtocolDocument.IProtocolDocument;
  277.     BEGIN
  278.         IDocument(myFileType, 'FLOW', kUsesDataFork, NOT kUsesRsrcFork,
  279.                     NOT kDataOpen, NOT kRsrcOpen);
  280.  
  281.         fFileType := myFileType;
  282.  
  283.         fChartView := NIL;
  284.         fOutlineView := NIL;
  285.         fTree := NIL;
  286.         fText := NewHandle(0);
  287.         fPICT := NIL;
  288.     END;
  289.  
  290.  
  291.     PROCEDURE TProtocolDocument.DoNeedDiskSpace(VAR dataForkBytes, rsrcForkBytes: LONGINT);
  292.     BEGIN
  293.         IF fPICT = NIL THEN
  294.             dataForkBytes := GetHandleSize(fText)
  295.         ELSE
  296.             dataForkBytes := 512 + fPICT^^.picSize;
  297.     END;
  298.  
  299.  
  300.     PROCEDURE TProtocolDocument.DoMakeViews(forPrinting: BOOLEAN);
  301.         VAR aChartView:     TChartView;
  302.             anOutlineView:    TOutlineView;
  303.     BEGIN
  304.         New(aChartView);
  305.         fChartView := aChartView;
  306.         aChartView.IChartView(SELF);
  307.  
  308.         IF forPrinting THEN
  309.             aChartView.GeneratePict
  310.         ELSE
  311.             BEGIN
  312.             New(anOutlineView);
  313.             fOutlineView := anOutlineView;
  314.             anOutlineView.IOutlineView(SELF, fText);
  315.             END;
  316.     END;
  317.  
  318.  
  319.     PROCEDURE TProtocolDocument.DoMakeWindows; OVERRIDE;
  320.  
  321.         VAR aWindow:    TWindow;
  322.  
  323.     BEGIN
  324.     aWindow := NewSimpleWindow(kIDStdWindow, NOT kDialogWindow, kWantHScrollBar, kWantVScrollBar,
  325.                                     fOutlineView);
  326.     AdaptToScreen(aWindow);
  327.     SimpleStagger(aWindow, kStaggerAmount, kStaggerAmount, gStaggerCount);
  328.     END;
  329.  
  330.  
  331.     FUNCTION  TProtocolDocument.DoMenuCommand(aCmdNumber: CmdNumber): TCommand; OVERRIDE;
  332.         VAR oldType:    OSType;
  333.             oldCreator: OSType;
  334.             oldPort:    GrafPtr;
  335.             oldSaveExists: BOOLEAN;
  336.             oldTitle:    STRING[63];
  337.             pic:        PicHandle;
  338.             port:        GrafPort;
  339.             r:            Rect;
  340.  
  341.     BEGIN
  342.             {cSavePICT is enabled by the chart view}
  343.         IF aCmdNumber = cSavePICT THEN {??? This is a little kludgy right now ???}
  344.             BEGIN
  345.             gApplication.CommitLastCommand;
  346.  
  347.             oldType := fFileType;
  348.             oldCreator := fCreator;
  349.             oldSaveExists := fSaveExists;
  350.             oldTitle := fTitle;
  351.             GetPort(oldPort);
  352.  
  353.             fFileType := 'PICT';
  354.             fCreator := 'MDRW';
  355.             {This will save to NEW file, not to same existsing outline file}
  356.             fSaveExists := FALSE;
  357.             fTitle := Concat(oldTitle, '.PICT');
  358.  
  359.             r := fChartView.fExtentRect;
  360.             OpenPort(@port);
  361.             PortSize(r.right-r.left, r.bottom-r.top);
  362.             ClipRect(r);
  363.  
  364.             pic := OpenPicture(r);
  365.  
  366.             gNowPrinting := FALSE;
  367.             IF fChartView.fTree <> NIL THEN
  368.                 fChartView.fTree.Draw(r, TRUE);
  369.  
  370.             ClosePicture;
  371.             fPICT := pic;
  372.  
  373.             Save(aCmdNumber, kAskForFilename, kMakingCopy);
  374.  
  375.             KillPicture(pic);
  376.             fPICT := NIL;
  377.  
  378.             fFileType := oldType;
  379.             fCreator := oldCreator;
  380.             fSaveExists := oldSaveExists;
  381.             fTitle := oldTitle;
  382.             SetPort(oldPort);
  383.  
  384.             ClosePort(@port);
  385.  
  386.             DoMenuCommand := gNoChanges;
  387.             END
  388.         ELSE
  389.             DoMenuCommand := INHERITED DoMenuCommand(aCmdNumber);
  390.     END;
  391.  
  392.  
  393.     PROCEDURE TProtocolDocument.DoRead(aRefNum: INTEGER; rsrcExists, forPrinting: BOOLEAN);
  394.         VAR numChars:        LONGINT;
  395.     BEGIN
  396.         FailOSErr(GetEOF(aRefNum, numChars));
  397.         SetHandleSize(fText, numChars);
  398.         FailOSErr(FSRead(aRefNum, numChars, fText^));
  399.     END;
  400.  
  401.  
  402.     PROCEDURE TProtocolDocument.DoWrite(aRefNum: INTEGER; makingCopy: BOOLEAN);
  403.         VAR n:    LONGINT;
  404.             i:    INTEGER;
  405.             v:    LONGINT;
  406.     BEGIN
  407.         IF fPICT = NIL THEN
  408.             BEGIN
  409.             n := GetHandleSize(fText);
  410.             FailOSErr(FSWrite(aRefNum, n, fText^));
  411.             END
  412.         ELSE
  413.             BEGIN
  414.             v := 0;
  415.             FOR i := 1 TO 512 DIV 4 DO
  416.                 BEGIN
  417.                 n := 4;
  418.                 FailOSErr(FSWrite(aRefNum, n, @v));
  419.                 END;
  420.  
  421.             n := fPICT^^.picSize;
  422.             FailOSErr(FSWrite(aRefNum, n, Ptr(fPICT^)));
  423.             END;
  424.     END;
  425.  
  426.  
  427.  
  428.     PROCEDURE TProtocolDocument.FreeData; OVERRIDE;
  429.     BEGIN
  430.         SetHandleSize(fText, 0);
  431.     END;
  432.  
  433.  
  434.     PROCEDURE TOutlineView.IOutlineView(itsDocument: TProtocolDocument; aText: Handle);
  435.         VAR aTEView:        TTEView;
  436.             itsExtent:        Rect;
  437.             aStdHandler:    TStdPrintHandler;
  438.     BEGIN
  439.         fProtocolDoc := TProtocolDocument(itsDocument);
  440.         SetRect(itsExtent, 0, 0, 1000, 100);
  441.         ITEView(NIL, itsDocument, itsDocument.fText, Point(0), cTyping, 10, 8, 1000, 100,
  442.             monaco, 12, [], sizeFixed, sizeVariable, kUnlimited);
  443.         New(aStdHandler);
  444.         aStdHandler.IStdPrintHandler(SELF, FALSE);
  445.     END;
  446.  
  447.  
  448.     FUNCTION  TOutlineView.DoMenuCommand(aCmdNumber: CmdNumber): TCommand;
  449.         VAR aChartView: TChartView;
  450.             kwCmd:        TKWCommand;
  451.             menuNum:    INTEGER;
  452.             itemNum:    INTEGER;
  453.             key:        Str255;
  454.     BEGIN
  455.         DoMenuCommand := gNoChanges;
  456.         IF aCmdNumber < 0 THEN
  457.             BEGIN
  458.             CmdToMenuItem(aCmdNumber, menuNum, itemNum);
  459.  
  460.             IF menuNum = mKeyword THEN
  461.                 BEGIN
  462.                 GetItem(GetMHandle(mKeyword), itemNum, key);
  463.  
  464.                 New(kwCmd);
  465.                 kwCmd.IKWCommand(SELF, aCmdNumber, key);
  466.                 DoMenuCommand := kwCmd;
  467.                 END;
  468.             END
  469.         ELSE
  470.         CASE aCmdNumber OF
  471.             cOutline:    BEGIN END;
  472.             cChart:     BEGIN
  473.                         aChartView := fProtocolDoc.fChartView;
  474.                         aChartView.GeneratePict;
  475.                         fFrame.HaveView(aChartView);
  476.                         END;
  477.             OTHERWISE    DoMenuCommand := INHERITED DoMenuCommand(aCmdNumber);
  478.             END;
  479.     END;
  480.  
  481.  
  482.     PROCEDURE TOutlineView.DoSetupMenus;
  483.         CONST    kwCommand1 = -(256*mKeyword+1);
  484.  
  485.         VAR cmd:        CmdNumber;
  486.             cmdLast:    CmdNumber;
  487.     BEGIN
  488.         INHERITED DoSetupMenus;
  489.         EnableCheck(cOutline, TRUE, TRUE);
  490.         EnableCheck(cChart, TRUE, FALSE);
  491.  
  492.         cmdLast := kwCommand1 - CountMItems(GetMHandle(mKeyword)) + 1;
  493.  
  494.         FOR cmd := kwCommand1 DOWNTO cmdLast DO {cmdLast <= kwCommand}
  495.             Enable(cmd, TRUE);
  496.     END;
  497.  
  498.  
  499.     PROCEDURE TChartView.IChartView(itsDocument: TProtocolDocument);
  500.         VAR r:                Rect;
  501.             aStdHandler:    TStdPrintHandler;
  502.     BEGIN
  503.         fProtocolDoc := TProtocolDocument(itsDocument);
  504.         fTree := NIL;
  505.         fMinSize := Point($00010001);
  506.         fTarget := SELF;
  507.         fShadow := FALSE;
  508.         fWouldMakePICTScrap := TRUE;
  509.  
  510.         SetRect(r, 0, 0, 8, 8);     {arbitrary; actual extent calculated at GeneratePict time}
  511.         IView(NIL, itsDocument, r, sizeFixed, sizeFixed, TRUE, hlOff);
  512.         New(aStdHandler);
  513.         aStdHandler.IStdPrintHandler(SELF, TRUE);
  514.     END;
  515.  
  516.  
  517.     PROCEDURE TChartView.CalcMinExtent(VAR minExtent: Rect);
  518.     BEGIN
  519.         minExtent.topLeft := Point(0);
  520.         minExtent.botRight := fMinSize;
  521.     END;
  522.  
  523.  
  524.     FUNCTION  TChartView.DoMenuCommand(aCmdNumber: CmdNumber): TCommand;
  525.     BEGIN
  526.         DoMenuCommand := gNoChanges;
  527.         CASE aCmdNumber OF
  528.             cChart:     BEGIN END;
  529.             cOutline:    fFrame.HaveView(fProtocolDoc.fOutlineView);
  530.             cShadow:    BEGIN
  531.                         fShadow := NOT fShadow;
  532.                         GeneratePict;
  533.                         END;
  534.             OTHERWISE    DoMenuCommand := INHERITED DoMenuCommand(aCmdNumber);
  535.             END;
  536.     END;
  537.  
  538.  
  539.     PROCEDURE TChartView.DoPrinterChanged;
  540.     BEGIN
  541.         INHERITED DoPrinterChanged;
  542.         IF fTree <> NIL THEN
  543.             BEGIN
  544.             GeneratePict;
  545.             IF fFrame <> NIL THEN
  546.                 fFrame.ForceRedraw;
  547.             END;
  548.     END;
  549.  
  550.  
  551.     PROCEDURE TChartView.DoSetupMenus;
  552.     BEGIN
  553.         INHERITED DoSetupMenus;
  554.         EnableCheck(cChart, TRUE, TRUE);
  555.         EnableCheck(cOutline, TRUE, FALSE);
  556.         EnableCheck(cShadow, TRUE, fShadow);
  557.  
  558.         Enable(cSavePICT, TRUE); {command is handled by the document}
  559.     END;
  560.  
  561.  
  562.     PROCEDURE TChartView.Draw(area: Rect);
  563.     BEGIN
  564.         gNowPrinting := gPrinting;
  565.         IF fTree <> NIL THEN
  566.             fTree.Draw(area, FALSE);
  567.     END;
  568.  
  569.  
  570.     PROCEDURE TChartView.GeneratePict;
  571.         CONST CR = 13;
  572.  
  573.         TYPE PAOC81 = PACKED ARRAY[0..80] OF CHAR;
  574.  
  575.         VAR aTree:        TTree;
  576.             h:            Handle;
  577.             len, n:     INTEGER;
  578.             crChar:     Char;
  579.             pCr:        Ptr;
  580.             lineLen:    INTEGER;
  581.             str:        String80;
  582.             nextReturn: LONGINT;
  583.             viewRect:    Rect;
  584.  
  585.     BEGIN
  586.         FreeObject(fTree);
  587.  
  588.         New(aTree);
  589.         aTree.ITree(gFont, gSize, fShadow);
  590.         fProtocolDoc.fTree := aTree;
  591.  
  592.         h := Handle(fProtocolDoc.fText);
  593.         len := GetHandleSize(h);
  594.         crChar := Chr(CR);
  595.         pCR := Ptr(ORD(@crChar)+1);
  596.  
  597.         n := 0;
  598.         WHILE n < len DO
  599.             BEGIN
  600.                 {find next carriage return}
  601.             nextReturn := Munger(h, n, pCR, 1, NIL, 0);
  602.             IF nextReturn < 0 THEN {not found}
  603.                 nextReturn := len;
  604.  
  605.                 {nextReturn - n is size of next line}
  606.             lineLen := nextReturn - n;
  607.             IF lineLen > 80 THEN
  608.                 lineLen := 80;
  609.  
  610.                 {Get next line of text}
  611.             BlockMove(Ptr(LONGINT(h^) + n), Ptr(ORD(@str) + 1), lineLen);
  612.             PAOC81(str)[0] := CHR(lineLen); {set length of line}
  613.  
  614.             IF Length(Str) > 0 THEN
  615.                 aTree.GenLine(str);
  616.  
  617.             n := nextReturn + 1; {skip the CR}
  618.             END;
  619.  
  620.         gNowPrinting := gPrinting;
  621.         DoCheckPrinter;
  622.         aTree.Layout(viewRect);
  623.         fMinSize := viewRect.botRight;
  624.  
  625.         fTree := aTree;
  626.         SetExtent(viewRect);
  627.         DoPagination;
  628.         IF fFrame <> NIL THEN
  629.             fFrame.ForceRedraw;
  630.     END;
  631.  
  632.  
  633.     PROCEDURE TKWCommand.IKWCommand(itsTEView: TTEView; itsCmdNumber: CmdNumber; s: Str255);
  634.         VAR h:            Handle;
  635.             size:        INTEGER;
  636.     BEGIN
  637.         ITECommand(itsTEView, itsCmdNumber, TRUE);
  638.  
  639.         size := Length(s);
  640.  
  641.         h := NewHandle(size);
  642.         FailNIL(h);
  643.  
  644.         BlockMove(Ptr(ORD(@s)+1), h^, size);
  645.  
  646.         fNewText := h;
  647.         fNewStart := fHTE^^.selStart;
  648.         fNewEnd := fNewStart + size;
  649.     END;
  650.  
  651.