home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional Developers Kit 1992 November / Disc01 / Disc01.mdf / cppbeta / ibmcli / icnrctl.hp_ / ICNRCTL.HPP
Encoding:
C/C++ Source or Header  |  1992-10-26  |  49.6 KB  |  1,063 lines

  1. #ifndef _ICNRCTL_
  2. #define _ICNRCTL_
  3. /*******************************************************************************
  4. * FILE NAME: icnrctl.hpp                                                       *
  5. *                                                                              *
  6. * DESCRIPTION:                                                                 *
  7. *   Declaration of the class(es):                                              *
  8. *     IContainerControl - Base container control class                         *
  9. *     IContainerObject::ObjectCursor - iterate the objects in a container      *
  10. *     IContainerObject::ColumnCursor - iterate the columns in a container      *
  11. *     ICnrControlList  - a collection of container controls                    *
  12. *                                                                              *
  13. * COPYRIGHT:                                                                   *
  14. *   (C) Copyright IBM Corporation 1992                                         *
  15. *   All Rights Reserved                                                        *
  16. *   Licensed Materials * Property of IBM                                       *
  17. *                                                                              *
  18. * HISTORY:                                                                     *
  19. * $Log:   U:/ibmclass/icnr/vcs/icnrctl.hpv  $
  20. //
  21. //   Rev 1.18   26 Oct 1992 17:36:18   PETERB
  22. //Added ScrolltoObject for columns
  23. //
  24. //   Rev 1.17   25 Oct 1992 19:26:36   BOBLOVE
  25. //Updated documentation
  26. //
  27. //   Rev 1.16   25 Oct 1992 16:27:44   nunn
  28. //changed library name to ICLUI
  29. //
  30. //   Rev 1.15   25 Oct 1992 11:16:28   BOBLOVE
  31. //External Beta Release
  32. *                                                                              *
  33. *******************************************************************************/
  34.  
  35. #ifndef _ICONTROL_
  36.   #include <icontrol.hpp>
  37. #endif
  38.  
  39. #ifndef _ICNROBJ_
  40.   #include <icnrobj.hpp>
  41. #endif
  42.  
  43. #ifndef _IRECT_
  44.   #include <irect.hpp>
  45. #endif
  46.  
  47.  
  48. //  Forward Declarations
  49. class IContainerControl;
  50. class IContainerColumn;
  51. class IContainerObject;
  52. class IResourceId;
  53. class IPrivateResource;
  54. class IMultiLineEdit;
  55. struct ICnrInfo;
  56.  
  57.  
  58.  
  59. // Replace with BB
  60. #ifdef _USEBB_
  61.   #include <iset.h>
  62. #else
  63.   #include <iset.hpp>
  64. #endif
  65.  
  66. /*---------------------------------------------------------*/
  67. /*  Type Definition of Sort and Filter Functions           */
  68. /*  Warning: These callback functions will be made         */
  69. /*  obsolete in the future - replace with objects.         */
  70. /*---------------------------------------------------------*/
  71. #if (OS2LEVEL > 130)
  72.   typedef long  (_System ICOMPOBJCALLBACK)(const IContainerObject* pcnrobj1,
  73.                              const IContainerObject* pcnrobj2,
  74.                              void *pUserData);
  75.   typedef Boolean  (_System IFILTEROBJCALLBACK)(const IContainerObject* pcnrobj,
  76.                                     const IContainerControl*pcnrctl);
  77. #else
  78.   typedef long  (pascal far ICOMPOBJCALLBACK)(const IContainerObject* pcnrobj1,
  79.                              const IContainerObject* pcnrobj2,
  80.                              void *pUserData);
  81.   typedef Boolean (pascal far IFILTEROBJCALLBACK)(const IContainerObject* pcnrobj,
  82.                                     const IContainerControl*pcnrctl);
  83. #endif
  84.  
  85. #ifdef _USEBB_
  86.    typedef ISet<IContainerControl*> ICnrControlList;
  87. #else
  88.  
  89.    declare(IGSet1,  IContainerControl);
  90.    class ICnrControlList : public IGSet1(IContainerControl)
  91.    {
  92.      public:
  93.          ICnrControlList()   : IGSet1(IContainerControl)() {}
  94.  
  95.    };
  96.  
  97. #endif
  98.  
  99.  
  100. class IContainerControl : public IControl
  101. {
  102. /*******************************************************************************
  103. * IContainerControl is used to display a container of objects in any of        *
  104. * the supported views (Icon, Name, Tree, Details, Text).                       *
  105. *                                                                              *
  106. * This control can be constructed similar to the other controls in the         *
  107. * library - on a window, loaded in a dialog template, or as a pre-existing     *
  108. * control.                                                                     *
  109. *                                                                              *
  110. * EXAMPLE:                                                                     *
  111. * ** Frame Window Constructor **                                               *
  112. * CustomerList :: CustomerList(const IRectangle& rect,                         *
  113. *                                Boolean fLoadObjectsIn)                       *
  114. *   : IFrameWindow(CNR_MAINWINDOW)                                             *
  115. *    **  Create a Container Control  **                                        *
  116. * pCustContainer = new IContainerControl(CNR_RESID, this, this);               *
  117. *   ** Make the container the client **                                        *
  118. * setClient(pCustContainer);                                                   *
  119. *   ** Now construct columns and objects **                                    *
  120. *******************************************************************************/
  121.   typedef IControl Inherited;
  122.   friend class IContainerColumn;
  123.   friend class IContainerObject;
  124.   friend class ICnrEditHandler;
  125.  
  126. public:
  127. /*---------------------------- ENUMERATIONS ------------------------------------
  128. | The following enumerations are defined:                                      |
  129. |   state               - internal container state flag                        |
  130. |   enumerationOrder    - order that icons are enumerated in                   |
  131. |   titleAlighnment     - title justification                                  |
  132. ------------------------------------------------------------------------------*/
  133.     enum state { ok=1, noRefresh=2, invalid=4};
  134.     enum enumerationOrder { inItemOrder, inIconZOrder};
  135.     enum titleAlignment { left, right, center};
  136.  
  137. /*---------------------------- STYLES/ATTRIBUTES -------------------------------
  138. | The following classes are macro generated:                                   |
  139. |   IContainerControl::Style                                                   |
  140. |   IContainerControl::Attribute                                               |
  141. | Default styles and attributes can be queried/set with the following:         |
  142. |   defaultStyle        - retrieve the default style                           |
  143. |   setDefaultStyle     - set a new default style                              |
  144. |   defaultAttribute    - retrieve the default style                           |
  145. |   setDefaultAttribute - set a new default style                              |
  146. ------------------------------------------------------------------------------*/
  147.     INESTEDBITFLAGCLASSDEF2( Style, IContainerControl, IWindow, IControl);
  148.     INESTEDBITFLAGCLASSDEF0( Attribute, IContainerControl);
  149.  
  150.     /* Available const styles (in addition to IWindow/IControl)               */
  151.     static const Style
  152.       readOnly,
  153.       autoPosition,       /* default */
  154.       extendedSelection,
  155.       singleSelection,    /* default */
  156.       multipleSelection,
  157.       verifyPointers;
  158.  
  159.     /* Available const attributes    */
  160.     static const Attribute
  161.       textView,
  162.       iconView,           /* default */
  163.       nameView,
  164.       detailsView,
  165.       treeView,
  166.       flowedView,
  167.       readOnlyTitle,      /* default */
  168.       titleSeparator,
  169.       detailsViewTitles,  /* default */
  170.       visibleTitle,
  171.       centeredTitle,
  172.       leftJustifiedTitle,
  173.       rightJustifiedTitle,
  174.       handleForgroundPaint,
  175.       handleBackgroundPaint,
  176.       orderedTargetEmphasis,
  177.       mixedTargetEmphasis,
  178.       visibleTreeLine;          /* default */
  179.  
  180.     /* References to default styles and attributes  */
  181.     static const Style&      defStyle;
  182.     static const Attribute&  defAttribute;
  183.  
  184. static Style
  185.   defaultStyle();
  186. static void
  187.   setDefaultStyle( Style style);
  188. static Attribute
  189.   defaultAttribute();
  190. static void
  191.   setDefaultAttribute( Attribute attribute);
  192.  
  193. /*------------------------ CONSTRUCTORS/DESTRUCTORS ----------------------------
  194. | There are 3 ways to construct instances of this class:                       |
  195. |   1. On a window by specifying the parent and owner.                         |
  196. |                                                                              |
  197. |   2. From a container control on a loaded dialog template.                   |
  198. |                                                                              |
  199. |   3. From and existing container control's window handle.                    |
  200. ------------------------------------------------------------------------------*/
  201.   /* Construct a control from scratch */
  202.   IContainerControl( unsigned long Id,
  203.                      const IWindow* parent,
  204.                      const IWindow* owner,
  205.                      const IRectangle& initial = IRectangle(),
  206.                      const Style& initialStyle
  207.                               = defStyle,
  208.                      const Attribute& initialAttribute
  209.                               = defAttribute);
  210.  
  211.   /* Construct from a control on a Dialog */
  212.   IContainerControl( unsigned long Id,
  213.                      const IWindow* parentDialog);
  214.  
  215.   /* Construct from an existing control */
  216.   IContainerControl( IWindowHandle handle);
  217.  
  218.   /* Compare two controls, equality if they are the same */
  219.   Boolean operator==( const IContainerControl& that) { return (&that==this); }
  220.  
  221. virtual
  222.   ~IContainerControl();
  223.  
  224. /*------------------------ INITIALIZATION --------------------------------------
  225. | initialize  - setup the container environment.  Called automatically if      |
  226. |   the first container component created is an IContainerControl but MUST     |
  227. |   be called explicitly if creating IContainerObjects before the container    |
  228. |   is constructed.                                                            |
  229. ------------------------------------------------------------------------------*/
  230. static void
  231.      initialize();
  232.  
  233.  
  234.    class ObjectCursor
  235.    {
  236.    /***************************************************************************
  237.    *  The cursor class is used to iterate the container finding objects       *
  238.    *  based on the selection criteria established during construction of the  *
  239.    *  cursor.                                                                 *
  240.    *                                                                          *
  241.    * EXAMPLE:                                                                 *
  242.    *  ** smack all the objects in a container **                              *
  243.    *  IContainerControl::ObjectCursor cursor(*pCustContainer)                 *
  244.    *  for (cursor.setToFirst();                                               *
  245.    *       cursor.isValid();                                                  *
  246.    *       cursor.setToNext() )                                               *
  247.    *  {                                                                       *
  248.    *     object.objectAt(cursor).smack();                                     *
  249.    *  }                                                                       *
  250.    *                                                                          *
  251.    ***************************************************************************/
  252.    public:
  253.    /*------------------------ CONSTRUCTORS/DESTRUCTORS -------------------------
  254.    | There are 3 ways to construct instances of this class:                    |
  255.    |  1) A cursor to iterate all records in the container or records meeting   |
  256.    |   the Emphasis selection criteria. Records can be found in item order     |
  257.    |   (the default) or Z order.                                               |
  258.    |  2) A cursor to find text in the Icon View. The search can be case        |
  259.    |   sensitive or not and the text can required to start the icon string.    |
  260.    |  3) A cursor to find all objects that have the passed object as a parent. |
  261.    ---------------------------------------------------------------------------*/
  262.    ObjectCursor( const IContainerControl& container,
  263.                  IContainerObject::emphasis Emphasis= IContainerObject::none,
  264.                  enumerationOrder Enumeration=inIconZOrder);
  265.  
  266.    /* Construct an iterator for text occurances */
  267.    ObjectCursor( const IContainerControl& container,
  268.                  const char*  Text,
  269.                  Boolean isCaseSensitive = true,
  270.                  Boolean isFirstInRecord = false);
  271.  
  272.    /* Construct an iterator for Child Iteration */
  273.    ObjectCursor( const IContainerControl& container,
  274.                  const IContainerObject* parentObject);
  275.  
  276.    virtual
  277.      ~ObjectCursor();
  278.  
  279.    /*------------------------ CURSOR MOVEMENT ----------------------------------
  280.    | setToFirst - point to the first object in the container                   |
  281.    | setToNext  - point to the next or first object in the container           |
  282.    | setToLast  - point to the last object in the container                    |
  283.    | setToPrevious - point to the previous or last object in the container     |
  284.    ---------------------------------------------------------------------------*/
  285.    virtual  Boolean
  286.      setToFirst(),
  287.      setToNext(),
  288.      setToLast(),
  289.      setToPrevious();
  290.  
  291.    /*------------------------ CURSOR MOVEMENT/ OBJECT RETRIEVAL ----------------
  292.    | first - point to and return the first object in the container             |
  293.    | next  - point to and return the next or first object in the container     |
  294.    | last  - point to and return the last object in the container              |
  295.    | previous - point to and return the previous or last object in  container  |
  296.    | current - return the current object of this cursor                        |
  297.    | setCurrent - set the cursor to point to a particular object               |
  298.    ---------------------------------------------------------------------------*/
  299.     IContainerObject
  300.      *first(),
  301.      *next(),
  302.      *previous(),
  303.      *last(),
  304.      *current() const;
  305.     void
  306.       setCurrent( const IContainerObject* Current);
  307.  
  308.    /*------------------------ CURSOR VALIDATION --------------------------------
  309.    | isValid - does this cursor point to a valid object?                       |
  310.    | invalidate - flag this cursor as invalid                                  |
  311.    ---------------------------------------------------------------------------*/
  312.      virtual  Boolean
  313.        isValid() const;
  314.      virtual void
  315.        invalidate();
  316.  
  317.    protected:
  318.    /*----------------------------- IMPLEMENTATION ------------------------------
  319.    | object - retrieve an object in the container                              |
  320.    | find   - search for an object in the container                            |
  321.    | selectedObject - return an object with the specified emphasis             |
  322.    ---------------------------------------------------------------------------*/
  323.    IContainerObject
  324.     *object( const IContainerObject* pcnrobjAfter,
  325.              unsigned long  ulCmd),
  326.     *find( unsigned long ulView,
  327.            IContainerObject* pcnrobjAfter,
  328.            const char* pszText,
  329.            Boolean fIsCaseSensitive,
  330.            Boolean fIsFirstInRecord),
  331.     *selectedObject( const IContainerObject* pcnrobjAfter,
  332.                      unsigned long  ulEmphasis);
  333.    private:
  334.    /*------------------------------ DATA MEMBERS -------------------------------
  335.    |  pcnrobjClCurrent     - the current object or zero                        |
  336.    |  pcnrobjClParent      - the parent to search for descendent objects       |
  337.    |  ulClView             - the view to search in                             |
  338.    |  pcnrctlClOwner       - the container to search                           |
  339.    |  flClEmphasis         - the emphasis to restrict the search               |
  340.    |  strClSearchString    - text for search                                   |
  341.    |  fClIsCaseSensitive   - should text search be case sensitive or not       |
  342.    |  fClIsFirstInRecord   - must match from the beginning                     |
  343.    |  flClEnumeration      - order to enumerate in icon view                   |
  344.    ---------------------------------------------------------------------------*/
  345.    IContainerObject
  346.     *pcnrobjClCurrent,
  347.     *pcnrobjClParent;
  348.    unsigned long
  349.      ulClView;
  350.    IContainerControl
  351.     *pcnrctlClOwner;
  352.    unsigned long
  353.      flClEmphasis;
  354.    IString
  355.      strClSearchString;
  356.    Boolean
  357.      fClIsCaseSensitive,
  358.      fClIsFirstInRecord;
  359.    unsigned long
  360.      flClEnumeration;
  361.    };  /* end ObjectCursor */
  362.  
  363.  
  364.    class ColumnCursor
  365.    {
  366.    /***************************************************************************
  367.    * The cursor class is used to iterate the containers details view columns  *
  368.    *                                                                          *
  369.    * EXAMPLE:                                                                 *
  370.    *  ** smack all the columns in a container **                              *
  371.    *  IContainerControl::ColumnCursor cursor(*pCustContainer);                *
  372.    *  for (cursor.setToFirst();                                               *
  373.    *       cursor.isValid();                                                  *
  374.    *       cursor.setToNext() )                                               *
  375.    *  {                                                                       *
  376.    *     object.columnAt(cursor).smack();                                     *
  377.    *  }                                                                       *
  378.    *                                                                          *
  379.    ****************************************************************************/
  380.    public:
  381.    /*------------------------ CONSTRUCTORS/DESTRUCTORS -------------------------
  382.    | There is 1 way to construct an instance of this class:                    |
  383.    |  1) A cursor to iterate all columns in the container meeting the          |
  384.    |   visibility criteria(All columns or visible columns only).               |
  385.    ---------------------------------------------------------------------------*/
  386.    ColumnCursor( const IContainerControl& container,
  387.                  Boolean VisibleOnly=false);
  388.    virtual
  389.      ~ColumnCursor()  {}
  390.  
  391.    /*------------------------ CURSOR MOVEMENT ----------------------------------
  392.    | setToFirst - point to the first column in the container                   |
  393.    | setToNext  - point to the next or first column in the container           |
  394.    | setToLast  - point to the last column in the container                    |
  395.    | setToPrevious - point to the previous or last column in the container     |
  396.    ---------------------------------------------------------------------------*/
  397.    virtual  Boolean
  398.      setToFirst(),
  399.      setToNext(),
  400.      setToLast(),
  401.      setToPrevious();
  402.  
  403.    /*------------------------ CURSOR MOVEMENT/ COLUMN RETRIEVAL ----------------
  404.    | first - point to and return the first column in the container             |
  405.    | next  - point to and return the next or first column in the container     |
  406.    | last  - point to and return the last column in the container              |
  407.    | previous - point to and return the previous or last column in  container  |
  408.    | current - return the current column of this cursor                        |
  409.    | setCurrent - set the cursor to point to a particular column               |
  410.    ---------------------------------------------------------------------------*/
  411.    virtual IContainerColumn
  412.      *first(),
  413.      *next(),
  414.      *previous(),
  415.      *last(),
  416.      *current() const;
  417.    void
  418.      setCurrent( const IContainerColumn* Current);
  419.  
  420.    /*------------------------ CURSOR VALIDATION --------------------------------
  421.    | isValid - does this cursor point to a valid column?                       |
  422.    | invalidate - flag this cursor as invalid                                  |
  423.    ---------------------------------------------------------------------------*/
  424.    virtual  Boolean
  425.      isValid() const;
  426.    virtual void
  427.      invalidate();
  428.  
  429.    private:
  430.    /*------------------------------ DATA MEMBERS -------------------------------
  431.    |  pcnrcolClCurrent     - the current column or zero                        |
  432.    |  pcnrctlOwner         - the container to search                           |
  433.    |  fClVisible           - should search be on visible columns only          |
  434.    ---------------------------------------------------------------------------*/
  435.    IContainerColumn
  436.      *pcnrcolClCurrent;
  437.    IContainerControl
  438.      *pcnrctlClOwner;
  439.    Boolean
  440.      fClVisible;
  441.    };
  442.   friend class ColumnCursor;
  443.  
  444.  
  445.  
  446. /*-------------------------------- ACCESSORS -----------------------------------
  447. | These function provide means of getting and setting the accessible           |
  448. | attributes of instances of this class:                                       |
  449. |                                                                              |
  450. | setContainerTitle     - Set container title using text or a resource ID.     |
  451. | justifyContainerTitle - Set the justification attributes for the title.      |
  452. | showContainerTitle    - Show the container title.                            |
  453. | hideContainerTitle    - Remove the container title from the container window.|
  454. | enableTitleUpdate     - Allow the container title to be edited.              |
  455. | disableTitleUpdate    - Do not allow the container title to be edited        |
  456. | showTitleSeparator    - Display a horizontal separator between title and     |
  457. |                         viewport.                                            |
  458. | hideTitleSeparator    - Remove title separator from container window.        |
  459. | showDetailsViewTitles - Display column titles in details view.               |
  460. | hideDetailsViewTitles - Remove column titles from details view.              |
  461. | setLineSpacing        - Set vertical distance between records.               |
  462. | setIconSize           - Set Icon or Bitmap size for all objects.             |
  463. | setSingleSelection       - Set selection mode to Single Selection.           |
  464. | setMultipleSelection     - Set selection mode to Multiple Selection.         |
  465. | setExtendedSelection     - Set selection mode to Extended Selection.         |
  466. | setNormalTargetEmphasis  - Set drag mode to normal object emphasis.          |
  467. | setOrderedTargetEmphasis - Set drag mode to ordered target emphasis.         |
  468. | setMixedTargetEmphasis   - Set drag mode to mixed target emphasis            |
  469. | containerTitle           - Query the title of the container.                 |
  470. | isContainerTitleVisible  - Is the container title currently displayed?       |
  471. | lineSpacing              - Query the space in Pixels between lines.          |
  472. | iconSize                 - Query the icon or bitmap size of all objects.     |
  473. ------------------------------------------------------------------------------*/
  474. IContainerControl
  475.  &setContainerTitle( const char* pszTitle),
  476.  &setContainerTitle( const IResourceId& resid),
  477.  &justifyContainerTitle( titleAlignment align = center),
  478.  &showContainerTitle(),
  479.  &hideContainerTitle(),
  480.  &enableTitleUpdate(),
  481.  &disableTitleUpdate(),
  482.  &showTitleSeparator(),
  483.  &hideTitleSeparator(),
  484.  &showDetailsViewTitles(),
  485.  &hideDetailsViewTitles(),
  486.  &setLineSpacing( long lLineSpacing),
  487.  &setIconSize( const ISize& sizeIcon),
  488.  &setSingleSelection(),
  489.  &setMultipleSelection(),
  490.  &setExtendedSelection(),
  491.  &setNormalTargetEmphasis(),
  492.  &setOrderedTargetEmphasis(),
  493.  &setMixedTargetEmphasis();
  494.  
  495. IString
  496.    containerTitle() const;
  497.  
  498. Boolean
  499.   isContainerTitleVisible() const;
  500.  
  501. long
  502.   lineSpacing() const;
  503.  
  504. ISize
  505.   iconSize() const;
  506.  
  507. /******************************************************************************/
  508. /* The following functions are still under development and are in the midst of*/
  509. /* substantial change.                                                        */
  510. /******************************************************************************/
  511. IContainerControl
  512.  &enableCaching( unsigned long ulDeltaValue = 30),
  513.  &disableCaching(),
  514.  &enableOwnerDraw(),
  515.  &disableOwnerDraw(),
  516.  &enableOwnerPaintBackground(),
  517.  &disableOwnerPaintBackground();
  518.  
  519.  
  520.  
  521. /*-------------------- CHANGING THE CONTAINER VIEW -----------------------------
  522. | showTextView       - Set the current view to Non-flowed Text View.           |
  523. | showFlowedTextView - Set the current view to Flowed Text View.               |
  524. | showNameView       - Set the current view to Non-flowed Name View.           |
  525. | showFlowedNameView - Set the current view to Flowed Name View.               |
  526. | showDetailsView    - Set the current view to Details View.                   |
  527. | showTreeIconView   - Set the current view to Tree-icon View.                 |
  528. | showTreeTextView   - Set the current view to Tree-text View.                 |
  529. | showTreeNameView   - Set the current view to Tree-name View.                 |
  530. | showIconView       - Set the current view to Icon View.                      |
  531. | arrangeIconView    - Arrange the Icon View.                                  |
  532. ------------------------------------------------------------------------------*/
  533. IContainerControl
  534.  &showTextView(),
  535.  &showFlowedTextView(),
  536.  &showNameView(),
  537.  &showFlowedNameView(),
  538.  &showDetailsView(),
  539.  &showTreeIconView(),
  540.  &showTreeTextView(),
  541.  &showTreeNameView(),
  542.  &showIconView(),
  543.  &arrangeIconView();
  544.  
  545. /*-------------- QUERYING THE CURRENT CONTAINER VIEW ---------------------------
  546. | isTextView     - Is the container currently in Text View?                    |
  547. | isNameView     - Is the container currently in Name View?                    |
  548. | isDetailsView  - Is the container currently in Details View?                 |
  549. | isTreeView     - Is the container currently in Tree View?                    |
  550. | isIconView     - Is the container currently in Icon View?                    |
  551. | isFlowed       - Is the current container view flowed?                       |
  552. ------------------------------------------------------------------------------*/
  553. Boolean
  554.   isTextView() const,
  555.   isNameView() const,
  556.   isDetailsView() const,
  557.   isTreeView() const,
  558.   isIconView() const,
  559.  
  560.   isFlowed() const;
  561.  
  562. /*-------------------- CONTAINER REFRESH ---------------------------------------
  563. | setRefreshOff        - Disable refreshing the container after changes.       |
  564. | setRefreshOn         - Enable refreshing the container after changes.        |
  565. | refresh              - Refresh all objects in the container.                 |
  566. | refreshAllContainers - Refresh all containers.                               |
  567. | isRefreshOn          - Query the refresh state of the container.             |
  568. ------------------------------------------------------------------------------*/
  569. IContainerControl
  570.  &setRefreshOff(),
  571.  &setRefreshOn(),
  572.  &refresh();
  573.  
  574. static void
  575.   refreshAllContainers();
  576.  
  577. Boolean
  578.   isRefreshOn();
  579.  
  580. /*-------------- QUERYING THE CONTAINER VIEWPORT RECTANGLE ---------------------
  581. | viewportOnWorkspace - Retrieve the current viewport in workspace coordinates |
  582. | viewportOnWindow    - Retrieve the current viewport in window coordinates    |
  583. | detailsViewportOnWorkspace - Details viewport(R or L) in workspace  coord.   |
  584. | detailsViewportOnWindow    - Details viewport(R or L) in window  coord.      |
  585. ------------------------------------------------------------------------------*/
  586. IRectangle
  587.   viewportOnWorkspace() const,
  588.   viewportOnWindow() const,
  589.   detailsViewportOnWorkspace( Boolean fRight = false) const,
  590.   detailsViewportOnWindow( Boolean fRight = false) const;
  591.  
  592. /*------------------- SCROLLING ------------------------------------------------
  593. | scrollVertically   - Scroll the container vertically.                        |
  594. | scrollHorizontally - Scroll the container horizontally.                      |
  595. | scroll             - Scroll both horizontally and vertically.                |
  596. | scrollDetailsHorizontally - Scroll right or left Details view horizontally.  |
  597. | scrollToObject - Scroll a particular object into the vieport.                |
  598. | scrollToObject - Scroll a particular object and column into the viewport.    |
  599. ------------------------------------------------------------------------------*/
  600. virtual IContainerControl
  601.  &scrollVertically( long lPixels),
  602.  &scrollHorizontally( long lPixels,
  603.                       Boolean fRight=false),
  604.  &scroll( long lVericalPixels,
  605.           long lHorizontalPixels,
  606.           Boolean fRight=false),
  607.  &scrollDetailsHorizontally( long lHorizontalPixels,
  608.                              Boolean fRight=false),
  609.  &scrollToObject( const IContainerObject* Object),
  610.  &scrollToObject( const IContainerObject* Object,
  611.                   const IContainerColumn* Column);
  612.  
  613. /*------------------------------------------------------------------------------
  614. | The following functions are still under development and are in the midst of  |
  615. | substantial change.                                                          |
  616. ------------------------------------------------------------------------------*/
  617. IContainerControl
  618.  &setIconViewBackground( const IBitmapHandle& Background,
  619.                          const ISize& sizBitmap),
  620.  &setIconViewBackground( const IBitmapHandle& Background),
  621.  &removeIconViewBackground();
  622.  
  623. /*------------------- TREE VIEW FUNCTIONS --------------------------------------
  624. | showTreeLine - Show lines connecting parents to children records.            |
  625. | hideTreeLine - Do not show lines connecting parents to children records.     |
  626. | setTreeExpandIconSize - Change the size of the Expanded/Collapsed Bitmaps.   |
  627. | setTreeViewIndent  - Set distance children will be offset horiz. from parent.|
  628. | setTreeItemBitmaps - Set the Bitmaps to be use for Tree View.                |
  629. | setTreeItemIcons   - Set the Icons to be used for Tree View.                 |
  630. | collapseTree       - Collapse all nodes of Tree view.                        |
  631. | expandTree         - Expand all nodes of Tree view.                          |
  632. ------------------------------------------------------------------------------*/
  633. virtual IContainerControl
  634.  &showTreeLine( long lTreeLinePelWidth=-1),
  635.  &hideTreeLine(),
  636.  &setTreeExpandIconSize( const ISize& sizeIcon),
  637.  &setTreeViewIndent( long lIndentPels=-1),
  638.  &setTreeItemBitmaps( const IBitmapHandle& Expanded,
  639.                       const IBitmapHandle& Collapsed),
  640.  &setTreeItemBitmaps( const IResourceId& Expanded,
  641.                       const IResourceId& Collapsed),
  642.  &setTreeItemIcons( const IPointerHandle& Expanded,
  643.                     const IPointerHandle& Collapsed),
  644.  &setTreeItemIcons( const IResourceId& Expanded,
  645.                     const IResourceId& Collapsed),
  646.  &collapseTree(),
  647.  &expandTree();
  648.  
  649. /*------------------- DETAILS VIEW FUNCTIONS -----------------------------------
  650. | showSplitBar        - Add the split bar to the details view viewport.        |
  651. | hideSplitBar        - Remove the split bar from the detail view viewport.    |
  652. | setDetailsViewSplit - Split the details view- specifying last column in left.|
  653. | isColumnRight       - Return true if the given column is to the right        |
  654. |                       of the splitbar.                                       |
  655. | addColumn           - Add column to container following the given column.    |
  656. | removeColumn        - Remove given column from the container.                |
  657. | removeColumnAt      - Remove the column at a gievn index or Cursor.          |
  658. | columnAt            - Retrieve column at given index or Cursor.              |
  659. | detailsViewSplit    - Return last column before split bar.                   |
  660. | columnCount         - Return number of columns in the container.             |
  661. ------------------------------------------------------------------------------*/
  662. virtual IContainerControl
  663.  &showSplitBar(),
  664.  &hideSplitBar(),
  665.  &setDetailsViewSplit(
  666.      const IContainerColumn* LastColumnBeforeSplit,
  667.      unsigned long ulPixelsFromLeft=50);
  668.                 /* note: the 1st parameter is the last column  */
  669.                 /* which will ever be scrolled in the left     */
  670.                 /* frame. The 2nd parameter is the location    */
  671.                 /* of the split bar in Pixels                  */
  672. Boolean
  673.   isColumnRight( const IContainerColumn* pcnrcol) const;
  674.  
  675. virtual IContainerControl
  676.  &addColumn( const IContainerColumn* Column,
  677.              const IContainerColumn* AfterColumn=0),
  678.  &removeColumn( const IContainerColumn* Column),
  679.  &removeColumnAt( IContainerControl::ColumnCursor& cursor);
  680.  
  681. IContainerColumn
  682.  *columnAt( unsigned long Index) const,
  683.  *columnAt( const ColumnCursor&) const,
  684.  *detailsViewSplit() const;
  685.  
  686. unsigned long
  687.     columnCount() const;
  688.  
  689. /*------------------- ADDING AND REMOVING OBJECTS ------------------------------
  690. | addObject             - Add an object to the container. The parent defines   |
  691. |                         the objects location in the tree view.               |
  692. | addObjectAfter        - Add an object to be placed after a given object      |
  693. | removeObject          - Remove an object from this container or all          |
  694. |                         containers.                                          |
  695. | removeObjectAt        - Remove the object at the Cursor location.            |
  696. | removeSelectedObjects - Remove all selected objects from the container.      |
  697. | removeAllObjects      - Remove all objects from the container.               |
  698. | deleteSelectedObjects - Delete this containers selected objects.  If an      |
  699. |                         object exists in other containers it is removed      |
  700. |                         and deleted from them as well.                       |
  701. | deleteAllObjects      - Delete all objects in this container. If an          |
  702. |                         object exists in other containers it is removed      |
  703. |                         and deleted from them as well.                       |
  704. ------------------------------------------------------------------------------*/
  705. virtual IContainerControl
  706.  &addObject( const IContainerObject* newObject,
  707.              const IContainerObject* parentObject = 0),
  708.  &addObjectAfter( const IContainerObject* newObject,
  709.                   const IContainerObject* afterObject,
  710.                   const IContainerObject* parentObject = 0),
  711.   /* remove does not delete the object */
  712.  &removeObject( IContainerObject* object,
  713.                 Boolean fAllContainers = false),
  714.  &removeObjectAt( IContainerControl::ObjectCursor& cursor),
  715.  &removeSelectedObjects(),
  716.  &removeAllObjects(),
  717.  &deleteSelectedObjects(),
  718.  &deleteAllObjects();
  719.  
  720. /*----------------- MOVING/COPYING SUBTREES ------------------------------------
  721. | moveObjectTo - Move an object and it's descendents to a new location in the  |
  722. |                tree view.                                                    |
  723. | copyObjectTo - Copy an object and it's descendents to a new location in the  |
  724. |                tree view. The object must overload the "objectCopy" function.|
  725. ------------------------------------------------------------------------------*/
  726. Boolean
  727.   moveObjectTo( IContainerObject* moveObject,
  728.                 IContainerObject* newParent = 0,
  729.                 IContainerControl* newContainer = 0),
  730.   copyObjectTo( IContainerObject* copyObject,
  731.                 IContainerObject* Parent = 0,
  732.                 IContainerControl* newContainer = 0);
  733.  
  734. Boolean
  735.    containsObject( const IContainerObject* Object) const;
  736.  
  737. /*-------------------- RETRIEVING OBJECTS --------------------------------------
  738. | objectAt               - Return an object at an index in the container.      |
  739. | objectAt               - Return an object at a Cursor location.              |
  740. | parent                 - Return the parent object in the container tree view.|
  741. | descendentsOf          - Return the set of all descendents of an object      |
  742. |                          in the container tree view.                         |
  743. | immediateDescendentsOf - Return the set of immediate descendents (only) of   |
  744. |                          an object in the container tree view.               |
  745. | objectList             - Return the set of all objects in the container.     |
  746. ------------------------------------------------------------------------------*/
  747. virtual IContainerObject
  748.  *objectAt( unsigned long ulIndex) const,
  749.  *objectAt( const IContainerControl::ObjectCursor&) const,
  750.  *parent() const;
  751.  
  752.  /* Return a list of descendents of the passed object */
  753. ICnrObjectSet
  754.   descendentsOf( IContainerObject* ParentObject) const,
  755.   immediateDescendentsOf( IContainerObject* ParentObject) const,
  756.   objectList() const;
  757.  
  758.  
  759. unsigned long
  760.   objectCount() const;
  761.  
  762.  
  763. IContainerControl
  764.  &setDestroyObjectsOnClose() {fClDestructObjects=true; return *this;}
  765.  
  766. /*------------------ SETTING OBJECT ATTRIBUTES ---------------------------------
  767. | setSelected       - Give an object selection emphasis.                       |
  768. | removeSelected    - Remove selection emphasis from an object.                |
  769. | setInUse          - Give an object in-use emphasis.                          |
  770. | removeInUse       - Remove in-use emphasis from an object.                   |
  771. | setCursor         - Give an object cursored emphasis.                        |
  772. | enableDataUpdate  - Disable read-only for an object.                         |
  773. | disableDataUpdate - Make an object read-only.                                |
  774. | expand            - Expand a tree-view parent object.                        |
  775. | collapse          - Collapse a tree-view parent object.                      |
  776. | refresh           - Invalidate an object so it will be redrawn.              |
  777. | enableDrop        - Set an object to receive target emphasis during drag.    |
  778. | disableDrop       - Set an object to not droponable, no target emph is drawn.|
  779. ------------------------------------------------------------------------------*/
  780. IContainerControl
  781.  &setSelected( IContainerObject* pcnrobj),
  782.  &removeSelected( IContainerObject* pcnrobj),
  783.  &setInUse( IContainerObject* pcnrobj),
  784.  &removeInUse( IContainerObject* pcnrobj),
  785.  &setCursor( IContainerObject* pcnrobj),
  786.  &enableDataUpdate( IContainerObject* pcnrobj),
  787.  &disableDataUpdate( IContainerObject* pcnrobj),
  788.  &expand( IContainerObject* pcnrobj),
  789.  &collapse( IContainerObject* pcnrobj),
  790.  &refresh( IContainerObject* pcnrobj),
  791.  &enableDrop( IContainerObject* pcnrobj),
  792.  &disableDrop( IContainerObject* pcnrobj);
  793.  
  794. /*------------------ QUERYING OBJECT ATTRIBUTES --------------------------------
  795. | isTarget     - Is the object a target of direct manipulation?                |
  796. | isSelected   - Does the object have selection emphasis?                      |
  797. | isInUse      - Does the object have in-use emphasis?                         |
  798. | isCursored   - Does the object have cursored emphasis?                       |
  799. | isFiltered   - Is the object currently filtered out?                         |
  800. | isExpanded   - Is the tree-view node object currently expanded?              |
  801. | isCollapsed  - Is the tree-view node object currently collapsed?             |
  802. | isReadOnly   - Is the object read-only(no direct edit support)?              |
  803. | isDropOnAble - Is the object set to receive a direct manipulation drop action|
  804. ------------------------------------------------------------------------------*/
  805. Boolean
  806.   isTarget( const IContainerObject* pcnrobj) const,
  807.   isSelected( const IContainerObject* pcnrobj) const,
  808.   isInUse( const IContainerObject* pcnrobj) const,
  809.   isCursored( const IContainerObject* pcnrobj) const,
  810.   isFiltered( const IContainerObject* pcnrobj) const,
  811.   isExpanded( const IContainerObject* pcnrobj) const,
  812.   isCollapsed( const IContainerObject* pcnrobj) const,
  813.   isReadOnly( const IContainerObject* pcnrobj) const,
  814.   isDropOnAble( const IContainerObject* pcnrobj) const;
  815.  
  816. /*------------------ ICON VIEW OBJECT POSITION ---------------------------------
  817. | moveIconTo            - Move object to specified workspace location.         |
  818. | iconRectangle         - Query icon rectangle (optionally include text rect). |
  819. | detailObjectRectangle - Query details view rectangle.                        |
  820. | detailObjectRectangle - Query object and column intersection rectangle.      |
  821. | textRectangle         - Query text rectangle.                                |
  822. | objectUnderPoint      - Retrieve object under point in window coordinates.   |
  823. ------------------------------------------------------------------------------*/
  824. IContainerControl
  825.  &moveIconTo( IContainerObject* pcnrobj,
  826.               const IPoint& pt);
  827. IRectangle
  828.   iconRectangle( const IContainerObject* pcnrobj,
  829.                  Boolean fIncludeText=false) const,
  830.   detailObjectRectangle( const IContainerObject* pcnrobj,
  831.                          Boolean fRightWindow=0 ) const,
  832.   detailObjectRectangle( const IContainerObject* pcnrobj,
  833.                          const IContainerColumn* pcnrcol) const,
  834.   textRectangle( const IContainerObject* pcnrobj) const;
  835.  
  836. IContainerObject
  837.  *objectUnderPoint(const IPoint& pt);
  838.  
  839. /*------------------------ SORTING OBJECTS -------------------------------------
  840. |  Notes:                                                                      |
  841. |     1) Sorting by user defined data is handled in the                        |
  842. |        subclass by:                                                          |
  843. |          a) creating a user comparison function which                        |
  844. |             returns:                                                         |
  845. |                0 if p1==p2                                                   |
  846. |               <0 if p1<p2                                                    |
  847. |               >0 if p1>p2                                                    |
  848. |          b) invoking setSortFunction with the function                       |
  849. |          c) invoking the sort() function.                                    |
  850. |     2) User data will be passed to sort function.                            |
  851. |     3) If user data not specified, container passed.                         |
  852. |                                                                              |
  853. | setSortFunction - Indicate a function to be used for object comparison.      |
  854. | sortByIconText  - Sort the container by the icons text.                      |
  855. | sort            - Sort by the User Defined Sort function.                    |
  856. | nlsCompare      - Compare two strings with National Language Support.        |
  857. ------------------------------------------------------------------------------*/
  858. IContainerControl
  859.  &setSortFunction( ICOMPOBJCALLBACK* pfncomp)
  860.           { pfncompCl = pfncomp; return *this;}
  861. IContainerControl
  862.  &sortByIconText(),
  863.  &sort( void* pUserData=0);
  864.  
  865. long
  866.   nlsCompare( const char* pszString1,
  867.               const char* pszString2) const;
  868.  
  869. /*------------------------ FILTERING OBJECTS -----------------------------------
  870. |  Notes:                                                                      |
  871. |     1) Filter Function returns true to keep record in.                       |
  872. |     2) User data will be passed to filter function.                          |
  873. |     3) If user data not specified, container passed.                         |
  874. |                                                                              |
  875. |  setFilterFunction -                                                         |
  876. |  filter            - Filter the container with User Defined Filter                                                        |
  877. ------------------------------------------------------------------------------*/
  878. IContainerControl
  879.  &setFilterFunction( IFILTEROBJCALLBACK* pfnfilter)
  880.                       { pfnfilterCl = pfnfilter; return *this; }
  881. IContainerControl
  882.  &filter( void* pUserData=0);
  883.  
  884. /*------------------------ DIRECT EDITING --------------------------------------
  885. | editContainerTitle - Open an edit field on the Container Title.              |
  886. | editColumnTitle    - Open an edit field on a Column Title.                   |
  887. | editObject         - Open an edit field on an object.                        |
  888. | closeEdit          - Close an open edit field.                               |
  889. | setEditMLE         - Store an MLE being used for editing.                    |
  890. | setEditColumn      - Store the Column over which editing is occurring.       |
  891. | setEditObject      - Store the Object over which editing is occurring.       |
  892. | currentEditMLE     - Retrieve the MLE being used for editing.                |
  893. | currentEditColumn  - Retrieve the column being edited.                       |
  894. | currentEditObject  - Retrieve the object being edited.                       |
  895. ------------------------------------------------------------------------------*/
  896. virtual IContainerControl
  897.  &editContainerTitle(),
  898.  &editColumnTitle( IContainerColumn* pcnrcol),
  899.  &editObject( IContainerObject* pcnrobj,
  900.               IContainerColumn* pcnrcol=0),
  901.  &closeEdit(),
  902.  &setEditMLE( IMultiLineEdit*),
  903.  &setEditColumn( IContainerColumn*),
  904.  &setEditObject( IContainerObject*);
  905.  
  906. IMultiLineEdit
  907.  *currentEditMLE();
  908. IContainerColumn
  909.  *currentEditColumn();
  910. IContainerObject
  911.  *currentEditObject();
  912.  
  913.  
  914.  
  915. /*------------------------ MISCELLANEOUS ---------------------------------------
  916. | cursoredObject      - Return the object with the cursor.                     |
  917. | containerFromHandle - Retrieve a container from the list using the handle.   |
  918. ------------------------------------------------------------------------------*/
  919. IContainerObject
  920.  *cursoredObject() const;
  921.  
  922. static IContainerControl
  923.  *containerFromHandle( const IWindowHandle& ContainerHandle);
  924.  
  925.  
  926.  
  927.  
  928. protected:
  929. /*----------------------------- IMPLEMENTATION ---------------------------------
  930. | The following functions are used in the implementation of the class:         |
  931. |   setContainerAttributes - Set the attributes into the container control.    |
  932. |   containerInfo          - Refresh our copy of the containers state data.    |
  933. |   setEmphasis            - Set an object to an emphasis attribute.           |
  934. |   setAttibutes           - Update the attributes of an object.               |
  935. |   setDefaultContainer    - Initialize a container to the default styles.     |
  936. |   containerAttributes    - Return the current container attribute mask.      |
  937. |   attributes             - Return an attribute mask for an object.           |
  938. |   column                 - Return a column matching the CMD criteria.        |
  939. |   calcMinSize            - Return a minimum size for the container.          |
  940. ------------------------------------------------------------------------------*/
  941.  
  942. virtual void
  943.   setContainerAttributes( unsigned long ulCnrAttrOff,
  944.                           unsigned long ulCnrAttrOn),
  945.   containerInfo() const,
  946.   setEmphasis( IContainerObject* pcnrobj,
  947.                unsigned long ulEmphasisAttribute,
  948.                Boolean fOn=true),
  949.   setAttributes( IContainerObject* pcnrobj,
  950.                  unsigned long flAttrOff,
  951.                  unsigned long flAttrOn),
  952.   setDefaultContainer( const Attribute& attribute);
  953.  
  954. unsigned long
  955.   containerAttributes() const,
  956.   attributes( const IContainerObject* pcnrobj) const;
  957.  
  958. IContainerColumn
  959.  *column( IContainerColumn* pcnrcol,
  960.           unsigned long ulCmd,
  961.           Boolean visible);
  962.  
  963. virtual unsigned long
  964.   baseRecordSize();
  965.  
  966. virtual ISize
  967.  calcMinSize() {return ISize(50,50); }
  968.  
  969. IContainerControl();
  970.  
  971. /*-------------------------------- OVERRIDES -----------------------------------
  972. | This class overrides the following inherited functions:                      |
  973. |   handleWindowEvent - Overriddent to ensure that objects and column are      |
  974. |                       removed from the container on WM_DESTROY.              |
  975. ------------------------------------------------------------------------------*/
  976. virtual Boolean
  977.   handleWindowEvent( IEvent& evt);
  978.  
  979.  
  980.  
  981. private:
  982. /*--------------------------------- PRIVATE ----------------------------------*/
  983. void
  984.   addContainer(),
  985.   showView( unsigned long ulViewFlags),
  986.   collectDescendents( ICnrObjectSet& cnrset,
  987.                       IContainerObject* pcnrobj) const;
  988.  
  989. IContainerObject
  990.  *findFirst( unsigned long usView,
  991.              const char* pszText,
  992.              Boolean isCaseSensitive = false,
  993.              Boolean isFirstInRecord = false) const,
  994.  *selectedObject( const IContainerObject* pcnrobjAfter,
  995.                   unsigned long  ulEmphasis) const,
  996.  *object( const IContainerObject* pcnrobjAfter,
  997.           unsigned long  ulCmd) const;
  998.  
  999. static IWindowHandle
  1000.   hwndAllocation();
  1001. static ICnrControlList
  1002.  &containerList();
  1003. static IPrivateResource
  1004.  &containerKey();
  1005.  
  1006. IRectangle
  1007.   viewport( unsigned long ulCoordinateSpace,
  1008.             Boolean fRightSplitWindow) const;
  1009.  
  1010. ICnrInfo
  1011.  *pcnrinfoCl;
  1012. ICOMPOBJCALLBACK
  1013.  *pfncompCl;
  1014. IFILTEROBJCALLBACK
  1015.  *pfnfilterCl;
  1016.  
  1017. /* MLE Edit data */
  1018. IContainerColumn
  1019.  *pcnrcolClEdit;
  1020. IContainerObject
  1021.  *pcnrobjClEdit;
  1022. IMultiLineEdit
  1023.  *pmleClEdit;
  1024.  
  1025. Boolean
  1026.   fClDestructObjects,
  1027.   fClInvalidate;
  1028. int
  1029.   lClSplitbar,
  1030.   flClState;
  1031. unsigned long
  1032.   ulClDragEvent;
  1033. IBitmapHandle
  1034.   hbmClIconViewBackground;
  1035. ISize
  1036.   sizIconViewBitmap;
  1037. static Attribute
  1038.   classDefaultAttribute;
  1039. static Style
  1040.   classDefaultStyle;
  1041. static IWindowHandle
  1042.   hwndClAllocate;
  1043. };
  1044.  
  1045.  
  1046.      /*-----------------------*/
  1047.      /*    INLINES            */
  1048.      /*-----------------------*/
  1049. inline IContainerControl& IContainerControl ::setRefreshOff()
  1050.        { flClState |= IContainerControl::noRefresh; return *this;}
  1051. inline IContainerControl&    IContainerControl ::setRefreshOn()
  1052.        { flClState &= ~IContainerControl::noRefresh; return *this; }
  1053. inline Boolean IContainerControl ::isRefreshOn()
  1054.        { return !(flClState & IContainerControl::noRefresh); }
  1055.  
  1056.  
  1057.  
  1058. INESTEDBITFLAGCLASSFUNCS(Style, IContainerControl);
  1059.  
  1060. #define _USEBBIMP_ 1
  1061.  
  1062. #endif
  1063.