14#include <owl/validate.rh>
17#if !defined(__CYGWIN__)
27#if defined(__BORLANDC__)
64TEdit* TEdit::ValidatorReFocus =
nullptr;
102:
TStatic(parent,
id,
text, x, y,
w,
h,
textLen, module), Validator(
nullptr), Requirement(roNone)
117:
TStatic(parent, id,
text, x, y,
w,
h,
textLen, module), Validator(
nullptr), Requirement(roNone)
216 if (Validator && key !=
VK_BACK) {
257 Validator->
Error(
this);
307 Validator->
Error(
this);
334 if ((Validator ||
IsRequired()) && !ValidatorReFocus)
353 ValidatorReFocus =
this;
370 if (ValidatorReFocus ==
this)
371 ValidatorReFocus =
nullptr;
522 if (
static_cast<unsigned int>(
strSize) <
sizeof(
int16)) {
549 WARN(!
ok,
_T(
"TEdit::GetLine failed, line = ") << line);
550 static_cast<void>(
ok);
650#if defined(BI_DBCS_SUPPORT) && !defined(UNICODE)
668#if defined(BI_DBCS_SUPPORT) && !defined(UNICODE)
692#if defined(BI_DBCS_SUPPORT) && !defined(UNICODE)
705#if defined(BI_DBCS_SUPPORT) && !defined(UNICODE)
723#if defined(BI_DBCS_SUPPORT) && !defined(UNICODE)
773#if defined(BI_DBCS_SUPPORT)
889 WARN(
true,
_T(
"TEdit::GetSubText is deprecated. Use GetTextRange instead."));
912 const int begin =
r.cpMin;
922 if (begin == 0 && end == -1)
928 if (begin < 0 || end < 0)
930 WARN(
true,
_T(
"Arguments out of range"));
933 else if (begin == end)
935 WARN(
true,
_T(
"Empty range"));
938 else if (begin > end)
940 WARN(
true,
_T(
"Inverted range"));
953 end = std::min(end,
n);
969 s.append(line,
b,
e -
b);
1059 if (
valid && Validator)
1084 Validator = validator;
1129#if OWL_PERSISTENT_STREAMS
1137 auto t = GetObject();
1156TEdit::Streamer::Write(opstream&
os)
const
1158 auto t = GetObject();
#define WARN(condition, message)
#define PRECONDITION(condition)
The clipboard class encapsulates the methods for the clipboard object of Windows.
bool IsClipboardFormatAvailable(uint format) const
Indicates if the format specified in format exists for use in the Clipboard.
Base class for an extensible interface for auto enabling/disabling of commands (menu items,...
A TEdit is an interface object that represents an edit control interface element.
ObjectWindows dynamic-link libraries (DLLs) construct an instance of TModule, which acts as an object...
TNmUpDown is a wrapper of the NM_UPDOWN structure sent with notifications from an 'UpDown' control.
An interface object that represents a static text interface element.
tstring GetText() const
String-aware overload.
int GetTextLen() const
Return the current length of the text in the control, excluding the terminating null character.
void SetText(LPCTSTR str)
Sets the static control's text to the string supplied in str.
auto Transfer(void *buffer, TTransferDirection) -> uint override
TWindow override Transfers TextLimit characters of text to or from a transfer buffer pointed to by bu...
Classes that inherit from TStreamableBase are known as streamable classes (their objects can be writt...
A streamable class, TValidator defines an abstract data validation object.
virtual uint Transfer(TCHAR *text, void *buffer, TTransferDirection direction)
Allows a validator to set and read the values of its associated edit control.
bool Valid(LPCTSTR str, TWindow *owner=0)
Returns true if IsValid returns true.
bool HasOption(int option)
Gets the Options bits. Returns true if a specified option is set.
virtual bool IsValidInput(TCHAR *input, bool suppressFill)
Checks current input against validator.
virtual void Error(TWindow *owner)
Error is an abstract function called by Valid when it detects that the user has entered invalid infor...
virtual bool IsValid(LPCTSTR input)
Checks input against validator for completeness. Never modifies input.
virtual int Adjust(tstring &text, int &begPos, int &endPos, int amount)
Adjusts the 'value' of the text, given a cursor position and an amount.
Type-safe encapsulation of a Windows class name, a union between ATOM and LPCTSTR.
TWindow, derived from TEventHandler and TStreamableBase, provides window-specific behavior and encaps...
HWND SetFocus()
Sets the keyboard focus to current window and activates the window that receives the focus by sending...
tstring LoadString(uint id) const
TWindow * GetParent() const
Retrieves the OWL object of the parent window. If none exists, returns 0.
bool IsWindowEnabled() const
Returns true if the window is enabled.
long GetWindowLong(int index) const
Retrieves information about the window depending on the value stored in index.
TWindow * GetParentO() const
Return the OWL's parent for this window.
uint EvGetDlgCode(const MSG *msg)
The default message handler for WM_GETDLGCODE.
void EnableTransfer()
Enables the transfer mechanism, which allows state data to be transferred between the window and a tr...
void EvKillFocus(HWND hWndGetFocus)
Handle WM_KILLFOCUS so that we can have a parent window hold onto our Handle and possibly restore foc...
bool ModifyStyle(uint32 offBits, uint32 onBits, uint swpFlags=0)
Modifies the style bits of the window.
TResult DefaultProcessing()
Handles default processing of events, which includes continued processing of menu/accelerators comman...
int GetDlgCtrlID() const
Returns the ID of the control.
virtual bool CanClose()
Use this function to determine if it is okay to close a window.
void EvSetFocus(HWND hWndLostFocus)
The default message handler for WM_SETFOCUS.
bool PostMessage(TMsgId, TParam1=0, TParam2=0)
Posts a message (msg) to the window in the application's message queue.
int MessageBox(LPCTSTR text, LPCTSTR caption=0, uint flags=MB_OK) const
Creates and displays a message box that contains a message (text), a title (caption),...
TResult SendMessage(TMsgId, TParam1=0, TParam2=0) const
Sends a message (msg) to a specified window or windows.
virtual void SetupWindow()
Performs setup following creation of an associated MS-Windows window.
void EvChar(uint key, uint repeatCount, uint flags)
The default message handler for WM_CHAR.
bool ModifyExStyle(uint32 offBits, uint32 onBits, uint swpFlags=0)
Modifies the style bits of the window.
static HWND GetFocus()
Gets a handle to the window that has the focus.
HWND THandle
TWindow encapsulates an HWND.
HWND GetHandle() const
Returns the handle of the window.
int GetWindowTextLength() const
Returns the length, in characters, of the specified window's title.
ipstream, a specialized input stream derivative of pstream, is the base class for reading (extracting...
#define EV_UDN_DELTAPOS(id, method)
bool method(TNmUpDown&)
Definition of class TEdit.
#define DEFINE_RESPONSE_TABLE1(cls, base)
Macro to define a response table for a class with one base.
#define IMPLEMENT_STREAMABLE1(cls, base1)
TRequireOption GetRequired() const
Returns the requirement option for the edit control.
void SetValidator(TValidator *validator)
Sets a new validator for this control, can be 0. Cleans up the old validator.
bool DeleteSubText(int startPos, int endPos)
Deletes the text between the starting and ending positions specified by startPos and endPos,...
auto CanClose() -> bool override
Checks to see if all child windows can be closed before closing the current window.
void CmPasteEnable(TCommandEnabler &commandHandler)
This function is called for the Paste menu item to determine whether or not the item is enabled.
bool DeleteSelection()
Deletes the currently selected text, and returns false if no text is selected.
void EvChildInvalid(HWND)
Handler for input validation message sent by parent.
void EvSetFocus(HWND hWndLostFocus)
Handle the set focus message and make sure the anti-oscillation flag is cleared.
void SetMemHandle(HLOCAL localMem)
Sets the memory handle for the edit control's buffer.
bool EvUpDown(TNmUpDown &)
Handles up-down messages from an up-down control and adjusts contents if there is a validator to help...
void ValidatorError()
Handles validation errors that occur as a result of validating the edit control.
virtual void LimitText(int)
Limit the amount of new text that can be entered in the edit control.
bool DeleteLine(int lineNumber)
Deletes the text in the line specified by lineNumber in a multiline edit control.
void EvChar(uint key, uint repeatCount, uint flags)
Validates Self whenever a character is entered.
void EvKillFocus(HWND hWndGetFocus)
Validates this whenever the focus is about to be lost.
virtual tstring GetTextRange(const TRange &) const
Retrieves a specified range of text from the edit control.
HLOCAL GetMemHandle() const
Return the memory handle for the edit control's buffer.
void SetupWindow() override
void ENErrSpace()
EN_ERRSPACE.
auto GetWindowClassName() -> TWindowClassName override
Return name of predefined Windows edit class.
bool IsValid(bool reportErr=false)
Always returns true if the TEdit object does not have an associated TValidator object (i....
void CmModEnable(TCommandEnabler &commandHandler)
This function is called for the Undo menu item to determine whether or not the item is enabled.
void EvKeyDown(uint key, uint repeatCount, uint flags)
EvKeyDown translates the virtual key code into a movement.
void UnlockBuffer(LPCTSTR buffer, bool updateHandle=false)
Unlock the edit control's buffer locked by LockBuffer.
virtual int GetLineFromPos(int charPos) const
Return the line number associated with character index "CharPos".
bool IsRequired() const
Returns true if a value is required for the edit control.
int GetLineLength(int lineNumber) const
Return the length of line number "lineNumber".
auto Transfer(void *buffer, TTransferDirection) -> uint override
Transfers state information for TEdit controls.
uint EvGetDlgCode(const MSG *)
Responds to WM_GETDLGCODE messages that are sent to a dialog box associated with a control.
virtual void GetSubText(TCHAR *textBuf, int startPos, int endPos) const
Deprecated. Use GetTextRange instead.
void CmSelectEnable(TCommandEnabler &commandHandler)
This function is called for Cut/Copy/Delete menu items to determine whether or not the item is enable...
bool IsModified() const
Returns true if the user has changed the text in the edit control.
TCHAR * LockBuffer(uint newSize=0)
Lock and unlock this edit control's buffer.
~TEdit() override
Destructor for a TEdit control.
int GetNumLines() const
Return the number of lines in the associated edit control.
void Clear() override
Override TStatic virtual member functions.
void CmCharsEnable(TCommandEnabler &commandHandler)
This function is called for the Clear menu item to determine whether or not the item is enabled.
virtual int Search(int startPos, LPCTSTR text, bool caseSensitive=false, bool wholeWord=false, bool up=false)
searches for and selects the given text and returns the offset of the text or -1 if the text is not f...
int GetLineIndex(int lineNumber) const
In a multiline edit control, GetLineIndex returns the number of characters that appear before the lin...
virtual bool SetSelection(int startPos, int endPos)
Select the characters in the range "startPos .. endPos".
TRange GetSelection() const
Functional style overload.
TEdit(TWindow *parent, int id, LPCTSTR text, int x, int y, int w, int h, uint textLimit=0, bool multiline=false, TModule *=nullptr)
Constructs an edit control object with a parent window (parent).
bool GetLine(TCHAR *str, int strSize, int lineNumber) const
Return the text of line number "lineNumber" (0-terminated)
@ voTransfer
Option to perform conversion & transfer.
@ voOnAppend
Option to only validate input on appending.
TTransferDirection
The TTransferDirection enum describes the constants that the transfer function uses to determine how ...
@ tdSetData
Set data from the buffer into the window.
Object Windows Library (OWLNext Core)
TWindow * GetWindowPtr(HWND, const TApplication *)
Raw function to retrieve a TWindow pointer given an HWND from the a given app, or any app (app==0).
LPARAM TParam2
Second parameter type.
tstring CopyText(int size, TGetText get_text)
Copies text from a C-string (null-terminated character array) into a string object,...
auto GetCommCtrlVersion() -> DWORD
Returns the version number of the Common Control library (ComCtl32.dll).
WPARAM TParam1
First parameter type.
#define CONST_CAST(targetType, object)
Definition of class TString, a flexible universal string envelope class.
Represents a half-open range of positions in the edit control, e.g.
Definition of class TUpDown.
#define EV_COMMAND_ENABLE(id, method)
Response table entry for enabling a command.
#define EV_NOTIFY_AT_CHILD(notifyCode, method)
Response table entry for a child ID notification handled at the child.
#define EV_COMMAND(id, method)
Response table entry for a menu/accelerator/push button message.