
Home |
|
PegString
|

Examples |

Index |
|
|
|
 |
|
Overview |
Derived from class
PegThing
and PegTextThing
|
 |
|
The PegString class provides a user editable
graphical string object. A PegString object can be
displayed with any font or color and with several different border
styles. Only one line of text can be displayed in a PegString
object.
The length of the string text can be limited, if desired.
If the string cannot be completely displayed in the client area
of the PegString object, the string will be shifted
left or right as needed to allow the string to be edited.
The PegString class supports mark, cut, copy and paste
operations via keyboard input. These operations are only provided if
your KwikPeg Library has been configured to include a keyboard
as an input device.
|
|
PegPrompt
PegTextBox
The PegString 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. |
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. |
EF_EDIT |
The text within a PegEditBox or PegString
object can be edited by the user.
If this style is applied, the object automatically includes the
TT_COPY style. |
The PegString class generates
the following signals:
PSF_TEXT_SELECT | Sent when the user selects all or a portion of a text object. |
PSF_TEXT_EDIT | Sent each time text object string is modified. |
PSF_TEXT_EDITDONE | Sent when a text object modification is complete. |
Constructors:
 |
 |
PegString(const PegRect &Rect,
|
| |

const PEGCHAR *Text = NULL, WORD wId = 0,
|
| |

WORD wStyle = FF_RECESSED|AF_ENABLED|EF_EDIT,
|
| |

SIGNED iLen = -1)
|
This constructor creates a
PegString object at a specific location within a
rectangle specified by parameter Rect.
The text will be rendered in the default PegString font.
 |
 |
PegString(SIGNED iLeft, SIGNED iTop,
|
| |

SIGNED iWidth,
|
| |

const PEGCHAR *Text = NULL, WORD wId = 0,
|
| |

WORD wStyle = FF_RECESSED|AF_ENABLED|EF_EDIT,
|
| |

SIGNED iLen = -1)
|
This constructor creates a
PegString object of width iWidth with its
top left corner located at (iLeft,iTop).
The text will be rendered in the default PegString font.
The object automatically adjusts its width and height
according to the dimensions of the rendered text string.
 |
 |
PegString(SIGNED iLeft, SIGNED iTop,
|
| |

const PEGCHAR *Text = NULL, WORD wId = 0,
|
| |

WORD wStyle = FF_RECESSED|AF_ENABLED|EF_EDIT,
|
| |

SIGNED iLen = -1)
|
This constructor creates a
PegString object with its
top left corner located at (iLeft,iTop).
The text will be rendered in the default PegString font.
The object automatically adjusts its width and height
according to the dimensions of the rendered text string.
Public Functions:
 |
 |
void CopyToScratchPad(void)
|
This function copies
the currently marked text to the scratch pad.
 |
 |
virtual void DataSet(const PEGCHAR *Text)
|
The PegString class overrides
the DataSet() function to permit the installation of
a new text string. Any string mark or edit operations which are
in progress are reset and the string client area is invalidated.
 |
 |
void DeleteMarkedText(void)
|
This function deletes the currently marked text.
 |
 |
virtual void Draw(void)
|
The PegString class overrides
the Draw() function to display the string border and text.
 |
 |
virtual SIGNED GetMarkEnd(void)
|
| |

{return miMarkEnd;}
|
This function returns the index of the last character marked by the user.
 |
 |
virtual SIGNED GetMarkStart(void)
|
| |

{return miMarkStart;}
|
This function returns the index of the first character marked by the user.
 |
 |
virtual SIGNED Message(const PegMessage &Mesg)
|
The PegString class catches
various screen input and keyboard messages to provide
editing services.
 |
 |
void PasteFromScratchPad(void)
|
This function pastes
the text from the scratch pad into the string at the current cursor position.
 |
 |
virtual void SetFont(PegFont *pFont)
|
The PegString class overrides
the SetFont() function to invalidate the
client area when the font is altered to that specified by
parameter pFont.
 |
 |
virtual void SetMark(
|
| |

SIGNED iStart, SIGNED iEnd)
|
This function marks all or part of the string text under program control.
The iStart and iEnd values are the
indexes into the string at which character marking will begin and end,
inclusively.
 |
 |
virtual void SetMark(PEGCHAR *MarkStart,
|
| |

PEGCHAR *MarkEnd)
|
This function marks all or part of the string text under program control.
The MarkStart and MarkEnd parameters are pointers
to the characters within the string
at which marking will begin and end, inclusively.
 |
 |
virtual void Style(WORD wStyle)
|
The PegString class overrides
the Style() function to reset any mark or edit operations
which are in progress when the EF_EDIT style is removed.
The following example illustrates different styles of
PegString objects:

The following code fragment creates a PegString
object with a custom font and adds it to the parent window.
extern PegFont CustomFont;
void MyWindow::AddCustomString(void)
{
PegRect ChildRect;
ChildRect.Set(0, 0, 100, 40);
PegString *pString =
new PegString(ChildRect, "My String");
pString->SetFont(&CustomFont);
Add(pPrompt);
}