Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
3399 leency 1
//Leency 2008-2013
2
 
3848 punk_joker 3
#ifdef LANG_RUS
4225 punk_joker 4
	?define T_DEVICES "“бва®©бвў "
5
	?define T_ACTIONS "„Ґ©бвўЁп"
6
	char *actions[] = {
7
		57, "Ќ®ўл© д ©«", "F7",
8
		56, "Ќ®ў п Ї ЇЄ ", "F6",
9
		60, "Ќ бва®©ЄЁ", "F10",
10
		0,0,0
11
	};
5576 pavelyakov 12
	?define T_PROG "Џа®Ја ¬¬л "
13
	?define T_SYS  "‘Ёб⥬  "
14
	?define T_UNC  "ЌҐЁ§ўҐбв­® "
15
	?define T_CD   "CD-ROM "
16
	?define T_FD   "„ЁбЄҐв  "
17
	?define T_HD   "†ҐбвЄЁ© ¤ЁбЄ "
18
	?define T_SATA "SATA ¤ЁбЄ "
19
	?define T_USB  "USB ¤ЁбЄ "
20
	?define T_RAM  "RAM ¤ЁбЄ "
3848 punk_joker 21
#else
4225 punk_joker 22
	?define T_DEVICES "Devices"
23
	?define T_ACTIONS "Actions"
24
	char *actions[] = {
25
		57, "New file", "F7",
26
		56, "New folder", "F6",
5428 leency 27
		60, "Settings", "F10",
4225 punk_joker 28
		0,0,0
29
	};
5576 pavelyakov 30
	?define T_PROG "Programs "
31
	?define T_SYS  "System "
32
	?define T_UNC  "Unknown "
33
	?define T_CD   "CD-ROM "
34
	?define T_FD   "Floppy disk "
35
	?define T_HD   "Hard disk "
36
	?define T_SATA "SATA disk"
37
	?define T_USB  "USB disk"
38
	?define T_RAM  "RAM disk"
3848 punk_joker 39
#endif
40
 
6034 leency 41
struct _SystemDiscs
42
{
43
	collection list;
44
	void Get();
45
	void Draw();
46
	void Click();
47
} SystemDiscs;
3848 punk_joker 48
 
6034 leency 49
 
50
void GetDiskIconAndName(char disk_first_letter, dword dev_icon, disc_name)
3363 leency 51
{
6034 leency 52
	switch(disk_first_letter)
53
	{
54
		case 'k':
55
			ESBYTE[dev_icon]=0;
56
			strcpy(disc_name, T_PROG);
57
			break;
58
		case 'r':
59
			ESBYTE[dev_icon]=0;
60
			strcpy(disc_name, T_SYS);
61
			break;
62
		case 'c':
63
			ESBYTE[dev_icon]=1;
64
			strcpy(disc_name, T_CD);
65
			break;
66
		case 'f':
67
			ESBYTE[dev_icon]=2;
68
			strcpy(disc_name, T_FD);
69
			break;
70
		case 'h':
71
		case 'b':
72
			ESBYTE[dev_icon]=3;
73
			strcpy(disc_name, T_HD);
74
			break;
75
		case 's':
76
			ESBYTE[dev_icon]=3;
77
			strcpy(disc_name, T_SATA);
78
			break;
79
		case 'u':
80
			ESBYTE[dev_icon]=5;
81
			strcpy(disc_name, T_USB);
82
			break;
83
		case 't':
84
			ESBYTE[dev_icon]=4;
85
			strcpy(disc_name, T_RAM);
86
			break;
87
		default:
88
			ESBYTE[dev_icon]=3;
89
			strcpy(disc_name, T_UNC);
90
	}
3363 leency 91
}
92
 
6034 leency 93
void _SystemDiscs::Get()
3363 leency 94
{
5150 leency 95
	char dev_name[10], sys_discs[10];
5960 leency 96
	int i1, j1, dev_num, dev_disc_num;
5734 leency 97
	dword temp_file_count, tempbuf;
5960 leency 98
	dword devbuf;
5734 leency 99
 
6034 leency 100
	list.drop();
5960 leency 101
	devbuf = malloc(10000);
3363 leency 102
	ReadDir(19, devbuf, "/");
103
	dev_num = EBX;
104
	for (i1=0; i1
105
	{
6635 leency 106
		sprintf(#dev_name,"/%s",i1*304+ devbuf+72);
3363 leency 107
		Open_Dir(#dev_name, ONLY_OPEN);
3434 leency 108
		dev_disc_num = files.count;
3363 leency 109
		for (j1=0; j1
110
		{
6635 leency 111
			sprintf(#sys_discs,"%s/%s",#dev_name,j1*304+ buf+72);
6034 leency 112
			list.add(#sys_discs);
3363 leency 113
		}
6635 leency 114
		if (!strcmp(#sys_discs, "/rd/1"))
3956 leency 115
		{
6583 leency 116
			GetDir(#tempbuf, #temp_file_count, "/kolibrios", DIRS_ONLYREAL);
6635 leency 117
			if (temp_file_count) list.add("/kolibrios");
5734 leency 118
			free(tempbuf);
4225 punk_joker 119
		}
3363 leency 120
	}
5960 leency 121
	free(devbuf);
3363 leency 122
}
123
 
6034 leency 124
void _SystemDiscs::Draw()
3363 leency 125
{
5753 leency 126
	char dev_name[15], disc_name[100], i, dev_icon, is_active, name_len;
6034 leency 127
	int draw_y, draw_x, draw_h;
3363 leency 128
 
5960 leency 129
	for (i=0; i<30; i++) DeleteButton(100+i);
6034 leency 130
 
131
	if ( two_panels) { draw_y = 41; draw_x =  2; draw_h = 21; }
132
	if (!two_panels) { draw_y = 74; draw_x = 17; draw_h = 16; }
133
 
134
	for (i=0;i
3363 leency 135
	{
6034 leency 136
		strcpy(#dev_name, list.get(i));
137
		GetDiskIconAndName(dev_name[1], #dev_icon, #disc_name);
138
		if (strstr(#path, #dev_name)) is_active=true; else is_active=false;
139
		if (two_panels)
3363 leency 140
		{
6034 leency 141
			name_len = strlen(#dev_name)-1*8;
142
			DrawBar(draw_x, draw_y, name_len + 31, draw_h, 0xFFFFFF);
143
			DefineButton(draw_x+2, draw_y, name_len + 27, draw_h-1, 100+i+BT_HIDE,0xFFFFFF);
144
			_PutImage(draw_x + 5, draw_y+2, 18,17, is_active*6+dev_icon*17*18*3+#devices);
145
			WriteText(draw_x + 24, draw_y+3, 10110000b, 0, #dev_name+1);
146
			draw_x += name_len + 31;
147
			if (draw_x>=Form.width-35) && (Form.width) {
148
				DrawBar(draw_x, draw_y, Form.cwidth - draw_x - 2, draw_h, 0xFFFFFF);
149
				draw_x = 2;
150
				draw_y += draw_h;
151
			}
3363 leency 152
		}
6034 leency 153
		else
5633 leency 154
		{
6034 leency 155
			DrawBar(draw_x,draw_y,6,draw_h+1,0xFFFFFF);
156
			DrawBar(draw_x+6+18,draw_y,160-6-18,draw_h+1,0xFFFFFF);
157
			DefineButton(draw_x,draw_y,159,16,100+i+BT_HIDE,0xFFFFFF);
5698 leency 158
			if (show_dev_name)
159
			{
160
				strcat(#disc_name, #dev_name);
6034 leency 161
				if (is_active) WriteText(draw_x+30,draw_y+5,0x80,0x555555,#disc_name);
162
				WriteText(draw_x+29,draw_y+5,0x80,0,#disc_name);
5698 leency 163
			}
164
			else
165
			{
6034 leency 166
				if (is_active) WriteText(draw_x+30,draw_y+5,0x80,0x555555,#dev_name);
167
				WriteText(draw_x+29,draw_y+5,0x80,0,#dev_name);
5698 leency 168
			}
6034 leency 169
			_PutImage(draw_x+6,draw_y, 18,17, is_active*6+dev_icon*17*18*3+#devices);
170
			draw_y += draw_h;
5633 leency 171
		}
3363 leency 172
	}
5703 leency 173
	if (two_panels)
174
	{
6034 leency 175
		DrawBar(draw_x, draw_y, Form.cwidth - draw_x - 2, draw_h, 0xFFFFFF);
176
		DefineButton(Form.cwidth - 23, draw_y+2, 17,16, 60+BT_HIDE, 0xCCCccc);
177
		_PutImage(Form.cwidth - 21, draw_y+4, 14,13, 2*14*13*3+#factions);
178
		files.y = draw_y + draw_h + 17;
5703 leency 179
	}
3363 leency 180
}
181
 
6034 leency 182
void _SystemDiscs::Click(int n)
183
{
184
	strcpy(#path, list.get(n));
185
	files.KeyHome();
186
	Open_Dir(#path,WITH_REDRAW);
187
}
5698 leency 188
 
6034 leency 189
 
190
 
191
void DrawDeviceAndActionsLeftPanel()
192
{
193
	Tip(56, T_DEVICES, 55, "=");
194
	SystemDiscs.Draw();
195
	ActionsDraw();
196
	DrawLeftPanelBg();
197
}
198
 
199
void Tip(int y, dword caption, id, arrow)
200
{
201
	DrawBar(17,y,160,1,0xEFEDEE);
202
	DrawFilledBar(17, y+1, 160, 16);
6191 leency 203
	WriteText(25,y+5,0x80,0x000000,caption);
6034 leency 204
	if (id) DefineButton(159,y+1,16,16,id+BT_HIDE+BT_NOFRAME,0); //arrow button
6191 leency 205
	WriteText(165,y+5,0x80,0x000000,arrow); //arrow
206
	DrawBar(17,y+17,160,1,col_graph);
6034 leency 207
}
208
 
3434 leency 209
void ActionsDraw()
3363 leency 210
{
6034 leency 211
	int actions_y= SystemDiscs.list.count*16+108, lineh=16;
3848 punk_joker 212
	Tip(actions_y-18, T_ACTIONS, 77, ""); //заголовок
3434 leency 213
	for (i=0; actions[i*3]!=0; i++, actions_y+=lineh)
3363 leency 214
	{
3434 leency 215
		DrawBar(17,actions_y,160,lineh,0xFFFFFF); //белое
216
		DefineButton(17,actions_y,159,lineh,actions[i*3]+BT_HIDE,0xE4DFE1);
217
		WriteText(45,actions_y+4,0x80,0,actions[i*3+1]);
218
		WriteText(-strlen(actions[i*3+2])*6+170,actions_y+4,0x80,0x999999,actions[i*3+2]);
5149 leency 219
		_PutImage(23,actions_y+2, 14,13, i*14*13*3+#factions);
3363 leency 220
	}
221
}
222
 
5441 leency 223
void DrawLeftPanelBg()
3363 leency 224
{
6034 leency 225
	int actions_y = SystemDiscs.list.count*16;
3434 leency 226
	int start_y = actions_y+156;
5743 leency 227
	int onTop1;
3363 leency 228
	DrawBar(2,41,190,15,col_lpanel);		      //синий прямоугольник - над девайсами
229
	DrawBar(17,actions_y+75,160,15,col_lpanel); //синий прямоугольник - под девайсами
3877 leency 230
	PutShadow(17,actions_y+75,160,1,1,3);
3434 leency 231
	PutShadow(18,actions_y+75+1,158,1,1,1);
3363 leency 232
	DrawBar(2,56,15,actions_y+103,col_lpanel);	          //синий прямоугольник - слева
233
	DrawBar(177,56,15,actions_y+103,col_lpanel);            //синий прямоугольник - справа
6564 leency 234
	onTop1 = Form.cheight-start_y-2 - status_bar_h;
5743 leency 235
	if (onTop1 < 268)
236
	{
237
		PutPaletteImage(#blue_hl, 190, onTop1, 2, start_y, 8, #blue_hl_pal);
238
	}
3363 leency 239
	else
240
	{
6583 leency 241
		DrawBar(2,start_y,190, onTop1-268+status_bar_h, col_lpanel);
5743 leency 242
		PutPaletteImage(#blue_hl, 190, 268, 2, Form.cheight-270, 8, #blue_hl_pal);
3363 leency 243
	}
3877 leency 244
	PutShadow(17,start_y,160,1,1,3);
3434 leency 245
	PutShadow(18,start_y+1,158,1,1,1);
5698 leency 246
}