/* $Id: INPUT.H 2.4 1995/07/20 11:24:33 leon Exp $
 */
#ifndef __INPUT_H_

#define __INPUT_H_


#define Uses_TButton

#define Uses_TKeys

#define Uses_TWindow

#define Uses_TStreamableClass


#if defined(Uses_TInputInt   ) || \

    defined(Uses_TInputLong  ) || \
    defined(Uses_TInputDouble)
#define Uses_TInputLine

#define Uses_TRect

#define Uses_pstream

#define __INPUT_INC

#endif


#include <tvision/tv.h>


class TStreamable;
#include <values.h>



#if defined(Uses_TInputKey) && ! defined(__TInputKey)

#define __TInputKey


/**
 ** Same as TInputLine, except invalid if empty
 **/
class TInputKey : public TInputLine
{

public:

    TInputKey( const TRect&, int len );
    TInputKey( int x, int y, int len );
    virtual Boolean valid( ushort );

protected:

    TInputKey( StreamableInit ) : TInputLine( streamableInit ) {};

private:

    virtual const char *streamableName() const
        { return name; }

public:

    static const char * const name;
    static TStreamable *build();

};


inline ipstream& operator >> ( ipstream& is, TInputKey& cl )
    { return is >> (TStreamable&)cl; }
inline ipstream& operator >> ( ipstream& is, TInputKey*& cl )
    { return is >> (void *&)cl; }
inline opstream& operator << ( opstream& os, TInputKey& cl )
    { return os << (TStreamable&)cl; }
inline opstream& operator << ( opstream& os, TInputKey* cl )
    { return os << (TStreamable *)cl; }

#endif // Uses_TInputKey




#if defined(Uses_TInputInt) && ! defined(__TInputInt)

#define __TInputInt


/**
 ** Accepts only valid numeric input (int) between Min and Max
 **/
class TInputInt : public TInputLine
{

public:

    TInputInt( const TRect&, int len = 7, int min = -MAXINT, int max = MAXINT );
    TInputInt( int x, int y, int len = 7, int min = -MAXINT, int max = MAXINT );
    virtual ushort dataSize();
    virtual void getData( void *);
    virtual void setData( void *);
    virtual Boolean valid( ushort );
    int min;
    int max;

protected:

    TInputInt( StreamableInit ) : TInputLine( streamableInit ) {};
    virtual void write( opstream& );
    virtual void *read( ipstream& );

private:

    virtual const char *streamableName() const
        { return name; }

public:

    static const char * const name;
    static TStreamable *build();

};

inline ipstream& operator >> ( ipstream& is, TInputInt& cl )
    { return is >> (TStreamable&)cl; }
inline ipstream& operator >> ( ipstream& is, TInputInt*& cl )
    { return is >> (void *&)cl; }
inline opstream& operator << ( opstream& os, TInputInt& cl )
    { return os << (TStreamable&)cl; }
inline opstream& operator << ( opstream& os, TInputInt* cl )
    { return os << (TStreamable *)cl; }

#endif // Uses_TInputInt






#if defined( Uses_TInputLong ) && !defined( __TInputLong )

#define __TInputLong


//flags for TInputLong constructor


const
  ilHex = 1,          //will enable hex input with leading '0x'

  ilBlankEqZero = 2,  //No input (blank) will be interpreted as '0'

  ilDisplayHex = 4;   //Number displayed as hex when possible


// class far TRect;

// class far TEvent;


/**
 ** Inputs long variable
 **/ 
class TInputLong : public TInputLine
{

public:

    TInputLong( const TRect& bounds, int aMaxLen, long lowerLim,
		    long upperLim, ushort flags, const char* labelName = 0 );
    ~TInputLong();

    virtual ushort dataSize();
    virtual void getData( void *rec );
    virtual void handleEvent( TEvent& event );
    virtual void setData( void *rec );
    virtual Boolean rangeCheck();
    virtual void error();
    virtual Boolean valid(ushort command);

    ushort ilOptions;
    long lLim, uLim;
    char* label;

private:

    virtual const char *streamableName() const
	{ return name; }

protected:

    TInputLong( StreamableInit );
    virtual void write( opstream& );
    virtual void *read( ipstream& );

public:

    static const char * const near name;
    static TStreamable *build();

};

inline ipstream& operator >> ( ipstream& is, TInputLong& cl )
    { return is >> (TStreamable&)cl; }
inline ipstream& operator >> ( ipstream& is, TInputLong*& cl )
    { return is >> (void *&)cl; }

inline opstream& operator << ( opstream& os, TInputLong& cl )
    { return os << (TStreamable&)cl; }
inline opstream& operator << ( opstream& os, TInputLong* cl )
    { return os << (TStreamable *)cl; }

#endif  // Uses_TInputLong



#if defined(Uses_TInputDouble) && ! defined(__TInputDouble)

#define __TInputDouble


/**
 ** Accepts only valid numeric input between Min and Max
 **/
class TInputDouble : public TInputLine
{

public:

    TInputDouble( const TRect&, int len = 15, double min = -MAXDOUBLE, double max = MAXDOUBLE );
    TInputDouble( int x, int y, int len = 15, double min = -MAXDOUBLE, double max = MAXDOUBLE );
    virtual ushort dataSize();
    virtual void getData( void *);
    virtual void setData( void *);
    virtual Boolean valid( ushort );
    double min;
    double max;

protected:

    TInputDouble( StreamableInit ) : TInputLine( streamableInit ) {};
    virtual void write( opstream& );
    virtual void *read( ipstream& );

private:

    virtual const char *streamableName() const
        { return name; }

public:

    static const char * const name;
    static TStreamable *build();

};

inline ipstream& operator >> ( ipstream& is, TInputDouble& cl )
    { return is >> (TStreamable&)cl; }
inline ipstream& operator >> ( ipstream& is, TInputDouble*& cl )
    { return is >> (void *&)cl; }
inline opstream& operator << ( opstream& os, TInputDouble& cl )
    { return os << (TStreamable&)cl; }
inline opstream& operator << ( opstream& os, TInputDouble* cl )
    { return os << (TStreamable *)cl; }

#endif //  Uses_TInputDouble





#endif // __INPUT_H_



syntax highlighted by Code2HTML, v. 0.9.1