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

  1. /* @(#)Z 1.5 com/src/ui/FocusSet.cpp, odui, od96os2, odos29712d 97/03/21 17:20:19 (96/07/15 18:26:45) */
  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:        FocusSet.cpp
  30.  
  31.     Contains:    ODFocusSet implementation
  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.         <11>      8/3/95    RR        #1257260: Collapse B classes. Remove
  40.                                     somInit methods. Don't call IsInitialized
  41.                                     or SubclassResponsibility
  42.         <10>     7/25/95    VL        1270320: DeleteAllLinks on _fImplementation
  43.                                     in somUninit.
  44.          <9>     5/26/95    RR        #1251403: Multithreading naming support
  45.          <8>     5/25/95    jpa        List.h --> LinkList.h [1253324]
  46.          <7>     4/28/95    RR        1211085 Remove 5$ comments
  47.          <6>     4/13/95    RR        # 1216618 Added ODVolatile, ODDeleteObject
  48.          <5>      4/7/95    RR        #1216618 Added SOM_TRY etc.
  49.          <4>     2/22/95    RR        #1209427 Changed private api between
  50.                                     iterator and iteratee
  51.          <3>     9/29/94    RA        1189812: Mods for 68K build.
  52.          <2>     9/26/94    RR        Include ArbUtils
  53.          <1>     9/26/94    RR        first checked in
  54.  
  55.     To Do:
  56.     In Progress:
  57. */
  58.  
  59.  
  60. #define ODFocusSet_Class_Source
  61. #define VARIABLE_MACROS
  62. #include <FocusSet.xih>
  63.  
  64. #ifndef SOM_ODFocusSetIterator_xh
  65. #include "FocusItr.xh"
  66. #endif
  67.  
  68. #ifndef SOM_Module_OpenDoc_Foci_defined
  69. #include "Foci.xh"    // For kODNULLFocus. Returned by iterator, but ignored
  70. #endif
  71.  
  72. #ifndef _LINKLIST_
  73. #include <LinkList.h>
  74. #endif
  75.  
  76. #ifndef _ARBUTILS_
  77. #include "ArbUtils.h"
  78. #endif
  79.  
  80. #ifndef _EXCEPT_
  81. #include "Except.h"
  82. #endif
  83.  
  84. #ifndef _ODDEBUG_
  85. #include "ODDebug.h"    // Adkins -- added
  86. #endif
  87.  
  88. #if defined(_PLATFORM_WIN32_) || defined(_PLATFORM_OS2_) || defined(_PLATFORM_UNIX_)  
  89. #include "ODUtils.h"
  90. #endif
  91.  
  92. #if !defined(_PLATFORM_OS2_) && !defined(_PLATFORM_WIN32_)
  93. #pragma segment ODFocusSet
  94. #endif
  95.  
  96.  
  97. //======================================================================================
  98. // Method Implementations for ODFocusSet
  99. //======================================================================================
  100.  
  101.  
  102. SOM_Scope void  SOMLINK ODFocusSetInitFocusSet(ODFocusSet *somSelf, Environment *ev)
  103. {
  104.     ODFocusSetData *somThis = ODFocusSetGetData(somSelf);
  105.     ODFocusSetMethodDebug("ODFocusSet","ODFocusSetInitFocusSet");
  106.     
  107.     /* Moved from somInit. SOM itself sets fields to zero
  108.     _fImplementation = kODNULL;
  109.     */
  110.  
  111.     if (_fImplementation == kODNULL)
  112.     {
  113.         LinkedList* linkedList = kODNULL; ODVolatile(linkedList);
  114.  
  115.         SOM_TRY
  116.         
  117.             
  118.             somSelf->InitObject(ev);
  119.     
  120.             linkedList = new LinkedList;
  121.             _fImplementation = linkedList;
  122.             
  123.         SOM_CATCH_ALL
  124.             
  125.             ODDeleteObject(linkedList);
  126.             
  127.         SOM_ENDTRY
  128.     }
  129. }
  130.  
  131. SOM_Scope void  SOMLINK ODFocusSetAdd(ODFocusSet *somSelf, Environment *ev,
  132.         ODTypeToken focus)
  133. {
  134.     ODFocusSetData *somThis = ODFocusSetGetData(somSelf);
  135.     ODFocusSetMethodDebug("ODFocusSet","ODFocusSetAdd");
  136.  
  137.     FocusLink* focusLink = kODNULL; ODVolatile(focusLink);
  138.         
  139.     SOM_TRY
  140.     
  141.         ASSERT(_fImplementation != kODNULL,kODErrUndefined); // Note: Undefined error code
  142.     
  143.         if (!somSelf->Contains(ev,focus))
  144.         {
  145.             focusLink = new FocusLink(focus);        
  146.             _fImplementation->AddLast(focusLink);
  147.         }
  148.  
  149.     SOM_CATCH_ALL
  150.     
  151.         ODDeleteObject(focusLink);
  152.         
  153.     SOM_ENDTRY
  154. }
  155.  
  156. SOM_Scope void  SOMLINK ODFocusSetRemove(ODFocusSet *somSelf, Environment *ev,
  157.         ODTypeToken focus)
  158. {
  159.     ODFocusSetData *somThis = ODFocusSetGetData(somSelf);
  160.     ODFocusSetMethodDebug("ODFocusSet","ODFocusSetRemove");
  161.  
  162.     SOM_TRY
  163.     
  164.         ASSERT(_fImplementation != kODNULL,kODErrUndefined);
  165.     
  166.         LinkedListIterator iter(_fImplementation);
  167.         ODTypeToken foundFocus;
  168.         
  169.         FocusLink* link = (FocusLink*) iter.First();
  170.         while (link != kODNULL)
  171.         {
  172.             foundFocus = link->fFocus;
  173.             if (foundFocus == focus) 
  174.             {
  175.                 _fImplementation->Remove(*link);
  176.                 delete link;
  177.                 link = kODNULL;
  178.             }
  179.             else
  180.                 link = (FocusLink*) iter.Next();
  181.         }    
  182.  
  183.     SOM_CATCH_ALL
  184.     SOM_ENDTRY
  185.  
  186. }
  187.  
  188. SOM_Scope ODBoolean  SOMLINK ODFocusSetContains(ODFocusSet *somSelf, Environment *ev,
  189.         ODTypeToken focus)
  190. {
  191.     ODFocusSetData *somThis = ODFocusSetGetData(somSelf);
  192.     ODFocusSetMethodDebug("ODFocusSet","ODFocusSetContains");
  193.     
  194.     ODBoolean containsFocus = kODFalse;
  195.  
  196.     SOM_TRY
  197.     
  198.         ASSERT(_fImplementation != kODNULL,kODErrUndefined);
  199.     
  200.         LinkedListIterator iter(_fImplementation);
  201.         ODTypeToken foundFocus;
  202.     
  203.         FocusLink* link = (FocusLink*) iter.First();
  204.         while (link != kODNULL)
  205.         {
  206.             foundFocus = link->fFocus;
  207.     
  208.             if (foundFocus == focus) 
  209.             {
  210.                 containsFocus = kODTrue;
  211.                 break;    
  212.             }
  213.             else
  214.                 link = (FocusLink*) iter.Next();
  215.         }    
  216.  
  217.     SOM_CATCH_ALL
  218.     SOM_ENDTRY
  219.     
  220.     return containsFocus;
  221. }
  222.  
  223. SOM_Scope ODFocusSetIterator*  SOMLINK ODFocusSetCreateIterator(ODFocusSet *somSelf, Environment *ev)
  224. {
  225.     ODFocusSetData *somThis = ODFocusSetGetData(somSelf);
  226.     ODFocusSetMethodDebug("ODFocusSet","ODFocusSetCreateIterator");
  227.  
  228.     ODFocusSetIterator* iterator = kODNULL; ODVolatile(iterator);
  229.     
  230.     SOM_TRY
  231.     
  232.         iterator = new ODFocusSetIterator;
  233.         THROW_IF_NULL(iterator);
  234.         iterator->InitFocusSetIterator(ev,somSelf);
  235.         
  236.     SOM_CATCH_ALL
  237.     
  238.         ODDeleteObject(iterator);
  239.         
  240.     SOM_ENDTRY
  241.     
  242.     return iterator;
  243. }
  244.  
  245. SOM_Scope ODULong  SOMLINK ODFocusSetAddIterator(ODFocusSet *somSelf, Environment *ev,
  246.         ODFocusSetIterator* iterator)
  247. {
  248.     ODFocusSetData *somThis = ODFocusSetGetData(somSelf);
  249.     ODFocusSetMethodDebug("ODFocusSet","ODFocusSetAddIterator");
  250.  
  251.     LinkedListIterator* iter = kODNULL; ODVolatile(iter);
  252.  
  253.     SOM_TRY
  254.     
  255.         iter = new LinkedListIterator(_fImplementation);
  256.         
  257.     SOM_CATCH_ALL
  258.     
  259.         ODDeleteObject(iter);
  260.         
  261.     SOM_ENDTRY
  262.  
  263.     return (ODULong) iter;
  264. }
  265.  
  266. SOM_Scope ODTypeToken  SOMLINK ODFocusSetFirst(ODFocusSet *somSelf, Environment *ev,
  267.         ODULong iteratorID)
  268. {
  269.     ODFocusSetData *somThis = ODFocusSetGetData(somSelf);
  270.     ODFocusSetMethodDebug("ODFocusSet","ODFocusSetFirst");
  271.  
  272.     ODTypeToken focus = kODNullFocus;
  273.  
  274.     SOM_TRY
  275.     
  276.         LinkedListIterator* iterator = (LinkedListIterator*) iteratorID; 
  277.         FocusLink* link = (FocusLink*) iterator->First();
  278.         if (link)
  279.             focus = link->fFocus;
  280.  
  281.     SOM_CATCH_ALL
  282.     SOM_ENDTRY
  283.     
  284.     return focus;
  285. }
  286.  
  287. SOM_Scope ODTypeToken  SOMLINK ODFocusSetNext(ODFocusSet *somSelf, Environment *ev,
  288.         ODULong iteratorID)
  289. {
  290.     ODFocusSetData *somThis = ODFocusSetGetData(somSelf);
  291.     ODFocusSetMethodDebug("ODFocusSet","ODFocusSetNext");
  292.  
  293.     ODTypeToken focus = kODNullFocus;
  294.  
  295.     SOM_TRY
  296.  
  297.         LinkedListIterator* iterator = (LinkedListIterator*) iteratorID; 
  298.         FocusLink* link = (FocusLink*) iterator->Next();
  299.         if (link)
  300.             focus = link->fFocus;
  301.             
  302.     SOM_CATCH_ALL
  303.     SOM_ENDTRY
  304.     
  305.     return focus;
  306. }
  307.  
  308. SOM_Scope ODBoolean  SOMLINK ODFocusSetIsNotComplete(ODFocusSet *somSelf, Environment *ev,
  309.         ODULong iteratorID)
  310. {
  311.     ODFocusSetData *somThis = ODFocusSetGetData(somSelf);
  312.     ODFocusSetMethodDebug("ODFocusSet","ODFocusSetIsNotComplete");
  313.     
  314.     ODBoolean isNotComplete = kODFalse;
  315.  
  316.     SOM_TRY
  317.  
  318.         LinkedListIterator* iterator = (LinkedListIterator*) iteratorID; 
  319.         isNotComplete = iterator->IsNotComplete();
  320.     
  321.     SOM_CATCH_ALL
  322.     SOM_ENDTRY
  323.  
  324.     return isNotComplete;
  325. }
  326.  
  327. SOM_Scope void  SOMLINK ODFocusSetRemoveIterator(ODFocusSet *somSelf, Environment *ev,
  328.         ODULong iteratorID)
  329. {
  330.     ODFocusSetData *somThis = ODFocusSetGetData(somSelf);
  331.     ODFocusSetMethodDebug("ODFocusSet","ODFocusSetRemoveIterator");
  332.     
  333.     LinkedListIterator* iterator = (LinkedListIterator*) iteratorID; 
  334.     ODDeleteObject(iterator);
  335. }
  336.  
  337. SOM_Scope void  SOMLINK ODFocusSetsomUninit(ODFocusSet *somSelf)
  338. {
  339.     ODFocusSetData *somThis = ODFocusSetGetData(somSelf);
  340.     ODFocusSetMethodDebug("ODFocusSet","ODFocusSetsomUninit");
  341.  
  342.     _fImplementation->DeleteAllLinks();
  343.     ODDeleteObject(_fImplementation);
  344.     parent_somUninit(somSelf);
  345. }
  346.