/*
* colorsel.h
*
* Turbo Vision - Version 2.0
*
* Copyright (c) 1994 by Borland International
* All Rights Reserved.
*
* Modified by Sergio Sigala <ssigala@globalnet.it>
*/
#if !defined( __COLOR_COMMAND_CODES )
#define __COLOR_COMMAND_CODES
const
int cmColorForegroundChanged = 71,
cmColorBackgroundChanged = 72,
cmColorSet = 73,
cmNewColorItem = 74,
cmNewColorIndex = 75,
cmSaveColorIndex = 76;
#endif // __COLOR_COMMAND_CODES
class TColorItem;
class TColorGroup;
TColorItem& operator + ( TColorItem& i1, TColorItem& i2 );
TColorGroup& operator + ( TColorGroup& g, TColorItem& i );
TColorGroup& operator + ( TColorGroup& g1, TColorGroup& g2 );
#if defined( Uses_TColorItem ) && !defined( __TColorItem )
#define __TColorItem
class TColorGroup;
/**
* Stores informations about a color item.
* @see TColorGroup
* @see TColorDialog
* @short Informations about a color item
*/
class TColorItem
{
public:
/**
* Constructor.
*
* `nm' is a pointer to the name of the color item. A local copy of the
* string is created. `idx' is the color index. `nxt' is a pointer to the
* next color item (its default value is 0).
*
* See file `demo/tvdemo2.cc' for an example.
*/
TColorItem( const char *nm, uchar idx, TColorItem *nxt = 0 );
/**
* Destructor.
*/
virtual ~TColorItem();
/**
* The name of the color item.
*/
const char *name;
/**
* The index of the color item.
*/
uchar index;
/**
* A pointer to the next color item.
*/
TColorItem *next;
/**
* Inserts color item `i' in color group `g'.
* @see TColorGroup
*/
friend TColorGroup& operator + ( TColorGroup& g, TColorItem& i );
/**
* Inserts another color item after this one by changing the `next'
* pointer.
*/
friend TColorItem& operator + ( TColorItem& i1, TColorItem& i2 );
};
#endif // Uses_TColorItem
#if defined( Uses_TColorGroup ) && !defined( __TColorGroup )
#define __TColorGroup
class TColorItem;
/**
* Stores a set of color items.
* @see TColorItem
* @see TColorDialog
* @short Stores a set of color items
*/
class TColorGroup
{
public:
/**
* Constructor.
*
* `nm' is a pointer to the name of the color group. A local copy of the
* string is created. `itm' is a pointer to the first color item of the
* color group (its default value is 0). `nxt' is a pointer to the next
* color group (its default value is 0).
*
* See file `demo/tvdemo2.cc' for an example.
*/
TColorGroup( const char *nm, TColorItem *itm = 0, TColorGroup *nxt = 0 );
/**
* Destructor.
*/
virtual ~TColorGroup();
/**
* The name of the color group.
*/
const char *name;
/**
* The start index of the color group.
*/
uchar index;
/**
* A pointer to the first color item in this color group.
*/
TColorItem *items;
/**
* A pointer to the next color group.
*/
TColorGroup *next;
/**
* Inserts color item `i' in color group `g'.
* @see TColorItem
*/
friend TColorGroup& operator + ( TColorGroup& g, TColorItem& i);
/**
* Inserts another color group after this one by changing the `next'
* pointer.
* @see TColorItem
*/
friend TColorGroup& operator + ( TColorGroup& g1, TColorGroup& g2 );
};
class TColorIndex
{
public:
uchar groupIndex;
uchar colorSize;
uchar colorIndex[256];
};
#endif // Uses_TColorGroup
#if defined( Uses_TColorSelector ) && !defined( __TColorSelector )
#define __TColorSelector
class TRect;
class TEvent;
/**
* Displays a color selector. This view may be used to change the standard
* color settings of TVision.
* @short A color selector
*/
class TColorSelector : public TView
{
public:
/**
* This view can handle two sets of colors: the 8 background colors or the
* 16 foreground colors.
*/
enum ColorSel { csBackground, csForeground };
/**
* Constructor.
*
* `Bounds' is the bounding rectangle of the view. `ASelType' may be one
* of the following values:
*
* csBackground - show the 8 background colors
*
* csForeground - show the 16 foreground colors
*/
TColorSelector( const TRect& Bounds, ColorSel ASelType );
/**
* Draws the color selector.
*/
virtual void draw();
/**
* Handles TColorSelector events.
*/
virtual void handleEvent( TEvent& event );
/**
* This character is used to mark the current color.
*/
static char icon;
protected:
/**
* This value specifies the current color.
*/
uchar color;
/**
* Specifies if the view shows the 8 background colors or the 16
* foreground colors.
*/
ColorSel selType;
private:
void colorChanged();
virtual const char *streamableName() const
{ return name; }
protected:
/**
* Constructor.
*
* Used to recover the view from a stream.
*/
TColorSelector( 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 TColorSelector.
*
* Used to recover the view from a stream.
*/
static TStreamable *build();
};
inline ipstream& operator >> ( ipstream& is, TColorSelector& cl )
{ return is >> (TStreamable&)cl; }
inline ipstream& operator >> ( ipstream& is, TColorSelector*& cl )
{ return is >> (void *&)cl; }
inline opstream& operator << ( opstream& os, TColorSelector& cl )
{ return os << (TStreamable&)cl; }
inline opstream& operator << ( opstream& os, TColorSelector* cl )
{ return os << (TStreamable *)cl; }
#endif // Uses_TColorSelector
#if defined( Uses_TMonoSelector ) && !defined( __TMonoSelector )
#define __TMonoSelector
class TRect;
class TEvent;
/**
* Displays a monochromatic color selector. This view may be used to change
* the standard color settings of TVision.
* @short A monochromatic color selector
*/
class TMonoSelector : public TCluster
{
public:
/**
* Constructor.
*
* `bounds' is the bounding rectangle of the view.
* @see TCluster
*/
TMonoSelector( const TRect& bounds );
/**
* Draws the monochromatic color selector.
*/
virtual void draw();
/**
* Handles TMonoSelector events.
*/
virtual void handleEvent( TEvent& event );
/**
* YYY
*/
virtual Boolean mark( int item );
/**
* YYY
*/
void newColor();
/**
* YYY
*/
virtual void press( int item );
/**
* YYY
*/
void movedTo( int item );
private:
static const char * button;
static const char * normal;
static const char * highlight;
static const char * underline;
static const char * inverse;
virtual const char *streamableName() const
{ return name; }
protected:
/**
* Constructor.
*
* Used to recover the view from a stream.
*/
TMonoSelector( StreamableInit );
public:
static const char * const name;
/**
* Creates a new TMonoSelector.
*
* Used to recover the view from a stream.
*/
static TStreamable *build();
};
inline ipstream& operator >> ( ipstream& is, TMonoSelector& cl )
{ return is >> (TStreamable&)cl; }
inline ipstream& operator >> ( ipstream& is, TMonoSelector*& cl )
{ return is >> (void *&)cl; }
inline opstream& operator << ( opstream& os, TMonoSelector& cl )
{ return os << (TStreamable&)cl; }
inline opstream& operator << ( opstream& os, TMonoSelector* cl )
{ return os << (TStreamable *)cl; }
#endif // Uses_TMonoSelector
#if defined( Uses_TColorDisplay ) && !defined( __TColorDisplay )
#define __TColorDisplay
class TRect;
class TEvent;
/**
* Implements a test box used to display the current selected color.
* @short A color test box
*/
class TColorDisplay : public TView
{
public:
/**
* Constructor.
*
* `bounds' is the bounding rectangle of the view. `aText' is the string
* printed in the view.
*/
TColorDisplay( const TRect& bounds, const char *aText );
/**
* Destructor.
*/
virtual ~TColorDisplay();
/**
* Draws the test box.
*/
virtual void draw();
/**
* Handles TColorDisplay events.
*/
virtual void handleEvent( TEvent& event );
/**
* Change the currently displayed color.
*/
virtual void setColor( uchar *aColor );
protected:
/**
* Stores the current color.
*/
uchar *color;
/**
* Stores a pointer to the displayed text.
*/
const char *text;
private:
virtual const char *streamableName() const
{ return name; }
protected:
/**
* Constructor.
*
* Used to recover the view from a stream.
*/
TColorDisplay( 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 TColorDisplay.
*
* Used to recover the view from a stream.
*/
static TStreamable *build();
};
inline ipstream& operator >> ( ipstream& is, TColorDisplay& cl )
{ return is >> (TStreamable&)cl; }
inline ipstream& operator >> ( ipstream& is, TColorDisplay*& cl )
{ return is >> (void *&)cl; }
inline opstream& operator << ( opstream& os, TColorDisplay& cl )
{ return os << (TStreamable&)cl; }
inline opstream& operator << ( opstream& os, TColorDisplay* cl )
{ return os << (TStreamable *)cl; }
#endif // Uses_TColorDisplay
#if defined( Uses_TColorGroupList ) && !defined( __TColorGroupList )
#define __TColorGroupList
class TRect;
class TScrollBar;
class TColorGroup;
class TColorItem;
class TColorGroupList : public TListViewer
{
public:
TColorGroupList( const TRect& bounds,
TScrollBar *aScrollBar,
TColorGroup *aGroups
);
virtual ~TColorGroupList();
virtual void focusItem( short item );
virtual void getText( char *dest, short item, short maxLen );
virtual void handleEvent(TEvent&);
protected:
TColorGroup *groups;
private:
virtual const char *streamableName() const
{ return name; }
static void writeItems( opstream&, TColorItem * );
static void writeGroups( opstream&, TColorGroup * );
static TColorItem *readItems( ipstream& );
static TColorGroup *readGroups( ipstream& );
protected:
TColorGroupList( StreamableInit );
virtual void write( opstream& os );
virtual void *read( ipstream& is );
public:
void setGroupIndex(uchar groupNum, uchar itemNum);
TColorGroup* getGroup(uchar groupNum);
uchar getGroupIndex(uchar groupNum);
uchar getNumGroups();
static const char * const name;
static TStreamable *build();
};
inline ipstream& operator >> ( ipstream& is, TColorGroupList& cl )
{ return is >> (TStreamable&)cl; }
inline ipstream& operator >> ( ipstream& is, TColorGroupList*& cl )
{ return is >> (void *&)cl; }
inline opstream& operator << ( opstream& os, TColorGroupList& cl )
{ return os << (TStreamable&)cl; }
inline opstream& operator << ( opstream& os, TColorGroupList* cl )
{ return os << (TStreamable *)cl; }
#endif // Uses_TColorGroupList
#if defined( Uses_TColorItemList ) && !defined( __TColorItemList )
#define __TColorItemList
class TRect;
class TScrollBar;
class TColorItem;
class TEvent;
class TColorItemList : public TListViewer
{
public:
TColorItemList( const TRect& bounds,
TScrollBar *aScrollBar,
TColorItem *aItems
);
virtual void focusItem( short item );
virtual void getText( char *dest, short item, short maxLen );
virtual void handleEvent( TEvent& event );
protected:
TColorItem *items;
private:
virtual const char *streamableName() const
{ return name; }
protected:
TColorItemList( StreamableInit );
public:
static const char * const name;
static TStreamable *build();
};
inline ipstream& operator >> ( ipstream& is, TColorItemList& cl )
{ return is >> (TStreamable&)cl; }
inline ipstream& operator >> ( ipstream& is, TColorItemList*& cl )
{ return is >> (void *&)cl; }
inline opstream& operator << ( opstream& os, TColorItemList& cl )
{ return os << (TStreamable&)cl; }
inline opstream& operator << ( opstream& os, TColorItemList* cl )
{ return os << (TStreamable *)cl; }
#endif // Uses_TColorItemList
#if defined( Uses_TColorDialog ) && !defined( __TColorDialog )
#define __TColorDialog
class TColorGroup;
class TEvent;
class TColorDisplay;
class TColorGroupList;
class TLabel;
class TColorSelector;
class TMonoSelector;
class TPalette;
/**
* This class implements a dialog used to change the standard color palette.
* @see TDialog
* @short Change the standard palette
*/
class TColorDialog : public TDialog
{
public:
/**
* Constructor.
*
* `aPalette' is a pointer to the initial palette to be modified. This
* class creates a local copy of the initial palette, so the initial
* palette is never modified. You may safely leave this field to 0 and set
* the palette with a subsequent call to setData(). `aGroups' is a pointer
* to a cluster of objects which specifies all the items in the palette.
*
* See file `demo/tvdemo2.cc' for an example.
* @see TColorDialog::setData
*/
TColorDialog( TPalette *aPalette, TColorGroup *aGroups );
/**
* Destructor.
*
* Deletes the local copy of the palette.
*/
~TColorDialog();
/**
* Returns the size of the palette, expressed in bytes.
*/
virtual ushort dataSize();
/**
* Reads the data record of this dialog.
*
* `rec' should point to a TPalette object. Its contents will be
* overwritten by the contents of this object.
*/
virtual void getData( void *rec );
/**
* Handles TColorDialog events.
*/
virtual void handleEvent( TEvent& event );
/**
* Writes the data record of this view.
*
* `rec' should point to a TPalette object.
*/
virtual void setData( void *rec);
/**
* Is a pointer to the local palette.
*/
TPalette *pal;
protected:
/**
* YYY
*/
TColorDisplay *display;
/**
* YYY
*/
TColorGroupList *groups;
/**
* YYY
*/
TLabel *forLabel;
/**
* YYY
*/
TColorSelector *forSel;
/**
* YYY
*/
TLabel *bakLabel;
/**
* YYY
*/
TColorSelector *bakSel;
/**
* YYY
*/
TLabel *monoLabel;
/**
* YYY
*/
TMonoSelector *monoSel;
/**
* YYY
*/
uchar groupIndex;
private:
static const char * colors;
static const char * groupText;
static const char * itemText;
static const char * forText;
static const char * bakText;
static const char * textText;
static const char * colorText;
static const char * okText;
static const char * cancelText;
virtual const char *streamableName() const
{ return name; }
protected:
/**
* Constructor.
*
* Used to recover the dialog from a stream.
*/
TColorDialog( StreamableInit );
/**
* Used to store the dialog in a stream.
*/
virtual void write( opstream& os );
/**
* Used to recover the dialog from a stream.
*/
virtual void *read( ipstream& is );
public:
/**
* YYY
*/
void getIndexes(TColorIndex*&);
/**
* YYY
*/
void setIndexes(TColorIndex*&);
static const char * const name;
/**
* YYY
*/
static TStreamable *build();
};
inline ipstream& operator >> ( ipstream& is, TColorDialog& cl )
{ return is >> (TStreamable&)cl; }
inline ipstream& operator >> ( ipstream& is, TColorDialog*& cl )
{ return is >> (void *&)cl; }
inline opstream& operator << ( opstream& os, TColorDialog& cl )
{ return os << (TStreamable&)cl; }
inline opstream& operator << ( opstream& os, TColorDialog* cl )
{ return os << (TStreamable *)cl; }
#endif // TColorDialog
Documentation generated by sergio@athena.milk.it on Wed Feb 10 22:11:47 CET 1999