# vTextCanvasPane

A class for drawing text on a canvas.

## Synopsis

Header:
  `<v/vtextcnv.h>`
Class name:
  vTextCanvasPane
Hierarchy:
  vPane ->vCanvasPane ->vTextCanvasPane

## Description

This class provides a complete scrolling text window. You can send text line by line to the window, and it will scroll the text up the screen in response to linefeed characters. You can also position the cursor, and selectively clear areas of the text screen or display text at specific locations. This class handles repainting the screen on `Redraw` events. In essence, the `vTextCanvasPane` class provides the functionality of a typical simple-minded text terminal.

## New Methods

#### void ClearRow(const int row, const int col)

This clears to blanks row `row` of the screen from column `col` to the end of the line.

#### void ClearToEnd(const int row, const int col)

This clears to blanks from row `row` and column `col` to the end of the screen.

#### int GetCols()

Returns number of columns in current text canvas.

#### int GetRows()

Returns number of rows in current text canvas.

#### void GetRC(int& row, int& col)

Returns in `row` and `col` the current row and column of the text cursor.

#### void GotoRC(const int row ,const int row)

Moves the text cursor to `row,col`.

#### void DrawAttrText(const char* text, const ChrAttr attr)

Draws `text` starting at the current cursor location using text attribute `attr`. For more details, see `vDC::DrawAttrText`.

#### void DrawChar(const char chr, const ChrAttr attr)

Draws a single character `chr` at the current cursor location using text attribute `attr`. See `DrawAttrText` for more details.

#### void DrawText(const char* text)

Draws `text` starting at the current cursor location. The newline character `'\n'` will cause the cursor to move to the beginning of the next line, and the text to scroll if the cursor was on the last line.

#### void HideTextCursor(void)

This method will hide the text cursor.

#### void SetTextRowsCols(int rows, int cols)

This will set the size of the text canvas to `rows` and `cols` in characters (cols is for either mono-spaced fonts, or the average character width). It will also cause a `ResizeText` event message to be sent to the window.

#### void ShowTextCursor(void)

This method will redisplay the text cursor at the current row and column.

#### void ScrollText(const int count)

This will scroll the text in the text canvas up or down by `count` lines. There will be `count` blank lines created at the bottom or top of the screen.

#### void ResizeText(const int rows, const int cols)

This method handles resize events. You will want to override this to track the new number of rows and columns.

#### void TextMouseDown(int row, int col, int button)

This is called when the user clicks the mouse button down. It is called with the text row and column, and the button number.

#### void TextMouseUp(int row, int col, int button)

This is called when the user releases the mouse button. It is called with the text row and column, and the button number.

#### void TextMouseMove(int row, int col, int button)

This is called when the mouse moves. It is called with the text row and column, and the button number.

#### int ColToX(int col)

Returns the pixel value of the given column. Most useful to place vPopupMenus in proper position from text canvas.

#### int RowToY(int row)

Returns the pixel value of the given row. Most useful to place vPopupMenus in proper position from text canvas.

## Derived Methods

#### virtual void Clear()

This clears the text canvas and resets the row and column to 0,0.

#### void FontChanged(int)

This is called when the font of the canvas changes. `FontChanged` calls `ResizeText`, so you probably won't have to deal with this event.

#### void Redraw(int x, int y, int width, int height)

Called when the screen needs to be redrawn. Normally, you won't have to override this class since the `vTextCanvasPane` superclass will handle redrawing what is in the window. Instead, you will usually just have to respond to the `FontChanged` and `ResizeText` events when the contents of the canvas will actually change.

## Inherited Methods

#### virtual void HPage(int Shown, int Top)

#### virtual void HScroll(int step)

#### virtual void SetFont(int vf)

#### virtual void SetHScroll(int Shown, int Top)

#### virtual void SetVScroll(int Shown, int Top)

#### virtual void VPage(int Shown, int Top)

#### virtual void VScroll(int step)

## See Also

vCanvasPane, vCmdWindow