12#if defined(__BORLANDC__)
33# if defined(MSFTEDIT_CLASS)
34# define OWL_USERICHEDIT41
39#if defined(OWL_USERICHEDIT41)
40const tchar RichEdit41DllName[] =
_T(
"Msftedit.dll");
57 memset(
this, 0,
sizeof(CHARFORMAT2));
59 cbSize =
sizeof(::CHARFORMAT);
61 cbSize =
sizeof(CHARFORMAT2);
75 dwEffects |= CFE_BOLD;
77 dwEffects &= ~CFE_BOLD;
88 dwEffects |= CFE_ITALIC;
90 dwEffects &= ~CFE_ITALIC;
99 dwMask |= CFM_UNDERLINE;
101 dwEffects |= CFE_UNDERLINE;
103 dwEffects &= ~CFE_UNDERLINE;
112 dwMask |= CFM_STRIKEOUT;
114 dwEffects |= CFE_STRIKEOUT;
116 dwEffects &= ~CFE_STRIKEOUT;
125 dwMask |= CFM_PROTECTED;
127 dwEffects |= CFE_PROTECTED;
129 dwEffects &= ~CFE_PROTECTED;
140 if ((dwMask & CFM_COLOR) && !(dwEffects & CFE_AUTOCOLOR))
141 return TColor(crTextColor);
155 dwEffects |= CFE_AUTOCOLOR;
157 dwEffects &= ~CFE_AUTOCOLOR;
171 szFaceName[0] =
_T(
'\0');
172 ::_tcsncat(szFaceName, name, LF_FACESIZE - 1);
197 bPitchAndFamily = pitchFam;
217 dwMask |= CFM_OFFSET;
230 memset(&lf, 0,
sizeof(LOGFONT));
232 if (dwMask & CFM_SIZE)
233 lf.lfHeight = yHeight/-20;
235 if (dwMask & CFM_BOLD)
236 lf.lfWeight = dwEffects & CFE_BOLD ? FW_BOLD : FW_NORMAL;
238 if (dwMask & CFM_ITALIC)
239 lf.lfItalic =
static_cast<uint8>(dwEffects & CFE_ITALIC ? TRUE : FALSE);
241 if (dwMask & CFM_UNDERLINE)
242 lf.lfUnderline =
static_cast<uint8>(dwEffects & CFE_UNDERLINE ? TRUE : FALSE);
244 if (dwMask & CFM_FACE) {
245 lf.lfPitchAndFamily = bPitchAndFamily;
246 lf.lfFaceName[0] =
_T(
'\0');
247 ::_tcsncat(lf.lfFaceName, szFaceName, LF_FACESIZE - 1);
250 lf.lfCharSet = DEFAULT_CHARSET;
251 lf.lfQuality = DEFAULT_QUALITY;
261 dwMask = (CFM_SIZE | CFM_BOLD | CFM_ITALIC | CFM_OFFSET|
262 CFM_STRIKEOUT | CFM_UNDERLINE | CFM_FACE);
264 yHeight = lf.lfHeight * -20;
266 if (FW_BOLD == lf.lfWeight)
267 dwEffects |= CFE_BOLD;
269 dwEffects |= CFE_ITALIC;
271 dwEffects |= CFE_STRIKEOUT;
273 dwEffects |= CFE_UNDERLINE;
275 bPitchAndFamily = lf.lfPitchAndFamily;
276 szFaceName[0] =
_T(
'\0');
277 ::_tcsncat(szFaceName, lf.lfFaceName, LF_FACESIZE - 1);
286 dwMask |= CFM_WEIGHT;
296 dwMask |= CFM_SPACING;
307 if ((dwMask & CFM_BACKCOLOR)&& !(dwEffects & CFE_AUTOBACKCOLOR))
308 return TColor(crBackColor);
318 dwMask |= CFM_BACKCOLOR;
320 dwEffects |= CFE_AUTOBACKCOLOR;
322 dwEffects &= ~CFE_AUTOBACKCOLOR;
363 dwMask |= CFM_UNDERLINETYPE;
364 bUnderlineType = utype;
373 dwMask |= CFM_ANIMATION;
383 dwMask |= CFM_REVAUTHOR;
419 hdcTarget = targetDC;
467 memset(
this, 0,
sizeof(PARAFORMAT2));
469 cbSize =
sizeof(PARAFORMAT);
471 cbSize =
sizeof(PARAFORMAT2);
484 memset(
this, 0,
sizeof(PARAFORMAT2));
486 cbSize =
sizeof(PARAFORMAT);
488 cbSize =
sizeof(PARAFORMAT2);
512 dwMask |= PFM_NUMBERING;
525 dwMask |= PFM_STARTINDENT;
527 dwMask |= PFM_OFFSETINDENT;
529 dwMask &= ~PFM_OFFSETINDENT;
531 dxStartIndent = start;
540 dwMask |= PFM_RIGHTINDENT;
541 dxRightIndent = indent;
552 dwMask |= PFM_OFFSET;
565 dwMask |= PFM_ALIGNMENT;
577 dwMask |= PFM_TABSTOPS;
579 for (
int i=0; i<cnt; i++)
580 rgxTabs[i] = *tabs++;
589 dwMask |= PFM_SPACEBEFORE;
590 dySpaceBefore = space;
599 dwMask |= PFM_SPACEAFTER;
600 dySpaceAfter = space;
609 dwMask |= PFM_LINESPACING;
610 dyLineSpacing = space;
611 bLineSpacingRule = rule;
631 dwMask |= PFM_SHADING;
632 wShadingWeight = wight;
633 wShadingStyle = style;
642 dwMask |= PFM_NUMBERINGSTART;
643 wNumberingStart = start;
652 dwMask |= PFM_NUMBERINGSTYLE;
653 wNumberingStyle = style;
662 dwMask |= PFM_NUMBERINGTAB;
672 dwMask |= PFM_BORDER;
673 wBorderSpace = space;
674 wBorderWidth = width;
710 int x,
int y,
int w,
int h,
714 TEditFile(parent, id, text, x, y, w, h, fileName, module)
730 ModifyStyle(ES_LOWERCASE|ES_PASSWORD|ES_OEMCONVERT|ES_UPPERCASE|ES_AUTOHSCROLL,
731 ES_LEFT|WS_BORDER|WS_TABSTOP);
741 int x,
int y,
int w,
int h,
745 :
TEditFile(parent, id, text, x, y, w, h, fileName, module)
761 ModifyStyle(ES_LOWERCASE|ES_PASSWORD|ES_OEMCONVERT|ES_UPPERCASE|ES_AUTOHSCROLL,
762 ES_LEFT|WS_BORDER|WS_TABSTOP);
792 TParam1 a1 = selection ? SCF_SELECTION : 0;
860 if (cf.dwMask & mask) {
861 if (cf.dwEffects & effects)
891 cf.dwMask = CFM_SIZE;
892 if (((cf.yHeight + 20*pointSizeDelta) <= (
MaxPointSize*20)) &&
893 ((cf.yHeight + 20*pointSizeDelta) >= (
MinPointSize*6))) {
894 cf.yHeight += 20*pointSizeDelta;
931 WARN(
true,
_T(
"TRichEdit::GetSelRange is deprecated. Use GetSelection instead."));
994 gtl.flags = GTL_DEFAULT;
1000 gtl.codepage = CP_ACP;
1028 WARN(
true,
_T(
"TRichEdit::GetTextRange(const TCharRange&, LPTSTR) is deprecated. Use GetTextRange(const TRange&) instead."));
1037struct TRichEditGetTextRange
1043 int operator()(LPTSTR buf,
int)
1045 TTextRange tr(range, buf);
1046 return static_cast<int>(
CONST_CAST(TRichEdit*, &edit)->SendMessage(EM_GETTEXTRANGE, 0,
TParam2(&tr)));
1067 const int begin = r.
cpMin;
1077 if (begin == 0 && end == -1)
1081 else if (begin < 0 || end < 0)
1083 WARN(
true,
_T(
"Arguments out of range"));
1086 else if (begin == end)
1088 WARN(
true,
_T(
"Empty range"));
1091 else if (begin > end)
1093 WARN(
true,
_T(
"Inverted range"));
1105 end = std::min(end, n);
1106 const int range_length = end - begin;
1111 CHECK(begin >= 0 && end >= 0 && begin < n && end <= n);
1113 return CopyText(range_length, TRichEditGetTextRange(*
this, adjusted_range));
1123 WARN(
true,
_T(
"TRichEdit::GetSubText is deprecated. Use GetTextRange instead."));
1140struct TRichEditGetSelectedText
1143 TRichEditGetSelectedText(
const TRichEdit& e) : edit(e){}
1145 int operator()(LPTSTR buf,
int)
1146 {
return static_cast<int>(
CONST_CAST(TRichEdit*, &edit)->SendMessage(EM_GETSELTEXT, 0,
TParam2(buf)));}
1156 return (n > 0) ?
CopyText(n, TRichEditGetSelectedText(*
this)) :
tstring();
1203 bool wholeWord,
bool up)
1205 if (!text || !text[0])
1208 if (startPos == -1) {
1211 startPos = up ? sBeg : sEnd;
1219 uint flags = (caseSensitive ? FR_MATCHCASE : 0) |
1220 (wholeWord ? FR_WHOLEWORD : 0) |
1222 int index =
FindText(flags, findText);
1298 static_cast<int>(
SendMessage(EM_GETIMECOMPMODE)) :
1319 static_cast<int>(
SendMessage(EM_GETLANGOPTIONS)) :
1332 if(mode & TM_PLAINTEXT)
1334 else if(mode & TM_RICHTEXT)
1346 IsRTF() ? TM_RICHTEXT : TM_PLAINTEXT;
1563 0,
TParam2((
void * *)&pInterface)) != 0;
1669 commandHandler.
Enable(sPos != ePos);
1734#if defined(OWL_USERICHEDIT41)
1812 is.read(&tempBuff[0], cb);
1813 LONG n =
static_cast<LONG
>(is.gcount());
1814 ::WideCharToMultiByte(CP_ACP, 0, &tempBuff[0], n,
reinterpret_cast<char*
>(pbBuff), cb, NULL, NULL);
1816 is.read(
reinterpret_cast<char*
>(pbBuff), cb);
1817 LONG n =
static_cast<LONG
>(is.gcount());
1839 streampos pCnt = os.tellp();
1843 ::MultiByteToWideChar(CP_ACP, 0, (
char*)pbBuff, cb, tempBuff, cb);
1844 os.write(tempBuff, cb);
1847 os.write((
char*)pbBuff, cb);
1852 *pcb =
static_cast<LONG
>(os.tellp() - pCnt);
1885 DWORD_PTR cookie =
reinterpret_cast<DWORD_PTR
>(&is);
1888 return edStrm.dwError == 0;
1913 DWORD_PTR cookie =
reinterpret_cast<DWORD_PTR
>(&os);
1916 return edStrm.dwError == 0;
1981#if OWL_PERSISTENT_STREAMS
1995TRichEdit::Streamer::Write(opstream& os)
const
2007#if defined(OWL_USERICHEDIT41)
2019static int CheckREVersion()
2021 TErrorMode loadMode(SEM_NOOPENFILEERRORBOX|SEM_FAILCRITICALERRORS);
2023#if defined(OWL_USERICHEDIT41)
2024 HINSTANCE Handle41 = ::LoadLibrary(RichEdit41DllName);
2025 if (Handle41 > HINSTANCE(HINSTANCE_ERROR))
2027 ::FreeLibrary(Handle41);
2033 if (Handle <= HINSTANCE(HINSTANCE_ERROR))
2035 ::FreeLibrary(Handle);
2044 static int REVersion = force_old ? 1 : CheckREVersion();
2048#if defined(_BUILDOWLDLL)
#define WARN(condition, message)
#define PRECONDITION(condition)
TCharRange encapsulates the CHARRANGE structure, which specifies a range of characters in a rich edit...
The clipboard class encapsulates the methods for the clipboard object of Windows.
int CountClipboardFormats() const
Returns a count of the number of types of data formats the Clipboard can use.
bool IsClipboardFormatAvailable(uint format) const
Indicates if the format specified in format exists for use in the Clipboard.
Class wrapper for management of color values.
static const TColor None
not-a-color
TColor()
Construct a null color.
static const TColor SysWindowText
The symbolic system color value for text in every window.
static const TColor SysWindow
The symbolic system color value for the background of each window.
Base class for an extensible interface for auto enabling/disabling of commands (menu items,...
virtual void Enable(bool enable=true)
Enables or disables the command sender.
TDllLoader<> provides an easy way to load one instance of a DLL on demand.
TEditFile is a file-editing window.
LPCTSTR GetFileName() const
Return the filename for this buffer.
TOpenSaveDialog::TData & GetFileData()
Return the FileData data member used for the common dialogs.
void SetupWindow() override
Creates the edit window's Editor edit control by calling TEditFile::SetupWindow().
TEditFile(TWindow *parent=nullptr, int id=0, LPCTSTR text=nullptr, int x=0, int y=0, int w=0, int h=0, LPCTSTR fileName=nullptr, TModule *module=nullptr)
Constructs a TEditFile window given the parent window, resource ID (Id), text, file name,...
TEditStream encapsulates the EDITSTREAM structure, which contains information about a data stream use...
Simple encapsulation of the SetErrorMode call.
TFindText encapsulates the FINDTEXT structure, which contains information about text to search for in...
ObjectWindows dynamic-link libraries (DLLs) construct an instance of TModule, which acts as an object...
void SetFilter(LPCTSTR filter=nullptr)
Makes a copy of the filter list used to display the file names.
TRect is a mathematical class derived from tagRect.
TRichEdit encapsulates a rich edit control, a window in which a user can enter, edit and format text.
bool ToggleCharAttribute(ulong mask, uint32 effects)
Toggles a set of character attributes.
bool DisplayBand(TRect &)
bool ReadFromStream(tistream &, uint format=SF_RTF)
< String-aware overload
ulong StreamOut(uint format, TEditStream &)
bool SetCharFormat(const TCharFormat &, uint flags=SCF_SELECTION)
Sets the character formatting of a rich edit control.
bool WriteToStream(tostream &, uint format=SF_RTF)
int GetTextRange(TTextRange &) const
Retrieves a specified range of text from the rich edit control.
auto GetLineFromPos(int charPos) const -> int override
void CeEditClear(TCommandEnabler &commandHandler)
ulong GetSelectionType() const
Returns the selection type of the rich edit control.
void CeHasSelect(TCommandEnabler &commandHandler)
void EvKillFocus(HWND hWndGetFocus)
WM_KILLFOCUS handler to bypass TEdit's handler (which caters to validators).
int GetLangOptions() const
auto SetSelection(int startPos, int endPos) -> bool override
Selects a range of characters in the rich edit control.
void GetSelRange(TCharRange &) const
Retrieves the starting and ending character positions of the selection of the richedit control.
void CeEditPaste(TCommandEnabler &commandHandler)
auto Read(LPCTSTR fileName=nullptr) -> bool override
void CeEditUndo(TCommandEnabler &commandHandler)
@ Partly
Part of the selection has the attribute.
@ Yes
The attribute is absent from the selection.
@ No
The whole selection has the attribute.
void LimitText(int maxValue) override
Sets an upper limit to the amount of text in the richedit control.
void GetSelection(int &startPos, int &endPos) const override
Retrieves the starting and ending character position of the selection in the rich edit control.
bool SetParaFormat(const TParaFormat &)
Sets the paragraph formatting of the current selection of the rich edit control.
tstring GetSelectedText() const
String-aware overload.
auto Write(LPCTSTR fileName=nullptr) -> bool override
< String-aware overload
auto PosFromChar(uint charIndex) -> uint32 override
int SetSelRange(const TCharRange &)
Selects a range of characters in the rich edit control.
ulong GetParaFormat(TParaFormat &) const
Retrieves the paragraph formatting of the current selection of the rich edit control.
ulong GetEventMask() const
void SetTextMode(int mode)
int GetTextLength() const
bool SetTargetDevice(HDC, int lineWidth)
void PasteSpecial(uint format)
bool EnableAutoURL(bool enable=true)
bool ChangeCharPointSize(int pointSizeDelta)
Increases or decreases (using a positive or negative value respectively) the point size of the curren...
auto Transfer(void *buffer, TTransferDirection) -> uint override
void HideSelection(bool hide, bool changeStyle)
Shows or hides the selection in the rich edit control.
void GetSubText(TCHAR *textBuf, int startPos, int endPos) const override
Retrieves a specified range of text from the rich edit control.
TColor SetBkgndColor(const TColor &=TColor::None)
Sets the background color of the rich edit control.
void EvSetFocus(HWND hWndLostFocus)
WM_SETFOCUS handler to bypass TEdit's handler (which caters to validators).
int FindWordBreak(uint code, int start)
uint HasCharAttribute(ulong mask, uint32 effects)
Function returns whether or not the current selection has a particular attribute.
bool SetOleInterface(IRichEditOleCallback *)
bool HasSelection() const
Returns true if the rich edit control has an active selection.
void SetUndoLimit(int maxnum)
void EvKeyDown(uint key, uint repeatCount, uint flags)
WM_GETDLGCODE handler to bypass TEdit's handler (which caters to validators).
TRichEdit(TWindow *parent, int id, LPCTSTR text, int x, int y, int w, int h, LPCTSTR fileName=nullptr, TModule *module=nullptr)
Constructor for a TRichEdit object.
int FindText(uint flags, const TFindText &)
Finds text within the rich edit control.
void SetupWindow() override
Updates the list of filters describing files which can be opened by the rich edit control.
void EvChar(uint key, uint repeatCount, uint flags)
WM_CHAR handler to bypass TEdit's handler (which caters to validators).
auto CharFromPos(int16 x, int16 y) -> uint32 override
uint EvGetDlgCode(const MSG *)
WM_GETDLGCODE handler to bypass TEdit's handler (which caters to validators).
auto Search(int startPos, LPCTSTR text, bool caseSensitive=false, bool wholeWord=false, bool up=false) -> int override
ulong StreamIn(uint format, TEditStream &)
ulong SetEventMask(ulong msk)
ulong GetCharFormat(TCharFormat &, bool selection=false) const
Retrieves the current character formatting in an edit control.
bool CanPaste(uint format) const
void SetLangOptions(int options)
bool GetOleInterface(IRichEditOle *&) const
static int GetVersion(bool force_old=false)
TTextRange encapsulates the TEXTRANGE structure, which contains information about a range of text in ...
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...
tstring LoadString(uint id) const
virtual auto GetWindowClassName() -> TWindowClassName
TModule * GetModule() const
Returns a pointer to the module object.
uint EvGetDlgCode(const MSG *msg)
The default message handler for WM_GETDLGCODE.
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...
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.
int GetWindowTextLength() const
Returns the length, in characters, of the specified window's title.
static void Raise()
Constructs a TXCommCtrl exception from scratch, and throws it.
ipstream, a specialized input stream derivative of pstream, is the base class for reading (extracting...
#define DEFINE_RESPONSE_TABLE1(cls, base)
Macro to define a response table for a class with one base.
void ReadBaseObject(Base *base, ipstream &in)
void WriteBaseObject(Base *base, opstream &out)
void ClearModify()
Resets the change flag of the edit control causing IsModified to return false.
bool CanUndo() const
Returns true if it is possible to undo the last edit.
int GetLineLength(int lineNumber) const
Return the length of line number "lineNumber".
void Undo()
Undoes the last edit.
int GetNumLines() const
Return the number of lines in the associated edit control.
void Clear() override
Override TStatic virtual member functions.
TRange GetSelection() const
Functional style overload.
TModule(const tstring &name, bool shouldLoad=true, bool mustLoad=true, bool addToList=true)
Constructs a TModule object that is used as an alias for a DLL.
static bool IsAvailable()
static TRichEditModule * Dll()
TTransferDirection
The TTransferDirection enum describes the constants that the transfer function uses to determine how ...
Object Windows Library (OWLNext Core).
const tchar RichEdit20DllName[]
uint32 MkUint32(uint16 lo, uint16 hi)
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,...
DWORD CALLBACK RichEditStrmOutWithOstream(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
WPARAM TParam1
First parameter type.
bool IsRepresentable(U v)
Helper function for testing for integer truncations.
const tchar RichEditDllName[]
EV_COMMAND_ENABLE(CM_FILENEW, CeFileNew)
DWORD CALLBACK RichEditStrmInWithIStream(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
IMPLEMENT_STREAMABLE1(TApplication, TModule)
EV_COMMAND(IDOK, CmOkCancel)
#define CONST_CAST(targetType, object)
Definition of class TRichEdit.
Represents a half-open range of positions in the edit control, e.g.