Subversion Repositories Kolibri OS

Rev

Rev 8256 | Rev 8389 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8256 Rev 8381
1
/*
1
/*
2
 * Icon Editor for KolibriOS
2
 * Icon Editor for KolibriOS
3
 * Authors: Leency, Nicolas
3
 * Authors: Leency, Nicolas
4
 * Licence: GPL v2
4
 * Licence: GPL v2
5
*/
5
*/
6
 
6
 
7
#define MEMSIZE 1024*2000
7
#define MEMSIZE 1024*2000
8
 
8
 
9
#include "../lib/gui.h"
9
#include "../lib/gui.h"
10
#include "../lib/random.h"
10
#include "../lib/random.h"
11
#include "../lib/mem.h"
11
#include "../lib/mem.h"
12
#include "../lib/cursor.h"
12
#include "../lib/cursor.h"
13
#include "../lib/list_box.h"
13
#include "../lib/list_box.h"
14
#include "../lib/events.h"
14
#include "../lib/events.h"
-
 
15
 
15
 
16
#include "../lib/obj/libio.h"
16
#include "../lib/obj/libimg.h"
17
#include "../lib/obj/libimg.h"
17
#include "../lib/obj/box_lib.h"
18
#include "../lib/obj/box_lib.h"
18
 
19
 
19
#include "../lib/patterns/rgb.h"
20
#include "../lib/patterns/rgb.h"
20
 
21
 
21
#include "colors_mas.h"
22
#include "colors_mas.h"
22
 
23
 
23
#ifndef AUTOBUILD
24
#ifndef AUTOBUILD
24
#include "lang.h--"
25
#include "lang.h--"
25
#endif
26
#endif
26
 
27
 
27
//===================================================//
28
//===================================================//
28
//                                                   //
29
//                                                   //
29
//                       DATA                        //
30
//                       DATA                        //
30
//                                                   //
31
//                                                   //
31
//===================================================//
32
//===================================================//
32
 
33
 
33
#ifdef LANG_RUS
34
#ifdef LANG_RUS
34
char edit_menu_items[] = 
35
char edit_menu_items[] = 
35
"‚ë१ âì|Ctrl+X
36
"‚ë१ âì|Ctrl+X
36
Š®¯¨à®¢ âì|Ctrl+C
37
Š®¯¨à®¢ âì|Ctrl+C
37
‚áâ ¢¨âì|Ctrl+V";
38
‚áâ ¢¨âì|Ctrl+V";
38
char image_menu_items[] = 
39
char image_menu_items[] = 
39
"Š®«¨ç¥á⢮ ¨á¯®«ì§®¢ ­­ëå 梥⮢
40
"Š®«¨ç¥á⢮ ¨á¯®«ì§®¢ ­­ëå 梥⮢
40
‡ ¬¥­¨âì ¢á¥ æ¢¥â  1 ­  2";
41
‡ ¬¥­¨âì ¢á¥ æ¢¥â  1 ­  2";
41
?define T_MENU_IMAGE "ˆª®­ª "
42
?define T_MENU_IMAGE "ˆª®­ª "
42
?define T_TEST_ICON "à®¢¥à¨âì ¨ª®­ªã"
43
?define T_TEST_ICON "à®¢¥à¨âì ¨ª®­ªã"
43
?define T_TITLE "¥¤ ªâ®à ¨ª®­®ª 0.70a Beta"
44
?define T_TITLE "¥¤ ªâ®à ¨ª®­®ª 0.70a Beta"
44
?define T_UNIC_COLORS_COUNT "'“­¨ª «ì­ëå 梥⮢: %i.' -I"
45
?define T_UNIC_COLORS_COUNT "'“­¨ª «ì­ëå 梥⮢: %i.' -I"
45
?define T_TOO_BIG_IMAGE_FOR_PREVIEW "'IconEdit
46
?define T_TOO_BIG_IMAGE_FOR_PREVIEW "'IconEdit
46
ˆ§®¡à ¦¥­¨¥ ᫨誮¬ ¡®«ì讥 ¤«ï ¯à¥¤¯à®á¬®âà !' -tE"
47
ˆ§®¡à ¦¥­¨¥ ᫨誮¬ ¡®«ì讥 ¤«ï ¯à¥¤¯à®á¬®âà !' -tE"
47
?define T_ERROR_CROP_TOOL "'„«ï ®¡à¥§ª¨ ¨§®¡à ¦¥­¨ï ¢­ ç «¥ ­ã¦­® ¢ë¤¥«¨âì ®¡« áâì.' -W"
48
?define T_ERROR_CROP_TOOL "'„«ï ®¡à¥§ª¨ ¨§®¡à ¦¥­¨ï ¢­ ç «¥ ­ã¦­® ¢ë¤¥«¨âì ®¡« áâì.' -W"
48
?define T_ERROR_IMA_ICONEDIT "'â® ¯à®á⮠। ªâ®à ¨ª®­®ª, ¢ë¡à ­®¥
49
?define T_ERROR_IMA_ICONEDIT "'â® ¯à®á⮠। ªâ®à ¨ª®­®ª, ¢ë¡à ­®¥
49
¨§®¡à ¦¥­¨¥ ᫨誮¬ ¢¥«¨ª® ¤«ï ­¥£®!' -E"
50
¨§®¡à ¦¥­¨¥ ᫨誮¬ ¢¥«¨ª® ¤«ï ­¥£®!' -E"
50
#else
51
#else
51
char edit_menu_items[] = 
52
char edit_menu_items[] = 
52
"Cut|Ctrl+X
53
"Cut|Ctrl+X
53
Copy|Ctrl+C
54
Copy|Ctrl+C
54
Paste|Ctrl+V";
55
Paste|Ctrl+V";
55
char image_menu_items[] = 
56
char image_menu_items[] = 
56
"Count colors used
57
"Count colors used
57
Replace all colors equal to 1 by 2";
58
Replace all colors equal to 1 by 2";
58
?define T_MENU_IMAGE "Icon"
59
?define T_MENU_IMAGE "Icon"
59
?define T_TEST_ICON "Test Icon"
60
?define T_TEST_ICON "Test Icon"
60
?define T_TITLE "Icon Editor 0.70 Beta"
61
?define T_TITLE "Icon Editor 0.70 Beta"
61
?define T_UNIC_COLORS_COUNT "'Image has %i unique colors.' -I"
62
?define T_UNIC_COLORS_COUNT "'Image has %i unique colors.' -I"
62
?define T_TOO_BIG_IMAGE_FOR_PREVIEW "'IconEdit
63
?define T_TOO_BIG_IMAGE_FOR_PREVIEW "'IconEdit
63
Image is too big for preview!' -tE"
64
Image is too big for preview!' -tE"
64
?define T_ERROR_CROP_TOOL "'You need to select something before using crop tool.' -W"
65
?define T_ERROR_CROP_TOOL "'You need to select something before using crop tool.' -W"
65
?define T_ERROR_IMA_ICONEDIT "'Hey, this is just an icon editor,
66
?define T_ERROR_IMA_ICONEDIT "'Hey, this is just an icon editor,
66
selected image is too big to open!' -E"
67
selected image is too big to open!' -E"
67
#endif
68
#endif
68
 
69
 
69
 
70
 
70
 
71
 
71
#define TOPBAR_H    24+8
72
#define TOPBAR_H    24+8
72
#define LEFTBAR_W 16+5+5+3+3
73
#define LEFTBAR_W 16+5+5+3+3
73
#define PALLETE_SIZE 116
74
#define PALLETE_SIZE 116
74
 
75
 
75
#define PAL_ITEMS_X_COUNT 13
76
#define PAL_ITEMS_X_COUNT 13
76
#define COLSIZE 18
77
#define COLSIZE 18
77
#define RIGHT_BAR_W PAL_ITEMS_X_COUNT*COLSIZE
78
#define RIGHT_BAR_W PAL_ITEMS_X_COUNT*COLSIZE
78
 
79
 
79
#define TO_CANVAS_X(xval) xval - canvas.x/zoom.value
80
#define TO_CANVAS_X(xval) xval - canvas.x/zoom.value
80
#define TO_CANVAS_Y(yval) yval - canvas.y/zoom.value
81
#define TO_CANVAS_Y(yval) yval - canvas.y/zoom.value
81
 
82
 
82
block canvas = { NULL, NULL, NULL, NULL };
83
block canvas = { NULL, NULL, NULL, NULL };
83
block wrapper = { LEFTBAR_W, TOPBAR_H, NULL, NULL };
84
block wrapper = { LEFTBAR_W, TOPBAR_H, NULL, NULL };
84
block right_bar = { NULL, 10+TOPBAR_H, RIGHT_BAR_W+10, NULL };
85
block right_bar = { NULL, 10+TOPBAR_H, RIGHT_BAR_W+10, NULL };
85
block image_menu_btn = { NULL, 4, NULL, 22 };
86
block image_menu_btn = { NULL, 4, NULL, 22 };
86
 
87
 
87
dword linear_gradient[RIGHT_BAR_W];
88
dword linear_gradient[RIGHT_BAR_W];
88
block b_color_gradient = {NULL, 40+TOPBAR_H, RIGHT_BAR_W, 25};
89
block b_color_gradient = {NULL, 40+TOPBAR_H, RIGHT_BAR_W, 25};
89
//block b_opacity_gradient = {NULL, 75+TOPBAR_H, RIGHT_BAR_W, 15};
90
//block b_opacity_gradient = {NULL, 75+TOPBAR_H, RIGHT_BAR_W, 15};
90
block b_last_colors = {NULL, 75+TOPBAR_H, RIGHT_BAR_W, COLSIZE};
91
block b_last_colors = {NULL, 75+TOPBAR_H, RIGHT_BAR_W, COLSIZE};
91
block b_default_palette = {NULL, COLSIZE+10+75+TOPBAR_H, RIGHT_BAR_W, COLSIZE*9};
92
block b_default_palette = {NULL, COLSIZE+10+75+TOPBAR_H, RIGHT_BAR_W, COLSIZE*9};
92
 
93
 
93
dword transparent = 0xBFCAD2;
94
dword transparent = 0xBFCAD2;
94
dword color1 = 0x000000;
95
dword color1 = 0x000000;
95
dword color2 = 0xBFCAD2;
96
dword color2 = 0xBFCAD2;
96
dword tool_color;
97
dword tool_color;
97
 
98
 
98
signed hoverX;
99
signed hoverX;
99
signed hoverY;
100
signed hoverY;
100
signed priorHoverX;
101
signed priorHoverX;
101
signed priorHoverY;
102
signed priorHoverY;
102
bool canvasMouseMoved = false;
103
bool canvasMouseMoved = false;
103
 
104
 
104
EVENTS button;
105
EVENTS button;
105
EVENTS key;
106
EVENTS key;
106
 
107
 
107
enum {
108
enum {
108
	BTNS_PALETTE_COLOR_MAS = 100,
109
	BTNS_PALETTE_COLOR_MAS = 100,
109
	BTNS_LAST_USED_COLORS = 400
110
	BTNS_LAST_USED_COLORS = 400
110
};
111
};
111
 
112
 
112
proc_info Form;
113
proc_info Form;
113
dword semi_white;
114
dword semi_white;
114
bool bg_dark=false;
115
bool bg_dark=false;
115
 
116
 
116
more_less_box zoom = { 11, 1, 40, "Zoom" };
117
more_less_box zoom = { 11, 1, 40, "Zoom" };
117
 
118
 
118
dword default_palette[] = {
119
dword default_palette[] = {
119
0x330000,0x331900,0x333300,0x193300,0x003300,0x003319,0x003333,0x001933,0x000033,0x190033,
120
0x330000,0x331900,0x333300,0x193300,0x003300,0x003319,0x003333,0x001933,0x000033,0x190033,
120
0x330033,0x330019,0x000000,0x660000,0x663300,0x666600,0x336600,0x006600,0x006633,0x006666,
121
0x330033,0x330019,0x000000,0x660000,0x663300,0x666600,0x336600,0x006600,0x006633,0x006666,
121
0x003366,0x000066,0x330066,0x660066,0x660033,0x202020,0x990000,0x994C00,0x999900,0x4C9900,
122
0x003366,0x000066,0x330066,0x660066,0x660033,0x202020,0x990000,0x994C00,0x999900,0x4C9900,
122
0x009900,0x00994C,0x009999,0x004C99,0x000099,0x4C0099,0x990099,0x99004C,0x404040,0xCC0000,
123
0x009900,0x00994C,0x009999,0x004C99,0x000099,0x4C0099,0x990099,0x99004C,0x404040,0xCC0000,
123
0xCC6600,0xCCCC00,0x66CC00,0x00CC00,0x00CC66,0x00CCCC,0x0066CC,0x0000CC,0x6600CC,0xCC00CC,
124
0xCC6600,0xCCCC00,0x66CC00,0x00CC00,0x00CC66,0x00CCCC,0x0066CC,0x0000CC,0x6600CC,0xCC00CC,
124
0xCC0066,0x606060,0xFF0000,0xFF8000,0xFFFF00,0x80FF00,0x00FF00,0x00FF80,0x00FFFF,0x0080FF,
125
0xCC0066,0x606060,0xFF0000,0xFF8000,0xFFFF00,0x80FF00,0x00FF00,0x00FF80,0x00FFFF,0x0080FF,
125
0x0000FF,0x7F00FF,0xFF00FF,0xFF007F,0x808080,0xFF3333,0xFF9933,0xFFFF33,0x99FF33,0x33FF33,
126
0x0000FF,0x7F00FF,0xFF00FF,0xFF007F,0x808080,0xFF3333,0xFF9933,0xFFFF33,0x99FF33,0x33FF33,
126
0x33FF99,0x33FFFF,0x3399FF,0x3333FF,0x9933FF,0xFF33FF,0xFF3399,0xA0A0A0,0xFF6666,0xFFB266,
127
0x33FF99,0x33FFFF,0x3399FF,0x3333FF,0x9933FF,0xFF33FF,0xFF3399,0xA0A0A0,0xFF6666,0xFFB266,
127
0xFFFF66,0xB2FF66,0x66FF66,0x66FFB2,0x66FFFF,0x66B2FF,0x6666FF,0xB266FF,0xFF66FF,0xFF66B2,
128
0xFFFF66,0xB2FF66,0x66FF66,0x66FFB2,0x66FFFF,0x66B2FF,0x6666FF,0xB266FF,0xFF66FF,0xFF66B2,
128
0xC0C0C0,0xFF9999,0xFFCC99,0xFFFF99,0xCCFF99,0x99FF99,0x99FFCC,0x99FFFF,0x99CCFF,0x9999FF,
129
0xC0C0C0,0xFF9999,0xFFCC99,0xFFFF99,0xCCFF99,0x99FF99,0x99FFCC,0x99FFFF,0x99CCFF,0x9999FF,
129
0xCC99FF,0xFF99FF,0xFF99CC,0xE0E0E0,0xFFCCCC,0xFFE5CC,0xFFFFCC,0xE5FFCC,0xCCFFCC,0xCCFFE5,
130
0xCC99FF,0xFF99FF,0xFF99CC,0xE0E0E0,0xFFCCCC,0xFFE5CC,0xFFFFCC,0xE5FFCC,0xCCFFCC,0xCCFFE5,
130
0xCCFFFF,0xCCE5FF,0xCCCCFF,0xE5CCFF,0xFFCCFF,0xFFCCE5,0xFFFFFF	
131
0xCCFFFF,0xCCE5FF,0xCCCCFF,0xE5CCFF,0xFFCCFF,0xFFCCE5,0xFFFFFF	
131
};
132
};
132
 
133
 
133
#define LAST_USED_MAX 13
134
#define LAST_USED_MAX 13
134
dword last_used_colors[LAST_USED_MAX] = {
135
dword last_used_colors[LAST_USED_MAX] = {
135
0xFFFFFF,0xFFFFFF,0xFFFFFF,0xFFFFFF,0xFFFFFF,0xFFFFFF,0xFFFFFF,0xFFFFFF,0xFFFFFF,0xFFFFFF,
136
0xFFFFFF,0xFFFFFF,0xFFFFFF,0xFFFFFF,0xFFFFFF,0xFFFFFF,0xFFFFFF,0xFFFFFF,0xFFFFFF,0xFFFFFF,
136
0xFFFFFF,0xFFFFFF,0xFFFFFF
137
0xFFFFFF,0xFFFFFF,0xFFFFFF
137
};
138
};
138
 
139
 
139
CustomCursor Cursor;
140
CustomCursor Cursor;
140
dword CursorBar = FROM "cursors/bar.cur";
141
dword CursorBar = FROM "cursors/bar.cur";
141
dword CursorFill = FROM "cursors/fill.cur";
142
dword CursorFill = FROM "cursors/fill.cur";
142
dword CursorLine = FROM "cursors/line.cur";
143
dword CursorLine = FROM "cursors/line.cur";
143
dword CursorPencil = FROM "cursors/pencil.cur";
144
dword CursorPencil = FROM "cursors/pencil.cur";
144
dword CursorPipette = FROM "cursors/pipette.cur";
145
dword CursorPipette = FROM "cursors/pipette.cur";
145
dword CursorRectangle = FROM "cursors/rectangle.cur";
146
dword CursorRectangle = FROM "cursors/rectangle.cur";
146
dword CursorSelect = FROM "cursors/select.cur";
147
dword CursorSelect = FROM "cursors/select.cur";
147
 
148
 
148
_image image;
149
_image image;
149
 
150
 
150
#include "actions_history.h"
151
#include "actions_history.h"
151
 
152
 
152
_ActionsHistory actionsHistory;
153
_ActionsHistory actionsHistory;
153
 
154
 
154
#include "tools.h"
155
#include "tools.h"
155
#include "canvas_resize.h"
156
#include "canvas_resize.h"
156
 
157
 
157
//===================================================//
158
//===================================================//
158
//                                                   //
159
//                                                   //
159
//                       CODE                        //
160
//                       CODE                        //
160
//                                                   //
161
//                                                   //
161
//===================================================//
162
//===================================================//
162
 
163
 
163
libimg_image top_icons;
164
libimg_image top_icons;
164
libimg_image left_icons;
165
libimg_image left_icons;
165
 
166
 
166
void main()
167
void main()
167
{
168
{
168
	word btn;
169
	word btn;
169
	libimg_image open_image;
170
	libimg_image open_image;
170
 
171
 
171
	load_dll(libio,  #libio_init,  1);
172
	load_dll(libio,  #libio_init,  1);
172
	load_dll(libimg, #libimg_init, 1);
173
	load_dll(libimg, #libimg_init, 1);
173
	load_dll(boxlib, #box_lib_init,0);
174
	load_dll(boxlib, #box_lib_init,0);
174
 
175
 
175
	top_icons.load("/sys/icons16.png");
176
	top_icons.load("/sys/icons16.png");
176
	left_icons.load("/sys/icons16.png");
177
	left_icons.load("/sys/icons16.png");
177
 
178
 
178
	sc.get();
179
	sc.get();
179
	bg_dark = skin_is_dark();
180
	bg_dark = skin_is_dark();
180
 
181
 
181
	semi_white = MixColors(sc.work, 0xFFFfff, bg_dark*90 + 96);
182
	semi_white = MixColors(sc.work, 0xFFFfff, bg_dark*90 + 96);
182
	top_icons.replace_color(0xffFFFfff, semi_white);
183
	top_icons.replace_color(0xffFFFfff, semi_white);
183
	top_icons.replace_color(0xffCACBD6, MixColors(semi_white, 0, 220));
184
	top_icons.replace_color(0xffCACBD6, MixColors(semi_white, 0, 220));
184
 
185
 
185
	left_icons.replace_color(0xffFFFfff, sc.work);
186
	left_icons.replace_color(0xffFFFfff, sc.work);
186
	left_icons.replace_color(0xffCACBD6, MixColors(sc.work, 0, 200));
187
	left_icons.replace_color(0xffCACBD6, MixColors(sc.work, 0, 200));
187
 
188
 
188
	//fix line and rectandle color for dark skins
189
	//fix line and rectandle color for dark skins
189
	if (bg_dark) left_icons.replace_color(0xff545454, 0xffD3D3D4);
190
	if (bg_dark) left_icons.replace_color(0xff545454, 0xffD3D3D4);
190
 
191
 
191
	EventSetActiveColor(1, color1);
192
	EventSetActiveColor(1, color1);
192
 
193
 
193
	if (!param[0]) {
194
	if (!param[0]) {
194
		image.create(32, 32);
195
		image.create(32, 32);
195
	}
196
	}
196
	else
197
	else
197
	{
198
	{
198
		open_image.load(#param);
199
		open_image.load(#param);
199
		open_image.convert_into(IMAGE_BPP24);
200
		open_image.convert_into(IMAGE_BPP24);
200
 
201
 
201
		if (open_image.w*open_image.h>MAX_CELL_SIZE*MAX_CELL_SIZE) {
202
		if (open_image.w*open_image.h>MAX_CELL_SIZE*MAX_CELL_SIZE) {
202
			notify(T_ERROR_IMA_ICONEDIT);
203
			notify(T_ERROR_IMA_ICONEDIT);
203
			ExitProcess();
204
			ExitProcess();
204
		}
205
		}
205
		else {
206
		else {
206
			image.create(open_image.h, open_image.w);
207
			image.create(open_image.h, open_image.w);
207
			image.set_image(open_image.imgsrc);
208
			image.set_image(open_image.imgsrc);
208
		}
209
		}
209
	}
210
	}
210
 
211
 
211
	actionsHistory.init();
212
	actionsHistory.init();
212
 
213
 
213
	initTools();
214
	initTools();
214
	setCurrentTool(TOOL_PENCIL);
215
	setCurrentTool(TOOL_PENCIL);
215
	
216
	
216
	SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER);
217
	SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER);
217
 
218
 
218
	loop() switch(WaitEvent())
219
	loop() switch(WaitEvent())
219
	{
220
	{
220
		case evMouse:
221
		case evMouse:
221
			if (Window_CanvasReSize.thread_exists()) break;
222
			if (Window_CanvasReSize.thread_exists()) break;
222
			mouse.get();
223
			mouse.get();
223
			
224
			
224
			if (mouse.lkm) tool_color = color1;
225
			if (mouse.lkm) tool_color = color1;
225
			if (mouse.pkm) tool_color = color2;
226
			if (mouse.pkm) tool_color = color2;
226
			if (mouse.mkm) break;
227
			if (mouse.mkm) break;
227
 
228
 
228
			hoverX = mouse.x - canvas.x / zoom.value;
229
			hoverX = mouse.x - canvas.x / zoom.value;
229
			hoverY = mouse.y - canvas.y / zoom.value;
230
			hoverY = mouse.y - canvas.y / zoom.value;
230
			if (hoverX<0) hoverX = 0;
231
			if (hoverX<0) hoverX = 0;
231
			if (hoverY<0) hoverY = 0;
232
			if (hoverY<0) hoverY = 0;
232
			if (hoverX>image.columns-1) hoverX = image.columns-1;
233
			if (hoverX>image.columns-1) hoverX = image.columns-1;
233
			if (hoverY>image.rows-1) hoverY = image.rows-1;
234
			if (hoverY>image.rows-1) hoverY = image.rows-1;
234
			canvasMouseMoved = false;
235
			canvasMouseMoved = false;
235
			if (priorHoverX != hoverX) canvasMouseMoved = true;
236
			if (priorHoverX != hoverX) canvasMouseMoved = true;
236
			if (priorHoverY != hoverY) canvasMouseMoved = true;
237
			if (priorHoverY != hoverY) canvasMouseMoved = true;
237
			priorHoverX = hoverX;
238
			priorHoverX = hoverX;
238
			priorHoverY = hoverY;
239
			priorHoverY = hoverY;
239
			//DrawBar(Form.cwidth-100, 3, 80, 12, 0xFFFfff);
240
			//DrawBar(Form.cwidth-100, 3, 80, 12, 0xFFFfff);
240
			//WriteText(Form.cwidth-100, 3, 0x80, 0x000000, 
241
			//WriteText(Form.cwidth-100, 3, 0x80, 0x000000, 
241
			//	sprintf(#param, "%i %i", hoverX, hoverY));
242
			//	sprintf(#param, "%i %i", hoverX, hoverY));
242
 
243
 
243
			if (currentTool != TOOL_NONE)
244
			if (currentTool != TOOL_NONE)
244
				tools[currentTool].onMouseEvent(mouse.x, mouse.y, mouse.lkm, mouse.pkm);
245
				tools[currentTool].onMouseEvent(mouse.x, mouse.y, mouse.lkm, mouse.pkm);
245
 
246
 
246
			if (mouse.vert) {
247
			if (mouse.vert) {
247
				if (mouse.vert==65535) zoom.inc();
248
				if (mouse.vert==65535) zoom.inc();
248
				if (mouse.vert==1) zoom.dec();
249
				if (mouse.vert==1) zoom.dec();
249
				DrawEditArea();
250
				DrawEditArea();
250
			}
251
			}
251
 
252
 
252
			if (wrapper.hovered()) SetCursor();
253
			if (wrapper.hovered()) SetCursor();
253
			else Cursor.Restore();
254
			else Cursor.Restore();
254
 
255
 
255
			if (mouse.down) {
256
			if (mouse.down) {
256
				if (b_color_gradient.hovered()) 
257
				if (b_color_gradient.hovered()) 
257
				|| (b_last_colors.hovered())
258
				|| (b_last_colors.hovered())
258
				|| (b_default_palette.hovered()) {
259
				|| (b_default_palette.hovered()) {
259
					if (mouse.key&MOUSE_LEFT) EventSetActiveColor(1, GetPixelUnderMouse());
260
					if (mouse.key&MOUSE_LEFT) EventSetActiveColor(1, GetPixelUnderMouse());
260
					if (mouse.key&MOUSE_RIGHT) EventSetActiveColor(2, GetPixelUnderMouse());
261
					if (mouse.key&MOUSE_RIGHT) EventSetActiveColor(2, GetPixelUnderMouse());
261
				}	
262
				}	
262
			}
263
			}
263
 
264
 
264
			break;
265
			break;
265
 
266
 
266
		case evButton:
267
		case evButton:
267
			if (Window_CanvasReSize.thread_exists()) break;
268
			if (Window_CanvasReSize.thread_exists()) break;
268
			btn = GetButtonID();
269
			btn = GetButtonID();
269
 
270
 
270
			if (zoom.click(btn)) DrawEditArea();
271
			if (zoom.click(btn)) DrawEditArea();
271
 
272
 
272
			button.press(btn);
273
			button.press(btn);
273
	  
274
	  
274
		case evKey:
275
		case evKey:
275
			GetKeys();
276
			GetKeys();
276
 
277
 
277
			if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL) key.press(ECTRL + key_scancode);
278
			if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL) key.press(ECTRL + key_scancode);
278
 
279
 
279
			if (key_modifier&KEY_LSHIFT) || (key_modifier&KEY_RSHIFT) {
280
			if (key_modifier&KEY_LSHIFT) || (key_modifier&KEY_RSHIFT) {
280
				if (key_scancode == SCAN_CODE_DEL) EventCleanCanvas();
281
				if (key_scancode == SCAN_CODE_DEL) EventCleanCanvas();
281
			}
282
			}
282
 
283
 
283
			if (currentTool != TOOL_NONE) && (tools[currentTool].onKeyEvent != 0)
284
			if (currentTool != TOOL_NONE) && (tools[currentTool].onKeyEvent != 0)
284
				tools[currentTool].onKeyEvent(key_scancode);
285
				tools[currentTool].onKeyEvent(key_scancode);
285
 
286
 
286
			key.press(key_scancode);
287
			key.press(key_scancode);
287
 
288
 
288
			if (key_scancode == SCAN_CODE_KEY_Z) actionsHistory.undoLastAction();
289
			if (key_scancode == SCAN_CODE_KEY_Z) actionsHistory.undoLastAction();
289
			if (key_scancode == SCAN_CODE_KEY_Y) actionsHistory.redoLastAction();
290
			if (key_scancode == SCAN_CODE_KEY_Y) actionsHistory.redoLastAction();
290
 
291
 
291
			if (key_scancode == SCAN_CODE_MINUS) {zoom.dec(); DrawEditArea();}
292
			if (key_scancode == SCAN_CODE_MINUS) {zoom.dec(); DrawEditArea();}
292
			if (key_scancode == SCAN_CODE_PLUS)  {zoom.inc(); DrawEditArea();}
293
			if (key_scancode == SCAN_CODE_PLUS)  {zoom.inc(); DrawEditArea();}
293
 
294
 
294
			break;
295
			break;
295
		 
296
		 
296
		case evReDraw:
297
		case evReDraw:
297
			Window_CanvasReSize.thread_exists();
298
			Window_CanvasReSize.thread_exists();
298
			if (CheckActiveProcess(Form.ID)) EventCheckMenuItemSelected();
299
			if (CheckActiveProcess(Form.ID)) EventCheckMenuItemSelected();
299
			DrawWindow();
300
			DrawWindow();
300
			break;
301
			break;
301
	}
302
	}
302
}
303
}
303
 
304
 
304
void DrawTopPanelButton(dword _event, _hotkey, _x, _icon_n)
305
void DrawTopPanelButton(dword _event, _hotkey, _x, _icon_n)
305
{
306
{
306
	DrawWideRectangle(_x, 4, 22, 22, 3, semi_white);
307
	DrawWideRectangle(_x, 4, 22, 22, 3, semi_white);
307
	PutPixel(_x,4,sc.work);
308
	PutPixel(_x,4,sc.work);
308
	PutPixel(_x,4+21,sc.work);
309
	PutPixel(_x,4+21,sc.work);
309
	PutPixel(_x+21,4,sc.work);
310
	PutPixel(_x+21,4,sc.work);
310
	PutPixel(_x+21,4+21,sc.work);
311
	PutPixel(_x+21,4+21,sc.work);
311
	DefineHiddenButton(_x, 4, 21, 21, button.add(_event));
312
	DefineHiddenButton(_x, 4, 21, 21, button.add(_event));
312
	img_draw stdcall(top_icons.image, _x+3, 7, 16, 16, 0, _icon_n*16);
313
	img_draw stdcall(top_icons.image, _x+3, 7, 16, 16, 0, _icon_n*16);
313
	if (_hotkey) key.add_n(_hotkey, _event);
314
	if (_hotkey) key.add_n(_hotkey, _event);
314
}
315
}
315
 
316
 
316
 
317
 
317
int DrawFlatPanelButton(dword _id, _x, _y, _text)
318
int DrawFlatPanelButton(dword _id, _x, _y, _text)
318
{
319
{
319
	#define P 10
320
	#define P 10
320
	int w = strlen(_text)*6 + P + P;
321
	int w = strlen(_text)*6 + P + P;
321
	DrawBar(_x, _y, w, 22, semi_white);
322
	DrawBar(_x, _y, w, 22, semi_white);
322
	PutPixel(_x,_y,sc.work);
323
	PutPixel(_x,_y,sc.work);
323
	PutPixel(_x,_y+21,sc.work);
324
	PutPixel(_x,_y+21,sc.work);
324
	PutPixel(_x+w-1,_y,sc.work);
325
	PutPixel(_x+w-1,_y,sc.work);
325
	PutPixel(_x+w-1,_y+21,sc.work);
326
	PutPixel(_x+w-1,_y+21,sc.work);
326
	DefineHiddenButton(_x, _y, w, 21, _id);
327
	DefineHiddenButton(_x, _y, w, 21, _id);
327
	WriteText(_x+P, _y+7, 0x80, sc.work_text, _text);
328
	WriteText(_x+P, _y+7, 0x80, sc.work_text, _text);
328
	return w;
329
	return w;
329
}
330
}
330
 
331
 
331
void DrawLeftPanelButton(dword _event, _hotkey, _y, _icon_n)
332
void DrawLeftPanelButton(dword _event, _hotkey, _y, _icon_n)
332
{
333
{
333
	int x = 5;
334
	int x = 5;
334
	DrawRectangle(x, _y, 22-1, 22-1, sc.work);
335
	DrawRectangle(x, _y, 22-1, 22-1, sc.work);
335
	DefineHiddenButton(x, _y, 21, 21, button.add(_event));
336
	DefineHiddenButton(x, _y, 21, 21, button.add(_event));
336
	img_draw stdcall(left_icons.image, x+3, _y+3, 16, 16, 0, _icon_n*16);
337
	img_draw stdcall(left_icons.image, x+3, _y+3, 16, 16, 0, _icon_n*16);
337
	key.add_n(_hotkey, _event);
338
	key.add_n(_hotkey, _event);
338
}
339
}
339
void DrawStatusBar()
340
void DrawStatusBar()
340
{
341
{
341
	zoom.draw(wrapper.x, wrapper.y + wrapper.h + 6);
342
	zoom.draw(wrapper.x, wrapper.y + wrapper.h + 6);
342
 
343
 
343
	sprintf(#param,"%i x %i", image.columns, image.rows);
344
	sprintf(#param,"%i x %i", image.columns, image.rows);
344
	DrawCaptButton(
345
	DrawCaptButton(
345
		wrapper.x+wrapper.w-calc(strlen(#param)*8) -6 - 1,
346
		wrapper.x+wrapper.w-calc(strlen(#param)*8) -6 - 1,
346
		zoom.y,
347
		zoom.y,
347
		calc(strlen(#param)*8)+6,
348
		calc(strlen(#param)*8)+6,
348
		18,
349
		18,
349
		button.add(#EventCanvasResize),
350
		button.add(#EventCanvasResize),
350
		sc.button,
351
		sc.button,
351
		sc.button_text,
352
		sc.button_text,
352
		#param
353
		#param
353
		);
354
		);
354
}
355
}
355
 
356
 
356
 
357
 
357
void DrawWindow()
358
void DrawWindow()
358
{
359
{
359
	#define GAPH 27
360
	#define GAPH 27
360
	#define GAPV 28
361
	#define GAPV 28
361
	#define BLOCK_SPACE 10
362
	#define BLOCK_SPACE 10
362
	incn tx;
363
	incn tx;
363
	incn ty;
364
	incn ty;
364
	sc.get();
365
	sc.get();
365
	DefineAndDrawWindow(115+random(100), 50+random(100), 700, 540, 0x73, NULL, T_TITLE, 0);
366
	DefineAndDrawWindow(115+random(100), 50+random(100), 700, 540, 0x73, NULL, T_TITLE, 0);
366
	GetProcessInfo(#Form, SelfInfo);
367
	GetProcessInfo(#Form, SelfInfo);
367
	if (Form.status_window>2) return;
368
	if (Form.status_window>2) return;
368
	if (Form.width  < 560) { MoveSize(OLD,OLD,560,OLD); return; }
369
	if (Form.width  < 560) { MoveSize(OLD,OLD,560,OLD); return; }
369
	if (Form.height < 430) { MoveSize(OLD,OLD,OLD,430); return; }
370
	if (Form.height < 430) { MoveSize(OLD,OLD,OLD,430); return; }
370
	button.init(40);
371
	button.init(40);
371
	key.init(40);
372
	key.init(40);
372
 
373
 
373
	right_bar.x = Form.cwidth - right_bar.w;
374
	right_bar.x = Form.cwidth - right_bar.w;
374
	b_color_gradient.x = b_last_colors.x = b_default_palette.x = right_bar.x;
375
	b_color_gradient.x = b_last_colors.x = b_default_palette.x = right_bar.x;
375
	DrawBar(0, 0, Form.cwidth, TOPBAR_H-1, sc.work);
376
	DrawBar(0, 0, Form.cwidth, TOPBAR_H-1, sc.work);
376
	DrawBar(0, TOPBAR_H-1, Form.cwidth, 1, sc.work_graph);
377
	DrawBar(0, TOPBAR_H-1, Form.cwidth, 1, sc.work_graph);
377
 
378
 
378
	DrawTopPanelButton(#EventCreateNewIcon,  ECTRL + SCAN_CODE_KEY_N, tx.set(5),    2);
379
	DrawTopPanelButton(#EventCreateNewIcon,  ECTRL + SCAN_CODE_KEY_N, tx.set(5),    2);
379
	DrawTopPanelButton(#EventOpenIcon,       ECTRL + SCAN_CODE_KEY_O, tx.inc(GAPH), 0);
380
	DrawTopPanelButton(#EventOpenIcon,       ECTRL + SCAN_CODE_KEY_O, tx.inc(GAPH), 0);
380
	DrawTopPanelButton(#EventSaveIconToFile, ECTRL + SCAN_CODE_KEY_S, tx.inc(GAPH), 5);
381
	DrawTopPanelButton(#EventSaveIconToFile, ECTRL + SCAN_CODE_KEY_S, tx.inc(GAPH), 5);
381
	DrawTopPanelButton(#EventMoveLeft,       ECTRL + SCAN_CODE_LEFT,  tx.inc(GAPH+BLOCK_SPACE), 30);
382
	DrawTopPanelButton(#EventMoveLeft,       ECTRL + SCAN_CODE_LEFT,  tx.inc(GAPH+BLOCK_SPACE), 30);
382
	DrawTopPanelButton(#EventMoveRight,      ECTRL + SCAN_CODE_RIGHT, tx.inc(GAPH), 31);
383
	DrawTopPanelButton(#EventMoveRight,      ECTRL + SCAN_CODE_RIGHT, tx.inc(GAPH), 31);
383
	DrawTopPanelButton(#EventMoveUp,         ECTRL + SCAN_CODE_UP,    tx.inc(GAPH), 32);
384
	DrawTopPanelButton(#EventMoveUp,         ECTRL + SCAN_CODE_UP,    tx.inc(GAPH), 32);
384
	DrawTopPanelButton(#EventMoveDown,       ECTRL + SCAN_CODE_DOWN,  tx.inc(GAPH), 33);
385
	DrawTopPanelButton(#EventMoveDown,       ECTRL + SCAN_CODE_DOWN,  tx.inc(GAPH), 33);
385
	DrawTopPanelButton(#EventFlipHor,        0, tx.inc(GAPH+BLOCK_SPACE), 34);
386
	DrawTopPanelButton(#EventFlipHor,        0, tx.inc(GAPH+BLOCK_SPACE), 34);
386
	DrawTopPanelButton(#EventFlipVer,        0, tx.inc(GAPH), 35);
387
	DrawTopPanelButton(#EventFlipVer,        0, tx.inc(GAPH), 35);
387
	DrawTopPanelButton(#EventRotateLeft,     ECTRL + SCAN_CODE_KEY_L, tx.inc(GAPH), 37);
388
	DrawTopPanelButton(#EventRotateLeft,     ECTRL + SCAN_CODE_KEY_L, tx.inc(GAPH), 37);
388
	DrawTopPanelButton(#EventRotateRight,    ECTRL + SCAN_CODE_KEY_R, tx.inc(GAPH), 36);
389
	DrawTopPanelButton(#EventRotateRight,    ECTRL + SCAN_CODE_KEY_R, tx.inc(GAPH), 36);
389
	DrawTopPanelButton(#EventTestIcon,       ECTRL + SCAN_CODE_KEY_T, tx.inc(GAPH+BLOCK_SPACE), 12);
390
	DrawTopPanelButton(#EventTestIcon,       ECTRL + SCAN_CODE_KEY_T, tx.inc(GAPH+BLOCK_SPACE), 12);
390
	DrawTopPanelButton(#EventCrop,           0, tx.inc(GAPH+BLOCK_SPACE), 46);
391
	DrawTopPanelButton(#EventCrop,           0, tx.inc(GAPH+BLOCK_SPACE), 46);
391
 
392
 
392
	image_menu_btn.x = tx.inc(GAPH+BLOCK_SPACE);
393
	image_menu_btn.x = tx.inc(GAPH+BLOCK_SPACE);
393
	image_menu_btn.w = DrawFlatPanelButton(button.add(#EventShowImageMenu), image_menu_btn.x, image_menu_btn.y, T_MENU_IMAGE);
394
	image_menu_btn.w = DrawFlatPanelButton(button.add(#EventShowImageMenu), image_menu_btn.x, image_menu_btn.y, T_MENU_IMAGE);
394
	//tx.inc(image_menu_btn.w + BLOCK_SPACE);
395
	//tx.inc(image_menu_btn.w + BLOCK_SPACE);
395
	
396
	
396
	DrawEditArea();
397
	DrawEditArea();
397
 
398
 
398
	DrawBar(0, TOPBAR_H, LEFTBAR_W-1, Form.cheight - TOPBAR_H, sc.work);
399
	DrawBar(0, TOPBAR_H, LEFTBAR_W-1, Form.cheight - TOPBAR_H, sc.work);
399
 
400
 
400
	ty.n = right_bar.y - GAPV - 2;
401
	ty.n = right_bar.y - GAPV - 2;
401
 
402
 
402
	DrawLeftPanelButton(#EventSelectToolPencil, SCAN_CODE_KEY_P, ty.inc(GAPV), 38);
403
	DrawLeftPanelButton(#EventSelectToolPencil, SCAN_CODE_KEY_P, ty.inc(GAPV), 38);
403
	DrawLeftPanelButton(#EventSelectToolPick,   SCAN_CODE_KEY_I, ty.inc(GAPV), 39);
404
	DrawLeftPanelButton(#EventSelectToolPick,   SCAN_CODE_KEY_I, ty.inc(GAPV), 39);
404
	DrawLeftPanelButton(#EventSelectToolFill,   SCAN_CODE_KEY_F, ty.inc(GAPV), 40);
405
	DrawLeftPanelButton(#EventSelectToolFill,   SCAN_CODE_KEY_F, ty.inc(GAPV), 40);
405
	DrawLeftPanelButton(#EventSelectToolLine,   SCAN_CODE_KEY_L, ty.inc(GAPV), 41);
406
	DrawLeftPanelButton(#EventSelectToolLine,   SCAN_CODE_KEY_L, ty.inc(GAPV), 41);
406
	DrawLeftPanelButton(#EventSelectToolRect,   SCAN_CODE_KEY_R, ty.inc(GAPV), 42);
407
	DrawLeftPanelButton(#EventSelectToolRect,   SCAN_CODE_KEY_R, ty.inc(GAPV), 42);
407
	DrawLeftPanelButton(#EventSelectToolBar,    SCAN_CODE_KEY_B, ty.inc(GAPV), 43);
408
	DrawLeftPanelButton(#EventSelectToolBar,    SCAN_CODE_KEY_B, ty.inc(GAPV), 43);
408
	DrawLeftPanelButton(#EventSelectToolSelect, SCAN_CODE_KEY_S, ty.inc(GAPV), 44);
409
	DrawLeftPanelButton(#EventSelectToolSelect, SCAN_CODE_KEY_S, ty.inc(GAPV), 44);
409
	DrawLeftPanelButton(#EventSelectToolScrCopy,SCAN_CODE_KEY_Q, ty.inc(GAPV), 45);
410
	DrawLeftPanelButton(#EventSelectToolScrCopy,SCAN_CODE_KEY_Q, ty.inc(GAPV), 45);
410
	DrawLeftPanelSelection();
411
	DrawLeftPanelSelection();
411
 
412
 
412
	button.add_n(1, #EventExitIconEdit);
413
	button.add_n(1, #EventExitIconEdit);
413
 
414
 
414
	DrawBar(wrapper.x+wrapper.w, TOPBAR_H, Form.cwidth-wrapper.x-wrapper.w,
415
	DrawBar(wrapper.x+wrapper.w, TOPBAR_H, Form.cwidth-wrapper.x-wrapper.w,
415
		Form.cheight - TOPBAR_H, sc.work);
416
		Form.cheight - TOPBAR_H, sc.work);
416
	DrawActiveColor(right_bar.y);
417
	DrawActiveColor(right_bar.y);
417
	DrawColorPallets();
418
	DrawColorPallets();
418
	DrawPreview();
419
	DrawPreview();
419
 
420
 
420
	DrawBar(LEFTBAR_W-1, wrapper.y + wrapper.h, wrapper.w+1, 
421
	DrawBar(LEFTBAR_W-1, wrapper.y + wrapper.h, wrapper.w+1, 
421
		Form.cheight - wrapper.y - wrapper.h, sc.work);
422
		Form.cheight - wrapper.y - wrapper.h, sc.work);
422
	DrawStatusBar();
423
	DrawStatusBar();
423
}
424
}
424
 
425
 
425
void DrawLeftPanelSelection()
426
void DrawLeftPanelSelection()
426
{
427
{
427
	if (previousTool!=-1) DrawRectangle3D(5, previousTool*GAPV+right_bar.y-2, 16+3+2, 16+3+2, sc.work, sc.work);
428
	if (previousTool!=-1) DrawRectangle3D(5, previousTool*GAPV+right_bar.y-2, 16+3+2, 16+3+2, sc.work, sc.work);
428
	DrawRectangle3D(5, currentTool*GAPV+right_bar.y-2, 16+3+2, 16+3+2, 0x333333, 0x777777);
429
	DrawRectangle3D(5, currentTool*GAPV+right_bar.y-2, 16+3+2, 16+3+2, 0x333333, 0x777777);
429
}
430
}
430
 
431
 
431
void DrawEditArea()
432
void DrawEditArea()
432
{
433
{
433
	dword color1=0xC0C0C0;
434
	dword color1=0xC0C0C0;
434
	int top_side;
435
	int top_side;
435
	int left_side;
436
	int left_side;
436
 
437
 
437
	wrapper.w = Form.cwidth - right_bar.w - 10 - wrapper.x;
438
	wrapper.w = Form.cwidth - right_bar.w - 10 - wrapper.x;
438
	wrapper.h = Form.cheight - TOPBAR_H - 35;
439
	wrapper.h = Form.cheight - TOPBAR_H - 35;
439
 
440
 
440
	//canvas{
441
	//canvas{
441
	canvas.w = image.columns * zoom.value;
442
	canvas.w = image.columns * zoom.value;
442
	canvas.h = image.rows * zoom.value;
443
	canvas.h = image.rows * zoom.value;
443
	if (canvas.w+2 > wrapper.w) || (canvas.h+2 > wrapper.h) { 
444
	if (canvas.w+2 > wrapper.w) || (canvas.h+2 > wrapper.h) { 
444
		zoom.value--;
445
		zoom.value--;
445
		if (zoom.x) zoom.redraw();
446
		if (zoom.x) zoom.redraw();
446
		DrawEditArea();
447
		DrawEditArea();
447
		return;
448
		return;
448
	}
449
	}
449
	canvas.x = -zoom.value*image.columns+wrapper.w/2 + wrapper.x;
450
	canvas.x = -zoom.value*image.columns+wrapper.w/2 + wrapper.x;
450
	canvas.y = -zoom.value*image.rows+wrapper.h/2 + wrapper.y;
451
	canvas.y = -zoom.value*image.rows+wrapper.h/2 + wrapper.y;
451
	DrawCanvas();
452
	DrawCanvas();
452
	//}
453
	//}
453
 
454
 
454
	left_side = canvas.x-wrapper.x-1;
455
	left_side = canvas.x-wrapper.x-1;
455
	top_side = canvas.y-wrapper.y-1;
456
	top_side = canvas.y-wrapper.y-1;
456
 
457
 
457
	DrawRectangle(wrapper.x-1, wrapper.y-1, wrapper.w, wrapper.h, sc.work_graph);
458
	DrawRectangle(wrapper.x-1, wrapper.y-1, wrapper.w, wrapper.h, sc.work_graph);
458
 
459
 
459
	if (left_side>0)
460
	if (left_side>0)
460
	{
461
	{
461
		DrawBar(wrapper.x, wrapper.y, wrapper.w-1, top_side, color1); //top
462
		DrawBar(wrapper.x, wrapper.y, wrapper.w-1, top_side, color1); //top
462
		DrawBar(wrapper.x, wrapper.y+wrapper.h-top_side-1, wrapper.w-1, top_side, color1); //bottom
463
		DrawBar(wrapper.x, wrapper.y+wrapper.h-top_side-1, wrapper.w-1, top_side, color1); //bottom
463
	}
464
	}
464
	if (top_side>0)
465
	if (top_side>0)
465
	{
466
	{
466
		//left
467
		//left
467
		DrawBar(wrapper.x, wrapper.y+top_side, left_side, 
468
		DrawBar(wrapper.x, wrapper.y+top_side, left_side, 
468
			wrapper.h-top_side-top_side, color1); 
469
			wrapper.h-top_side-top_side, color1); 
469
		//right
470
		//right
470
		DrawBar(wrapper.x+wrapper.w-left_side-1, wrapper.y+top_side, left_side, 
471
		DrawBar(wrapper.x+wrapper.w-left_side-1, wrapper.y+top_side, left_side, 
471
			wrapper.h-top_side-top_side, color1);
472
			wrapper.h-top_side-top_side, color1);
472
	}
473
	}
473
	DrawRectangle(canvas.x-1, canvas.y-1, canvas.w+1, canvas.h+1, 0x808080);
474
	DrawRectangle(canvas.x-1, canvas.y-1, canvas.w+1, canvas.h+1, 0x808080);
474
}
475
}
475
 
476
 
476
void DrawActiveColor(dword iny)
477
void DrawActiveColor(dword iny)
477
{
478
{
478
	#define CELL 20
479
	#define CELL 20
479
	static dword outy;
480
	static dword outy;
480
	if (iny != NULL) outy = iny;
481
	if (iny != NULL) outy = iny;
481
	DrawFrame(right_bar.x, outy, CELL, CELL, NULL);
482
	DrawFrame(right_bar.x, outy, CELL, CELL, NULL);
482
	DrawBar(right_bar.x+2, outy+2, CELL-4, CELL-4, color1);
483
	DrawBar(right_bar.x+2, outy+2, CELL-4, CELL-4, color1);
483
 
484
 
484
	DrawFrame(right_bar.x+CELL+5, outy, CELL, CELL, NULL);
485
	DrawFrame(right_bar.x+CELL+5, outy, CELL, CELL, NULL);
485
	DrawBar(right_bar.x+CELL+5+2, outy+2, CELL-4, CELL-4, color2);
486
	DrawBar(right_bar.x+CELL+5+2, outy+2, CELL-4, CELL-4, color2);
486
 
487
 
487
	//sprintf(#param, "%A", color1);
488
	//sprintf(#param, "%A", color1);
488
	//WriteTextWithBg(right_bar.x+30, outy+3, 0xD0, sc.work_text, #param+4, sc.work);
489
	//WriteTextWithBg(right_bar.x+30, outy+3, 0xD0, sc.work_text, #param+4, sc.work);
489
	DrawCurrentColorGradient();
490
	DrawCurrentColorGradient();
490
}
491
}
491
 
492
 
492
int lmax;
493
int lmax;
493
void GenerateCurrentColorGradient()
494
void GenerateCurrentColorGradient()
494
{
495
{
495
	int i, avg, rmax;
496
	int i, avg, rmax;
496
 
497
 
497
	rgb.DwordToRgb(color1);
498
	rgb.DwordToRgb(color1);
498
	avg = 255 - calc(rgb.r + rgb.g + rgb.b / 3);
499
	avg = 255 - calc(rgb.r + rgb.g + rgb.b / 3);
499
 
500
 
500
	lmax = b_color_gradient.w *avg/255 | 1;
501
	lmax = b_color_gradient.w *avg/255 | 1;
501
	rmax = b_color_gradient.w - lmax | 1;
502
	rmax = b_color_gradient.w - lmax | 1;
502
	if (lmax == 0) lmax=1;
503
	if (lmax == 0) lmax=1;
503
	if (rmax == 0) rmax=1;
504
	if (rmax == 0) rmax=1;
504
	
505
	
505
	for (i=0; i
506
	for (i=0; i
506
		linear_gradient[i] = MixColors(color1,0xFFFfff,255*i/lmax);
507
		linear_gradient[i] = MixColors(color1,0xFFFfff,255*i/lmax);
507
	}
508
	}
508
 
509
 
509
	for (i=0 ; i<=rmax; i++) {
510
	for (i=0 ; i<=rmax; i++) {
510
		linear_gradient[lmax+rmax - i] = MixColors(color1,0x000000,255*i/rmax);
511
		linear_gradient[lmax+rmax - i] = MixColors(color1,0x000000,255*i/rmax);
511
	}
512
	}
512
}
513
}
513
 
514
 
514
int DrawGradientMarker(dword marker_x, marker_color)
515
int DrawGradientMarker(dword marker_x, marker_color)
515
{
516
{
516
	if (marker_x > b_color_gradient.w - 1) marker_x = b_color_gradient.w - 1;
517
	if (marker_x > b_color_gradient.w - 1) marker_x = b_color_gradient.w - 1;
517
	DrawBar(b_color_gradient.x + marker_x-2, b_color_gradient.y-3, 5, 1, marker_color);
518
	DrawBar(b_color_gradient.x + marker_x-2, b_color_gradient.y-3, 5, 1, marker_color);
518
	DrawBar(b_color_gradient.x + marker_x-1, b_color_gradient.y-2, 3, 1, marker_color);
519
	DrawBar(b_color_gradient.x + marker_x-1, b_color_gradient.y-2, 3, 1, marker_color);
519
	PutPixel(b_color_gradient.x + marker_x, b_color_gradient.y-1, marker_color);
520
	PutPixel(b_color_gradient.x + marker_x, b_color_gradient.y-1, marker_color);
520
	return marker_x;
521
	return marker_x;
521
}
522
}
522
 
523
 
523
int old_marker_pos;
524
int old_marker_pos;
524
void DrawCurrentColorGradient()
525
void DrawCurrentColorGradient()
525
{
526
{
526
	int i;
527
	int i;
527
	for (i=0 ; i
528
	for (i=0 ; i
528
		DrawBar(b_color_gradient.x+i, b_color_gradient.y, 1, b_color_gradient.h, linear_gradient[i]);		
529
		DrawBar(b_color_gradient.x+i, b_color_gradient.y, 1, b_color_gradient.h, linear_gradient[i]);		
529
	}
530
	}
530
	DrawGradientMarker(old_marker_pos, sc.work);
531
	DrawGradientMarker(old_marker_pos, sc.work);
531
	old_marker_pos = DrawGradientMarker(lmax, 0xFFFfff * bg_dark);
532
	old_marker_pos = DrawGradientMarker(lmax, 0xFFFfff * bg_dark);
532
}
533
}
533
 
534
 
534
void DrawColorPallets()
535
void DrawColorPallets()
535
{
536
{
536
	int r, c, i=0;
537
	int r, c, i=0;
537
	//Last used colors
538
	//Last used colors
538
	for (r = 0; r < LAST_USED_MAX/PAL_ITEMS_X_COUNT; r++)
539
	for (r = 0; r < LAST_USED_MAX/PAL_ITEMS_X_COUNT; r++)
539
	{
540
	{
540
		for (c = 0; c < PAL_ITEMS_X_COUNT; c++, i++)
541
		for (c = 0; c < PAL_ITEMS_X_COUNT; c++, i++)
541
		{
542
		{
542
			DrawBar(c*COLSIZE + b_last_colors.x, r*COLSIZE + b_last_colors.y, 
543
			DrawBar(c*COLSIZE + b_last_colors.x, r*COLSIZE + b_last_colors.y, 
543
				COLSIZE, COLSIZE, last_used_colors[i]);
544
				COLSIZE, COLSIZE, last_used_colors[i]);
544
		}
545
		}
545
	}
546
	}
546
	i=0;
547
	i=0;
547
	//Default colors
548
	//Default colors
548
	for (r = 0; r < 9; r++)
549
	for (r = 0; r < 9; r++)
549
	{
550
	{
550
		for (c = 0; c < PAL_ITEMS_X_COUNT; c++, i++)
551
		for (c = 0; c < PAL_ITEMS_X_COUNT; c++, i++)
551
		{
552
		{
552
			DrawBar(c*COLSIZE + b_default_palette.x, r*COLSIZE + b_default_palette.y, 
553
			DrawBar(c*COLSIZE + b_default_palette.x, r*COLSIZE + b_default_palette.y, 
553
				COLSIZE, COLSIZE, default_palette[PALLETE_SIZE-i]);
554
				COLSIZE, COLSIZE, default_palette[PALLETE_SIZE-i]);
554
		}
555
		}
555
	}
556
	}
556
}
557
}
557
 
558
 
558
void DrawCanvasPixel(dword _r,_c,_color)
559
void DrawCanvasPixel(dword _r,_c,_color)
559
{
560
{
560
	DrawBar(_c*zoom.value + canvas.x, _r*zoom.value + canvas.y, 
561
	DrawBar(_c*zoom.value + canvas.x, _r*zoom.value + canvas.y, 
561
	zoom.value, zoom.value, _color);
562
	zoom.value, zoom.value, _color);
562
}
563
}
563
 
564
 
564
void DrawCanvas()
565
void DrawCanvas()
565
{
566
{
566
	int r, c;
567
	int r, c;
567
	dword color;
568
	dword color;
568
 
569
 
569
	if ((currentTool != TOOL_NONE) && (tools[currentTool].onCanvasDraw != 0))
570
	if ((currentTool != TOOL_NONE) && (tools[currentTool].onCanvasDraw != 0))
570
	{
571
	{
571
		tools[currentTool].onCanvasDraw();
572
		tools[currentTool].onCanvasDraw();
572
	}
573
	}
573
 
574
 
574
	for (r = 0; r < image.rows; r++)
575
	for (r = 0; r < image.rows; r++)
575
	{
576
	{
576
		for (c = 0; c < image.columns; c++)
577
		for (c = 0; c < image.columns; c++)
577
		{
578
		{
578
			if (image.pixel_state.is_drawable(r,c)) 
579
			if (image.pixel_state.is_drawable(r,c)) 
579
				DrawCanvasPixel(r, c, image.get_pixel(r,c));
580
				DrawCanvasPixel(r, c, image.get_pixel(r,c));
580
		}
581
		}
581
	}
582
	}
582
	image.pixel_state.reset_and_set_all_drawable();
583
	image.pixel_state.reset_and_set_all_drawable();
583
 
584
 
584
	DrawPreview();
585
	DrawPreview();
585
}
586
}
586
 
587
 
587
void DrawPreview()
588
void DrawPreview()
588
{
589
{
589
	int x = right_bar.x;
590
	int x = right_bar.x;
590
	int y = b_default_palette.y + b_default_palette.h + 6;
591
	int y = b_default_palette.y + b_default_palette.h + 6;
591
	int preview_h = Form.cheight - y;
592
	int preview_h = Form.cheight - y;
592
 
593
 
593
	if (image.columns > right_bar.w) return;
594
	if (image.columns > right_bar.w) return;
594
	if (image.rows > preview_h) return;
595
	if (image.rows > preview_h) return;
595
 
596
 
596
	_PutImage(right_bar.w - image.columns / 2 + x - 3,
597
	_PutImage(right_bar.w - image.columns / 2 + x - 3,
597
		preview_h - image.rows / 2 + y, 
598
		preview_h - image.rows / 2 + y, 
598
		image.columns, image.rows, image.get_image()
599
		image.columns, image.rows, image.get_image()
599
		);
600
		);
600
}
601
}
601
 
602
 
602
dword GetPixelUnderMouse()
603
dword GetPixelUnderMouse()
603
{
604
{
604
	return GetPixelColorFromScreen(mouse.x + Form.left + 5, mouse.y + Form.top + skin_height);
605
	return GetPixelColorFromScreen(mouse.x + Form.left + 5, mouse.y + Form.top + skin_height);
605
}
606
}
606
 
607
 
607
int preview_size = 128;
608
int preview_size = 128;
608
void DrawImageWithBg(dword _x, _y, _col_to)
609
void DrawImageWithBg(dword _x, _y, _col_to)
609
{
610
{
610
	_x *= preview_size;
611
	_x *= preview_size;
611
	_y *= preview_size;
612
	_y *= preview_size;
612
	DrawWideRectangle(_x,_y, preview_size, preview_size, preview_size-image.columns/2, _col_to);
613
	DrawWideRectangle(_x,_y, preview_size, preview_size, preview_size-image.columns/2, _col_to);
613
	_PutImage(preview_size - image.columns / 2 + _x, preview_size - image.rows / 2 + _y,
614
	_PutImage(preview_size - image.columns / 2 + _x, preview_size - image.rows / 2 + _y,
614
		image.columns, image.rows, image.get_image_with_replaced_color(color2, _col_to));
615
		image.columns, image.rows, image.get_image_with_replaced_color(color2, _col_to));
615
}
616
}
616
 
617
 
617
void ShowWindow_TestIcon()
618
void ShowWindow_TestIcon()
618
{
619
{
619
	if (image.rows>=preview_size) || (image.columns>=preview_size) {
620
	if (image.rows>=preview_size) || (image.columns>=preview_size) {
620
		notify(T_TOO_BIG_IMAGE_FOR_PREVIEW);
621
		notify(T_TOO_BIG_IMAGE_FOR_PREVIEW);
621
		return;
622
		return;
622
	}
623
	}
623
	loop() switch(WaitEvent())
624
	loop() switch(WaitEvent())
624
	{
625
	{
625
		case evButton:
626
		case evButton:
626
			if (GetButtonID()) ExitProcess();
627
			if (GetButtonID()) ExitProcess();
627
			break;
628
			break;
628
	  
629
	  
629
		case evKey:
630
		case evKey:
630
			GetKeys();
631
			GetKeys();
631
			if (key_scancode == SCAN_CODE_ESC) ExitProcess();
632
			if (key_scancode == SCAN_CODE_ESC) ExitProcess();
632
			break;
633
			break;
633
		 
634
		 
634
		case evReDraw:
635
		case evReDraw:
635
			DefineAndDrawWindow(Form.left+100, Form.top+100, preview_size*2+9,
636
			DefineAndDrawWindow(Form.left+100, Form.top+100, preview_size*2+9,
636
				preview_size*2+skin_height+4, 0x74, NULL, T_TEST_ICON, 0);
637
				preview_size*2+skin_height+4, 0x74, NULL, T_TEST_ICON, 0);
637
			DrawImageWithBg(0, 0, 0x000000);
638
			DrawImageWithBg(0, 0, 0x000000);
638
			DrawImageWithBg(1, 0, 0xFFFfff);
639
			DrawImageWithBg(1, 0, 0xFFFfff);
639
			DrawImageWithBg(0, 1, GetPixelColorFromScreen(0, 0));
640
			DrawImageWithBg(0, 1, GetPixelColorFromScreen(0, 0));
640
			DrawImageWithBg(1, 1, sc.work);
641
			DrawImageWithBg(1, 1, sc.work);
641
			break;
642
			break;
642
	}
643
	}
643
}
644
}
644
 
645
 
645
//===================================================//
646
//===================================================//
646
//                                                   //
647
//                                                   //
647
//                      EVENTS                       //
648
//                      EVENTS                       //
648
//                                                   //
649
//                                                   //
649
//===================================================//
650
//===================================================//
650
 
651
 
651
void EventCreateNewIcon()
652
void EventCreateNewIcon()
652
{
653
{
653
	EventSaveIconToFile();
654
	EventSaveIconToFile();
654
	Window_CanvasReSize.create();
655
	Window_CanvasReSize.create();
655
}
656
}
656
 
657
 
657
void EventOpenIcon()
658
void EventOpenIcon()
658
{
659
{
659
	RunProgram("/sys/lod", sprintf(#param, "*png* %s",#program_path));
660
	RunProgram("/sys/lod", sprintf(#param, "*png* %s",#program_path));
660
}
661
}
661
 
662
 
662
void EventSaveIconToFile()
663
void EventSaveIconToFile()
663
{
664
{
664
	int i=0;
665
	int i=0;
665
	char save_file_name[4096];
666
	char save_file_name[4096];
666
	char save_path_stable[4096];
667
	char save_path_stable[4096];
667
	strcpy(#save_path_stable, "/tmp0/1");
668
	strcpy(#save_path_stable, "/tmp0/1");
668
	do {
669
	do {
669
		i++;
670
		i++;
670
		sprintf(#save_file_name, "%s/saved_icon_%i.png", #save_path_stable, i);
671
		sprintf(#save_file_name, "%s/saved_icon_%i.png", #save_path_stable, i);
671
	} while (file_exists(#save_file_name));
672
	} while (file_exists(#save_file_name));
672
	save_image(image.get_image(), image.columns, image.rows, #save_file_name);
673
	save_image(image.get_image(), image.columns, image.rows, #save_file_name);
673
}
674
}
674
 
675
 
675
void EventCleanCanvas()
676
void EventCleanCanvas()
676
{
677
{
677
	image.create(image.rows, image.columns);
678
	image.create(image.rows, image.columns);
678
	actionsHistory.saveCurrentState();
679
	actionsHistory.saveCurrentState();
679
	DrawCanvas();
680
	DrawCanvas();
680
}
681
}
681
 
682
 
682
void EventExitIconEdit()
683
void EventExitIconEdit()
683
{
684
{
684
	EventSaveIconToFile();
685
	EventSaveIconToFile();
685
	ExitProcess();
686
	ExitProcess();
686
}
687
}
687
 
688
 
688
void EventSetActiveColor(int _number, _color)
689
void EventSetActiveColor(int _number, _color)
689
{
690
{
690
	int i;
691
	int i;
691
	if (last_used_colors[0] == _color) return;
692
	if (last_used_colors[0] == _color) return;
692
	for (i=LAST_USED_MAX-1; i>0; i--) {
693
	for (i=LAST_USED_MAX-1; i>0; i--) {
693
		last_used_colors[i] = last_used_colors[i-1];
694
		last_used_colors[i] = last_used_colors[i-1];
694
	}
695
	}
695
	last_used_colors[0] = _color;
696
	last_used_colors[0] = _color;
696
 
697
 
697
	if (_number == 1) color1 = _color;
698
	if (_number == 1) color1 = _color;
698
	if (_number == 2) color2 = _color;
699
	if (_number == 2) color2 = _color;
699
 
700
 
700
	if (b_color_gradient.hovered()) {
701
	if (b_color_gradient.hovered()) {
701
		lmax = mouse.x - b_color_gradient.x;
702
		lmax = mouse.x - b_color_gradient.x;
702
	}
703
	}
703
	else {
704
	else {
704
		GenerateCurrentColorGradient();
705
		GenerateCurrentColorGradient();
705
	}
706
	}
706
	DrawActiveColor(NULL);
707
	DrawActiveColor(NULL);
707
	DrawColorPallets();
708
	DrawColorPallets();
708
}
709
}
709
 
710
 
710
void EventTestIcon()
711
void EventTestIcon()
711
{
712
{
712
	CreateThread(#ShowWindow_TestIcon, #test_icon_stak+4092);
713
	CreateThread(#ShowWindow_TestIcon, #test_icon_stak+4092);
713
}
714
}
714
 
715
 
715
void EventMove(dword _action)
716
void EventMove(dword _action)
716
{
717
{
717
	if (selection.state) {
718
	if (selection.state) {
718
		selection.buf.move(_action);
719
		selection.buf.move(_action);
719
		SelectTool_onCanvasDraw();
720
		SelectTool_onCanvasDraw();
720
	}
721
	}
721
	else {
722
	else {
722
		image.move(_action);
723
		image.move(_action);
723
		DrawCanvas();
724
		DrawCanvas();
724
	}
725
	}
725
	actionsHistory.saveCurrentState();
726
	actionsHistory.saveCurrentState();
726
}
727
}
727
 
728
 
728
void EventCrop()
729
void EventCrop()
729
{
730
{
730
	if (selection.state) {
731
	if (selection.state) {
731
		EventSaveIconToFile();
732
		EventSaveIconToFile();
732
		image.create(selection.buf.rows, selection.buf.columns);
733
		image.create(selection.buf.rows, selection.buf.columns);
733
		selection.move_to_point(0,0);
734
		selection.move_to_point(0,0);
734
		selection.apply_to_image();
735
		selection.apply_to_image();
735
		selection.reset();
736
		selection.reset();
736
		actionsHistory.init();
737
		actionsHistory.init();
737
		DrawWindow();
738
		DrawWindow();
738
	}
739
	}
739
	else {
740
	else {
740
		notify(T_ERROR_CROP_TOOL);
741
		notify(T_ERROR_CROP_TOOL);
741
	}
742
	}
742
}
743
}
743
 
744
 
744
void EventShowImageMenu()
745
void EventShowImageMenu()
745
{
746
{
746
	open_lmenu(image_menu_btn.x, image_menu_btn.y + image_menu_btn.h, 
747
	open_lmenu(image_menu_btn.x, image_menu_btn.y + image_menu_btn.h, 
747
		MENU_TOP_LEFT, NULL, #image_menu_items);
748
		MENU_TOP_LEFT, NULL, #image_menu_items);
748
}
749
}
749
 
750
 
750
void EventShowEditMenu()
751
void EventShowEditMenu()
751
{
752
{
752
	open_lmenu(image_menu_btn.x, image_menu_btn.y + image_menu_btn.h, 
753
	open_lmenu(image_menu_btn.x, image_menu_btn.y + image_menu_btn.h, 
753
		MENU_TOP_LEFT, NULL, #edit_menu_items);
754
		MENU_TOP_LEFT, NULL, #edit_menu_items);
754
}
755
}
755
 
756
 
756
void EventCheckMenuItemSelected()
757
void EventCheckMenuItemSelected()
757
{
758
{
758
	switch(get_menu_click()) {
759
	switch(get_menu_click()) {
759
		case 1: 
760
		case 1: 
760
			EventCountColorsUsed();
761
			EventCountColorsUsed();
761
			break;
762
			break;
762
		case 2: 
763
		case 2: 
763
			EventReplaceImageColors(color1, color2);
764
			EventReplaceImageColors(color1, color2);
764
			break;
765
			break;
765
	}
766
	}
766
}
767
}
767
 
768
 
768
void EventCountColorsUsed()
769
void EventCountColorsUsed()
769
{
770
{
770
	char res_str[64];
771
	char res_str[64];
771
	int cur, prev;
772
	int cur, prev;
772
	int max = image.rows*image.columns;
773
	int max = image.rows*image.columns;
773
	int resi=0;
774
	int resi=0;
774
	bool unic;
775
	bool unic;
775
	for (cur=0; cur
776
	for (cur=0; cur
776
		unic = true;
777
		unic = true;
777
		for (prev=0; prev
778
		for (prev=0; prev
778
			if (image.mas[prev] == image.mas[cur]) {unic=false; break;}
779
			if (image.mas[prev] == image.mas[cur]) {unic=false; break;}
779
		}
780
		}
780
		if (unic) resi++;
781
		if (unic) resi++;
781
	}
782
	}
782
	notify( sprintf(#res_str, T_UNIC_COLORS_COUNT, resi) );
783
	notify( sprintf(#res_str, T_UNIC_COLORS_COUNT, resi) );
783
}
784
}
784
 
785
 
785
void EventReplaceImageColors(dword c1, c2)
786
void EventReplaceImageColors(dword c1, c2)
786
{
787
{
787
	int max = image.rows*image.columns;
788
	int max = image.rows*image.columns;
788
	int cur;
789
	int cur;
789
	for (cur=0; cur
790
	for (cur=0; cur
790
		if (image.mas[cur] == color1) image.mas[cur] = color2;
791
		if (image.mas[cur] == color1) image.mas[cur] = color2;
791
	}
792
	}
792
}
793
}
793
 
794
 
794
void EventCanvasResize()
795
void EventCanvasResize()
795
{
796
{
796
	notify("Sorry, not implemented yet.");
797
	notify("Sorry, not implemented yet.");
797
}
798
}
798
 
799
 
799
void EventMoveLeft() { EventMove(MOVE_LEFT); }
800
void EventMoveLeft() { EventMove(MOVE_LEFT); }
800
void EventMoveRight() { EventMove(MOVE_RIGHT); }
801
void EventMoveRight() { EventMove(MOVE_RIGHT); }
801
void EventMoveUp() { EventMove(MOVE_UP); }
802
void EventMoveUp() { EventMove(MOVE_UP); }
802
void EventMoveDown() { EventMove(MOVE_DOWN); }
803
void EventMoveDown() { EventMove(MOVE_DOWN); }
803
void EventFlipHor() { EventMove(FLIP_HOR); }
804
void EventFlipHor() { EventMove(FLIP_HOR); }
804
void EventFlipVer() { EventMove(FLIP_VER); }
805
void EventFlipVer() { EventMove(FLIP_VER); }
805
void EventRotateLeft() { EventMove(ROTATE_LEFT); }
806
void EventRotateLeft() { EventMove(ROTATE_LEFT); }
806
void EventRotateRight() { EventMove(ROTATE_RIGHT); }
807
void EventRotateRight() { EventMove(ROTATE_RIGHT); }
807
 
808
 
808
void EventSelectToolPencil() { setCurrentTool(TOOL_PENCIL); }
809
void EventSelectToolPencil() { setCurrentTool(TOOL_PENCIL); }
809
void EventSelectToolPick() { setCurrentTool(TOOL_PIPETTE); }
810
void EventSelectToolPick() { setCurrentTool(TOOL_PIPETTE); }
810
void EventSelectToolFill() { setCurrentTool(TOOL_FILL); }
811
void EventSelectToolFill() { setCurrentTool(TOOL_FILL); }
811
void EventSelectToolLine() { setCurrentTool(TOOL_LINE); }
812
void EventSelectToolLine() { setCurrentTool(TOOL_LINE); }
812
void EventSelectToolRect() { setCurrentTool(TOOL_RECT); }
813
void EventSelectToolRect() { setCurrentTool(TOOL_RECT); }
813
void EventSelectToolBar() { setCurrentTool(TOOL_BAR); }
814
void EventSelectToolBar() { setCurrentTool(TOOL_BAR); }
814
void EventSelectToolSelect() { setCurrentTool(TOOL_SELECT); }
815
void EventSelectToolSelect() { setCurrentTool(TOOL_SELECT); }
815
void EventSelectToolScrCopy() { setCurrentTool(TOOL_SCREEN_COPY);  }
816
void EventSelectToolScrCopy() { setCurrentTool(TOOL_SCREEN_COPY);  }
816
 
817
 
817
char test_icon_stak22[4096];
818
char test_icon_stak22[4096];
818
 
819
 
819
stop:
820
stop:
820
 
821
 
821
char test_icon_stak[4096];
822
char test_icon_stak[4096];