home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / lib / mac / UserInterface / LGABox_fixes.cp < prev    next >
Encoding:
Text File  |  1998-04-08  |  5.3 KB  |  160 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19.  
  20. // LGABox_fixes.cp
  21.  
  22. /*====================================================================================*/
  23.     #pragma mark INCLUDE FILES
  24. /*====================================================================================*/
  25.  
  26. #include "LGABox_fixes.h"
  27.  
  28.  
  29. #pragma mark -
  30. /*====================================================================================*/
  31.     #pragma mark CLASS IMPLEMENTATIONS
  32. /*====================================================================================*/
  33.  
  34.  
  35. /*======================================================================================
  36.     Turds be gone! Assumes entire frame is visible through superview.
  37. ======================================================================================*/
  38.  
  39. void LGABox_fixes::ResizeFrameBy(Int16 inWidthDelta, Int16 inHeightDelta,
  40.                                  Boolean inRefresh) {
  41.  
  42.     
  43.     if ( mHasBorder && (mBorderStyle != borderStyleGA_NoBorder) && !mRefreshAllWhenResized ) {
  44.         Rect borderRect;
  45.         CalcBorderRect(borderRect);
  46.         Point beforeBotRight = botRight(borderRect);
  47.         Rect invalRect;
  48.         CalcPortFrameRect(invalRect);
  49.         Point portBeforeBotRight = botRight(invalRect);
  50.  
  51.         inherited::ResizeFrameBy(inWidthDelta, inHeightDelta, inRefresh);
  52.  
  53.         CalcPortFrameRect(invalRect);
  54.         CalcBorderRect(borderRect);
  55.         Point portAfterBotRight = botRight(invalRect);
  56.  
  57.         if ( inWidthDelta != 0 ) {
  58.             if ( beforeBotRight.h < borderRect.right ) {
  59.                 ::SetRect(&invalRect, beforeBotRight.h - mContentOffset.right, 
  60.                           borderRect.top, portBeforeBotRight.h, portBeforeBotRight.v);
  61.             } else {
  62.                 ::SetRect(&invalRect, borderRect.right - mContentOffset.right, 
  63.                           borderRect.top, portAfterBotRight.h, portAfterBotRight.v);
  64.             }
  65.             LocalToPortPoint(topLeft(invalRect));
  66.             LocalToPortPoint(botRight(invalRect));
  67.             InvalPortRect(&invalRect);
  68.         }
  69.         if ( inHeightDelta != 0 ) {
  70.             if ( beforeBotRight.v < borderRect.bottom ) {
  71.                 ::SetRect(&invalRect, borderRect.left, beforeBotRight.v - mContentOffset.bottom,
  72.                           portBeforeBotRight.h, portBeforeBotRight.v);
  73.             } else {
  74.                 ::SetRect(&invalRect, borderRect.left, borderRect.bottom - mContentOffset.bottom,
  75.                           portAfterBotRight.h, portAfterBotRight.v);
  76.             }
  77.             LocalToPortPoint(topLeft(invalRect));
  78.             LocalToPortPoint(botRight(invalRect));
  79.             InvalPortRect(&invalRect);
  80.         }
  81.     } else {
  82.         inherited::ResizeFrameBy(inWidthDelta, inHeightDelta, inRefresh);
  83.     }
  84. }
  85.  
  86.  
  87. /*======================================================================================
  88.     Fix bug where everything was not refreshed correctly.
  89. ======================================================================================*/
  90.  
  91. void LGABox_fixes::RefreshBoxBorder(void) {
  92.  
  93.     Rect theFrame;
  94.     if ( IsVisible() && CalcLocalFrameRect(theFrame) && (mSuperView) ) {
  95.         Rect revealed;
  96.         mSuperView->GetRevealedRect(revealed);
  97.         Point delta = topLeft(revealed);
  98.         PortToLocalPoint(topLeft(revealed));
  99.         PortToLocalPoint(botRight(revealed));
  100.         delta.h -= revealed.left; delta.v -= revealed.top;
  101.         if ( ::SectRect(&theFrame, &revealed, &revealed) ) {
  102.             RgnHandle borderRgn = GetBoxBorderRegion(revealed);
  103.             ::OffsetRgn(borderRgn, delta.h, delta.v);
  104.             InvalPortRgn(borderRgn);
  105.             ::DisposeRgn(borderRgn);
  106.         }
  107.     }
  108. }
  109.  
  110.  
  111. /*======================================================================================
  112.     Fix bug where everything was not refreshed correctly.
  113. ======================================================================================*/
  114.  
  115. void LGABox_fixes::RefreshBoxTitle(void) {
  116.  
  117.     Rect theFrame;
  118.     if ( IsVisible() && CalcPortFrameRect(theFrame) && (mSuperView) ) {
  119.         Rect revealed;
  120.         mSuperView->GetRevealedRect(revealed);
  121.         if ( ::SectRect(&theFrame, &revealed, &theFrame) ) {
  122.             Rect titleRect;
  123.             CalcTitleRect(titleRect);
  124.             LocalToPortPoint(topLeft(titleRect));
  125.             LocalToPortPoint(botRight(titleRect));
  126.             if ( ::SectRect(&titleRect, &revealed, &titleRect) ) {
  127.                 InvalPortRect(&titleRect);
  128.             }
  129.         }
  130.     }
  131. }
  132.  
  133.  
  134. /*======================================================================================
  135.     Fix bug where everything was not refreshed correctly.
  136. ======================================================================================*/
  137.  
  138. void LGABox_fixes::Disable(void) {
  139.  
  140.     LView::Disable();
  141.     
  142.     RefreshBoxBorder();
  143.     RefreshBoxTitle();
  144. }
  145.  
  146.  
  147. /*======================================================================================
  148.     Get rid of the flicker.
  149. ======================================================================================*/
  150.  
  151. void LGABox_fixes::Enable(void) {
  152.  
  153.     LView::Enable();
  154.     
  155.     RefreshBoxBorder();
  156.     RefreshBoxTitle();
  157. }
  158.  
  159.  
  160.