home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / mlelib.zip / mlelib / mle.h < prev    next >
C/C++ Source or Header  |  1993-06-07  |  6KB  |  151 lines

  1. /*************************************************************************
  2. *
  3. * filename        : editor.h
  4. *
  5. * description    : header file for class EDITOR
  6. *
  7. * exp. types    : struct MLE_LIST    - chain MLEs together
  8. *                  class  EDITOR        - handle many MLEs
  9. *
  10. * used classes    : class  MLE
  11. *
  12. * copyright (C) 1993 Jörg Caumanns (caumanns@cs.tu-berlin.de)
  13. *
  14. *************************************************************************/
  15. #ifndef _MLE_INCLUDED
  16. #define _MLE_INCLUDED
  17.  
  18. #include <os2def.h>
  19.  
  20. /*
  21. * shellposition parameters
  22. */
  23. #define MLE_DISTANCE         32        // distance between the upper right
  24.                                     // corners of two MLEs (in pels)
  25. #define MLE_XSIZE            60        // MLE default x-size (% of desktop)
  26. #define MLE_YSIZE            60      // MLE default y-size (% of desktop)
  27.  
  28. /*
  29. * Creation Flags
  30. */
  31. #define MLE_HIDE            1        // create the MLE invisible
  32. #define MLE_MAXIMIZE        2        // create the MLE with maximum size
  33. #define MLE_MINIMIZE        4        // create the MLE with minimum size
  34. #define MLE_NEWFILE            8        // don't load a file to the MLE
  35.  
  36. /*
  37. * Size and position flags
  38. */
  39. #define MLE_SIZEPOS_SIZE    1        // change the MLE-size
  40. #define MLE_SIZEPOS_POS        2        // change the MLE-position
  41. #define MLE_SIZEPOS_MAX        4        // maximize the MLE
  42. #define MLE_SIZEPOS_MIN        8        // minimize the MLE
  43.  
  44. /*************************************************************************
  45. *
  46. * class    : MLE (Multi-Line Entryfield)
  47. *
  48. * descr.: Create and manage MLEs
  49. *
  50. * method: OpenFile        : Create an MLE and load a file to it. If no
  51. *                          filename is given the action depends on
  52. *                          the flag parameter: if MLE_NEWFILE is set
  53. *                          an empty MLE is created, otherwise the user
  54. *                          is asked for a filename ("open"-dialogbox).
  55. *                          If flag MLE_HIDE is set, the MLE is created
  56. *                          invisible. This may be useful if you want
  57. *                          to change some attributes of the MLE (e.g.
  58. *                          color, size, ...) before the MLE is displayed.
  59. *         CloseFile        : Close the MLE. If the contents of the MLE
  60. *                          has changed, the user is asked if the
  61. *                          changes can be discarded or not.
  62. *         SaveFile        : Save the contents of the MLE to the filesystem.
  63. *                          If no filename was given at open-time
  64. *                          the "save as"-dialogbox appears.
  65. *          SaveFileAs    : Save the contents of the MLE to a file that
  66. *                          name is given by the user ("save as"-dialogbox).
  67. *                          If the file already exists, the user is asked
  68. *                          if it should be overwritten.
  69. *          Cut            : Remove the selected text from the  MLE and put
  70. *                          it in the clipboard.
  71. *          Copy          : Copy the selected text from the active MLE to the
  72. *                          clipboard.
  73. *          Paste            : Insert text from the clipboard at the cursor-
  74. *                          position of the MLE.
  75. *          Clear            : Delete the selected text of the MLE.
  76. *         Show            : Depending on the argument the MLE is shown (TRUE)
  77. *                          or hidden (FALSE).
  78. *          SetSizeAndPosition : Change size and/or position of the MLE.
  79. *                          If the flag MLE_SIZEPOS_SIZE is set the size is
  80. *                          changed, if MLE_SIZEPOS_POS is set the MLE is
  81. *                          moved. If both are set, the MLE is moved and
  82. *                          resized. If MLE_SIZEPOS_MAX or MLE_SIZEPOS_MIN
  83. *                          is set the MLE is maximized (minimized).
  84. *          SetSize        : Change only the MLE's size
  85. *          SetPosition    : Move the MLE.
  86. *          SetColor        : Change foreground and background color of the
  87. *                          MLE.
  88. *          GetColor        : Query foreground and background color of the
  89. *                          MLE.
  90. *          GetText        : Copy the contents of the MLE to a buffer.
  91. *                          GetText allocates the buffer big enough to
  92. *                          hold the text. The buffer must be freed by
  93. *                          application via DosFreeMem.
  94. *         Print            : Insert text at the current cursor position.
  95. *                          The syntax is the same as of 'printf'.
  96. *         Touched        : Check if the contents of the MLE changed.
  97. *         TouchFile        : 'Touch' the MLE.
  98. *          Activate        : Set this MLE as the active MLE.
  99. *         SetClosed        : Clear the 'fActive'-flag (only for internal use)
  100. *          LoadedFile    : Get the path of the file that is loaded to
  101. *                          the MLE
  102. *          ActiveMLE        : Get the handle of the MLE that has the focus.
  103. *
  104. * uses  : [none]
  105. *
  106. *************************************************************************/
  107. class MLE    {
  108.         HWND  hwnd;                    // frame window handle
  109.         HWND  hwndClient;            // client area handle
  110.         CHAR  *pszLoadedFile;        // path of loaded file
  111.         ULONG ulFlags;                // flags
  112.         BOOL  fTouched;                // TRUE if MLE contents changed
  113.         BOOL  fAlive;                // TRUE if MLE not closed
  114.         LONG  clrForeground;        // foreground color
  115.         LONG  clrBackground;        // background color
  116.         static MLE *pmleActive;        // MLE with focus
  117.     public:
  118.              MLE(VOID);
  119.         BOOL OpenFile(CHAR *pszFile, ULONG ulf = 0);
  120.         BOOL CloseFile(VOID);
  121.         BOOL SaveFile(VOID);
  122.         BOOL SaveFileAs(VOID);
  123.         VOID Cut(VOID);
  124.         VOID Copy(VOID);
  125.         VOID Paste(VOID);
  126.         VOID Clear(VOID);
  127.         VOID Show(BOOL f);
  128.         VOID SetSizeAndPosition(INT x,INT y,INT cx,INT cy,
  129.                             ULONG ulFlags = MLE_SIZEPOS_SIZE | MLE_SIZEPOS_POS);
  130.         VOID SetSize(INT cx, INT cy);
  131.         VOID SetPosition(INT x, INT y);
  132.         VOID SetColor(LONG clrFg, LONG clrBg);
  133.         VOID GetColor(LONG *pclrFg, LONG *pclrBg);
  134.         BOOL GetText(CHAR **ppszBuffer);
  135.         VOID Print(CHAR *pszMask, ...);
  136.         BOOL Touched(VOID);
  137.         VOID TouchFile(BOOL);
  138.         VOID Activate(VOID);
  139.         VOID SetClosed(VOID);
  140.         CHAR *LoadedFile(VOID);
  141.         MLE  *ActiveMLE(VOID);
  142.         };
  143.  
  144.  
  145. /*
  146. * include inline implementation of some methods
  147. */
  148. #include "mle.inl"
  149.  
  150. #endif    // !_MLE_INCLUDED
  151.