wTextCtrl

A text control allows text to be displayed and edited.

If the user pressed Enter key inside the control, a wEvent_TextEnter event will be generated. If this event is not processed, the default behavior of text control will be doen. However, for read-only control, wEvent_TextEnter will never be generated.

Appearance:
Superclass:wControl
Styles:
StylesDescription
wTeMultiLineThe text control allows multiple lines.
wTePasswordThe text will be echoed as asterisks.
wTeReadOnlyThe text will not be user-editable.
wTeNoHideSelShow the selection event when it doesn't have focus.
wTeLeftThe text in the control will be left-justified (default).
wTeCentreThe text in the control will be centered.
wTeCenterThe text in the control will be centered.
wTeRightThe text in the control will be right-justified.
wTeDontWrapDon't wrap at all, show horizontal scrollbar instead.
wTeRichUse rich text control under, this allows to have more than 64KB of text in the control.
wTeProcessTabWith this style, press TAB key to insert a TAB character instead of switches focus to the next control. Only works with wTeMultiLine.
Events:wCommandEvent
wCommandEventDescription
wEvent_TextWhen the text changes.
wEvent_TextUpdateWhen the control is about to redraw itself.
wEvent_TextMaxlenWhen the user tries to enter more text into the control than the limit.
wEvent_TextEnterWhen pressing Enter key.

Consts

wTeMultiLine = 0x00000004
wTeReadOnly = 0x00000800
wTePassword = 0x00000020
wTeNoHideSel = 0x00000100
wTeLeft = 0x00000000
wTeCentre = 0x00000001
wTeCenter = 0x00000001
wTeRight = 0x00000002
wTeDontWrap = 1048704
wTeRich = 1152921504606846976
wTeProcessTab = 0x00004000

Procs

proc isMultiLine(self: wTextCtrl): bool {...}{.validate, inline, raises: [], tags: [].}
Returns true if this is a multi line edit control and false otherwise.
proc isEditable(self: wTextCtrl): bool {...}{.validate, inline, raises: [], tags: [].}
Returns true if the controls contents may be edited by user.
proc isSingleLine(self: wTextCtrl): bool {...}{.validate, inline, raises: [], tags: [].}
Returns true if this is a single line edit control and false otherwise.
proc setModified(self: wTextCtrl; modified: bool) {...}{.validate, property, inline,
    raises: [], tags: [].}
Marks the control as being modified by the user or not.
proc discardEdits(self: wTextCtrl) {...}{.validate, inline, raises: [], tags: [].}
Resets the internal modified flag as if the current changes had been saved.
proc markDirty(self: wTextCtrl) {...}{.validate, inline, raises: [], tags: [].}
Mark text as modified (dirty).
proc isModified(self: wTextCtrl): bool {...}{.validate, inline, raises: [], tags: [].}
Returns true if the text has been modified by user.
proc setEditable(self: wTextCtrl; flag: bool) {...}{.validate, property, inline, raises: [],
    tags: [].}
Makes the text item editable or read-only.
proc setMargin(self: wTextCtrl; left: int; right: int) {...}{.validate, property, inline,
    raises: [], tags: [].}
Set the left and right margins. Set the left and right margins.
proc setMargin(self: wTextCtrl; margin: int) {...}{.validate, property, inline, raises: [],
    tags: [].}
Set the left and right margins to the same value.
proc getMargin(self: wTextCtrl): tuple[left: int, right: int] {...}{.validate, property,
    inline, raises: [], tags: [].}
Returns the margins.
proc xyToPosition(self: wTextCtrl; x: int; y: int): int {...}{.validate, inline, raises: [],
    tags: [].}
Converts the given zero based column and line number to a position.
proc xyToPosition(self: wTextCtrl; pos: wPoint): int {...}{.validate, inline, raises: [],
    tags: [].}
Converts the given zero based column and line number to a position.
proc getLineCount(self: wTextCtrl): int {...}{.validate, property, inline, raises: [],
                                      tags: [].}
Gets the number of lines in the control.
proc getNumberOfLines(self: wTextCtrl): int {...}{.validate, property, inline, raises: [],
    tags: [].}
Returns the number of lines in the text control buffer. The same as getLineCount().
proc getLineLength(self: wTextCtrl; line: int): int {...}{.validate, property, inline,
    raises: [], tags: [].}
Gets the length of the specified line, not including any trailing newline character
proc getLastPosition(self: wTextCtrl): int {...}{.validate, property, raises: [], tags: [].}
Returns the zero based index of the last position in the text control, which is equal to the number of characters in the control.
proc positionToXY(self: wTextCtrl; pos: int): wPoint {...}{.validate, raises: [], tags: [].}
Converts given position to a zero-based column, line number pair.
proc showPosition(self: wTextCtrl; pos: int) {...}{.validate, raises: [], tags: [].}
Makes the line containing the given position visible.
proc getSelection(self: wTextCtrl): Slice[int] {...}{.validate, property, inline,
    raises: [], tags: [].}
Gets the current selection range. If result.b < result.a, there was no selection.
proc getInsertionPoint(self: wTextCtrl): int {...}{.validate, property, inline, raises: [],
    tags: [].}
Returns the insertion point, or cursor, position.
proc setSelection(self: wTextCtrl; start: int; last: int) {...}{.validate, property, inline,
    raises: [], tags: [].}
Selects the text starting at the first position up to (but not including) the character at the last position.
proc setSelection(self: wTextCtrl; range: Slice[int]) {...}{.validate, property, inline,
    raises: [], tags: [].}
Selects the text in range (including).
proc selectAll(self: wTextCtrl) {...}{.validate, inline, raises: [], tags: [].}
Selects all text.
proc setInsertionPoint(self: wTextCtrl; pos: int) {...}{.validate, property, inline,
    raises: [], tags: [].}
Sets the insertion point at the given position.
proc setInsertionPointEnd(self: wTextCtrl) {...}{.validate, property, inline, raises: [],
    tags: [].}
Sets the insertion point at the end of the text control.
proc selectNone(self: wTextCtrl) {...}{.validate, inline, raises: [], tags: [].}
Deselects selected text in the control.
proc getRange(self: wTextCtrl; range: Slice[int]): string {...}{.validate, property,
    raises: [], tags: [].}
Returns the text in range.
proc getValue(self: wTextCtrl): string {...}{.validate, property, raises: [], tags: [].}
Gets the contents of the control.
proc copy(self: wTextCtrl) {...}{.validate, inline, raises: [], tags: [].}
Copies the selected text to the clipboard.
proc cut(self: wTextCtrl) {...}{.validate, inline, raises: [], tags: [].}
Copies the selected text to the clipboard and removes it from the control.
proc paste(self: wTextCtrl) {...}{.validate, inline, raises: [], tags: [].}
Pastes text from the clipboard to the text item.
proc undo(self: wTextCtrl) {...}{.validate, inline, raises: [], tags: [].}
If there is an undo facility and the last operation can be undone, undoes the last operation.
proc redo(self: wTextCtrl) {...}{.validate, inline, raises: [], tags: [].}
If there is a redo facility and the last operation can be redone, redoes the last operation.
proc canRedo(self: wTextCtrl): bool {...}{.validate, inline, raises: [], tags: [].}
Returns true if there is a redo facility available and the last operation can be redone.
proc canUndo(self: wTextCtrl): bool {...}{.validate, inline, raises: [], tags: [].}
Returns true if there is an undo facility available and the last operation can be undone.
proc setMaxLength(self: wTextCtrl; length: int) {...}{.validate, property, raises: [],
    tags: [].}
This function sets the maximum number of characters the user can enter into the control.
proc setValue(self: wTextCtrl; value: string) {...}{.validate, property, raises: [], tags: [].}
Sets the new text control value. Note that, unlike most other functions changing the controls values, this function generates a wEvent_Text event. To avoid this you can use ChangeValue() instead.
proc changeValue(self: wTextCtrl; value: string) {...}{.validate, raises: [], tags: [].}
Sets the new text control value. This functions does not generate the wEvent_Text event.
proc clear(self: wTextCtrl) {...}{.validate, inline, raises: [], tags: [].}
Clears the text in the control.
proc getLineText(self: wTextCtrl; line: int): string {...}{.validate, property, raises: [],
    tags: [].}
Returns the contents of a given line in the text control, not including any trailing newline character.
proc writeText(self: wTextCtrl; text: string) {...}{.validate, inline, raises: [], tags: [].}
Writes the text into the text control at the current insertion position.
proc appendText(self: wTextCtrl; text: string) {...}{.validate, inline, raises: [], tags: [].}
Appends the text to the end of the text control.
proc getTextSelection(self: wTextCtrl): string {...}{.validate, property, raises: [],
    tags: [].}
Gets the text currently selected in the control or empty string if there is no selection.
proc replace(self: wTextCtrl; range: Slice[int]; value: string) {...}{.validate, inline,
    raises: [], tags: [].}
Replaces the text in range.
proc remove(self: wTextCtrl; range: Slice[int]) {...}{.validate, inline, raises: [], tags: [].}
Removes the text in range.
proc loadFile(self: wTextCtrl; filename: string) {...}{.validate, inline, raises: [], tags: [].}
Loads and displays the named file, if it exists.
proc saveFile(self: wTextCtrl; filename: string) {...}{.validate, inline, raises: [], tags: [].}
Saves the contents of the control in a text file.
proc len(self: wTextCtrl): int {...}{.validate, inline, raises: [], tags: [].}
Returns the number of characters in the control.
proc add(self: wTextCtrl; text: string) {...}{.validate, inline, raises: [], tags: [].}
Appends the text to the end of the text control. The same as appendText()
proc final(self: wTextCtrl) {...}{.raises: [], tags: [].}
Default finalizer for wTextCtrl.
proc init(self: wTextCtrl; parent: wWindow; id = wDefaultID; value: string = "";
         pos = wDefaultPoint; size = wDefaultSize; style: wStyle = wTeLeft) {...}{.validate,
    raises: [], tags: [].}
Initializer.
proc TextCtrl(parent: wWindow; id = wDefaultID; value: string = ""; pos = wDefaultPoint;
             size = wDefaultSize; style: wStyle = wTeLeft): wTextCtrl {...}{.inline,
    discardable, raises: [], tags: [].}
 Constructor, creating and showing a text control.
proc TextCtrl(hWnd: HWND): wTextCtrl {...}{.inline, discardable, raises: [], tags: [].}
A special constructor to subclass the textctrl of other contorls.

Methods

method setFont(self: wTextCtrl; font: wFont) {...}{.validate, property, raises: [], tags: [].}
Sets the font for this text control.
method getBestSize(self: wTextCtrl): wSize {...}{.property, raises: [], tags: [].}
Returns the best acceptable minimal size for the control.
method getDefaultSize(self: wTextCtrl): wSize {...}{.property, raises: [], tags: [].}
Returns the default size for the control.
method setBackgroundColor(self: wTextCtrl; color: wColor) {...}{.property, raises: [],
    tags: [].}
Sets the background color of the control.

Iterators

iterator lines(self: wTextCtrl): string {...}{.validate, raises: [], tags: [].}
Iterates over each line in the control.