region.h 2.7 KB

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