Subversion Repositories Kolibri OS

Rev

Rev 7444 | Rev 7450 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7444 Rev 7447
Line 8... Line 8...
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"
Line 12... Line 13...
12
#include "../lib/cursor.h"
13
#include "../lib/list_box.h"
13
 
14
 
Line 14... Line 15...
14
#include "../lib/obj/libimg.h"
15
#include "../lib/obj/libimg.h"
Line 28... Line 29...
28
//                       DATA                        //
29
//                       DATA                        //
29
//                                                   //
30
//                                                   //
30
//===================================================//
31
//===================================================//
Line 31... Line 32...
31
 
32
 
32
#ifdef LANG_RUS
33
#ifdef LANG_RUS
33
#define T_NOTIFY_OPEN "'IconEdit
34
char image_menu_items[] = 
34
‚ ¤ ­­ë© ¬®¬¥­â IconEdit ¬®¦¥â ®âªà뢠âì ⮫쪮 ¨ª®­ª¨, ᮧ¤ ­­ë¥ ¢ á ¬®¬ । ªâ®à¥.
35
"Š®«¨ç¥á⢮ ¨á¯®«ì§®¢ ­­ëå 梥⮢
-
 
36
‡ ¬¥­¨âì ¢á¥ æ¢¥â  1 ­  2";
35
…᫨ ­ã¦­® ®âªàëâì ¤à㣮¥ ¨§®¡à ¦¥­¨¥, ¢®á¯®«ì§ã©â¥áì ¨­áâà㬥­â®¬ <”®â® ¯¯ à â>
37
?define T_MENU_IMAGE "ˆª®­ª "
-
 
38
?define T_TEST_ICON "à®¢¥à¨âì ¨ª®­ªã"
36
¤«ï § å¢ â  ª à⨭ª¨ á íªà ­ .' -Wt"
39
?define T_TITLE "Icon Editor 0.59 Alpha"
-
 
40
#else
-
 
41
char image_menu_items[] = 
-
 
42
"Count colors used
37
#else
43
Replace all colors equal to 1 by 2";
38
#define T_NOTIFY_OPEN "'IconEdit
44
?define T_MENU_IMAGE "Icon"
39
You can open only files created in IconEdit for now!
45
?define T_TEST_ICON "Test Icon"
40
In other case please use  tool to get an image from screen.' -Wt"
46
?define T_TITLE "¥¤ ªâ®à ¨ª®­®ª 0.59 Alpha"
Line 41... Line -...
41
#endif
-
 
Line 42... Line 47...
42
 
47
#endif
43
 
48
 
44
#define T_TITLE "Icon Editor 0.58 Alpha"
49
 
Line 55... Line 60...
55
#define TO_CANVAS_Y(yval) yval - canvas.y/zoom.value
60
#define TO_CANVAS_Y(yval) yval - canvas.y/zoom.value
Line 56... Line 61...
56
 
61
 
57
block canvas = { NULL, NULL, NULL, NULL };
62
block canvas = { NULL, NULL, NULL, NULL };
58
block wrapper = { LEFTBAR_W, TOPBAR_H, NULL, NULL };
63
block wrapper = { LEFTBAR_W, TOPBAR_H, NULL, NULL };
-
 
64
block right_bar = { NULL, 10+TOPBAR_H, RIGHT_BAR_W+10, NULL };
Line 59... Line 65...
59
block right_bar = { NULL, 10+TOPBAR_H, RIGHT_BAR_W+10, NULL };
65
block image_menu_btn = { NULL, 4, NULL, 22 };
60
 
66
 
61
dword linear_gradient[RIGHT_BAR_W];
67
dword linear_gradient[RIGHT_BAR_W];
62
block b_color_gradient = {NULL, 40+TOPBAR_H, RIGHT_BAR_W, 25};
68
block b_color_gradient = {NULL, 40+TOPBAR_H, RIGHT_BAR_W, 25};
Line 98... Line 104...
98
	BTN_SCREEN_COPY,
104
	BTN_SCREEN_COPY,
99
	BTN_ZOOM_IN,
105
	BTN_ZOOM_IN,
100
	BTN_ZOOM_OUT,
106
	BTN_ZOOM_OUT,
101
	BTN_CANVAS_RESIZE,
107
	BTN_CANVAS_RESIZE,
102
	BTN_CROP,
108
	BTN_CROP,
-
 
109
	BTN_IMAGE_MENU,
103
	BTNS_PALETTE_COLOR_MAS = 100,
110
	BTNS_PALETTE_COLOR_MAS = 100,
104
	BTNS_LAST_USED_COLORS = 400
111
	BTNS_LAST_USED_COLORS = 400
105
};
112
};
Line 106... Line 113...
106
 
113
 
Line 331... Line 338...
331
					notify("Sorry, not implemented yet.");
338
					notify("Sorry, not implemented yet.");
332
					break;
339
					break;
333
				case BTN_CROP:
340
				case BTN_CROP:
334
					EventCrop();
341
					EventCrop();
335
					break;
342
					break;
-
 
343
				case BTN_IMAGE_MENU:
-
 
344
					EventShowImageMenu();
-
 
345
					break;
336
				case CLOSE_BTN:
346
				case CLOSE_BTN:
337
					EventExitIconEdit();
347
					EventExitIconEdit();
338
					break;
348
					break;
339
			}
349
			}
340
			break;
350
			break;
Line 398... Line 408...
398
 
408
 
Line 399... Line 409...
399
			break;
409
			break;
400
		 
410
		 
-
 
411
		case evReDraw:
401
		case evReDraw:
412
			Window_CanvasReSize.thread_exists();
402
			Window_CanvasReSize.thread_exists();
413
			EventCheckMenuItemSelected();
403
			DrawWindow();
414
			DrawWindow();
404
			break;
415
			break;
Line 414... Line 425...
414
	PutPixel(_x+21,4+21,system.color.work);
425
	PutPixel(_x+21,4+21,system.color.work);
415
	DefineHiddenButton(_x, 4, 21, 21, _id);
426
	DefineHiddenButton(_x, 4, 21, 21, _id);
416
	img_draw stdcall(top_icons.image, _x+3, 7, 16, 16, 0, _icon_n*16);
427
	img_draw stdcall(top_icons.image, _x+3, 7, 16, 16, 0, _icon_n*16);
417
}
428
}
Line -... Line 429...
-
 
429
 
-
 
430
int DrawFlatPanelButton(dword _id, _x, _y, _text)
-
 
431
{
-
 
432
	#define P 10
-
 
433
	int w = strlen(_text)*6 + P + P;
-
 
434
	DrawBar(_x, _y, w, 22, semi_white);
-
 
435
	PutPixel(_x,_y,system.color.work);
-
 
436
	PutPixel(_x,_y+21,system.color.work);
-
 
437
	PutPixel(_x+w-1,_y,system.color.work);
-
 
438
	PutPixel(_x+w-1,_y+21,system.color.work);
-
 
439
	DefineHiddenButton(_x, _y, w, 21, _id);
-
 
440
	WriteText(_x+P, _y+7, 0x80, system.color.work_text, _text);
-
 
441
	return w;
-
 
442
}
418
 
443
 
419
void DrawLeftPanelButton(dword _id, _y, _icon_n)
444
void DrawLeftPanelButton(dword _id, _y, _icon_n)
420
{
445
{
421
	int x = 5;
446
	int x = 5;
422
	DrawRectangle(x, _y, 22-1, 22-1, system.color.work);
447
	DrawRectangle(x, _y, 22-1, 22-1, system.color.work);
Line 474... Line 499...
474
 
499
 
Line 475... Line 500...
475
	DrawTopPanelButton(BTN_TEST_ICON,  tx.inc(GAP+BLOCK_SPACE), 12);
500
	DrawTopPanelButton(BTN_TEST_ICON,  tx.inc(GAP+BLOCK_SPACE), 12);
Line -... Line 501...
-
 
501
 
-
 
502
	DrawTopPanelButton(BTN_CROP,  tx.inc(GAP+BLOCK_SPACE), 46);
-
 
503
 
-
 
504
	image_menu_btn.x = tx.n;
476
 
505
	image_menu_btn.w = DrawFlatPanelButton(BTN_IMAGE_MENU, image_menu_btn.x, image_menu_btn.y, T_MENU_IMAGE);
Line 477... Line 506...
477
	DrawTopPanelButton(BTN_CROP,  tx.inc(GAP+BLOCK_SPACE), 46);
506
	//tx.inc(image_menu_btn.w + BLOCK_SPACE);
478
	
507
	
Line 711... Line 740...
711
			if (key_scancode == SCAN_CODE_ESC) ExitProcess();
740
			if (key_scancode == SCAN_CODE_ESC) ExitProcess();
712
			break;
741
			break;
Line 713... Line 742...
713
		 
742
		 
714
		case evReDraw:
743
		case evReDraw:
715
			DefineAndDrawWindow(Form.left+100, Form.top+100, preview_size*2+9,
744
			DefineAndDrawWindow(Form.left+100, Form.top+100, preview_size*2+9,
716
				preview_size*2+skin_height+4, 0x74, NULL, "Test Icon", 0);
745
				preview_size*2+skin_height+4, 0x74, NULL, T_TEST_ICON, 0);
717
			DrawImageWithBg(0, 0, 0x000000);
746
			DrawImageWithBg(0, 0, 0x000000);
718
			DrawImageWithBg(1, 0, 0xFFFfff);
747
			DrawImageWithBg(1, 0, 0xFFFfff);
719
			DrawImageWithBg(0, 1, GetPixelColorFromScreen(0, 0));
748
			DrawImageWithBg(0, 1, GetPixelColorFromScreen(0, 0));
720
			DrawImageWithBg(1, 1, system.color.work);
749
			DrawImageWithBg(1, 1, system.color.work);
Line 734... Line 763...
734
	Window_CanvasReSize.create();
763
	Window_CanvasReSize.create();
735
}
764
}
Line 736... Line 765...
736
 
765
 
737
void EventOpenIcon()
766
void EventOpenIcon()
738
{
-
 
739
	//notify(T_NOTIFY_OPEN);
767
{
740
	RunProgram("/sys/lod", sprintf(#param, "*png* %s",#program_path));
768
	RunProgram("/sys/lod", sprintf(#param, "*png* %s",#program_path));
Line 741... Line 769...
741
}
769
}
742
 
770
 
Line 816... Line 844...
816
		selection.reset();
844
		selection.reset();
817
		actionsHistory.init();
845
		actionsHistory.init();
818
		DrawWindow();
846
		DrawWindow();
819
	}
847
	}
820
	else {
848
	else {
821
		notify("'You need to select something before usnig crop tool.' -W");
849
		notify("'You need to select something before using crop tool.' -W");
-
 
850
	}
-
 
851
}
-
 
852
 
-
 
853
void EventShowImageMenu()
-
 
854
{
-
 
855
	menu.selected = 0;
-
 
856
	menu.show(Form.left+5 + image_menu_btn.x, 
-
 
857
		Form.top+skin_height + image_menu_btn.y + image_menu_btn.h,
-
 
858
		240, 
-
 
859
		#image_menu_items, 
-
 
860
		20);
-
 
861
}
-
 
862
 
-
 
863
void EventCheckMenuItemSelected()
-
 
864
{
-
 
865
	if (menu.list.cur_y) {
-
 
866
		if (20 == menu.list.cur_y) EventCountColorsUsed();
-
 
867
		if (21 == menu.list.cur_y) EventReplaceImageColors(color1, color2);
-
 
868
		menu.list.cur_y = 0;
-
 
869
	}
-
 
870
}
-
 
871
 
-
 
872
void EventCountColorsUsed()
-
 
873
{
-
 
874
	char res_str[64];
-
 
875
	int cur, prev;
-
 
876
	int max = image.rows*image.columns;
-
 
877
	int resi=0;
-
 
878
	bool unic;
-
 
879
	for (cur=0; cur
-
 
880
		unic = true;
-
 
881
		for (prev=0; prev
-
 
882
			if (image.mas[prev] == image.mas[cur]) {unic=false; break;}
-
 
883
		}
-
 
884
		if (unic) resi++;
-
 
885
	}
-
 
886
	notify( sprintf(#res_str, "'Image has %i unique colors.' -I", resi) );
-
 
887
}
-
 
888
 
-
 
889
void EventReplaceImageColors(dword c1, c2)
-
 
890
{
-
 
891
	int max = image.rows*image.columns;
-
 
892
	int cur;
-
 
893
	for (cur=0; cur
-
 
894
		if (image.mas[cur] == color1) image.mas[cur] = color2;
822
	}
895
	}
823
}
896
}
Line 824... Line 897...
824
 
897