home *** CD-ROM | disk | FTP | other *** search
- #ifndef _ICNROBJ_
- #define _ICNROBJ_
- /*******************************************************************************
- * FILE NAME: icnrobj.hpp *
- * *
- * DESCRIPTION: *
- * Declaration of the class(es): *
- * IContainerObject - Base container object class *
- * *
- * COPYRIGHT: *
- * (C) Copyright IBM Corporation 1992 *
- * All Rights Reserved *
- * Licensed Materials * Property of IBM *
- * *
- * HISTORY: *
- * $Log: R:/ibmclass/icnr/vcs/icnrobj.hpv $
- //
- // Rev 1.12 25 Oct 1992 19:26:40 BOBLOVE
- //Updated documentation
- //
- // Rev 1.11 25 Oct 1992 16:28:04 nunn
- //changed library name to ICLUI
- //
- // Rev 1.10 25 Oct 1992 12:49:58 BOBLOVE
- //Added inline for setBase function
- //
- // Rev 1.9 25 Oct 1992 11:17:40 BOBLOVE
- //External Beta Release
- * *
- *******************************************************************************/
- #if !defined(_IVBASE_)
- #include <ivbase.hpp>
- #endif
-
- #if !defined(_ISTRING_)
- #include <istring.hpp>
- #endif
-
- #if !defined(_IBITFLAG_)
- #include <ibitflag.hpp>
- #endif
-
- #if !defined(_IHANDLE_)
- #include <ihandle.hpp>
- #endif
-
-
- /* Change to BB */
- #ifdef _USEBB_
- #include <isrtset.h>
- #else
- #include <iset.hpp>
- #endif
-
-
- // Class Forward Declarations
- class IContainerObject;
- class IMiniCnrRecord;
- class IContainerControl;
- class IResourceId;
-
-
-
- class IContainerObject : public IVBase
- {
- /*******************************************************************************
- * IContainerObject is the base class of all objects stored in a container. *
- * This object is required to be subclassed to support additional data in the *
- * Details View but may be used as is in other views. All instances of *
- * this class must be created using operator new which is overloaded here *
- * to provide the storage allocation required by the underlying OS/2 container *
- * control. *
- * *
- * If this object is subclassed and data added for the details view, the data *
- * must be contiguous with the data of this class and be one of the supported *
- * types defined in IContainerColumn. It is important to note that only the *
- * string type can be edited. The IString class is the recommended way to *
- * store text data in an object subclass. *
- * *
- * Container initialization normally occurs when the first IContainerControl *
- * is instantiated. If container objects need to be instantiated earlier, the *
- * function IContainerControl::initialize() should be called prior to the first *
- * instantiation but after the presentation environment has been initialized. *
- * *
- * It is recommended that you use a ResourceLibrary to load icons as it *
- * is capable of satisfying multiple requests for the same icon with a *
- * single load and will manage multiple references to the same object. Actual *
- * icon deletion occurs when the use count reaches zero. *
- * *
- * IContainerObjects can be added to multiple container at the same time. When *
- * functions in this class modify an objects characteristics, they do so in *
- * ALL containers that hold the object. Functions exist in IContainerControl *
- * that can be used to modify an object in a single container. *
- * *
- * *
- * EXAMPLE: *
- * *
- * *
- * class Customer : public IContainerObject *
- * { *
- * public: *
- * Customer(const IString& Name, *
- * const IPointerHandle& Icon = 0, *
- * const IString& Address = IString(), *
- * const IString& Phone = IString(), *
- * unsigned long Age = 0) *
- * : IContainerObject(Name, hptrIcon), *
- * strCustomerAddress(Address), *
- * strCustomerPhone(Phone), *
- * ulCustomerAge(Age) { } *
- * *
- * private: *
- * IString strCustomerAddress; *
- * IString strCustomerPhone; *
- * unsigned long ulCustomerAge; *
- * }; *
- * *
- * *
- * Customer ski("Blacky Diamond", 10, "Park City, Utah", "1-800-SKI-JUMP", 39); *
- * *
- * *
- * *
- *******************************************************************************/
- friend class IContainerControl;
- friend class IContainerObject;
- friend class IMiniCnrRecord;
- friend IMiniCnrRecord* IRecFromObj( const IContainerObject* pcnrobj);
-
- public:
-
- enum emphasis { none, cursored, inuse, selected};
- enum state { ok=1, opened=2, noInvalidate=4, oneParent=8,
- multipleParents=16, noRefresh=32, invalid=64};
-
- /*------------------------ CONSTRUCTORS/DESTRUCTORS ----------------------------
- | There are 4 ways to construct instances of this class: |
- | 1. By providing a character array for text and an IPointerHandle for the |
- | icon. |
- | |
- | 2. By providing an IString for text and an IPointerHandle for the |
- | icon. |
- | |
- | 3. By providing resource id's for both the text and icon. |
- | icon. |
- | |
- | 4. From a copy of an existing object. If the object is subclassed this |
- | copy constructor must be overloaded to ensure that the object is |
- | is copied correctly. |
- ------------------------------------------------------------------------------*/
- IContainerObject( const char* Name = 0,
- const IPointerHandle& Icon = 0);
-
- IContainerObject( const IString& str = IString(),
- const IPointerHandle& Icon = 0);
-
- IContainerObject( const IResourceId& NameID,
- const IResourceId& IconId);
-
-
- IContainerObject( const IContainerObject& cnrobj);
-
- virtual
- ~IContainerObject();
-
- /*-------------------------------- ACCESSORS -----------------------------------
- | These functions provide means of getting and setting the accessible |
- | attributes of instances of this class: |
- | |
- | setIcon - Set new text for an object. |
- | setIconText - Set a new icon for an object. |
- | icon - Return the icon handle of an object. |
- | iconText - Return the text of an object. |
- | setInUse - Set In-use emphasis for this object in all |
- | containers. |
- | removeInUse - Remove In-use emphasis for this object in all |
- | containers. |
- | enableDataUpdate - Enable this object to be updated in all containers. |
- | disableDataUpdate - Disable update of this object in all containers. |
- | refresh - Refresh this object in all containers. |
- | enableDrop - Enable this object to be dropped in all containers. |
- | disableDrop - Disable this object being dropped in all containers. |
- | setRefreshOn - Set this objects state to refreshable. |
- | setRefreshOff - Inhibit refresh of this object. |
- | isInUse - Return true if this object has In-use emphasis. |
- | isReadOnly - Return true if this object is read-only. |
- | isDropOnAble - Return true if this object can accept a drop. |
- | isRefreshOn - Return true if this object is in refresh state. |
- | iconOffset - Return the offset of the Objects IPointerHandle for |
- | the icon. This allows the icon to be used in a |
- | column of the details view. |
- | iconTextOffset - Return the offset of the objects IString. This |
- | allows the IString to be used in a |
- | column of the details view. |
- | setOpen - Set open emphasis in all containers. |
- | setClose - Remove open emphasis in all containers. |
- | isOpen - Return true if this object is open in all containers.|
- | |
- ------------------------------------------------------------------------------*/
- IContainerObject
- &setIcon( const IPointerHandle& Icon),
- &setIcon( const IResourceId& IconId),
- &setIcon( unsigned long IconId),
-
- &setIconText( const char* IconText),
- &setIconText( const IString& IconText),
- &setIconText( const IResourceId& IconTextId);
-
- IPointerHandle
- icon() const;
- IString
- iconText() const;
-
- IContainerObject
- &setInUse(),
- &removeInUse(),
-
- &enableDataUpdate(),
- &disableDataUpdate(),
-
-
- &enableDrop(),
- &disableDrop(),
-
- &refresh(),
- &setRefreshOn(),
- &setRefreshOff();
-
- Boolean
- isInUse() const,
- isReadOnly() const,
- isDropOnAble() const,
- isRefreshOn() const;
-
- static unsigned long
- iconOffset(),
- iconTextOffset();
-
-
- IContainerObject
- &setOpen(),
- &setClose();
- Boolean
- isOpen();
-
-
- /*------------------------ OBJECT ALLOCATION -----------------------------------
- | These functions provide all object allocation and deallocation for instances |
- | of the class. Stack and static instances of this class are not allowed. |
- | new - Allocate storage for a class instance. |
- | delete - Deallocate the storage of a class instance. |
- | |
- ------------------------------------------------------------------------------*/
- void
- *operator new(size_t size),
- operator delete(void* );
-
-
- /*------------------------ SUBCLASS PROVIDED FUNCTIONS -------------------------
- | These functions must be provided by the subclass if the behavior is |
- | required. |
- | handleOpen - Called when Enter is pressed on an object or a mouse double |
- | click. |
- | objectCopy - Called when it is necessary to make a copy of an object. This |
- | occurs when "IContainerControl::copyObjectTo" is called. |
- | operator== - Returns true if the objects are at the same storage location. |
- ------------------------------------------------------------------------------*/
- virtual void
- handleOpen(IContainerControl* pcnrctl);
-
- virtual IContainerObject
- *objectCopy();
-
- Boolean
- operator== (const IContainerObject& cnrobj);
-
-
- /* The following will shortly be obsolete */
- const char
- *iconTextRef() const;
-
- #if 0
- void setPopUpMenu(IPopUpMenu* const ppumn);
- #endif
-
-
- protected:
- /*----------------------------- IMPLEMENTATION ---------------------------------
- | The following functions are used in the implementation of the class: |
- | setEmphasis - Set the passed emphasis attribute on or off. |
- | setAttributes - Set some attributes off while setting others on. Used |
- | to toggle the state of mutually exclusive attributes. |
- | incrementUseCount - Increase the count of containers with this object. |
- | decrementUseCount - Decrease the count of containers with this object. |
- | setBase - Store the address of the real base of this object. |
- | baseRecord - Return the address of the real base of this object. |
- | useCount - Returns the number of containers with this object. |
- | isAttribute - Returns true if the passed attribute is on. |
- ------------------------------------------------------------------------------*/
- virtual void
- setEmphasis( unsigned long ulEmphasisAttribute,
- Boolean fOn=true),
- setAttributes( unsigned long flAttrOff,
- unsigned long flAttrOn),
- incrementUseCount() const,
- decrementUseCount() const,
- setBase( const IMiniCnrRecord* pcnrrec);
-
- IMiniCnrRecord
- *baseRecord();
-
- virtual unsigned long
- useCount() const;
-
- virtual Boolean
- isAttribute(unsigned long flAttribute) const;
-
- private:
- /*--------------------------------- PRIVATE ----------------------------------*/
- IContainerObject() {;}
-
- unsigned long
- iconTextLength() const;
-
- int
- flClState;
- unsigned long
- ulClUseCount;
- IContainerObject
- *pcnrobjClParent;
- IMiniCnrRecord
- *pbase;
- /* IPopUpMenu* ppumnCl; */
- } ;
-
- /*----------------------------------------------------------*/
- /* Object Collection Definition. */
- /*----------------------------------------------------------*/
- #ifdef _USEBB_
- class ICnrObjectSet : public ISortedSet<IContainerObject*>
- {
- public:
- ICnrObjectSet() : ISortedSet<IContainerObject*>() {}
-
- };
- #else
- declare(IGSet1, IContainerObject);
-
- class ICnrObjectSet : public IGSet1(IContainerObject)
- {
- public:
- ICnrObjectSet() : IGSet1(IContainerObject)() {} // RDL 32 bit
- };
-
- #endif
-
- /*----------------------------------------------------------*/
- /* Inline Functions */
- /*----------------------------------------------------------*/
-
-
- // inline Boolean IContainerObject :: isDropAcceptable(const ICnrDragOverEvent& evt)
- // { return(false); };
-
-
-
-
-
- inline void IContainerObject :: incrementUseCount() const
- { ((IContainerObject*)this)->ulClUseCount++; }
- inline void IContainerObject :: decrementUseCount() const
- { ((IContainerObject*)this)->ulClUseCount--; }
- inline unsigned long IContainerObject :: useCount() const
- { return((IContainerObject*)this)->ulClUseCount; }
- inline IMiniCnrRecord* IContainerObject :: baseRecord()
- { return((IContainerObject*)this)->pbase; }
- inline void IContainerObject :: setBase( const IMiniCnrRecord* pcnrrec)
- { this->pbase = (IMiniCnrRecord*)pcnrrec; }
-
-
- inline IContainerObject& IContainerObject :: setRefreshOff()
- { flClState |= noRefresh; return *this;}
- inline IContainerObject& IContainerObject :: setRefreshOn()
- { flClState &= ~noRefresh; return *this;}
- inline Boolean IContainerObject :: isRefreshOn() const
- { return !(flClState&noRefresh); }
-
- inline IContainerObject& IContainerObject ::setOpen()
- { flClState |= opened; setInUse(); return *this; }
- inline IContainerObject& IContainerObject ::setClose()
- { flClState &= ~opened; removeInUse(); return *this; }
- inline void IContainerObject :: handleOpen(IContainerControl* pcnrctl)
- { setOpen(); }
- inline Boolean IContainerObject :: isOpen()
- { return isInUse(); }
-
-
- #endif // _ICNROBJ_