home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / include / imle.hpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-22  |  9.2 KB  |  287 lines

  1. #ifndef _IMLE_
  2.   #define _IMLE_
  3. /*******************************************************************************
  4. * FILE NAME: imle.hpp                                                          *
  5. *                                                                              *
  6. * DESCRIPTION:                                                                 *
  7. *   Declaration of the classes:                                                *
  8. *     IMultiLineEdit                                                           *
  9. *                                                                              *
  10. * COPYRIGHT:                                                                   *
  11. *   IBM Open Class Library                                                     *
  12. *   (C) Copyright International Business Machines Corporation 1992, 1996       *
  13. *   Licensed Material - Program-Property of IBM - All Rights Reserved.         *
  14. *   US Government Users Restricted Rights - Use, duplication, or disclosure    *
  15. *   restricted by GSA ADP Schedule Contract with IBM Corp.                     *
  16. *                                                                              *
  17. *******************************************************************************/
  18. #include <itextctl.hpp>
  19. #include <irect.hpp>
  20.  
  21. class IWindowHandle;
  22. class IFont;
  23. class IColor;
  24. class IMultiLineEditData;
  25.  
  26. #pragma pack(4)
  27.  
  28. class IMultiLineEdit : public ITextControl {
  29. typedef ITextControl
  30.   Inherited;
  31.  
  32. public:
  33. class Style;
  34. /*------------------------------ Constructors --------------------------------*/
  35.   IMultiLineEdit ( unsigned long     id,
  36.                    IWindow*          parent,
  37.                    IWindow*          owner,
  38.                    const IRectangle& initial= IRectangle(),
  39.                    const Style&      style = defaultStyle() );
  40.  
  41.   IMultiLineEdit ( unsigned long     id,
  42.                    IWindow*          parent );
  43.  
  44.   IMultiLineEdit ( const IWindowHandle& handle );
  45.  
  46. virtual
  47.  ~IMultiLineEdit ( );
  48.  
  49. /*---------------------------------- Styles ----------------------------------*/
  50. INESTEDBITFLAGCLASSDEF2(Style, IMultiLineEdit, IWindow, IControl);
  51.  
  52. static const Style
  53.   IC_IMPORTU classDefaultStyle,
  54.   IC_IMPORTU border,
  55.   IC_IMPORTU readOnly,
  56.   IC_IMPORTU wordWrap,
  57.   IC_IMPORTU horizontalScroll,
  58.   IC_IMPORTU verticalScroll,
  59.   IC_IMPORTU ignoreTab,
  60. #ifndef IC_MOTIFPM_FLAGNOP
  61.   IC_IMPORTU border3D;
  62. #endif
  63.  
  64. static Style
  65.   defaultStyle      ( );
  66.  
  67. static void
  68.   setDefaultStyle   ( const Style&    style );
  69.  
  70. virtual unsigned long
  71.   convertToGUIStyle ( const IBitFlag& style,
  72.                       Boolean         extendedOnly = false ) const;
  73.  
  74. /*-------------------------------- Change Operations -------------------------*/
  75. virtual IMultiLineEdit
  76.  &setTextChangedFlag    ( Boolean changed=true ),
  77.  &resetTextChangedFlag  ( );
  78. Boolean
  79.   hasTextChanged        ( ) const;
  80.  
  81. /*-------------------------------- Read-Only Operations ----------------------*/
  82. virtual IMultiLineEdit
  83.   &disableDataUpdate  ( ),
  84.   &enableDataUpdate   ( Boolean update=true );
  85.  
  86. Boolean
  87.   isWriteable         ( ) const;
  88.  
  89. /*-------------------------------- Refresh Operations ------------------------*/
  90. virtual IMultiLineEdit
  91.  &enableUpdate        ( Boolean update=true ),
  92.  &disableUpdate       ( );
  93.  
  94. /*-------------------------------- Text Operations ---------------------------*/
  95. enum EOLFormat {
  96.   cfText,
  97.   noTran,
  98.   MLEFormat
  99. };
  100.  
  101. virtual IString
  102.   text         ( ) const,
  103.   text         ( unsigned long lineNumber ) const;
  104. unsigned long
  105.   limit        ( ) const;
  106. virtual unsigned long
  107.   textLength   ( ) const;
  108. virtual IMultiLineEdit
  109.   &setText     ( const char* text ),
  110.   &setText     ( const IResourceId& text ),
  111.   &setText     ( const char* buffer,
  112.                  unsigned long bufferSize ),
  113.   &setLimit    ( unsigned long newLimit );
  114.  
  115. virtual IMultiLineEdit
  116.   &add         ( const char* text,
  117.                  unsigned long textSize=0,
  118.                  EOLFormat type=cfText ),
  119.   &addAsLast   ( const char* text,
  120.                  unsigned long textSize=0,
  121.                  EOLFormat type=cfText ),
  122.   &addAtOffset ( const char* text,
  123.                  unsigned long offset,
  124.                  unsigned long textSize=0,
  125.                  EOLFormat type=cfText );
  126.  
  127. /*-------------------------------- Import/Export Operations ------------------*/
  128. virtual unsigned long
  129.   importFromFile           ( const char* fileName,
  130.                              EOLFormat type=cfText ),
  131.   exportToFile             ( const char* fileName,
  132.                              EOLFormat type=cfText ),
  133.   exportSelectedTextToFile ( const char* fileName,
  134.                              EOLFormat type=cfText );
  135.  
  136. /*-------------------------------- Selected Text -----------------------------*/
  137. static const long
  138.   IC_IMPORTU deselect,
  139.   IC_IMPORTU end;
  140. virtual IMultiLineEdit
  141.  &selectRange        ( const IRange& range=IRange(0,end),
  142.                        unsigned long timestamp=0 );
  143. virtual IRange
  144.   selectedRange      ( ) const;
  145. virtual IString
  146.   selectedText       ( ) const;
  147. virtual unsigned long
  148.   selectedTextLength ( ) const;
  149. virtual Boolean
  150.   hasSelectedText    ( ) const;
  151.  
  152. /*-------------------------------- Clipboard Operations ----------------------*/
  153. virtual IMultiLineEdit
  154.  &cut     ( unsigned long timestamp=0 ),
  155.  ©    ( unsigned long timestamp=0 ),
  156.  &paste   ( ),
  157.  &clear   ( unsigned long timestamp=0 ),
  158.  &discard ( );
  159.  
  160. /*-------------------------------- Undo Operations ---------------------------*/
  161. Boolean
  162.   isUndoable ( ) const;
  163. virtual IMultiLineEdit
  164.  &undo       ( );
  165.  
  166. /*-------------------------------- Delete Text Operation ---------------------*/
  167. virtual IMultiLineEdit
  168.  &removeAll  ( );
  169.  
  170. /*-------------------------------- Size Operations ---------------------------*/
  171. virtual IMultiLineEdit
  172.  &setEditRegion       ( ),
  173.  &setEditRegion       ( const ISize& sizeEditRegion ),
  174.  &setEditRegionWidth  ( long width ),
  175.  &setEditRegionHeight ( long height );
  176. unsigned long
  177.   editRegionWidth     ( ) const,
  178.   editRegionHeight    ( ) const;
  179.  
  180. /*-------------------------------- Tab Stop Operation ------------------------*/
  181. virtual IMultiLineEdit
  182.  &setTab              ( unsigned long tabPixelInterval );
  183.  
  184. /*------------------------- Compound Control Method --------------------------*/
  185.  
  186. /*---------------------------- Word Wrap Operations --------------------------*/
  187. Boolean
  188.   isWordWrap      ( ) const;
  189. #ifndef IC_WIN_FLAGNOP
  190. virtual IMultiLineEdit
  191.  &enableWordWrap  ( Boolean enable=true ),
  192.  &disableWordWrap ( );
  193. #endif
  194.  
  195. /*---------------------------------- Colors ----------------------------------*/
  196. #if ( !defined(IC_MOTIF) && !defined(IC_WIN_FLAGNOP) )
  197. virtual IColor
  198.   foregroundColor ( ) const,
  199.   backgroundColor ( ) const;
  200. #endif //!IC_MOTIF and !IC_WIN_FLAGNOP
  201.  
  202. /*---------------------------------- Fonts -----------------------------------*/
  203.  
  204. /*-------------------------------- Line Operations ---------------------------*/
  205. virtual IMultiLineEdit
  206.  &addLine               ( const char*   text,
  207.                           unsigned long lineNumber,
  208.                           EOLFormat     type=cfText ),
  209.  &addLineAsLast         ( const char*   text,
  210.                           EOLFormat     type=cfText ),
  211.  &removeLine            ( unsigned long lineNumber ),
  212.  &setCursorLinePosition ( unsigned long lineNumber ),
  213.  &setCursorPosition     ( unsigned long cursorPosition ),
  214.  &setTop                ( unsigned long lineNumber );
  215.  
  216. unsigned long
  217.   cursorLinePosition ( ) const,
  218.   cursorPosition     ( ) const,
  219.   top                ( ) const,
  220.   numberOfLines      ( ) const,
  221.   visibleLines       ( ) const;
  222.  
  223. /*----------------------- Notification Event Descriptions --------------------*/
  224. static INotificationId const
  225.   IC_IMPORTU dataUpdateId,
  226.   IC_IMPORTU limitId;
  227.  
  228. /*----------------------- Observer Notification ------------------------------*/
  229. virtual IMultiLineEdit
  230.  &enableNotification ( Boolean enable = true );
  231.  
  232.  
  233. protected:
  234. /*---------------------- Event-Handling Implementation -----------------------*/
  235.  
  236. /*-------------------------- Drag and Drop Support ---------------------------*/
  237. virtual Boolean
  238.  isDragStarting    ( IEvent &event );
  239.  
  240.  
  241. private:
  242. /*------------------------------ Hidden Members ------------------------------*/
  243.   IMultiLineEdit        ( const IMultiLineEdit& multiLineEdit );
  244. IMultiLineEdit
  245.  &operator=             ( const IMultiLineEdit& multiLineEdit );
  246.  
  247. /*--------------------------------- Private ----------------------------------*/
  248. long
  249.   exportFile            ( const char* fileName,
  250.                           Boolean flMarkedAreaOnly );
  251.  
  252.  
  253. unsigned long
  254.   textLengthAfterFormat ( ) const;
  255.  
  256. static Style
  257.   currentDefaultStyle;
  258.  
  259. unsigned long
  260.   fcharLimit;
  261. Boolean
  262.   flimitSet;
  263.  
  264. Boolean
  265.   bRefresh;
  266.  
  267. IMultiLineEditData
  268.  *fMultiLineEditData;
  269.  
  270. friend class IMultiLineHandler;
  271. /*---------------------------- Obsolete Members ------------------------------*/
  272. #if (IC_OBSOLETE <= IC_OBSOLETE_2)
  273. public:
  274. virtual IMultiLineEdit
  275.  &setChangedFlag    ( Boolean changed=true ),
  276.  &resetChangedFlag  ( );
  277. Boolean
  278.   isChanged         ( ) const;
  279. #endif
  280. };
  281.  
  282. INESTEDBITFLAGCLASSFUNCS(Style, IMultiLineEdit);
  283.  
  284. #pragma pack()
  285.  
  286. #endif
  287.