home *** CD-ROM | disk | FTP | other *** search
- #ifndef _IRESLIB_
- #define _IRESLIB_
- /*******************************************************************************
- * FILE NAME: ireslib.hpp *
- * *
- * DESCRIPTION: *
- * Declaration of the class(es): *
- * IResourceLibrary - Base class for Resources *
- * IDynamicLinkLibrary - DLL resources *
- * IResourceId - Wrapper class for resource identifier *
- * *
- * COPYRIGHT: *
- * Licensed Materials - Property of IBM *
- * (C) Copyright IBM Corporation 1992, 1993 *
- * All Rights Reserved *
- * US Government Users Restricted Rights - Use, duplication, or disclosure *
- * restricted by GSA ADP Schedule Contract with IBM Corp. *
- * *
- *$Log: R:/IBMCLASS/IBASEAPP/VCS/IRESLIB.HPV $ *
- //
- // Rev 1.8 25 Oct 1992 16:57:30 nunn
- // changed library name to ICLUI
- //
- // Rev 1.7 24 Oct 1992 14:47:40 BOBLOVE
- // Updated documentation
-
- *******************************************************************************/
- #if !defined(_IVBASE_)
- #include <ivbase.hpp>
- #endif
-
- #if !defined(_IHANDLE_)
- #include <ihandle.hpp>
- #endif
-
- // Forward declarations for other classes:
- class IString;
- class IResourceLibrary;
- class IDynamicLinkLibrary;
- class IDLLModule;
- class ISize;
- class IWindow;
- class IProcAddressHandle;
-
-
- class IResourceLibrary : public IVBase
- /*******************************************************************************
- * IResourceLibrary provide the functions for loading most types of OS/2 *
- * resources. This class defaults the location of resources to the *
- * EXE itself. Resources stored in a DLL can be loaded using the class *
- * IDynamicLinkLibrary. *
- * *
- * For the most part, this class is used very little outside of the *
- * User Interface library itself as these components typically take *
- * an IResourceId as input and do the resource loading themselves. *
- * *
- * *
- * EXAMPLE: *
- * *
- * const unsigned MyIcon 15; *
- * IResourceLibrary reslib; *
- * IPointerHandle ptrh = reslib.loadIcon(MyIcon); *
- * *
- *******************************************************************************/
- {
- friend class IPointerHandle;
- friend class IBitmapHandle;
- friend class ISysPointerHandle;
- friend class ISysBitmapHandle;
-
- public:
- /*------------------------ CONSTRUCTORS/DESTRUCTORS ----------------------------
- | There is one way to construct instances of this class: |
- | 1. The default which takes no parameters. |
- ------------------------------------------------------------------------------*/
- IResourceLibrary();
- virtual
- ~IResourceLibrary() {}
-
- /*-------------------------------- ACCESSORS -----------------------------------
- | These function provide means of getting and setting the accessible |
- | attributes of instances of this class: |
- | fileName - Returns the path qualified name of the current executable file. |
- | asString - Provides textual information about the class instance. |
- | asDebugInfo - Provides debugging information about the class instance. |
- | isOpen - Returns the open state of the resource file. This is always true |
- | for an IResourceLibrary. |
- | handle - Returns the handle used to load resources. This is always zero |
- | for an IResourceLibrary. |
- ------------------------------------------------------------------------------*/
- virtual IString
- fileName() const,
- asString() const,
- asDebugInfo() const;
-
- virtual Boolean
- isOpen() const;
-
- virtual IModuleHandle
- handle() const;
-
-
- /*----------------------- RESOURCE LOADING FUNCTIONS ---------------------------
- | These functions load specific resources from an OS/2 resource file: |
- | loadString - Load a string resource from a resource file. |
- | loadMessage - Load a message resource from a resource file. |
- | loadMenu - Load a menu for a window from a resource file. |
- | loadDialog - Load and start a Dialog from a resource file. |
- | loadAccelTable - Load an accelerator table from a resource file. |
- | loadHelpTable - Load a help table from a resource file. |
- | loadHelpTable - Load a help table from a resource file. |
- | loadIcon - Load an icon from a resource file. If managed is |
- | specified then the icon is reference counted. |
- | loadBitmap - Load a bitmap from a resource file. If managed is |
- | specified then the bitmap is reference counted. If |
- | a size is specified then the bitmap is loaded at that |
- | size. |
- ------------------------------------------------------------------------------*/
- IString
- loadString(unsigned long stringId) const,
- loadMessage(unsigned long messageId) const;
-
- IWindowHandle
- loadMenu(unsigned long menuId,
- const IWindow* menuOwner) const,
- loadDialog(unsigned long dialogId,
- const IWindow* dialogParent,
- const IWindow* dialogOwner,
- IWINCALLBACK* pDialogProc,
- void* pDialogCreateParams) const;
-
- IAccelTblHandle
- loadAccelTable(unsigned long accelTableId) const;
-
- void
- loadHelpTable(const IWindow* helpInstance,
- unsigned long helpTableId) const;
-
- /* Note: Cached Icons and Bitmaps use reference counting to reduce loading */
- IPointerHandle
- loadIcon(unsigned long iconId,
- Boolean cached=true) const,
- loadPointer(unsigned long iconId,
- Boolean cached=true) const;
-
- IBitmapHandle
- loadBitmap(unsigned long bitmapId,
- Boolean cached=true) const,
- loadBitmap(unsigned long bitmapId,
- const ISize& bitmapSize,
- Boolean cached=true) const;
-
- private:
- char
- *loadText(Boolean isString,
- unsigned long StringID,
- char* Buffer=0,
- unsigned long Length=0) const;
-
- /* Static functions to cache icon & bitmap resources */
- static unsigned long
- addRef(const IPointerHandle& ptrh),
- addRef(const IBitmapHandle& bmph),
- removeRef(const IPointerHandle& ptrh),
- removeRef(const IBitmapHandle& bmph);
-
-
-
- };
-
-
- class IDynamicLinkLibrary : public IResourceLibrary
- /*******************************************************************************
- * IDynamicLinkLibrary provides the support for loading OS/2 resources from a *
- * Dynamic Link Library. *
- * *
- * *
- * EXAMPLE: *
- * *
- * const unsigned MyIcon 15; *
- * IDynamicLinkLibrary reslib("icons"); *
- * IPointerHandle ptrh = reslib.loadIcon(MyIcon); *
- * *
- *******************************************************************************/
- {
- public:
-
- friend class IProcAddressHandle;
-
- /*------------------------ CONSTRUCTORS/DESTRUCTORS ----------------------------
- | There are three ways to construct instances of this class: |
- | 1. By providing a name to use for the Dynamic Link Module. The name should |
- | be specified without the path or extension. |
- | 2. From an IModuleHandle obtained by loading the DLL explicitly. |
- | 3. By copying an existing IDynamicLinkLibary. |
- ------------------------------------------------------------------------------*/
- IDynamicLinkLibrary(const char* resourceFileName);
- IDynamicLinkLibrary(const IModuleHandle& modh);
- IDynamicLinkLibrary(const IDynamicLinkLibrary& resmgr);
-
- virtual
- ~IDynamicLinkLibrary();
-
- IDynamicLinkLibrary
- &operator=(const IDynamicLinkLibrary& resmgr);
-
-
- /*----------------------- DLL OPEN/CLOSE FUNCTIONS -----------------------------
- | These functions open and close an OS/2 Dynamic Link Library. |
- | open - Open a Dynamic Link Library. |
- | close - Close a Dynamic Link Library. |
- ------------------------------------------------------------------------------*/
- virtual void
- open(),
- close();
-
- /*----------------------- PROCEDURE ADDRESS FUNCTIONS --------------------------
- | These functions open and close an OS/2 Dynamic Link Library. |
- | procAddress - Load a procedure address from a Dynamic Link Library. |
- ------------------------------------------------------------------------------*/
- IProcAddressHandle
- procAddress(const char* procedureName),
- procAddress(unsigned long procedureOrdinal);
-
- /*-------------------------------- OVERRIDES -----------------------------------
- | This class overrides the following inherited functions: |
- | isOpen - Overridden to return the open state of the Dynamic Link |
- | Library. |
- | fileName - Overridden to return the name of Dynamic Link Library. |
- | asString - Overridden to provide textual information about the class |
- | instance. |
- | asDebugInfo - Overridden to provide debugging information about the class |
- | instance. |
- | handle - Overridden to provide the Dynamic Link Module handle. |
- ------------------------------------------------------------------------------*/
- virtual Boolean
- isOpen() const;
-
- virtual IString
- fileName() const,
- asString() const,
- asDebugInfo() const;
-
- /* Note: Call to handle() before open() causes exception */
- virtual IModuleHandle
- handle() const;
-
- private:
- IDynamicLinkLibrary();
-
- // Static functions to reference count DLL's */
- static unsigned long
- addRef(const IModuleHandle& modh),
- removeRef(const IModuleHandle& modh);
-
- IDLLModule
- *pmodClResource;
- };
-
-
-
- class IResourceId : public IBase /* resid */
- /*******************************************************************************
- * IResourceId is a "wrapper" class for a resource identifier. Part of the *
- * information contained in the class is the location of the resources which *
- * is described using either an IResourceLibrary or an IDynamicLinkLibrary. *
- * Most classes in the User Interface Library typically take an IResourceId *
- * as input to describe resources and provide the resource loading themselves. *
- * *
- * EXAMPLE: *
- * *
- * const unsigned MyIcon 15; *
- * IResourceId resid(10); *
- * *
- * IDynamicLinkLibrary reslib("icons"); *
- * IResourceId resid(10, reslib); *
- * *
- * *
- *******************************************************************************/
- {
- public:
-
- /*------------------------ CONSTRUCTORS/DESTRUCTORS ----------------------------
- | There are three ways to construct instances of this class: |
- | 1. By providing an id and a reference to an IResourceLibrary. |
- | 2. By providing an id and a reference to an IDynamicLinkLibrary. |
- | 3. By providing only an id. The resource library used is that returned |
- | by a call to IApplication::resource(). This is the recommended use of |
- | the class. |
- ------------------------------------------------------------------------------*/
- IResourceId(unsigned long Resid, const IResourceLibrary&);
- IResourceId(unsigned long Resid, const IDynamicLinkLibrary&);
-
- /* The following ResourceId defaults to IApplication::resource() */
- IResourceId(unsigned long resourceId);
-
- const IResourceLibrary
- &resourceLibrary() const;
-
- unsigned long
- id() const;
-
- operator unsigned long( ) const;
-
- virtual IString
- asString() const,
- asDebugInfo() const;
-
-
- private:
- unsigned long
- ulClId;
- const IResourceLibrary
- &reslibCl;
-
- };
-
-
-
-
- /***************************************************************/
- /* Inline Functions. */
- /***************************************************************/
-
-
- inline IPointerHandle IResourceLibrary::loadPointer(unsigned long iconId, Boolean managed) const
- /***************************************************************/
- /* Load a Pointer. */
- /***************************************************************/
- { return loadIcon(iconId, managed); }
-
-
- inline Boolean IResourceLibrary::isOpen() const
- /***************************************************************/
- /* Return the fact the the library is always open. */
- /***************************************************************/
- {
- return true;
- }
-
-
-
- inline const IResourceLibrary& IResourceId::resourceLibrary() const
- /***************************************************************/
- /* Return the Resource Manager associated with the id. */
- /***************************************************************/
- { return reslibCl; }
-
- inline IResourceId::operator unsigned long( ) const
- /***************************************************************/
- /* Return the Resource Id as an unsigned long integer. */
- /***************************************************************/
- { return this->ulClId; }
-
-
- inline unsigned long IResourceId::id( ) const
- /***************************************************************/
- /* Return the Resource Id as an unsigned long integer. */
- /***************************************************************/
- { return this->ulClId; }
-
-
-
-
-
- #endif