VTextCanvasPane: Difference between revisions
Appearance
Created page with "A class for drawing text on a canvas. ==Synopsis== ; '''Header:''' : <tt>[vquickr.htm#vTextCanvasPane <v/vtextcnv.h>]</tt> ; '''Class name:''' : vTextCanvasPane ; '''Hierarchy:..." |
mNo edit summary |
||
(2 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
==Synopsis== | ==Synopsis== | ||
;Header:<tt><v/vtextcnv.h></tt> | |||
; | ;Class name:vTextCanvasPane | ||
: <tt> | ;Hierarchy:[[vPane]]->[[vCanvasPane]]->vTextCanvasPane | ||
; | |||
: vTextCanvasPane | |||
; | |||
==Description== | ==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 <tt>Redraw</tt> events. In essence, the <tt>vTextCanvasPane</tt> class provides the functionality of a typical simple-minded text terminal. | 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 <tt>Redraw</tt> events. In essence, the <tt>vTextCanvasPane</tt> class provides the functionality of a typical simple-minded text terminal. | ||
==New Methods== | ==New Methods== | ||
;void ClearRow(const int row, const int col):This clears to blanks row <tt>row</tt> of the screen from column <tt>col</tt> to the end of the line. | |||
;void ClearToEnd(const int row, const int col):This clears to blanks from row <tt>row</tt> and column <tt>col</tt> to the end of the screen. | |||
;int GetCols():Returns number of columns in current text canvas. | |||
This clears to blanks row <tt>row</tt> of the screen from column <tt>col</tt> to the end of the line. | ;int GetRows():Returns number of rows in current text canvas. | ||
;void GetRC(int& row, int& col):Returns in <tt>row</tt> and <tt>col</tt> the current row and column of the text cursor. | |||
;void GotoRC(const int row ,const int row):Moves the text cursor to <tt>row,col</tt>. | |||
;void DrawAttrText(const char* text, const ChrAttr attr):Draws <tt>text</tt> starting at the current cursor location using text attribute <tt>attr</tt>. For more details, see <tt>vDC::DrawAttrText</tt>. | |||
This clears to blanks from row <tt>row</tt> and column <tt>col</tt> to the end of the screen. | ;void DrawChar(const char chr, const ChrAttr attr):Draws a single character <tt>chr</tt> at the current cursor location using text attribute <tt>attr</tt>. See <tt>DrawAttrText</tt> for more details. | ||
;void DrawText(const char* text):Draws <tt>text</tt> starting at the current cursor location. The newline character <tt>'\n'</tt> 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 ShowTextCursor(void):This method will redisplay the text cursor at the current row and column. | |||
Returns number of columns in current text canvas. | ;void ScrollText(const int count):This will scroll the text in the text canvas up or down by <tt>count</tt> lines. There will be <tt>count</tt> 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. | |||
Returns number of rows in current text canvas. | ;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. | |||
Returns in <tt>row</tt> and <tt>col</tt> the current row and column of the text cursor. | |||
Moves the text cursor to <tt>row,col</tt>. | |||
Draws <tt>text</tt> starting at the current cursor location using text attribute <tt>attr</tt>. For more details, see <tt>vDC::DrawAttrText</tt>. | |||
Draws a single character <tt>chr</tt> at the current cursor location using text attribute <tt>attr</tt>. See <tt>DrawAttrText</tt> for more details. | |||
Draws <tt>text</tt> starting at the current cursor location. The newline character <tt>'\n'</tt> 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. | |||
This method will hide the text cursor. | |||
This method will redisplay the text cursor at the current row and column. | |||
This will scroll the text in the text canvas up or down by <tt>count</tt> lines. There will be <tt>count</tt> blank lines created at the bottom or top of the screen. | |||
This method handles resize events. You will want to override this to track the new number of rows and columns. | |||
This is called when the user clicks the mouse button down. It is called with the text row and column, and the button number. | |||
This is called when the user releases the mouse button. It is called with the text row and column, and the button number. | |||
This is called when the mouse moves. It is called with the text row and column, and the button number. | |||
Returns the pixel value of the given column. Most useful to place vPopupMenus in proper position from text canvas. | |||
Returns the pixel value of the given row. Most useful to place vPopupMenus in proper position from text canvas. | |||
==Derived Methods== | ==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. <tt>FontChanged</tt> calls <tt>ResizeText</tt>, 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 <tt>vTextCanvasPane</tt> superclass will handle redrawing what is in the window. Instead, you will usually just have to respond to the <tt>FontChanged</tt> and <tt>ResizeText</tt> events when the contents of the canvas will actually change. | |||
This clears the text canvas and resets the row and column to 0,0. | |||
This is called when the font of the canvas changes. <tt>FontChanged</tt> calls <tt>ResizeText</tt>, so you probably won't have to deal with this event. | |||
Called when the screen needs to be redrawn. Normally, you won't have to override this class since the <tt>vTextCanvasPane</tt> superclass will handle redrawing what is in the window. Instead, you will usually just have to respond to the <tt>FontChanged</tt> and <tt>ResizeText</tt> events when the contents of the canvas will actually change. | |||
==Inherited Methods== | ==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== | ==See Also== | ||
vCanvasPane, vCmdWindow | |||
[[Category:V C++ GUI Framework]] | |||
[[Category: |
Latest revision as of 00:44, 8 April 2020
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 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