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

  1. #ifndef _ICNRCOL_
  2. #define _ICNRCOL_
  3. /*******************************************************************************
  4. * FILE NAME: icnrcol.hpp                                                       *
  5. *                                                                              *
  6. * DESCRIPTION:                                                                 *
  7. *   Declaration of the class(es):                                              *
  8. *     IContainerColumn - Details View column information.                      *
  9. *                                                                              *
  10. * COPYRIGHT:                                                                   *
  11. *   (C) Copyright IBM Corporation 1992                                         *
  12. *   All Rights Reserved                                                        *
  13. *   Licensed Materials * Property of IBM                                       *
  14. *                                                                              *
  15. * HISTORY:                                                                     *
  16. * $Log:   U:/ibmclass/icnr/vcs/icnrcol.hpv  $
  17. //
  18. //   Rev 1.8   26 Oct 1992 16:53:24   PETERB
  19. //Added isVisible to column
  20. //
  21. //   Rev 1.7   25 Oct 1992 19:26:24   BOBLOVE
  22. //Updated documentation
  23. //
  24. //   Rev 1.6   25 Oct 1992 16:27:40   nunn
  25. //changed library name to ICLUI
  26. //
  27. //   Rev 1.5   25 Oct 1992 11:16:24   BOBLOVE
  28. //External Beta Release
  29. *                                                                              *
  30. *******************************************************************************/
  31.  
  32. #ifndef _IVBASE_
  33.   #include <ivbase.hpp>
  34. #endif
  35.  
  36. #ifndef _BITFLAGS_
  37.    #include <ibitflag.hpp>
  38. #endif
  39.  
  40. #ifndef _HANDLE_
  41.    #include <ihandle.hpp>
  42. #endif
  43.  
  44.  
  45.  
  46. //  Forward Declarations
  47. class IContainerWindow;
  48. class IContainerControl;
  49. class IResourceId;
  50. class IString;
  51. struct _FIELDINFO;
  52.  
  53.  
  54. class IContainerColumn : public IVBase
  55. {
  56. /*******************************************************************************
  57. * This class provides the container the ability to display a Details           *
  58. * view.  Functions exist to add, delete, and hide columns in a                 *
  59. * container control.  It also defines the characteristics of the header        *
  60. * for the column (text or icon) and the position of the data in the            *
  61. * record to be displayed in the column.                                        *
  62. *                                                                              *
  63. * The default implementation of a Container column has:                        *
  64. *                                                                              *
  65. *   1) a heading which contains centered, read-only text                       *
  66. *   2) a horizontal separator under the heading                                *
  67. *   3) a vertical separator between columns                                    *
  68. *   4) string data that is non-editable, left justified, and centered          *
  69. *      vertically                                                              *
  70. *                                                                              *
  71. * Notes:                                                                       *
  72. *  1) An IContainerColumn can only be added to one container.                  *
  73. *                                                                              *
  74. * EXAMPLE:                                                                     *
  75. *                                                                              *
  76. * IContainerColumn pIcon = new IContainerColumn(                               *
  77. *                         IContainerObject :: iconOffset(),                    *
  78. *                         IContainerColumn::defaultHeadingStyle,               *
  79. *                         IContainerColumn::bitmapOrIcon |                     *
  80. *                         IContainerColumn::centerVertically);                 *
  81. * IContainerColumn pName = new IContainerColumn(                               *
  82. *                         IContainerObject::iconTextOffset(),                  *
  83. *                         IContainerColumn::defaultHeadingStyle,               *
  84. *                         IContainerColumn::string |                           *
  85. *                         IContainerColumn::centerVertically |                 *
  86. *                         IContainerColumn::leftJustify |                      *
  87. *                         IContainerColumn::horizontalSeparator);              *
  88. *                                                                              *
  89. *                                                                              *
  90. * container().addColumn(pIcon);                                                *
  91. * container().addColumn(pName);                                                *
  92. *                                                                              *
  93. *                                                                             *
  94. *******************************************************************************/
  95. friend class IContainerControl;
  96.  
  97.                          /*----------------------*/
  98.                          /*    PUBLIC SECTION    */
  99.                          /*----------------------*/
  100. public:
  101. /*---------------------------- STYLES/ATTRIBUTES -------------------------------
  102. | The following styles are currently provided as typedefs:                     |
  103. |   IContainerControl::Style                                                   |
  104. |   IContainerControl::HeadingStyle                                            |
  105. |   IContainerControl::DataStyle                                               |
  106. | Default heading and datibutes can be queried/set with the following:         |
  107. |   defaultHeadingStyle        - Retrieve the default heading style.           |
  108. |   setDefaultHeadingStyle     - Set a new default heading style.              |
  109. |   defaultDataStyle           - Retrieve the default data style.              |
  110. |   setDefaultDataStyle        - Set a new default data style.                        |
  111. ------------------------------------------------------------------------------*/
  112. typedef unsigned long Style;
  113. typedef unsigned long HeadingStyle;
  114. typedef unsigned long DataStyle;
  115.     static const Style
  116.       string,                  /* default */
  117.       icon,
  118.       horizontalSeparator,
  119.       verticalSeparator,
  120.       /* One of */
  121.         topJustify,
  122.         bottomJustify,
  123.         centerVertically,     /* default */
  124.       /* One of */
  125.         leftJustify,          /* default */
  126.         rightJustify,
  127.         centerHorizontally;
  128.  
  129.     static const DataStyle   /* plus Heading styles */
  130.       date,
  131.       time,
  132.       number,
  133.       ownerDraw,
  134.       readOnlyData,           /* default */
  135.       invisible;              /* Column is invisible */
  136.  
  137.       static const HeadingStyle
  138.         readOnlyHeading;        /* default */
  139.  
  140.  
  141.  
  142. static const HeadingStyle
  143.   &defHeadingStyle;
  144. static const DataStyle
  145.   &defDataStyle;
  146.  
  147.  
  148. static Style
  149.   defaultHeadingStyle(),
  150.   defaultDataStyle();
  151. static void
  152.   setDefaultHeadingStyle( HeadingStyle style),
  153.   setDefaultDataStyle( DataStyle style);
  154.  
  155. /*------------------------ CONSTRUCTORS/DESTRUCTORS ----------------------------
  156. | There are two ways to construct instances of this class:                     |
  157. |   1. By providing the offset of the object data to be displayed in the       |
  158. |      column and optionally the styles to be used for the heading and data.   |
  159. |                                                                              |
  160. |   2. From and existing container column as a copy.                           |
  161. ------------------------------------------------------------------------------*/
  162.   IContainerColumn( unsigned long DataOffset,
  163.                   const HeadingStyle& title = defHeadingStyle,
  164.                   const DataStyle& data = defDataStyle);
  165.  
  166.   IContainerColumn( const IContainerColumn& cnrcol);
  167.  
  168. virtual
  169.   ~IContainerColumn();
  170.  
  171. /*-------------------------------- ACCESSORS -----------------------------------
  172. | These function provide means of getting and setting the accessible           |
  173. | attributes of instances of this class:                                       |
  174. |                                                                              |
  175. | setHeadingText       - Set Text to be used for the heading and change the    |
  176. |                        heading style to "string".                            |
  177. | setHeadingIcon       - Set the icon to be used for the heading and change    |
  178. |                        the style to "icon".                                  |
  179. | headingText          - Return the text in the heading if the style is        |
  180. |                        "string".                                             |
  181. | headingIcon          - Return the icon in the heading if the style is        |
  182. |                        "icon".                                               |
  183. | enableHeadingUpdate  - Allow an edit field to be opened on the heading. This |
  184. |                        is only valid if the style is "string".               |
  185. | disableHeadingUpdate - Disallow editing of the heading.                      |
  186. | enableDataUpdate     - Allow an edit field to be opened in the data of the   |
  187. |                        column. This is only valid if the style is "string".  |
  188. | disableDataUpdate    - Disallow editing of the column data.                  |
  189. | show                 - Make the column visible.                              |
  190. | hide                 - Make the column invisible.                            |
  191. | showHeadingSeparators  - Add vertical and/or horizontal separators to the    |
  192. |                          column heading.                                     |
  193. | hideHeadingSeparators  - Hide the column heading separators.                 |
  194. | showDataSeparators     - Add vertical and/or horizontal separators to the    |
  195. |                          column data.                                        |
  196. | hideDataSeparators     - Hide the column data separators.                    |
  197. | IsVisible            - Is the column currently visible?                      |
  198. | justifyHeading       - Set the justification of the heading to left, right,  |
  199. |                        or centered.                                          |
  200. | justifyData          - Set the justification of the data to left, right,     |
  201. |                        or centered.                                          |
  202. | setDisplayWidth      - Set the displayable width of the column in pels.      |
  203. | displayWidth         - Return the displayable width of the column in pels.   |
  204. | setDataOffset        - Identify where the data is located in a container     |
  205. |                        record for this column.                               |
  206. |                                                                              |
  207. ------------------------------------------------------------------------------*/
  208. virtual IContainerColumn
  209.  &setHeadingText( const char* Text),
  210.  &setHeadingText( const IResourceId& TextId),
  211.  &setHeadingIcon( const IPointerHandle& Icon),
  212.  &setHeadingIcon( const IResourceId& IconId);
  213.  
  214. virtual IString
  215.   headingText() const;
  216. virtual IPointerHandle
  217.   headingIcon() const;
  218.  
  219. virtual IContainerColumn
  220.  &enableHeadingUpdate(),
  221.  &disableHeadingUpdate(),
  222.  &enableDataUpdate(),
  223.  &disableDataUpdate();
  224.  
  225. virtual IContainerColumn
  226.  &show(),
  227.  &hide(),
  228.  &showHeadingSeparators( const HeadingStyle& separatorStyles =
  229.                           horizontalSeparator | verticalSeparator),
  230.  &hideHeadingSeparators(),
  231.  &showDataSeparators( const DataStyle& separatorStyles =
  232.                         horizontalSeparator | verticalSeparator),
  233.  &hideDataSeparators();
  234.  
  235. Boolean                                                               //ppb5
  236.   isVisible() const;                                                  //ppb5
  237.  
  238. /*----------------------------------------------------------*/
  239. /*  Set Justification of data                               */
  240. /*----------------------------------------------------------*/
  241. enum VerticalJustification { top, bottom, centerV};
  242. enum HorizontalJustification { left, right, centerH};
  243.  
  244. virtual IContainerColumn
  245.  &justifyData( VerticalJustification = centerV,
  246.                HorizontalJustification = centerH),
  247.  &justifyHeading( VerticalJustification = centerV,
  248.                   HorizontalJustification = centerH);
  249.  
  250. virtual IContainerColumn
  251.  &setDisplayWidth( unsigned long ulPelWidth);
  252. virtual unsigned long
  253.   displayWidth();
  254.  
  255. IContainerColumn
  256.  &setDataOffset(unsigned long ulDataOffset);
  257.  
  258.  
  259. protected:
  260. /*----------------------------- IMPLEMENTATION ---------------------------------
  261. | The following functions are used in the implementation of the class:         |
  262. |   setTitleAttributes - Set the passed attribute into the title.              |
  263. |   setDataAttributes  - Set the passed attribute into the title.              |
  264. |   titleAttributes    - Return the current title attributes in the container. |
  265. |   dataAttributes     - Return the current data attributes in the container.  |
  266. |   columnInfo         - Return the address of the containers column record.   |
  267. |   setContainer       - Store the container this column is in.                |
  268. |   invalidate         - Cause a refresh of the column if it is in a container.|
  269. ------------------------------------------------------------------------------*/
  270. virtual IContainerColumn
  271.  &setTitleAttributes( unsigned long  ulTitleAttr),
  272.  &setDataAttributes( unsigned long  ulDataAttr);
  273.  
  274. virtual unsigned long
  275.   titleAttributes() const,
  276.   dataAttributes() const;
  277.  
  278. _FIELDINFO
  279.  *columnInfo() const;
  280.  
  281. IContainerColumn
  282.  &setContainer( IContainerControl* pcnrctl),
  283.  &invalidate();
  284.  
  285. const char*
  286.   headingTextRef() const;
  287.  
  288.  
  289. private:
  290. /*--------------------------------- PRIVATE ----------------------------------*/
  291.  
  292.  
  293. IContainerControl
  294.  *pcnrctlCl;
  295. _FIELDINFO
  296.  *pfieldinfoCl;
  297. IBitmapHandle
  298.   bmphCl;
  299. IPointerHandle
  300.   ptrhCl;
  301. static Style
  302.   classDefaultHeadingStyle,
  303.   classDefaultDataStyle;
  304.  
  305.  } ;
  306.  
  307.     /*----------------------------------------------------------*/
  308.     /*  Inline Functions                                        */
  309.     /*----------------------------------------------------------*/
  310.     inline _FIELDINFO* IContainerColumn :: columnInfo() const
  311.                           {return pfieldinfoCl; }
  312.     inline IContainerColumn& IContainerColumn :: setContainer(IContainerControl* pcnrctl)
  313.                           {pcnrctlCl = pcnrctl; return *this; }
  314.  
  315. #endif
  316.  
  317.