home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-08-16 | 5.2 KB | 182 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWShdWin.cpp
- // Release Version: $ ODF 1 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWFrameW.hpp"
-
- #ifndef FWSHDWIN_H
- #include "FWShdWin.h"
- #endif
-
- #ifndef FWPRIDEB_H
- #include "FWPriDeb.h"
- #endif
-
- #ifndef FWACQUIR_H
- #include "FWAcquir.h"
- #endif
-
- #ifndef FWFLOWIN_H
- #include "FWFloWin.h"
- #endif
-
- #ifndef FWPART_H
- #include "FWPart.h"
- #endif
-
- #ifndef SOM_ODWindowState_xh
- #include <WinStat.xh>
- #endif
-
- //========================================================================================
- // Runtime Info
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment fwwindow
- #endif
-
- //========================================================================================
- // Template Instantiations
- //========================================================================================
-
- FW_DEFINE_AUTO_TEMPLATE(FW_TOrderedCollectionIterator, FW_CPrivSharedWindow)
- FW_DEFINE_AUTO_TEMPLATE(FW_TOrderedCollection, FW_CPrivSharedWindow)
-
- #ifdef FW_USE_TEMPLATE_PRAGMAS
-
- #pragma template_access public
- #pragma template FW_TOrderedCollection<FW_CPrivSharedWindow>
- #pragma template FW_TOrderedCollectionIterator<FW_CPrivSharedWindow>
-
- #endif
-
- //========================================================================================
- // class FW_CPrivSharedWindow
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CPrivSharedWindow::FW_CPrivSharedWindow
- //----------------------------------------------------------------------------------------
-
- FW_CPrivSharedWindow::FW_CPrivSharedWindow(ODTypeToken presentationType) :
- fWindowID(kODNULLID),
- fPresentation(presentationType),
- fWasShown(FALSE),
- fWindowList(NULL)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPrivSharedWindow::~FW_CPrivSharedWindow
- //----------------------------------------------------------------------------------------
-
- FW_CPrivSharedWindow::~FW_CPrivSharedWindow()
- {
- delete fWindowList;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPrivSharedWindow::AddWindow
- //----------------------------------------------------------------------------------------
-
- void FW_CPrivSharedWindow::AddWindow(FW_CFloatingWindow* window)
- {
- if (fWindowList == NULL)
- fWindowList = FW_NEW(FW_TOrderedCollection<FW_CFloatingWindow>, ());
-
- fWindowList->AddLast(window);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPrivSharedWindow::RemoveWindow
- //----------------------------------------------------------------------------------------
-
- void FW_CPrivSharedWindow::RemoveWindow(FW_CFloatingWindow* window)
- {
- fWindowList->Remove(window);
-
- if (fWindowList->Count() == 0)
- {
- delete fWindowList;
- fWindowList = NULL;
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPrivSharedWindow::CountWindow
- //----------------------------------------------------------------------------------------
-
- long FW_CPrivSharedWindow::CountWindow() const
- {
- return fWindowList ? fWindowList->Count() : 0;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPrivSharedWindow::SetWindowID
- //----------------------------------------------------------------------------------------
-
- void FW_CPrivSharedWindow::SetWindowID(ODID windowID)
- {
- FW_ASSERT(fWindowID == kODNULLID || fWindowID == windowID);
- fWindowID = windowID;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPrivSharedWindow::HideShow
- //----------------------------------------------------------------------------------------
-
- void FW_CPrivSharedWindow::HideShow(Environment *ev, ODWindowState* windowState, FW_Boolean state)
- {
- if (fWindowID == kODNULLID)
- return;
-
- FW_CAcquiredODWindow aqODWindow = windowState->AcquireWindow(ev, fWindowID);
-
- if (state)
- {
- if (fWasShown)
- aqODWindow->Show(ev);
-
- fWasShown = FALSE;
-
- // ----- Force an update -----
- aqODWindow->Update(ev);
- }
- else
- {
- if (aqODWindow->IsShown(ev))
- {
- aqODWindow->Hide(ev);
- fWasShown = TRUE;
- }
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPrivSharedWindow::GetFloatingWindow
- //----------------------------------------------------------------------------------------
-
- FW_CFloatingWindow* FW_CPrivSharedWindow::GetFloatingWindow(Environment* ev, ODPart* part) const
- {
- FW_ASSERT(fWindowList);
-
- FW_TOrderedCollectionIterator<FW_CFloatingWindow> ite(fWindowList);
- for (FW_CFloatingWindow* floatWindow = ite.First();
- ite.IsNotComplete();
- floatWindow = ite.Next())
- {
- if (floatWindow->GetPart(ev)->GetODPart(ev) == part)
- return floatWindow;
- }
-
- FW_DEBUG_MESSAGE("FW_CPrivSharedWindow:GetFloatingWindow - Can't find Window");
- return NULL;
- }
-
-