aboutsummaryrefslogtreecommitdiff
path: root/Src/Wasabi/api/imgldr/imggen/shadowwnd.cpp
blob: fb61c95ce6eaab3cf1c02394307ec23c6472146a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#include "precomp.h"

#include "shadowwnd.h"

#include "../bfc/canvas.h"
#include "../bfc/region.h"

enum { TARGET };

char XuiShadowWndParams[][]=
{
	"TARGET",
};
XuiShadowWnd::XuiShadowWnd() {
  myxuihandle = newXuiHandle();
  addParam(myxuihandle, XuiShadowWndParams[0], TARGET, XUI_ATTRIBUTE_REQUIRED);
  group = NULL;
  bltcanvas = NULL;
  c_w = c_h = 0;
  in_paint = 0;
}

XuiShadowWnd::~XuiShadowWnd() {
  delete bltcanvas;
}

int XuiShadowWnd::onInit() {
  XUISHADOWWND_PARENT::onInit();

DebugString("on iniiit");

  attachToGroup();
setTimer(10, 50);

  return 1;
}

void XuiShadowWnd::timerclient_timerCallback(int id) {
  if (id == 10) {
    if (group == NULL) attachToGroup();
    delete bltcanvas;
    RECT r; group->getClientRect(&r);
    bltcanvas = new BltCanvas(r.right - r.left, r.bottom - r.top);
    in_paint++;
    group->paint(bltcanvas);
MEMFILL<ARGB32>((unsigned long *)bltcanvas->getBits(), 0xffffffff, (r.right - r.left) * 20);
    in_paint--;
    invalidate();
  } else
    XUISHADOWWND_PARENT::timerclient_timerCallback(id);
}

int XuiShadowWnd::onPaint(Canvas *canvas) {
#if 0
if (group == NULL) attachToGroup();
if (group == NULL) { DebugString("groupNull"); }
if (group == NULL) return 0;

#endif
DebugString("begin painting");

if (in_paint++) {
//    RECT cr = clientRect();
//    canvas->fillRect(&cr, RGB(255,0,255));
//MEMFILL<ARGB32>((unsigned long *)canvas->getBits(), 0xffffffff, (cr.right - cr.left) * 20);
DebugString("filla!");
} else {
#if 0
    RECT cr;
    group->getClientRect(&cr);
    SkinBitmap *bm
bltcanvas->blit(0, 0, 
BltCanvas c(cr.right - cr.left, cr.bottom - cr.top);
group->paint(&c);
#if 0
c.pushPen(0,255,0);
c.lineDraw(0, 0, cr.right, cr.bottom);
/c.popPen();
#endif
MEMFILL<ARGB32>((unsigned long *)c.getBits(), 0xffffffff, (cr.right - cr.left) * 20);
c.blit(0, 0, canvas, 0, 0, cr.right - cr.left, cr.bottom - cr.top);

DebugString("get from group!");
#endif
  if (bltcanvas != NULL) {
    SkinBitmap *bm = bltcanvas->getSkinBitmap();
    bm->stretchToRectAlpha(canvas, &clientRect(), getPaintingAlpha());
DebugString("bleet!");
  }
}
in_paint--;
  return 1;
}

int XuiShadowWnd::setXuiParam(int xuihandle, int xmlattributeid, const wchar_t *xmlattributename, const wchar_t *value) {
  if (xuihandle != myxuihandle)
    return XUISHADOWWND_PARENT::setXuiParam(xuihandle, xmlattributeid, xmlattributename, value);
  switch (xmlattributeid) {
    case TARGET:
      targetname = value;
DebugString("set target %s", value);
      if (isPostOnInit()) attachToGroup();
    break;
    default: return 0;
  }
  return 1;
}

void XuiShadowWnd::attachToGroup() {
  if (targetname.isempty()) return;
  group = findWindow(targetname);
  if (group == NULL) return;
  monitorWindow(group);
DebugString("attached to group rw %d", group);

  delete bltcanvas; bltcanvas = NULL;
}

void XuiShadowWnd::onAfterPaint(PaintCallbackInfo *info) {
DebugString("after paint");
#if 0
  RECT ncr;
  group->getNonClientRect(&ncr);
  c_w = ncr.right - ncr.left;
  c_h = ncr.bottom - ncr.top;

DebugString("w %d h %d", c_w, c_h);

  delete bltcanvas; bltcanvas = NULL;
  if (c_w != 0 && c_h != 0) bltcanvas = new BltCanvas(c_w, c_h);

  Canvas *c = info->getCanvas();
  api_region *r = info->getRegion();
  // blit what changed
  RegionI saved;
  c->getClipRgn(&saved);
  bltcanvas->selectClipRgn(r);
  c->blit(0, 0, bltcanvas, 0, 0, c_w, c_h);
  c->selectClipRgn(&saved);

  invalidate();
#endif
}

void XuiShadowWnd::onInvalidation(PaintCallbackInfo *info) {
//  invalidate();
DebugString("got invalidate");
}

void XuiShadowWnd::onWindowDeleted(api_window *w) {
  if (w == group) group = NULL;
}