home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional Developers Kit 1992 November / Disc01 / Disc01.mdf / cppbeta / ibmcli / ientryfd.hp_ / IENTRYFD.HPP
Encoding:
C/C++ Source or Header  |  1992-10-26  |  17.2 KB  |  357 lines

  1. #ifndef _IENTRYFD_
  2.   #define _IENTRYFD_
  3. /*******************************************************************************
  4. * FILE NAME: Ientryfd.hpp                                                      *
  5. *                                                                              *
  6. * DESCRIPTION:                                                                 *
  7. *   Declaration of the class(es):                                              *
  8. *    Ientryfd - This class creates and manages the entry field control window. *
  9. *                                                                              *
  10. * COPYRIGHT:                                                                   *
  11. *   Licensed Materials - Property of IBM                                       *
  12. *   (C) Copyright IBM Corporation 1992, 1993                                   *
  13. *   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. * $Log:   R:/IBMCLASS/IBASECTL/VCS/IENTRYFD.HPV  $
  18. //
  19. //   Rev 1.9   25 Oct 1992 17:05:18   nunn
  20. //changed library name to ICLUI
  21. //
  22. //   Rev 1.8   25 Oct 1992 10:53:48   boezeman
  23. //Add documentation and converted file to skeleton.hpp format.
  24. //
  25. //   Rev 1.7   22 Oct 1992 09:48:06   boezeman
  26. //Made changes to set and return all styles, also changed all methods that
  27. //return void to now return IEntryField&, also changed the format of the
  28. //hpp to that of the skeleton.hpp.
  29.  
  30.       Rev 1.7   20 Oct 1992 21:22:02   Boezeman
  31.    Add methods for setting and return all allowable styles for entryfields.
  32.    Changed file to be structed like skeleton.hpp
  33.  
  34.       Rev 1.6   13 Oct 1992 21:22:02   tsuji
  35.    Correct comments around log directive.
  36.  
  37.       Rev 1.5   13 Oct 1992 20:56:44   tsuji
  38.    Correct log directive, remove IBM Confidential classification.
  39.  
  40.       Rev 1.4   13 Oct 1992 19:05:40   tsuji
  41.    Remove no-op virtual destructor, add Inherited typedef.
  42. *******************************************************************************/
  43. #ifndef _ITEXTCTL_
  44.   #include <itextctl.hpp>
  45. #endif
  46.  
  47. // Forward declarations for other classes:
  48. class IEntryField;  /* ef */
  49. class IRange;
  50. class IRectangle;
  51. class ISize;
  52. class IString;
  53. class IResourceId;
  54. class IWindowHandle;
  55. #ifndef _IBITFLAG_
  56.   #include <ibitflag.hpp>
  57. #endif
  58.  
  59. class IEntryField : public ITextControl  {
  60. /*******************************************************************************
  61. * This class creates and manages the entry field control window.               *
  62. *                                                                              *
  63. * To use this class, create an instance of this class as follows:              *
  64. *   IEntryField efEntry(ID_ENTRY, this, IRectangle(10,10,30,12));              *
  65. *                                                                              *
  66. * To change the style of the entry field after it has been created, use        *
  67. * functions such as:                                                           *       *
  68. *    setAlignment(IEntryField::center).                                        *
  69. *                                                                              *
  70. * Valid styles for an entry field are:                                         *
  71. *    IEntryField::autoscroll,                                                  *
  72. *    IEntryField::margin,                                                      *
  73. *    IEntryField::autotab,                                                     *
  74. *    IEntryField::readonly,                                                    *
  75. *    IEntryField::command,                                                     *
  76. *    IEntryField::unreadable,                                                  *
  77. *    IEntryField::autosize,                                                    *
  78. *    IEntryField::leftAlign,                                                   *
  79. *    IEntryField::centerAlign,                                                 *
  80. *    IEntryField::rightAlign,                                                  *
  81. *    IEntryField::anyData,                                                     *
  82. *    IEntryField::sbcsData,                                                    *
  83. *    IEntryField::dbcsData,                                                    *
  84. *    IEntryField::mixedData,                                                   *
  85. *    IEntryField::defStyle,                                                    *
  86. *    any of the IControl styles, and                                           *
  87. *    any of the IWindow styles.                                                *
  88. *                                                                              *
  89. * Specific keystroke processing (e.g. numeric                                  *
  90. * only fields) can be implemented through the                                  *
  91. * use of a specialized handler for the entry                                   *
  92. * field control.                                                               *
  93. *                                                                              *
  94. * EXAMPLE:                                                                     *
  95. *   <sample code>                                                              *
  96. *******************************************************************************/
  97. /* Next release, ICLUI will provide support                                 *
  98. * to automatically change the height and                                       *
  99. * width of an entry field on a canvas to                                       *
  100. * match the size of the font used by the                                       *
  101. * entry field.                                                                */
  102. typedef ITextControl
  103.   Inherited;
  104.  
  105. public:
  106.  
  107. INESTEDBITFLAGCLASSDEF2(Style, IEntryField, IWindow, IControl);
  108.                                   // style class definition
  109. static const Style
  110.   autoscroll,
  111.   margin,
  112.   autotab,
  113.   readonly,
  114.   command,
  115.   unreadable,
  116.   autosize,
  117.   leftAlign,
  118.   centerAlign,
  119.   rightAlign,
  120.   anyData,
  121.   sbcsData,
  122.   dbcsData,
  123.   mixedData;
  124. static const Style&
  125.   defStyle;
  126. /*------------------------ CONSTRUCTORS/DESTRUCTORS ----------------------------
  127. | There are 3 ways to construct instances of this class:                       |
  128. |   1. default                                                                 |
  129. |   2. From a Dialog Template                                                  |
  130. |   3. From a Window                                                           |
  131. ------------------------------------------------------------------------------*/
  132.   IEntryField(unsigned long Id,
  133.               const IWindow* parent,
  134.               const IWindow* owner,
  135.               const IRectangle& initial,
  136.               Style style = defStyle);
  137.  
  138.   IEntryField(unsigned long Id,
  139.               const IWindow* parentDialog);
  140.  
  141.   IEntryField(IWindowHandle handle);
  142.  
  143. /*-------------------------------- STYLES --------------------------------------
  144. | These function provide means of getting and setting the default style        |
  145. | attributes of instances of this class:                                       |
  146. |   defaultStyle    - returns the entry field control default style setting    |
  147. |   setDefaultStyle - sets the entry field control default style               |
  148. ------------------------------------------------------------------------------*/
  149. static Style
  150.   defaultStyle();
  151. static void
  152.   setDefaultStyle(Style style);
  153. /*-------------------------------- STYLES --------------------------------------
  154. | These operations replace the value of, append a style value(s) to and remove |
  155. | a style value(s) from the window style of the entry field control.           |
  156. |   setAlignment     - sets the alignment of the entry field                   |
  157. |   alignment        - returns the currently set alignment, left is the default|
  158. |   setCharType      - sets the character type of the entry field control      |
  159. |   charType         - returns the currently set char type, any is the default |
  160. |   enableAutoScroll - Enables or diables the autoscroll style on an entry field|
  161. |   disableAutoScroll- Diables the autoscroll style on an entry field.         |
  162. |   isAutoScroll     - Queries if the autoscroll style is set on an entry field|
  163. |   enableMargin     - Enables or diables the margin style on an entry field   |
  164. |   disableMargin    - Diables the margin style on an entry field.             |
  165. |   isMargin         - Queries if the margin style is set on an entry field    |
  166. |   enableCommand    - Enables or diables the command style on an entry field  |
  167. |   disableCommand   - Diables the command style on an entry field.            |
  168. |   isCommand        - Queries if the command style is set on an entry field   |
  169. |   enableAutoTab    - Enables or diables the autotab style on an entry field  |
  170. |   disableAutoTab   - Diables the autotab style on an entry field.            |
  171. |   isAutoTab        - Queries if the autotab style is set on an entry field   |
  172. |   enableAutoSize   - Enables or diables the autosize style on an entry field |
  173. |   disableAutoSize  - Diables the autosize style on an entry field.           |
  174. |   isAutoSize       - Queries if the autosize style is set on an entry field  |
  175. ------------------------------------------------------------------------------*/
  176. enum Alignment { left, center, right };
  177. IEntryField&
  178.   setAlignment(Alignment alignment);      //JJB
  179. Alignment
  180.   alignment();                               //JJB
  181. enum CharType { sbcs, dbcs, any, mixed };
  182. IEntryField&
  183.   setCharType(CharType type);             //JJB
  184. CharType
  185.   charType();                                 //JJB
  186. IEntryField&
  187.   enableAutoScroll(Boolean bTurnOn=true);  //JJB
  188. IEntryField&
  189.   disableAutoScroll();                     //JJB
  190. IEntryField&
  191.   enableMargin(Boolean bTurnOn=true);      //JJB
  192. IEntryField&
  193.   disableMargin();                         //JJB
  194. IEntryField&
  195.   enableCommand(Boolean bTurnOn=true);     //JJB
  196. IEntryField&
  197.   disableCommand();                        //JJB
  198. IEntryField&
  199.   enableAutoTab(Boolean bTurnOn=true);     //JJB
  200. IEntryField&
  201.   disableAutoTab();                        //JJB
  202. IEntryField&
  203.   enableAutoSize(Boolean bTurnOn=true);    //JJB
  204. IEntryField&
  205.   disableAutoSize();                       //JJB
  206. Boolean
  207.   isAutoScroll(),                              //JJB
  208.   isMargin(),                                  //JJB
  209.   isCommand(),                                 //JJB
  210.   isAutoTab(),                                 //JJB
  211.   isAutoSize();                                //JJB
  212.  
  213. /*-------------------------------- CLIPBOARD OPERATIONS ------------------------
  214. | These operations allows data to be transferred between the clipboard and the |
  215. | entry field.  Each of these operations deal with the selected text in the    |
  216. | entry field.                                                                 |
  217. |   isClipboardOpen  - Queries if the clipboard contains text data.            |
  218. |   cut              - Removes the selected text from the entry field and puts |
  219. |                      it in the clipboard.                                    |
  220. |   copy             - Copies the selected text to the clipboard.              |
  221. |   paste            - Replaces the selected text with the text in the clipboard|
  222. |   clear            - Replaces the selected text in the entry field with spaces|
  223. |   discard          - Deletes the marked text.                                |
  224. ------------------------------------------------------------------------------*/
  225. Boolean
  226.   isClipboardOpen() const;
  227. IEntryField&
  228.   cut();                                 //JJB
  229. IEntryField&
  230.   copy();                                //JJB
  231. IEntryField&
  232.   paste();                               //JJB
  233. IEntryField&
  234.   clear();                               //JJB
  235. IEntryField&
  236.   discard();                             //JJB
  237.  
  238.  
  239. /*-------------------------------- OVERLOADED DISABLE/ENABLE WINDOW ------------
  240. | These operations are overloaded to ensure a diabled entry field is set to    |
  241. | read-only state to prevent user input.                                       |
  242. |   disable          - Disables an entry field.                                |
  243. |   enable           - Enables or disables an entry field.                     |
  244. ------------------------------------------------------------------------------*/
  245. void
  246.   disable(),
  247.   enable(Boolean bTurnOn=true);
  248.  
  249. /*-------------------------------- INSERTMODE ----------------------------------
  250. |   enableInsertMode - Enables or disables the insert mode on a entry field.   |
  251. |   disableInsertMode- Disables the insert mode on a entry field.              |
  252. |   isInsertMode     - Queries is the entry field is in insert mode.           |
  253. ------------------------------------------------------------------------------*/
  254. IEntryField&
  255.   enableInsertMode(Boolean bTurnOn=true); //JJB
  256. IEntryField&
  257.   disableInsertMode();                    //JJB
  258. Boolean
  259.   isInsertMode() const;
  260.  
  261. /*-------------------------------- READONLYMODE --------------------------------
  262. |   enableReadOnly   - Enables or disables the read-only mode on a entry field |
  263. |   disableReadOnly  - Disables the read-only mode on a entry field.           |
  264. |   isReadOnly       - Queries is the entry field is in read-only mode.        |
  265. ------------------------------------------------------------------------------*/
  266. IEntryField&
  267.   enableReadOnly(Boolean bTurnOn=true);   //JJB
  268. IEntryField&
  269.   disableReadOnly();                      //JJB
  270. Boolean
  271.   isReadOnly() const;
  272.  
  273. /*-------------------------------- TEXTLIMIT -----------------------------------
  274. |   setTextLimit - Sets the length of the longest text that the entry field is |
  275. |                  is allowed to hold.                                         |
  276. |   textLimit    - Returns the longest text that the entry field can hold.     |
  277. ------------------------------------------------------------------------------*/
  278. IEntryField&
  279.   setTextLimit(unsigned long textLimit);      //JJB
  280. IEntryField&
  281.   setTextLimit(const IResourceId& textLimit); //JJB
  282. unsigned long
  283.   textLimit() const;
  284.  
  285. /*-------------------------------- MARKED TEXT ---------------------------------
  286. | These operations mark (select) a range of text, return the range of the      |
  287. | marked text, and return the marked text string.  The marked range is the     |
  288. | 0-based index of the first character marked (or to be marked) and the 0-based|
  289. | index of the last character marked (or to be marked).  A range of (-1,-1) is |
  290. | returned by markedTextRange is no text is marked                             |
  291. |   markText         - Marks(select) a range of text.                          |
  292. |   markedTextRange  - Returns the range of the marked text.                   |
  293. |   markedText       - Returns the marked text string.                         |
  294. ------------------------------------------------------------------------------*/
  295. IEntryField&
  296.   markText(const IRange& range);          //JJB
  297. IRange
  298.   markedTextRange() const;
  299. IString
  300.   markedText() const;
  301.  
  302. /*-------------------------------- FIRST CHARACTER------------------------------
  303. |   setFirstCharIndex- Set the first character displayed at the left edge of   |
  304. |                      the entry field. The index is 0-based.                  |
  305. |   firstCharIndex   - Returns the first character displayed at the left edge  |
  306. |                      of the entry field. The index is 0-based.               |
  307. ------------------------------------------------------------------------------*/
  308. IEntryField&
  309.   setFirstCharIndex(unsigned long index); //JJB
  310. unsigned long
  311.   firstCharIndex() const;
  312.  
  313. /*-------------------------------- TEST OPERATIONS -----------------------------
  314. |   isChanged  - Queries if the entry field text has changed.                  |
  315. |   isEmpty    - Queries if the entry field is empty.                          |
  316. |   isMarked   - Queries if any of the entry field text is selected.           |
  317. ------------------------------------------------------------------------------*/
  318. Boolean
  319.   isChanged() const,
  320.   isEmpty() const,
  321.   isMarked() const;
  322.  
  323. protected:
  324. /*----------------------------- LAYOUT SIZE ------------------------------------
  325. | calcMinSize - Returns the minimum size that this entry field control should be|
  326. ------------------------------------------------------------------------------*/
  327. virtual ISize
  328.   calcMinSize();
  329.  
  330. virtual void
  331.   setStyle(unsigned long style);
  332.  
  333.   IEntryField();
  334.  
  335. static Style
  336.   classDefaultStyle;
  337.  
  338. private:
  339. /*--------------------------------- PRIVATE ----------------------------------*/
  340.   IEntryField(const IEntryField&);
  341. //IEntryField& operator=(const IEntryField&);
  342.  
  343. IRange
  344.   getCursorInfo() const;
  345. void
  346.   setCursorInfo(const IRange& range);
  347.  
  348. enum ReadStatus { doesntMatter, wasInput, wasRead,
  349.                   wasInputButReset, wasReadButReset };
  350. ReadStatus
  351.   eReadStatus;
  352. };  // class IEntryField
  353.  
  354. INESTEDBITFLAGCLASSFUNCS(Style, IEntryField);
  355.                                   // global style functions
  356. #endif  /* _IENTRYFD_ */
  357.