home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / atl / atlfire / size.h < prev    next >
C/C++ Source or Header  |  1998-03-26  |  2KB  |  72 lines

  1. // Size.h: interface for the CSize class.
  2. //
  3. // This is a part of the Active Template Library.
  4. // Copyright (C) 1996-1998 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Active Template Library Reference and related
  9. // electronic documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Active Template Library product.
  12.  
  13. #if !defined(AFX_SIZE_H__479B29F2_9A2C_11D0_B696_00A0C903487A__INCLUDED_)
  14. #define AFX_SIZE_H__479B29F2_9A2C_11D0_B696_00A0C903487A__INCLUDED_
  15.  
  16. #if _MSC_VER >= 1000
  17. #pragma once
  18. #endif // _MSC_VER >= 1000
  19.  
  20. class CSize : public tagSIZE
  21. {
  22. public:
  23.     CSize(){ cx = cy = 0;}
  24.     CSize(int initCX, int initCY);
  25.     CSize(SIZE initSize);
  26.     CSize(POINT initPt);
  27.     CSize(DWORD dwSize);
  28.  
  29.     // Operations
  30.     BOOL operator==(SIZE size) const;
  31.     BOOL operator!=(SIZE size) const;
  32.     void operator+=(SIZE size);
  33.     void operator-=(SIZE size);
  34.  
  35.     // Operators returning CSize values
  36.     CSize operator+(SIZE size) const;
  37.     CSize operator-(SIZE size) const;
  38.     CSize operator-() const;
  39.  
  40.     // dtor
  41.     virtual ~CSize(){}
  42.  
  43. };
  44.  
  45. inline CSize::CSize(int initCX, int initCY)
  46. { cx = initCX; cy = initCY; }
  47. inline CSize::CSize(SIZE initSize)
  48. { *(SIZE*)this = initSize; }
  49. inline CSize::CSize(POINT initPt)
  50. { *(POINT*)this = initPt; }
  51. inline CSize::CSize(DWORD dwSize)
  52. {
  53.     cx = (short)LOWORD(dwSize);
  54.     cy = (short)HIWORD(dwSize);
  55. }
  56. inline BOOL CSize::operator==(SIZE size) const
  57. { return (cx == size.cx && cy == size.cy); }
  58. inline BOOL CSize::operator!=(SIZE size) const
  59. { return (cx != size.cx || cy != size.cy); }
  60. inline void CSize::operator+=(SIZE size)
  61. { cx += size.cx; cy += size.cy; }
  62. inline void CSize::operator-=(SIZE size)
  63. { cx -= size.cx; cy -= size.cy; }
  64. inline CSize CSize::operator+(SIZE size) const
  65. { return CSize(cx + size.cx, cy + size.cy); }
  66. inline CSize CSize::operator-(SIZE size) const
  67. { return CSize(cx - size.cx, cy - size.cy); }
  68. inline CSize CSize::operator-() const
  69. { return CSize(-cx, -cy); }
  70.  
  71. #endif // !defined(AFX_SIZE_H__479B29F2_9A2C_11D0_B696_00A0C903487A__INCLUDED_)
  72.