1
0

region.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. #ifndef __REGION_H
  2. #define __REGION_H
  3. #include <tataki/bitmap/bitmap.h>
  4. #include <bfc/dispatch.h>
  5. #include <tataki/export.h>
  6. class BaseWnd;
  7. class Canvas;
  8. class api_region;
  9. class RegionServer;
  10. #include <tataki/region/api_region.h>
  11. class TATAKIAPI RegionI : public api_region
  12. {
  13. public:
  14. RegionI();
  15. RegionI(const RegionI *copy);
  16. RegionI(const RECT *r);
  17. RegionI(int l, int t, int r, int b);
  18. RegionI(OSREGIONHANDLE region);
  19. RegionI(SkinBitmap *bitmap, RECT *r=NULL, int xoffset=0, int yoffset=0, bool inverted=false, int dothreshold=0, __int8 threshold=0, int threversed=0, int minalpha=1);
  20. RegionI(Canvas *c, RECT *defboundbox=NULL);
  21. virtual ~RegionI();
  22. api_region *clone();
  23. void disposeClone(api_region *r);
  24. bool ptInRegion(const POINT *pt);
  25. void offset(int x, int y);
  26. void getBox(RECT *r);
  27. void subtractRegion(const api_region *reg);
  28. void subtractRect(const RECT *r);
  29. void addRect(const RECT *r);
  30. void addRegion(const api_region *r);
  31. void andRegion(const api_region *r);
  32. void setRect(const RECT *r);
  33. void empty();
  34. int isEmpty();
  35. int equals(const api_region *r);
  36. int enclosed(const api_region *r, api_region *outside=NULL);
  37. int intersectRgn(const api_region *r, api_region *intersection);
  38. int doesIntersectRgn(const api_region *r);
  39. int intersectRect(const RECT *r, api_region *intersection);
  40. int doesIntersectRect(const RECT *r);
  41. int isRect();
  42. void scale(double sx, double sy, bool round=0);
  43. void debug(int async=0);
  44. // NONPORTABLE
  45. 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
  46. OSREGIONHANDLE getOSHandle(); // avoid as much as you can, should be used only by WIN32-dependant classes
  47. // END NONPORTABLE
  48. int getNumRects();
  49. int enumRect(int n, RECT *r);
  50. OSREGIONHANDLE alphaToRegionRect(void *pbits32, int bmX, int bmY, int bmWidth, int bmHeight, int fullw, int fullh, int xoffset, int yoffset, bool portion, int _x, int _y, int _w, int _h, bool inverted, int dothreshold, unsigned __int8 threshold, int thinverse, int minalpha);
  51. private:
  52. inline void init();
  53. void optimize();
  54. void deoptimize();
  55. OSREGIONHANDLE hrgn;
  56. OSREGIONHANDLE alphaToRegionRect(SkinBitmap *bitmap, int xoffset, int yoffset, bool portion, int _x, int _y, int _w, int _h, bool inverted=false, int dothreshold=0, unsigned __int8 threshold=0, int thinverse=0, int minalpha=1/* 1..255*/);
  57. RECT overlay;
  58. int clonecount;
  59. RegionI *lastdebug;
  60. RegionServer *srv;
  61. RECT optrect;
  62. int optimized;
  63. protected:
  64. RECVS_DISPATCH;
  65. };
  66. class RegionServer : public Dispatchable {
  67. protected:
  68. RegionServer() {}
  69. virtual ~RegionServer() {}
  70. public:
  71. void addRef(void *client);
  72. void delRef(void *client);
  73. api_region *getRegion();
  74. enum {
  75. REGIONSERVER_ADDREF = 500,
  76. REGIONSERVER_DELREF = 550,
  77. REGIONSERVER_GETREGION = 600,
  78. };
  79. };
  80. inline void RegionServer::addRef(void *client) {
  81. _voidcall(REGIONSERVER_ADDREF, (api_region *)NULL, client);
  82. }
  83. inline void RegionServer::delRef(void *client) {
  84. _voidcall(REGIONSERVER_DELREF, client);
  85. }
  86. inline api_region * RegionServer::getRegion() {
  87. return _call(REGIONSERVER_GETREGION, (api_region *)NULL);
  88. }
  89. class TATAKIAPI RegionServerI : public RegionServer
  90. {
  91. public :
  92. RegionServerI() { numrefs = 0; }
  93. virtual ~RegionServerI() {}
  94. virtual void addRef(void *client) { numrefs++; }
  95. virtual void delRef(void *client) { numrefs--; }
  96. virtual api_region *getRegion()=0;
  97. virtual int getNumRefs() { return numrefs; }
  98. protected:
  99. RECVS_DISPATCH;
  100. private:
  101. int numrefs;
  102. };
  103. #endif