/*
 * views.h
 *
 * Turbo Vision - Version 2.0
 *
 * Copyright (c) 1994 by Borland International
 * All Rights Reserved.
 *
 * Modified by Sergio Sigala <ssigala@globalnet.it>
 */

#if !defined( __COMMAND_CODES )
#define __COMMAND_CODES

const ushort

//  Standard command codes

    cmValid         = 0,
    cmQuit          = 1,
    cmError         = 2,
    cmMenu          = 3,
    cmClose         = 4,
    cmZoom          = 5,
    cmResize        = 6,
    cmNext          = 7,
    cmPrev          = 8,
    cmHelp          = 9,

//  TDialog standard commands

    cmOK            = 10,
    cmCancel        = 11,
    cmYes           = 12,
    cmNo            = 13,
    cmDefault       = 14,

// Standard application commands

    cmNew           = 30,
    cmOpen          = 31,
    cmSave          = 32,
    cmSaveAs        = 33,
    cmSaveAll       = 34,
    cmChDir         = 35,
    cmDosShell      = 36,
    cmCloseAll      = 37,

    /*
     * SS: some new internal commands.
     */
    cmSysRepaint    = 38,
    cmSysResize     = 39,
    cmSysWakeup     = 40,

//  TView State masks

    sfVisible       = 0x001,
    sfCursorVis     = 0x002,
    sfCursorIns     = 0x004,
    sfShadow        = 0x008,
    sfActive        = 0x010,
    sfSelected      = 0x020,
    sfFocused       = 0x040,
    sfDragging      = 0x080,
    sfDisabled      = 0x100,
    sfModal         = 0x200,
    sfDefault       = 0x400,
    sfExposed       = 0x800,

// TView Option masks

    ofSelectable    = 0x001,
    ofTopSelect     = 0x002,
    ofFirstClick    = 0x004,
    ofFramed        = 0x008,
    ofPreProcess    = 0x010,
    ofPostProcess   = 0x020,
    ofBuffered      = 0x040,
    ofTileable      = 0x080,
    ofCenterX       = 0x100,
    ofCenterY       = 0x200,
    ofCentered      = 0x300,
    ofValidate      = 0x400,

// TView GrowMode masks

    gfGrowLoX       = 0x01,
    gfGrowLoY       = 0x02,
    gfGrowHiX       = 0x04,
    gfGrowHiY       = 0x08,
    gfGrowAll       = 0x0f,
    gfGrowRel       = 0x10,
    gfFixed         = 0x20,

// TView DragMode masks

    dmDragMove      = 0x01,
    dmDragGrow      = 0x02,
    dmLimitLoX      = 0x10,
    dmLimitLoY      = 0x20,
    dmLimitHiX      = 0x40,
    dmLimitHiY      = 0x80,
    dmLimitAll      = dmLimitLoX | dmLimitLoY | dmLimitHiX | dmLimitHiY,

// TView Help context codes

    hcNoContext     = 0,
    hcDragging      = 1,

// TScrollBar part codes

    sbLeftArrow     = 0,
    sbRightArrow    = 1,
    sbPageLeft      = 2,
    sbPageRight     = 3,
    sbUpArrow       = 4,
    sbDownArrow     = 5,
    sbPageUp        = 6,
    sbPageDown      = 7,
    sbIndicator     = 8,

// TScrollBar options for TWindow.StandardScrollBar

    sbHorizontal    = 0x000,
    sbVertical      = 0x001,
    sbHandleKeyboard = 0x002,

// TWindow Flags masks

    wfMove          = 0x01,
    wfGrow          = 0x02,
    wfClose         = 0x04,
    wfZoom          = 0x08,

//  TView inhibit flags

    noMenuBar       = 0x0001,
    noDeskTop       = 0x0002,
    noStatusLine    = 0x0004,
    noBackground    = 0x0008,
    noFrame         = 0x0010,
    noViewer        = 0x0020,
    noHistory       = 0x0040,

// TWindow number constants

    wnNoNumber      = 0,

// TWindow palette entries

    wpBlueWindow    = 0,
    wpCyanWindow    = 1,
    wpGrayWindow    = 2,

//  Application command codes

    cmCut           = 20,
    cmCopy          = 21,
    cmPaste         = 22,
    cmUndo          = 23,
    cmClear         = 24,
    cmTile          = 25,
    cmCascade       = 26,

// Standard messages

    cmReceivedFocus     = 50,
    cmReleasedFocus     = 51,
    cmCommandSetChanged = 52,

// TScrollBar messages

    cmScrollBarChanged  = 53,
    cmScrollBarClicked  = 54,

// TWindow select messages

    cmSelectWindowNum   = 55,

//  TListViewer messages

    cmListItemSelected  = 56,

//  Event masks

    positionalEvents    = evMouse,
    focusedEvents       = evKeyboard | evCommand;

#endif  // __COMMAND_CODES

#if defined( Uses_TCommandSet ) && !defined( __TCommandSet )
#define __TCommandSet

/**
 * This class stores a set of commands.
 *
 * Note: this object can only handle commands whose code is within 0 and 255.
 * Only commands in this range may be disabled.
 * @short Stores a set of commands
 */
class TCommandSet
{
public:
    /**
     * Constructor.
     *
     * The initial command set is empty.
     */
    TCommandSet();
    /**
     * Constructor.
     *
     * The initial command set is copied from set `tc'.
     */
    TCommandSet( const TCommandSet& tc );
    /**
     * Returns True if command `cmd' is in the set.
     */
    Boolean has( int cmd );
    /**
     * Removes command `cmd' from the set.
     */
    void disableCmd( int cmd );
    /**
     * Adds command `cmd' to the set.
     */
    void enableCmd( int cmd );
    /**
     * Adds command `cmd' to the set.
     */
    void operator += ( int cmd );
    /**
     * Removes command `cmd' from the set.
     */
    void operator -= ( int cmd );
    /**
     * Removes all commands in set `tc' from this command set.
     */
    void disableCmd( const TCommandSet& tc );
    /**
     * Adds all commands in set `tc' to this command set.
     */
    void enableCmd( const TCommandSet& tc );
    /**
     * Adds all commands in set `tc' to this command set.
     */
    void operator += ( const TCommandSet& tc );
    /**
     * Removes all commands in set `tc' from this command set.
     */
    void operator -= ( const TCommandSet& tc );
    /**
     * Returns True if the command set is empty.
     */
    Boolean TCommandSet::isEmpty();
    /**
     * Calculates the intersection of this set and the `tc' set.
     *
     * The resulting set is the larger set which contains commands present in
     * both sets. Returns a reference to this object.
     */
    TCommandSet& operator &= ( const TCommandSet& tc);
    /**
     * Calculates the union of this set and the `tc' set.
     *
     * The resulting set is the smaller set which contains commands present in
     * either sets. Returns a reference to this object.
     */
    TCommandSet& operator |= ( const TCommandSet& tc);
    /**
     * Calculates the intersection of this set and the `tc' set.
     *
     * The resulting set is the larger set which contains commands present in
     * both sets. Returns the resulting set.
     */
    friend TCommandSet operator & ( const TCommandSet&, const TCommandSet& );
    /**
     * Calculates the union of this set and the `tc' set.
     *
     * The resulting set is the smaller set which contains commands present in
     * either sets. Returns the resulting set.
     */
    friend TCommandSet operator | ( const TCommandSet&, const TCommandSet& );
    /**
     * Returns 1 if the sets `tc1' and `tc2' are equal.
     *
     * Otherwise returns 0.
     */
    friend int operator == ( const TCommandSet& tc1, const TCommandSet& tc2 );
    /**
     * Returns 1 if the sets `tc1' and `tc2' are not equal.
     *
     * Otherwise returns 0.
     */
    friend int operator != ( const TCommandSet& tc1, const TCommandSet& tc2 );
private:
    int loc( int );
    int mask( int );
    static int masks[8];
    uchar cmds[32];
};

inline void TCommandSet::operator += ( int cmd )
{
    enableCmd( cmd );
}

inline void TCommandSet::operator -= ( int cmd )
{
    disableCmd( cmd );
}

inline void TCommandSet::operator += ( const TCommandSet& tc )
{
    enableCmd( tc );
}

inline void TCommandSet::operator -= ( const TCommandSet& tc )
{
    disableCmd( tc );
}

inline int operator != ( const TCommandSet& tc1, const TCommandSet& tc2 )
{
    return !operator == ( tc1, tc2 );
}

inline int TCommandSet::loc( int cmd )
{
    return cmd / 8;
}

inline int TCommandSet::mask( int cmd )
{
    return masks[ cmd & 0x07 ];
}

#endif  // Uses_TCommandSet

#if defined( Uses_TPalette ) && !defined( __TPalette )
#define __TPalette

class TPalette
{

public:

    TPalette( const char *, ushort );
    TPalette( const TPalette& );
    ~TPalette();

    TPalette& operator = ( const TPalette& );

    uchar& operator[]( int ) const;

    uchar *data;

};

#endif  // Uses_TPalette

#if defined( Uses_TView ) && !defined( __TView )
#define __TView

class TRect;
class TEvent;
class TGroup;

/**
 * The base of all visible objects.
 * @short The base of all visible objects
 */
class TView : public TObject, public TStreamable
{
public:
    /**
     * YYY
     */
    enum phaseType { phFocused, phPreProcess, phPostProcess };
    /**
     * YYY
     */
    enum selectMode{ normalSelect, enterSelect, leaveSelect };
    /**
     * Constructor.
     *
     * Parameter `bounds' will be the bounding rectangle of the view.
     */
    TView( const TRect& bounds );
    /**
     * Destructor.
     */
    ~TView();
    /**
     * Gets the minimum and maximum size limits of the view.
     */
    virtual void sizeLimits( TPoint& min, TPoint& max );
    /**
     * Returns the bounding rectangle of the view.
     *
     * `a' is set to `origin' and `b' is set to `origin' + `size'.
     */
    TRect getBounds();
    /**
     * Returns the size of the view.
     *
     * `a' is set to 0,0 and `b' is set to `size'.
     */
    TRect getExtent();
    /**
     * Returns the smaller rectangle which needs to be redrawn in a draw()
     * call.
     *
     * For complex views, you may use this method inside draw() to achieve
     * better speed performances.
     * @see TView::draw
     */
    TRect getClipRect();
    /**
     * Returns True if the coordinate `mouse' is inside this view.
     *
     * `mouse' is defined in the global coordinate system.
     * @see TView::makeGlobal
     * @see TView::makeLocal
     */
    Boolean mouseInView( TPoint mouse );
    /**
     * Returns True if the view is visible and the mouse coordinate (defined
     * in `event.mouse.where') is within this view.
     *
     * The coordinate is defined in the global coordinate system.
     * @see TView::makeGlobal
     * @see TView::makeLocal
     */
    Boolean containsMouse( TEvent& event );
    /**
     * Changes view bounds according to the `bounds' parameter.
     *
     * This method calls sizeLimits() to be sure that parameter `bounds' is
     * acceptable. Then calls changeBounds() to change view bounds and last
     * the view is redrawn in its new position.
     * @see TView::changeBounds
     * @see TView::sizeLimits
     */
    void locate( TRect& bounds );
    /**
     * YYY
     */
    virtual void dragView( TEvent& event, uchar mode,   //  temporary fix
      TRect& limits, TPoint minSize, TPoint maxSize ); //  for Miller's stuff
    /**
     * YYY
     */
    virtual void calcBounds( TRect& bounds, TPoint delta );
    /**
     * YYY
     */
    virtual void changeBounds( const TRect& bounds );
    /**
     * YYY
     */
    void growTo( short x, short y );
    /**
     * YYY
     */
    void moveTo( short x, short y );
    /**
     * YYY
     */
    void setBounds( const TRect& bounds );
    /**
     * YYY
     */
    virtual ushort getHelpCtx();
    /**
     * YYY
     */
    virtual Boolean valid( ushort command );
    /**
     * Hides the view.
     *
     * It just calls setState() to clear sfVisible bit in `state' variable.
     * @see TView::setState
     */
    void hide();
    /**
     * Shows the view.
     *
     * It just calls setState() to set sfVisible bit in `state' variable.
     * @see TView::setState
     */
    void show();
    /**
     * Draws the view on the screen.
     *
     * Every visible object must redefine it. To perform its task, draw()
     * usually uses a TDrawBuffer object.
     * @see TDrawBuffer
     * @see TView::drawView
     */
    virtual void draw();
    /**
     * Draws the view on the screen.
     *
     * This method calls exposed() to check if the view is exposed and on
     * success calls the draw() method. If you need to redraw a view, it is
     * best to call this method instead of calling draw() directly.
     * @see TView::draw
     * @see TView::exposed
     */
    void drawView();
    /**
     * Checks if the view is exposed.
     *
     * Returns True on success. The view is exposed if:
     *
     * - it has the sfExposed bit set in `state' variable
     *
     * - it has the sfVisible bit set in `state' variable
     *
     * - its coordinates make it fully or partially visible on the screen.
     */
    Boolean exposed();
    /**
     * Tries to grab the focus.
     *
     * The view can grab the focus if:
     *
     * - the view is not selected (bit sfSelected cleared in `state')
     *
     * - the view is not modal (bit sfModal cleared in `state')
     *
     * - the owner exists and it is focused.
     *
     * If all the above conditions are True, the exposed() calls select() to
     * get the focus.
     * @see TView::select
     */
    Boolean focus();
    /**
     * YYY
     */
    void hideCursor();
    /**
     * YYY
     */
    void drawHide( TView *lastView );
    /**
     * YYY
     */
    void drawShow( TView *lastView );
    /**
     * YYY
     */
    void drawUnderRect( TRect& r, TView *lastView );
    /**
     * YYY
     */
    void drawUnderView( Boolean doShadow, TView *lastView );
    /**
     * YYY
     */
    virtual ushort dataSize();
    /**
     * YYY
     */
    virtual void getData( void *rec );
    /**
     * YYY
     */
    virtual void setData( void *rec );
    /**
     * YYY
     */
    virtual void awaken();
    /**
     * YYY
     */
    void blockCursor();
    /**
     * YYY
     */
    void normalCursor();
    /**
     * YYY
     */
    virtual void resetCursor();
    /**
     * YYY
     */
    void setCursor( int x, int y );
    /**
     * YYY
     */
    void showCursor();
    /**
     * YYY
     */
    void drawCursor();
    /**
     * YYY
     */
    void clearEvent( TEvent& event );
    /**
     * YYY
     */
    Boolean eventAvail();
    /**
     * YYY
     */
    virtual void getEvent( TEvent& event );
    /**
     * The standard event handler of the view.
     */
    virtual void handleEvent( TEvent& event );
    /**
     * YYY
     */
    virtual void putEvent( TEvent& event );
    /**
     * YYY
     */
    static Boolean commandEnabled( ushort command );
    /**
     * YYY
     */
    static void disableCommands( TCommandSet& commands );
    /**
     * YYY
     */
    static void enableCommands( TCommandSet& commands );
    /**
     * YYY
     */
    static void disableCommand( ushort command );
    /**
     * YYY
     */
    static void enableCommand( ushort command );
    /**
     * YYY
     */
    static void getCommands( TCommandSet& commands );
    /**
     * YYY
     */
    static void setCommands( TCommandSet& commands );
    /**
     * YYY
     */
    static void setCmdState( TCommandSet& commands, Boolean enable);
    /**
     * YYY
     */
    virtual void endModal( ushort command );
    /**
     * YYY
     */
    virtual ushort execute();
    /**
     * YYY
     */
    ushort getColor( ushort color );
    /**
     * YYY
     */
    virtual TPalette& getPalette() const;
    /**
     * YYY
     */
    uchar mapColor( uchar );
    /**
     * YYY
     */
    Boolean getState( ushort aState );
    /**
     * YYY
     */
    void select();
    /**
     * YYY
     */
    virtual void setState( ushort aState, Boolean enable );
    /**
     * YYY
     */
    void keyEvent( TEvent& event );
    /**
     * YYY
     */
    Boolean mouseEvent( TEvent& event, ushort mask );
    /**
     * YYY
     */
    TPoint makeGlobal( TPoint source );
    /**
     * YYY
     */
    TPoint makeLocal( TPoint source );
    /**
     * YYY
     */
    TView *nextView();
    /**
     * YYY
     */
    TView *prevView();
    /**
     * YYY
     */
    TView *prev();
    /**
     * YYY
     */
    TView *next;
    /**
     * YYY
     */
    void makeFirst();
    /**
     * YYY
     */
    void putInFrontOf( TView *Target );
    /**
     * YYY
     */
    TView *TopView();
    /**
     * YYY
     */
    void writeBuf(  short x, short y, short w, short h, const void* b );
    /**
     * YYY
     */
    void writeBuf(  short x, short y, short w, short h, const TDrawBuffer& b );
    /**
     * YYY
     */
    void writeChar( short x, short y, char c, uchar color, short count );
    /**
     * YYY
     */
    void writeLine( short x, short y, short w, short h, const TDrawBuffer& b );
    /**
     * YYY
     */
    void writeLine( short x, short y, short w, short h, const void *b );
    /**
     * YYY
     */
    void writeStr( short x, short y, const char *str, uchar color );
    /**
     * YYY
     */
    TPoint size;
    /**
     * YYY
     */
    ushort options;
    /**
     * YYY
     */
    ushort eventMask;
    /**
     * YYY
     */
    ushort state;
    /**
     * YYY
     */
    TPoint origin;
    /**
     * YYY
     */
    TPoint cursor;
    /**
     * YYY
     */
    uchar growMode;
    /**
     * YYY
     */
    uchar dragMode;
    /**
     * YYY
     */
    ushort helpCtx;
    /**
     * YYY
     */
    static Boolean commandSetChanged;
#ifndef GENINC
    /**
     * YYY
     */
    static TCommandSet curCommandSet;
#endif
    /**
     * YYY
     */
    TGroup *owner;
    /**
     * YYY
     */
    static Boolean showMarkers;
    /**
     * YYY
     */
    static uchar errorAttr;
    /**
     * YYY
     */
    virtual void shutDown();
private:
    void moveGrow( TPoint p,
                   TPoint s,
                   TRect& limits,
                   TPoint minSize,
                   TPoint maxSize,
                   uchar mode
                 );
    void change( uchar, TPoint delta, TPoint& p, TPoint& s, ulong ctrlState );
    int exposedRec1(short int, short int, class TView *);
    int exposedRec2(short int, short int, class TView *);
    void writeView(short int, short int, short int, const void *);
    void writeViewRec1(short int, short int, class TView *, int);
    void writeViewRec2(short int, short int, class TView *, int);
    virtual const char *streamableName() const
        { return name; }
protected:
    /**
     * Constructor.
     *
     * Used to recover the view from a stream.
     */
    TView( StreamableInit );
public:
    static const char * const name;
    /**
     * YYY
     */
    static TStreamable *build();
protected:
    /**
     * YYY
     */
    virtual void write( opstream& os );
    /**
     * YYY
     */
    virtual void *read( ipstream& is );
};

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

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

inline void TView::writeBuf( short x, short y, short w, short h,
                             const TDrawBuffer& b )
{
    writeBuf( x, y, w, h, b.data );
}

inline void TView::writeLine( short x, short y, short w, short h,
                              const TDrawBuffer& b )
{
    writeLine( x, y, w, h, b.data );
}

#endif  // Uses_TView

/* ---------------------------------------------------------------------- */
/*      class TFrame                                                      */
/*                                                                        */
/*      Palette layout                                                    */
/*        1 = Passive frame                                               */
/*        2 = Passive title                                               */
/*        3 = Active frame                                                */
/*        4 = Active title                                                */
/*        5 = Icons                                                       */
/* ---------------------------------------------------------------------- */

#if defined( Uses_TFrame ) && !defined( __TFrame )
#define __TFrame

class TRect;
class TEvent;
class TDrawBuffer;

/**
 * The frame around the windows.
 * @short The frame around the windows
 */
class TFrame : public TView
{
public:
    /**
     * Constructor.
     *
     * `bounds' is the bounding rectangle of the frame.
     */
    TFrame( const TRect& bounds );
    /**
     * Draws the frame.
     * @see TView::draw
     */ 
    virtual void draw();
    /**
     * Returns a reference to the frame palette.
     * @see TView::getPalette
     */
    virtual TPalette& getPalette() const;
    /**
     * Handles TFrame events.
     * @see TView::handleEvents
     */
    virtual void handleEvent( TEvent& event );
    /**
     * Changes the state of the frame.
     * @see TView::setState
     */
    virtual void setState( ushort aState, Boolean enable );
    static char frameChars[33];
    /**
     * The character showed in the close box.
     */
    static const char * closeIcon;
    /**
     * The character showed in the lower right corner of the screen.
     */
    static const char * dragIcon;
private:
    void frameLine( TDrawBuffer& frameBuf, short y, short n, uchar color );
    void dragWindow( TEvent& event, uchar dragMode );
    friend class TDisplay;
    static const char initFrame[19];
    static const char * zoomIcon;
    static const char * unZoomIcon;
    virtual const char *streamableName() const
        { return name; }
protected:
    /**
     * Constructor.
     *
     * Used to recover the view from a stream.
     */
    TFrame( StreamableInit );
public:
    static const char * const name;
    /**
     * Creates a new TFrame.
     *
     * Used to recover the view from a stream.
     */
    static TStreamable *build();
};

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

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

#endif  // Uses_TFrame

/* ---------------------------------------------------------------------- */
/*      class TScrollBar                                                  */
/*                                                                        */
/*      Palette layout                                                    */
/*        1 = Page areas                                                  */
/*        2 = Arrows                                                      */
/*        3 = Indicator                                                   */
/* ---------------------------------------------------------------------- */

#if defined( Uses_TScrollBar ) && !defined( __TScrollBar )
#define __TScrollBar

class TRect;
class TEvent;

typedef char TScrollChars[5];

class TScrollBar : public TView
{

public:

    TScrollBar( const TRect& bounds );

    virtual void draw();
    virtual TPalette& getPalette() const;
    virtual void handleEvent( TEvent& event );
    virtual void scrollDraw();
    virtual int scrollStep( int part );
    void setParams( int aValue, int aMin, int aMax,
                    int aPgStep, int aArStep );
    void setRange( int aMin, int aMax );
    void setStep( int aPgStep, int aArStep );
    void setValue( int aValue );

    void drawPos( int pos );
    int getPos();
    int getSize();

    int value;

    TScrollChars chars;
    int minVal;
    int maxVal;
    int pgStep;
    int arStep;
    static TScrollChars vChars;
    static TScrollChars hChars;

private:

    int getPartCode(void);

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

protected:

    TScrollBar( StreamableInit );
    virtual void write( opstream& os );
    virtual void *read( ipstream& is );

public:

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

};

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

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

#endif  // Uses_TScrollBar

/* ---------------------------------------------------------------------- */
/*      class TScroller                                                   */
/*                                                                        */
/*      Palette layout                                                    */
/*      1 = Normal text                                                   */
/*      2 = Selected text                                                 */
/* ---------------------------------------------------------------------- */

#if defined( Uses_TScroller ) && !defined( __TScroller )
#define __TScroller

class TRect;
class TScrollBar;
class TEvent;

class TScroller : public TView
{

public:

    TScroller( const TRect& bounds,
               TScrollBar *aHScrollBar,
               TScrollBar *aVScrollBar
             );

    virtual void changeBounds( const TRect& bounds );
    virtual TPalette& getPalette() const;
    virtual void handleEvent( TEvent& event );
    virtual void scrollDraw();
    void scrollTo( int x, int y );
    void setLimit( int x, int y );
    virtual void setState( ushort aState, Boolean enable );
    void checkDraw();
    virtual void shutDown();
    TPoint delta;

protected:

    uchar drawLock;
    Boolean drawFlag;
    TScrollBar *hScrollBar;
    TScrollBar *vScrollBar;
    TPoint limit;

private:

    void showSBar( TScrollBar *sBar );

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

protected:

    TScroller( StreamableInit );
    virtual void write( opstream& os );
    virtual void *read( ipstream& is );

public:

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

};

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

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

#endif  // Uses_TScroller

#if defined( Uses_TListViewer ) && !defined( __TListViewer )
#define __TListViewer

class TRect;
class TScrollBar;
class TEvent;

class TListViewer : public TView
{

    static const char * emptyText;

public:

    TListViewer( const TRect& bounds,
                 ushort aNumCols,
                 TScrollBar *aHScrollBar,
                 TScrollBar *aVScrollBar
               );

    virtual void changeBounds( const TRect& bounds );
    virtual void draw();
    virtual void focusItem( short item );
    virtual TPalette& getPalette() const;
    virtual void getText( char *dest, short item, short maxLen );
    virtual Boolean isSelected( short item );
    virtual void handleEvent( TEvent& event );
    virtual void selectItem( short item );
    void setRange( short aRange );
    virtual void setState( ushort aState, Boolean enable );

    virtual void focusItemNum( short item );
    virtual void shutDown();

    TScrollBar *hScrollBar;
    TScrollBar *vScrollBar;
    short numCols;
    short topItem;
    short focused;
    short range;
    static char separatorChar;

private:

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

protected:

    TListViewer( StreamableInit );
    virtual void write( opstream& os );
    virtual void *read( ipstream& is );

public:

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

};

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

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

#endif  // Uses_TListViewer

#if defined( Uses_TGroup ) && !defined( __TGroup )
#define __TGroup

class TView;

class TGroup : public TView
{

public:

    TGroup( const TRect& bounds );
    ~TGroup();

    virtual void shutDown();

    ushort execView( TView *p );
    virtual ushort execute();
    virtual void awaken();

    void insertView( TView *p, TView *Target );
    void remove( TView *p );
    void removeView( TView *p );
    void resetCurrent();
    void setCurrent( TView *p, selectMode mode );
    void selectNext( Boolean forwards );
    TView *firstThat( Boolean (*func)( TView *, void * ), void *args );
    Boolean focusNext(Boolean forwards);
    void forEach( void (*func)( TView *, void * ), void *args );
    void insert( TView *p );
    void insertBefore( TView *p, TView *Target );
    TView *current;
    TView *at( short index );
    TView *firstMatch( ushort aState, ushort aOptions );
    short indexOf( TView *p );
    Boolean matches( TView *p );
    TView *first();

    virtual void setState( ushort aState, Boolean enable );

    virtual void handleEvent( TEvent& event );

    void drawSubViews( TView *p, TView *bottom );

    virtual void changeBounds( const TRect& bounds );

    virtual ushort dataSize();
    virtual void getData( void *rec );
    virtual void setData( void *rec );

    virtual void draw();
    void redraw();
    void lock();
    void unlock();
    virtual void resetCursor();

    virtual void endModal( ushort command );

    virtual void eventError( TEvent& event );

    virtual ushort getHelpCtx();

    virtual Boolean valid( ushort command );

    void freeBuffer();
    void getBuffer();

    TView *last;

    TRect clip;
    phaseType phase;

    ushort *buffer;
    uchar lockFlag;
    ushort endState;

private:

    Boolean invalid( TView *p, ushort command );
    void focusView( TView *p, Boolean enable );
    void selectView( TView *p, Boolean enable );
    TView* findNext(Boolean forwards);

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

protected:

    TGroup( StreamableInit );
    virtual void write( opstream& os );
    virtual void *read( ipstream& is );

public:

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

};

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

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

#endif  // Uses_TGroup

#if defined( Uses_TWindow ) && !defined( __TWindow )
#define __TWindow

#define cpBlueWindow "\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F"
#define cpCyanWindow "\x10\x11\x12\x13\x14\x15\x16\x17"
#define cpGrayWindow "\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F"

class TFrame;
class TRect;
class TPoint;
class TEvent;
class TFrame;
class TScrollBar;

class TWindowInit
{

public:

    TWindowInit( TFrame *(*cFrame)( TRect ) );

protected:

    TFrame *(*createFrame)( TRect );

};

/* ---------------------------------------------------------------------- */
/*      class TWindow                                                     */
/*                                                                        */
/*      Palette layout                                                    */
/*        1 = Frame passive                                               */
/*        2 = Frame active                                                */
/*        3 = Frame icon                                                  */
/*        4 = ScrollBar page area                                         */
/*        5 = ScrollBar controls                                          */
/*        6 = Scroller normal text                                        */
/*        7 = Scroller selected text                                      */
/*        8 = Reserved                                                    */
/* ---------------------------------------------------------------------- */

class TWindow: public TGroup, public virtual TWindowInit
{

public:

    TWindow( const TRect& bounds,
             const char *aTitle,
             short aNumber
           );
    ~TWindow();

    virtual void close();
    virtual TPalette& getPalette() const;
    virtual const char *getTitle( short maxSize );
    virtual void handleEvent( TEvent& event );
    static TFrame *initFrame( TRect );
    virtual void setState( ushort aState, Boolean enable );
    virtual void sizeLimits( TPoint& min, TPoint& max );
    TScrollBar *standardScrollBar( ushort aOptions );
    virtual void zoom();
    virtual void shutDown();

    uchar flags;
    TRect zoomRect;
    short number;
    short palette;
    TFrame *frame;
    const char *title;

private:

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

protected:

    TWindow( StreamableInit );
    virtual void write( opstream& os );
    virtual void *read( ipstream& is );

public:

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

};

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

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

#endif  // Uses_TWindow

Documentation generated by sergio@athena.milk.it on Wed Feb 10 22:11:47 CET 1999