Subversion Repositories Kolibri OS

Rev

Rev 7521 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7521 Rev 7977
1
#define TOIMAGE 1
1
#define TOIMAGE 1
2
#define TOCANVAS 2
2
#define TOCANVAS 2
3
 
3
 
4
 
4
 
5
struct Tool {
5
struct TOOL {
6
	int id;
6
	int id;
7
	dword cursor;
7
	dword cursor;
8
	void (*activate)();
8
	void (*activate)();
9
	void (*deactivate)();
9
	void (*deactivate)();
10
	void (*onMouseEvent)(int x, int y, int lkm, int pkm);
10
	void (*onMouseEvent)(int x, int y, int lkm, int pkm);
11
	void (*onKeyEvent)(dword keycode);
11
	void (*onKeyEvent)(dword keycode);
12
	void (*onCanvasDraw)();
12
	void (*onCanvasDraw)();
13
};
13
} tools[8];
14
 
14
 
15
int previousTool = -1;
15
int previousTool = -1;
16
int currentTool = -1;
16
int currentTool = -1;
17
Tool tools[8];
-
 
18
 
17
 
19
enum {
18
enum {
20
	TOOL_NONE = -1,
19
	TOOL_NONE = -1,
21
	TOOL_PENCIL,
20
	TOOL_PENCIL,
22
	TOOL_PIPETTE,
21
	TOOL_PIPETTE,
23
	TOOL_FILL,
22
	TOOL_FILL,
24
	TOOL_LINE,
23
	TOOL_LINE,
25
	TOOL_RECT,
24
	TOOL_RECT,
26
	TOOL_BAR,
25
	TOOL_BAR,
27
	TOOL_SELECT,
26
	TOOL_SELECT,
28
	TOOL_SCREEN_COPY
27
	TOOL_SCREEN_COPY
29
};
28
};
30
#include "tools/pencil.h";
29
#include "tools/pencil.h";
31
#include "tools/pipette.h";
30
#include "tools/pipette.h";
32
#include "tools/fill.h";
31
#include "tools/fill.h";
33
#include "tools/simple_figure.h";
32
#include "tools/simple_figure.h";
34
#include "tools/selection.h";
33
#include "tools/selection.h";
35
#include "tools/screen_copy.h";
34
#include "tools/screen_copy.h";
36
 
35
 
37
 
36
 
38
void initTools() 
37
void initTools() 
39
{
38
{
40
	tools[TOOL_PENCIL].id = TOOL_PENCIL;
39
	tools[TOOL_PENCIL].id = TOOL_PENCIL;
41
	tools[TOOL_PENCIL].cursor = #CursorPencil;
40
	tools[TOOL_PENCIL].cursor = #CursorPencil;
42
	tools[TOOL_PENCIL].onMouseEvent = #PencilTool_onMouseEvent;
41
	tools[TOOL_PENCIL].onMouseEvent = #PencilTool_onMouseEvent;
43
	tools[TOOL_PENCIL].deactivate = #PencilTool_reset;
42
	tools[TOOL_PENCIL].deactivate = #PencilTool_reset;
44
	
43
	
45
	tools[TOOL_PIPETTE].id = TOOL_PIPETTE;
44
	tools[TOOL_PIPETTE].id = TOOL_PIPETTE;
46
	tools[TOOL_PIPETTE].cursor = #CursorPipette;
45
	tools[TOOL_PIPETTE].cursor = #CursorPipette;
47
	tools[TOOL_PIPETTE].activate = #PipetteTool_activate;
46
	tools[TOOL_PIPETTE].activate = #PipetteTool_activate;
48
	tools[TOOL_PIPETTE].onMouseEvent = #PipetteTool_onMouseEvent;
47
	tools[TOOL_PIPETTE].onMouseEvent = #PipetteTool_onMouseEvent;
49
	tools[TOOL_PIPETTE].onKeyEvent = #PipetteTool_onKeyEvent;
48
	tools[TOOL_PIPETTE].onKeyEvent = #PipetteTool_onKeyEvent;
50
	
49
	
51
	tools[TOOL_FILL].id = TOOL_FILL;
50
	tools[TOOL_FILL].id = TOOL_FILL;
52
	tools[TOOL_FILL].cursor = #CursorFill;
51
	tools[TOOL_FILL].cursor = #CursorFill;
53
	tools[TOOL_FILL].onMouseEvent = #FillTool_onMouseEvent;
52
	tools[TOOL_FILL].onMouseEvent = #FillTool_onMouseEvent;
54
	
53
	
55
	tools[TOOL_LINE].id = TOOL_LINE;
54
	tools[TOOL_LINE].id = TOOL_LINE;
56
	tools[TOOL_LINE].cursor = #CursorLine;
55
	tools[TOOL_LINE].cursor = #CursorLine;
57
	tools[TOOL_LINE].activate = #SimpleFigureTool_Reset;
56
	tools[TOOL_LINE].activate = #SimpleFigureTool_Reset;
58
	tools[TOOL_LINE].deactivate = #SimpleFigureTool_Reset;
57
	tools[TOOL_LINE].deactivate = #SimpleFigureTool_Reset;
59
	tools[TOOL_LINE].onMouseEvent = #SimpleFigureTool_onMouseEvent;
58
	tools[TOOL_LINE].onMouseEvent = #SimpleFigureTool_onMouseEvent;
60
	tools[TOOL_LINE].onCanvasDraw = #SimpleFigureTool_onCanvasDraw;
59
	tools[TOOL_LINE].onCanvasDraw = #SimpleFigureTool_onCanvasDraw;
61
	
60
	
62
	tools[TOOL_RECT].id = TOOL_RECT;
61
	tools[TOOL_RECT].id = TOOL_RECT;
63
	tools[TOOL_RECT].cursor = #CursorRectangle;
62
	tools[TOOL_RECT].cursor = #CursorRectangle;
64
	tools[TOOL_RECT].activate = #SimpleFigureTool_Reset;
63
	tools[TOOL_RECT].activate = #SimpleFigureTool_Reset;
65
	tools[TOOL_RECT].deactivate = #SimpleFigureTool_Reset;
64
	tools[TOOL_RECT].deactivate = #SimpleFigureTool_Reset;
66
	tools[TOOL_RECT].onMouseEvent = #SimpleFigureTool_onMouseEvent;
65
	tools[TOOL_RECT].onMouseEvent = #SimpleFigureTool_onMouseEvent;
67
	tools[TOOL_RECT].onCanvasDraw = #SimpleFigureTool_onCanvasDraw;	
66
	tools[TOOL_RECT].onCanvasDraw = #SimpleFigureTool_onCanvasDraw;	
68
 
67
 
69
	tools[TOOL_BAR].id = TOOL_BAR;
68
	tools[TOOL_BAR].id = TOOL_BAR;
70
	tools[TOOL_BAR].cursor = #CursorBar;
69
	tools[TOOL_BAR].cursor = #CursorBar;
71
	tools[TOOL_BAR].activate = #SimpleFigureTool_Reset;
70
	tools[TOOL_BAR].activate = #SimpleFigureTool_Reset;
72
	tools[TOOL_BAR].deactivate = #SimpleFigureTool_Reset;
71
	tools[TOOL_BAR].deactivate = #SimpleFigureTool_Reset;
73
	tools[TOOL_BAR].onMouseEvent = #SimpleFigureTool_onMouseEvent;
72
	tools[TOOL_BAR].onMouseEvent = #SimpleFigureTool_onMouseEvent;
74
	tools[TOOL_BAR].onCanvasDraw = #SimpleFigureTool_onCanvasDraw;	
73
	tools[TOOL_BAR].onCanvasDraw = #SimpleFigureTool_onCanvasDraw;	
75
 
74
 
76
	tools[TOOL_SELECT].id = TOOL_SELECT;
75
	tools[TOOL_SELECT].id = TOOL_SELECT;
77
	tools[TOOL_SELECT].cursor = #CursorSelect;
76
	tools[TOOL_SELECT].cursor = #CursorSelect;
78
	tools[TOOL_SELECT].activate = #SelectTool_activate;
77
	tools[TOOL_SELECT].activate = #SelectTool_activate;
79
	tools[TOOL_SELECT].deactivate = #SelectTool_deactivate;
78
	tools[TOOL_SELECT].deactivate = #SelectTool_deactivate;
80
	tools[TOOL_SELECT].onMouseEvent = #SelectTool_onMouseEvent;
79
	tools[TOOL_SELECT].onMouseEvent = #SelectTool_onMouseEvent;
81
	tools[TOOL_SELECT].onCanvasDraw = #SelectTool_onCanvasDraw;	
80
	tools[TOOL_SELECT].onCanvasDraw = #SelectTool_onCanvasDraw;	
82
	tools[TOOL_SELECT].onKeyEvent = #SelectTool_onKeyEvent;	
81
	tools[TOOL_SELECT].onKeyEvent = #SelectTool_onKeyEvent;	
83
 
82
 
84
	tools[TOOL_SCREEN_COPY].id = TOOL_SCREEN_COPY;
83
	tools[TOOL_SCREEN_COPY].id = TOOL_SCREEN_COPY;
85
	tools[TOOL_SCREEN_COPY].cursor = NULL;
84
	tools[TOOL_SCREEN_COPY].cursor = NULL;
86
	tools[TOOL_SCREEN_COPY].activate = #ScreenCopy_activate;
85
	tools[TOOL_SCREEN_COPY].activate = #ScreenCopy_activate;
87
	tools[TOOL_SCREEN_COPY].onMouseEvent = #ScreenCopy_onMouseEvent;
86
	tools[TOOL_SCREEN_COPY].onMouseEvent = #ScreenCopy_onMouseEvent;
88
	tools[TOOL_SCREEN_COPY].onKeyEvent = #ScreenCopy_onKeyEvent;	
87
	tools[TOOL_SCREEN_COPY].onKeyEvent = #ScreenCopy_onKeyEvent;	
89
}
88
}
90
 
89
 
91
 
90
 
92
void resetCurrentTool() {
91
void resetCurrentTool() {
93
	if ((currentTool != TOOL_NONE) && (tools[currentTool].deactivate != 0)) {
92
	if ((currentTool != TOOL_NONE) && (tools[currentTool].deactivate != 0)) {
94
		tools[currentTool].deactivate();
93
		tools[currentTool].deactivate();
95
	}
94
	}
96
	currentTool = TOOL_NONE;
95
	currentTool = TOOL_NONE;
97
}
96
}
98
 
97
 
99
void setCurrentTool(int index) {
98
void setCurrentTool(int index) {
100
	previousTool = currentTool;
99
	previousTool = currentTool;
101
	resetCurrentTool();
100
	resetCurrentTool();
102
 
101
 
103
	currentTool = index;
102
	currentTool = index;
104
	
103
	
105
	if ((index != TOOL_NONE) && (tools[index].activate != 0))
104
	if ((index != TOOL_NONE) && (tools[index].activate != 0))
106
		tools[index].activate();
105
		tools[index].activate();
107
 
106
 
108
	Cursor.Restore();
107
	Cursor.Restore();
109
	if (wrapper.hovered()) SetCursor();
108
	if (wrapper.hovered()) SetCursor();
110
	DrawCanvas();
109
	DrawCanvas();
-
 
110
	DrawLeftPanelSelection();
111
}
111
}
112
 
112
 
113
void SetCursor()
113
void SetCursor()
114
{
114
{
115
	if (tools[currentTool].cursor) && (!Cursor.CursorPointer) {
115
	if (tools[currentTool].cursor) && (!Cursor.CursorPointer) {
116
		Cursor.Load(tools[currentTool].cursor);
116
		Cursor.Load(tools[currentTool].cursor);
117
		Cursor.Set();
117
		Cursor.Set();
118
	}
118
	}
119
}
119
}