Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

Teddy::PhysicalComponents::Console Class Reference

Text (fixed width font) console userinterface component. More...

#include <Console.h>

Inheritance diagram for Teddy::PhysicalComponents::Console:

Inheritance graph
[legend]
Collaboration diagram for Teddy::PhysicalComponents::Console:

Collaboration graph
[legend]
List of all members.

Public Methods

 Console (const std::string &name, const int w, const int h)
 Constructor; font, width (chars), height (chars). More...

Console & setLine (const int l, const string &s)
 Set contents of given line - no scrolling. More...

Console & operator<< (const string &s)
 Print string to buffer. More...

void append (const char *str, int count)
 Append chars. More...

void append (int c)
 Append single char. More...

void cursorDown ()
void newLine ()
void insertLine (const int y)
 Insert new line. More...

void killLine (const int y)
 Kill line. More...

void killChar (const int x, const int y)
 Kill character. More...

void scroll (int x1, int y1, int x2, int y2, int dx, int dy)
 Scroll area. More...

virtual void drawSelf ()
 Draw. More...

bool focusActive (const Event &e)
 Received or lost keyboard focus. More...

bool keyDown (const Event &e)
bool keyUp (const Event &e)

Protected Methods

virtual void setSize (const int width, const int height)

Protected Attributes

vector< string * > buffer_lines
 Buffer. More...

int font_width
 For quick access.. FIX? Observer? More...

int font_height
 For quick access.. FIX? Observer? More...

int width_chars
 Number of visible chars per line. More...

int height_chars
 Number of visible lines. More...

int max_height_chars
 Number of lines in buffer. More...

int topleft_x
 Current scroll x-position - first visible char. More...

int topleft_y
 Current scroll y-position - first visible line. More...

int cx
 Cursor X position. More...

int cy
 Cursor Y position. More...

bool cursor_visible
 Do we want visible cursor? More...

Color text_color
 Text color. More...


Detailed Description

Text (fixed width font) console userinterface component.

Warning:
Current console class is more instance than general console
Todo:
Selection

Support for variable width font

Console com7ponent can be used for standard input and output in simple text form.

At the moment MouseListener is used for window dragging, but that will change into selection later, and dragging will be put into Frame Label.

The basic input and output is working now, but there are still a number of cliches, so be aware.

Console may or may not be connected to a parser. Currently I have plugged in Kamin Scheme interpreter as parser. If you enable it, be sure not to try to parse lines that are not complete, legal scheme statements. At the moment it is only small subset of scheme, and you can only send one line at time to it.

Definition at line 65 of file Console.h.


Constructor & Destructor Documentation

Teddy::PhysicalComponents::Console::Console const std::string &    name,
const int    w,
const int    h
 

Constructor; font, width (chars), height (chars).

Definition at line 49 of file Console.cpp.

References Teddy::PhysicalComponents::EventListener::bind, buffer_lines, cursor_visible, cx, cy, Teddy::PhysicalComponents::Area::drawing_ordering, Teddy::PhysicalComponents::Area::fill_base_pixels, font_height, font_width, height_chars, Teddy::PhysicalComponents::Area::insert, max_height_chars, Teddy::PhysicalComponents::Area::post_self, Teddy::PhysicalComponents::Area::style, text_color, topleft_x, topleft_y, and width_chars.


Member Function Documentation

void Teddy::PhysicalComponents::Console::append int    c
 

Append single char.

Definition at line 217 of file Console.cpp.

References buffer_lines, cy, and newLine.

void Teddy::PhysicalComponents::Console::append const char *    str,
int    count
 

Append chars.

Definition at line 230 of file Console.cpp.

References buffer_lines, cy, and newLine.

void Teddy::PhysicalComponents::Console::cursorDown  
 

Definition at line 258 of file Console.cpp.

References buffer_lines, cy, height_chars, and topleft_y.

Referenced by keyDown, and newLine.

void Teddy::PhysicalComponents::Console::drawSelf   [virtual]
 

Draw.

Parameters:
width  Console width in characters
height  Console height in characters
Todo:
Support for variable width fonts

Reimplemented from Teddy::PhysicalComponents::Area.

Definition at line 163 of file Console.cpp.

References buffer_lines, Teddy::Graphics::ViewClient::color, cursor_visible, cx, cy, Teddy::PhysicalComponents::Area::drawString, font_height, font_width, height_chars, Teddy::PhysicalComponents::Area::style, text_color, topleft_x, topleft_y, Teddy::Graphics::ViewClient::view, and width_chars.

bool Teddy::PhysicalComponents::Console::focusActive const Event   e
 

Received or lost keyboard focus.

Definition at line 198 of file Console.cpp.

References text_color.

void Teddy::PhysicalComponents::Console::insertLine const int    y
 

Insert new line.

Definition at line 271 of file Console.cpp.

References buffer_lines.

Referenced by keyDown, and newLine.

bool Teddy::PhysicalComponents::Console::keyDown const Event   e
 

Insert key

Warning:
Pretty buggy - work in progress
Direct use of physical keys, no mapping :I

Definition at line 311 of file Console.cpp.

References buffer_lines, cursorDown, cx, cy, insertLine, killChar, killLine, and topleft_y.

bool Teddy::PhysicalComponents::Console::keyUp const Event   e
 

void Teddy::PhysicalComponents::Console::killChar const int    x,
const int    y
 

Kill character.

Definition at line 283 of file Console.cpp.

References buffer_lines.

Referenced by keyDown.

void Teddy::PhysicalComponents::Console::killLine const int    y
 

Kill line.

Definition at line 276 of file Console.cpp.

References buffer_lines.

Referenced by keyDown.

void Teddy::PhysicalComponents::Console::newLine   [inline]
 

Definition at line 80 of file Console.h.

References cursorDown, cx, cy, and insertLine.

Referenced by append.

Console & Teddy::PhysicalComponents::Console::operator<< const string &    s
 

Print string to buffer.

Definition at line 209 of file Console.cpp.

References buffer_lines, cx, and cy.

void Teddy::PhysicalComponents::Console::scroll int    x1,
int    y1,
int    x2,
int    y2,
int    dx,
int    dy
 

Scroll area.

Definition at line 253 of file Console.cpp.

Console & Teddy::PhysicalComponents::Console::setLine const int    l,
const string &    s
 

Set contents of given line - no scrolling.

Definition at line 246 of file Console.cpp.

References buffer_lines.

virtual void Teddy::PhysicalComponents::Console::setSize const int    width,
const int    height
[protected, virtual]
 


Member Data Documentation

vector<string*> Teddy::PhysicalComponents::Console::buffer_lines [protected]
 

Buffer.

Definition at line 96 of file Console.h.

Referenced by append, Console, cursorDown, drawSelf, insertLine, keyDown, killChar, killLine, operator<<, and setLine.

bool Teddy::PhysicalComponents::Console::cursor_visible [protected]
 

Do we want visible cursor?

Definition at line 106 of file Console.h.

Referenced by Console, and drawSelf.

int Teddy::PhysicalComponents::Console::cx [protected]
 

Cursor X position.

Definition at line 104 of file Console.h.

Referenced by Console, drawSelf, keyDown, newLine, and operator<<.

int Teddy::PhysicalComponents::Console::cy [protected]
 

Cursor Y position.

Definition at line 105 of file Console.h.

Referenced by append, Console, cursorDown, drawSelf, keyDown, newLine, and operator<<.

int Teddy::PhysicalComponents::Console::font_height [protected]
 

For quick access.. FIX? Observer?

Definition at line 98 of file Console.h.

Referenced by Console, and drawSelf.

int Teddy::PhysicalComponents::Console::font_width [protected]
 

For quick access.. FIX? Observer?

Definition at line 97 of file Console.h.

Referenced by Console, and drawSelf.

int Teddy::PhysicalComponents::Console::height_chars [protected]
 

Number of visible lines.

Definition at line 100 of file Console.h.

Referenced by Console, cursorDown, and drawSelf.

int Teddy::PhysicalComponents::Console::max_height_chars [protected]
 

Number of lines in buffer.

Definition at line 101 of file Console.h.

Referenced by Console.

Color Teddy::PhysicalComponents::Console::text_color [protected]
 

Text color.

Definition at line 107 of file Console.h.

Referenced by Console, drawSelf, and focusActive.

int Teddy::PhysicalComponents::Console::topleft_x [protected]
 

Current scroll x-position - first visible char.

Definition at line 102 of file Console.h.

Referenced by Console, and drawSelf.

int Teddy::PhysicalComponents::Console::topleft_y [protected]
 

Current scroll y-position - first visible line.

Definition at line 103 of file Console.h.

Referenced by Console, cursorDown, drawSelf, and keyDown.

int Teddy::PhysicalComponents::Console::width_chars [protected]
 

Number of visible chars per line.

Definition at line 99 of file Console.h.

Referenced by Console, and drawSelf.


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