
Home |
|
PegTextBox
|

Examples |

Index |
|
 |
|
|
 |
|
Overview |
Derived from class
PegWindow
and PegTextThing
|
 |
|
The PegTextBox class provides a multiline
text display control with windowing features. The font, color,
size and scrolling mode can be modified to give PegTextBox objects
a wide variety of appearances.
The text within a PegTextBox object is normally
left justified. Right and center justification are also supported.
The textbox size (the maximum number of characters which the textbox
can accommodate) is established when the textbox is constructed. The size can
subsequently be adjusted if necessary to meet the dynamic needs of
your application.
Lines of text that
exceed the client width of the textbox are wrapped
by default to extend across two or more lines.
Lines wrap at whitespace, comma or hyphen characters.
If a suitable breaking point cannot be found, the line will wrap
at the last character which fits within the width of the client area.
If a PegTextBox object is
used to display a long section of text that requires more text lines
than will fit in the visible TextBox client area, a
vertical scroll bar can be added to the window. The maximum number of
lines of text that can be maintained for display is 100, unless modified by your
KwikPeg Library configuration. Automatic vertical scrolling can be enabled
by calling the SetScrollMode(WSM_AUTOVSCROLL) member function
of the PegWindow class from which the PegTextBox
object is derived.
Each PegTextBox object
maintains an array of line break offsets into the block of text displayed in the
window. Using this array, new lines of text can be quickly displayed
as the text is scrolled up or down. You can access these line start offsets
if needed using member functions.
The PegTextBox class also catches PM_KEY
messages in order to detect PK_PGUP and PK_PGDN
requests which it services to scroll the displayed text up or down,
one page at a time.
Characters can be inserted into the textbox using
the DataSet() function. Any characters which would extend
beyond the textbox limit are lost.
Hence, insertion clipping occurs at the end of the textbox character array.
Characters can also be appended to the end of the textbox using
the Append() function. If any appended characters would extend
beyond the textbox limit, an equivalent number of characters are deleted
from the beginning of the textbox character array.
Hence, when characters are appended, clipping occurs at the head
of the textbox character array.
The PegTextBox class does not provide text editing
support. The text displayed in the textbox can be
modified by your application using the DataSet() or
Append() member functions.
For a full editable control, use a PegEditBox object.
|
|
 |
 |
|
PegPrompt
PegString
PegEditBox
The PegTextBox class supports
the following style flags:
FF_NONE | No frame. |
FF_THIN | Thin frame. |
FF_THICK | Thick 3D frame. |
FF_RAISED | Raised 3D frame. |
FF_RECESSED | Recessed 3D frame. |
EF_WRAP |
Long lines of text in any object derived from a PegTextBox
object will be wrapped to prevent them from being clipped. |
TJ_RIGHT | Right justify text. |
TJ_LEFT | Left justify text. |
TJ_CENTER | Center text. |
TT_COPY |
Keep separate copy of text with the object.
This flag should be used when the string value used to assign text to an object
is located in temporary storage such as a local variable on the stack. |
Constructors:
 |
 |
PegTextBox(const PegRect &Rect,
|
| |

WORD wId = 0,
|
| |

WORD wStyle = FF_RECESSED|EF_WRAP|TJ_LEFT,
|
| |

PEGCHAR *Text = NULL,
|
| |

WORD wMaxChars = 1000)
|
This constructor creates a
PegTextBox object at a specific location within a
rectangle specified by parameter Rect.
The rectangle defines the mReal position of the window.
The textbox object ID, window style and initial text can all
be specified. Parameter wMaxChars specifies the size
of the textbox character array,
the maximum number of characters that the textbox can hold.
Public Functions:
 |
 |
virtual void Append(const PEGCHAR *pText,
|
| |

BOOL bDraw = TRUE)
|
This function appends the indicated text to the current textbox
string value. If any appended characters would extend
beyond the textbox limit, an equivalent number of characters are deleted
from the beginning of the textbox character array.
The append function facilitates creation of terminal style windows.
If parameter bDraw is TRUE,
the textbox will be redrawn to reflect the newly added text.
 |
 |
virtual void DataSet(const PEGCHAR *Text)
|
The PegTextButton class overrides the
DataSet() function to permit the installation of
the new text string referenced by Text.
The textbox client area is invalidated.
Line offsets are recalcalculated and the scroll bars, if any,
are adjusted if necessary.
 |
 |
virtual void Draw(void)
|
The PegTextBox class overrides
the Draw() function to display the textbox border and text.
 |
 |
PEGCHAR *FindLinePointer(SIGNED iLine)
|
This function returns a pointer to the text which begins
at line iLine. Lines are numbered from 0.
Be aware that the text line is NOT '\0' terminated.
If iLine exceeds the number of lines present in the textbox,
the function returns NULL.
 |
 |
virtual void GetHScrollInfo(PegScrollInfo *Put)
|
The PegTextBox overrides
the PegWindow::GetHScrollInfo function to make
the scroll bars operate relative to the contained text.
 |
 |
WORD GetLineIndex(SIGNED iLine)
|
This function returns the index into the textbox character array
at which text line iLine begins.
Lines and character indices are numbered from 0.
If iLine exceeds the number of lines present in the textbox,
the function returns 0xFFFF.
 |
 |
PEGCHAR *GetLineStart(SIGNED iLine,
|
| |

SIGNED *pLength)
|
This function returns a pointer to the text which begins
at line iLine. Lines are numbered from 0.
Be aware that the text line is NOT '\0' terminated.
If iLine exceeds the number of lines present in the textbox,
the function returns NULL.
If pointer pLength is not NULL, this function
will set *pLength to the number of characters
(excluding '\r' or '\n' characters)
present in line iLine.
 |
 |
WORD GetMaxChars(void)
|
This inline function
returns the textbox character array size, the maximum number of
characters which the textbox can hold.
 |
 |
WORD GetTopLine(void)
|
This inline function
returns the line index of the line currently displayed at
the top of the textbox. Lines are numbered from 0.
 |
 |
virtual void GetVScrollInfo(PegScrollInfo *Put)
|
The PegTextBox overrides
the PegWindow::GetVScrollInfo function to make
the scroll bars operate relative to the contained text.
 |
 |
WORD GetWidestLine(void)
|
| |

{return miWidestLine;}
|
This inline function
returns the width (in pixels) of the widest line
of currently displayed text in the textbox. The widest line
may not be visible in the client area.
 |
 |
SIGNED LineCount(void)
|
| |

{return miTotalLines;}
|
This inline function
returns the total number of lines of text contained in the textbox.
The result is the total number of lines available,
not the number of lines actually visible.
 |
 |
BOOL LineDown(void)
|
This function scrolls the textbox down one line.
Your application can use this function to scroll the textbox whenever
required, independent of the scroll bar controls.
 |
 |
BOOL LineUp(void)
|
This function scrolls the textbox up one line.
Your application can use this function to scroll the textbox whenever
required, independent of the scroll bar controls.
 |
 |
void MarkLine(SIGNED iLine)
|
This function "marks" text line number iLine.
Lines are numbered from 0.
The marked line of text will be displayed
using the PCI_STEXT and PCI_SELECTED
foreground and background colors.
 |
 |
virtual SIGNED Message(const PegMessage &Mesg)
|
The PegTextBox class catches
several screen pointer and keyboard messages to provide
single line and paged scrolling of the text.
 |
 |
virtual void Resize(PegRect NewSize)
|
The PegTextBox class overrides
the Resize() function to recalculate the layout
of the displayed text lines to reflect the result of
the resizing operation.
 |
 |
void RewindDataSet(const PEGCHAR *pText)
|
This function assigns
the text string pText to the PegTextBox character
array. The new text replaces any current text.
The textbox line offset array is reset to match the new text.
The display is positioned with the first line of text at the
top of the textbox client area.
 |
 |
virtual void SetFont(PegFont *pFont)
|
The PegTextBox class overrides
the SetFont() function to recalculate the layout
of the displayed text lines to reflect the result of
the font change.
 |
 |
void SetMaxChars(WORD wMax)
|
This function can
be used to modify the size of the textbox character array,
the maximum number of characters the textbox can hold.
 |
 |
void SetTopLine(SIGNED iLine)
|
This function scrolls the textbox so that line iLine
is positioned at the top of the textbox client area.
Lines are numbered from 0.
If iLine exceeds the number of available lines
or is such that the displayed text lines would
would require more lines of text than are present in the textbox,
the top line is adjusted so that the last visible line is the last
available line text. If the number of lines following line iLine
is not sufficient to fill the client area, line iLine will be
positioned at the top of the textbox with the available lines following
and the remainder of the textbox cleared of text.
 |
 |
void SetTopLineToEnd(void)
|
This function will redraw the textbox so that the last text line
is visible at the bottom of the textbox. The function is equivalent to
SetTopLine(LineCount()).
Protected Members:
 |
 |
SIGNED miWidestLine
|
This variable indicates the width of the widest textbox line, in pixels.
 |
 |
SIGNED miLeftOffset
|
This variable indicates the distance (in pixels)
that the textbox has scrolled horizontally from the
anchor point used to identify the start of a line.
The following examples illustrate different styles of
PegTextBox objects.


