home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / lib / mac / UserInterface / CDesktop.cp < prev    next >
Encoding:
Text File  |  1998-04-08  |  2.6 KB  |  88 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. #include "CDesktop.h"
  20.  
  21. #include <LWindow.h>
  22. #include <UWindows.h>
  23.  
  24. // ---------------------------------------------------------------------------
  25. //        Ñ FetchNextWindowWithThisAttribute
  26. // ---------------------------------------------------------------------------
  27.  
  28. LWindow*
  29. CDesktop::FetchNextWindowWithThisAttribute(
  30.     const LWindow&    inWindow,
  31.     EWindAttr        inAttribute)
  32. {
  33.         // Start with specified window and search thru window list until finding the
  34.         // next window with the specified attributes.
  35.         
  36.     WindowPtr    macWindowP            = static_cast<WindowPtr>(inWindow.GetMacPort());
  37.     WindowPtr    specifiedMacWindowP    = macWindowP;
  38.     
  39.     LWindow*    theWindow = nil;
  40.     while ((theWindow = LWindow::FetchWindowObject(macWindowP)) != nil)
  41.     {
  42.         if (theWindow->HasAttribute(inAttribute)    &&
  43.              ((WindowPeek) macWindowP)->visible        &&
  44.              macWindowP != specifiedMacWindowP)
  45.         {
  46.             break;
  47.         }
  48.         macWindowP = (WindowPtr) ((WindowPeek) macWindowP)->nextWindow;
  49.     }
  50.  
  51.     if (macWindowP == specifiedMacWindowP)
  52.     {
  53.         theWindow = nil;
  54.     }
  55.     
  56.     return theWindow;
  57. }
  58.  
  59. // ---------------------------------------------------------------------------
  60. //        Ñ FetchNextRegular
  61. // ---------------------------------------------------------------------------
  62.  
  63. LWindow*
  64. CDesktop::FetchNextRegular(
  65.     const LWindow&    inWindow)
  66. {
  67.     return FetchNextWindowWithThisAttribute(inWindow, windAttr_Regular);
  68. }
  69.  
  70. // ---------------------------------------------------------------------------
  71. //        Ñ FindWindow
  72. // ---------------------------------------------------------------------------
  73.  
  74. LWindow*
  75. CDesktop::FindWindow(
  76.     ResIDT            inWINDid)
  77. {
  78.     Int16    theIndex = 1;
  79.     LWindow*    theWindow = LWindow::FetchWindowObject(UWindows::FindNthWindow(theIndex));
  80.     
  81.     while (theWindow && theWindow->GetPaneID() != inWINDid)
  82.     {
  83.         theIndex++;
  84.         theWindow = LWindow::FetchWindowObject(UWindows::FindNthWindow(theIndex));
  85.     }
  86.     
  87.     return theWindow;
  88. }