Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

125 lines
4.2 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corp., 1991 **/
  4. /**********************************************************************/
  5. /*
  6. bltrect.hxx
  7. Rectangle support for BLT
  8. This file contains the declaration of the RECT class.
  9. FILE HISTORY:
  10. beng 22-Jul-1991 Created
  11. terryk 03-Aug-1991 add Screen<->client coordinate
  12. system subroutine.
  13. terryk 16-Aug-1991 Code review changed.
  14. Attend: Rustanl davidhov davidbul
  15. terryk
  16. */
  17. #ifndef _BLTRECT_HXX_
  18. #define _BLTRECT_HXX_
  19. /*************************************************************************
  20. NAME: XYRECT
  21. SYNOPSIS: Rectangle calculation and manipulation object
  22. INTERFACE: XYRECT() - constructor. May take window.
  23. operator==() - equality operator
  24. operator=() - assignment operator
  25. ContainsXY() - determine whether point is in rectangle
  26. IsEmpty() - determine empty rectangle
  27. Offset() - moves rectangle
  28. Inflate() - sizes rectangle by constant addition
  29. CalcIntersect() - calculate intersection of two others
  30. CalcUnion() - calculate union of two others
  31. operator const RECT*()
  32. - access operator for Win APIs
  33. ConvertClientToScreen() - convert the rectangle from client
  34. coordinate system to screen coordinate
  35. system.
  36. ConvertScreenToClient() - convert the screen coordinate
  37. system to client coordinate system.
  38. PARENT: BASE
  39. USES: XYPOINT, XYDIMENSION
  40. CAVEATS:
  41. May report error upon construction if built from a window.
  42. NOTES:
  43. HISTORY:
  44. beng 22-Jul-1991 Created
  45. terryk 03-Aug-1991 add convertion routines.
  46. terryk 16-Aug-1991 Correct typos; added operator +=
  47. beng 09-Oct-1991 Extended get-client-window ctors
  48. beng 28-May-1992 Make client rect pwnd arg const
  49. **************************************************************************/
  50. DLL_CLASS XYRECT: public BASE
  51. {
  52. private:
  53. RECT _rect;
  54. public:
  55. // Create an empty rectangle
  56. XYRECT();
  57. XYRECT( XYPOINT xyUl, XYPOINT xyLr );
  58. XYRECT( XYPOINT xy, XYDIMENSION dxy );
  59. XYRECT( INT xUl, INT yUl, INT xLr, INT yLr );
  60. XYRECT( const RECT & rect );
  61. // Get the client (or bounding) rectangle from the window
  62. XYRECT( HWND hwnd, BOOL fClientOnly = TRUE );
  63. XYRECT( const WINDOW * pwnd, BOOL fClientOnly = TRUE );
  64. XYRECT( const XYRECT & rect );
  65. XYRECT& operator=( const XYRECT& rect );
  66. XYRECT& AdjustLeft( INT dx ) { _rect.left += dx; return *this; }
  67. XYRECT& AdjustRight( INT dx ) { _rect.right += dx; return *this; }
  68. XYRECT& AdjustTop( INT dy ) { _rect.top += dy; return *this; }
  69. XYRECT& AdjustBottom( INT dy ) { _rect.bottom += dy; return *this; }
  70. INT QueryLeft() const { return _rect.left; }
  71. INT QueryRight() const { return _rect.right; }
  72. INT QueryTop() const { return _rect.top; }
  73. INT QueryBottom() const { return _rect.bottom; }
  74. XYRECT& operator +=( const XYRECT& xySrc ) ;
  75. INT CalcWidth() const { return _rect.right - _rect.left; }
  76. INT CalcHeight() const { return _rect.bottom - _rect.top; }
  77. XYRECT& Offset( INT dx, INT dy );
  78. XYRECT& Offset( XYDIMENSION dxy );
  79. XYRECT& Inflate( INT dx, INT dy );
  80. XYRECT& Inflate( XYDIMENSION dxy );
  81. XYRECT& CalcIntersect( const XYRECT &xySrc1, const XYRECT &xySrc2 );
  82. XYRECT& CalcUnion( const XYRECT &xySrc1, const XYRECT &xySrc2 );
  83. BOOL ContainsXY( XYPOINT xy ) const;
  84. BOOL IsEmpty() const;
  85. BOOL operator==( const XYRECT& ) const;
  86. operator const RECT*() const { return &_rect; }
  87. VOID ConvertClientToScreen( HWND hwnd );
  88. VOID ConvertScreenToClient( HWND hwnd );
  89. };
  90. #endif // _BLTRECT_HXX_