api_region.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. #ifndef __WASABI_API_REGION_H
  2. #define __WASABI_API_REGION_H
  3. #include <bfc/dispatch.h>
  4. class api_region : public Dispatchable
  5. {
  6. protected:
  7. api_region() {}
  8. virtual ~api_region() {}
  9. public:
  10. DISPATCH_CODES
  11. {
  12. REGION_GETOSHANDLE = 50,
  13. REGION_CLONE = 100,
  14. REGION_DISPOSECLONE = 110,
  15. REGION_PTINREGION = 120,
  16. REGION_OFFSET = 130,
  17. REGION_GETBOX = 140,
  18. REGION_SUBTRACTRGN = 150,
  19. REGION_SUBTRACTRECT = 160,
  20. REGION_ADDRECT = 170,
  21. REGION_ADD = 180,
  22. REGION_AND = 190,
  23. REGION_SETRECT = 200,
  24. REGION_EMPTY = 210,
  25. REGION_ISEMPTY = 220,
  26. REGION_EQUALS = 230,
  27. REGION_ENCLOSED = 240,
  28. REGION_INTERSECTRGN = 250,
  29. REGION_DOESINTERSECTRGN = 251,
  30. REGION_INTERSECTRECT = 260,
  31. REGION_ISRECT = 270,
  32. REGION_SCALE = 280,
  33. REGION_DEBUG = 290,
  34. REGION_MAKEWNDREGION = 300,
  35. REGION_GETNUMRECTS = 310,
  36. REGION_ENUMRECT = 320,
  37. };
  38. public:
  39. OSREGIONHANDLE getOSHandle(); // avoid as much as you can, should be used only when you need to call the OS api
  40. api_region *clone();
  41. void disposeClone(api_region *r);
  42. bool ptInRegion(const POINT *pt);
  43. void offset(int x, int y);
  44. void getBox(RECT *r);
  45. void subtractRegion(const api_region *r);
  46. void subtractRgn(const api_region *r) { subtractRegion(r); } //DEPRECATED
  47. void subtractRect(const RECT *r);
  48. void addRect(const RECT *r);
  49. void addRegion(const api_region *r);
  50. void andRegion(const api_region *r);
  51. void setRect(const RECT *r);
  52. void empty();
  53. int isEmpty();
  54. int equals(const api_region *r);
  55. int enclosed(const api_region *r, api_region *outside = NULL);
  56. int intersectRgn(const api_region *r, api_region *intersection);
  57. int doesIntersectRgn(const api_region *r);
  58. int intersectRect(const RECT *r, api_region *intersection);
  59. int isRect();
  60. void scale(double sx, double sy, bool round = 0);
  61. void debug(int async = 0);
  62. OSREGIONHANDLE makeWindowRegion(); // gives you a handle to a clone of the OSREGION object so you can insert it into a window's region with SetWindowRgn. ANY other use is prohibited
  63. // this is how you can enumerate the subrects that compose to make up the
  64. // entire region
  65. int getNumRects();
  66. int enumRect(int n, RECT *r);
  67. };
  68. inline OSREGIONHANDLE api_region::getOSHandle()
  69. {
  70. return _call(REGION_GETOSHANDLE, (OSREGIONHANDLE)NULL);
  71. }
  72. inline api_region *api_region::clone()
  73. {
  74. return _call(REGION_CLONE, (api_region *)NULL);
  75. }
  76. inline void api_region::disposeClone(api_region *r)
  77. {
  78. _voidcall(REGION_DISPOSECLONE, r);
  79. }
  80. inline bool api_region::ptInRegion(const POINT *pt)
  81. {
  82. return _call(REGION_PTINREGION, false, pt);
  83. }
  84. inline void api_region::offset(int x, int y)
  85. {
  86. _voidcall(REGION_OFFSET, x, y);
  87. }
  88. inline void api_region::getBox(RECT *r)
  89. {
  90. _voidcall(REGION_GETBOX, r);
  91. }
  92. inline void api_region::subtractRegion(const api_region *reg)
  93. {
  94. _voidcall(REGION_SUBTRACTRGN, reg);
  95. }
  96. inline void api_region::subtractRect(const RECT *r)
  97. {
  98. _voidcall(REGION_SUBTRACTRECT, r);
  99. }
  100. inline void api_region::addRect(const RECT *r)
  101. {
  102. _voidcall(REGION_ADDRECT, r);
  103. }
  104. inline void api_region::addRegion(const api_region *r)
  105. {
  106. _voidcall(REGION_ADD, r);
  107. }
  108. inline void api_region::andRegion(const api_region *r)
  109. {
  110. _voidcall(REGION_AND, r);
  111. }
  112. inline void api_region::setRect(const RECT *r)
  113. {
  114. _voidcall(REGION_SETRECT, r);
  115. }
  116. inline void api_region::empty()
  117. {
  118. _voidcall(REGION_EMPTY);
  119. }
  120. inline int api_region::isEmpty()
  121. {
  122. return _call(REGION_ISEMPTY, 0);
  123. }
  124. inline int api_region::equals(const api_region *r)
  125. {
  126. return _call(REGION_EQUALS, 0, r);
  127. }
  128. inline int api_region::enclosed(const api_region *r, api_region *outside)
  129. {
  130. return _call(REGION_ENCLOSED, 0, r, outside);
  131. }
  132. inline int api_region::intersectRgn(const api_region *r, api_region *intersection)
  133. {
  134. return _call(REGION_INTERSECTRGN, 0, r, intersection);
  135. }
  136. inline int api_region::doesIntersectRgn(const api_region *r)
  137. {
  138. return _call(REGION_DOESINTERSECTRGN, 0, r);
  139. }
  140. inline int api_region::intersectRect(const RECT *r, api_region *intersection)
  141. {
  142. return _call(REGION_INTERSECTRECT, 0, r, intersection);
  143. }
  144. inline int api_region::isRect()
  145. {
  146. return _call(REGION_ISRECT, 0);
  147. }
  148. inline void api_region::scale(double sx, double sy, bool round)
  149. {
  150. _voidcall(REGION_SCALE, sx, sy, round);
  151. }
  152. inline void api_region::debug(int async)
  153. {
  154. _voidcall(REGION_DEBUG, async);
  155. }
  156. inline OSREGIONHANDLE api_region::makeWindowRegion()
  157. {
  158. return _call(REGION_MAKEWNDREGION, (OSREGIONHANDLE)NULL);
  159. }
  160. inline int api_region::getNumRects()
  161. {
  162. return _call(REGION_GETNUMRECTS, 0);
  163. }
  164. inline int api_region::enumRect(int n, RECT *r)
  165. {
  166. return _call(REGION_ENUMRECT, 0, n, r);
  167. }
  168. #endif