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

  1. #ifndef _ICNROBJ_
  2. #define _ICNROBJ_
  3. /*******************************************************************************
  4. * FILE NAME: icnrobj.hpp                                                       *
  5. *                                                                              *
  6. * DESCRIPTION:                                                                 *
  7. *   Declaration of the classes:                                                *
  8. *     IContainerObject                                                         *
  9. *     ICnrAllocator                                                            *
  10. *                                                                              *
  11. * COPYRIGHT:                                                                   *
  12. *   IBM Open Class Library                                                     *
  13. *   (C) Copyright International Business Machines Corporation 1992, 1996       *
  14. *   Licensed Material - Program-Property of IBM - All Rights Reserved.         *
  15. *   US Government Users Restricted Rights - Use, duplication, or disclosure    *
  16. *   restricted by GSA ADP Schedule Contract with IBM Corp.                     *
  17. *                                                                              *
  18. *******************************************************************************/
  19. #include <ivbase.hpp>
  20. #include <ihandle.hpp>
  21. #include <istring.hpp>
  22.  
  23. extern "C" {
  24.   #include <stdlib.h>
  25.   }
  26.  
  27. class ICnrAllocator;
  28. class ICnrControlData;
  29. class ICnrObjPrivateData;
  30. class ICnrRecord;
  31. class IContainerControl;
  32. class IMiniCnrRecord;
  33. class IResourceId;
  34.  
  35. #pragma pack(4)
  36.  
  37. class IContainerObject : public IVBase {
  38. typedef IVBase
  39.   Inherited;
  40. public:
  41. /*------------------------------ Related Members -----------------------------*/
  42. enum Emphasis { none=0, cursored=1, inuse=2, selected=4 };
  43.  
  44. /*------------------------------- Constructors -------------------------------*/
  45.   IContainerObject ( );
  46.   IContainerObject ( const IString&          string,
  47.                      const IPointerHandle&   iconHandle = 0 );
  48.  
  49.   IContainerObject ( const IString&          string,
  50.                      const IResourceId&      iconId );
  51.  
  52.   IContainerObject ( const IResourceId&      nameID,
  53.                      const IResourceId&      iconId );
  54.  
  55.   IContainerObject ( const IContainerObject& object );
  56.  
  57.   IContainerObject ( const IString&          string,
  58.                      unsigned long           iconId );
  59.  
  60. virtual
  61.  ~IContainerObject ( );
  62.  
  63. /*------------------------------ Characteristics -----------------------------*/
  64. virtual IContainerObject
  65.  &setIcon           ( const IPointerHandle& iconHandle ),
  66.  &setIcon           ( const IResourceId&    iconId ),
  67.  &setIcon           ( unsigned long         iconId ),
  68.  
  69.  &setIconText       ( const char*           iconText ),
  70.  &setIconText       ( const IString&        iconText ),
  71.  &setIconText       ( const IResourceId&    iconTextId );
  72.  
  73. virtual IPointerHandle
  74.   icon              ( ) const;
  75. virtual IString
  76.   iconText          ( ) const;
  77.  
  78. virtual IContainerObject
  79.  &setInUse          ( Boolean            inUse = true,
  80.                       IContainerControl* container = 0 ),
  81.  &removeInUse       ( IContainerControl* container = 0 );
  82.  
  83. virtual IContainerObject
  84.  &enableDataUpdate  ( Boolean            enable = true,
  85.                       IContainerControl* container = 0 ),
  86.  &disableDataUpdate ( IContainerControl* container = 0 );
  87.  
  88. virtual IContainerObject
  89.  &enableDrop        ( Boolean            enable = true,
  90.                       IContainerControl* container = 0 ),
  91.  &disableDrop       ( IContainerControl* container = 0 );
  92.  
  93. virtual IContainerObject
  94.  &show              ( Boolean            show = true,
  95.                       IContainerControl* container = 0 ),
  96.  &hide              ( IContainerControl* container = 0 );
  97.  
  98. virtual IContainerObject
  99.  &refresh           ( IContainerControl* container = 0,
  100.                       Boolean            immediate = false ),
  101.  &setRefreshOn      ( Boolean            refreshOn = true ),
  102.  &setRefreshOff     ( );
  103.  
  104. virtual Boolean
  105.   isInUse           ( IContainerControl* container = 0 ) const;
  106. virtual Boolean
  107.   isWriteable       ( IContainerControl* container = 0 ) const;
  108. virtual Boolean
  109.   isDropOnAble      ( IContainerControl* container = 0 ) const;
  110.  
  111. virtual Boolean
  112.   isVisible         ( IContainerControl* container = 0 ) const;
  113.  
  114. virtual Boolean
  115.   isRefreshOn       ( ) const;
  116.  
  117.  
  118. virtual IContainerObject
  119.   &setOpen          ( Boolean open = true ),
  120.   &setClosed        ( );
  121. virtual Boolean
  122.   isOpen            ( ) const;
  123.  
  124. /*---------------------------- Object Allocation -----------------------------*/
  125. #ifdef __DEBUG_ALLOC__
  126. void
  127.  *operator new    ( size_t         size,
  128.                     const char*    fileName,
  129.                     size_t         lineNumber );
  130. void
  131.  *operator new    ( size_t         size,
  132.                     const char*    fileName,
  133.                     size_t         lineNumber,
  134.                     ICnrAllocator& allocator );
  135. void
  136.   operator delete ( void*,
  137.                     const char*    fileName,
  138.                     size_t         lineNumber );
  139. #else
  140. void
  141.  *operator new    ( size_t         size );
  142. void
  143.  *operator new    ( size_t         size,
  144.                     ICnrAllocator& allocator );
  145. void
  146.   operator delete ( void* );
  147. #endif
  148.  
  149. /*--------------------- Derived Class Provided Members -----------------------*/
  150. virtual void
  151.   handleOpen           ( IContainerControl* container ),
  152.   handleInuseChange    ( IContainerControl* container,
  153.                          Boolean            acquired ),
  154.   handleCursoredChange ( IContainerControl* container,
  155.                          Boolean            acquired ),
  156.   handleSelectedChange ( IContainerControl* container,
  157.                          Boolean            acquired ),
  158.   handleTreeCollapse   ( IContainerControl* container ),
  159.   handleTreeExpand     ( IContainerControl* container );
  160.  
  161. virtual unsigned long
  162.   helpId               ( ) const;
  163.  
  164. virtual IContainerObject
  165.  *objectCopy           ( );
  166.  
  167. Boolean
  168.   operator==           ( const IContainerObject& object );
  169.  
  170. protected:
  171. /*------------------------------ Attributes ----------------------------------*/
  172. virtual IContainerObject
  173.  &setEmphasis       ( unsigned long      emphasisAttribute,
  174.                       Boolean            turnOn = true,
  175.                       IContainerControl* container = 0 ),
  176.  &setAttributes     ( unsigned long      attributeTurnedOff,
  177.                       unsigned long      attributeTurnedOn,
  178.                       IContainerControl* container = 0 ),
  179.  &incrementUseCount ( ),
  180.  &decrementUseCount ( ),
  181.  &setBase           ( const IMiniCnrRecord* baseRecord ),
  182.  &initialize        ( );
  183.  
  184. IMiniCnrRecord
  185.  *baseRecord        ( );
  186.  
  187. unsigned long
  188.   useCount          ( ) const;
  189.  
  190. virtual Boolean
  191.   isAttribute       ( unsigned long      attribute,
  192.                       IContainerControl* container ) const;
  193.  
  194. private:
  195. /*--------------------------------- Private ----------------------------------*/
  196. friend class ICnrObjPrivateData;
  197. friend class IContainerControl;
  198. friend class ICnrControlData;
  199. friend class IMiniCnrRecord;
  200. friend IMiniCnrRecord* IRecFromObj       ( const IContainerObject* pcnrobj );
  201. friend IWindowHandle IGadgetFromObj      ( IContainerObject*,
  202.                                            IContainerControl*,
  203.                                            IBase::Boolean );
  204. friend Boolean __stdcall pfnDeleteObjects  ( ICnrRecord* pRecord,
  205.                                              void*       p );
  206. friend Boolean __stdcall pfnCleanUpObjects ( ICnrRecord* pRecord,
  207.                                              void*       thisCnr );
  208. friend class INativeContainerHandler;
  209.  
  210. enum State {
  211.   ok=1,
  212.   opened=2,
  213.   noInvalidate=4,
  214.   hasDescendents=8,
  215.   noRefresh=16,
  216.   invalid=32,
  217.   subclassed=64,
  218.   deleteInProcess=128,
  219.   nestedDelete=256
  220.   };
  221.  
  222. unsigned long
  223.   iconTextLength ( ) const;
  224. static void
  225.  *newRecord      ( size_t size ),
  226.   deleteRecord   ( void* precord );
  227.  
  228. int
  229.   flClState;
  230. unsigned long
  231.   ulClUseCount;
  232. IContainerObject
  233.  *pcnrobjClParent;
  234. IMiniCnrRecord
  235.  *pbase;
  236.  
  237. void
  238.   setDelayedFree ( Boolean delay = true );
  239. Boolean
  240.   isDelayedFree  ( ) const;
  241. Boolean
  242.   delayFree;
  243.  
  244. ICnrObjPrivateData
  245.  *ppd;
  246.  
  247. }; // IContainerObject
  248.  
  249.  
  250. class ICnrAllocator : public IBase {
  251. typedef IBase
  252.   Inherited;
  253. public:
  254. /*------------------------------- Constructors -------------------------------*/
  255.   ICnrAllocator ( unsigned long num,
  256.                   unsigned long size );
  257.  
  258. virtual
  259.   ~ICnrAllocator ( );
  260.  
  261. protected:
  262. /*---------------------------- Object Information ----------------------------*/
  263. void
  264.   *first           ( ) const,
  265.   *next            ( void* pRec ),
  266.   *nextAvailable   ( );
  267. unsigned long
  268.   initialized     ( ) const;
  269. ICnrAllocator
  270.   &updateForInsert ( );
  271.  
  272. private:
  273. /*----------------------------- Hidden Members -------------------------------*/
  274. ICnrAllocator ( const ICnrAllocator& aCnrAllocator );
  275. ICnrAllocator
  276.   &operator=   ( const ICnrAllocator& cnrAllocator );
  277.  
  278. /*--------------------------------- Private ----------------------------------*/
  279. friend class IContainerControl;
  280. friend class IContainerObject;
  281. void
  282.   *pFirst,
  283.   *pAvailable;
  284. unsigned long
  285.    numInitialized;
  286. }; // ICnrAllocator
  287.  
  288. #pragma pack()
  289.  
  290.   #include <icnrobj.inl>
  291.   #include <icnrobjn.inl>
  292.  
  293. #endif  /* _ICNROBJ_ */
  294.