Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
4042 leency 1
//Leency 2008-2013
2
 
3
//pay attension: >200 this is only file actions, not supported by folders
4
#ifdef LANG_RUS
5
char *file_captions[] = {
6
	"Открыть",               "Enter",100,
7
	"Открыть с помощью...",  "CrlEnt",201,
8
	"Открыть как текст",     "F3",202,
9
	"Открыть как HEX",       "F4",203,
10
	"Копировать",            "Crl+C",104,
11
	"Вырезать",              "Crl+X",105,
12
	"Вставить",              "Crl+V",106,
13
	"Переименовать",         "F2",207,
14
	"Удалить",               "Del",108,
15
	"Обновить папку",        "F5",109,
5447 punk_joker 16
	"Свойства",              "",110,
4042 leency 17
	0, 0, 0};
18
#elif LANG_EST
19
char *file_captions[] = {
20
	"Ava",            "Enter",100,
21
	"Ava ...",        "CrlEnt",201,
22
	"Vaata tekstina", "F3",202,
23
	"Vaata HEX",      "F4",203,
24
	"Kopeeri",        "Crl+C",104,
25
	"Lїika",          "Crl+X",105,
26
	"Aseta",          "Crl+V",106,
27
	"Nimeta №mber",   "F2",207,
28
	"Kustuta",        "Del",108,
29
	"Vфrskenda",      "F5",109,
5447 punk_joker 30
	"Properties",       "",110,
4042 leency 31
	0, 0, 0};
32
#else
33
char *file_captions[] = {
34
	"Open",          "Enter",100,
35
	"Open with...",  "CrlEnt",201,
36
	"View as text",  "F3",202,
37
	"View as HEX",   "F4",203,
38
	"Copy",          "Crl+C",104,
39
	"Cut",           "Crl+X",105,
40
	"Paste",         "Crl+V",106,
41
	"Rename",        "F2",207,
42
	"Delete",        "Del",108,
43
	"Refresh",       "F5",109,
5447 punk_joker 44
	"Properties",       "",110,
4042 leency 45
	0, 0, 0};
46
#endif
47
 
6973 leency 48
llist rbmenu;
4072 leency 49
int cur_action_buf;
4042 leency 50
 
51
void FileMenu()
52
{
53
	proc_info MenuForm;
4072 leency 54
	int index;
4042 leency 55
 
6973 leency 56
	rbmenu.ClearList();
57
	rbmenu.SetFont(6, 9, 0x80);
58
	rbmenu.SetSizes(0,0,10,0,18);
4042 leency 59
	for (index=0; file_captions[index]!=0; index+=3)
60
	{
61
		if (itdir) && (file_captions[index+2]>=200) continue;
6973 leency 62
		if (selected_count > 0) && (file_captions[index+2]==100) continue; //do not show "open" for several files
63
		if (strlen(file_captions[index])>rbmenu.w) rbmenu.w = strlen(file_captions[index]);
64
		rbmenu.count++;
65
		rbmenu.visible++;
4042 leency 66
	}
6973 leency 67
	rbmenu.w = rbmenu.w + 3 * rbmenu.font_w + 50;
68
	rbmenu.h = rbmenu.count * rbmenu.item_h;
4042 leency 69
	SetEventMask(100111b);
70
	goto _MENU_DRAW;
71
 
72
	loop() switch(WaitEvent())
73
	{
74
		case evMouse:
5640 pavelyakov 75
				mouse.get();
5576 pavelyakov 76
				if (!CheckActiveProcess(MenuForm.ID)){ cmd_free=1; ExitProcess();}
6973 leency 77
				else if (mouse.move)&&(rbmenu.ProcessMouse(mouse.x, mouse.y)) MenuListRedraw();
5640 pavelyakov 78
				else if (mouse.key&MOUSE_LEFT)&&(mouse.up) {action_buf = cur_action_buf; cmd_free=1; ExitProcess(); }
5576 pavelyakov 79
		break;
4042 leency 80
 
81
		case evKey:
5707 leency 82
				GetKeys();
5811 leency 83
				if (key_scancode == SCAN_CODE_ESC) {cmd_free=1;ExitProcess();}
84
				if (key_scancode == SCAN_CODE_ENTER) {action_buf = cur_action_buf; cmd_free=1; ExitProcess(); }
6973 leency 85
				if (rbmenu.ProcessKey(key_scancode)) MenuListRedraw();
4042 leency 86
				break;
87
 
88
		case evReDraw: _MENU_DRAW:
6973 leency 89
				if (menu_call_mouse) DefineAndDrawWindow(mouse.x+Form.left+5, mouse.y+Form.top+GetSkinHeight(),rbmenu.w+3,rbmenu.h+6,0x01, 0, 0, 0x01fffFFF);
90
				else DefineAndDrawWindow(Form.left+files.x+15, files.item_h*files.cur_y+files.y+Form.top+30,rbmenu.w+3,rbmenu.h+6,0x01, 0, 0, 0x01fffFFF);
4042 leency 91
				GetProcessInfo(#MenuForm, SelfInfo);
6973 leency 92
				DrawRectangle(0,0,rbmenu.w+1,rbmenu.h+2,col_graph);
93
				DrawBar(1,1,rbmenu.w,1,0xFFFfff);
94
				DrawPopupShadow(1,1,rbmenu.w,rbmenu.h,0);
4072 leency 95
				MenuListRedraw();
96
	}
97
}
4042 leency 98
 
4072 leency 99
void MenuListRedraw()
100
{
101
	int start_y=0;
102
	int index;
103
	for (index=0; file_captions[index*3]!=0; index++)
104
	{
105
		if ((itdir) && (file_captions[index*3+2]>=200)) continue;
6973 leency 106
		if (selected_count > 0) && (file_captions[index+2]==100) continue;
107
		DrawBar(1,start_y+2,1,rbmenu.item_h,0xFFFfff);
108
		if (start_y/rbmenu.item_h==rbmenu.cur_y)
4072 leency 109
		{
110
			cur_action_buf = file_captions[index*3+2];
6973 leency 111
			DrawBar(2,start_y+2,rbmenu.w-1,rbmenu.item_h,0xFFFfff);
4072 leency 112
		}
113
		else
114
		{
6973 leency 115
			DrawBar(2,start_y+2,rbmenu.w-1,rbmenu.item_h,col_work);
116
			WriteText(8,start_y+rbmenu.text_y+4,rbmenu.font_type,0xf2f2f2,file_captions[index*3]);
4072 leency 117
		}
6973 leency 118
		WriteText(7, start_y + rbmenu.text_y + 3, rbmenu.font_type, 0, file_captions[index*3]);
119
		WriteText(-strlen(file_captions[index*3+1])-1*rbmenu.font_w + rbmenu.w, start_y + rbmenu.text_y + 3, rbmenu.font_type, 0x888888, file_captions[index*3+1]);
120
		start_y+=rbmenu.item_h;
4072 leency 121
	}
4042 leency 122
}