Milo  0.1
Milo:EquationManipulationProgram
Private Member Functions | Private Attributes | Static Private Attributes | List of all members
CursesGraphics Class Reference
Inheritance diagram for CursesGraphics:
Inheritance graph
[legend]
Collaboration diagram for CursesGraphics:
Collaboration graph
[legend]

Public Member Functions

Constructor and Virtual Destructor
 CursesGraphics ()
 
 ~CursesGraphics ()
 
- Public Member Functions inherited from UI::Graphics
 Graphics ()
 
virtual ~Graphics ()
 
virtual void at (int x0, int y0, const std::string &s, Attributes chrAttr, Color color=BLACK)=0
 
void set (const Box &box)
 
void setSelect (const Box &box)
 
void parenthesis (const Box &box)
 
void relativeOrig (int &x, int &y)
 

Private Member Functions

void at (int x, int y, int c)
 

Private Attributes

bool m_has_colors
 If true, flag is screen has colors.
 
int m_xMouse
 Last mouse horizontal coordinate.
 
int m_yMouse
 Last mouse vertical coordinate.
 

Static Private Attributes

static bool init = false
 Singleton has been initialized.
 
static const unordered_map< Attributes, int > attribute_map
 
static const unordered_map< char, string > char_map
 

Virtual Public Member Functions

int getTextHeight ()
 
int getTextLength (const std::string &s)
 
int getCharLength (char)
 
int getParenthesisWidth (int)
 
int getDivideLineHeight ()
 
int getDifferentialHeight (char)
 
int getDifferentialWidth (char)
 
int getDifferentialBase (char)
 
void at (int x, int y, int c, Attributes chrAttr, Color color=BLACK)
 
void at (int x, int y, const string &s, Attributes chrAttr, Color color=BLACK)
 
void at (int x, int y, const char *s)
 
void out ()
 
void clear_screen ()
 
void set (int x, int y, int, int)
 
void horiz_line (int x_size, int x0, int y0)
 
void differential (int x0, int y0, char variable)
 
void parenthesis (int x_size, int y_size, int x0, int y0)
 
void setSelect (int x, int y, int x0, int y0)
 
unsigned int ins (int x, int y)
 
unsigned int getChar (int y, int x, bool active)
 
static CursesGraphics & getInstance ()
 

Additional Inherited Members

- Public Types inherited from UI::Graphics
enum  Color {
  BLACK, RED, GREEN, YELLOW,
  BLUE, MAGENTA, CYAN, WHITE
}
 
enum  Attributes { NONE =0, BOLD =1, ITALIC =2, BOLD_ITALIC =3 }
 
- Protected Attributes inherited from UI::Graphics
int m_xSize
 Horizontal size of graphic window.
 
int m_ySize
 Vertical size of graphic window.
 
int m_xOrig
 Horizontal origin of graphic window.
 
int m_yOrig
 Vertical origin of graphic window.
 
Box m_select
 Currently selected area.
 

Detailed Description

Class derived from ABC Graphics to allow milo to draw to a ncurses ascii screen.

Member Function Documentation

void CursesGraphics::at ( int  x,
int  y,
int  c,
Attributes  chrAttr,
Color  color = BLACK 
)
inlinevirtual

Draw a character at x,y with a color.

Parameters
xHorizontal origin of line.
yVertical origin of line.
cCharacter to be drawn at x0,y0.
chrAttrAttribute of character.
colorColor of line.

Implements UI::Graphics.

void CursesGraphics::at ( int  x,
int  y,
const string &  s,
Attributes  chrAttr,
Color  color = BLACK 
)
inline

Draw a string at x,y with a color.

Parameters
xHorizontal origin of line.
yVertical origin of line.
sString to be drawn at x0,y0.
chrAttrAttribute of character.
colorColor of line.
void CursesGraphics::at ( int  x,
int  y,
const char *  s 
)
inline

Draw a c-string at x,y with black color.

Parameters
xHorizontal origin of line.
yVertical origin of line.
sC-String to be drawn at x0,y0.
void CursesGraphics::at ( int  x,
int  y,
int  c 
)
inlineprivate

Draw a character at x,y.

Parameters
xHorizontal origin of line.
yVertical origin of line.
cCharacter to be drawn at x0,y0.
void CursesGraphics::clear_screen ( )
inlinevirtual

Clear ncurses screen.

Implements UI::Graphics.

void CursesGraphics::differential ( int  x0,
int  y0,
char  variable 
)
virtual

Draw differential of width x0 and height y0 with char variable name.

Parameters
x0Horizontal origin of differential.
y0Vertical origin of differential.
variableName of variable of differential.

Implements UI::Graphics.

unsigned int CursesGraphics::getChar ( int  y,
int  x,
bool  active 
)
inline

Return character from key press. Put up a blinking cursor at given coordinates. Erase cursor after key press.

Parameters
yVertical coordinate.
xHorizontal coordinate.
activeTrue if cursor should blink
Returns
Character from keyboard.
int CursesGraphics::getCharLength ( char  )
inlinevirtual

Length of character in ASCII is 1.

Returns
Return one.

Implements UI::Graphics.

int CursesGraphics::getDifferentialBase ( char  )
inlinevirtual

Get vertical offset of differential.

Returns
Vertical offset of differential in lines of text.

Implements UI::Graphics.

int CursesGraphics::getDifferentialHeight ( char  )
inlinevirtual

Get height of differential in lines of text.

Returns
Height of differential in lines of text.

Implements UI::Graphics.

int CursesGraphics::getDifferentialWidth ( char  )
inlinevirtual

Get width of differential in lines of text.

Returns
Width of differential in lines of text.

Implements UI::Graphics.

int CursesGraphics::getDivideLineHeight ( )
inlinevirtual

Get height of line in a division node which is always 1.

Returns
Return one.

Implements UI::Graphics.

static CursesGraphics& CursesGraphics::getInstance ( )
inlinestatic

Static fucntion that return singleton CursesGraphics object attached to screen

Returns
CursesGraphics singleton.
int CursesGraphics::getParenthesisWidth ( int  )
inlinevirtual

Get width of a parenthesis in characters which is always 1.

Returns
Return one.

Implements UI::Graphics.

int CursesGraphics::getTextHeight ( )
inlinevirtual

Get height of text in lines.

Returns
All ASCII characters are one line in height.

Implements UI::Graphics.

int CursesGraphics::getTextLength ( const std::string &  s)
inlinevirtual

Get length of string in characters.

Returns
Length of string in characters.

Implements UI::Graphics.

void CursesGraphics::horiz_line ( int  x_size,
int  x0,
int  y0 
)
inlinevirtual

Draw a horizontal line starting at x0,y0 length x_size.

Parameters
x_sizeHorizontal size of both line.
x0Horizontal origin of line.
y0Vertical origin of line.

Implements UI::Graphics.

unsigned int CursesGraphics::ins ( int  x,
int  y 
)
inline

Return character drawn at screen coordinates.

Parameters
xHorizontal coordinate.
yVertical coordinate.
Returns
Character at x,y coordinate.
void CursesGraphics::out ( )
inlinevirtual

Flush all characters to the ncurses screen.

Implements UI::Graphics.

void CursesGraphics::parenthesis ( int  x_size,
int  y_size,
int  x0,
int  y0 
)
virtual

Draw pair of parenthesis around a node of size x_size, y_size and origin x0,y0.

Parameters
x_sizeHorizontal size of both parenthesis.
y_sizeVertical size of parenthesis.
x0Horizontal origin of parenthesis.
y0Vertical origin of parenthesis.

Implements UI::Graphics.

void CursesGraphics::set ( int  x,
int  y,
int  ,
int   
)
inlinevirtual

Set size of this graphics window (origin is always 0,0).

Parameters
xHorizontal size of graphics window.
yVertical size of graphics window.

Reimplemented from UI::Graphics.

void CursesGraphics::setSelect ( int  x,
int  y,
int  x0,
int  y0 
)
inlinevirtual

Select the area of size x,y at origin x0,y0.

Parameters
xHorizontal size of both selection area.
yVertical size of selection area.
x0Horizontal origin of selection area.
y0Vertical origin of selection area.

Reimplemented from UI::Graphics.

Member Data Documentation

const unordered_map< Graphics::Attributes, int > CursesGraphics::attribute_map
staticprivate
Initial value:
= {
{ Graphics::Attributes::NONE, A_NORMAL },
{ Graphics::Attributes::BOLD, A_BOLD },
{ Graphics::Attributes::ITALIC, A_ITALIC },
{ Graphics::Attributes::BOLD_ITALIC, A_ITALIC|A_BOLD }
}

Map Graphics attributs to ncurses attributes.

const unordered_map< char, string > CursesGraphics::char_map
staticprivate
Initial value:
= {
{ 'A', "\u03b1" }, { 'B', "\u03b2" }, { 'C', "\u03c8" }, { 'D', "\u03b4" },
{ 'E', "\u03b5" }, { 'F', "\u03c6" }, { 'G', "\u03b3" }, { 'H', "\u03b7" },
{ 'I', "\u03b9" }, { 'J', "\u03be" }, { 'K', "\u03ba" }, { 'L', "\u03bb" },
{ 'M', "\u03bc" }, { 'N', "\u03bd" }, { 'O', "\u03bf" }, { 'P', "\u03c0" },
{ 'Q', "\u03d9" }, { 'R', "\u03c1" }, { 'S', "\u03c3" }, { 'T', "\u03c4" },
{ 'U', "\u03b8" }, { 'V', "\u03c9" }, { 'W', "\u03c2" }, { 'X', "\u03c7" },
{ 'Y', "\u03c5" }, { 'Z', "\u03b6" }
}

Special characters that are mapped to special unicode characters. Upper case characters mapped to greek letters.


The documentation for this class was generated from the following file: