/* @(#)Z 1.8 com/src/ui/WinIter.cpp, odui, od96nt, odnt9712d 97/03/21 16:49:25 (96/10/29 09:33:46) */
//====START_GENERATED_PROLOG======================================
//
//
//   COMPONENT_NAME: odui
//
//   CLASSES: none
//
//   ORIGINS: 82,27
//
//
//   (C) COPYRIGHT International Business Machines Corp. 1995,1996
//   All Rights Reserved
//   Licensed Materials - Property of IBM
//   US Government Users Restricted Rights - Use, duplication or
//   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
//
//   IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
//   ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
//   PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR
//   CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
//   USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
//   OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
//   OR PERFORMANCE OF THIS SOFTWARE.
//
//====END_GENERATED_PROLOG========================================
//

/*
        File:           WinIter.cpp

        Contains:       SOM class ODWindowIterator

        Owned by:       Richard Rodseth

        Copyright:      © 1994 - 1995 by Apple Computer, Inc., all rights reserved.

        Change History (most recent first):

                 <7>     10/8/95        TJ              Fixes Recomended by Refball
                 <6>      8/3/95        RR              #1257260: Collapse B classes. Remove
                                                                        somInit methods. Don't call IsInitialized
                                                                        or SubclassResponsibility
                 <5>     6/22/95        RR              #1245283 Undoable frame deletion
                                                                        #1209427 Changed private api between
                                                                        iterator and iteratee
                 <4>     5/26/95        RR              #1251403: Multithreading naming support
                 <3>     5/25/95        jpa             List.h --> LinkList.h [1253324]
                 <2>     4/13/95        RR              # 1216618 Added SOM_TRY
                 <1>     6/23/94        RR              first checked in

        To Do:
        In Progress:
*/


/*
 *  This file was generated by the SOM Compiler.
 *  Generated using:
 *      SOM Emitter emitxtm.dll: somc/smmain.c
 */

#ifdef DEBUG
// By defining this macro, SOM doesn't define it and I am able to use the
// MyMethodDebug as a break point for IPMD debugging
#define ODWindowIteratorMethodDebug(c,m) MyMethodDebug(c,m)
static void MyMethodDebug(char *c, char *m);
#endif

#define ODWindowIterator_Class_Source
#define VARIABLE_MACROS
#include <WinIter.xih>

#ifndef SOM_ODWindowState_xh
#include "WinStat.xh"
#endif

#ifndef _EXCEPT_
#include "Except.h"
#endif

#ifndef _LINKLIST_
#include <LinkList.h>
#endif

#ifndef _WINUTILM_
#include "WinUtilM.h"
#endif

#ifdef DEBUG
// This method is only used in the debug case as a break point for IPMD
static void MyMethodDebug(char *c, char *m)
{
  SOMMethodDebug(c,m);
}
#endif

SOM_Scope void  SOMLINK ODWindowIteratorInitWindowIterator(ODWindowIterator *somSelf, Environment *ev,
                ODWindowState* windowState)
{
    ODWindowIteratorData *somThis = ODWindowIteratorGetData(somSelf);
    ODWindowIteratorMethodDebug("ODWindowIterator","ODWindowIteratorInitWindowIterator");

        LinkedListIterator* iter = kODNULL; ODVolatile(iter);

        SOM_TRY

        /* Moved from somInit. SOM itself sets fields to zero
        _fWindowState = kODNULL;
        _fIteratorID = 0;
        */

        somSelf->InitObject(ev);

        _fWindowState = windowState;
        if (_fWindowState)
                _fIteratorID = _fWindowState->AddIterator(ev, somSelf);

        SOM_CATCH_ALL
        SOM_ENDTRY
}

SOM_Scope ODWindow*  SOMLINK ODWindowIteratorFirst(ODWindowIterator *somSelf, Environment *ev)
{
    ODWindowIteratorData *somThis = ODWindowIteratorGetData(somSelf);
    ODWindowIteratorMethodDebug("ODWindowIterator","ODWindowIteratorFirst");

        ODWindow* window = kODNULL;

        SOM_TRY

                window = _fWindowState->First(ev, _fIteratorID);

#if defined(_PLATFORM_WIN32_) || defined(_PLATFORM_OS2_) || defined(_PLATFORM_UNIX_)
                // Signify IsNotComplete will now work correctly
                _fIsNotCompleteWorks = kODTrue;
#endif

        SOM_CATCH_ALL
        SOM_ENDTRY

        return window;

}

SOM_Scope ODWindow*  SOMLINK ODWindowIteratorNext(ODWindowIterator *somSelf, Environment *ev)
{
    ODWindowIteratorData *somThis = ODWindowIteratorGetData(somSelf);
    ODWindowIteratorMethodDebug("ODWindowIterator","ODWindowIteratorNext");

        ODWindow* window = kODNULL;

        SOM_TRY

                window = _fWindowState->Next(ev, _fIteratorID);

#if defined(_PLATFORM_WIN32_) || defined(_PLATFORM_OS2_) || defined(_PLATFORM_UNIX_)
                // Signify IsNotComplete will now work correctly
                _fIsNotCompleteWorks = kODTrue;
#endif

        SOM_CATCH_ALL
        SOM_ENDTRY

        return window;
}

SOM_Scope ODWindow*  SOMLINK ODWindowIteratorLast(ODWindowIterator *somSelf, Environment *ev)
{
    ODWindowIteratorData *somThis = ODWindowIteratorGetData(somSelf);
    ODWindowIteratorMethodDebug("ODWindowIterator","ODWindowIteratorLast");

        ODWindow* window = kODNULL;

        SOM_TRY

                window = _fWindowState->Last(ev, _fIteratorID);

#if defined(_PLATFORM_WIN32_) || defined(_PLATFORM_OS2_) || defined(_PLATFORM_UNIX_)
                // Signify IsNotComplete will now work correctly
                _fIsNotCompleteWorks = kODTrue;
#endif

        SOM_CATCH_ALL
        SOM_ENDTRY

        return window;
}

SOM_Scope ODWindow*  SOMLINK ODWindowIteratorPrevious(ODWindowIterator *somSelf, Environment *ev)
{
    ODWindowIteratorData *somThis = ODWindowIteratorGetData(somSelf);
    ODWindowIteratorMethodDebug("ODWindowIterator","ODWindowIteratorPrevious");

        ODWindow* window = kODNULL;

        SOM_TRY

                window = _fWindowState->Previous(ev, _fIteratorID);

#if defined(_PLATFORM_WIN32_) || defined(_PLATFORM_OS2_) || defined(_PLATFORM_UNIX_)
                // Signify IsNotComplete will now work correctly
                _fIsNotCompleteWorks = kODTrue;
#endif

        SOM_CATCH_ALL
        SOM_ENDTRY

        return window;
}

SOM_Scope ODBoolean  SOMLINK ODWindowIteratorIsNotComplete(ODWindowIterator *somSelf, Environment *ev)
{
    ODWindowIteratorData *somThis = ODWindowIteratorGetData(somSelf);
    ODWindowIteratorMethodDebug("ODWindowIterator","ODWindowIteratorIsNotComplete");

        ODBoolean isNotComplete = kODFalse;

        SOM_TRY

#if defined(_PLATFORM_WIN32_) || defined(_PLATFORM_OS2_) || defined(_PLATFORM_UNIX_)
                // If first, last, previous or next used
                if (_fIsNotCompleteWorks)
                {
#endif
                    isNotComplete = _fWindowState->IsNotComplete(ev, _fIteratorID);
#if defined(_PLATFORM_WIN32_) || defined(_PLATFORM_OS2_) || defined(_PLATFORM_UNIX_)
                }
                else
                {
                    // Throw exception
                    THROW(kODErrIteratorNotInitialized);
                }
#endif

        SOM_CATCH_ALL
        SOM_ENDTRY

        return isNotComplete;
}

SOM_Scope void  SOMLINK ODWindowIteratorsomUninit(ODWindowIterator *somSelf)
{
    ODWindowIteratorData *somThis = ODWindowIteratorGetData(somSelf);
    ODWindowIteratorMethodDebug("ODWindowIterator","ODWindowIteratorsomUninit");

        TRY{
                _fWindowState->RemoveIterator(somGetGlobalEnvironment(), _fIteratorID);
        }CATCH_ALL{
                // Ignore any exception
        }ENDTRY

        _fWindowState = kODNULL;
        _fIteratorID = 0;
    parent_somUninit(somSelf);
}
