\ File: Editbox.f \ Author: Jeff Kelm \ Created: 02-Oct-1998 \ Updated: 15-Oct-1998 NEEDS WinBase.f \ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \ \\\ Generic Multiline Edit Control Class \ :Class GenericMultilineEdit abs NULL Call CreateWindowEx DUP PutHandle: self ?WinError \ set window font TRUE Handle: wFont WM_SETFONT SendMessage: self DROP \ set tab stops for window 'tabs rel>abs 1 EM_SETTABSTOPS SendMessage: self ?WinError \ set margins for window LeftMargin: self RightMargin: self MAKELONG EC_LEFTMARGIN EC_RIGHTMARGIN OR EM_SETMARGINS SendMessage: self DROP ;M :M SetText: ( szText) \ send text to control ;M :M GetText: ( szBuffer) \ send control text to buffer ;M :M Undo: ( -- ) \ Send WM_UNDO only if there is something to be undone 0 0 EM_CANUNDO SendMessage: self IF 0 0 WM_UNDO SendMessage: self ?WinError ELSE MB_OK Z" Undo notification" rel>abs Z" Nothing to undo." rel>abs GetHandle: self Call MessageBox DROP THEN ;M :M Cut: ( -- ) \ cut selected text to clipboard 0 0 WM_CUT SendMessage: self DROP ;M :M Copy: ( -- ) \ copy selected text to clipboard 0 0 WM_COPY SendMessage: self DROP ;M :M Paste: ( -- ) \ paste clipboard text to control 0 0 WM_PASTE SendMessage: self DROP ;M :M Clear: ( -- ) \ delete selected text (not to clipboard!) 0 0 WM_CLEAR SendMessage: self DROP ;M :M SetSelection: ( nEnd nStart -- ) \ set selection range EM_SETSEL SendMessage: self DROP ;M :M GetSelection: ( -- nEnd nStart) \ return selection range NULL NULL EM_GETSEL SendMessage: self DUP HIWORD SWAP LOWORD ;M :M SelectAll: ( -- ) \ select all the text in control -1 0 SetSelection: self DROP ;M :M RemoveSelection: ( -- ) \ remove any selection 0 -1 SetSelection: self DROP ;M :M GetCursor: ( -- n) \ return location of cursor (chars from start) GetSelection: self RemoveSelection: self GetSelection: self >R SetSelection: self R> DROP ;M :M ReadOnly: ( f -- ) 0 SWAP EM_SETREADONLY SendMessage: self ?WinError ;M :M Wrap: ( -- ) \ set control to wrap text ;M :M Unwrap: ( -- ) \ set control to scroll instead of wrap text ;M ;Class