1
0

shadowwnd.cpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. #include "precomp.h"
  2. #include "shadowwnd.h"
  3. #include "../bfc/canvas.h"
  4. #include "../bfc/region.h"
  5. enum { TARGET };
  6. char XuiShadowWndParams[][]=
  7. {
  8. "TARGET",
  9. };
  10. XuiShadowWnd::XuiShadowWnd() {
  11. myxuihandle = newXuiHandle();
  12. addParam(myxuihandle, XuiShadowWndParams[0], TARGET, XUI_ATTRIBUTE_REQUIRED);
  13. group = NULL;
  14. bltcanvas = NULL;
  15. c_w = c_h = 0;
  16. in_paint = 0;
  17. }
  18. XuiShadowWnd::~XuiShadowWnd() {
  19. delete bltcanvas;
  20. }
  21. int XuiShadowWnd::onInit() {
  22. XUISHADOWWND_PARENT::onInit();
  23. DebugString("on iniiit");
  24. attachToGroup();
  25. setTimer(10, 50);
  26. return 1;
  27. }
  28. void XuiShadowWnd::timerclient_timerCallback(int id) {
  29. if (id == 10) {
  30. if (group == NULL) attachToGroup();
  31. delete bltcanvas;
  32. RECT r; group->getClientRect(&r);
  33. bltcanvas = new BltCanvas(r.right - r.left, r.bottom - r.top);
  34. in_paint++;
  35. group->paint(bltcanvas);
  36. MEMFILL<ARGB32>((unsigned long *)bltcanvas->getBits(), 0xffffffff, (r.right - r.left) * 20);
  37. in_paint--;
  38. invalidate();
  39. } else
  40. XUISHADOWWND_PARENT::timerclient_timerCallback(id);
  41. }
  42. int XuiShadowWnd::onPaint(Canvas *canvas) {
  43. #if 0
  44. if (group == NULL) attachToGroup();
  45. if (group == NULL) { DebugString("groupNull"); }
  46. if (group == NULL) return 0;
  47. #endif
  48. DebugString("begin painting");
  49. if (in_paint++) {
  50. // RECT cr = clientRect();
  51. // canvas->fillRect(&cr, RGB(255,0,255));
  52. //MEMFILL<ARGB32>((unsigned long *)canvas->getBits(), 0xffffffff, (cr.right - cr.left) * 20);
  53. DebugString("filla!");
  54. } else {
  55. #if 0
  56. RECT cr;
  57. group->getClientRect(&cr);
  58. SkinBitmap *bm
  59. bltcanvas->blit(0, 0,
  60. BltCanvas c(cr.right - cr.left, cr.bottom - cr.top);
  61. group->paint(&c);
  62. #if 0
  63. c.pushPen(0,255,0);
  64. c.lineDraw(0, 0, cr.right, cr.bottom);
  65. /c.popPen();
  66. #endif
  67. MEMFILL<ARGB32>((unsigned long *)c.getBits(), 0xffffffff, (cr.right - cr.left) * 20);
  68. c.blit(0, 0, canvas, 0, 0, cr.right - cr.left, cr.bottom - cr.top);
  69. DebugString("get from group!");
  70. #endif
  71. if (bltcanvas != NULL) {
  72. SkinBitmap *bm = bltcanvas->getSkinBitmap();
  73. bm->stretchToRectAlpha(canvas, &clientRect(), getPaintingAlpha());
  74. DebugString("bleet!");
  75. }
  76. }
  77. in_paint--;
  78. return 1;
  79. }
  80. int XuiShadowWnd::setXuiParam(int xuihandle, int xmlattributeid, const wchar_t *xmlattributename, const wchar_t *value) {
  81. if (xuihandle != myxuihandle)
  82. return XUISHADOWWND_PARENT::setXuiParam(xuihandle, xmlattributeid, xmlattributename, value);
  83. switch (xmlattributeid) {
  84. case TARGET:
  85. targetname = value;
  86. DebugString("set target %s", value);
  87. if (isPostOnInit()) attachToGroup();
  88. break;
  89. default: return 0;
  90. }
  91. return 1;
  92. }
  93. void XuiShadowWnd::attachToGroup() {
  94. if (targetname.isempty()) return;
  95. group = findWindow(targetname);
  96. if (group == NULL) return;
  97. monitorWindow(group);
  98. DebugString("attached to group rw %d", group);
  99. delete bltcanvas; bltcanvas = NULL;
  100. }
  101. void XuiShadowWnd::onAfterPaint(PaintCallbackInfo *info) {
  102. DebugString("after paint");
  103. #if 0
  104. RECT ncr;
  105. group->getNonClientRect(&ncr);
  106. c_w = ncr.right - ncr.left;
  107. c_h = ncr.bottom - ncr.top;
  108. DebugString("w %d h %d", c_w, c_h);
  109. delete bltcanvas; bltcanvas = NULL;
  110. if (c_w != 0 && c_h != 0) bltcanvas = new BltCanvas(c_w, c_h);
  111. Canvas *c = info->getCanvas();
  112. api_region *r = info->getRegion();
  113. // blit what changed
  114. RegionI saved;
  115. c->getClipRgn(&saved);
  116. bltcanvas->selectClipRgn(r);
  117. c->blit(0, 0, bltcanvas, 0, 0, c_w, c_h);
  118. c->selectClipRgn(&saved);
  119. invalidate();
  120. #endif
  121. }
  122. void XuiShadowWnd::onInvalidation(PaintCallbackInfo *info) {
  123. // invalidate();
  124. DebugString("got invalidate");
  125. }
  126. void XuiShadowWnd::onWindowDeleted(api_window *w) {
  127. if (w == group) group = NULL;
  128. }