#ifndef GUICLSS
#define GUICLSS
// ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
// º NPSGUI.LIB Ç¿
// º GUICLS.CPP º³
// º Copyright 1993, Nearly Perfect Software. º³
// º All rights reserved º³
// º º³
// º This file is included in NPSGUI as a set of º³
// º middle-level classes for use by the library º³
// º user. It is intended as a programming example º³
// º and is included as source code. It may be º³
// º modified as needed and used in any application º³
// º that uses NPSGUI, as long as this comment º³
// º block is included. º³
// º º³
// º þ Written by Brad Broerman º³
// º þ Last Modified: 02/14/95 º³
// º þ Revision 2.5 º³
// ÈÍÑÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ³
// ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
class radiopanel : public panel
{
// This class is a panel with multiple rbuttons on it, along with
// text. it allows the selection of one parameter at a time, sort of line
// the buttons on a radio.
//
// Please be aware of a bug I have discovered... When you select a button
// with the mouse, either using selectbtn(btnhit(), or using checkforevent(),
// the mouse driver will 'stick', and it will report that the buttons are down,
// when actually, they may not be.
//
// It looks somewhat like this: --------------------
// | Header text | <-- The header, centered.
// | |
// This button is selected--> | 0 Item 1 | <-- The buttons text.
// But all the others aren't. | O Item 2 |
// | O Item 3 |
// | O Item 4 |
// --------------------
//
// Parameters: X,Y,W,H : Same as in the Panel class.
// Hdr : The name of the radiopanel.
// list : A string containing a comma seperated list of elements, as above.
// k : The 'keep track of background' flag.
// c : A color parameter.
// no : A number corresponding to a button, starting with 1.
//
// Preconditions: X,Y,W,H: Same as Panel.
// Hdr : Must contain a valid string.
// List : Mist consist of at least 1 item. and no more than 20.
// k : Same as Panel.
// c : Must be a valid color number (0-16)
// no : Must be 0 < no <= Number of items.
//
//
rbutton *Buttons[20]; // Pointers to the buttons.
char *Header; // The header.
char *Items[20]; // The list of text items for the buttons.
int NumItems; // The number of items.
int TextClr; // The text color.
int BtnSel; // The current selected button.
public:
radiopanel(int x, int y, int w, int h, int d, char *Hdr, char *list, int k);
~radiopanel();
void setbtnclr(int c); // Changes the radio buttons color.
void settextclr(int c); // Changes the text color.
void show(); // Displays the radiopanel.
void hide(); // Hides teh radiopanel.
int btnhit(); // Returns the number corresponding to the button the cursor is on.
void selectbtn(int no); // Selects a button.
int btnselected(); // Returns the number of the button selected.
void btnclear(); // Clears all buttons.
int checkforevent(); // Waits for a button to be selected, or escape key.
// Uses mouse, and up/down arrow keys.
// Returns TRUE if button selected, false if none.
};
struct attr
{
int Fgd : 4;
int Bkg : 4;
};
class textplane : public gbase
{
// This class allows the input and output of text to graphics text windows
// in a way that is similar to using cin and cout in the text modes. It also
// emulates ANSI and VT100 displays (decodes the escape sequences).
//
// Parameters: X,Y,W,H : Same as the other classes.
// tc : The initial color of the text.
// bc : The default, and initial background color.
//
// Preconditions: X,Y,W,H: Same as in Panel.
// tc : Can be any valid color (0 - 16)
// bc : Can be any color from BLACK (0) to LIGHTGRAY(7);
//
// On Input, the insertioin routines for long, and double are undefined
// if an overflow occurs, or if invalid inputs are entered. Also, NO overflow
// checking is used for string input. YOU MUST ENSURE THAT AN OVERFLOW DOES NOT OCCUR.
//
//
char *Buffer; // Graphics buffer used in hiding and restoring display.
int CsrX,CsrY,// The X and Y coordinates of the next character.
OldX,OldY,// The old position of the cursor.
DefBkgClr,// The default background color.
BkgClr, // The current background color.
TxtClr, // The current text color.
Bold, // The Bold or normal flag.
Echo, // echo the entered characrter or not.
ShowCsr, // Show the cursor or not.
CsrShwn, // Tells if the cursor is shown or not.
SavX,SavY,// The stored coordinates of the cursor (for ANSI & VT100).
TermEm, // The terminal emulation used.
isShown; // Wether or not the plane is being shown.
char STR[20]; // Collection buffer for escape sequences, and printable strings.
char *TxtBuf; // Storage for the text buffer.
attr *AtrBuf; // Storage for the text attribute buffer.
unsigned SBBSize, // The size of the scrollback buffer.
CurScrn; // The offset into the buffer that the current screen starts.
int SIndex, // Index for STR.
REscSeq; // Flag that indicates an escape sequence is being compiled.
void ANSI_Decode(char c); // Decodes ANSI escape sequences.
void VT100_Decode(char c); // Decodes VT100 escape sequences.
void Print_Char(char c); // Displays the character on the screen.
void move_csr(void); // moves the cursor to the new x & y.
public:
textplane (int x, int y, int w, int h, int tc = 15, int bc=0);
~textplane();
void show(); // Display a textplane.
void hide(); // Prepares a textplane to be hidden.
void drawscrn(char far *B,attr far *A,int L); // Re-draws the screen, starting at the top, and going down L lines.
int setbuffsize(unsigned); // Resets the size of the scrollback buffer.
void settxtclr(int c); // Set the text color.
void setbkgclr(int c); // Set the background color.
void gotoxy(int x, int y); // Move the cursor to x,y (in pixels).
void settermem(int t); // Sets the terminal emulation. (ANSI, VT100, ASCII)
void setcsr(int F); // Turns the cursor on & off (1,0).
void clearwin(void); // Clears the textplane to the background color.
char peek(void); // Check the next keyboard character without extracting it.
char *gettxt(void); // returns a copy of the screen text buffer.
char *getatr(void); // returns a copy of the screen attribute buffer.
unsigned getscrnptr(void); // returns the current screen offset in the text buffer.
unsigned getbufsize(void); // returns the size of the screen text buffers.
textplane &operator << (char &c); // The formatted inserters.
textplane &operator << (char *c);
textplane &operator << (int &I);
textplane &operator << (long &L);
textplane &operator << (double &D);
textplane &operator >> (char &c); // The formatted extractors.
textplane &operator >> (char *c);
textplane &operator >> (int &I);
textplane &operator >> (long &L);
textplane &operator >> (double &D);
textplane &setecho() // Turns on character echoing.
{ Echo = 1; return *this; }
textplane &clrecho() // Turns off character echoing.
{ Echo = 0; return *this; }
};
class selectbar : public instrn
{
// The selection bar class is an instrn class with a button that pulls down a
// list of options that can be selected with the mouse or the keyboard. To use with
// a keyboard, the down arrow pulls down the list, and then the item can be highlighted
// with the arrow keys. To select, press [Enter] and to quit, press [Esc]. The button
// is placed on the right of the instrn, and the X,Y,Width, and Height of the components
// must be chosen so that the object is within the screen area. The selection panel extends
// down textheight+2 pixels for every option, it begins 2 pixels below the instrn, and has a
// depth of 1. The total width is: w+bw+2*d+4, and the total height is: h+2*d+3+(textheight()+2)*#
// options. The List is a string containing a comma seperated list, the same as the menubar.
// The other options and parameters are the same as previous classes.
panel *PlDn; // The pulled-down panel.
button *DnBtn; // The button.
int BW, // The button's width.
pulled_down, // Non-Zero if the panel is pulled-down.
itm_selected, // Contains the number of the last item selected.
num_itms, // Contains the number of items in the list.
Hi_Clr; // The highlight color.
char *List; // The string containing the comma seperated list of options.
public:
selectbar(int x, int y, int w, char *Lst, int bw=8, int h=12, int c=7, int bc=7, int k=0);
~selectbar(void);
void show(void); // Shows a selection bar.
void hide(void); // Removes a selection bar.
void pulldown(void); // Pulls down the options panel.
void pushup(void); // Pushes the options panel back up.
void push(void); // Pushes the button.
void rels(void); // Releases the button.
void selitem (int); // Selects an item, (highlights it). 1st item is #1.
void clritem (void); // Clears any selected item.
char *getinput(); // The full get-input routine, with the selection panel implemented.
char *getitem(void); // Gets the string form of the option selected.
char *inptstrn(); // Just gets the typed-in string from the instrn.
int itmselected(void); // Gets the number of the option selected.
int itmhit(void); // Returns the number of the option the mouse cursor is over.
int btnhit(void); // Returns TRUE (non-zero) if the mouse cursor is on the button.
int pnlhit(void); // Returns TRUE if the mouse cursor is on the options panel.
void resize(int w, int h); // Changes the width and height of the selection bar.
void moveto (int x, int y); // Moves a selection bar to the new coordinates.
void setbtnclr(int c=7); // Changes the button color.
void sethiclr(int c=12 ); // Changes the highlight color.
void setbkgclr(int c=7); // Changes the background (panel & instrn) color.
};
class wndow : public bevel
{
// This is a window, similar to other GUIs. It has a close button in the
// upper left corner, a caption bar at the top right, and a border. This can
// be used instead of a panel or bevel for child windows in an application.
// The close button is ALWAYS the same size (11x11) and the caption bar is
// always 11 high. Also, the color default to light gray, but can be changed.
//
//
// Parameters: x,y,w,h,d,bw,k : These are the same as the bevel class and
// should be self-explanitory.
// c : This is a color value (0-15). Use the defined
// constants from graphics.h
// caption : This is the caption to be displayed in the
// caption bar.
//
//
//
// Preconditions: x,y,w,h,d,bw,k : Same as bevel, except that the width
// should be large enough to handle the
// close button (11 pixels) plus the text
// of the caption. If not, results could be
// very messy. Also, d should NOT be larger
// than 2. Again, if not, results could be
// messy.
// c : Should be a valid color (0 to 15).
// caption : Should point to a valid string. DO NOT
// make it NULL. If you do not want a caption
// make caption equil to "" (a null string).
//
//
protected:
char *Caption; // Holds the caption text.
button *cl_button; // The close button.
panel *cap_panl; // The caption panel
int Client_Clr, // The color of the client area. (defaults to light gray)
Txt_Clr; // The color of the caption text. (defaults to white)
public:
wndow(int x,int y,int w,int h,int d,int bw,char *caption,int k=1);// Creates a window.
~wndow(); // Deletes a window.
void show(void); // Shows a window.
void moveto(int x, int y); // Moves a window to a new location.
void resize(int w, int h); // Changes the width & height of a window.
void setbkgclr(int c); // Changes the border color of the window.
void setcliclr(int c); // Clanges the color of the client area.
void setcapclr(int c); // Changes the color of the caption bar.
void settxtclr(int c); // Changes the color of the caption text.
int clbtnhit(void); // Returns true if the mouse cursor is over the close button.
void clbtnprs(void); // Presses the close button.
void clbtnrls(void); // Releases the close button.
int clbtnpressed(void); // Returns true if the close button is pressed.
int capbarhit(void); // Returns true if the mouse cursor is over the caption bar.
};
#endif