home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1997 May / Pcwk0597.iso / sybase / starbuck / hpp.z / WSIZE.HPP < prev    next >
C/C++ Source or Header  |  1996-10-18  |  4KB  |  142 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. /*************************************************************************
  12.  *
  13.  * WSize --
  14.  *
  15.  *************************************************************************/
  16.  
  17. #ifndef _WSIZE_HPP_INCLUDED
  18. #define _WSIZE_HPP_INCLUDED
  19.  
  20. #ifndef _WNO_PRAGMA_PUSH
  21. #pragma pack(push,8);
  22. #pragma enum int;
  23. #endif
  24.  
  25. #ifndef _WDEF_HPP_INCLUDED
  26. #  include "wdef.hpp"
  27. #endif
  28.  
  29. #ifndef _WINDEF_
  30. #ifndef _WIN16
  31. typedef struct tagSIZE {
  32.     WInt cx;
  33.     WInt cy;
  34. } SIZE, *PSIZE, *LPSIZE;
  35.  
  36. typedef SIZE SIZEL;
  37. typedef SIZE *PSIZEL, *LPSIZEL;
  38. #else
  39. typedef struct tagSIZE {
  40.     WLong cx;
  41.     WLong cy;
  42. } SIZE, *PSIZE, *LPSIZE;
  43.  
  44. typedef SIZE SIZEL;
  45. typedef SIZE *PSIZEL, *LPSIZEL;
  46. #endif
  47. #endif
  48.  
  49. class WCMCLASS WSize {
  50.  
  51.         /**********************************************************
  52.          * Data members
  53.          *********************************************************/
  54.  
  55.     public:
  56.     
  57.         WInt w;
  58.         WInt h;
  59.  
  60.     public:
  61.  
  62.         /**********************************************************
  63.          * Constructors and Destructors
  64.          *********************************************************/
  65.  
  66.         WSize() { w = h = 0; }
  67.         WSize( WInt nw, WInt nh ) { w = nw; h = nh; }
  68.         WSize( const WSize & o ) { w = o.w; h = o.h; }
  69.         WSize( const SIZE & o ); // WCMINLINE
  70.  
  71.         // Note: no destructor is defined and none will be generated
  72.         // because the class has simple types as data and no virtual
  73.         // functions and does not inherit from anyone.
  74.  
  75.         /**********************************************************
  76.          * Properties
  77.          *********************************************************/
  78.  
  79.         // SIZE 
  80.  
  81.         SIZE  GetSIZE() const; // WCMINLINE
  82.         void  SetSIZE( const SIZE & s ); // WCMINLINE
  83.  
  84.         /**********************************************************
  85.          * Methods
  86.          *********************************************************/
  87.  
  88.         // Create
  89.  
  90.         void Create() { w = h = 0; }
  91.         void Create( WInt nw, WInt nh ) { w = nw; h = nh; }
  92.         void Create( const WSize & o ) { w = o.w; h = o.h; }
  93.         void Create( const SIZE & o ); // WCMINLINE
  94.  
  95.         // Offset
  96.  
  97.         void Offset( WInt nw, WInt nh ); // WCMINLINE
  98.         void Offset( const WSize & sz ); // WCMINLINE
  99.  
  100.         /**********************************************************
  101.          * Operators
  102.          *********************************************************/
  103.  
  104.         // == operator
  105.  
  106.         int operator==( const WSize & o ) const; // WCMINLINE
  107.  
  108.         // != operator
  109.  
  110.         int operator!=( const WSize & o ) const; // WCMINLINE
  111.     
  112.         // = operator
  113.  
  114.         WSize & operator=( const WSize & o )
  115.             { w = o.w; h = o.h; return *this; }
  116.         WSize & operator=( const SIZE & o ); // WCMINLINE
  117.  
  118.         // +, - operator
  119.  
  120.         WSize operator+( const WSize & o ); // WCMINLINE
  121.         WSize operator-( const WSize & o ); // WCMINLINE
  122.  
  123.         // +=, -= operator
  124.  
  125.         WSize & operator+=( const WSize & o ); // WCMINLINE
  126.         WSize & operator-=( const WSize & o ); // WCMINLINE
  127. };
  128.  
  129. #ifdef WCM_ENABLE_INLINES
  130.   #ifndef WCM_NO_WSIZE_INLINES
  131.     #define WCMINLINE inline
  132.     #include "wsize.inl"
  133.   #endif
  134. #endif
  135.  
  136. #ifndef _WNO_PRAGMA_PUSH
  137. #pragma enum pop;
  138. #pragma pack(pop);
  139. #endif
  140.  
  141. #endif // _WSIZE_HPP_INCLUDED
  142.