home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / include / fe_rgn.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  4.1 KB  |  134 lines

  1. /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19.  
  20. /* Region-related definitions and prototypes */
  21.  
  22. #ifndef _FE_RGN_H_
  23. #define _FE_RGN_H_
  24.  
  25. #ifdef LAYERS
  26.  
  27. #include "xp_core.h"
  28. #include "xp_rect.h"
  29. /******************Definitions and Types************/
  30.  
  31. /* For Windows only: Should we use the MFC CRgn class for region stuff? */
  32. #ifdef XP_WIN
  33. #undef FE_RGN_USE_MFC
  34. #endif /* XP_WIN */
  35.  
  36. #ifdef XP_WIN
  37.  
  38. #ifdef FE_RGN_USE_MFC
  39. #define FE_GetMDRegion(rgn) ((CRgn *)rgn)
  40. #else 
  41. /* 
  42.  * Note that the resultant CRgn * does not have to be 
  43.  * explicitly deleted. It is considered a temporary object
  44.  * by the MFC and is deleted the next time we have idle
  45.  * time in the event loop.
  46.  */
  47. #define FE_GetMDRegion(rgn) ((HRGN)rgn)
  48. #endif /* FE_RGN_USE_MFC */
  49.  
  50. #elif defined(XP_UNIX)
  51. #define FE_GetMDRegion(rgn) ((Region)rgn)
  52. #elif defined(XP_MAC)
  53. #define FE_GetMDRegion(rgn) ((RgnHandle)rgn)
  54. #else
  55. #define FE_GetMDRegion(rgn) (rgn)
  56. #endif /* XP_WIN */
  57.  
  58. #ifdef XP_WIN
  59. #define FE_MAX_REGION_COORDINATE 0x7FFFFFFF
  60. #else
  61. #define FE_MAX_REGION_COORDINATE 0x7FFF
  62. #endif
  63.  
  64. /* Setting the clip region to this effectively unsets the clip */
  65. #define FE_NULL_REGION NULL
  66.  
  67. #define FE_CLEAR_REGION(region)    \
  68.     do {FE_SubtractRegion((region), (region), (region)); } while (0)
  69.  
  70. /* Function called by FE_ForEachRectInRegion */
  71. typedef void (*FE_RectInRegionFunc)(void *closure, XP_Rect *rect);
  72.  
  73. /*******************Prototypes**********************/
  74.  
  75. XP_BEGIN_PROTOS
  76.  
  77. extern FE_Region FE_CreateRegion(void);
  78.  
  79. /* Creates a region from a rectangle. Returns */
  80. /* NULL if region can't be created.           */
  81. extern FE_Region FE_CreateRectRegion(XP_Rect *rect);
  82.  
  83. /* Destroys region. */
  84. extern void FE_DestroyRegion(FE_Region region);
  85.  
  86. /* Makes a copy of a region. If dst is NULL, creates a new region */
  87. extern FE_Region FE_CopyRegion(FE_Region src, FE_Region dst);
  88.  
  89. /* Set an existing region to a rectangle */
  90. extern FE_Region FE_SetRectRegion(FE_Region region, XP_Rect *rect);
  91.  
  92. /* dst = src1 intersect sr2       */
  93. /* dst can be one of src1 or src2 */
  94. extern void FE_IntersectRegion(FE_Region src1, FE_Region src2, FE_Region dst);
  95.  
  96. /* dst = src1 union src2          */
  97. /* dst can be one of src1 or src2 */
  98. extern void FE_UnionRegion(FE_Region src1, FE_Region src2, FE_Region dst);
  99.  
  100. /* dst = src1 - src2              */
  101. /* dst can be one of src1 or src2 */
  102. extern void FE_SubtractRegion(FE_Region src1, FE_Region src2, FE_Region dst);
  103.  
  104. /* Returns TRUE if the region contains no pixels */
  105. extern XP_Bool FE_IsEmptyRegion(FE_Region region);
  106.  
  107. /* Returns the bounding rectangle of the region */
  108. extern void FE_GetRegionBoundingBox(FE_Region region, XP_Rect *bbox);
  109.  
  110. /* TRUE if rgn1 == rgn2 */
  111. extern XP_Bool FE_IsEqualRegion(FE_Region rgn1, FE_Region rgn2);
  112.  
  113. /* Moves a region by the specified offsets */
  114. extern void FE_OffsetRegion(FE_Region region, int32 xOffset, int32 yOffset);
  115.  
  116. /* Is any part of the rectangle in the specified region */
  117. extern XP_Bool FE_RectInRegion(FE_Region region, XP_Rect *rect);
  118.  
  119. /* For each rectangle that makes up this region, call the func */
  120. extern void FE_ForEachRectInRegion(FE_Region region, 
  121.                                    FE_RectInRegionFunc func,
  122.                                    void * closure);
  123.  
  124. #ifdef DEBUG
  125. extern void FE_HighlightRect(void *context, XP_Rect *rect, int how_much);
  126. extern void FE_HighlightRegion(void *context, FE_Region region, int how_much);
  127. #endif /* DEBUG */
  128.  
  129. XP_END_PROTOS
  130.  
  131. #endif /* LAYERS */
  132.  
  133. #endif /* _FE_RGN_H_ */
  134.