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

  1. /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2.    %     Copyright (C) 1995, 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 _WPALETTE_HPP_INCLUDED
  12. #define _WPALETTE_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 _WCOLOR_HPP_INCLUDED
  26. #  include "wcolor.hpp"
  27. #endif
  28.  
  29. class WPaletteReference;
  30.  
  31. enum WPaletteHandle { NULLHPALETTE = 0, LASTHPALETTE = LAST_16TO32BIT };
  32.  
  33. class WCMCLASS WPalette : public WObject {
  34.     WDeclareSubclass( WPalette, WObject );
  35.  
  36.     public:
  37.  
  38.         /************************************************************
  39.          * Constructors and Destructors
  40.          ************************************************************/
  41.  
  42.         WPalette();
  43.         WPalette( const WPalette & palette );
  44.         WPalette( const WColorArray & colorList );
  45.         WPalette( const WPaletteHandle handle, WBool deleteHandle=FALSE );
  46.  
  47.         ~WPalette();
  48.  
  49.         /************************************************************
  50.          * Properties
  51.          ************************************************************/
  52.  
  53.         // Handle
  54.  
  55.         WPaletteHandle GetHandle() const;
  56.  
  57.         // Valid
  58.         //
  59.         //     TRUE if palette was created/loaded.
  60.     
  61.         WBool GetValid() const { return GetHandle() != NULLHPALETTE; }
  62.  
  63.         /************************************************************
  64.          * Methods
  65.          ************************************************************/
  66.  
  67.         // Clear
  68.         //
  69.         //     Set the palette to a null state.  Deletes the palette
  70.         //     handle.
  71.  
  72.         void Clear();
  73.  
  74.         // Create
  75.         //
  76.         //     Create a new palette.  First clears old palette by calling
  77.         //     the Clear method.
  78.  
  79.         WBool Create( const WColorArray & colorList );
  80.         WBool Create( const WPalette & palette );
  81.         WBool Create( const WPaletteHandle handle, WBool deleteHandle=FALSE );
  82.  
  83.         /************************************************************
  84.          * Static Methods
  85.          ************************************************************/
  86.  
  87.         // IsValidHandle
  88.         //
  89.         //     Returns TRUE if the given handle is valid.  Can
  90.         //     optionally specify whether or not a null handle
  91.         //     is "valid".
  92.  
  93.         static WBool IsValidHandle( WPaletteHandle handle,
  94.                                     WBool nullValid=FALSE );
  95.  
  96.         /************************************************************
  97.          * Static Properties
  98.          ************************************************************/
  99.  
  100.         // NullPalette
  101.  
  102.         static const WPalette & GetNullPalette();
  103.  
  104.         /************************************************************
  105.          * Operators
  106.          ************************************************************/
  107.  
  108.         WPalette & operator=( const WPalette & p );
  109.  
  110.         int operator==( const WPalette & p ) const;
  111.         int operator!=( const WPalette & p ) const;
  112.  
  113.         /***********************************************************
  114.          * Data members
  115.          ***********************************************************/
  116.  
  117.     private:
  118.  
  119.         WPaletteReference *     _ref;
  120. };
  121.  
  122. #ifdef _DEBUG
  123. #define W_ISPALETTEHANDLE(h) CHECKGDI(WPalette::IsValidHandle((WPaletteHandle)h))
  124. #else
  125. #define W_ISPALETTEHANDLE(h)
  126. #endif
  127.  
  128. #ifndef _WNO_PRAGMA_PUSH
  129. #pragma enum pop;
  130. #pragma pack(pop);
  131. #endif
  132.  
  133. #endif // _WPALETTE_HPP_INCLUDED
  134.