home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C++ / Applications / Muddweller 1.2 / source code / Main / LogView.cp < prev    next >
Encoding:
Text File  |  1994-02-11  |  16.2 KB  |  681 lines  |  [TEXT/MPS ]

  1. /* LogView - Implementation of TLogView                                       */
  2.  
  3. #include "LogView.h"
  4.  
  5.         // • Toolbox
  6. #ifndef __FONTS__
  7. #include "Fonts.h"
  8. #endif
  9.  
  10. #ifndef __TOOLUTILS__
  11. #include "ToolUtils.h"
  12. #endif
  13.  
  14.         // • Implementation use
  15. #ifndef __GLOBALS__
  16. #include "Globals.h"
  17. #endif
  18.  
  19. #ifndef __LOGWINDOW__
  20. #include "LogWindow.h"
  21. #endif
  22.  
  23. #ifndef __MUDDOC__
  24. #include "MUDDoc.h"
  25. #endif
  26.  
  27. #ifndef __UMUDDWELLER__
  28. #include "UMUDDweller.h"
  29. #endif
  30.  
  31.  
  32. //------------------------------------------------------------------------------
  33.  
  34. const short kLeftInset = 4;
  35. const short kRightInset = 19;
  36. const short kScrlWidth = 15;
  37. const short kMaxScrapTE = 8000;
  38.  
  39. //------------------------------------------------------------------------------
  40.  
  41. #pragma segment MACommandRes
  42.  
  43. class TScrapTEView: public TTEView {
  44. public:
  45.     Handle fRealText;
  46.     
  47.     virtual pascal void Free (void);
  48.     virtual pascal long GivePasteData (Handle aDataHandle, ResType dataType);
  49.     virtual pascal void ITEView (TDocument *itsDocument, TView *itsSuperView,
  50.         VPoint *itsLocation, VPoint *itsSize, SizeDeterminer itsHDeterminer,
  51.         SizeDeterminer itsVDeterminer, Rect *itsInset, TextStyle *itsTextStyle,
  52.         short itsJustification, Boolean itsStyleType, Boolean itsAutoWrap);
  53.     virtual pascal void WriteToDeskScrap (void);
  54. };
  55.  
  56. pascal void TScrapTEView::Free (void)
  57. {
  58.     DisposIfHandle (fRealText);
  59.     inherited::Free ();
  60. }
  61.  
  62. pascal long TScrapTEView::GivePasteData (Handle aDataHandle, ResType dataType)
  63. {
  64.     long size;
  65.     
  66.     if (fRealText && (dataType == 'TEXT')) {
  67.         size = GetHandleSize (fRealText);
  68.         if (aDataHandle) {
  69.             SetPermHandleSize (aDataHandle, size);
  70.             BlockMove (*fRealText, *aDataHandle, size);
  71.         }
  72.         return size;
  73.     } else
  74.         return inherited::GivePasteData (aDataHandle, dataType);
  75. }
  76.  
  77. pascal void TScrapTEView::ITEView (TDocument *itsDocument, TView *itsSuperView,
  78.         VPoint *itsLocation, VPoint *itsSize, SizeDeterminer itsHDeterminer,
  79.         SizeDeterminer itsVDeterminer, Rect *itsInset, TextStyle *itsTextStyle,
  80.         short itsJustification, Boolean itsStyleType, Boolean itsAutoWrap)
  81. {
  82.     fRealText = NULL;
  83.     inherited::ITEView (itsDocument, itsSuperView, itsLocation, itsSize,
  84.         itsHDeterminer, itsVDeterminer, itsInset, itsTextStyle,
  85.         itsJustification, itsStyleType, itsAutoWrap);
  86. }
  87.  
  88. pascal void TScrapTEView::WriteToDeskScrap (void)
  89. {
  90.     if (fRealText)
  91.         FailOSErr (PutDeskScrapData ('TEXT', fRealText));
  92.     else
  93.         inherited::WriteToDeskScrap ();
  94. }
  95.  
  96.  
  97. //------------------------------------------------------------------------------
  98.  
  99. #pragma segment MACommandRes
  100.  
  101. class TLogCmd: public TCommand {
  102. public:
  103.     virtual pascal void DoIt (void);
  104.     virtual pascal void ILogCmd (TLogView *itsView, CmdNumber itsCmdNumber);
  105. };
  106.  
  107.  
  108. pascal void TLogCmd::DoIt (void)
  109. {
  110.     switch (fCmdNumber) {
  111.     case cCopy:
  112.         ((TLogView *) fView)->DoCopy ();
  113.         break;
  114.     }
  115. }
  116.  
  117.  
  118. pascal void TLogCmd::ILogCmd (TLogView *itsView, CmdNumber itsCmdNumber)
  119. {
  120.     ICommand (itsCmdNumber, NULL, itsView, NULL);
  121.     fCanUndo = FALSE;
  122.     fCausesChange = FALSE;
  123. }
  124.  
  125. //------------------------------------------------------------------------------
  126.  
  127. #pragma segment SMUDDocRes
  128.  
  129. pascal void CallActionProc (ControlHandle aCMgrControl, short partCode)
  130. {
  131.     TScrollBar *aScrollBar;
  132.  
  133.     aScrollBar = (TScrollBar *) GetCRefCon (aCMgrControl);
  134.     FailNIL (aScrollBar);
  135.     aScrollBar->ActionProc (partCode);
  136. }
  137.  
  138.  
  139. class TLogScrollBar: public TScrollBar {
  140. public:
  141.     virtual pascal void Activate (Boolean entering);
  142.     virtual pascal struct TCommand *DoMouseCommand (Point *theMouse,
  143.         EventInfo *info, Point *hysteresis);
  144.     virtual pascal void SuperViewChangedSize (VPoint *delta,
  145.         Boolean invalidate);
  146.     virtual pascal void TrackScrollBar (short partCode);
  147. };
  148.  
  149.  
  150. pascal void TLogScrollBar::Activate (Boolean entering)
  151. {
  152.     Rect itsRect;
  153.     Boolean wasVisible;
  154.     
  155.     itsRect = (**fCMgrControl).contrlRect;
  156.     if (fCMgrControl) {
  157.         if (Focus ()) {
  158.             if (entering)
  159.                 ShowControl (fCMgrControl);
  160.             else {
  161.                 HideControl (fCMgrControl);
  162.                 Draw (&itsRect);
  163.             }
  164.             ValidRect (&itsRect);
  165.         } else {
  166.             wasVisible = IsCMgrVisible ();
  167.             SetCMgrVisibility (FALSE);
  168.             if (entering)
  169.                 ShowControl (fCMgrControl);
  170.             else
  171.                 HideControl (fCMgrControl);
  172.             if (wasVisible && (!IsCMgrVisible ()))
  173.                 SetCMgrVisibility (wasVisible);
  174.         }
  175.     }
  176. }
  177.  
  178.  
  179. pascal struct TCommand *TLogScrollBar::DoMouseCommand (Point *theMouse,
  180.         EventInfo *, Point *)
  181. {
  182.     short partCode;
  183.     VCoordinate oldLongVal, newLongVal;
  184.     
  185.     oldLongVal = fLongVal;
  186.     switch (TestControl (fCMgrControl, *theMouse)) {
  187.     case inUpButton:
  188.     case inDownButton:
  189.     case inPageUp:
  190.     case inPageDown:
  191.         partCode = TrackControl (fCMgrControl, *theMouse,
  192.             (ProcPtr) CallActionProc);
  193.         if (fLongVal != oldLongVal) DoChoice (this, fDefChoice);
  194.         break;
  195.     case inThumb:
  196.         if (TrackControl(fCMgrControl, *theMouse, NULL) == inThumb) {
  197.             if (GetVal () == GetMax ())
  198.                 newLongVal = ((long) GetMax ()) << fBitsToShift;
  199.             else
  200.                 newLongVal = ((long) GetVal ()) << fBitsToShift;
  201.             if (newLongVal != oldLongVal) {
  202.                 ((TLogView *) fSuperView)->Focus ();
  203.                 ((TLogView *) fSuperView)->fBT->BTScroll (0, - newLongVal -
  204.                     ((TLogView *) fSuperView)->fBT->fBounds.top, kRedraw);
  205.                 ((TLogView *) fSuperView)->SynchScrollBar (kRedraw);
  206.             }
  207.         }
  208.         break;
  209.     }
  210.     return NULL;
  211. }
  212.  
  213. pascal void TLogScrollBar::SuperViewChangedSize (VPoint *delta,
  214.         Boolean invalidate)
  215. {
  216.     Locate (fLocation.h + delta->h, fLocation.v, invalidate);
  217.     Resize (fSize.h, fSize.v + delta->v, invalidate);
  218. }
  219.  
  220.  
  221. pascal void TLogScrollBar::TrackScrollBar (short partCode)
  222. {
  223.     TBigText *bt;
  224.     long delta;
  225.     
  226.     bt = ((TLogView *) fSuperView)->fBT;
  227.     switch (partCode) {
  228.     case inPageUp:
  229.         delta = fSuperView->fSize.v;
  230.         break;
  231.     case inPageDown:
  232.         delta = -fSuperView->fSize.v;
  233.         break;
  234.     case inUpButton:
  235.         delta = bt->fLineHeight;
  236.         break;
  237.     case inDownButton:
  238.         delta = -bt->fLineHeight;
  239.         break;
  240.     default:
  241.         return;
  242.     }
  243.     ((TLogView *) fSuperView)->Focus ();
  244.     bt->BTScroll (0, delta, kRedraw);
  245.     ((TLogView *) fSuperView)->SynchScrollBar (kRedraw);
  246. }
  247.  
  248.  
  249. //------------------------------------------------------------------------------
  250.  
  251. #pragma segment MAActivate
  252.  
  253. pascal void TLogView::Activate (Boolean entering)
  254. {
  255.     TLogWindow *aLogWindow;
  256.     
  257.     aLogWindow = (TLogWindow *) GetWindow ();
  258.     if (aLogWindow->fTarget == this) {
  259.         if (Focus ()) fBT->BTActivate (entering, kRedraw);
  260.     }
  261.     inherited::Activate (entering);
  262. }
  263.  
  264.  
  265. //------------------------------------------------------------------------------
  266.  
  267. #pragma segment SMUDDocRes
  268.  
  269. pascal long TLogView::AddText (unsigned char *textBuf, long count)
  270. {
  271.     if (Focus ()) {
  272.         fBT->BTAppend (textBuf, count, kRedraw);
  273.         if (fBT->fBounds.bottom > fBT->fDisplay.bottom)
  274.             fBT->BTScroll (0, fSize.v - fBT->fBounds.bottom, kRedraw);
  275.         SynchScrollBar (kRedraw);
  276.     }
  277.     return count;
  278. }
  279.  
  280.  
  281. //------------------------------------------------------------------------------
  282.  
  283. #pragma segment SMUDDocRes
  284.  
  285. pascal void TLogView::ClikLoop (Point pt)
  286. {
  287.     static unsigned long ticks = 0;
  288.     
  289.     if (((pt.v < fBT->fDisplay.top) || (pt.v > fBT->fDisplay.bottom)) &&
  290.             ((unsigned long) (TickCount () - ticks) >= kClikDelay)) {
  291.         ticks = TickCount ();
  292.         fBT->BTScroll (0, (pt.v < 0) ? fBT->fLineHeight: -fBT->fLineHeight,
  293.             kRedraw);
  294.         SynchScrollBar (kRedraw);
  295.         Focus ();
  296.     }
  297. }
  298.  
  299.  
  300. //------------------------------------------------------------------------------
  301.  
  302. #pragma segment SMUDDocRes
  303.  
  304. static Handle txtHdl;
  305. static TScrapTEView *clipTEView;
  306.  
  307. pascal void DoCopyHandler (short , long , void * )
  308. {
  309.     DisposIfHandle (txtHdl);
  310.     txtHdl = NULL;
  311.     FreeIfObject (clipTEView);
  312.     clipTEView = NULL;
  313. }
  314.  
  315. pascal void TLogView::DoCopy (void)
  316. {
  317.     TextStyle clipStyle;
  318.     VPoint clipSize;
  319.     Rect clipMargins;
  320.     FailInfo fi;
  321.     long size;
  322.     Handle h;
  323.     
  324.     size = fBT->fSelEnd - fBT->fSelStart;
  325.     if (size > kMaxScrapTE) size += kMaxScrapTE;
  326.     h = NewPermHandle (size);
  327.     while (!h) {
  328.         if (!((TMUDDwellerApp *) gApplication)->DropSome (fDocument)) break;
  329.         h = NewPermHandle (size);
  330.     }
  331.     FailNIL (h);
  332.     ((TMUDDwellerApp *) gApplication)->BuildReserves (fDocument);
  333.     DisposIfHandle (h);
  334.     txtHdl = NULL;
  335.     clipTEView = NULL;
  336.     CatchFailures (&fi, DoCopyHandler, kDummyLink);
  337.     txtHdl = fBT->BTGetText ();
  338.     FailNIL (txtHdl);
  339.     SetTextStyle (&clipStyle, applFont, 0, 12, &gRGBBlack);
  340.     SetVPt (&clipSize, 100, 50);
  341.     SetRect (&clipMargins, 0, 0, 10, 0);
  342.     clipTEView = new TScrapTEView;
  343.     FailNIL (clipTEView);
  344.     clipTEView->ITEView (NULL, NULL, &gZeroVPt, &clipSize, sizeSuperView,
  345.         sizeVariable, &clipMargins, &clipStyle, teJustSystem, TRUE, FALSE);
  346.     clipTEView->fAcceptsChanges = FALSE;
  347.     FailSpaceIsLow ();
  348.     if (size > kMaxScrapTE) {
  349.         clipTEView->fRealText = txtHdl;
  350.         txtHdl = NewPermHandle (kMaxScrapTE);
  351.         FailNIL (txtHdl);
  352.         BlockMove (*(clipTEView->fRealText), *txtHdl, kMaxScrapTE);
  353.     }
  354.     FailSpaceIsLow ();
  355.     clipTEView->StuffText (txtHdl);
  356.     FailSpaceIsLow ();
  357.     clipTEView->fFreeText = TRUE;
  358.     Success (&fi);
  359.     gApplication->ClaimClipboard (clipTEView);
  360. }
  361.  
  362. //------------------------------------------------------------------------------
  363.  
  364. #pragma segment SMUDDocRes
  365.  
  366. pascal TCommand *TLogView::DoKeyCommand (short ch, short aKeyCode,
  367.         EventInfo *info)
  368. {
  369.     TLogWindow *aLogWindow;
  370.     long delta;
  371.     
  372.     if (Focus ()) {
  373.         switch (ch) {
  374.         case chHome:
  375.             delta = -fBT->fBounds.top;
  376.             break;
  377.         case chEnd:
  378.             delta = fSize.v - fBT->fBounds.bottom;
  379.             break;
  380.         case chPageUp:
  381.             delta = fSize.v;
  382.             break;
  383.         case chPageDown:
  384.             delta = -fSize.v;
  385.             break;
  386.         default:
  387.             aLogWindow = (TLogWindow *) GetWindow ();
  388.             aLogWindow->SetTarget (aLogWindow->fCommandView);
  389.             if (gTarget == this) // to prevent endless recursion
  390.                 return inherited::DoKeyCommand (ch, aKeyCode, info);
  391.             else
  392.                 return gTarget->DoKeyCommand (ch, aKeyCode, info);
  393.         }
  394.         fBT->BTScroll (0, delta, kRedraw);
  395.         SynchScrollBar (kRedraw);
  396.     }
  397.     return inherited::DoKeyCommand (ch, aKeyCode, info);
  398. }
  399.  
  400.  
  401. //------------------------------------------------------------------------------
  402.  
  403. #pragma segment MASelCommand
  404.  
  405. pascal TCommand *TLogView::DoMenuCommand (CmdNumber aCmdNumber)
  406. {
  407.     TLogCmd *aLogCmd;
  408.     TLogWindow *aLogWindow;
  409.  
  410.     switch (aCmdNumber) {
  411.     case cCopy:
  412.         aLogCmd = new TLogCmd;
  413.         FailNIL (aLogCmd);
  414.         aLogCmd->ILogCmd (this, aCmdNumber);
  415.         return aLogCmd;
  416.     case cUndo:
  417.     case cPaste:
  418.     case cSelectAll:
  419.         aLogWindow = (TLogWindow *) GetWindow ();
  420.         aLogWindow->SetTarget (aLogWindow->fCommandView);
  421.         if (gTarget == this) // to prevent endless recursion
  422.             return inherited::DoMenuCommand (aCmdNumber);
  423.         else
  424.             return gTarget->DoMenuCommand (aCmdNumber);
  425.         break;
  426.     default:
  427.         return inherited::DoMenuCommand (aCmdNumber);
  428.     }
  429. }
  430.  
  431.  
  432. //------------------------------------------------------------------------------
  433.  
  434. #pragma segment SMUDDocRes
  435.  
  436. pascal struct TCommand *TLogView::DoMouseCommand (Point *theMouse,
  437.         EventInfo *info, Point *)
  438. {
  439.     TLogWindow *aLogWindow;
  440.  
  441.     aLogWindow = (TLogWindow *) GetWindow ();
  442.     if (!info->theShiftKey && Focus ()) fBT->BTSetSelect (0, 0, kRedraw);
  443.     aLogWindow->SetTarget (this);
  444.     if (Focus () && IsVisible ())
  445.         fBT->BTClick (theMouse, info->theClickCount, info->theShiftKey);
  446.     if (fBT->fSelStart == fBT->fSelEnd)
  447.         aLogWindow->SetTarget (aLogWindow->fCommandView);
  448.     return NULL;
  449. }
  450.  
  451.  
  452. //------------------------------------------------------------------------------
  453.  
  454. #pragma segment SMUDDocRes
  455.  
  456. pascal Boolean TLogView::DoSetCursor (Point localPoint, RgnHandle cursorRgn)
  457. {
  458.     GetDefaultCursorRgn (localPoint, cursorRgn);
  459.     UseROMMap (TRUE);
  460.     SetCursor (*GetCursor (iBeamCursor));
  461.     return TRUE;
  462. }
  463.  
  464.  
  465. //------------------------------------------------------------------------------
  466.  
  467. #pragma segment SMUDDocRes
  468.  
  469. pascal void TLogView::DoSetupMenus (void)
  470. {
  471.     TLogWindow *aLogWindow;
  472.  
  473.     aLogWindow = (TLogWindow *) GetWindow ();
  474.     inherited::DoSetupMenus ();
  475.     if (fBT->fSelStart != fBT->fSelEnd) Enable (cCopy, TRUE);
  476.     CanPaste ('TEXT');
  477.     Enable (cSelectAll, (**(aLogWindow->fCommandView->fHTE)).teLength > 0);
  478. }
  479.  
  480.  
  481. //------------------------------------------------------------------------------
  482.  
  483. #pragma segment SMUDDocRes
  484.  
  485. pascal void TLogView::Draw (Rect *area)
  486. {
  487.     fBT->Draw (area);
  488. }
  489.  
  490.  
  491. //------------------------------------------------------------------------------
  492.  
  493. #pragma segment MAClose
  494.  
  495. pascal void TLogView::Free (void)
  496. {
  497.     if (fBT) {
  498.         fBT->Free ();
  499.         fBT = NULL;
  500.     }
  501.     inherited::Free ();
  502. }
  503.  
  504.  
  505. //------------------------------------------------------------------------------
  506.  
  507. #pragma segment SMUDDocRes
  508.  
  509. pascal void TLogView::InstallSelection (Boolean , Boolean beActive)
  510. {
  511.     if (Focus ()) fBT->BTActivate (beActive, kRedraw);
  512. }
  513.  
  514.  
  515. //------------------------------------------------------------------------------
  516.  
  517. #pragma segment AOpen
  518.  
  519. pascal void TLogView::IRes (TDocument *itsDocument, TView *itsSuperView,
  520.         Ptr *itsParams)
  521. {
  522.     TBigText *aBT;
  523.     TextStyle aStyle;
  524.     Rect r;
  525.     
  526.     fBT = NULL;
  527.     fScrollBar = NULL;
  528.     inherited::IRes (itsDocument, itsSuperView, itsParams);
  529.     aBT = new TBigText;
  530.     FailNIL (aBT);
  531.     r.top = 0;
  532.     r.left = kLeftInset;
  533.     r.right = (short) (fSize.h - kRightInset);
  534.     r.bottom = (short) fSize.v;
  535.     aStyle.tsFont = ((TMUDDoc *) fDocument)->fFontNum;
  536.     aStyle.tsFace = 0;
  537.     aStyle.tsSize = ((TMUDDoc *) fDocument)->fFontSize;
  538.     aStyle.tsColor = gRGBBlack;
  539.     aBT->IBigText (&r, &aStyle, ((TMUDDoc *) fDocument)->fTabSize, this);
  540.     fBT = aBT;
  541.     FailSpaceIsLow ();
  542. }
  543.  
  544. //------------------------------------------------------------------------------
  545.  
  546. #pragma segment MAOpen
  547.  
  548. pascal void TLogView::Open (void)
  549. {
  550.     TScrollBar *aScrollBar;
  551.     VRect extent;
  552.     
  553.     aScrollBar = (TScrollBar *) FindSubView ('scrl');
  554.     fScrollBar = aScrollBar;
  555.     GetExtent (&extent); /* avoid flashing */
  556.     extent.right -= kScrlWidth; /* but draw scrollbar */
  557.     ValidVRect (&extent);
  558.     inherited::Open ();
  559. }
  560.  
  561. //------------------------------------------------------------------------------
  562.  
  563. #pragma segment SMUDDocRes
  564.  
  565. pascal void TLogView::Resize (VCoordinate width, VCoordinate height,
  566.         Boolean invalidate)
  567. {
  568.     Rect r;
  569.     VRect extent;
  570.     Boolean atend;
  571.     
  572.     inherited::Resize (width, height, invalidate);
  573.     r.top = 0;
  574.     r.left = kLeftInset;
  575.     r.right = (short) (fSize.h - kRightInset);
  576.     r.bottom = (short) fSize.v;
  577.     Focus ();
  578.     atend = fBT->fBounds.bottom <= fBT->fDisplay.bottom;
  579.     fBT->BTResize (&r, r.left, r.right, kDontRedraw);
  580.     if (atend && (fBT->fBounds.bottom > fBT->fDisplay.bottom))
  581.         fBT->BTScroll (0, fSize.v - fBT->fBounds.bottom, kDontRedraw);
  582.     SynchScrollBar (kDontRedraw);
  583.     GetExtent (&extent);
  584.     extent.right -= kScrlWidth;
  585.     InvalidVRect (&extent);
  586. }
  587.  
  588. //------------------------------------------------------------------------------
  589.  
  590. #pragma segment SMUDDocRes
  591.  
  592. pascal void TLogView::SetBaseStyle (TextStyle *theStyle, Boolean redraw)
  593. {
  594.     Boolean atend;
  595.     VRect extent;
  596.  
  597.     Focus ();
  598.     atend = fBT->fBounds.bottom <= fBT->fDisplay.bottom;
  599.     fBT->BTSetStyle (theStyle, ((TMUDDoc *) fDocument)->fTabSize, kDontRedraw);
  600.     if (atend && (fBT->fBounds.bottom > fBT->fDisplay.bottom))
  601.         fBT->BTScroll (0, fSize.v - fBT->fBounds.bottom, kDontRedraw);
  602.     SynchScrollBar (kDontRedraw);
  603.     if (redraw) {
  604.         GetExtent (&extent);
  605.         InvalidVRect (&extent);
  606.     }
  607. }
  608.  
  609. //------------------------------------------------------------------------------
  610.  
  611. #pragma segment SMUDDocRes
  612.  
  613. pascal void TLogView::SetMaxSize (long logSize)
  614. {
  615.     long oldbot;
  616.     VRect extent;
  617.     
  618.     fBT->fMaxLength = logSize;
  619.     if ((fBT->fLength > logSize) && Focus ()) {
  620.         oldbot = fBT->fBounds.bottom;
  621.         fBT->BTDrop (fBT->fLength - logSize, kDontRedraw);
  622.         SynchScrollBar (kDontRedraw);
  623.         GetExtent (&extent);
  624.         if (oldbot == fBT->fBounds.bottom)
  625.             extent.left = extent.right - kScrlWidth;
  626.         InvalidVRect (&extent);
  627.     }
  628. }
  629.  
  630. //------------------------------------------------------------------------------
  631.  
  632. #pragma segment SMUDDocRes
  633.  
  634. pascal void TLogView::SynchScrollBar (Boolean redraw)
  635. {
  636.     VRect bounds;
  637.     long val, max, oldval, oldmax;
  638.     short bts;
  639.     
  640.     if (!fScrollBar) return;
  641.     oldmax = fScrollBar->GetMax ();
  642.     oldval = fScrollBar->GetVal ();
  643.     bounds = fBT->fBounds;
  644.     max = bounds.bottom - bounds.top - fSize.v;
  645.     if (max < 0) max = 0;
  646.     val = -bounds.top;
  647.     fScrollBar->fLongMax = max;
  648.     fScrollBar->fLongVal = val;
  649.     bts = 0;
  650.     while (max > 32767) {
  651.         max >>= 1;
  652.         val >>= 1;
  653.         bts += 1;
  654.     }
  655.     fScrollBar->fBitsToShift = bts;
  656.     if (oldval > max) oldval = max;
  657.     if ((oldmax != max) || (oldval != val)) {
  658.         if ((!max && oldmax) || (oldval == val)) {
  659.             fScrollBar->SetMax ((short) max, redraw);
  660.             fScrollBar->SetVal ((short) val, kDontRedraw);
  661.         } else {
  662.             fScrollBar->SetMax ((short) max, kDontRedraw);
  663.             fScrollBar->SetVal ((short) val, redraw);
  664.         }
  665.     }
  666. }
  667.  
  668. //------------------------------------------------------------------------------
  669.  
  670. #pragma segment MAInit
  671.  
  672. void InitLogView (void)
  673. {
  674.     if (gDeadStripSuppression) {
  675.         TLogView *aLogView = new TLogView;
  676.         TLogScrollBar *aLogScrollBar = new TLogScrollBar;
  677.     }
  678. }
  679.  
  680. //------------------------------------------------------------------------------
  681.