home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
cset21v1.zip
/
IBMCPP
/
IBMCLASS
/
IRESLIB.HPP
< prev
next >
Wrap
C/C++ Source or Header
|
1993-10-22
|
18KB
|
360 lines
#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. *
* *
*******************************************************************************/
#if !defined(_IVBASE_)
#include <ivbase.hpp>
#endif
#if !defined(_IHANDLE_)
#include <ihandle.hpp>
#endif
/*----------------------------------------------------------------------------*/
/* Align classes on four byte boundary. */
/*----------------------------------------------------------------------------*/
#pragma pack(4)
/*----------------------------------------------------------------------------*/
/* Turn off warning for compiler generated copy/assignment */
/*----------------------------------------------------------------------------*/
#pragma info(nocpy)
// Forward declarations for other classes:
class IString;
class IResourceLibrary;
class IDynamicLinkLibrary;
class IDLLModule;
class ISize;
class IWindow;
class IResourceLibrary : public IVBase
{
typedef IVBase
Inherited;
/*******************************************************************************
* The IResourceLibrary class provides the functions for loading most types of *
* OS/2 resources. This class defaults the location of resources to the *
* executable file itself. Resources stored in a dynamic-link library (DLL) *
* can be loaded using the IDynamicLinkLibrary class. *
* *
* Generally, this class is seldom used outside of the User Interface Class *
* 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 ISystemPointerHandle;
friend class ISystemBitmapHandle;
public:
/*------------------------ Constructor -----------------------------------------
| The only way to construct instances of this class is by using the default |
| constructor, which does not take any arguments. |
------------------------------------------------------------------------------*/
IResourceLibrary ( );
virtual
~IResourceLibrary ( );
/*-------------------------------- Accessors -----------------------------------
| These functions provide a 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 |
| 0 for an IResourceLibrary. |
------------------------------------------------------------------------------*/
virtual IString
fileName ( ) const,
asString ( ) const,
asDebugInfo ( ) const;
virtual Boolean
isOpen ( ) const;
virtual IModuleHandle
handle ( ) const;
/*----------------------- Resource Loading -------------------------------------
| These functions load specific resources from an OS/2 resource file: |
| loadString - Loads a string resource from a resource file. |
| loadMessage - Loads a message resource from a resource file. |
| loadMenu - Loads a menu for a window from a resource file. |
| loadDialog - Loads and starts a dialog from a resource file. |
| loadAccelTable - Loads an accelerator table from a resource file. |
| loadHelpTable - Loads a help table from a resource file. |
| loadIcon - Loads an icon from a resource file. If the cached |
| argument is specified, the icon is reference counted. |
| loadPointer - Loads a pointer from a resource file. If the cached |
| argument is specified, the pointer is reference counted. |
| This is the same as a call to loadIcon. |
| loadBitmap - Loads a bit map from a resource file. If the cached |
| argument is specified, the bit map is reference counted. |
| However, if a size is specified, the bit map is loaded |
| at that size. |
------------------------------------------------------------------------------*/
IString
loadString ( unsigned long stringId ) const,
loadMessage ( unsigned long messageId ) const;
IWindowHandle
loadMenu ( unsigned long menuId,
IWindow* menuOwner) const,
loadDialog ( unsigned long dialogId,
IWindow* dialogParent,
IWindow* dialogOwner,
IWinProc* dialogProcedure,
void* dialogCreateParameters) const;
IAccelTblHandle
loadAccelTable ( unsigned long accelTableId) const;
IResourceLibrary
&loadHelpTable ( IWindow* helpInstance,
unsigned long helpTableId) const;
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& pointerHandle),
addRef ( const IBitmapHandle& bitmapHandle),
removeRef ( const IPointerHandle& pointerHandle),
removeRef ( const IBitmapHandle& bitmapHandle);
static unsigned long
systemPointer ( unsigned long systemPointerId,
Boolean fCopy = false);
static unsigned long
systemBitmap ( unsigned long systemPointerId);
};
class IDynamicLinkLibrary : public IResourceLibrary
{
typedef IResourceLibrary
Inherited;
/*******************************************************************************
* The IDynamicLinkLibrary class provides the support for loading OS/2 *
* resources from a dynamic-link library (DLL). * *
* *
* Example: *
* *
* const unsigned MyIcon 15; *
* IDynamicLinkLibrary reslib("icons"); *
* IPointerHandle ptrh = reslib.loadIcon(MyIcon); *
*******************************************************************************/
public:
//friend class IProcAddressHandle;
/*------------------------ Constructors/Destructor ----------------------------
| You can construct an instance of this class in the following ways: |
| - By providing a name to use for the dynamic link module. The name |
| should be specified without the path or extension if the LIBPATH is |
| to be searched for the DLL. |
| - From an IModuleHandle obtained by loading the DLL explicitly. |
| - By copying an existing IDynamicLinkLibary. |
------------------------------------------------------------------------------*/
IDynamicLinkLibrary (const char* resourceFileName);
IDynamicLinkLibrary (const IModuleHandle& moduleHandle);
IDynamicLinkLibrary (const IDynamicLinkLibrary& dllLibrary);
virtual
~IDynamicLinkLibrary ( );
/*----------------------- Assignment -------------------------------------------
| This operator is used for assignment: |
| operator = - Used to assign one DLL to another. |
------------------------------------------------------------------------------*/
IDynamicLinkLibrary
&operator= ( const IDynamicLinkLibrary& dllLibrary);
/*----------------------- DLL Open/Close ---------------------------------------
| These functions open and close an OS/2 DLL: |
| open - Opens a DLL. |
| close - Closes a DLL. |
------------------------------------------------------------------------------*/
virtual IDynamicLinkLibrary
&open ( ),
&close ( );
/*----------------------- Procedure Address Loading ----------------------------
| This is used to get a procedure address from a DLL: |
| procAddress - Loads a procedure address from a DLL. |
| isEntryPoint32Bit - Returns true if the entry point with a given name or |
| ordinal is a 32-bit function. |
------------------------------------------------------------------------------*/
void
*procAddress (const char* procedureName),
*procAddress (unsigned long procedureOrdinal);
Boolean
isEntryPoint32Bit (const char* procedureName) const,
isEntryPoint32Bit (unsigned long procedureOrdinal) const;
/*-------------------------------- Overrides -----------------------------------
| This class overrides the following inherited functions: |
| isOpen - Overridden to return the open state of the DLL. |
| fileName - Overridden to return the name of the DLL. |
| 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;
virtual IModuleHandle
handle ( ) const;
private:
// Static functions to reference count DLL's */
static unsigned long
addRef ( const IModuleHandle& moduleHandle),
removeRef ( const IModuleHandle& moduleHandle);
IDLLModule
*pmodClResource;
};
class IResourceId : public IBase
{
typedef IBase
Inherited;
/*******************************************************************************
* The IResourceId class is a wrapper class for a resource identifier. Part *
* of the information contained in the class is the location of the resources *
* that are described using either an IResourceLibrary or an *
* IDynamicLinkLibrary. Most classes in the User Interface Class 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 ----------------------------------------
| You can construct an instance of this class in the following ways: |
| - By providing an ID and a reference to an IResourceLibrary. |
| - By providing an ID and a reference to an IDynamicLinkLibrary. |
| - By providing only an ID. The resource library used is the one |
| returned by a call to ICurrentApplication::userResourceLibrary. This |
| is the recommended use of the class. |
------------------------------------------------------------------------------*/
IResourceId ( unsigned long resourceId,
const IResourceLibrary& resourceLibrary);
IResourceId ( unsigned long resourceId,
const IDynamicLinkLibrary& dllLibrary);
IResourceId ( unsigned long resourceId);
/*-------------------------------- Accessors -----------------------------------
| These functions provide a means of getting and setting the accessible |
| attributes of instances of this class: |
| id - Returns the identifier used for the resource. |
| operator unsigned long - Returns the identifier used for the resource. |
| resourceLibrary - Returns a const reference to the resource |
| library. |
------------------------------------------------------------------------------*/
unsigned long
id ( ) const;
operator unsigned long ( ) const;
const IResourceLibrary
&resourceLibrary ( ) const;
/*-------------------------------- Overrides -----------------------------------
| This class overrides the following inherited functions: |
| asString - Overridden to provide textual information about the class |
| instance. |
| asDebugInfo - Overridden to provide debugging information about the class |
| instance. |
------------------------------------------------------------------------------*/
virtual IString
asString ( ) const,
asDebugInfo ( ) const;
private:
unsigned long
ulClId;
const IResourceLibrary
&reslibCl;
};
/*----------------------------------------------------------------------------*/
/* Resume compiler default packing and warning messages. */
/*----------------------------------------------------------------------------*/
#pragma pack()
#pragma info(restore)
/*----------------------------- Inline Functions -----------------------------*/
#ifndef I_NO_INLINES
#include <ireslib.inl>
#endif
#endif /* _IRESLIB_ */