Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
7257 leency 1
#define TOIMAGE 1
2
#define TOCANVAS 2
7254 leency 3
 
7257 leency 4
 
7254 leency 5
struct Tool {
6
	int id;
7
	void (*activate)();
8
	void (*deactivate)();
9
	void (*onMouseEvent)(int x, int y, int lkm, int pkm);
10
	void (*onKeyEvent)(dword keycode);
11
	void (*onCanvasDraw)();
12
};
13
 
7257 leency 14
int previousTool = -1;
7254 leency 15
int currentTool = -1;
16
Tool tools[6];
17
 
7257 leency 18
enum {
19
	TOOL_NONE = -1,
20
	TOOL_PENCIL,
21
	TOOL_PIPETTE,
22
	TOOL_FILL,
23
	TOOL_LINE,
24
	TOOL_RECT,
25
	TOOL_SELECT
26
};
27
#include "tools/pencil.h";
28
#include "tools/pipette.h";
29
#include "tools/fill.h";
30
#include "tools/selection.h";
31
#include "tools/simple_figure.h";
7254 leency 32
 
7257 leency 33
 
34
void initTools()
35
{
36
	tools[0].id = TOOL_PENCIL;
37
	tools[0].onMouseEvent = #PencilTool_onMouseEvent;
38
	tools[0].deactivate = #PencilTool_reset;
39
 
40
	tools[1].id = TOOL_PIPETTE;
41
	tools[1].activate = #PipetteTool_activate;
42
	tools[1].onMouseEvent = #PipetteTool_onMouseEvent;
43
 
44
	tools[2].id = TOOL_FILL;
45
	tools[2].onMouseEvent = #FillTool_onMouseEvent;
46
 
47
	tools[3].id = TOOL_LINE;
48
	tools[3].activate = #SimpleFigureTool_Reset;
49
	tools[3].deactivate = #SimpleFigureTool_Reset;
50
	tools[3].onMouseEvent = #SimpleFigureTool_onMouseEvent;
51
	tools[3].onCanvasDraw = #SimpleFigureTool_onCanvasDraw;
52
 
53
	tools[4].id = TOOL_RECT;
54
	tools[4].activate = #SimpleFigureTool_Reset;
55
	tools[4].deactivate = #SimpleFigureTool_Reset;
56
	tools[4].onMouseEvent = #SimpleFigureTool_onMouseEvent;
57
	tools[4].onCanvasDraw = #SimpleFigureTool_onCanvasDraw;
58
 
59
	tools[5].id = TOOL_SELECT;
60
	tools[5].activate = #SelectTool_activate;
61
	tools[5].deactivate = #SelectTool_deactivate;
62
	tools[5].onMouseEvent = #SelectTool_onMouseEvent;
63
	tools[5].onCanvasDraw = #SelectTool_onCanvasDraw;
64
	tools[5].onKeyEvent = #SelectTool_onKeyEvent;
65
}
66
 
67
 
7254 leency 68
void resetCurrentTool() {
69
	if ((currentTool != TOOL_NONE) && (tools[currentTool].deactivate != 0)) {
70
		tools[currentTool].deactivate();
71
	}
72
	currentTool = TOOL_NONE;
73
}
74
 
75
void setCurrentTool(int index) {
7257 leency 76
	previousTool = currentTool;
7254 leency 77
	resetCurrentTool();
78
 
79
	currentTool = index;
80
 
81
	if ((index != TOOL_NONE) && (tools[index].activate != 0))
82
		tools[index].activate();
83
 
84
	DrawLeftPanel();
85
	DrawCanvas();
86
}
87
 
88
//===================================================//
89
//                                                   //
90
//                    FUNTIONS                       //
91
//                                                   //
92
//===================================================//
93