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