1 //------------------------------------------------------------------------------
2 // emFileManControlPanel.cpp
3 //
4 // Copyright (C) 2006-2008,2010,2014-2016 Oliver Hamann.
5 //
6 // Homepage: http://eaglemode.sourceforge.net/
7 //
8 // This program is free software: you can redistribute it and/or modify it under
9 // the terms of the GNU General Public License version 3 as published by the
10 // Free Software Foundation.
11 //
12 // This program is distributed in the hope that it will be useful, but WITHOUT
13 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 // FOR A PARTICULAR PURPOSE. See the GNU General Public License version 3 for
15 // more details.
16 //
17 // You should have received a copy of the GNU General Public License version 3
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 //------------------------------------------------------------------------------
20 
21 #include <emFileMan/emFileManControlPanel.h>
22 #include <emCore/emInstallInfo.h>
23 #include <emCore/emRes.h>
24 #include <emFileMan/emFileManSelInfoPanel.h>
25 #include <emFileMan/emDirPanel.h>
26 
27 
emFileManControlPanel(ParentArg parent,const emString & name,emView & contentView)28 emFileManControlPanel::emFileManControlPanel(
29 	ParentArg parent, const emString & name, emView & contentView
30 )
31 	: emLinearLayout(parent,name),
32 	ContentView(contentView)
33 {
34 	emLinearLayout * vsLayout, * saveGroup;
35 	emRasterLayout * themeLayout, * themeLayout2, * sortLayout, * sortLayout2;
36 	emRasterGroup * nameSortingStyleGroup;
37 	emRadioButton * rb;
38 	emTunnel * tunnel;
39 	emImage image;
40 	emLook look;
41 	int i;
42 
43 	FMModel=emFileManModel::Acquire(GetRootContext());
44 	FMVConfig=emFileManViewConfig::Acquire(contentView);
45 	FMThemeNames=emFileManThemeNames::Acquire(GetRootContext());
46 
47 	SetOrientationThresholdTallness(0.43);
48 	SetChildWeight(0, 8.16);
49 	SetChildWeight(1, 13.0);
50 	SetInnerSpace(0.015,0.015);
51 
52 	vsLayout=new emLinearLayout(this,"vs");
53 	vsLayout->SetOrientationThresholdTallness(0.8);
54 	vsLayout->SetChildWeight(0, 5.0);
55 	vsLayout->SetChildWeight(1, 3.0);
56 	vsLayout->SetInnerSpace(0.04,0.04);
57 
58 	GrView=new emPackGroup(vsLayout,"view","File View Settings");
59 	GrView->SetPrefChildTallness(0, 0.7);
60 	GrView->SetPrefChildTallness(1, 0.7);
61 	GrView->SetPrefChildTallness(2, 0.7);
62 	GrView->SetPrefChildTallness(3, 0.35);
63 	GrView->SetPrefChildTallness(4, 0.35);
64 	GrView->SetChildWeight(0, 4.0);
65 	GrView->SetChildWeight(1, 4.0);
66 	GrView->SetChildWeight(2, 1.0);
67 	GrView->SetChildWeight(3, 0.5);
68 	GrView->SetChildWeight(4, 0.5);
69 		themeLayout=new emRasterLayout(GrView,"theme");
70 		themeLayout->SetPrefChildTallness(0.7);
71 		rb=new emRadioButton(
72 			themeLayout,"aspect ratio 1",emString(),
73 			"Set the aspect ratio of file panels to the highest value.\n"
74 			"This may be best for managing files, because the file\n"
75 			"names get a bigger proportion of the display area, than\n"
76 			"with the other selectable aspect ratios.",
77 			emGetInsResImage(GetRootContext(),"emFileMan","icons/aspect_ratio_1.tga")
78 		);
79 		rb->SetIconAboveCaption();
80 		rb->SetBorderScaling(0.5);
81 		RbmAspect.Add(rb);
82 		rb=new emRadioButton(
83 			themeLayout,"aspect ratio 2",emString(),
84 			"Set the aspect ratio of file panels to a low value.\n"
85 			"This may be best for viewing the contents of many files\n"
86 			"(e.g. photos), which have similar aspect ratios.",
87 			emGetInsResImage(GetRootContext(),"emFileMan","icons/aspect_ratio_2.tga")
88 		);
89 		rb->SetIconAboveCaption();
90 		rb->SetBorderScaling(0.5);
91 		RbmAspect.Add(rb);
92 		rb=new emRadioButton(
93 			themeLayout,"aspect ratio 3",emString(),
94 			"Set the aspect ratio of file panels to the lowest value.\n"
95 			"This may be best for viewing the contents of many files\n"
96 			"(e.g. photos), which have similar aspect ratios.",
97 			emGetInsResImage(GetRootContext(),"emFileMan","icons/aspect_ratio_3.tga")
98 		);
99 		rb->SetIconAboveCaption();
100 		rb->SetBorderScaling(0.5);
101 		RbmAspect.Add(rb);
102 		themeLayout2=new emRasterGroup(
103 			themeLayout,"theme","Theme",
104 			"Here you can choose the look of the directory entry panels."
105 		);
106 		themeLayout2->SetPrefChildTallness(0.7);
107 		for (i=0; i<FMThemeNames->GetThemeStyleCount(); i++) {
108 			image.Clear();
109 			if (!FMThemeNames->GetThemeStyleDisplayIcon(i).IsEmpty()) {
110 				image=emGetResImage(
111 					GetRootContext(),
112 					emGetChildPath(
113 						emGetInstallPath(EM_IDT_RES,"emFileMan","icons"),
114 						FMThemeNames->GetThemeStyleDisplayIcon(i)
115 					)
116 				);
117 			}
118 			rb=new emRadioButton(
119 				themeLayout2,
120 				FMThemeNames->GetThemeStyleDisplayName(i),
121 				FMThemeNames->GetThemeStyleDisplayName(i),
122 				emString(),
123 				image
124 			);
125 			rb->SetIconAboveCaption();
126 			rb->SetBorderScaling(0.5);
127 			RbmTheme.Add(rb);
128 		}
129 		sortLayout=new emRasterLayout(GrView,"sort");
130 		sortLayout->SetPrefChildTallness(0.7);
131 			RbSortByName=new emRadioButton(
132 				sortLayout,"sort by name",
133 				"Sort By Name",
134 				"Sort by file name.\n"
135 				"\n"
136 				"Hotkey: Shift+Alt+N",
137 				emGetInsResImage(GetRootContext(),"emFileMan","icons/sort_by_name.tga")
138 			);
139 			RbSortByName->SetIconAboveCaption();
140 			RbSortByName->SetBorderScaling(0.5);
141 			RbSortByDate=new emRadioButton(
142 				sortLayout,"sort by date",
143 				"Sort By Date",
144 				"Sort primarily by date and time of last modification,\n"
145 				"secondarily by name.\n"
146 				"\n"
147 				"Hotkey: Shift+Alt+D",
148 				emGetInsResImage(GetRootContext(),"emFileMan","icons/sort_by_date.tga")
149 			);
150 			RbSortByDate->SetIconAboveCaption();
151 			RbSortByDate->SetBorderScaling(0.5);
152 			RbSortBySize=new emRadioButton(
153 				sortLayout,"sort by size",
154 				"Sort By Size",
155 				"Sort primarily by file size, secondarily by name.\n"
156 				"\n"
157 				"Hotkey: Shift+Alt+S",
158 				emGetInsResImage(GetRootContext(),"emFileMan","icons/sort_by_size.tga")
159 			);
160 			RbSortBySize->SetIconAboveCaption();
161 			RbSortBySize->SetBorderScaling(0.5);
162 			sortLayout2=new emRasterLayout(sortLayout,"more");
163 			sortLayout2->SetPrefChildTallness(0.7);
164 				RbSortByEnding=new emRadioButton(
165 					sortLayout2,"sort by ending",
166 					"Sort By Ending",
167 					"Sort by file name ending. It's the part after the last dot.\n"
168 					"Files with equal endings are sorted by name.\n"
169 					"\n"
170 					"Hotkey: Shift+Alt+E",
171 					emGetInsResImage(GetRootContext(),"emFileMan","icons/sort_by_ending.tga")
172 				);
173 				RbSortByEnding->SetIconAboveCaption();
174 				RbSortByEnding->SetBorderScaling(0.5);
175 				RbSortByClass=new emRadioButton(
176 					sortLayout2,"sort by class",
177 					"Sort By Class",
178 					"Sort by class names in the file names. This sorting algorithm\n"
179 					"splits each file name into words and sorts primarily by the\n"
180 					"last word, secondarily by the next-to-last word and so on.\n"
181 					"\n"
182 					"Hotkey: Shift+Alt+C",
183 					emGetInsResImage(GetRootContext(),"emFileMan","icons/sort_by_class.tga")
184 				);
185 				RbSortByClass->SetIconAboveCaption();
186 				RbSortByClass->SetBorderScaling(0.5);
187 				RbSortByVersion=new emRadioButton(
188 					sortLayout2,"sort by version",
189 					"Sort By Version",
190 					"Sort by version number. This is like sorting by name, but\n"
191 					"decimal numbers are recognized and compared. For example,\n"
192 					"\"a-2.10.xy\" comes after \"a-2.9.xy\".\n"
193 					"\n"
194 					"Hotkey: Shift+Alt+V",
195 					emGetInsResImage(GetRootContext(),"emFileMan","icons/sort_by_version.tga")
196 				);
197 				RbSortByVersion->SetIconAboveCaption();
198 				RbSortByVersion->SetBorderScaling(0.5);
199 				CbSortDirectoriesFirst=new emCheckButton(
200 					sortLayout2,"sort directories first",
201 					"Directories First",
202 					"Always have directories at the beginning, regardless of\n"
203 					"the other sort criterions.",
204 					emGetInsResImage(GetRootContext(),"emFileMan","icons/directories_first.tga")
205 				);
206 				CbSortDirectoriesFirst->SetIconAboveCaption();
207 				CbSortDirectoriesFirst->SetBorderScaling(0.5);
208 		CbShowHiddenFiles=new emCheckButton(
209 			GrView,"show hidden files",
210 			"Show Hidden Files",
211 			"Hotkey: Shift+Alt+H",
212 			emGetInsResImage(GetRootContext(),"emFileMan","icons/show_hidden_files.tga")
213 		);
214 		CbShowHiddenFiles->SetIconAboveCaption();
215 		CbShowHiddenFiles->SetBorderScaling(0.5);
216 		nameSortingStyleGroup=new emRasterGroup(
217 			GrView,"nameSortingStyle",
218 			"File Name Sorting Style (Order of Characters)"
219 		);
220 		nameSortingStyleGroup->SetBorderScaling(2.0);
221 		nameSortingStyleGroup->SetPrefChildTallness(0.05);
222 			RbPerLocale=new emRadioButton(
223 				nameSortingStyleGroup,"per locale",
224 				"Per Locale",
225 				"Sort names depending on the user's current locale.\n"
226 				"Technically, names are compared through \"strcoll\"."
227 			);
228 			RbCaseSensitive=new emRadioButton(
229 				nameSortingStyleGroup,"case-sensitive",
230 				"Classic Case-Sensitive",
231 				"Sort names by the ASCII code of characters.\n"
232 				"Technically, names are compared through \"strcmp\"."
233 			);
234 			RbCaseInsensitive=new emRadioButton(
235 				nameSortingStyleGroup,"case-insensitive",
236 				"Classic Case-Insensitive",
237 				"Sort names by the ASCII code of characters, but ignore the\n"
238 				"letter case. This may be correct for English letters only.\n"
239 				"Technically, names are compared through \"strcasecmp\"."
240 			);
241 		tunnel=new emTunnel(GrView,"tunnel","Save File View Settings");
242 		tunnel->SetBorderScaling(0.57);
243 			saveGroup=new emLinearGroup(tunnel,"save");
244 			saveGroup->SetVertical();
245 				CbAutosave=new emCheckBox(
246 					saveGroup,"autosave",
247 					"Save Automatically",
248 					"Automatically save changes of the file view settings as the default for new windows."
249 				);
250 				CbAutosave->SetNoEOI();
251 				BtSaveAsDefault=new emButton(
252 					saveGroup,"save",
253 					"Save",
254 					"Save the current file view settings as the default for new windows."
255 				);
256 
257 	GrSelection=new emRasterGroup(vsLayout,"selection","File Selection");
258 	GrSelection->SetPrefChildTallness(0.7);
259 		BtSelectAll=new emButton(
260 			GrSelection,"select all",
261 			"Select All",
262 			"Select all entries in the directory content panel which is active\n"
263 			"(focused) itself, or which is the parent of an active directory\n"
264 			"entry panel. As usual, the entries are selected as the target and\n"
265 			"the source selection is set from the previous target selection.\n"
266 			"\n"
267 			"Hotkey: Alt+A",
268 			emGetInsResImage(GetRootContext(),"emFileMan","icons/select_all.tga")
269 		);
270 		BtSelectAll->SetIconAboveCaption();
271 		BtSelectAll->SetBorderScaling(0.5);
272 		BtClearSelection=new emButton(
273 			GrSelection,"clear selection",
274 			"Clear Selection",
275 			"Clear the source and target selections.\n"
276 			"\n"
277 			"Hotkey: Alt+E",
278 			emGetInsResImage(GetRootContext(),"emFileMan","icons/clear_selection.tga")
279 		);
280 		BtClearSelection->SetIconAboveCaption();
281 		BtClearSelection->SetBorderScaling(0.5);
282 		BtSwapSelection=new emButton(
283 			GrSelection,"swap selection",
284 			"Swap Selection",
285 			"Exchange the source selection for the target selection.\n"
286 			"\n"
287 			"Hotkey: Alt+Z",
288 			emGetInsResImage(GetRootContext(),"emFileMan","icons/swap_selection.tga")
289 		);
290 		BtSwapSelection->SetIconAboveCaption();
291 		BtSwapSelection->SetBorderScaling(0.5);
292 		GrSelInfo=new emLinearGroup(GrSelection,"stat","Selection Statistics");
293 		GrSelInfo->SetBorderType(OBT_INSTRUMENT,IBT_OUTPUT_FIELD);
294 		look=GrSelInfo->GetLook();
295 		look.SetOutputBgColor(look.GetButtonBgColor());
296 		GrSelInfo->SetLook(look);
297 		GrSelInfo->SetBorderScaling(0.5);
298 			SelInfo=new emFileManSelInfoPanel(GrSelInfo,"info");
299 			SelInfo->SetFocusable(false);
300 		BtPaths2Clipboard=new emButton(
301 			GrSelection,"paths2clipboard",
302 			"Copy Paths",
303 			"Copy the full file path(s) of the target selection to the clipboard.\n"
304 			"Multiple entries are separated by line feeds.\n"
305 			"\n"
306 			"Hotkey: Alt+P",
307 			emGetInsResImage(GetRootContext(),"emFileMan","icons/copy_paths.tga")
308 		);
309 		BtPaths2Clipboard->SetIconAboveCaption();
310 		BtPaths2Clipboard->SetBorderScaling(0.5);
311 		BtNames2Clipboard=new emButton(
312 			GrSelection,"names2clipboard",
313 			"Copy Names",
314 			"Copy the file name(s) of the target selection to the clipboard.\n"
315 			"Multiple entries are separated by line feeds.\n"
316 			"\n"
317 			"Hotkey: Alt+N",
318 			emGetInsResImage(GetRootContext(),"emFileMan","icons/copy_names.tga")
319 		);
320 		BtNames2Clipboard->SetIconAboveCaption();
321 		BtNames2Clipboard->SetBorderScaling(0.5);
322 
323 	GrCommand=new Group(this,"commands",contentView,FMModel,FMModel->GetCommandRoot());
324 	GrCommand->SetCaption("File Manager Commands");
325 
326 	AddWakeUpSignal(FMModel->GetSelectionSignal());
327 	AddWakeUpSignal(FMVConfig->GetChangeSignal());
328 	AddWakeUpSignal(RbmAspect.GetCheckSignal());
329 	AddWakeUpSignal(RbmTheme.GetCheckSignal());
330 	AddWakeUpSignal(RbSortByName->GetClickSignal());
331 	AddWakeUpSignal(RbSortByDate->GetClickSignal());
332 	AddWakeUpSignal(RbSortBySize->GetClickSignal());
333 	AddWakeUpSignal(RbSortByEnding->GetClickSignal());
334 	AddWakeUpSignal(RbSortByClass->GetClickSignal());
335 	AddWakeUpSignal(RbSortByVersion->GetClickSignal());
336 	AddWakeUpSignal(CbSortDirectoriesFirst->GetCheckSignal());
337 	AddWakeUpSignal(CbShowHiddenFiles->GetCheckSignal());
338 	AddWakeUpSignal(RbPerLocale->GetClickSignal());
339 	AddWakeUpSignal(RbCaseSensitive->GetClickSignal());
340 	AddWakeUpSignal(RbCaseInsensitive->GetClickSignal());
341 	AddWakeUpSignal(CbAutosave->GetCheckSignal());
342 	AddWakeUpSignal(BtSaveAsDefault->GetClickSignal());
343 	AddWakeUpSignal(BtSelectAll->GetClickSignal());
344 	AddWakeUpSignal(BtClearSelection->GetClickSignal());
345 	AddWakeUpSignal(BtSwapSelection->GetClickSignal());
346 	AddWakeUpSignal(BtPaths2Clipboard->GetClickSignal());
347 	AddWakeUpSignal(BtNames2Clipboard->GetClickSignal());
348 
349 	UpdateButtonStates();
350 }
351 
352 
~emFileManControlPanel()353 emFileManControlPanel::~emFileManControlPanel()
354 {
355 }
356 
357 
Cycle()358 bool emFileManControlPanel::Cycle()
359 {
360 	emScreen * screen;
361 	emDirPanel * dp;
362 	emPanel * p;
363 	int i,j;
364 
365 	if (
366 		IsSignaled(FMModel->GetSelectionSignal()) ||
367 		IsSignaled(FMVConfig->GetChangeSignal())
368 	) {
369 		UpdateButtonStates();
370 	}
371 	if (
372 		IsSignaled(RbmAspect.GetCheckSignal()) ||
373 		IsSignaled(RbmTheme.GetCheckSignal())
374 	) {
375 		i=RbmTheme.GetCheckIndex();
376 		j=RbmAspect.GetCheckIndex();
377 		if (i<0 || i>=FMThemeNames->GetThemeStyleCount()) i=0;
378 		if (j<0 || j>=FMThemeNames->GetThemeAspectRatioCount(i)) j=0;
379 		FMVConfig->SetThemeName(FMThemeNames->GetThemeName(i,j));
380 	}
381 	if (IsSignaled(RbSortByName->GetClickSignal())) {
382 		FMVConfig->SetSortCriterion(emFileManViewConfig::SORT_BY_NAME);
383 	}
384 	if (IsSignaled(RbSortByDate->GetClickSignal())) {
385 		FMVConfig->SetSortCriterion(emFileManViewConfig::SORT_BY_DATE);
386 	}
387 	if (IsSignaled(RbSortBySize->GetClickSignal())) {
388 		FMVConfig->SetSortCriterion(emFileManViewConfig::SORT_BY_SIZE);
389 	}
390 	if (IsSignaled(RbSortByEnding->GetClickSignal())) {
391 		FMVConfig->SetSortCriterion(emFileManViewConfig::SORT_BY_ENDING);
392 	}
393 	if (IsSignaled(RbSortByClass->GetClickSignal())) {
394 		FMVConfig->SetSortCriterion(emFileManViewConfig::SORT_BY_CLASS);
395 	}
396 	if (IsSignaled(RbSortByVersion->GetClickSignal())) {
397 		FMVConfig->SetSortCriterion(emFileManViewConfig::SORT_BY_VERSION);
398 	}
399 	if (IsSignaled(CbSortDirectoriesFirst->GetCheckSignal())) {
400 		FMVConfig->SetSortDirectoriesFirst(CbSortDirectoriesFirst->IsChecked());
401 	}
402 	if (IsSignaled(CbShowHiddenFiles->GetCheckSignal())) {
403 		FMVConfig->SetShowHiddenFiles(CbShowHiddenFiles->IsChecked());
404 	}
405 	if (IsSignaled(RbPerLocale->GetClickSignal())) {
406 		FMVConfig->SetNameSortingStyle(emFileManViewConfig::NSS_PER_LOCALE);
407 	}
408 	if (IsSignaled(RbCaseSensitive->GetClickSignal())) {
409 		FMVConfig->SetNameSortingStyle(emFileManViewConfig::NSS_CASE_SENSITIVE);
410 	}
411 	if (IsSignaled(RbCaseInsensitive->GetClickSignal())) {
412 		FMVConfig->SetNameSortingStyle(emFileManViewConfig::NSS_CASE_INSENSITIVE);
413 	}
414 	if (IsSignaled(CbAutosave->GetCheckSignal())) {
415 		FMVConfig->SetAutosave(CbAutosave->IsChecked());
416 	}
417 	if (IsSignaled(BtSaveAsDefault->GetClickSignal())) {
418 		FMVConfig->SaveAsDefault();
419 	}
420 	if (IsSignaled(BtSelectAll->GetClickSignal())) {
421 		dp=NULL;
422 		for (p=ContentView.GetActivePanel(); p; p=p->GetParent()) {
423 			dp=dynamic_cast<emDirPanel*>(p);
424 			if (dp) break;
425 		}
426 		if (dp && dp->IsContentComplete()) {
427 			dp->SelectAll();
428 		}
429 		else {
430 			screen=GetScreen();
431 			if (screen) screen->Beep();
432 		}
433 	}
434 	if (IsSignaled(BtClearSelection->GetClickSignal())) {
435 		FMModel->ClearSourceSelection();
436 		FMModel->ClearTargetSelection();
437 	}
438 	if (IsSignaled(BtSwapSelection->GetClickSignal())) {
439 		FMModel->SwapSelection();
440 	}
441 	if (IsSignaled(BtPaths2Clipboard->GetClickSignal())) {
442 		FMModel->SelectionToClipboard(ContentView,false,false);
443 	}
444 	if (IsSignaled(BtNames2Clipboard->GetClickSignal())) {
445 		FMModel->SelectionToClipboard(ContentView,false,true);
446 	}
447 	return emLinearLayout::Cycle();
448 }
449 
450 
UpdateButtonStates()451 void emFileManControlPanel::UpdateButtonStates()
452 {
453 	emRadioButton * rb;
454 	int si,ai,ac,i;
455 
456 	si=FMThemeNames->GetThemeStyleIndex(FMVConfig->GetThemeName());
457 	ai=FMThemeNames->GetThemeAspectRatioIndex(FMVConfig->GetThemeName());
458 	ac=FMThemeNames->GetThemeAspectRatioCount(si);
459 	for (i=0; i<RbmAspect.GetCount(); i++) {
460 		rb=RbmAspect.GetButton(i);
461 		if (i<ac) {
462 			rb->SetEnableSwitch(true);
463 			rb->SetCaption(FMThemeNames->GetThemeAspectRatio(si,i));
464 		}
465 		else {
466 			rb->SetEnableSwitch(false);
467 		}
468 	}
469 	RbmAspect.SetCheckIndex(ai);
470 	RbmTheme.SetCheckIndex(si);
471 
472 	RbSortByName->SetChecked(FMVConfig->GetSortCriterion()==emFileManViewConfig::SORT_BY_NAME);
473 	RbSortByDate->SetChecked(FMVConfig->GetSortCriterion()==emFileManViewConfig::SORT_BY_DATE);
474 	RbSortBySize->SetChecked(FMVConfig->GetSortCriterion()==emFileManViewConfig::SORT_BY_SIZE);
475 	RbSortByEnding->SetChecked(FMVConfig->GetSortCriterion()==emFileManViewConfig::SORT_BY_ENDING);
476 	RbSortByClass->SetChecked(FMVConfig->GetSortCriterion()==emFileManViewConfig::SORT_BY_CLASS);
477 	RbSortByVersion->SetChecked(FMVConfig->GetSortCriterion()==emFileManViewConfig::SORT_BY_VERSION);
478 
479 	CbSortDirectoriesFirst->SetChecked(FMVConfig->GetSortDirectoriesFirst());
480 	CbShowHiddenFiles->SetChecked(FMVConfig->GetShowHiddenFiles());
481 
482 	RbPerLocale->SetChecked(FMVConfig->GetNameSortingStyle()==emFileManViewConfig::NSS_PER_LOCALE);
483 	RbCaseSensitive->SetChecked(FMVConfig->GetNameSortingStyle()==emFileManViewConfig::NSS_CASE_SENSITIVE);
484 	RbCaseInsensitive->SetChecked(FMVConfig->GetNameSortingStyle()==emFileManViewConfig::NSS_CASE_INSENSITIVE);
485 
486 	CbAutosave->SetChecked(FMVConfig->GetAutosave());
487 	BtSaveAsDefault->SetEnableSwitch(FMVConfig->IsUnsaved());
488 
489 	BtClearSelection->SetEnableSwitch(
490 		FMModel->GetSourceSelectionCount()>0 ||
491 		FMModel->GetTargetSelectionCount()>0
492 	);
493 	BtSwapSelection->SetEnableSwitch(
494 		FMModel->GetSourceSelectionCount()>0 ||
495 		FMModel->GetTargetSelectionCount()>0
496 	);
497 	BtPaths2Clipboard->SetEnableSwitch(FMModel->GetTargetSelectionCount()>0);
498 	BtNames2Clipboard->SetEnableSwitch(FMModel->GetTargetSelectionCount()>0);
499 }
500 
501 
Group(ParentArg parent,const emString & name,emView & contentView,emFileManModel * fmModel,const emFileManModel::CommandNode * cmd)502 emFileManControlPanel::Group::Group(
503 	ParentArg parent, const emString & name, emView & contentView,
504 	emFileManModel * fmModel, const emFileManModel::CommandNode * cmd
505 )
506 	: emRasterGroup(parent,name,cmd->Caption,cmd->Description,cmd->Icon),
507 	ContentView(contentView)
508 {
509 	SetLook(cmd->Look);
510 	SetBorderScaling(cmd->BorderScaling);
511 	if (cmd->BorderScaling<=0.0) {
512 		SetBorderType(OBT_NONE,IBT_NONE);
513 		SetFocusable(false);
514 	}
515 	SetPrefChildTallness(cmd->PrefChildTallness);
516 	SetMinChildTallness(cmd->PrefChildTallness*0.65);
517 	SetMaxChildTallness(1.0);
518 	SetStrictRaster(true);
519 	SetAlignment(EM_ALIGN_TOP_LEFT);
520 	FMModel=fmModel;
521 	CmdPath=cmd->CmdPath;
522 	AddWakeUpSignal(FMModel->GetCommandsSignal());
523 }
524 
525 
~Group()526 emFileManControlPanel::Group::~Group()
527 {
528 }
529 
530 
Cycle()531 bool emFileManControlPanel::Group::Cycle()
532 {
533 	if (IsSignaled(FMModel->GetCommandsSignal())) {
534 		InvalidateAutoExpansion();
535 	}
536 	return emRasterGroup::Cycle();
537 }
538 
539 
AutoExpand()540 void emFileManControlPanel::Group::AutoExpand()
541 {
542 	const emFileManModel::CommandNode * cmd;
543 	emArray<const emFileManModel::CommandNode *> cmds;
544 	char chName[256];
545 	int i;
546 
547 	cmd=FMModel->GetCommand(CmdPath);
548 	if (!cmd) return;
549 	cmds=cmd->Children;
550 	for (i=0; i<cmds.GetCount(); i++) {
551 		cmd=cmds[i];
552 		sprintf(chName,"%d",i);
553 		switch (cmd->Type) {
554 		case emFileManModel::CT_COMMAND:
555 			new Button(this,chName,ContentView,FMModel,cmd);
556 			break;
557 		case emFileManModel::CT_GROUP:
558 			new Group(this,chName,ContentView,FMModel,cmd);
559 			break;
560 		case emFileManModel::CT_SEPARATOR:
561 			new emPanel(this,chName);
562 			break;
563 		}
564 	}
565 }
566 
567 
Button(ParentArg parent,const emString & name,emView & contentView,emFileManModel * fmModel,const emFileManModel::CommandNode * cmd)568 emFileManControlPanel::Group::Button::Button(
569 	ParentArg parent, const emString & name, emView & contentView,
570 	emFileManModel * fmModel, const emFileManModel::CommandNode * cmd
571 )
572 	: emButton(parent,name,cmd->Caption,cmd->Description,cmd->Icon),
573 	ContentView(contentView)
574 {
575 	SetLook(cmd->Look);
576 	SetIconAboveCaption();
577 	SetMaxIconAreaTallness(9.0/16.0);
578 	SetBorderScaling(cmd->BorderScaling * 0.5);
579 	FMModel=fmModel;
580 	CmdPath=cmd->CmdPath;
581 }
582 
583 
~Button()584 emFileManControlPanel::Group::Button::~Button()
585 {
586 }
587 
588 
Clicked()589 void emFileManControlPanel::Group::Button::Clicked()
590 {
591 	const emFileManModel::CommandNode * cmd;
592 
593 	cmd=FMModel->GetCommand(CmdPath);
594 	if (cmd) FMModel->RunCommand(cmd,ContentView);
595 }
596