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

#if !defined( __BUTTON_TYPE )
#define __BUTTON_TYPE

const
    int bfNormal    = 0x00,
    bfDefault   = 0x01,
    bfLeftJust  = 0x02,
    bfBroadcast = 0x04,
    bfGrabFocus = 0x08,

    cmRecordHistory = 60;

#endif  // __BUTTON_TYPE

/* ---------------------------------------------------------------------- */
/*      class TDialog                                                     */
/*                                                                        */
/*      Palette layout                                                    */
/*        1 = Frame passive                                               */
/*        2 = Frame active                                                */
/*        3 = Frame icon                                                  */
/*        4 = ScrollBar page area                                         */
/*        5 = ScrollBar controls                                          */
/*        6 = StaticText                                                  */
/*        7 = Label normal                                                */
/*        8 = Label selected                                              */
/*        9 = Label shortcut                                              */
/*       10 = Button normal                                               */
/*       11 = Button default                                              */
/*       12 = Button selected                                             */
/*       13 = Button disabled                                             */
/*       14 = Button shortcut                                             */
/*       15 = Button shadow                                               */
/*       16 = Cluster normal                                              */
/*       17 = Cluster selected                                            */
/*       18 = Cluster shortcut                                            */
/*       19 = InputLine normal text                                       */
/*       20 = InputLine selected text                                     */
/*       21 = InputLine arrows                                            */
/*       22 = History arrow                                               */
/*       23 = History sides                                               */
/*       24 = HistoryWindow scrollbar page area                           */
/*       25 = HistoryWindow scrollbar controls                            */
/*       26 = ListViewer normal                                           */
/*       27 = ListViewer focused                                          */
/*       28 = ListViewer selected                                         */
/*       29 = ListViewer divider                                          */
/*       30 = InfoPane                                                    */
/*       31 = Cluster Disabled                                            */
/*       32 = Reserved                                                    */
/* ---------------------------------------------------------------------- */

#if defined( Uses_TDialog ) && !defined( __TDialog )
#define __TDialog

#define  cpGrayDialog \
    "\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F"\
    "\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F"

#define  cpBlueDialog \
    "\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f"\
    "\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f"

#define  cpCyanDialog \
    "\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f"\
    "\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f"

#define cpDialog cpGrayDialog

const int dpBlueDialog = 0,
      dpCyanDialog = 1,
      dpGrayDialog = 2;

class TRect;
class TEvent;
class TValidator;

class TDialog : public TWindow
{

public:

    TDialog( const TRect& bounds, const char *aTitle );

    virtual TPalette& getPalette() const;
    virtual void handleEvent( TEvent& event );
    virtual Boolean valid( ushort command );

private:

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

protected:

    TDialog( StreamableInit );

public:

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

};

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

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

#endif  // Uses_TDialog

/* ---------------------------------------------------------------------- */
/*      class TInputLine                                                  */
/*                                                                        */
/*      Palette layout                                                    */
/*        1 = Passive                                                     */
/*        2 = Active                                                      */
/*        3 = Selected                                                    */
/*        4 = Arrows                                                      */
/* ---------------------------------------------------------------------- */

#if defined( Uses_TInputLine ) && !defined( __TInputLine )
#define __TInputLine

class TRect;
class TEvent;
class TValidator;

class TInputLine : public TView
{

public:

    TInputLine( const TRect& bounds, int aMaxLen, TValidator *aValid = 0 );
    ~TInputLine();

    virtual ushort dataSize();
    virtual void draw();
    virtual void getData( void *rec );
    virtual TPalette& getPalette() const;
    virtual void handleEvent( TEvent& event );
    void selectAll( Boolean enable );
    virtual void setData( void *rec );
    virtual void setState( ushort aState, Boolean enable );
    virtual Boolean valid( ushort cmd );
    void setValidator( TValidator* aValid );

    char* data;
    int maxLen;
    int curPos;
    int firstPos;
    int selStart;
    int selEnd;

private:

    Boolean canScroll( int delta );
    int mouseDelta( TEvent& event );
    int mousePos( TEvent& event );
    void deleteSelect();
    void adjustSelectBlock();
    void saveState();
    void restoreState();
    Boolean checkValid(Boolean);

    static const char rightArrow;
    static const char leftArrow;

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

    TValidator* validator;

    int anchor;
#ifndef __UNPATCHED
    int oldAnchor; // New variable to save another bit of state info
#endif
    char* oldData;
    int oldCurPos;
    int oldFirstPos;
    int oldSelStart;
    int oldSelEnd;

protected:

    TInputLine( 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, TInputLine& cl )
    { return is >> (TStreamable&)cl; }
inline ipstream& operator >> ( ipstream& is, TInputLine*& cl )
    { return is >> (void *&)cl; }

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

#endif  // Uses_TInputLine


/* ---------------------------------------------------------------------- */
/*      TButton object                                                    */
/*                                                                        */
/*      Palette layout                                                    */
/*        1 = Normal text                                                 */
/*        2 = Default text                                                */
/*        3 = Selected text                                               */
/*        4 = Disabled text                                               */
/*        5 = Normal shortcut                                             */
/*        6 = Default shortcut                                            */
/*        7 = Selected shortcut                                           */
/*        8 = Shadow                                                      */
/* ---------------------------------------------------------------------- */

#if defined( Uses_TButton ) && !defined( __TButton )
#define __TButton

class TRect;
class TEvent;
class TDrawBuffer;

/**
 * One of the most used and easy to use views.
 * @short The button view
 */
class TButton : public TView
{
public:
    /**
     * Constructor.
     *
     * `bounds' is the bounding rectangle of the button. `aTitle' is a pointer
     * to a string which will be the caption of the button. `aCommand' is the
     * command generated when the user presses the button. `aFlags' is a
     * bitmap of the following values:
     *
     * 0x00 bfNormal - this is a normal button
     *
     * 0x01 bfDefault - default button
     *
     * 0x02 bfLeftJust - justifies the title at the left
     *
     * 0x04 bfBroadcast	- sends a broadcast message when pressed
     *
     * 0x08 bfGrabFocus	- the button grabs the focus when pressed
     *
     * Note: you can use only one default button. However the default property
     * can be passed to normal buttons by calling makeDefault().
     * @see TButton::amDefault
     * @see TButton::makeDefault
     */
    TButton( const TRect& bounds,
             const char *aTitle,
             ushort aCommand,
             ushort aFlags
           );
    /**
     * Destructor.
     */
    ~TButton();
    /**
     * Draws the button.
     */
    virtual void draw();
    /**
     * Called by draw().
     * @see TButton::draw
     */
    void drawState( Boolean down );
    /**
     * Returns a reference to the standard TButton palette.
     */
    virtual TPalette& getPalette() const;
    /**
     * Handles TButton events.
     */
    virtual void handleEvent( TEvent& event );
    /**
     * Changes the default property of this button.
     *
     * This method does nothing if the button is a default button (i.e. it has
     * the bfDefault bit set). Otherwise the button gets or releases his
     * default property depending on the value of the `enable' flag. If
     * `enable' is True, the button grabs the default property from the
     * default button (if exists) and the default button losts the default
     * property. If `enable' is False, the button releases the default
     * property to the default button (if exists). This allows a normal button
     * (without the bfDefault bit set) to behave like a default button.
     */
    void makeDefault( Boolean enable );
    /**
     * This method is called whenever the button is pressed.
     *
     * Its task is to send a message. The message is a broadcast message to
     * the owner of the view if the button has the bfBroadcast bit set,
     * otherwise the message is a command message.
     */
    virtual void press();
    /**
     * Changes the state of the button.
     * @see TView::setState
     */
    virtual void setState( ushort aState, Boolean enable );
    /**
     * This is a pointer to the caption of the button.
     */
    const char *title;
    /**
     * A pointer to the shadow characters.
     *
     * These characters are used to draw the button shadow.
     */
    static const char * shadows;
protected:
    /**
     * This is the command generated when the user presses the button.
     */
    ushort command;
    /**
     * This variable stores the various bfXXXX flags of the button.
     * @see TButton::TButton
     */
    uchar flags;
    /**
     * If True the button has the default property.
     *
     * The default button is automatically selected when the user presses the
     * Enter key. If this variable is False, the button is a normal button.
     */
    Boolean amDefault;
private:
    void drawTitle( TDrawBuffer&, int, int, ushort, Boolean );
    void pressButton( TEvent& );
    TRect getActiveRect();
    static const char * markers;
    virtual const char *streamableName() const
        { return name; }
protected:
    /**
     * Constructor.
     *
     * Used to recover the view from a stream.
     */
    TButton( StreamableInit ): TView( streamableInit ) {};
    /**
     * Used to store the view in a stream.
     */
    virtual void write( opstream& os );
    /**
     * Used to recover the view from a stream.
     */
    virtual void *read( ipstream& is );
public:
    static const char * const name;
    /**
     * Creates a new TButton.
     *
     * Used to recover the view from a stream.
     */
    static TStreamable *build();
};

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

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

#endif  // Uses_TButton


#if defined( Uses_TSItem ) && !defined( __TSItem )
#define __TSItem

class TSItem
{

public:

    TSItem( const char *aValue, TSItem *aNext )
        { value = newStr(aValue); next = aNext; }
    ~TSItem() { delete (void *)value; }

    const char *value;
    TSItem *next;
};

#endif  // Uses_TSItem

/* ---------------------------------------------------------------------- */
/*      class TCluster                                                    */
/*                                                                        */
/*      Palette layout                                                    */
/*        1 = Normal text                                                 */
/*        2 = Selected text                                               */
/*        3 = Normal shortcut                                             */
/*        4 = Selected shortcut                                           */
/*        5 = Disabled text                                               */
/* ---------------------------------------------------------------------- */

#if defined( Uses_TCluster ) && !defined( __TCluster )
#define __TCluster

class TRect;
class TSItem;
class TEvent;
class TPoint;
class TStringCollection;

/**
 * The base class used by TCheckBoxes and TRadioButtons.
 * @see TCheckBoxes
 * @see TRadioButtons
 * @short The base class of TCheckBoxes and TRadioButtons
 */
class TCluster : public TView
{
public:
    /**
     * Constructor.
     *
     * `bounds' is the bounding rectangle of the view. `aStrings' points to
     * a list of TSItem objects, one for each cluster item. Every TSItem
     * object stores the caption of the related item. TCluster handles a
     * maximum of 32 items.
     * @see TSItem
     */
    TCluster( const TRect& bounds, TSItem *aStrings );
    /**
     * Destructor.
     */
    ~TCluster();
    /**
     * Returns the size of the data record of this view.
     *
     * It just returns `sizeof(short)'.
     */
    virtual ushort dataSize();
    /**
     * Redraws the view.
     *
     * Called within the draw() method. `icon' points to a string which will
     * be written at the left side of every item. Parameter `marker' is the
     * character which will be written if the item is checked. Otherwise a
     * space character will be used.
     * @see TCluster::drawMultiBox
     */
    void drawBox( const char *icon, char marker );
    /**
     * Redraws the view.
     *
     * Called within the draw() method. `icon' points to a string which will
     * be written at the left side of every item. For example
     * TCheckBoxes::draw() calls this method with string " [ ] " as `icon'
     * parameter. TRadioButton::draw() calls this method with string " ( ) "
     * as parameter `icon'. Parameter `marker' is a pointer to an array of 2
     * characters. If the item is not checked the first character will be
     * written. Otherwise the second character will be used.
     * @see TCluster::drawBox
     * @see TCheckBoxes::draw
     * @see TRadioButtons::draw
     */
    void drawMultiBox(const char *icon, const char* marker);
    /**
     * Reads the data record of this view.
     *
     * It stores variable `value' (casted to short integer) at address `rec`.
     */
    virtual void getData( void *rec );
    /**
     * Returns the help context of the selected item.
     *
     * The help context is calculated by summing view variable `helpCtx' and
     * the number of the currently selected item (0 for the first item, 1 for
     * the second item, etc). Redefines TView::getHelpCtx().
     * @see TView::getHelpCtx
     * @see TView::helpCtx
     */
    ushort getHelpCtx();
    /**
     * Returns a reference to the standard TCluster palette.
     */
    virtual TPalette& getPalette() const;
    /**
     * Handles TCluster events.
     */
    virtual void handleEvent( TEvent& event );
    /**
     * Should return True if the specified item is checked.
     *
     * Does nothing and returns False. Redefined in TCheckBoxes and in
     * TRadioButtons.
     * @see TCheckBoxes::mark
     * @see TRadioButtons::mark
     */
    virtual Boolean mark( int item );
    /**
     * It just returns `(uchar)(mark(item) == True)'.
     */
    virtual uchar multiMark( int item );
    /**
     * Should change the state of an item.
     *
     * Does nothing. Redefined in TCheckBoxes and in TRadioButtons.
     * @see TCheckBoxes::press
     * @see TRadioButtons::press
     */
    virtual void press( int item );
    /**
     * Called whenever the user moves the selection to another item.    
     *
     * Does nothing. Redefined in TRadioButtons.
     * @see TRadioButtons::movedTo
     */
    virtual void movedTo( int item );
    /**
     * Writes the data record of this view.
     *
     * This method reads a short integer from address `rec', places it in
     * variable `value' and then calls drawView().
     * @see TCluster::value
     * @see TView::drawView
     */
    virtual void setData( void *rec );
    /**
     * Changes the state of the view.
     * @see TView::setState
     */
    virtual void setState( ushort aState, Boolean enable );
    /**
     * Sets the state of one or more items.
     *
     * `aMask` is a bitmap which specifies what items to enable or disable.
     * `enable' is the action to perform: False to disable, True to enable.
     */
    virtual void setButtonState(unsigned long aMask, Boolean enable);
protected:
    /**
     * This variable stores the item status bitmap.
     *
     * If bit 0 is set the first item is checked, if bit 1 is set the second
     * item is checked, etc. If a bit is cleared the related item is
     * not checked. Its initial value is 0.
     */
    unsigned long value;
    /**
     * This variable stores a bitmap which selectively enables cluster items.
     *
     * If bit 0 is set the first item is enabled, if bit 1 is set the second
     * item is enabled, etc. If a bit is cleared the related item is
     * disabled. Its initial value is 0xffffffff.
     */
    unsigned long enableMask;
    /**
     * This integer contains the current selected item.
     *
     * If its value is 0 the first item is selected, if its value is 1 the
     * second item is selected, etc. Its initial value is 0.
     */
    int sel;
    /**
     * This object contains all the item captions.
     */
    TStringCollection *strings;
private:
    int column( int item );
    int findSel( TPoint p );
    int row( int item );
    void moveSel(int, int);
    virtual const char *streamableName() const
        { return name; }
protected:
    /**
     * Constructor.
     *
     * Used to recover the view from a stream.
     */
    TCluster( StreamableInit );
    /**
     * Used to store the view in a stream.
     */
    virtual void write( opstream& os );
    /**
     * Used to recover the view from a stream.
     */
    virtual void *read( ipstream& is );
public:
    /**
     * Returns True if the specified item is enabled.
     *
     * Parameter `item' specifies which item to check. 0 is the first item,
     * 1 is the second item, etc.
     * @see TCluster::enableMask
     */
    Boolean buttonState(int item);
    static const char * const name;
    /**
     * Creates a new TCluster view.
     *
     * Used to recover the view from a stream.
     */
    static TStreamable *build();
};

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

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

#endif  // Uses_TCluster


/* ---------------------------------------------------------------------- */
/*      class TRadioButtons                                               */
/*                                                                        */
/*      Palette layout                                                    */
/*        1 = Normal text                                                 */
/*        2 = Selected text                                               */
/*        3 = Normal shortcut                                             */
/*        4 = Selected shortcut                                           */
/* ---------------------------------------------------------------------- */


#if defined( Uses_TRadioButtons ) && !defined( __TRadioButtons )
#define __TRadioButtons

class TRect;
class TSItem;

/**
 * This view implements a cluster of radio buttons.
 *
 * Only one button is allowed to be pressed at any time.
 * @see TCheckBoxes
 * @see TCluster
 * @short A cluster of radio buttons
 */
class TRadioButtons : public TCluster
{
public:
    /**
     * Constructor.
     *
     * `bounds' is the bounding rectangle of the view. `aStrings' points to
     * a list of TSItem objects, one for each radio button. Every TSItem
     * object stores the caption of the related radio button. TRadioButtons
     * handles a maximum of 32 radio buttons.
     * @see TSItem
     */
    TRadioButtons( const TRect& bounds, TSItem *aStrings );
    /**
     * Draws the view.
     *
     * Redefines TView::draw().
     * @see TView::draw
     */
    virtual void draw();
    /**
     * Returns True if the specified radio button is pressed.
     *
     * Integer `item' specifies which radio button to check. 0 is the first
     * radio button, 1 is the second radio button, etc. Redefines
     * TCluster::mark().
     * @see TCluster::mark
     */
    virtual Boolean mark( int item );
    /**
     * Called whenever the user moves the selection to another radio button.
     *
     * Sets `value' to `item'. This will press `item' radio button and release
     * the previously pressed radio button.
     * @see TCluster::movedTo
     */
    virtual void movedTo( int item );
    /**
     * Called to press another radio button.
     *
     * Integer `item' specifies which radio button to press. The previous
     * radio button is released. 0 is the first radio button, 1 the second
     * radio button, etc. Redefines TCluster::press().
     * @see TCluster::press
     */
    virtual void press( int item );
    /**
     * Writes the data record of this view.
     *
     * This method calls TCluster::setData() and after sets `sel' to `value'.
     * This will move the selection on the currently pressed radio button.
     * @see TCluster::setData
     */
    virtual void setData( void *rec );
private:
    static const char * button;
    virtual const char *streamableName() const
        { return name; }
protected:
    /**
     * Constructor.
     *
     * Used to recover the view from a stream.
     */
    TRadioButtons( StreamableInit );
public:
    static const char * const name;
    /**
     * Creates a new TRadioButtons view.
     *
     * Used to recover the view from a stream.
     */
    static TStreamable *build();
};

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

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

inline TRadioButtons::TRadioButtons( const TRect& bounds, TSItem *aStrings ) :
    TCluster( bounds, aStrings )
{
}

#endif  // Uses_TRadioButtons


/* ---------------------------------------------------------------------- */
/*      TCheckBoxes                                                       */
/*                                                                        */
/*      Palette layout                                                    */
/*        1 = Normal text                                                 */
/*        2 = Selected text                                               */
/*        3 = Normal shortcut                                             */
/*        4 = Selected shortcut                                           */
/* ---------------------------------------------------------------------- */

#if defined( Uses_TCheckBoxes ) && !defined( __TCheckBoxes )
#define __TCheckBoxes

class TRect;
class TSItem;

/**
 * This view implements a cluster of check boxes.
 *
 * Each check box can be independently checked or unchecked.
 * @see TCluster
 * @see TRadioButtons
 * @short A cluster of check boxes
 */
class TCheckBoxes : public TCluster
{
public:
    /**
     * Constructor.
     *
     * `bounds' is the bounding rectangle of the view. `aStrings' points to
     * a list of TSItem objects, one for each check box. Every TSItem object
     * stores the caption of the related check box. TCheckBoxes handles a
     * maximum of 32 check boxes.
     * @see TSItem
     */
    TCheckBoxes( const TRect& bounds, TSItem *aStrings);
    /**
     * Draws the view.
     *
     * Redefines TView::draw().
     * @see TView::draw
     */
    virtual void draw();
    /**
     * Returns True if the specified check box is checked.
     *
     * Integer `item' specifies which check box to check. 0 is the first
     * check box, 1 the second check box, etc. Redefines TCluster::mark().
     * @see TCluster::mark
     */
    virtual Boolean mark( int item );
    /**
     * Called to toggle the state of a checkbox.
     *
     * Integer `item' specifies which check box to toggle. 0 is the first
     * check box, 1 is the second check box, etc. Redefines TCluster::press().
     * @see TCluster::press
     */
    virtual void press( int item );
private:
    static const char * button;
    virtual const char *streamableName() const
        { return name; }
protected:
    /**
     * Constructor.
     *
     * Used to recover the view from a stream.
     */
    TCheckBoxes( StreamableInit );
public:
    static const char * const name;
    /**
     * Creates a new TCheckBoxes view.
     *
     * Used to recover the view from a stream.
     */
    static TStreamable *build();
};

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

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

inline TCheckBoxes::TCheckBoxes( const TRect& bounds, TSItem *aStrings) :
    TCluster( bounds, aStrings )
{
}

#endif  // Uses_TCheckBoxes


#if defined( Uses_TMultiCheckBoxes ) && !defined( __TMultiCheckBoxes )
#define __TMultiCheckBoxes

const unsigned short cfOneBit       = 0x0101,
                     cfTwoBits      = 0x0203,
                     cfFourBits     = 0x040F,
                     cfEightBits    = 0x08FF;

/* ---------------------------------------------------------------------- */
/*      TMultiCheckBoxes                                                  */
/*                                                                        */
/*      Palette layout                                                    */
/*        1 = Normal text                                                 */
/*        2 = Selected text                                               */
/*        3 = Normal shortcut                                             */
/*        4 = Selected shortcut                                           */
/* ---------------------------------------------------------------------- */

class TRect;
class TSItem;

class TMultiCheckBoxes : public TCluster
{
public:
    TMultiCheckBoxes(TRect&, TSItem*, uchar, ushort, const char*);
    ~TMultiCheckBoxes();
    virtual ushort dataSize();
    virtual void draw();
    virtual void getData(void *);
    virtual uchar multiMark(int item);
    virtual void press( int item );
    virtual void setData(void*);

private:
    uchar selRange;
    ushort flags;
    char* states;
#ifndef __UNPATCHED
    virtual const char *streamableName() const
        { return name; }
#endif

protected:

    TMultiCheckBoxes( 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, TMultiCheckBoxes& cl )
    { return is >> (TStreamable&)cl; }
inline ipstream& operator >> ( ipstream& is, TMultiCheckBoxes*& cl )
    { return is >> (void *&)cl; }

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

#endif


#if defined( Uses_TListBox ) && !defined( __TListBox )
#define __TListBox

class TRect;
class TScrollBar;
class TCollection;

struct TListBoxRec
{
    TCollection *items;
    ushort selection;
};

class TListBox : public TListViewer
{

public:

    TListBox( const TRect& bounds, ushort aNumCols, TScrollBar *aScrollBar );
    ~TListBox();

    virtual ushort dataSize();
    virtual void getData( void *rec );
    virtual void getText( char *dest, short item, short maxLen );
    virtual void newList( TCollection *aList );
    virtual void setData( void *rec );

    TCollection *list();

private:

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

protected:

    TCollection *items;

    TListBox( 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, TListBox& cl )
    { return is >> (TStreamable&)cl; }
inline ipstream& operator >> ( ipstream& is, TListBox*& cl )
    { return is >> (void *&)cl; }

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

inline TCollection *TListBox::list()
{
    return items;
}

#endif  // Uses_TListBox


/* ---------------------------------------------------------------------- */
/*      class TStaticText                                                 */
/*                                                                        */
/*      Palette layout                                                    */
/*        1 = Text                                                        */
/* ---------------------------------------------------------------------- */

#if defined( Uses_TStaticText ) && !defined( __TStaticText )
#define __TStaticText

class TRect;

/**
 * Used to show static text in a window.
 *
 * This class stores a copy of the string. Check TParamText if you want to
 * show also dynamic text.
 * @see TParamText
 * @short Used to show static text in a window
 */
class TStaticText : public TView
{
public:
    /**
     * Constructor.
     *
     * `bounds' is the bounding rectangle of the static text. `aText' is a
     * pointer to the string to show.
     */
    TStaticText( const TRect& bounds, const char *aText );
    /**
     * Destructor.
     */
    ~TStaticText();
    /**
     * Draws the static text.
     */
    virtual void draw();
    /**
     * Returns a reference to the static text palette.
     */
    virtual TPalette& getPalette() const;
    /**
     * Writes the string at address `s'.
     */
    virtual void getText( char *s );
protected:
    /**
     * Stores the pointer to the string to show.
     */
    const char *text;
private:
    virtual const char *streamableName() const
        { return name; }
protected:
    /**
     * Constructor.
     *
     * Used to recover the view from a stream.
     */
    TStaticText( StreamableInit );
    /**
     * Used to store the view in a stream.
     */
    virtual void write( opstream& os );
    /**
     * Used to recover the view from a stream.
     */
    virtual void *read( ipstream& is );
public:
    static const char * const name;
    /**
     * Creates a new TStaticText.
     *
     * Used to recover the view from a stream.
     */
    static TStreamable *build();
};

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

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

#endif  // Uses_TStaticText


/* ---------------------------------------------------------------------- */
/*      class TParamText                                                  */
/*                                                                        */
/*      Palette layout                                                    */
/*        1 = Text                                                        */
/* ---------------------------------------------------------------------- */

#if defined( Uses_TParamText ) && !defined( __TParamText )
#define __TParamText

class TRect;

/**
 * Used to show dynamic text in a window.
 *
 * This class stores a copy of the string. Check TStaticText if you want to
 * show only static text.
 * @see TStaticText
 * @short Used to show dynamic text in a window
 */
class TParamText : public TStaticText
{
public:
    /**
     * Constructor.
     *
     * `bounds' is the bounding rectangle of the view. The string is initially
     * empty.
     */
    TParamText( const TRect& bounds );
    /**
     * Destructor.
     */
    ~TParamText();
    /**
     * Writes the string at address `s'.
     */
    virtual void getText( char *s );
    /**
     * Sets a new value for the string.
     *
     * Since this method calls vsprintf(), you can use a printf-like style for
     * its arguments.
     */
    virtual void setText( char *fmt, ... );
    /**
     * Returns the length of the string expressed in characters.
     */
    virtual int getTextLen();
protected:
    /**
     * Stores the pointer to the string.
     */
    char *str;
private:
    virtual const char *streamableName() const
        { return name; }
protected:
    /**
     * Constructor.
     *
     * Used to recover the view from a stream.
     */
    TParamText( StreamableInit );
#ifndef __UNPATCHED
    /**
     * Used to store the view in a stream.
     */
    virtual void write( opstream& os );
    /**
     * Used to recover the view from a stream.
     */
    virtual void *read( ipstream& is );
#endif
public:
    static const char * const name;
    /**
     * Creates a new TParamText.
     *
     * Used to recover the view from a stream.
     */
    static TStreamable *build();
};

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

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

#endif  // Uses_TParamText


/* ---------------------------------------------------------------------- */
/*      class TLabel                                                      */
/*                                                                        */
/*      Palette layout                                                    */
/*        1 = Normal text                                                 */
/*        2 = Selected text                                               */
/*        3 = Normal shortcut                                             */
/*        4 = Selected shortcut                                           */
/* ---------------------------------------------------------------------- */

#if defined( Uses_TLabel ) && !defined( __TLabel )
#define __TLabel

class TRect;
class TEvent;
class TView;

/**
 * Used to attach a label to a given view.
 *
 * Useful mainly with list boxes, check boxes and radio buttons, since they
 * don't have a default caption.
 * @see TCheckBoxes
 * @see TListBox
 * @see TRadioButtons
 * @short Attach a label to a view
 */
class TLabel : public TStaticText
{
public:
    /**
     * Constructor.
     *
     * `bounds' is the bounding rectangle of the view. `aText' is the caption
     * to show. `aLink' is a pointer to the view which will be focused when
     * the user selects this label.
     */
    TLabel( const TRect& bounds, const char *aText, TView *aLink );
    /**
     * Draws the view.
     */
    virtual void draw();
    /**
     * Returns a reference to the label palette.
     */
    virtual TPalette& getPalette() const;
    /**
     * Handles TLabel events.
     */
    virtual void handleEvent( TEvent& event );
    /**
     * Releases TLabel resources.
     *
     * This method releases all the resources allocated by the TLabel. It sets
     * pointer `link' to 0 and then calls TStaticText::shutDown(). Since
     * TStaticText::shutDown() is not implemented, TView::shutDown() will be
     * called instead.
     * @see TView::shutDown
     */
    virtual void shutDown();
protected:
    /**
     * This is a pointer to the view to focus when the user selects this
     * label.
     */
    TView *link;
    /**
     * This variable is used to redraw the label with bright colors if the
     * view pointed by `link' is currently focused.
     */
    Boolean light;
private:
    virtual const char *streamableName() const
        { return name; }
    void focusLink(TEvent&);
protected:
    /**
     * Constructor.
     *
     * Used to recover the view from a stream.
     */
    TLabel( StreamableInit );
    /**
     * Used to store the view in a stream.
     */
    virtual void write( opstream& os );
    /**
     * Used to recover the view from a stream.
     */
    virtual void *read( ipstream& is );
public:
    static const char * const name;
    /**
     * Creates a new TLabel.
     *
     * Used to recover the view from a stream.
     */
    static TStreamable *build();
};

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

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

#endif  // Uses_TLabel


/* ---------------------------------------------------------------------- */
/*      class THistoryViewer                                              */
/*                                                                        */
/*      Palette layout                                                    */
/*        1 = Active                                                      */
/*        2 = Inactive                                                    */
/*        3 = Focused                                                     */
/*        4 = Selected                                                    */
/*        5 = Divider                                                     */
/* ---------------------------------------------------------------------- */

#if defined( Uses_THistoryViewer ) && !defined( __THistoryViewer )
#define __THistoryViewer

class TRect;
class TScrollBar;

class THistoryViewer : public TListViewer
{

public:

    THistoryViewer( const TRect& bounds,
                    TScrollBar *aHScrollBar,
                    TScrollBar *aVScrollBar,
                    ushort aHistoryId
                  );

    virtual TPalette& getPalette() const;
    virtual void getText( char *dest, short item, short maxLen );
    virtual void handleEvent( TEvent& event );
    int historyWidth();

protected:

    ushort historyId;

};

#endif  // Uses_THistoryViewer

#if defined( Uses_THistoryWindow ) && !defined( __THistoryWindow )
#define __THistoryWindow

class TListViewer;
class TRect;
class TWindow;
class TInputLine;

class THistInit
{

public:

    THistInit( TListViewer *(*cListViewer)( TRect, TWindow *, ushort ) );

protected:

    TListViewer *(*createListViewer)( TRect, TWindow *, ushort );

};

/* ---------------------------------------------------------------------- */
/*      THistoryWindow                                                    */
/*                                                                        */
/*      Palette layout                                                    */
/*        1 = Frame passive                                               */
/*        2 = Frame active                                                */
/*        3 = Frame icon                                                  */
/*        4 = ScrollBar page area                                         */
/*        5 = ScrollBar controls                                          */
/*        6 = HistoryViewer normal text                                   */
/*        7 = HistoryViewer selected text                                 */
/* ---------------------------------------------------------------------- */

class THistoryWindow : public TWindow, public virtual THistInit
{

public:

    THistoryWindow( const TRect& bounds, ushort historyId );

    virtual TPalette& getPalette() const;
    virtual void getSelection( char *dest );
    static TListViewer *initViewer( TRect, TWindow *, ushort );

protected:

    TListViewer *viewer;
};

#endif  // Uses_THistoryWindow

#if defined( Uses_THistory ) && !defined( __THistory )
#define __THistory

class TRect;
class TInputLine;
class TEvent;
class THistoryWindow;

class THistory : public TView
{

public:

    THistory( const TRect& bounds, TInputLine *aLink, ushort aHistoryId );

    virtual void draw();
    virtual TPalette& getPalette() const;
    virtual void handleEvent( TEvent& event );
    virtual THistoryWindow *initHistoryWindow( const TRect& bounds );
    virtual void recordHistory(const char *s);
    virtual void shutDown();
    static const char * icon;

protected:

    TInputLine *link;
    ushort historyId;

private:

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

protected:

    THistory( 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, THistory& cl )
    { return is >> (TStreamable&)cl; }
inline ipstream& operator >> ( ipstream& is, THistory*& cl )
    { return is >> (void *&)cl; }

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

#endif  // Uses_THistory

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