home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1997 May / Pcwk0597.iso / sybase / starbuck / hpp.z / WICON.HPP < prev    next >
C/C++ Source or Header  |  1996-10-18  |  5KB  |  162 lines

  1. /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2.    %     Copyright (C) 1994, by WATCOM International Inc.  All rights    %
  3.    %     reserved.  No part of this software may be reproduced or        %
  4.    %     used in any form or by any means - graphic, electronic or       %
  5.    %     mechanical, including photocopying, recording, taping or        %
  6.    %     information storage and retrieval systems - except with the     %
  7.    %     written permission of WATCOM International Inc.                 %
  8.    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  9. */
  10.  
  11. #ifndef _WICON_HPP_INCLUDED
  12. #define _WICON_HPP_INCLUDED
  13.  
  14. #ifndef _WNO_PRAGMA_PUSH
  15. #pragma pack(push,8);
  16. #pragma enum int;
  17. #endif
  18.  
  19. #ifndef _WOBJECT_HPP_INCLUDED
  20. #  include "wobject.hpp"
  21. #endif
  22. #ifndef _WRESID_HPP_INCLUDED
  23. #  include "wresid.hpp"
  24. #endif
  25. #ifndef _WPOINT_HPP_INCLUDED
  26. #  include "wpoint.hpp"
  27. #endif
  28. #ifndef _WSIZE_HPP_INCLUDED
  29. #  include "wsize.hpp"
  30. #endif
  31.  
  32. class WImageList;
  33.  
  34. enum WStockIcon {
  35.     WSIconFirst,
  36.     WSIconApplication = WSIconFirst,
  37.     WSIconAsterisk,
  38.     WSIconExclamation,
  39.     WSIconStopSign,
  40.     WSIconQuestion,
  41.     WSIconLast = WSIconQuestion
  42. };
  43.  
  44. class WBitmap;
  45. class WColor;
  46. class WCanvas;
  47. class WIconReference;
  48.  
  49. class WCMCLASS WIcon : public WObject {
  50.     WDeclareSubclass( WIcon, WObject );
  51.  
  52.     friend class WImageList;
  53.  
  54.     public:
  55.  
  56.         /************************************************************
  57.          * Constructors and Destructors
  58.          ************************************************************/
  59.  
  60.         WIcon();
  61.         WIcon( WStockIcon stock );
  62.         WIcon( const WResourceID & id, WModuleHandle module=_ApplicationModule );
  63.         WIcon( const WChar * file, const WResourceID & id);
  64.         WIcon( const WChar * file, WBool monochrome,
  65.                         const WSize & iconSize = WSize(0,0) );
  66.         WIcon( WIconHandle handle, WBool deleteHandle=FALSE );
  67.         WIcon( const WIcon & icon );
  68.         WIcon( const WBitmap & bitmap, WPoint hotPoint, WBool color = TRUE);
  69.  
  70.         ~WIcon();
  71.  
  72.         /************************************************************
  73.          * Properties
  74.          ************************************************************/
  75.  
  76.         // Handle
  77.  
  78.         WIconHandle GetHandle() const;
  79.  
  80.         // Valid
  81.         //
  82.         //     TRUE if icon was created/loaded.
  83.     
  84.         WBool GetValid() const;
  85.  
  86.         /************************************************************
  87.          * Methods
  88.          ************************************************************/
  89.  
  90.         // Clear
  91.         //
  92.         //     Set the icon to a null state.  Deletes the icon
  93.         //     handle unless it's a stock icon or nodelete was specified.
  94.  
  95.         void Clear();
  96.  
  97.         // Create
  98.         //
  99.         //     Create a new icon.  First clears old icon by calling
  100.         //     the Clear method.
  101.  
  102.         WBool Create( WStockIcon stock );
  103.         WBool Create( const WResourceID & id, WModuleHandle module=_ApplicationModule );
  104.         WBool Create( const WChar * file, const WResourceID & id );
  105.         WBool Create( const WChar * file, WBool monochrome=FALSE,
  106.                         const WSize & iconSize = WSize(0,0) );
  107.         WBool Create( WIconHandle handle, WBool deleteHandle=FALSE );
  108.         WBool Create( const WIcon & icon );
  109.         WBool Create( const WBitmap & bitmap, WPoint hotPoint, WBool color = TRUE);
  110.  
  111.         /***********************************************************
  112.          * Static Methods
  113.          ***********************************************************/
  114.  
  115.         // IsValidHandle
  116.         //
  117.         //     Returns TRUE if the given handle is valid.  Can
  118.         //     optionally specify whether or not a null handle
  119.         //     is "valid".
  120.  
  121.         static WBool IsValidHandle( WIconHandle handle,
  122.                                     WBool nullValid=FALSE );
  123.  
  124.         /***********************************************************
  125.          * Static Properties
  126.          ***********************************************************/
  127.  
  128.         // IconCount
  129.  
  130.         static WUInt GetIconCount( const WChar *file );
  131.  
  132.         // NullIcon
  133.  
  134.         static const WIcon & GetNullIcon();
  135.  
  136.         /***********************************************************
  137.          * Operators
  138.          ***********************************************************/
  139.  
  140.         WIcon & operator=( const WIcon & icon );
  141.  
  142.         /***********************************************************
  143.          * Data Members
  144.          ***********************************************************/
  145.     
  146.     private:
  147.         WIconReference *        _iconRef;
  148. };
  149.  
  150. #ifdef _DEBUG
  151. #define W_ISICONHANDLE(h)  CHECKGDI( WIcon::IsValidHandle( (WIconHandle) h ) )
  152. #else
  153. #define W_ISICONHANDLE(h)
  154. #endif
  155.  
  156. #ifndef _WNO_PRAGMA_PUSH
  157. #pragma enum pop;
  158. #pragma pack(pop);
  159. #endif
  160.  
  161. #endif // _WICON_HPP_INCLUDED
  162.