home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / opendc12.zip / od124os2.exe / od12osr1.exe / src / Arbitrat.cpp < prev    next >
C/C++ Source or Header  |  1997-03-21  |  19KB  |  688 lines

  1. /* @(#)Z 1.7 com/src/ui/Arbitrat.cpp, odui, od96os2, odos29712d 97/03/21 17:20:15 (97/01/15 11:49:15) */
  2. //====START_GENERATED_PROLOG======================================
  3. //
  4. //
  5. //   COMPONENT_NAME: odui
  6. //
  7. //   CLASSES: none
  8. //
  9. //   ORIGINS: 82,27
  10. //
  11. //
  12. //   (C) COPYRIGHT International Business Machines Corp. 1995,1996
  13. //   All Rights Reserved
  14. //   Licensed Materials - Property of IBM
  15. //   US Government Users Restricted Rights - Use, duplication or
  16. //   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  17. //       
  18. //   IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  19. //   ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  20. //   PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  21. //   CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
  22. //   USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  23. //   OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
  24. //   OR PERFORMANCE OF THIS SOFTWARE.
  25. //
  26. //====END_GENERATED_PROLOG========================================
  27. //
  28. /*
  29.     File:        Arbitrat.cpp
  30.  
  31.     Contains:    Implementation of class ODArbitrator, which arbitrates foci.
  32.  
  33.     Owned by:    Richard Rodseth
  34.  
  35.     Copyright:    ⌐ 1994 - 1995 by Apple Computer, Inc., all rights reserved.
  36.  
  37.     Change History (most recent first):
  38.  
  39.         <14>     10/8/95    TJ        Fixes Recomended by Refball
  40.         <13>      8/3/95    RR        #1257260: Collapse B classes. Remove
  41.                                     somInit methods. Don't call IsInitialized
  42.                                     or SubclassResponsibility
  43.         <12>     5/26/95    RR        #1251403: Multithreading naming support
  44.         <11>     5/25/95    jpa        Fixed 'for' loop for ANSI compliance.
  45.                                     [1253324]
  46.         <10>     4/13/95    RR        # 1216618 Added ODVolatile
  47.          <9>      4/7/95    RR        #1216618 Added SOM_TRY etc.
  48.          <8>    10/18/94    RR        Removed unused private BRF, CRF, ARF
  49.                                     methods. Moved selection focus management
  50.                                     to focus module. Removed assumptions about
  51.                                     exclusivity by delegating to focus module
  52.                                     in more places.
  53.          <7>      9/2/94    RR        #1184275 Pass transferringFrame and
  54.                                     newOwner to focusModule::TransferFocus
  55.          <6>      9/1/94    CC        RADAR #1181971 - missing factory methods
  56.                                     (for JBS)
  57.          <5>     8/23/94    RR        Move Ref counting into focus module
  58.          <4>     8/17/94    jpa        Call DeleteSOMValues on fFocusModules since
  59.                                     they're SOM objects [1181531]
  60.          <3>     6/15/94    RR        Added function prefix
  61.          <2>     6/10/94    RR        Update #ifndefs
  62.          <1>     6/10/94    RR        first checked in
  63.  
  64.     To Do:
  65.     In Progress:
  66.         
  67. */
  68.  
  69.  
  70. /*
  71.  *  This file was generated by the SOM Compiler.
  72.  *  Generated using:
  73.  *     SOM incremental update: somc/smmain.c
  74.  */
  75.  
  76.  
  77. #define ODArbitrator_Class_Source
  78.  
  79. #define VARIABLE_MACROS
  80.  
  81. #include <Arbitrat.xih>
  82.  
  83. #ifndef _EXCEPT_
  84. #include "Except.h"
  85. #endif
  86.  
  87. #ifndef _DICTLIST_
  88. #include "DictList.h"
  89. #endif
  90.  
  91. #ifndef SOM_Module_OpenDoc_Foci_defined
  92. #include "Foci.xh"
  93. #endif
  94.  
  95. #ifndef SOM_ODFocusSet_xh
  96. #include "FocusSet.xh"
  97. #endif
  98.  
  99. #ifndef SOM_ODFocusSetIterator_xh
  100. #include "FocusItr.xh"
  101. #endif
  102.  
  103. #ifndef SOM_ODFocusModule_xh
  104. #include "FocusMod.xh"
  105. #endif
  106.  
  107. #ifndef SOM_ODExclusiveFocusModule_xh
  108. #include "ExcFocus.xh"
  109. #endif
  110.  
  111. #ifndef _ODSESSN_
  112. #include "ODSessn.xh"
  113. #endif
  114.  
  115. #ifndef SOM_ODPart_xh
  116. #include "Part.xh"
  117. #endif
  118.  
  119. #ifndef SOM_ODFrame_xh
  120. #include "Frame.xh"
  121. #endif
  122.  
  123. #include "ODUtils.h" 
  124.  
  125. #include "TempObj.h"
  126.  
  127. #ifndef SOM_ODWindowIterator_xh
  128. #include "WinIter.xh"
  129. #endif
  130.  
  131. #ifdef _PLATFORM_OS2_
  132. #include "Window.xh"
  133. #endif
  134. /*
  135.  * prototypes 
  136.  */
  137. #ifdef _PLATFORM_OS2_
  138. SOMEXTERN void SOMLINK EnableApplModal(Environment *ev, ODFrame *frame, ODSession *session, BOOL enable);
  139. #endif
  140.  
  141. SOM_Scope ODBoolean  SOMLINK ODArbitratorRequestFocusSet(ODArbitrator *somSelf, Environment *ev,
  142.         ODFocusSet* focusSet,
  143.         ODFrame* requestingFrame)
  144. {
  145.     ODArbitratorData *somThis = ODArbitratorGetData(somSelf);
  146.     ODArbitratorMethodDebug("ODArbitrator","RequestFocusSet");
  147.  
  148.     ODFocusSetIterator* iter = kODNULL; ODVolatile(iter);
  149.     ODBoolean allRegistered = kODTrue;
  150.     ODBoolean allWilling = kODTrue;
  151.     ODTypeToken lastFocus;
  152.     ODBoolean success = kODFalse;
  153.     
  154.     SOM_TRY
  155.  
  156.         iter = focusSet->CreateIterator(ev);
  157.         
  158.         // First check if any foci are not registered
  159.         ODTypeToken focus;
  160.         for (focus = iter->First(ev); allRegistered && iter->IsNotComplete(ev);focus = iter->Next(ev))
  161.         {
  162.             allRegistered = somSelf->GetFocusModule(ev,focus) && allRegistered;
  163.         }
  164.         if (!allRegistered)
  165.             THROW(kODErrFocusNotRegistered);
  166.         
  167.         // Now check if existing owners are willing to relinquish each focus
  168.         // Non-exclusive foci aren't checked
  169.         
  170.         for (focus = iter->First(ev); allWilling && iter->IsNotComplete(ev);focus = iter->Next(ev))
  171.         {
  172.             ODFocusModule* focusModule = somSelf->GetFocusModule(ev,focus);
  173.             
  174.             if (focusModule && (!focusModule->BeginRelinquishFocus(ev,focus, requestingFrame)))
  175.                 allWilling = kODFalse;
  176.             
  177.             lastFocus = focus;
  178.         }
  179.     
  180.         // Now commit or abort all requests
  181.         
  182.         if (allWilling)
  183.         {
  184.             for (ODTypeToken focus = iter->First(ev); iter->IsNotComplete(ev);focus = iter->Next(ev))
  185.             {
  186.                 ODFocusModule* focusModule = somSelf->GetFocusModule(ev, focus);
  187.                 
  188.                 focusModule->CommitRelinquishFocus(ev, focus, requestingFrame);
  189.                 focusModule->SetFocusOwnership(ev, focus, requestingFrame);
  190.                 
  191.             }
  192.             success = kODTrue;
  193.         }
  194.         else
  195.         {
  196.             for (ODTypeToken focus = iter->First(ev); (focus != lastFocus) && iter->IsNotComplete(ev);focus = iter->Next(ev))
  197.             {
  198.                 ODFocusModule* focusModule = somSelf->GetFocusModule(ev, focus);
  199.                     
  200.                 focusModule->AbortRelinquishFocus(ev, focus, requestingFrame);
  201.             }
  202.             success = kODFalse;
  203.         }    
  204.         ODDeleteObject(iter);
  205.         
  206.     SOM_CATCH_ALL
  207.     
  208.         ODDeleteObject(iter);
  209.             
  210.     SOM_ENDTRY
  211.     
  212.     return success;
  213. }
  214.  
  215. SOM_Scope ODBoolean  SOMLINK ODArbitratorRequestFocus(ODArbitrator *somSelf, Environment *ev,
  216.         ODTypeToken focus,
  217.         ODFrame* requestingFrame)
  218. {
  219.     ODArbitratorData *somThis = ODArbitratorGetData(somSelf);
  220.     ODArbitratorMethodDebug("ODArbitrator","RequestFocus");
  221.     
  222.     ODBoolean succeeded = kODFalse;
  223.  
  224.     SOM_TRY
  225.     
  226.         ODFocusModule* focusModule = somSelf->GetFocusModule(ev,focus);
  227.         
  228.         if (focusModule)
  229.         {
  230.             succeeded = focusModule->BeginRelinquishFocus(ev, focus, requestingFrame);
  231.             if (succeeded)
  232.             {
  233.                 focusModule->CommitRelinquishFocus(ev, focus, requestingFrame);
  234.                 focusModule->SetFocusOwnership(ev, focus, requestingFrame);
  235. #ifdef _PLATFORM_OS2_
  236.                                 ODTypeToken modalFocus  = _fSession->Tokenize(ev, kODModalFocus);
  237.                                 if (focus == modalFocus) {
  238.  
  239.                                    // OS/2 has no application modality.  We have to fake it here, by
  240.                                    // disabling mouse and keyboard inputs
  241.                                    // to all the OD windows except the window that is going to own
  242.                                    // the modal focus.dialog. 
  243.  
  244.                                    EnableApplModal(ev, requestingFrame, _fSession, FALSE);
  245.                                 }
  246. #endif // _PLATFORM_OS2_
  247.             }
  248.             else    
  249.                 focusModule->AbortRelinquishFocus(ev, focus, requestingFrame);
  250.         }
  251.         else
  252.         {
  253.             succeeded = kODFalse;
  254.             THROW(kODErrFocusNotRegistered);
  255.         }
  256.  
  257.     SOM_CATCH_ALL
  258.     
  259.         succeeded = kODFalse;
  260.             
  261.     SOM_ENDTRY
  262.     
  263.     return succeeded;
  264. }
  265.  
  266. SOM_Scope void  SOMLINK ODArbitratorRelinquishFocusSet(ODArbitrator *somSelf, Environment *ev,
  267.         ODFocusSet* focusSet,
  268.         ODFrame* relinquishingFrame)
  269. {
  270.     ODArbitratorData *somThis = ODArbitratorGetData(somSelf);
  271.     ODArbitratorMethodDebug("ODArbitrator","RelinquishFocusSet");
  272.  
  273.     ODFocusSetIterator* iter = kODNULL; ODVolatile(iter);
  274.     
  275.     SOM_TRY
  276.     
  277.         iter = focusSet->CreateIterator(ev);
  278.     
  279.         for (ODTypeToken focus = iter->First(ev); iter->IsNotComplete(ev);focus = iter->Next(ev))
  280.         {
  281.     
  282.             ODFocusModule* focusModule = somSelf->GetFocusModule(ev,focus);
  283.             
  284.             if (focusModule)
  285.             {
  286.                 focusModule->UnsetFocusOwnership(ev, focus, relinquishingFrame);
  287.             }
  288.             else
  289.                 THROW(kODErrFocusNotRegistered);
  290.         }
  291.         ODDeleteObject(iter);
  292.         
  293.     SOM_CATCH_ALL
  294.     
  295.         ODDeleteObject(iter);
  296.         
  297.     SOM_ENDTRY
  298. }
  299.  
  300. SOM_Scope void  SOMLINK ODArbitratorRelinquishFocus(ODArbitrator *somSelf, Environment *ev,
  301.         ODTypeToken focus,
  302.         ODFrame* relinquishingFrame)
  303. {
  304.     ODArbitratorData *somThis = ODArbitratorGetData(somSelf);
  305.     ODArbitratorMethodDebug("ODArbitrator","RelinquishFocus");
  306.  
  307.     SOM_TRY
  308.  
  309.         ODFocusModule* focusModule = somSelf->GetFocusModule(ev, focus);
  310.         
  311.         if (focusModule)
  312.         {
  313.             focusModule->UnsetFocusOwnership(ev, focus, relinquishingFrame);
  314.         }
  315.         else
  316.             THROW(kODErrFocusNotRegistered);
  317. #ifdef _PLATFORM_OS2_
  318.                 ODTypeToken modalFocus  = _fSession->Tokenize(ev, kODModalFocus);
  319.                 if (focus == modalFocus) {
  320.                    EnableApplModal(ev, kODNULL, _fSession, TRUE);
  321.                 }
  322. #endif
  323.  
  324.     SOM_CATCH_ALL
  325.     SOM_ENDTRY
  326. }
  327.  
  328. SOM_Scope void  SOMLINK ODArbitratorTransferFocus(ODArbitrator *somSelf, Environment *ev,
  329.         ODTypeToken focus,
  330.         ODFrame* transferringFrame,
  331.         ODFrame* newOwner)
  332. {
  333.     ODArbitratorData *somThis = ODArbitratorGetData(somSelf);
  334.     ODArbitratorMethodDebug("ODArbitrator","TransferFocus");
  335.  
  336.     SOM_TRY
  337.  
  338.         ODFocusModule* focusModule = somSelf->GetFocusModule(ev, focus);
  339.         if (focusModule)
  340.             focusModule->TransferFocusOwnership(ev, focus,transferringFrame, newOwner);
  341. #ifdef _PLATFORM_OS2_
  342.                 ODTypeToken modalFocus  = _fSession->Tokenize(ev, kODModalFocus);
  343.                 if (focus == modalFocus) {
  344.                    EnableApplModal(ev, newOwner, _fSession, TRUE);
  345.                    if(newOwner)
  346.                       EnableApplModal(ev, newOwner, _fSession, FALSE);
  347.                 }
  348. #endif
  349.  
  350.     SOM_CATCH_ALL
  351.     SOM_ENDTRY
  352. }
  353.  
  354. SOM_Scope void  SOMLINK ODArbitratorTransferFocusSet(ODArbitrator *somSelf, Environment *ev,
  355.         ODFocusSet* focusSet,
  356.         ODFrame* transferringFrame,
  357.         ODFrame* newOwner)
  358. {
  359.     ODArbitratorData *somThis = ODArbitratorGetData(somSelf);
  360.     ODArbitratorMethodDebug("ODArbitrator","TransferFocusSet");
  361.  
  362.     ODFocusModule* focusModule = kODNULL;
  363.     ODFocusSetIterator* iter = kODNULL; ODVolatile(iter);
  364.  
  365.     SOM_TRY
  366.     
  367.         iter = focusSet->CreateIterator(ev);
  368.     
  369.         for (ODTypeToken focus = iter->First(ev); iter->IsNotComplete(ev);focus = iter->Next(ev))
  370.         {
  371.             focusModule = somSelf->GetFocusModule(ev, focus);
  372.             if (focusModule)
  373.                 focusModule->TransferFocusOwnership(ev, focus,transferringFrame, newOwner);
  374.         }
  375.         ODDeleteObject(iter);
  376.  
  377.     SOM_CATCH_ALL
  378.     
  379.         ODDeleteObject(iter);
  380.         
  381.     SOM_ENDTRY
  382. }
  383.  
  384. SOM_Scope ODFrame*  SOMLINK ODArbitratorAcquireFocusOwner(ODArbitrator *somSelf, Environment *ev,
  385.         ODTypeToken focus)
  386. {
  387.     ODArbitratorData *somThis = ODArbitratorGetData(somSelf);
  388.     ODArbitratorMethodDebug("ODArbitrator","AcquireFocusOwner");
  389.  
  390.     ODFrame* focusOwner = kODNULL;
  391.     ODFocusModule* focusModule = kODNULL;
  392.         
  393.     SOM_TRY
  394.     
  395.         focusModule = somSelf->GetFocusModule(ev, focus);
  396.         if (focusModule) 
  397. //#ifdef _PLATFORM_OS2_
  398. //                {
  399. //                      if(!focusModule->IsFocusExclusive(ev, focus)) // [107837]
  400. //                            THROW(kODErrFocusIsNonExclusive);
  401. //#endif
  402.             focusOwner = focusModule->AcquireFocusOwner(ev, focus);
  403. //#ifdef _PLATFORM_OS2_
  404. //                }
  405. //#endif
  406.         else
  407.             focusOwner = kODNULL;
  408.         
  409.     SOM_CATCH_ALL
  410.     SOM_ENDTRY
  411.     
  412.     return focusOwner;
  413. }
  414.  
  415. SOM_Scope ODFocusOwnerIterator*  SOMLINK ODArbitratorCreateOwnerIterator(ODArbitrator *somSelf, Environment *ev,
  416.         ODTypeToken focus)
  417. {
  418.     ODArbitratorData *somThis = ODArbitratorGetData(somSelf);
  419.     ODArbitratorMethodDebug("ODArbitrator","CreateOwnerIterator");
  420.  
  421.     ODFocusOwnerIterator* ownerIterator = kODNULL;
  422.     ODFocusModule* focusModule = kODNULL;
  423.     
  424.     SOM_TRY
  425.  
  426.         focusModule = somSelf->GetFocusModule(ev, focus);
  427.         if (focusModule)
  428.             ownerIterator = focusModule->CreateOwnerIterator(ev, focus);
  429.         else
  430.             THROW(kODErrFocusNotRegistered);
  431.  
  432.     SOM_CATCH_ALL
  433.     SOM_ENDTRY
  434.     
  435.     return ownerIterator;
  436. }
  437.  
  438. SOM_Scope void  SOMLINK ODArbitratorRegisterFocus(ODArbitrator *somSelf, Environment *ev,
  439.         ODTypeToken focus,
  440.         ODFocusModule* focusModule)
  441. {
  442.     ODArbitratorData *somThis = ODArbitratorGetData(somSelf);
  443.     ODArbitratorMethodDebug("ODArbitrator","RegisterFocus");
  444.  
  445.     ODFocusModule* existingModule = kODNULL;
  446.     ODFocusModule* newModule = kODNULL; ODVolatile(newModule);
  447.  
  448.     SOM_TRY
  449.  
  450.         existingModule = (ODFocusModule*) _fFocusModules->ValueAtKey((KeyType) focus);
  451.         if (existingModule)
  452.             THROW(kODErrFocusAlreadyRegistered);
  453.         else
  454.         {
  455.             newModule = focusModule;
  456.             if (newModule == kODNULL)
  457.             {
  458.                 newModule = new ODExclusiveFocusModule();
  459.                 THROW_IF_NULL(newModule);    // new doesn't THROW for SOM objects
  460.                 ((ODExclusiveFocusModule*) newModule)->InitExclusiveFocusModule(ev, _fSession);
  461.             }
  462.     
  463.             _fFocusModules->AddPair((KeyType) focus, (ValueType) newModule);
  464.         }
  465.  
  466.     SOM_CATCH_ALL
  467.     
  468.         ODDeleteObject(newModule);
  469.         
  470.     SOM_ENDTRY
  471. }
  472.  
  473. SOM_Scope void  SOMLINK ODArbitratorUnregisterFocus(ODArbitrator *somSelf, Environment *ev,
  474.         ODTypeToken focus)
  475. {
  476.     ODArbitratorData *somThis = ODArbitratorGetData(somSelf);
  477.     ODArbitratorMethodDebug("ODArbitrator","UnregisterFocus");
  478.  
  479.     SOM_TRY
  480.  
  481.         if (_fFocusModules->ContainsKey((KeyType) focus))
  482.             _fFocusModules->RemoveKey((KeyType) focus);
  483.         else
  484.             THROW(kODErrFocusNotRegistered);
  485.  
  486.     SOM_CATCH_ALL
  487.     SOM_ENDTRY
  488. }
  489.  
  490. SOM_Scope ODBoolean  SOMLINK ODArbitratorIsFocusRegistered(ODArbitrator *somSelf, Environment *ev,
  491.         ODTypeToken focus)
  492. {
  493.     ODArbitratorData *somThis = ODArbitratorGetData(somSelf);
  494.     ODArbitratorMethodDebug("ODArbitrator","IsFocusRegistered");
  495.  
  496.     ODBoolean isRegistered = kODFalse;
  497.     
  498.     SOM_TRY
  499.  
  500.         ODFocusModule* focusModule = somSelf->GetFocusModule(ev, focus);
  501.         isRegistered = (focusModule != kODNULL);
  502.         
  503.     SOM_CATCH_ALL
  504.     SOM_ENDTRY
  505.     
  506.     return isRegistered;
  507. }
  508.  
  509. SOM_Scope ODBoolean  SOMLINK ODArbitratorIsFocusExclusive(ODArbitrator *somSelf, Environment *ev,
  510.         ODTypeToken focus)
  511. {
  512.     ODArbitratorData *somThis = ODArbitratorGetData(somSelf);
  513.     ODArbitratorMethodDebug("ODArbitrator","IsFocusExclusive");
  514.  
  515.     ODBoolean isExclusive = kODFalse;
  516.     ODFocusModule* focusModule = kODNULL;
  517.         
  518.     SOM_TRY
  519.  
  520.         focusModule = somSelf->GetFocusModule(ev, focus);
  521.         if (focusModule)
  522.             isExclusive = focusModule->IsFocusExclusive(ev, focus);
  523.         else
  524.             THROW(kODErrFocusNotRegistered);
  525.             
  526.     SOM_CATCH_ALL
  527.     SOM_ENDTRY
  528.     
  529.     return isExclusive;
  530. }
  531.  
  532. SOM_Scope void  SOMLINK ODArbitratorInitArbitrator(ODArbitrator *somSelf, Environment *ev,
  533.         ODSession* session)
  534. {
  535.     ODArbitratorData *somThis = ODArbitratorGetData(somSelf);
  536.     ODArbitratorMethodDebug("ODArbitrator","InitArbitrator");
  537.  
  538.     DictionaryList* focusModules = kODNULL; ODVolatile(focusModules);
  539.     
  540.  
  541.     SOM_TRY
  542.     
  543.         /* Moved from somInit. SOM itself sets fields to zero
  544.         _fSession = kODNULL;
  545.         _fFocusModules = kODNULL;
  546.         */
  547.         
  548.         somSelf->InitObject(ev);
  549.         _fSession = session;
  550.         focusModules = new DictionaryList(); // "new" THROWS for non-SOM objects
  551.         _fFocusModules = focusModules;
  552.         
  553.     SOM_CATCH_ALL
  554.     
  555.         ODDeleteObject(focusModules);
  556.         
  557.     SOM_ENDTRY
  558. }
  559.  
  560.  
  561. SOM_Scope ODFocusModule*  SOMLINK ODArbitratorGetFocusModule(ODArbitrator *somSelf, Environment *ev,
  562.         ODTypeToken focus)
  563. {
  564.     ODArbitratorData *somThis = ODArbitratorGetData(somSelf);
  565.     ODArbitratorMethodDebug("ODArbitrator","GetFocusModule");
  566.  
  567.     ODFocusModule* module = kODNULL;
  568.     
  569.     SOM_TRY
  570.     
  571.         if(_fFocusModules)
  572.         module = (ODFocusModule*) _fFocusModules->ValueAtKey((KeyType) focus);
  573.     else
  574.                 return((ODFocusModule*)kODNULL);    
  575.  
  576.     SOM_CATCH_ALL
  577.     SOM_ENDTRY
  578.     
  579.     return module;
  580. }
  581.  
  582. SOM_Scope ODFocusSet*  SOMLINK ODArbitratorCreateFocusSet(ODArbitrator *somSelf, Environment *ev)
  583. {
  584.     ODArbitratorData *somThis = ODArbitratorGetData(somSelf);
  585.     ODArbitratorMethodDebug("ODArbitrator","CreateFocusSet");
  586.  
  587.     ODFocusSet* focusSet = kODNULL;  ODVolatile(focusSet);
  588.  
  589.      SOM_TRY
  590.             
  591.         focusSet = new ODFocusSet;
  592.         THROW_IF_NULL(focusSet);    // new doesn't THROW for SOM objects
  593.         focusSet->InitFocusSet(ev);
  594.     
  595.     SOM_CATCH_ALL
  596.     
  597.         ODDeleteObject(focusSet);
  598.         
  599.     SOM_ENDTRY
  600.     
  601.     return focusSet;
  602. }
  603.  
  604. SOM_Scope void  SOMLINK ODArbitratorsomUninit(ODArbitrator *somSelf)
  605. {
  606.     ODArbitratorData *somThis = ODArbitratorGetData(somSelf);
  607.     ODArbitratorMethodDebug("ODArbitrator","somUninit");
  608.  
  609.     if (_fFocusModules)
  610.     {
  611.         TRY
  612.             _fFocusModules->DeleteSOMValues(); // Delete the Focus Modules
  613.             ODDeleteObject(_fFocusModules);
  614.         CATCH_ALL
  615.             // Ignore exceptions
  616.         ENDTRY
  617.     }
  618.  
  619.     parent_somUninit(somSelf);
  620. }
  621.  
  622. SOM_Scope ODSize  SOMLINK ODArbitratorPurge(ODArbitrator *somSelf, Environment *ev,
  623.         ODSize size)
  624. {
  625.     ODArbitratorData *somThis = ODArbitratorGetData(somSelf);
  626.     ODArbitratorMethodDebug("ODArbitrator","Purge");
  627.     
  628.     ODSize purgeSize = 0;
  629.  
  630.      SOM_TRY
  631.  
  632.             purgeSize = parent_Purge(somSelf,ev,size);
  633.             
  634.     SOM_CATCH_ALL
  635.     SOM_ENDTRY
  636.     
  637.     return purgeSize;
  638. }
  639.  
  640. #ifdef _PLATFORM_OS2_
  641. //------------------------------------------------------------------------------
  642. // EnableApplModal - Simulates application modality by disabling/enabling
  643. //                   all the OD windows except the window which owns the dialog.
  644. //------------------------------------------------------------------------------
  645. SOMEXTERN void SOMLINK EnableApplModal(Environment *ev, ODFrame* frame, ODSession* session, BOOL enable)
  646. {
  647.     ODWindowIterator *iter = kODNULL;
  648.     ODWindow         *curWindow;
  649.  
  650.     try
  651.     {
  652.         // Disable/Enable mouse and keyboard input to all the OD windows 
  653.         // except the one which is going to own the display dialog.
  654.     //
  655.     // Note: The window which is going to own the display dialog is
  656.     //       disable/enable by the system.
  657.     ODWindowState *windowState = session->GetWindowState(ev);
  658.     if (windowState)
  659.     {
  660.                 HWND hwnd = NULL;
  661.                 TempODWindow Window = kODNULL;
  662.                 if(frame)
  663.                    Window = frame->AcquireWindow(ev);
  664.                 if(Window)
  665.                    hwnd = Window->GetPlatformWindow(ev);
  666.  
  667.         iter = windowState->CreateWindowIterator(ev);
  668.         for (curWindow = iter->First(ev); iter->IsNotComplete(ev); 
  669.              curWindow = iter->Next(ev))
  670.             {
  671.                 HWND platformWindow = curWindow->GetPlatformWindow(ev);
  672.                 if (platformWindow != hwnd)
  673.                    WinEnableWindow(platformWindow, enable);
  674.             }
  675.             ODDeleteObject(iter);
  676.     }
  677.  
  678.     }
  679.     catch (ODException _exception)
  680.     {
  681. //        LOG("OpenDoc exception occured in EnableApplModal.\n");
  682.         ODDeleteObject(iter);
  683.         throw;
  684.     }
  685. }
  686.  
  687. #endif // _PLATFORM_OS2_
  688.