region.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. #ifndef __REGION_H
  2. #define __REGION_H
  3. #include <Carbon/Carbon.h>
  4. #include <bfc/platform/platform.h>
  5. #include <tataki/region/api_region.h>
  6. class SkinBitmap;
  7. class RegionI : public api_region
  8. {
  9. public:
  10. RegionI();
  11. RegionI(const RECT *r);
  12. RegionI(RgnHandle qdrgn);
  13. RegionI(HIShapeRef _rgn);
  14. RegionI(SkinBitmap *bitmap);
  15. ~RegionI();
  16. // api_region
  17. OSREGIONHANDLE getOSHandle();
  18. api_region *clone();
  19. void disposeClone(api_region *r);
  20. bool ptInRegion(const POINT *pt);
  21. void offset(int x, int y);
  22. void getBox(RECT *r);
  23. void subtractRegion(const api_region *r);
  24. void subtractRect(const RECT *r);
  25. void addRect(const RECT *r);
  26. void addRegion(const api_region *r);
  27. void andRegion(const api_region *r);
  28. void setRect(const RECT *r);
  29. void empty();
  30. int isEmpty();
  31. int equals(const api_region *r);
  32. int enclosed(const api_region *r, api_region *outside = NULL);
  33. int intersectRgn(const api_region *r, api_region *intersection);
  34. int doesIntersectRgn(const api_region *r);
  35. int intersectRect(const RECT *r, api_region *intersection);
  36. int isRect();
  37. void scale(double sx, double sy, bool round = 0);
  38. void debug(int async = 0);
  39. 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
  40. // this is how you can enumerate the subrects that compose to make up the
  41. // entire region
  42. int getNumRects();
  43. int enumRect(int n, RECT *r);
  44. private:
  45. RegionI(HIMutableShapeRef _rgn);
  46. HIMutableShapeRef rgn;
  47. protected:
  48. RECVS_DISPATCH;
  49. };
  50. // TODO: we could take of advantage of HIShapeRef's built in reference counting to implement this
  51. class RegionServer : public Dispatchable {
  52. protected:
  53. RegionServer() {}
  54. virtual ~RegionServer() {}
  55. public:
  56. void addRef(void *client);
  57. void delRef(void *client);
  58. api_region *getRegion();
  59. enum {
  60. REGIONSERVER_ADDREF = 500,
  61. REGIONSERVER_DELREF = 550,
  62. REGIONSERVER_GETREGION = 600,
  63. };
  64. };
  65. inline void RegionServer::addRef(void *client) {
  66. _voidcall(REGIONSERVER_ADDREF, (api_region *)NULL, client);
  67. }
  68. inline void RegionServer::delRef(void *client) {
  69. _voidcall(REGIONSERVER_DELREF, client);
  70. }
  71. inline api_region * RegionServer::getRegion() {
  72. return _call(REGIONSERVER_GETREGION, (api_region *)NULL);
  73. }
  74. class RegionServerI : public RegionServer {
  75. public :
  76. RegionServerI() { numrefs = 0; }
  77. virtual ~RegionServerI() {}
  78. virtual void addRef(void *client) { numrefs++; }
  79. virtual void delRef(void *client) { numrefs--; }
  80. virtual api_region *getRegion()=0;
  81. virtual int getNumRefs() { return numrefs; }
  82. protected:
  83. RECVS_DISPATCH;
  84. private:
  85. int numrefs;
  86. };
  87. #endif