home *** CD-ROM | disk | FTP | other *** search
- #ifndef _IMLE_
- #define _IMLE_
- /*******************************************************************************
- * FILE NAME: imle.hpp *
- * *
- * DESCRIPTION: *
- * Declaration of the class(es): *
- * Imle - This class creates and manages the multi-line edit control. *
- * *
- * COPYRIGHT: *
- * Licensed Materials - Property of IBM *
- * (C) Copyright IBM Corporation 1992, 1993 *
- * All Rights Reserved *
- * US Government Users Restricted Rights - Use, duplication, or disclosure *
- * restricted by GSA ADP Schedule Contract with IBM Corp. *
- * *
- * $Log: R:/IBMCLASS/IBASECTL/VCS/IMLE.HPV $
- //
- // Rev 1.7 25 Oct 1992 17:05:36 nunn
- //changed library name to ICLUI
- //
- // Rev 1.6 25 Oct 1992 10:55:20 boezeman
- //Add documentation and converted file to skeleton.hpp format.
-
- Rev 1.5 29 Sep 1992 21:17:36 Susan Nunn
- Added declare for isWordWrap()
-
- Rev 1.4 26 Feb 1992 20:55:52 Ken Fichthorn
- Added methods for manipulating lines, plus insertText(),unMark(),
- disableRefresh(), and enableRefresh()
-
- Rev 1.3 30 Oct 1991 21:17:36 Ken Fichthorn
- Redesign and implement.
-
- Rev 1.2 23 May 1991 20:55:52 Mike Chan
- Converted to new naming convention
-
- Rev 1.1 17 Aug 1990 19:02:08 James Hsieh
- Initial code
- *******************************************************************************/
- #ifndef _ICONTROL_
- #include <icontrol.hpp>
- #endif
-
- // Forward declarations for other classes:
- class IMultiLineEdit;
- class IWindowHandle;
- class IFontMgr;
-
- /* Defines for MLE */
- const long IC_MARK_TO_END = -2;
- const long IC_APPEND_TO_END = -1;
-
- class IMultiLineEdit : public IControl {
- /*******************************************************************************
- * This class creates and manages the multi-line edit control. *
- * *
- * To use this class, create an instance of this class as follows: *
- * #include <imle.hpp> *
- * char pchInitText[100]; *
- * pmle= 0; *
- * pmle = new IMultiLineEdit( this, ID_MLE, *
- * IRectangle(IPoint(50, 15), *
- * ISize(200, 200)), *
- * IC_DEFAULTMLESTYLE); *
- * sprintf( pchInitText, *
- * "Text init'd by setText, marked by setMarkedArea."); *
- * pmle->setText( pchInitText, 1+strlen(pchInitText)); *
- * pmle->setMarkedArea(1, IC_MARK_TO_END); *
- * pmle->setFocus(); // must setfocus to show marked area *
- * *
- * EXAMPLE: *
- * <sample code> *
- *******************************************************************************/
- public:
- typedef IControl
- Inherited;
- INESTEDBITFLAGCLASSDEF2(Style, IMultiLineEdit, IWindow, IControl);
- // style class definition
- static const Style
- border,
- readOnly,
- wordWrap,
- horzScroll,
- vertScroll,
- ignoreTab;
- static const Style&
- defaultStyle;
-
- /*------------------------ CONSTRUCTORS/DESTRUCTORS ----------------------------
- | There are 3 ways to construct instances of this class: |
- | 1. default |
- | 2. From a Dialog Template |
- | 3. From a Window |
- ------------------------------------------------------------------------------*/
- IMultiLineEdit(unsigned long ulId,
- const IWindow* pwndParent,
- const IWindow* pwndOwner,
- const IRectangle& rectInit,
- Style mles = defaultStyle);
- IMultiLineEdit(unsigned long ulId,
- const IWindow* pwndParent);
- IMultiLineEdit(IWindowHandle wh);
- virtual
- ~IMultiLineEdit() {;}
-
- /*-------------------------------- CHANGE OPERATIONS ---------------------------
- | setChangedFlag - Sets a flag to indicate that the MLE contents have changed|
- | clearChangedFlag - Resets the changed flag, so that addition changes to the |
- | mle from this point forward can be detected. |
- | isChanged - Queries whether any changes have been made to the mls |
- | since the last time the changed flag was reset. |
- ------------------------------------------------------------------------------*/
- void
- setChangedFlag(),
- clearChangedFlag();
- Boolean
- isChanged() const;
-
- /*-------------------------------- READONLY OPERATIONS -------------------------
- | setReadOnly - Prohibits changes to the current mle text. |
- | cancelReadOnly - Puts the mle into read/write mode, where the user can |
- | update the mle text. |
- | isReadOnly - Queries whether or not the mle is in readonly mode. |
- ------------------------------------------------------------------------------*/
- void
- setReadOnly(),
- cancelReadOnly();
- Boolean
- isReadOnly() const;
-
- /*-------------------------------- REFRESH OPERATIONS --------------------------
- | enableRefresh - Enables screen refreshes. The screen is brought up to |
- | date with the contents of the text. |
- | disableRefresh - Disables screen refreshes. This allows an application to|
- | make changes throughout an mle while avoiding unnecessary|
- | overhead caused by attempts to keep the screen display |
- | current. While refresh is disabled, mouse and keyboard |
- | messages are processed by beeping an ignoring them. The |
- | mouse pointer changes to the system standard "wait" pointer.|
- ------------------------------------------------------------------------------*/
- void
- enableRefresh(),
- disableRefresh();
-
- /*-------------------------------- TEXT OPERATIONS -----------------------------
- | setText - Overwrites the current contents of the mle with the new |
- | text contained in the input butter. The input buffer can|
- | contain NULL characters -- the buffer size parameter |
- | determines how much text is copied in the mle. |
- | text - Returns the current contents of the mle. |
- | lineText - Returns the current mle text at a given line. |
- | insert - Inserts the specified text into the MLE at the current |
- | cursor position. At the conclusion of this operation, the|
- | cursor will be positioned at the end of the inserted text.|
- | append - Inserts the specified text into the MLE at the end of the|
- | current text. This operation will not change the cursor |
- | position. |
- | insertAt - Inserts the specified text into the MLE at the point |
- | specified. At the conclusion of this insert, the cursor |
- | will be positioned at the same character as it was before|
- | the insert. |
- | markedText - Returns the currently marked text of the mle. |
- | setEndOfLineFormat-Changes the format used for copying mle text to and from |
- | buffers. |
- | endOfLineFormat - Returns the format used for copying mle text. |
- ------------------------------------------------------------------------------*/
- IString
- text(),
- lineText( long lLineNumber),
- markedText();
- long
- setText(char* pszBuffer,
- unsigned long ulBufferSize =0),
- insert( char * pszBuffer, // insert at cursor pos
- unsigned long ulBufferSize =0),
- append( char * pszBuffer, // insert at end of text
- unsigned long ulBufferSize =0),
- insertAt( char * pszBuffer, // insert at spec'd pos
- long lInsertionPoint,
- unsigned long ulBufferSize =0);
- void
- setEndOfLineFormat( unsigned long ulEOLFormat);
- unsigned long
- endOfLineFormat();
-
- /*-------------------------------- IMPORT/EXPORT OPERATIONS --------------------
- | importFromFile - Inserts the contents of the specified file into the mle |
- | at the current cursor position. |
- | exportToFile - Saves the contents of the mle to the specified file |
- | exportMarkedTextToFile - Saves the currently marked text to the specifed file|
- ------------------------------------------------------------------------------*/
- long
- importFromFile(char* pszFileName),
- exportToFile(char * pszFileName),
- exportMarkedTextToFile(char* pszFileName);
-
- /*-------------------------------- TEXT LIMIT OPERATION ------------------------
- | setTextLimit - Sets a limit on the number of characters that can be input |
- | into the mle. Returns 0 for successful completion. |
- | Otherwise, if the MLE already contains more characters than |
- | the proposed limit, then the call fails and returns the |
- | number of characters by which the limit is exceeded. |
- ------------------------------------------------------------------------------*/
- long
- setTextLimit(long lNewLimit);
-
- /*-------------------------------- MARKED TEXT OPERATIONS ----------------------
- | setMarkedArea - Specifies a range of characters as the marked area. If no |
- | range is specified, all of the mle text will be marked. |
- | unMark - Unmarks the currently marked text, if any, in the mle. |
- | isClipboardOpen-Checks if the clipboard is open in a format that is |
- | compatible with the mle. |
- | isAreaMarked - Checks if any text is currently marked. |
- | cut - Copies the currently marked text from the mle to the |
- | clipboard, and then deletes it from the mle. |
- | copy - Copies the currently marked text from the mle to the |
- | clipboard. |
- | paste - Inserts the contents of the clipboard into the mle at the |
- | current cursor position. |
- | clearMarkedText-Replaces the currently marked text with blank spaces. |
- | deleteMarkedText-Deletes all of the currently marked text. |
- ------------------------------------------------------------------------------*/
- void
- setMarkedArea(long lFirstMarkedChar = 1,
- long lLastMarkedChar = IC_MARK_TO_END),
- unMark();
- Boolean
- isClipboardOpen() const,
- isAreaMarked() const;
- unsigned long
- cut(),
- copy(),
- paste();
- long
- clearMarkedText(); /* replace marked area with blanks */
- unsigned long
- deleteMarkedText();
-
- /*-------------------------------- UNDO OPERATIONS -----------------------------
- | isUndoAvailable - Checks if any un-doable actions have been performed on the|
- | contents of the mle. |
- | undo - This backs out the last "undoable" change to the mle |
- | contents. |
- ------------------------------------------------------------------------------*/
- Boolean
- isUndoAvailable() const;
- void
- undo();
-
- /*-------------------------------- DELETE TEXT OPERATION------------------------
- | deleteAllText - Deletes the entire contents of the mle. |
- ------------------------------------------------------------------------------*/
- unsigned long
- deleteAllText();
-
- /*-------------------------------- SIZE OPERATIONS -----------------------------
- | setEditRegion - Sets the size of the edit region so that it covers the |
- | entire mle window. The edit region is the rectangular area |
- | in whih the text is displayed. |
- | setEditRegionWidth-Sets the width of the edit region, in pixels. |
- | setEditRegionHeight-Sets the height of the edit region, in pixels. |
- | editRegionWidth-Returns the width of the edit region. |
- | editRegionHeight-Returns the height of the edit region. |
- ------------------------------------------------------------------------------*/
- void
- setEditRegion(), // Set edit region to size of MLE window
- setEditRegion( const ISize& sizeEditRegion),
- setEditRegionWidth( long lWidth),
- setEditRegionHeight( long lHeight);
- long
- editRegionWidth() const,
- editRegionHeight() const;
-
- /*-------------------------------- TAB STOP OPERATION --------------------------
- | setTabStopInterval - Sets the number of pixels between tab stops inside |
- | the mle |
- ------------------------------------------------------------------------------*/
- void
- setTabStopInterval( long lTabPixelInterval);
-
- /*-------------------------------- WORD-WRAP OPERATIONS ------------------------
- | isWordWrap - Checks if the mle is in word-wrap mode. |
- | setWordWrap - Sets the mle into word-wrap mode. |
- | cancelWordWrap - Takes the mle out of word-wrap mode. |
- ------------------------------------------------------------------------------*/
- Boolean
- isWordWrap(); // (a) SHN
- void
- setWordWrap(),
- cancelWordWrap();
-
- /*-------------------------------- COLOR OPERATIONS ----------------------------
- | setTextColor - Sets the color of the text inside the mle. |
- | setBackgoundColor-Sets the color of the mle background. |
- ------------------------------------------------------------------------------*/
- long
- setTextColor( long lColor),
- setBackgroundColor( long lColor);
-
- /********************************************************************/
- /* Method to allow the user to change the font of the MLE text. */
- /********************************************************************/
- //void setFont( const IFontMgr& fontmgr);
-
- /*-------------------------------- LINE OPERATIONS -----------------------------
- | insertLine - Inserts teh specified null-teminated text at the line |
- | number specified |
- | deleteLine - Deletes the specified line of text. |
- | setTopLine - Makes the specified line be the top visible line on the |
- | screen. |
- | setCursorLine - Moves the cursor position to the specified line number. |
- | setCursorChar - Places the cursor on the specified character in the mle. |
- | topLine - Returns the number of the line currently visible as the |
- | top mle line on the screen |
- | cursorLine - Returns the line number of the line that currently |
- | contains the cursor. |
- | lineCount - Returns the total number of lines of text in the mle. |
- | visibleLineCount - Returns the number of lines that completely fit inside |
- | the mle on the screen. |
- ------------------------------------------------------------------------------*/
- void
- insertLine( char * pszLineText,
- long lLineNumber = IC_APPEND_TO_END),
- deleteLine( long lLineNumber),
- setTopLine( long lLineNumber),
- setCursorLine( long lLineNumber),
- setCursorChar( long lCursorPosition);
- long
- topLine() const,
- cursorLine() const,
- lineCount() const,
- visibleLineCount() const;
-
- /********************************************************************/
- /* OUTDATED METHODS */
- /********************************************************************/
- long
- getEditRegionWidth() const {return editRegionWidth();}
- long
- getEditRegionHeight() const {return editRegionHeight();}
-
- protected:
- static Style classDefaultStyle;
-
- private:
- /*--------------------------------- PRIVATE ----------------------------------*/
- long
- exportFile(char *pszFileName, Boolean flMarkedAreaOnly);
- unsigned long
- export(long *insertion_point,unsigned long *buffer_length),
- import(long *insertion_point,unsigned long buffer_length);
- void
- setIEBuffer(char *pchBuffer,unsigned long ulLength);
-
- /* These methods were moved from public to private when we decided */
- /* to return IString's instead of char * */
- unsigned long
- getMarkedTextLen() const,
- getTextLen() const;
-
- } ;
-
- INESTEDBITFLAGCLASSFUNCS(Style, IMultiLineEdit);
-
- #endif