home *** CD-ROM | disk | FTP | other *** search
- /*************************************************************************
- *
- * WTextBox -- Wrapper for the Windows 95 Textbox control.
- *
- *
- * Events:
- *
- * Change --
- *
- * DataAvailable --
- *
- * DataClose --
- *
- * DataOpen --
- *
- * DataRequest --
- *
- * Update --
- *
- *************************************************************************/
-
- #ifndef _WTEXTBOX_HPP_INCLUDED
- #define _WTEXTBOX_HPP_INCLUDED
-
- #ifndef _WNO_PRAGMA_PUSH
- #pragma pack(push,8);
- #pragma enum int;
- #endif
-
- #ifndef _WCONTROL_HPP_INCLUDED
- # include "wcontrol.hpp"
- #endif
- #ifndef _WDATATRG_HPP_INCLUDED
- # include "wdatatrg.hpp"
- #endif
-
- class WDataSource;
-
- enum WTextBoxScroll {
- WTBScrollLineUp,
- WTBScrollLineDown,
- WTBScrollPageUp,
- WTBScrollPageDown
- };
-
- //
- // Textbox Styles
- //
-
- #define WTextBoxDefault ((WStyle)0x50800080L) // WS_VISIBLE|WS_BORDER|ES_LEFT|ES_AUTOHSCROLL|WS_CHILD
-
- #define WTextBoxLeft ((WStyle)0x00000000L) // ES_LEFT
- #define WTextBoxCenter ((WStyle)0x00000001L) // ES_CENTER
- #define WTextBoxRight ((WStyle)0x00000002L) // ES_RIGHT
- #define WTextBoxMultiLine ((WStyle)0x00000004L) // ES_MULTILINE
- #define WTextBoxUpperCase ((WStyle)0x00000008L) // ES_UPPERCASE
- #define WTextBoxLowerCase ((WStyle)0x00000010L) // ES_LOWERCASE
- #define WTextBoxPassword ((WStyle)0x00000020L) // ES_PASSWORD
- #define WTextBoxAutoVScroll ((WStyle)0x00000040L) // ES_AUTOVSCROLL
- #define WTextBoxAutoHScroll ((WStyle)0x00000080L) // ES_AUTOHSCROLL
- #define WTextBoxNoHideSel ((WStyle)0x00000100L) // ES_NOHIDESEL
- #define WTextBoxOEMConvert ((WStyle)0x00000400L) // ES_OEMCONVERT
- #define WTextBoxReadOnly ((WStyle)0x00000800L) // ES_READONLY
- #define WTextBoxWantReturn ((WStyle)0x00001000L) // ES_WANTRETURN
- #define WTextBoxNumber ((WStyle)0x00002000L) // ES_NUMBER
-
- class WCMCLASS WTextBox : public WControl {
- WDeclareSubclass( WTextBox, WControl );
-
- public:
-
- WTextBox();
-
- ~WTextBox();
-
- /**************************************************************
- * Properties
- **************************************************************/
-
- // CanUndo
- //
- // Read-only property. Returns TRUE if the last edit operation
- // can be undone by calling the Undo method.
-
- WBool GetCanUndo() const;
-
- // DataColumns
-
- WString GetDataColumns() const;
- WBool SetDataColumns( const WString & cols );
-
- // DataSource
-
- WDataSource *GetDataSource() const;
- WBool SetDataSource( WDataSource *source );
-
- // FDXDataSource
-
- WBool SetFDXDataSource( WString * fdxDataSource );
-
- // EditSelection
- //
- // The current selection in the edit control. The
- // selection points start at 0 and occur between the characters.
- // When setting, set start=-1 to deselect everything,
- // or set end=-1 to select from start to end of text.
-
- WRange GetEditSelection() const;
- WBool SetEditSelection( const WRange & editSelection );
-
- // FirstCharacterIndex
- //
- // Read-only property. Returns the zero-based index of
- // the first visible character.
-
- WULong GetFirstCharacterIndex() const;
-
- // FirstLineIndex
- //
- // Read-only property. Returns the zero-based index of
- // the first visible line. (Always returns 0 for single
- // line text boxes.)
-
- WULong GetFirstLineIndex() const;
-
- // LineCount
- //
- // The number of lines in the control.
-
- WULong GetLineCount() const;
-
- // Caret position
- //
- // The position of caret
- //
- WBool SetCaretPosition(WInt pos, WBool scrollInfoView = FALSE);
- WULong GetCaretPosition() const;
-
- // Margins
- //
- // The margins for the multi line control.
- // If no parms are specified for the set, the margins
- // are reset to font margins.
-
- WBool SetMargins( const WRange & margins );
- WBool SetMargins();
- WRange GetMargins() const;
-
- // Modified
- //
- // If TRUE, text has been modified since the property
- // was cleared (it is initially cleared).
-
- WBool GetModified() const;
- WBool SetModified( WBool modified );
-
- // PasswordCharacter
- //
- // Get/set the password character. Note that 16-bit
- // values are used for DBCS/Unicode.
-
- WUShort GetPasswordCharacter() const;
- WBool SetPasswordCharacter( WUShort ch );
-
- // ReadOnly
- //
- // Determines whether edit box is read-only.
-
- WBool GetReadOnly() const;
- WBool SetReadOnly( WBool readOnly );
-
- // SoftLineBreaks
- //
- // Use at runtime with multiline text boxes. If TRUE, a
- // soft line break (CR-CR-LF) is inserted at the end of each
- // line that is broken because of wordwrap. If FALSE, all
- // such line breaks are removed and only hard line breaks
- // (CR-LF) are left.
-
- WBool GetSoftLineBreaks() const;
- WBool SetSoftLineBreaks( WBool on );
-
- // TextLimit
- //
- // Set/get the max # of charactes the text box can hold.
- // Setting the limit to 0 sets it to the max (32K for
- // single line, 64K for multi line).
-
- WULong GetTextLimit() const;
- WBool SetTextLimit( WULong limit );
-
- /**************************************************************
- * Methods
- **************************************************************/
-
- // AppendText
- //
- // Add text to the end of the textbox. If scroll is TRUE,
- // the caret is moved to the end of the text and the
- // text is scrolled into view.
-
- WBool AppendText( const WString & text, WBool scroll=TRUE );
-
- // CharacterIndex
- //
- // Given a point in the edit control's client area, returns
- // the character index (from 0) and line index (from 0)
- // of the character. Returns FALSE if the point is outside
- // the client area, in which case the charIndex and lineIndex
- // values are to be ignored. Note that charIndex and lineIndex
- // are limited to 16 bits.
-
- WBool CharacterIndex( const WPoint & pt, WULong & charIndex ) const;
- WBool CharacterIndex( const WPoint & pt, WULong & charIndex,
- WULong & lineIndex ) const;
-
- // Clear
- //
- // Clears (deletes) the selected text in the edit control.
-
- void Clear();
-
- // ClearUndoBuffer
- //
- // Clears the undo buffer.
-
- WBool ClearUndoBuffer() const;
-
- // Copy
- //
- // Copy the selected contents into the clipboard.
-
- WBool Copy();
-
- // Cut
- //
- // Copy & clear the selected contents.
-
- void Cut();
-
- // InsertText
- //
- // Insert text into the control. If text is currently
- // selected, the new text replaces it, otherwise the text
- // gets inserted at the current caret position.
-
- WBool InsertText( const WString & text, WBool canUndo=FALSE );
-
- // LineIndex
- //
- // Return the line that a character is on. If -1 (0xFFFFFFFF)
- // is passed, returns line the caret is on.
-
- WULong LineIndex( WULong charIndex=0xFFFFFFFF ) const;
-
- // Paste
- //
- // Paste the contents of the clipboard.
-
- void Paste();
-
- // CharacterPosition
- //
- // Return the point (in client coordinates) that corresponds
- // to a given character position.
-
- WBool CharacterPosition( WPoint & point, WULong charIndex ) const;
-
- // Scroll
- //
- // Scroll a certain number of characters and/or lines.
- // dx = # of characters, dy = # of lines.
-
- WBool Scroll( WTextBoxScroll scrollBy=WTBScrollLineDown ) const;
- WBool Scroll( WLong dx, WLong dy=0 ) const;
-
- // ScrollCaret
- //
- // Scroll the caret into view if not visible.
-
- WBool ScrollCaret() const;
-
- // Undo
- //
- // Undo the last operation if possible.
-
- WBool Undo();
-
- /**************************************************************
- * Item Properties
- **************************************************************/
-
- // Text
- //
- // The text for the given line (lines start at 0).
-
- WString GetText( WULong line ) const;
-
- // TextLength
- //
- // The length of text in a given line.
-
- WULong GetTextLength( WULong line ) const;
-
-
- /**************************************************************
- * Overrides
- **************************************************************/
-
- virtual WBool Scroll( const WPoint & amount, WRect * toScroll=NULL,
- WRect * clipRegion=NULL );
-
- virtual WColor GetBackColor( WBool getResultingColor=TRUE ) const;
-
- virtual WStyle GetDefaultStyle() const;
-
- virtual WStyle GetDefaultExtendedStyle() const;
-
- virtual WString GetText() const;
-
- virtual size_t GetTextLength() const;
-
- virtual WBool CloneWindow( WStyle newStyle, WStyle newExStyle,
- void * data=NULL );
-
- virtual WBool ProcessCommand( WUInt id, WNotify code,
- WNotifyInfo info, WLong & returns );
-
- virtual const WChar * InitializeClass();
-
- virtual WBool FDXIn();
-
- virtual WBool FDXOut();
-
- WBool DataOpenHandler( WTextBox *, WDataOpenEventData *ev );
- WBool DataCloseHandler( WTextBox *, WDataCloseEventData *ev );
- WBool DataAvailableHandler( WTextBox *, WDataAvailableEventData *ev );
- WBool DataRequestHandler( WTextBox *, WDataRequestEventData *ev );
-
- WBool DragStartHandler( WTextBox *, WDragEventData *ev );
- WBool DragDropHandler( WTextBox *, WDragEventData *ev );
-
- protected:
-
- WBool AllocDTCell();
-
- /**************************************************************
- * Data members
- **************************************************************/
-
- protected:
-
- WBool _ignoreChange;
-
- private:
-
- WBool _softLineBreaks;
- WString * _fdxDataSource;
- WDataTargetCell *_dataTarget;
- WBool _wasEnabled;
- };
-
- #ifndef _WNO_PRAGMA_PUSH
- #pragma enum pop;
- #pragma pack(pop);
- #endif
-
- #endif // _WTEXTBOX_HPP_INCLUDED
-