home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODFDev / ODF / Framewrk / FWWindow / FWShdWin.cpp < prev    next >
Encoding:
Text File  |  1996-09-17  |  5.4 KB  |  194 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWShdWin.cpp
  4. //    Release Version:    $ ODF 2 $
  5. //
  6. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #include "FWFrameW.hpp"
  11.  
  12. #ifndef FWSHDWIN_H
  13. #include "FWShdWin.h"
  14. #endif
  15.  
  16. #ifndef FWPRIDEB_H
  17. #include "FWPriDeb.h"
  18. #endif
  19.  
  20. #ifndef FWACQUIR_H
  21. #include "FWAcquir.h"
  22. #endif
  23.  
  24. #ifndef FWFLOWIN_H
  25. #include "FWFloWin.h"
  26. #endif
  27.  
  28. #ifndef FWPART_H
  29. #include "FWPart.h"
  30. #endif
  31.  
  32. #ifndef SOM_ODWindowState_xh
  33. #include <WinStat.xh>
  34. #endif
  35.  
  36. #ifndef FWSESION_H
  37. #include "FWSesion.h"
  38. #endif
  39.  
  40. //========================================================================================
  41. //    Runtime Info
  42. //========================================================================================
  43.  
  44. #ifdef FW_BUILD_MAC
  45. #pragma segment fwwindow
  46. #endif
  47.  
  48. //========================================================================================
  49. //    Template Instantiations
  50. //========================================================================================
  51.  
  52. FW_DEFINE_AUTO_TEMPLATE(FW_TOrderedCollectionIterator, FW_CPrivSharedWindow)
  53. FW_DEFINE_AUTO_TEMPLATE(FW_TOrderedCollection, FW_CPrivSharedWindow)
  54.  
  55. #ifdef FW_USE_TEMPLATE_PRAGMAS
  56.  
  57. #pragma template_access public
  58. #pragma template FW_TOrderedCollection<FW_CPrivSharedWindow>
  59. #pragma template FW_TOrderedCollectionIterator<FW_CPrivSharedWindow>
  60.  
  61. #endif
  62.  
  63. //========================================================================================
  64. //    class FW_CPrivSharedWindow
  65. //========================================================================================
  66.  
  67. //----------------------------------------------------------------------------------------
  68. // FW_CPrivSharedWindow::FW_CPrivSharedWindow
  69. //----------------------------------------------------------------------------------------
  70.  
  71. FW_CPrivSharedWindow::FW_CPrivSharedWindow(ODTypeToken presentationType, const ODDraft* draft) :
  72.     fWindowID(kODNULLID),
  73.     fPresentation(presentationType),
  74.     fDraft(draft),
  75.     fWasShown(FALSE),
  76.     fWindowList(NULL)
  77. {
  78. }
  79.  
  80. //----------------------------------------------------------------------------------------
  81. // FW_CPrivSharedWindow::~FW_CPrivSharedWindow
  82. //----------------------------------------------------------------------------------------
  83.  
  84. FW_CPrivSharedWindow::~FW_CPrivSharedWindow()
  85. {
  86.     delete fWindowList;
  87. }
  88.  
  89. //----------------------------------------------------------------------------------------
  90. // FW_CPrivSharedWindow::AddWindow
  91. //----------------------------------------------------------------------------------------
  92.  
  93. void FW_CPrivSharedWindow::AddWindow(FW_CFloatingWindow* window)
  94. {
  95.     if (fWindowList == NULL)
  96.         fWindowList = FW_NEW(FW_TOrderedCollection<FW_CFloatingWindow>, ());
  97.  
  98.     fWindowList->AddLast(window);
  99. }
  100.  
  101. //----------------------------------------------------------------------------------------
  102. // FW_CPrivSharedWindow::RemoveWindow
  103. //----------------------------------------------------------------------------------------
  104.  
  105. void FW_CPrivSharedWindow::RemoveWindow(FW_CFloatingWindow* window)
  106. {
  107.     fWindowList->Remove(window);
  108.  
  109.     if (fWindowList->Count() == 0)
  110.     {
  111.         delete fWindowList;
  112.         fWindowList = NULL;
  113.     }
  114. }
  115.  
  116. //----------------------------------------------------------------------------------------
  117. // FW_CPrivSharedWindow::CountWindow
  118. //----------------------------------------------------------------------------------------
  119.  
  120. long FW_CPrivSharedWindow::CountWindow() const
  121. {
  122.     return fWindowList ? fWindowList->Count() : 0;
  123. }
  124.  
  125. //----------------------------------------------------------------------------------------
  126. // FW_CPrivSharedWindow::SetWindowID
  127. //----------------------------------------------------------------------------------------
  128.  
  129. void FW_CPrivSharedWindow::SetWindowID(ODID windowID)
  130. {
  131.     FW_ASSERT(fWindowID == kODNULLID || fWindowID == windowID);
  132.     fWindowID = windowID;    
  133. }
  134.  
  135. //----------------------------------------------------------------------------------------
  136. // FW_CPrivSharedWindow::HideShow
  137. //----------------------------------------------------------------------------------------
  138.  
  139. void FW_CPrivSharedWindow::HideShow(Environment *ev, FW_Boolean state, ODPart* part)
  140. {
  141.     if (fWindowID == kODNULLID)
  142.         return;
  143.  
  144.     FW_CAcquiredODWindow aqODWindow = FW_CSession::GetWindowState(ev)->AcquireWindow(ev, fWindowID);
  145.     
  146.     // Test that the root frame belongs to part (if part != NULL)
  147.     if (part != NULL)
  148.     {
  149.         FW_CAcquiredODPart aqPart = aqODWindow->GetRootFrame(ev)->AcquirePart(ev);
  150.         if (aqPart != part)
  151.             return;
  152.     }
  153.     
  154.     if (state)
  155.     {
  156.         if (fWasShown)
  157.             aqODWindow->Show(ev);
  158.         
  159.         fWasShown = FALSE;
  160.         
  161.         // ----- Force an update -----
  162.         aqODWindow->Update(ev);
  163.     }
  164.     else
  165.     {
  166.         if (aqODWindow->IsShown(ev))
  167.         {
  168.             aqODWindow->Hide(ev);
  169.             fWasShown = TRUE;
  170.         }
  171.     }
  172. }
  173.  
  174. //----------------------------------------------------------------------------------------
  175. // FW_CPrivSharedWindow::GetFloatingWindow
  176. //----------------------------------------------------------------------------------------
  177.  
  178. FW_CFloatingWindow* FW_CPrivSharedWindow::GetFloatingWindow(Environment* ev, ODPart* part) const
  179. {
  180.     FW_ASSERT(fWindowList);
  181.     
  182.     FW_TOrderedCollectionIterator<FW_CFloatingWindow> ite(fWindowList);
  183.     for (FW_CFloatingWindow* floatWindow = ite.First();
  184.         ite.IsNotComplete();
  185.         floatWindow = ite.Next())
  186.     {
  187.         if (floatWindow->GetPart(ev)->GetODPart(ev) == part)
  188.             return floatWindow;    
  189.     }
  190.     
  191.     return NULL;
  192. }
  193.  
  194.