10#if !defined(OWL_EDIT_H)
14#if defined(BI_HAS_PRAGMA_ONCE)
36 TEdit(
TWindow* parent,
int id, LPCTSTR text,
int x,
int y,
int w,
int h,
37 uint textLimit = 0,
bool multiline =
false,
TModule* =
nullptr);
39 uint textLimit = 0,
bool multiline =
false,
TModule* =
nullptr);
61 bool GetLine(LPTSTR str,
int strSize,
int lineNumber)
const;
63 virtual void GetSelection(
int& startPos,
int& endPos)
const;
71 virtual void GetSubText(LPTSTR textBuf,
int startPos,
int endPos)
const;
86 void UnlockBuffer(LPCTSTR buffer,
bool updateHandle =
false);
94 bool DeleteLine(
int lineNumber);
95 bool DeleteSelection();
96 virtual bool SetSelection(
int startPos,
int endPos);
105 void Scroll(
int horizontalUnit,
int verticalUnit);
113 void Insert(LPCTSTR str);
115 virtual int Search(
int startPos, LPCTSTR text,
bool caseSensitive=
false,
bool wholeWord=
false,
bool up=
false);
116 int Search(
int startPos,
const tstring& text,
bool caseSensitive=
false,
bool wholeWord=
false,
bool up=
false)
117 {
return Search(startPos, text.c_str(), caseSensitive, wholeWord, up);}
119 void GetRect(
TRect& frmtRect)
const;
120 void SetRect(
const TRect& frmtRect);
121 void SetRectNP(
const TRect& frmtRect);
122 bool FormatLines(
bool addEOL);
123 void SetTabStops(
int numTabs,
const int * tabs);
125 virtual void LimitText(
int);
126 virtual int GetLimitText()
const;
128 HLOCAL GetMemHandle()
const;
129 void SetMemHandle(HLOCAL localMem);
131 void SetPasswordChar(
uint ch);
133 int GetFirstVisibleLine()
const;
134 void SetReadOnly(
bool readOnly);
135 uint GetPasswordChar()
const;
137 EDITWORDBREAKPROC GetWordBreakProc()
const;
138 void SetWordBreakProc(EDITWORDBREAKPROC proc);
142 bool CanUndo()
const;
143 void EmptyUndoBuffer();
145 virtual void Paste();
152 bool IsValid(
bool reportErr =
false);
155 void ValidatorError();
156 bool IsRefocusing()
const;
162 void SetNotRequired();
163 void SetRequired(TRequireOption option = roNonBlank);
164 TRequireOption GetRequired()
const;
165 bool IsRequired()
const;
170 void SetLeftMargin(
uint16 margin);
171 void SetRightMargin(
uint16 margin);
172 void SetMarginUseFontInfo();
173 uint32 GetMargins()
const;
184 void Clear()
override;
213 void SetupWindow()
override;
217 uint EvGetDlgCode(
const MSG*);
218 void EvSetFocus(HWND hWndLostFocus);
219 void EvKillFocus(HWND hWndGetFocus);
221 auto CanClose() ->
bool override;
226 void EvChildInvalid(HWND);
228 int ScrollText(
int how);
237 TRequireOption Requirement;
245 static TEdit* ValidatorReFocus;
352 return ValidatorReFocus ==
this;
412 return static_cast<int>(
CONST_CAST(
TEdit*,
this)->SendMessage(EM_GETLINECOUNT));
421 return static_cast<bool>(
CONST_CAST(
TEdit*,
this)->SendMessage(EM_GETMODIFY));
433 return SendMessage(EM_SETSEL, startPos, endPos) != 0;
475 return static_cast<int>(
CONST_CAST(
TEdit*,
this)->SendMessage(EM_LINEFROMCHAR, charPos));
486 return static_cast<int>(
CONST_CAST(
TEdit*,
this)->SendMessage(EM_LINEINDEX, lineNumber));
623 return reinterpret_cast<HLOCAL
>(
CONST_CAST(
TEdit*,
this)->SendMessage(EM_GETHANDLE));
643 return static_cast<int>(
CONST_CAST(
TEdit*,
this)->SendMessage(EM_GETFIRSTVISIBLELINE));
672 return reinterpret_cast<EDITWORDBREAKPROC
>(
CONST_CAST(
TEdit*,
this)->SendMessage(EM_GETWORDBREAKPROC));
693 return static_cast<bool>(
CONST_CAST(
TEdit*,
this)->SendMessage(EM_CANUNDO));
714 SendMessage(EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN,
MkUint32(EC_USEFONTINFO, EC_USEFONTINFO));
728 return static_cast<int>(
CONST_CAST(
TEdit*,
this)->SendMessage(EM_GETLIMITTEXT));
748 Requirement = option;
#define PRECONDITION(condition)
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.
TRect is a mathematical class derived from tagRect.
TStatic(TWindow *parent, int id, LPCTSTR title, int x, int y, int w, int h, uint textLen=0, TModule *=nullptr)
Constructs a static control object with the supplied parent window (parent), control ID (Id),...
A streamable class, TValidator defines an abstract data validation object.
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...
TResult SendMessage(TMsgId, TParam1=0, TParam2=0) const
Sends a message (msg) to a specified window or windows.
HWND THandle
TWindow encapsulates an HWND.
HWND GetHandle() const
Returns the handle of the window.
#define DECLARE_RESPONSE_TABLE(cls)
#define DECLARE_STREAMABLE_OWL(cls, ver)
#define DECLARE_STREAMABLE_INLINES(cls)
TRequireOption GetRequired() const
Returns the requirement option for the edit control.
bool DeleteSubText(int startPos, int endPos)
Deletes the text between the starting and ending positions specified by startPos and endPos,...
void SetLeftMargin(uint16 margin)
void SetReadOnly(bool readOnly)
Sets the edit control to be read-only or read-write.
void SetRect(const TRect &frmtRect)
Sets the formatting rectangle for a multiline edit control.
bool DeleteSelection()
Deletes the currently selected text, and returns false if no text is selected.
void SetRightMargin(uint16 margin)
void ScrollCaret()
EM_SCROLLCARET.
EDITWORDBREAKPROC GetWordBreakProc() const
Get word-breaking procedure.
void Cut()
Deletes the currently selected text and copies it into the Clipboard.
void Scroll(int horizontalUnit, int verticalUnit)
Scroll the text by the specified horizontal and vertical amounts.
virtual void GetSelection(int &startPos, int &endPos) const
Return the starting and ending positions of the selected text.
void SetMemHandle(HLOCAL localMem)
Sets the memory handle for the edit control's buffer.
virtual uint32 PosFromChar(uint charIndex)
bool FormatLines(bool addEOL)
Indicates if the end-of-line characters (carriage return, linefeed) are to be added or removed from t...
virtual uint32 CharFromPos(int16 x, int16 y)
void CmEditCut()
CM_EDITCUT.
virtual void LimitText(int)
Limit the amount of new text that can be entered in the edit control.
void CmEditUndo()
CM_EDITUNDO.
virtual tstring GetTextRange(const TRange &) const
Retrieves a specified range of text from the edit control.
void CmEditClear()
CM_EDITCLEAR.
bool IsRefocusing() const
Return true when this edit control is attempting to regain focus after an EvKillFocus() with invalid ...
HLOCAL GetMemHandle() const
Return the memory handle for the edit control's buffer.
int LineUp()
EM_SCROLL, SB_LINEUP Scrolls up one line.
virtual void Paste()
Inserts text from the Clipboard into the edit control at the current text insertion point (cursor pos...
void SetMarginUseFontInfo()
void EmptyUndoBuffer()
If an operation inside the edit control can be undone, the edit control undo flag is set.
TValidator * GetValidator()
Return the validator associated with this edit control.
void Copy()
Copies the currently selected text into the Clipboard.
void GetRect(TRect &frmtRect) const
Gets the formatting rectangle of a multiline edit control.
void ClearModify()
Resets the change flag of the edit control causing IsModified to return false.
void UnlockBuffer(LPCTSTR buffer, bool updateHandle=false)
Unlock the edit control's buffer locked by LockBuffer.
void Insert(const tstring &str)
virtual int GetLineFromPos(int charPos) const
Return the line number associated with character index "CharPos".
bool CanUndo() const
Returns true if it is possible to undo the last edit.
int GetFirstVisibleLine() const
Indicates the topmost visible line in an edit control.
uint GetPasswordChar() const
Returns the character to be displayed in place of a user-typed character.
int LineDown()
EM_SCROLL, SB_LINEDOWN Scrolls down one line.
uint32 GetMargins() const
void SetNotRequired()
Sets the requirement option for the edit control to reflect a value is not required.
void Insert(LPCTSTR str)
Inserts the text supplied in str into the edit control at the current text insertion point (cursor po...
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".
void CmEditPaste()
CM_EDITPASTE.
auto Transfer(void *buffer, TTransferDirection) -> uint override
Transfers state information for TEdit controls.
int PageUp()
EM_SCROLL, SB_PAGEUP Scrolls up one page.
virtual void GetSubText(TCHAR *textBuf, int startPos, int endPos) const
Deprecated. Use GetTextRange instead.
void SetRequired(TRequireOption option=roNonBlank)
Sets the requirement option for the edit control.
bool IsModified() const
Returns true if the user has changed the text in the edit control.
void Undo()
Undoes the last edit.
TCHAR * LockBuffer(uint newSize=0)
Lock and unlock this edit control's buffer.
void CmEditCopy()
CM_EDITCOPY.
int GetNumLines() const
Return the number of lines in the associated edit control.
void Clear() override
Override TStatic virtual member functions.
bool SetSelection(const TRange &r)
void SetRectNP(const TRect &frmtRect)
Sets the formatting rectangle for a multiline edit control.
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...
virtual int GetCurrentPosition() const
Return the current caret position.
void SetWordBreakProc(EDITWORDBREAKPROC proc)
In a multiline edit control, SetWordBreakProc indicates that an application-supplied word-break funct...
void SetTabStops(int numTabs, const int *tabs)
Sets the tab stop positions in a multiline edit control.
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".
int Search(int startPos, const tstring &text, bool caseSensitive=false, bool wholeWord=false, bool up=false)
TRange GetSelection() const
Functional style overload.
TRange(int b=0, int e=-1)
int PageDown()
EM_SCROLL, SB_PAGEDOWN Scrolls down one page.
bool DeleteSubText(const TRange &r)
void SetPasswordChar(uint ch)
SetPasswordChar sets the character to be displayed in place of a user-typed character.
virtual int GetLimitText() const
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).
void CmEditDelete()
CM_EDITDELETE.
TTransferDirection
The TTransferDirection enum describes the constants that the transfer function uses to determine how ...
Object Windows Library (OWLNext Core).
uint32 MkUint32(uint16 lo, uint16 hi)
uint16 HiUint16(LRESULT r)
LPARAM TParam2
Second parameter type.
WPARAM TParam1
First parameter type.
uint16 LoUint16(LRESULT r)
LRESULT TResult
Result type.
#define CONST_CAST(targetType, object)
Definition of class TStatic, the class for static controls and base for any control that manages simp...
Represents a half-open range of positions in the edit control, e.g.