This source file includes following definitions.
- Action_MountVolumes
- Action_Compare_Panels
- Action_SelVolume_Start
- Action_EmptyTrash
- Action_LoadSavePalete
- Action_SavePalete_1
- Action_LoadPalete_1
- Action_Open_FtpPanel
- Action_SelectDict
- Action_SelectDict_1
1 #include "BF_Dict.h"
2 #include "BF_GUI_WinMain.h"
3 #include "BF_Roster.h"
4 #include "BF_GUI_DlgViews.h"
5 #include "BF_GUI_FilesPanel_Tasks.h"
6
7
8 void
9 BF_GUI_ViewMain::Action_MountVolumes()
10 {
11
12
13 BMessage oMessage(BF_MSG_MAKEFOCUS);
14 oMessage.AddPointer("bf_focus",poWin->CurrentFocus());
15
16 BF_GUI_Func_PanelsEnable(false);
17
18 BF_GUI_Dialog *poDialog = new BF_GUI_Dialog(BRect(0,0,300,0),
19 "Mount/unmount volems","dialog",oMessage,BG_GUI_DIALOG_WINRESIZE_MOVE_CENTER);
20
21 BRect oRect;
22 poDialog->LocalBounds(oRect);
23
24
25 oRect.bottom = oRect.top+poSysSetup->oFontToolView.fHeight;
26 poDialog->AddChild(new BF_GUI_ViewText(oRect,"comment","Existing volumes",B_FOLLOW_LEFT_RIGHT|B_FOLLOW_TOP,B_WILL_DRAW,false));
27 oRect.top = oRect.bottom+5;
28
29 {
30 BL_List *ploItem = new BL_List();
31 BF_GUI_ViewMenu_Item *poItem = NULL;
32
33
34 bool bShowIcons = poSysSetup->MainStyle() & BF_SETUP_SEARCH_SETUP_VOLICONS;
35
36 BF_NodeList loNodeVol;
37 BF_Roster_VolumeList(loNodeVol,
38 ( (bShowIcons)?BF_ROSTER_LOADVOLS_SICON:0 )
39 );
40 BF_Volume *poNode;
41
42 for(int i=0;i<loNodeVol.CountItems();i++){
43 poNode = (BF_Volume*)loNodeVol.ItemAt(i);
44
45 if(poNode->bBootVolume) poNode->sName="boot";
46
47 poItem = new BF_GUI_ViewMenu_Item(poNode->sName.String(),poNode->sName.String() );
48 ploItem->AddItem(poItem);
49 if(poNode->poSIcon && bShowIcons) poItem->poSIcon = new BBitmap( poNode->poSIcon );
50
51 poItem->bSelected = poNode->bBootVolume;
52 }
53 oRect.bottom = oRect.top+70;
54 BF_GUI_DlgView_VMenu *poMenu = new BF_GUI_DlgView_VMenu(oRect,"volumes",B_FOLLOW_ALL,
55 ploItem,BF_GUI_DLGVIEW_VMENU_SICON|BF_GUI_DLGVIEW_VMENU_CAN_SELECTING);
56 poDialog->AddChild(poMenu);
57 oRect.top = oRect.bottom+5;
58 }
59
60 oRect.bottom = oRect.top;
61 poDialog->AddChild(new BF_GUI_ViewFrame(oRect,B_FOLLOW_LEFT_RIGHT|B_FOLLOW_TOP));
62 oRect.top = oRect.bottom + 5;
63
64
65 poDialog->AddOkCancelMenu(oRect);
66
67 poDialog->SetHeightFromLastChild();
68 poDialog->MoveToCenter( poWinView );
69 BF_GUI_Func_AddChildToMainView ( poDialog );
70 }
71
72 void
73 BF_GUI_ViewMain::Action_Compare_Panels()
74 {
75 BF_NodeList loLNode,loRNode;
76 BF_GUI_Panel *poLPanel = PanelOnTop(true);
77 BF_GUI_Panel *poRPanel = PanelOnTop(false);
78 if(!poLPanel || !poRPanel) return;
79
80 poLPanel->Nodes_GetAll(loLNode,false);
81 poRPanel->Nodes_GetAll(loRNode,false);
82 poLPanel->Nodes_SetSelectingByName(NULL,BF_NODE_SELECT_ON,false);
83 poRPanel->Nodes_SetSelectingByName(NULL,BF_NODE_SELECT_ON,false);
84 poLPanel->Nodes_SetSelectingByName(&loRNode,BF_NODE_SELECT_OFF);
85 poRPanel->Nodes_SetSelectingByName(&loLNode,BF_NODE_SELECT_OFF);
86 }
87
88 void
89 BF_GUI_ViewMain::Action_SelVolume_Start(bool b_LeftPos)
90 {
91
92 BF_GUI_Func_PanelsEnable(false);
93
94 bool bShowIcons = poSysSetup->MainStyle() & BF_SETUP_MAIN_SELECTVOL_SHOWSICON;
95 BF_NodeList loNodeVol;
96 BF_Roster_VolumeList(loNodeVol,
97 ( (poSysSetup->MainStyle() & BF_SETUP_MAIN_SELECTVOL_SHOWSPEC)?BF_ROSTER_LOADVOLS_SPEC:0) |
98 ( (bShowIcons)?BF_ROSTER_LOADVOLS_SICON:0 )
99 );
100 BL_List *ploMenu = new BL_List();
101 BF_GUI_ViewMenu_Item *po;
102 BF_Node *poNode;
103
104
105 for(int i=0;i<loNodeVol.CountItems();i++){
106 poNode = (BF_Node*)loNodeVol.ItemAt(i);
107
108 po = new BF_GUI_ViewMenu_Item(poNode->sName.String(),poNode->sName.String() );
109 ploMenu->AddItem(po);
110 if(poNode->poSIcon && bShowIcons) po->poSIcon = new BBitmap( poNode->poSIcon );
111 }
112
113
114 {
115 po = new BF_GUI_ViewMenu_Item("ftp",":ftp" );
116 ploMenu->AddItem(po);
117 }
118
119
120 while(poSysSetup->MainStyle() & BF_SETUP_MAIN_SELECTVOL_SHOWSTACK){
121 BF_GUI_Panel *poPanel = PanelOnTop(b_LeftPos);
122 if(!poPanel) break;
123 BF_Path oPath;
124 oPath = poPanel->Path();
125 if(!oPath.IsStorageKit()) break;
126
127 bool bFirst=false;
128 BL_String s;
129
130 while(oPath.GoParent()){
131 if(!bFirst){
132 ploMenu->AddItem( new BF_GUI_ViewMenu_Item("",""));
133 bFirst = true;
134 }
135 s = oPath.PathWFS();
136 po = new BF_GUI_ViewMenu_Item(s==""?oPath.Path():s.String(),s.String() );
137 if(bShowIcons) po->poSIcon = BL_Load_SIconFromMIME( BL_MIME_FOLDER );
138 ploMenu->AddItem(po);
139 }
140
141 break;
142 }
143
144
145 BMessage oMessage(BF_MSG_MAINVIEW_SELVOL_FINISH);
146 oMessage.AddPointer("bf_focus",(void*)this);
147 oMessage.AddPointer("bf_panel_focus",(void*)poWin->CurrentFocus());
148 oMessage.AddBool("bf_bPosLeft",b_LeftPos);
149
150 float fMaxWidth=0;
151 {
152 BF_GUI_ViewMenu_Item *po;
153 float f;
154 for(int i=0;i<ploMenu->CountItems();i++){
155 po = (BF_GUI_ViewMenu_Item*)ploMenu->ItemAt(i);
156 ASSERT(po);
157 f = po->CalcWidth(&poSysSetup->oFontToolView);
158
159 if(f>fMaxWidth) fMaxWidth = f;
160 }
161 if(bShowIcons) fMaxWidth+=19;
162 }
163
164 const char *pcWinTitle = BF_DictAt(BF_DICT_VOLUMEDIALOG_TITLE);
165 {
166 float fTitleWidth = poSysSetup->oFontToolView.oFont.StringWidth(pcWinTitle)+40;
167 if(fTitleWidth>fMaxWidth) fMaxWidth = fTitleWidth;
168 }
169
170 BRect oDlgRect(30,30,0,0);
171 if(!b_LeftPos){
172 BRect oRect(Bounds());
173 oDlgRect.left+=oRect.Width()/2;
174 }
175
176
177 BF_GUI_Dialog *poDialog = new BF_GUI_Dialog(oDlgRect,pcWinTitle,"dialog",oMessage,
178 b_LeftPos?BG_GUI_DIALOG_WINRESIZE_NONE:BG_GUI_DIALOG_WINRESIZE_MOVE_RCENTER,false);
179
180 float fHeight = poSysSetup->oFontToolView.fHeight;
181 if(fHeight<19 && bShowIcons) fHeight = 19;
182
183 BRect oMenuRect(0,0,0,0);
184 poDialog->LocalBounds(oMenuRect);
185 oMenuRect.right = oMenuRect.left + fMaxWidth;
186 oMenuRect.bottom = oMenuRect.top + 5 + fHeight*ploMenu->CountItems();
187
188
189 {
190 float fy = Bounds().Height()-10;
191 if((oMenuRect.top + oMenuRect.Height())>fy) oMenuRect.bottom = fy - oMenuRect.top -10;
192 }
193
194
195
196
197 BView* poMenu = new BF_GUI_DlgView_VMenu(oMenuRect,"menu", B_FOLLOW_ALL,ploMenu,
198 bShowIcons?BF_GUI_DLGVIEW_VMENU_SICON:0);
199
200 poDialog->AddChild(poMenu);
201 poDialog->SetSizeBy(oMenuRect.Width(),oMenuRect.Height());
202 BF_GUI_Func_AddChildToMainView ( poDialog );
203
204 return;
205 }
206
207
208 void
209 BF_GUI_ViewMain::Action_EmptyTrash()
210 {
211 BF_FilesPath oTrashPath(poSysSetup->oPathSysTrash.Path());
212 BF_NodeList loNode;
213 BF_Roster_LoadNodeList(oTrashPath,loNode,BF_ROSTER_LOAD_NODE_ALL_REAL);
214
215 BF_GUI_OperRoster_AddTask(
216 new BF_GUI_FilesPanel_DeleteTask(oTrashPath,loNode,BF_FILESPANEL_DELETE_TO_VOID));
217 }
218
219 void
220 BF_GUI_ViewMain::Action_LoadSavePalete(bool b_Load)
221 {
222
223 BF_GUI_Func_PanelsEnable(false);
224
225 BMessage oMessage(b_Load?BF_MSG_MAINVIEW_LOAD_PALLETE_1:BF_MSG_MAINVIEW_SAVE_PALLETE_1);
226 oMessage.AddPointer("bf_focus",this);
227 oMessage.AddPointer("bf_oldfocus",poWin->CurrentFocus());
228
229 BF_GUI_Dialog *poDialog = new BF_GUI_Dialog(BRect(0,0,300,0),
230 BF_DictAt(b_Load?BF_DICT_PAL_LOAD:BF_DICT_PAL_SAVE),"dialog",oMessage,BG_GUI_DIALOG_WINRESIZE_MOVE_CENTER);
231 BRect oRect;
232
233 poDialog->LocalBounds(oRect);
234 oRect.bottom = oRect.top+poSysSetup->oFontToolView.fHeight;
235 BF_GUI_ViewEdit_Create(oRect,BF_DictAt(BF_DICT_PAL_FILENAME),poDialog,"bf_cName",
236 "untitled", B_FOLLOW_LEFT_RIGHT|B_FOLLOW_TOP,B_NAVIGABLE);
237
238 poDialog->AddOkCancelMenu(oRect);
239
240 poDialog->SetHeightFromLastChild();
241 poDialog->MoveToCenter( poWinView );
242 BF_GUI_Func_AddChildToMainView ( poDialog );
243 }
244
245 void
246 BF_GUI_ViewMain::Action_SavePalete_1(BMessage * po_Message)
247 {
248 BF_GUI_Func_PanelsEnable(true);
249 BView *poOldFocus=NULL;
250 ASSERT(B_OK==po_Message->FindPointer("bf_oldfocus",(void**)&poOldFocus));
251 poOldFocus->MakeFocus();
252
253 const char *pcName=NULL;
254 if(B_OK!=po_Message->FindString("bf_cName",&pcName) && !pcName) return;
255
256 poSysSetup->SavePalete(pcName);
257 }
258
259 void
260 BF_GUI_ViewMain::Action_LoadPalete_1(BMessage * po_Message)
261 {
262 BF_GUI_Func_PanelsEnable(true);
263 BView *poOldFocus=NULL;
264 ASSERT(B_OK==po_Message->FindPointer("bf_oldfocus",(void**)&poOldFocus));
265 poOldFocus->MakeFocus();
266
267 const char *pcName=NULL;
268 if(B_OK!=po_Message->FindString("bf_cName",&pcName) && !pcName) return;
269
270 poSysSetup->LoadPalete(pcName);
271
272 BMessenger oMessenger(poWin);
273 BMessage oMessage(BF_MSG_SETUP_UPDATED);
274 oMessenger.SendMessage(&oMessage);
275 }
276
277 #include "BF_GUI_FtpPanel.h"
278
279 void
280 BF_GUI_ViewMain::Action_Open_FtpPanel(bool b_PosLeft)
281 {
282 BF_GUI_FtpPanel *po;
283 po = new BF_GUI_FtpPanel(poWinView->PanelRect(b_PosLeft),b_PosLeft);
284 poWinView->AddPanel(po);
285
286
287
288 }
289
290 #include "BF_Node.h"
291 #include "BF_Roster.h"
292
293 void
294 BF_GUI_ViewMain::Action_SelectDict()
295 {
296
297 BL_String sAppPath;
298 if(!BF_Path::GetPathForCurrentApp(sAppPath)) return;
299
300
301 BF_Path oPath(sAppPath.String());
302 BF_NodeList loNode;
303 if(!BF_Roster_LoadNodeList(oPath,loNode,BF_ROSTER_LOAD_NODE_FILE|BF_ROSTER_LOAD_SICON)) return;
304
305
306 BL_List *ploMenu=new BL_List();
307 for(int i=0;i<loNode.CountItems();i++){
308 BF_Node *poNode = loNode.NodeAt(i);
309 if(!poNode->CheckByMask("*.dict")) continue;
310 ploMenu->AddItem(new BF_GUI_ViewMenu_Item(poNode->sName.String(),poNode->sName.String(),new BBitmap(poNode->poSIcon)));
311 }
312
313
314
315 BF_GUI_Func_PanelsEnable(false);
316
317 BMessage oMessage(BF_MSG_MAINVIEW_SELECTDICT_1);
318 oMessage.AddPointer("bf_focus",this);
319 oMessage.AddPointer("bf_panel_focus",(void*)poWin->CurrentFocus());
320
321 BF_GUI_Dialog *poDialog = new BF_GUI_Dialog(BRect(0,0,300,0),
322 BF_DictAt(BF_DICT_SELDICT_TITLE),"dialog",oMessage,BG_GUI_DIALOG_WINRESIZE_MOVE_CENTER);
323 BRect oRect;
324
325 poDialog->LocalBounds(oRect);
326 oRect.bottom = oRect.top+300;
327
328 poDialog->AddChild(new BF_GUI_DlgView_VMenu(oRect,"bf_lFile",B_FOLLOW_ALL,ploMenu,BF_GUI_DLGVIEW_VMENU_SICON));
329
330 poDialog->AddOkCancelMenu(oRect);
331
332 poDialog->SetHeightFromLastChild();
333 poDialog->MoveToCenter( poWinView );
334 BF_GUI_Func_AddChildToMainView ( poDialog );
335 }
336
337
338 void
339 BF_GUI_ViewMain::Action_SelectDict_1(BMessage *po_Message)
340 {
341 ASSERT(po_Message);
342 BView *poView=NULL;
343 ASSERT(B_OK==po_Message->FindPointer("bf_panel_focus",(void**)&poView) && poView);
344
345 const char *pc=NULL;
346 if(B_OK!=po_Message->FindString("bf_lFile_code",&pc)){
347
348 EnablePanels(true);
349 poView->MakeFocus();
350 return;
351 }
352 poSysSetup->sDictFile = pc;
353 poSysSetup->Save();
354 BF_Dialog_Alert_Sep("","You must restart BeFar now",NULL,poView);
355 }