TxtPad Class Reference

The TxtPad class serves as a basic text-based canvas. More...

#include <TxtPad.h>

List of all members.

Public Types

enum  Justification {
  RIGHT, LEFT, TOP, BOTTOM,
  JUSTIFIED
}

Public Member Functions

 TxtPad (int x, int y, char background= ' ')
 Creates a TxtPad of given size and background.
 TxtPad ()
 Creates an empty TxtPad, with blank background.
void resize (int x, int y)
 Resizes the TxtPad.
void set (int x, int y, char c)
 Explicitly set a particular position to the given character.
char get (int x, int y)
 Explicitly retrieve the character at a given position.
int getXdim ()
 Accessor method.
int getYdim ()
 Accessor method.
void frame ()
 Draws a frame around the TxtPad.
void clear ()
 Clears the TxtPad by setting all locations to the background character.
void drawSquare (int xMin, int yMin, int xMax, int yMax)
 Draws a square in the TxtPad.
void insert (int xMin, int yMin, TxtPad &t)
 Inserts a smaller TxtPad into this one at the given position.
void print (int x, int y, const string &str, Justification j=LEFT)
 Writes a string into the TxtPad at the given position, with the given justification.
void printVert (int x, int y, const string &str, Justification j=TOP)
 Writes a vertical string to the TxtPad.
void print (int x, int y, int value, Justification j=RIGHT)
 Writes an integer to the TxtPad, using the given justification.
void print (int x, int y, float value, Justification j=RIGHT, int decimalPlaces=1)
 Writes a floating point number to the TxtPad, using the given justification.

Public Attributes

int xDim
int yDim
vector< vector< char > > pad
char background

Friends

ostream & operator<< (ostream &, TxtPad &)
 Writes the TxtPad to the output stream.


Detailed Description

The TxtPad class serves as a basic text-based canvas.


Member Enumeration Documentation

enum TxtPad::Justification
 

Enumerator:
RIGHT 
LEFT 
TOP 
BOTTOM 
JUSTIFIED 


Constructor & Destructor Documentation

TxtPad::TxtPad int  xDim,
int  yDim,
char  background = ' '
 

Creates a TxtPad of given size and background.

Parameters:
xDim Width in characters of the TxtPad.
yDim Height in characters of the TxtPad.
background Character to use for the TxtPad's background.

TxtPad::TxtPad  ) 
 

Creates an empty TxtPad, with blank background.


Member Function Documentation

void TxtPad::clear  ) 
 

Clears the TxtPad by setting all locations to the background character.

void TxtPad::drawSquare int  xMin,
int  yMin,
int  xMax,
int  yMax
 

Draws a square in the TxtPad.

Parameters:
xMin Left side.
yMin Bottom side.
xMax Right side.
yMax Top side.
Exceptions:
MsgException If any of the sides don't fall within the TxtPad.

void TxtPad::frame  ) 
 

Draws a frame around the TxtPad.

This doesn't change the size of the TxtPad; rather it uses up one character width on all sides for the frame.

char TxtPad::get int  x,
int  y
 

Explicitly retrieve the character at a given position.

Returns:
The character at position x, y.

int TxtPad::getXdim  )  [inline]
 

Accessor method.

Returns:
The width of the TxtPad in characters.

int TxtPad::getYdim  )  [inline]
 

Accessor method.

Returns:
The height of the TxtPad in characters.

void TxtPad::insert int  xMin,
int  yMin,
TxtPad t
 

Inserts a smaller TxtPad into this one at the given position.

Parameters:
xMin Position for the left edge of the inserted TxtPad.
yMin Position for the bottom edge of the inserted TxtPad.
t The TxtPad to insert.
Exceptions:
MsgException If the inserted TxtPad wouldn't fit into the parent TxtPad.

void TxtPad::print int  x,
int  y,
float  value,
Justification  j = RIGHT,
int  decimalPlaces = 1
 

Writes a floating point number to the TxtPad, using the given justification.

It just starts by converting it to a string and calling print(string).

Parameters:
x X position to write the float.
y Y position to write the float.
value The floating-point value to write.
j The justification to use for the float (RIGHT, LEFT, or JUSTIFIED).
decimalPlaces How many decimal points to write.

void TxtPad::print int  x,
int  y,
int  value,
Justification  j = RIGHT
 

Writes an integer to the TxtPad, using the given justification.

It just starts by converting it to a string and calling print(string).

Parameters:
x X position to write the int.
y Y position to write the int.
value The integer to write.
j The justification to use for the integer (RIGHT, LEFT, or JUSTIFIED).

void TxtPad::print int  x,
int  y,
const string &  str,
Justification  j = LEFT
 

Writes a string into the TxtPad at the given position, with the given justification.

Will complain if string is altogether out of range, otherwise will quietly clip if needed.

Parameters:
x X position to write the string.
y Y position to write the string.
str The string to write to the TxtPad.
j The justification to use for the string (RIGHT, LEFT, or JUSTIFIED).
Exceptions:
MsgException If justification is TOP or BOTTOM
MsgException If string doesn't fall within the TxtPad.

void TxtPad::printVert int  x,
int  y,
const string &  str,
Justification  j = TOP
 

Writes a vertical string to the TxtPad.

Will complain if string is altogether out of range, otherwise will quietly clip if needed.

Parameters:
x X position to write the string.
y Y position to write the string.
str The string to write to the TxtPad.
j The justification to use for the string (TOP, BOTTOM, or JUSTIFIED).
Exceptions:
MsgException If justification is LEFT or RIGHT.
MsgException If string doesn't fall within the TxtPad.

void TxtPad::resize int  xDim,
int  yDim
 

Resizes the TxtPad.

Parameters:
xDim New X dimension.
yDim New Y dimension.

void TxtPad::set int  x,
int  y,
char  c
 

Explicitly set a particular position to the given character.

Parameters:
x The x position.
y The y position.
c The character value to be written.


Friends And Related Function Documentation

ostream& operator<< ostream &  s,
TxtPad t
[friend]
 

Writes the TxtPad to the output stream.

Parameters:
s Place to which to write.
t The TxtPad to write.


Member Data Documentation

char TxtPad::background
 

vector<vector<char> > TxtPad::pad
 

int TxtPad::xDim
 

int TxtPad::yDim
 


The documentation for this class was generated from the following files:
Generated on Tue Dec 13 11:00:27 2005 for Classer by  doxygen 1.4.3