Subversion Repositories Kolibri OS

Rev

Rev 7444 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
7260 leency 1
dword screen_copy;
2
 
3
void ScreenCopy_activate() {
4
	SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE);
7275 leency 5
	screen_copy = malloc(image.columns * image.rows * 3 +4);
7260 leency 6
}
7
 
8
void ScreenCopy_onMouseEvent(int mouseX, int mouseY, int lkm, int pkm) {
9
	dword i;
7271 leency 10
	int x, y;
11
 
12
	x = mouse.x + Form.left + 5 - calc(image.columns/2);
13
	y = mouse.y + Form.top + skin_height - calc(image.rows/2);
14
 
15
	CopyScreen(
16
		screen_copy,
17
		math.in(x, 0, screen.width - image.columns),
18
		math.in(y, 0, screen.height - image.rows),
19
		image.columns,
20
		image.rows
21
	);
22
 
7260 leency 23
	for (i = 0; i < image.columns*image.rows; i++;)
24
	{
7506 leency 25
		image.mas[i] = ESDWORD[i*3+screen_copy]; // & 0xFFFFFF;
7260 leency 26
	}
27
	DrawCanvas();
28
 
29
	if (mouse.down) {
7444 leency 30
		ScreenCopy_onKeyEvent(SCAN_CODE_ENTER);
31
	}
32
}
33
 
34
void ScreenCopy_onKeyEvent(dword keycode) {
35
	if (SCAN_CODE_ENTER == keycode) {
36
		actionsHistory.saveCurrentState();
7260 leency 37
		screen_copy = free(screen_copy);
38
		SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER);
39
		setCurrentTool(previousTool);
7266 leency 40
		if (!CheckActiveProcess(Form.ID)) ActivateWindow(GetProcessSlot(Form.ID));
7260 leency 41
	}
7444 leency 42
	if (SCAN_CODE_ESC == keycode) {
43
		ScreenCopy_onKeyEvent(SCAN_CODE_ENTER);
44
		actionsHistory.undoLastAction();
45
	}
7260 leency 46
}