home *** CD-ROM | disk | FTP | other *** search
/ Chip 1997 October / Chip_1997-10_cd.bin / tema / sybase / powerj / hpp.z / WICON.HPP < prev    next >
C/C++ Source or Header  |  1997-01-14  |  5KB  |  178 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 _WARRAY_HPP_INCLUDED
  23. #  include "warray.hpp"
  24. #endif
  25. #ifndef _WRESID_HPP_INCLUDED
  26. #  include "wresid.hpp"
  27. #endif
  28. #ifndef _WPOINT_HPP_INCLUDED
  29. #  include "wpoint.hpp"
  30. #endif
  31. #ifndef _WSIZE_HPP_INCLUDED
  32. #  include "wsize.hpp"
  33. #endif
  34.  
  35. class WImageList;
  36.  
  37. enum WStockIcon {
  38.     WSIconFirst,
  39.     WSIconApplication = WSIconFirst,
  40.     WSIconAsterisk,
  41.     WSIconExclamation,
  42.     WSIconStopSign,
  43.     WSIconQuestion,
  44.     WSIconLast = WSIconQuestion
  45. };
  46.  
  47. class WBitmap;
  48. class WColor;
  49. class WCanvas;
  50. class WIconReference;
  51. class WFilePath;
  52. class WIcon;
  53.  
  54. extern template WArrayReference<WIcon>;
  55. extern template WArray<WIcon>;
  56. typedef WArray<WIcon>                   WIconArray;
  57.  
  58. class WCMCLASS WIcon : public WObject {
  59.     WDeclareSubclass( WIcon, WObject );
  60.  
  61.     friend class WImageList;
  62.  
  63.     public:
  64.  
  65.         /************************************************************
  66.          * Constructors and Destructors
  67.          ************************************************************/
  68.  
  69.         WIcon();
  70.         WIcon( WStockIcon stock );
  71.         WIcon( const WResourceID & id, WModuleHandle module=_ApplicationModule );
  72.         WIcon( const WChar * file, const WResourceID & id);
  73.         WIcon( const WChar * file, WBool monochrome,
  74.                         const WSize & iconSize = WSize(0,0) );
  75.         WIcon( WIconHandle handle, WBool deleteHandle=FALSE );
  76.         WIcon( const WIcon & icon );
  77.         WIcon( const WBitmap & bitmap, WPoint hotPoint, WBool color = TRUE);
  78.  
  79.         ~WIcon();
  80.  
  81.         /************************************************************
  82.          * Properties
  83.          ************************************************************/
  84.  
  85.         // Handle
  86.  
  87.         WIconHandle GetHandle() const;
  88.  
  89.         // Valid
  90.         //
  91.         //     TRUE if icon was created/loaded.
  92.     
  93.         WBool GetValid() const;
  94.  
  95.         /************************************************************
  96.          * Methods
  97.          ************************************************************/
  98.  
  99.         // Clear
  100.         //
  101.         //     Set the icon to a null state.  Deletes the icon
  102.         //     handle unless it's a stock icon or nodelete was specified.
  103.  
  104.         void Clear();
  105.  
  106.         // Create
  107.         //
  108.         //     Create a new icon.  First clears old icon by calling
  109.         //     the Clear method.
  110.  
  111.         WBool Create( WStockIcon stock );
  112.         WBool Create( const WResourceID & id, WModuleHandle module=_ApplicationModule );
  113.         WBool Create( const WChar * file, const WResourceID & id );
  114.         WBool Create( const WChar * file, WBool monochrome=FALSE,
  115.                         const WSize & iconSize = WSize(0,0) );
  116.         WBool Create( WIconHandle handle, WBool deleteHandle=FALSE );
  117.         WBool Create( const WIcon & icon );
  118.         WBool Create( const WBitmap & bitmap, WPoint hotPoint, WBool color = TRUE);
  119.  
  120.         // Save
  121.  
  122.         WBool Save( const WFilePath & path, WUInt bitsPerPixel=0 ) const;
  123.  
  124.         /***********************************************************
  125.          * Static Methods
  126.          ***********************************************************/
  127.  
  128.         // IsValidHandle
  129.         //
  130.         //     Returns TRUE if the given handle is valid.  Can
  131.         //     optionally specify whether or not a null handle
  132.         //     is "valid".
  133.  
  134.         static WBool IsValidHandle( WIconHandle handle,
  135.                                     WBool nullValid=FALSE );
  136.  
  137.         static WBool Save( const WIconArray & icons, const WFilePath & path,
  138.                            WUInt bitsPerPixel=0 );
  139.  
  140.         /***********************************************************
  141.          * Static Properties
  142.          ***********************************************************/
  143.  
  144.         // IconCount
  145.  
  146.         static WUInt GetIconCount( const WChar *file );
  147.  
  148.         // NullIcon
  149.  
  150.         static const WIcon & GetNullIcon();
  151.  
  152.         /***********************************************************
  153.          * Operators
  154.          ***********************************************************/
  155.  
  156.         WIcon & operator=( const WIcon & icon );
  157.  
  158.         /***********************************************************
  159.          * Data Members
  160.          ***********************************************************/
  161.     
  162.     private:
  163.         WIconReference *        _iconRef;
  164. };
  165.  
  166. #ifdef _DEBUG
  167. #define W_ISICONHANDLE(h)  CHECKGDI( WIcon::IsValidHandle( (WIconHandle) h ) )
  168. #else
  169. #define W_ISICONHANDLE(h)
  170. #endif
  171.  
  172. #ifndef _WNO_PRAGMA_PUSH
  173. #pragma enum pop;
  174. #pragma pack(pop);
  175. #endif
  176.  
  177. #endif // _WICON_HPP_INCLUDED
  178.