Subversion Repositories Kolibri OS

Rev

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

Rev 7398 Rev 7422
Line 30... Line 30...
30
//images
30
//images
31
#include "imgs/left_p.txt"
31
#include "imgs/left_p.txt"
Line 32... Line 32...
32
 
32
 
33
//Button IDs
33
//Button IDs
-
 
34
enum {
34
enum {
35
	PATH_BTN = 10,
35
	POPUP_BTN1 = 201,
36
	POPUP_BTN1 = 201,
36
	POPUP_BTN2 = 202,
37
	POPUP_BTN2 = 202,
37
	BREADCRUMB_ID = 300
38
	BREADCRUMB_ID = 300
Line 49... Line 50...
49
	ONLY_SHOW, 
50
	ONLY_SHOW, 
50
	WITH_REDRAW, 
51
	WITH_REDRAW, 
51
	ONLY_OPEN
52
	ONLY_OPEN
52
};
53
};
Line 53... Line 54...
53
 
54
 
Line 54... Line 55...
54
dword col_padding, col_selec, col_lpanel, col_work, col_graph, col_list_line=0xDDD7CF;
55
dword col_padding=0, col_selec, col_lpanel, col_work, col_graph, col_list_line=0xDDD7CF;
Line 55... Line 56...
55
 
56
 
56
int toolbar_buttons_x[7]={9,46,85,134,167,203};
57
int toolbar_buttons_x[7]={9,46,85,134,167,203};
Line 92... Line 93...
92
 
93
 
Line 93... Line 94...
93
dword menu_stak,about_stak,properties_stak,settings_stak,copy_stak,delete_stak;
94
dword menu_stak,about_stak,properties_stak,settings_stak,copy_stak,delete_stak;
94
 
95
 
95
proc_info Form;
-
 
96
int sc_slider_h;
96
proc_info Form;
97
int j, i;
97
int sc_slider_h;
Line 98... Line 98...
98
int action_buf;
98
int action_buf;
99
int rand_n;
99
int rand_n;
Line 131... Line 131...
131
#include "include\properties.h"
131
#include "include\properties.h"
132
#include "include\breadcrumbs.h"
132
#include "include\breadcrumbs.h"
Line 133... Line 133...
133
 
133
 
134
void main() 
134
void main() 
135
{
-
 
136
	bool update_files_list = false;
-
 
137
	dword files_count = 0;
-
 
138
	dword countPathFile = 0;
-
 
139
	dword countPathFile2 = 0;
-
 
140
	dword files_y = 0;
-
 
141
	dword countDisk = 0;
135
{
142
	dword id;
-
 
143
	dword devbuf;
136
	dword id;
144
	byte count_sl = 0;
137
	byte count_sl = 0;
145
	signed x_old, y_old, dif_x, dif_y, adif_x, adif_y;
138
	signed x_old, y_old, dif_x, dif_y, adif_x, adif_y;
146
	char stats;
139
	char stats;
Line 147... Line -...
147
	rand_n = random(40);
-
 
148
 
-
 
149
	devbuf = malloc(10000);
140
	rand_n = random(40);
150
	
141
 
151
	load_dll(boxlib, #box_lib_init,0);
142
	load_dll(boxlib, #box_lib_init,0);
152
	load_dll(libini, #lib_init,1);
143
	load_dll(libini, #lib_init,1);
Line 169... Line 160...
169
		strcpy(#file_name, #param + strrchr(#param, '/'));
160
		strcpy(#file_name, #param + strrchr(#param, '/'));
170
		properties_dialog();
161
		properties_dialog();
171
		ExitProcess();	
162
		ExitProcess();	
172
	}
163
	}
Line -... Line 164...
-
 
164
 
-
 
165
	ESBYTE[0] = NULL;
173
 
166
 
174
	if (param)
167
	if (param)
175
	{
168
	{
Line 176... Line 169...
176
		if (strlen(#param)>1) && (param[strlen(#param)-1]=='/') param[strlen(#param)-1]=NULL; //no "/" at the end
169
		if (strlen(#param)>1) && (param[strlen(#param)-1]=='/') param[strlen(#param)-1]=NULL; //no "/" at the end
Line 302... Line 295...
302
				
295
				
303
				if (scroll_used)
296
				if (scroll_used)
304
				{
297
				{
305
					if (sc_slider_h/2+files.y>mouse.y) || (mouse.y<0) || (mouse.y>4000) mouse.y=sc_slider_h/2+files.y; //anee eo?ni? iaa ieiii
298
					if (sc_slider_h/2+files.y>mouse.y) || (mouse.y<0) || (mouse.y>4000) mouse.y=sc_slider_h/2+files.y; //anee eo?ni? iaa ieiii
306
					id = files.first;
299
					id = files.first;
307
					files.first = -sc_slider_h / 2 + mouse.y -j -files.y * files.count;
300
					files.first = -sc_slider_h / 2 + mouse.y -files.y * files.count;
308
					files.first /= files.h - 18;
301
					files.first /= files.h - 18;
309
					if (files.visible+files.first>files.count) files.first=files.count-files.visible;
302
					if (files.visible+files.first>files.count) files.first=files.count-files.visible;
310
					if (files.first<0) files.first=0;
303
					if (files.first<0) files.first=0;
311
					if (id!=files.first) List_ReDraw();
304
					if (id!=files.first) List_ReDraw();
Line 349... Line 342...
349
				{
342
				{
350
					case CLOSE_BTN:
343
					case CLOSE_BTN:
351
							KillProcess(about_window);
344
							KillProcess(about_window);
352
							SaveIniSettings();
345
							SaveIniSettings();
353
							ExitProcess();
346
							ExitProcess();
-
 
347
					case PATH_BTN:
-
 
348
							notify(COPY_PATH_STR);
-
 
349
							Clipboard__CopyText(#path);
-
 
350
							break;
354
					case 21: //Back
351
					case 21: //Back
355
							GoBack();
352
							GoBack();
356
							break;
353
							break;
357
					case 22: //Forward
354
					case 22: //Forward
358
							if (history.forward())
355
							if (history.forward())
Line 465... Line 462...
465
						case SCAN_CODE_ENTER: //Ctrl+Enter
462
						case SCAN_CODE_ENTER: //Ctrl+Enter
466
								if (!itdir) ShowOpenWithDialog();
463
								if (!itdir) ShowOpenWithDialog();
467
								else Open(1);
464
								else Open(1);
468
								break;
465
								break;
469
						case 030: //Ctrl+A - select all files
466
						case 030: //Ctrl+A - select all files
470
								for (i=0; i
-
 
471
								List_ReDraw();
-
 
472
								DrawStatusBar();
467
								EventSelectAllFiles(true);
473
								break;
468
								break;
474
						case 022: //Ctrl+U - unselect all files
469
						case 022: //Ctrl+U - unselect all files
475
								for (i=0; i
-
 
476
								selected_count = 0;
470
								selected_count = 0;
477
								List_ReDraw();
-
 
478
								DrawStatusBar();
471
								EventSelectAllFiles(false);
479
								break;
472
								break;
480
					}
473
					}
481
					break;
474
					break;
482
				}
475
				}
Line 492... Line 485...
492
								break; 
485
								break; 
493
						case SCAN_CODE_TAB:
486
						case SCAN_CODE_TAB:
494
								if (!two_panels.checked) break;
487
								if (!two_panels.checked) break;
495
								if (active_panel==1) active_panel=2; else active_panel=1;
488
								if (active_panel==1) active_panel=2; else active_panel=1;
496
								ChangeActivePanel();
489
								ChangeActivePanel();
497
								DrawStatusBar();
490
								DrawFilePanels();
498
								break;
491
								break;
499
						case 093: //menu
492
						case 093: //menu
500
								menu_call_mouse=0;
493
								menu_call_mouse=0;
501
								menu_stak = malloc(4096);
494
								menu_stak = malloc(4096);
502
								CreateThread(#FileMenu,menu_stak+4092);
495
								CreateThread(#FileMenu,menu_stak+4092);
Line 513... Line 506...
513
								break;
506
								break;
514
						case 059...068: //F1-F10
507
						case 059...068: //F1-F10
515
								FnProcess(key_scancode-58);
508
								FnProcess(key_scancode-58);
516
								break; 
509
								break; 
517
						default:
510
						default:
518
								for (i=files.cur_y+1; i
-
 
519
								{
-
 
520
									strcpy(#temp, file_mas[i]*304+buf+72);
-
 
521
									if (temp[0]==key_ascii) || (temp[0]==key_ascii-32)
-
 
522
									{
-
 
523
										files.cur_y = i - 1;
-
 
524
										files.KeyDown();
511
								EventSelectFileByKeyPress();
525
										List_ReDraw();
-
 
526
										break;
-
 
527
									}
-
 
528
								}
-
 
529
				}                         
512
				}                         
530
			break;
513
			break;
531
			case evIPC:
514
			case evIPC:
532
			case evReDraw:
515
			case evReDraw:
533
				draw_window();
516
				draw_window();
Line 551... Line 534...
551
					if (action_buf==110) FnProcess(8);
534
					if (action_buf==110) FnProcess(8);
552
					action_buf=0;
535
					action_buf=0;
553
				}
536
				}
554
			break;
537
			break;
555
			default:
538
			default:
556
				
-
 
557
				ReadDir(19, devbuf, "/"); // get disk
-
 
558
				if(countDisk != EBX) // if different then
-
 
559
				{
-
 
560
					countDisk = EBX;
-
 
561
					FnProcess(5);
-
 
562
				}
-
 
563
				else // get current files
-
 
564
				{
-
 
565
					if(two_panels.checked)
-
 
566
					{
-
 
567
						// this add code update list files
-
 
568
						update_files_list = false;
-
 
569
						//strcpy(#inactive_path,#path);
-
 
570
						ReadDir(19, devbuf, #inactive_path);
-
 
571
						if(countPathFile != EBX) // if different then
-
 
572
						{
-
 
573
							countPathFile = EBX;
-
 
574
							update_files_list = true;
539
				if (Form.status_window>2) break;
575
						}
-
 
576
						
-
 
577
						//strcpy(#active_path,#path);
-
 
578
						ReadDir(19, devbuf, #active_path);
-
 
579
						if(countPathFile2 != EBX) // if different then
-
 
580
						{
-
 
581
							countPathFile2 = EBX;
-
 
582
							update_files_list = true;
-
 
583
						}
-
 
584
						if(update_files_list) DrawFilePanels();
540
				EventRefreshDisksAndFolders();
585
					}
-
 
586
					else
-
 
587
					{
-
 
588
						ReadDir(19, devbuf, #path);
-
 
589
						if(countPathFile != EBX) // if different then
-
 
590
						{
-
 
591
							countPathFile = EBX;
-
 
592
							Open_Dir(#path,WITH_REDRAW);
-
 
593
						}
-
 
594
					}
-
 
595
				}
-
 
596
		}
541
		}
Line 597... Line -...
597
		
-
 
598
		
-
 
599
		
542
		
600
		if(cmd_free)
543
		if(cmd_free)
601
		{
544
		{
602
			if(cmd_free==1)      menu_stak=free(menu_stak);
545
			if(cmd_free==1)      menu_stak=free(menu_stak);
603
			else if(cmd_free==2) about_stak=free(about_stak);
546
			else if(cmd_free==2) about_stak=free(about_stak);
Line 611... Line 554...
611
}
554
}
Line 612... Line 555...
612
 
555
 
613
void DrawFavButton(int x)
556
void DrawFavButton(int x)
614
{
557
{
615
	_PutImage(x,10,20,22,#fav);
558
	_PutImage(x,10,20,22,#fav);
616
	DefineButton(x+1,11,20-2,22-3,61+BT_HIDE,NULL);
559
	DefineHiddenButton(x+1,11,20-2,22-3,61);
Line 617... Line 560...
617
}
560
}
618
 
561
 
-
 
562
void draw_window()
619
void draw_window()
563
{
620
{
564
	int i;
621
	if (show_status_bar.checked) status_bar_h = STATUS_BAR_H; else status_bar_h = 0;
565
	if (show_status_bar.checked) status_bar_h = STATUS_BAR_H; else status_bar_h = 0;
622
	DefineAndDrawWindow(Form.left+rand_n,Form.top+rand_n,Form.width,Form.height,0x73,NULL,TITLE,0);
566
	DefineAndDrawWindow(Form.left+rand_n,Form.top+rand_n,Form.width,Form.height,0x73,NULL,TITLE,0);
623
	GetProcessInfo(#Form, SelfInfo);
567
	GetProcessInfo(#Form, SelfInfo);
624
	if (Form.status_window>2) return;
568
	if (Form.status_window>2) return;
625
	if (Form.height < 350) { MoveSize(OLD,OLD,OLD,350); return; }
569
	if (Form.height < 350) { MoveSize(OLD,OLD,OLD,350); return; }
626
	if (Form.width  < 480) { MoveSize(OLD,OLD,480,OLD); return; }
570
	if (Form.width  < 480) { MoveSize(OLD,OLD,480,OLD); return; }
627
	GetProcessInfo(#Form, SelfInfo); //if win_size changed
571
	GetProcessInfo(#Form, SelfInfo); //if win_size changed
628
	_PutImage(0,0,246,34,#toolbar);
572
	_PutImage(0,0,246,34,#toolbar);
629
	DrawBar(127, 8, 1, 25, col_graph);
573
	DrawBar(127, 8, 1, 25, col_graph);
630
	for (j=0; j<3; j++) DefineButton(toolbar_buttons_x[j]+2,5+2,31-5,29-5,21+j+BT_HIDE,NULL);
574
	for (i=0; i<3; i++) DefineHiddenButton(toolbar_buttons_x[i]+2,7,31-5,29-5,21+i);
631
	for (j=3; j<6; j++) DefineButton(toolbar_buttons_x[j],5,31,29,21+j+BT_HIDE,NULL);
575
	for (i=3; i<6; i++) DefineHiddenButton(toolbar_buttons_x[i],  5,31,  29,  21+i);
632
	DrawBar(246,0, Form.cwidth - 246, 34, col_work);
576
	DrawBar(246,0, Form.cwidth - 246, 34, col_work);
633
	_PutImage(Form.cwidth-17,11,6,18,#dots);
577
	_PutImage(Form.cwidth-17,11,6,18,#dots);
634
	DefineButton(Form.cwidth-24,7,20,25,51+BT_HIDE+BT_NOFRAME,0); //dots
578
	DefineHiddenButton(Form.cwidth-24,7,20,25,51+BT_NOFRAME); //dots
635
	//main rectangles
579
	//main rectangles
636
	DrawRectangle(1,40,Form.cwidth-3,Form.cheight - 42-status_bar_h,col_graph);
580
	DrawRectangle(1,40,Form.cwidth-3,Form.cheight - 42-status_bar_h,col_graph);
637
	DrawRectangle(0,39,Form.cwidth-1,Form.cheight - 40,col_palette[4]); //bg
581
	DrawRectangle(0,39,Form.cwidth-1,Form.cheight - 40,col_palette[4]); //bg
Line 721... Line 665...
721
 
665
 
722
 
666
 
723
void List_ReDraw()
667
void List_ReDraw()
-
 
668
{
724
{
669
	int all_lines_h;
Line 725... Line 670...
725
	int all_lines_h;
670
	dword j;
Line 726... Line 671...
726
	static int old_cur_y, old_first;
671
	static int old_cur_y, old_first;
Line 767... Line 712...
767
		  BDVK file;
712
		  BDVK file;
768
		  char temp_path[sizeof(file_path)];
713
		  char temp_path[sizeof(file_path)];
769
	char label_file_name[4096];
714
	char label_file_name[4096];
770
	if (filenum==-1) return;
715
	if (filenum==-1) return;
771
	DrawBar(files.x,y,4,files.item_h,bgcol);
716
	DrawBar(files.x,y,4,files.item_h,bgcol);
772
	DrawBar(files.x+20,y,files.w-20,files.item_h,bgcol);
-
 
773
	DrawBar(files.x+4,y,icon_size,icon_y-y,bgcol);
717
	DrawBar(files.x+4,y,icon_size,icon_y-y,bgcol);
774
	if (files.item_h>icon_size) DrawBar(files.x+4,icon_y+icon_size-1,icon_size,y+files.item_h-icon_y-icon_size+1,bgcol);
718
	if (files.item_h>icon_size) DrawBar(files.x+4,icon_y+icon_size-1,icon_size,y+files.item_h-icon_y-icon_size+1,bgcol);
-
 
719
	if (colored_lines.checked) && (bgcol!=col_selec) && (filenum%2) bgcol=0xF1F1F1;
-
 
720
	DrawBar(files.x+icon_size+4,y,files.w-icon_size-4,files.item_h,bgcol);
Line 775... Line 721...
775
 
721
 
776
	file_offet = file_mas[filenum+files.first]*304 + buf+32;
722
	file_offet = file_mas[filenum+files.first]*304 + buf+32;
777
	attr = ESDWORD[file_offet];
723
	attr = ESDWORD[file_offet];
778
	file.selected = ESBYTE[file_offet+7];
724
	file.selected = ESBYTE[file_offet+7];
Line 802... Line 748...
802
	}
748
	}
803
	sprintf(#temp_path,"%s/%s",#path,file_name_off);
749
	sprintf(#temp_path,"%s/%s",#path,file_name_off);
804
	DrawIconByExtension(#temp_path, ext1, files.x+4, icon_y, bgcol);
750
	DrawIconByExtension(#temp_path, ext1, files.x+4, icon_y, bgcol);
Line 805... Line 751...
805
 
751
 
806
	if (TestBit(attr, 1)) || (TestBit(attr, 2)) text_col=0xA6A6B7; //system or hiden?
752
	if (TestBit(attr, 1)) || (TestBit(attr, 2)) text_col=0xA6A6B7; //system or hiden?
807
	if (bgcol!=0xFFFfff)
753
	if (bgcol==col_selec)
808
	{
754
	{
809
		itdir = TestBit(attr, 4);
755
		itdir = TestBit(attr, 4);
810
		strcpy(#file_name, file_name_off);
756
		strcpy(#file_name, file_name_off);
811
		if (!strcmp(#path,"/")) sprintf(#file_path,"%s%s",#path,file_name_off);
757
		if (!strcmp(#path,"/")) sprintf(#file_path,"%s%s",#path,file_name_off);
Line 881... Line 827...
881
}
827
}
Line 882... Line 828...
882
 
828
 
883
inline Sorting()
829
inline Sorting()
884
{
830
{
-
 
831
	dword k=0, l=1;
885
	dword k=0, l=1;
832
	int j=0;
-
 
833
	dword file_off;
886
	dword file_off;
834
 
887
	if (!strcmp(#path,"/")) //do not sort root folder
835
	if (!strcmp(#path,"/")) //do not sort root folder
888
	{
836
	{
889
		for(k=1;k
837
		for(k=1;k
890
		count_dir = k;
838
		count_dir = k;
Line 906... Line 854...
906
	}
854
	}
907
	count_dir = k;
855
	count_dir = k;
908
	//sorting: files first, then folders
856
	//sorting: files first, then folders
909
	Sort_by_Name(0,k-1);
857
	Sort_by_Name(0,k-1);
910
	if (sort_num==1) Sort_by_Name(k,files.count-1);
858
	if (sort_num==1) Sort_by_Name(k,files.count-1);
911
	if (sort_num==2) Sort_by_Type(k,files.count-1);
859
	else if (sort_num==2) Sort_by_Type(k,files.count-1);
912
	if (sort_num==3) Sort_by_Size(k,files.count-1);
860
	else if (sort_num==3) Sort_by_Size(k,files.count-1);
913
	//make ".." first item in list
861
	//make ".." first item in list
914
	if (k>0) && (strncmp(file_mas[0]*304+buf+72,"..",2)!=0)
862
	if (k>0) && (strncmp(file_mas[0]*304+buf+72,"..",2)!=0)
915
		for(k--; k>0; k--;) if (!strncmp(file_mas[k]*304+buf+72,"..",2)) {file_mas[k]>
863
		for(k--; k>0; k--;) if (!strncmp(file_mas[k]*304+buf+72,"..",2)) {file_mas[k]>
916
}
864
}
Line 963... Line 911...
963
}
911
}
Line 964... Line 912...
964
 
912
 
965
 
913
 
-
 
914
void Dir_Up()
966
void Dir_Up()
915
{
967
{
916
	int iii;
968
	char old_folder_name[4096];
917
	char old_folder_name[4096];
969
	i=strlen(#path)-1;
-
 
970
	if (i==0) return;
918
	iii=strlen(#path)-1;
971
	//path[i]=0x00;
919
	if (iii==0) return;
972
	i = strrchr(#path, '/');
920
	iii = strrchr(#path, '/');
973
	strcpy(#old_folder_name, #path+i);
921
	strcpy(#old_folder_name, #path+iii);
974
	if (i>1) path[i-1]=NULL; else path[i]=NULL;
922
	if (iii>1) path[iii-1]=NULL; else path[iii]=NULL;
Line 975... Line 923...
975
	SelectFileByName(#old_folder_name);
923
	SelectFileByName(#old_folder_name);
976
}
924
}
Line 1186... Line 1134...
1186
	strcpy(#active_path, #inactive_path);
1134
	strcpy(#active_path, #inactive_path);
1187
	strcpy(#inactive_path, #path);
1135
	strcpy(#inactive_path, #path);
1188
	DrawFilePanels();
1136
	DrawFilePanels();
1189
}
1137
}
Line -... Line 1138...
-
 
1138
 
-
 
1139
void EventSelectAllFiles(dword state)
-
 
1140
{
-
 
1141
	int i;
-
 
1142
	for (i=0; i
-
 
1143
	List_ReDraw();
-
 
1144
	DrawStatusBar();
-
 
1145
}
-
 
1146
 
-
 
1147
void EventSelectFileByKeyPress()
-
 
1148
{
-
 
1149
	int i;
-
 
1150
	for (i=files.cur_y+1; i
-
 
1151
	{
-
 
1152
		strcpy(#temp, file_mas[i]*304+buf+72);
-
 
1153
		if (temp[0]==key_ascii) || (temp[0]==key_ascii-32)
-
 
1154
		{
-
 
1155
			files.cur_y = i - 1;
-
 
1156
			files.KeyDown();
-
 
1157
			List_ReDraw();
-
 
1158
			return;
-
 
1159
		}
-
 
1160
	}
-
 
1161
}
-
 
1162
 
-
 
1163
int GetRealFileCountInFolder(dword folder_path)
-
 
1164
{
-
 
1165
	int fcount;
-
 
1166
	dword countbuf;
-
 
1167
 
-
 
1168
	GetDir(#countbuf, #fcount, folder_path, DIRS_NOROOT);
-
 
1169
	if (countbuf) free(countbuf);
-
 
1170
 
-
 
1171
	return fcount;
-
 
1172
}
-
 
1173
 
-
 
1174
void EventRefreshDisksAndFolders()
-
 
1175
{
-
 
1176
	if(GetRealFileCountInFolder("/")+dir_exists("/kolibrios") != SystemDiscs.dev_num) {
-
 
1177
		FnProcess(5);
-
 
1178
	}
-
 
1179
	if(two_panels.checked)
-
 
1180
	{
-
 
1181
		if(GetRealFileCountInFolder(#inactive_path) != files_inactive.count) {
-
 
1182
			ChangeActivePanel();
-
 
1183
			Open_Dir(#path,WITH_REDRAW);
-
 
1184
			ChangeActivePanel();
-
 
1185
		}
-
 
1186
		if(GetRealFileCountInFolder(#path) != files.count) Open_Dir(#path,WITH_REDRAW);
-
 
1187
	}
-
 
1188
	else
-
 
1189
	{
-
 
1190
		if(GetRealFileCountInFolder(#path) != files.count) Open_Dir(#path,WITH_REDRAW);
-
 
1191
	}
Line 1190... Line 1192...
1190
 
1192
}