/* @(#)Z 1.10.1.3 com/src/samples/t3part/iodt3.h, odt3part, od96nt, odnt9712d 97/03/21 17:36:18 (97/03/04 18:24:22) */
/*====START_GENERATED_PROLOG======================================
 */
/*
 *   COMPONENT_NAME: odt3part
 *
 *   CLASSES:   T3GameException
 *              T3GameModel
 *
 *   ORIGINS: 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:      iodt3.h
//  Contains:  Implementation of an Embedded TicTacToe Game Part
// ************************************************************************



//---- T3Part: TicTacToe Game -----------------------------------------------
//
//

#ifndef OpenDoc_Sample_T3Part
#define OpenDoc_Sample_T3Part




// ---- T3GameModel ----------------------------------------------------------
//
//      This class contains the contents (persistent data) of the T3Game
//      program.  The T3Game plays interactive TicTacToe.  It contains a
//      simple game board of X and O positions.
//
//

class T3GameModel {

    public:

                         T3GameModel();
        virtual         ~T3GameModel();

        // main access to TTT game engine
        void             MakeAMove(char);

        // used by TTT game engine
        int              DoXMove(int);
        int              DoOMove(int);

        int              PickMove(void);
        int              AnyWinner(long);

        // used by containing game to detect winners
        void             AnyWinners(void);

        // used by Opendoc draw method
        int              GetXMove(int iSquare);
        int              GetOMove(int iSquare);

        // used by Opendoc WonByX or WonByO methods
        void             SetXMove(int iSquare);
        void             SetOMove(int iSquare);

        // used by Bento storage streaming methods
        long             GetXMap(void);
        long             GetOMap(void);

        void             SetXMap(long xMap);
        void             SetOMap(long oMap);

    private:

        T3GameModel&     operator=(const T3GameModel&);
                         T3GameModel(const T3GameModel&);

        long fXMap;                    // position of X's on Game Board
        long fOMap;                    // position of O's on Game Board
};



//---- T3GameException --------------------------------------------------------
//
//      The T3GameException throws a catchable exception that indicates
//      if incorrect moves were made or if the game has been tied or won.
//
//

class T3GameException {

public:
        enum EReason { kInvalidMove, kWinByX, kWinByO, kTieGame};

        unsigned long GetReason() const;
        virtual void Throw() const;

        T3GameException(EReason reason);
        T3GameException(const T3GameException&);
        T3GameException& operator=(const T3GameException&);

        virtual ~T3GameException();



private:
        enum EVersion { kOriginalVersion };

        unsigned long fData;

        T3GameException();
};



// ---- SOM / OpenDoc Includes, Constants, ... ---------------------------
//
//

#define T3Part_Class_Source


// VARIABLE_MACROS enables the SOM _fMyVariable convenience macros
#define VARIABLE_MACROS
#define METHOD_MACROS

#define T3GamePart_Class_Source

#include <barray.h>
#include <focuslib.h>
#include <ODMath.h>
#include <ODRes.h>
#include <ODTypes.h>
#include <StorUtil.h>
#include <TempObj.h>
#include <WinUtils.h>
#include <ODExcept.h>

#ifndef SOM_T3GamePart_xih
#include <iodt3.xih>
#endif


#ifndef SOM_ODArbitrator_xh
#include <Arbitrat.xh>
#endif

#ifndef SOM_ODCanvas_xh
#include <Canvas.xh>
#endif

#ifndef SOM_ODFacet_xh
#include <Facet.xh>
#endif

#ifndef SOM_ODFrame_xh
#include <Frame.xh>
#endif

#ifndef SOM_ODMenubar_xh
#include <Menubar.xh>
#endif

#ifndef SOM_ODSession_xh
#include <ODSessn.xh>
#endif

#ifndef SOM_ODPlatformCanvas_xh
#include <PlatCanv.xh>
#endif

#ifndef SOM_ODShape_xh
#include <Shape.xh>
#endif

#ifndef SOM_Module_xh5cStdProps_OpenDoc_StdProps_defined
#include <StdProps.xh>
#endif

#ifndef SOM_Module_xh5cStdTypes_OpenDoc_StdTypes_defined
#include <StdTypes.xh>
#endif

#ifndef SOM_ODStorageUnit_xh
#include <StorageU.xh>
#endif

#ifndef SOM_ODTransform_xh
#include <Trnsform.xh>
#endif

#ifndef SOM_ODWindow_xh
#include <Window.xh>
#endif

#ifndef SOM_ODWin32Canvas_xh
#include <WinPCanv.xh>
#endif

#ifndef SOM_ODWindowWorldCanvas_xh
#include <WinWCanv.xh>
#endif

#ifndef SOM_ODWindowState_xh
#include <WinStat.xh>
#endif



#   include <qprintf.h>

#   define QPRINTF qprintf
#   include <windows.h>
#   include <winuser.h>
#   include <wingdi.h>


#include <iostream.h>

#include <ODRegApi.h>



// ---- OpenDoc Menu Constants -------------------------------------------
//
//      Start our menuids with kODCommandParts, which is the menuid set
//      aside for parts subclassed from Base Container part, as defined
//      in BCMAIN.H.

const   ODMenuID  kODGameMenuID = kODCommandParts;

#define CMD(X)    kODCommand##X

#define kODCommandNewGame               (kODCommandParts+1)
#define kODCommandQuitGame              (kODCommandParts+2)

#define kT3PropXMap                     "T3GamePart:Property:XMap"
#define kT3PropOMap                     "T3GamePart:Property:OMap"
#define kT3GameExtension                 "T3GamePart:Extension:Game"


#define kPartKindName                   "T3GamePart"
#define kPartHandlerName                "T3GamePart"
#define kPartHandlerDllName             "iodt3.DLL"
#define kWindowsIcon                    "iodt3.ICO"

const   ODType   kPartKindDisplayName = "T3GamePart Container Part";
const   ODType   kPartCategory        = "Game Container";



// ---- NLS Message constants --------------------------------------------
//
//      The T3_MSG_SET and T3_* messages must conform to what
//      is shown in the XPG/4 Message catalog file T3PART.MSG
//
//

#include <locale.h>
#include <wchar.h>
#include <odnltyps.h>
#ifndef NL_CAT_LOCALE

    #define NL_CAT_LOCALE 1
    typedef int nl_catd;

    int catopen(char *, int) { return 0; }
    char* catgets(int a, int b, int c, char *defaultMsg) { return defaultMsg; }
    void catclose(int) { }

#endif

#define T3_NLS_CATALOG "iodt3"  // T3PART Messages are stored in iodt3.MSG
#define T3_MSG_SET     1         // T3PART menu messages are in Set #1

#define T3_GAMEMENU    1         // message "Game" title of the GAME pulldown menu
#define T3_NEWGAME     2         // message "New Game" for starting a new game
#define T3_QUITGAME    3         // message "Quit Game" for quitting the current game
#define T3_XTOKEN      4         // locale customizable token for X
#define T3_OTOKEN      5         // locale customizable token for O

#define T3_TTTANYONE   6         // TicTacToe Anyone
#define T3_INVMOVE     7         // Invalid Move
#define T3_XWINS       8         // X Wins the Game
#define T3_OWINS       9         // O Wins the Game
#define T3_TIEGAME    10         // Tie Game



// mouse position displayed for insertion point of dropped or pasted data
#define T3_NPOINTS 5            // # of points to make a cross hair mark


#endif   // end of OpenDoc_Sample_T3Part Include file
