1
0

api_region.h 4.5 KB

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