home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / lib / mac / UserInterface / CViewUtils.cp < prev    next >
Encoding:
Text File  |  1998-04-08  |  3.3 KB  |  116 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. // Mark G. Young.
  21. // ===========================================================================
  22.  
  23. #include "CViewUtils.h"
  24.  
  25. #include <UException.h>
  26.  
  27. // ---------------------------------------------------------------------------
  28. //        Ñ GetTopMostSuperView
  29. // ---------------------------------------------------------------------------
  30.  
  31. LView*
  32. CViewUtils::GetTopMostSuperView(
  33.     LPane*            inPane)
  34. {
  35.     ThrowIfNil_(inPane);
  36.  
  37.     LView* superView = inPane->GetSuperView();
  38.     
  39.     while (superView && superView->GetSuperView())
  40.     {
  41.         superView = superView->GetSuperView();
  42.     }
  43.     
  44.     return superView;
  45. }
  46.  
  47. // ---------------------------------------------------------------------------
  48. //        Ñ SetRect32
  49. // ---------------------------------------------------------------------------
  50.  
  51. void
  52. CViewUtils::SetRect32(
  53.     SRect32*        outRect,
  54.     Int32            inLeft,
  55.     Int32            inTop,
  56.     Int32            inRight,
  57.     Int32            inBottom)
  58. {
  59.     outRect->left    = inLeft;
  60.     outRect->right    = inRight;
  61.     outRect->top    = inTop;
  62.     outRect->bottom    = inBottom;
  63. }
  64.  
  65. // ---------------------------------------------------------------------------
  66. //        Ñ ImageToLocalRect
  67. // ---------------------------------------------------------------------------
  68.  
  69. void
  70. CViewUtils::ImageToLocalRect(
  71.     LView*            inView,
  72.     const SRect32&    inRect,
  73.     Rect*            outRect)
  74. {
  75.     SPoint32            theImagePoint;
  76.     Point                theLocalPoint;
  77.     
  78.     theImagePoint.h = inRect.left;
  79.     theImagePoint.v = inRect.top;
  80.     inView->ImageToLocalPoint(theImagePoint, theLocalPoint);
  81.     outRect->left = theLocalPoint.h;
  82.     outRect->top = theLocalPoint.v;
  83.     
  84.     theImagePoint.h = inRect.right;
  85.     theImagePoint.v = inRect.bottom;
  86.     inView->ImageToLocalPoint(theImagePoint, theLocalPoint);
  87.     outRect->right = theLocalPoint.h;
  88.     outRect->bottom = theLocalPoint.v;
  89. }
  90.  
  91.  
  92. // ---------------------------------------------------------------------------
  93. //        Ñ LocalToImageRect
  94. // ---------------------------------------------------------------------------
  95.  
  96. void
  97. CViewUtils::LocalToImageRect(
  98.     LView*            inView,
  99.     const Rect&        inRect,
  100.     SRect32*        outRect)
  101. {
  102.     SPoint32        theImagePoint;
  103.     Point            theLocalPoint;
  104.     
  105.     theLocalPoint.h    = inRect.left;
  106.     theLocalPoint.v    = inRect.top;
  107.     inView->LocalToImagePoint(theLocalPoint, theImagePoint);
  108.     outRect->left    = theImagePoint.h;
  109.     outRect->top    = theImagePoint.v;
  110.     
  111.     theLocalPoint.h    = inRect.right;
  112.     theLocalPoint.v    = inRect.bottom;
  113.     inView->LocalToImagePoint(theLocalPoint, theImagePoint);
  114.     outRect->right    = theImagePoint.h;
  115.     outRect->bottom    = theImagePoint.v;
  116. }