2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
11 #include <afs/param.h>
20 #include "svr_window.h"
21 #include "svr_general.h"
22 #include "svr_security.h"
23 #include "set_repprop.h"
24 #include "set_createrep.h"
25 #include "set_rename.h"
27 #include "propcache.h"
33 * RESIZING WINDOWS ___________________________________________________________
37 #define cxMIN_SERVER 75
38 #define cyMIN_SERVER 70
40 #define cxMIN_TABS 100
41 #define cyMIN_TABS 100
43 #define cxMIN_WINDOW_PREVIEW 220
44 #define cyMIN_WINDOW_PREVIEW 250
46 #define cxMIN_WINDOW 120
47 #define cyMIN_WINDOW 120
49 rwWindowData awdMain[] = {
50 { IDC_CELL_BORDER, raSizeX, 0, 0 },
51 { IDC_CELL, raSizeX | raRepaint, 0, 0 },
52 { IDC_AFS_ID, raSizeX | raRepaint, 0, 0 },
53 { IDC_SERVERS, raSizeX | raSizeY, MAKELONG(cxMIN_SERVER,cyMIN_SERVER), 0 },
54 { IDC_COVERDLG, raSizeX | raSizeY, 0, 0 },
55 { IDC_ANIMATE, raMoveX, 0, 0 },
56 { idENDLIST, 0, 0, 0 }
59 rwWindowData awdMainVert[] = {
60 { IDC_CELL_BORDER, raSizeX, 0, 0 },
61 { IDC_CELL, raSizeX | raRepaint, 0, 0 },
62 { IDC_AFS_ID, raSizeX | raRepaint, 0, 0 },
63 { IDC_SERVERS, raSizeX, MAKELONG(cxMIN_SERVER,cyMIN_SERVER), 0 },
64 { IDC_SPLITTER_SERVER, raSizeX, 0, 0 },
65 { IDC_TABS, raSizeX | raSizeY, MAKELONG(cxMIN_TABS,cyMIN_TABS), 0 },
66 { IDC_COVERDLG, raSizeX, 0, 0 },
67 { IDC_ANIMATE, raMoveX, 0, 0 },
68 { idENDLIST, 0, 0, 0 }
71 rwWindowData awdMainHorz[] = {
72 { IDC_CELL_BORDER, raSizeX, 0, 0 },
73 { IDC_CELL, raSizeX | raRepaint, 0, 0 },
74 { IDC_AFS_ID, raSizeX | raRepaint, 0, 0 },
75 { IDC_SERVERS, raSizeY, MAKELONG(cxMIN_SERVER,cyMIN_SERVER), 0 },
76 { IDC_SPLITTER_SERVER, raSizeY, 0, 0 },
77 { IDC_TABS, raSizeX | raSizeY, MAKELONG(cxMIN_TABS,cyMIN_TABS), 0 },
78 { IDC_COVERDLG, raSizeY, 0, 0 },
79 { IDC_ANIMATE, raMoveX, 0, 0 },
80 { idENDLIST, 0, 0, 0 }
83 rwWindowData awdSplitServer[] = {
84 { IDC_CELL, raRepaint, 0, 0 },
85 { IDC_AFS_ID, raRepaint, 0, 0 },
86 { IDC_SERVERS, raSizeX | raSizeY, MAKELONG(cxMIN_SERVER,cyMIN_SERVER), 0 },
87 { IDC_SPLITTER_SERVER, raMoveX | raMoveY, 0, 0 },
88 { IDC_TABS, raMoveX | raMoveY | raSizeXB | raSizeYB, MAKELONG(cxMIN_TABS,cyMIN_TABS), 0 },
89 { IDC_COVERDLG, raSizeX | raSizeY, 0, 0 },
90 { IDC_ANIMATE, 0, 0, 0 },
91 { idENDLIST, 0, 0, 0 }
96 * PROTOTYPES _________________________________________________________________
100 void Main_OnNotifyFromDispatch (LPNOTIFYSTRUCT lpns);
102 void Main_OnPreviewPane (BOOL fPreviewNew, BOOL fVertNew, BOOL fStoreView);
103 DWORD WINAPI Main_OnOpenServers_ThreadProc (PVOID lp);
105 void Main_SubclassServers (HWND hDlg);
107 void Main_CreateTabControl (void);
108 void Main_DeleteTabControl (void);
109 void Main_DisplayTab (CHILDTAB iTab);
110 void Main_RearrangeChildren (BOOL fSplitNew, BOOL fVertNew);
112 BOOL Main_HandleDialogKeys (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp);
113 void Main_OnKey_CtrlTab (BOOL fForward);
114 void Main_OnKey_Tab (BOOL fForward);
117 void ExportCell (void);
122 * ROUTINES ___________________________________________________________________
127 static BOOL fEnforceMinimumSize = TRUE;
128 static BOOL fNotifyChildrenForResize = TRUE;
129 static LONG nReqWorking = 0;
130 static int iFrameLast = 0;
132 BOOL CALLBACK Main_DialogProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp)
134 if (HandleColumnNotify (hDlg, msg, wp, lp, (gr.fPreview && !gr.fVert) ? &gr.diHorz.viewSvr : &gr.diVert.viewSvr))
137 if (Main_HandleDialogKeys (hDlg, msg, wp, lp))
140 if (msg == WM_INITDIALOG) // get this out of the way. :)
143 AfsAppLib_SetMainWindow (g.hMain);
150 LPRECT prTarget = (gr.fPreview) ? &gr.rMainPreview : &gr.rMain;
151 if (prTarget->right == 0)
152 GetWindowRect (g.hMain, prTarget);
153 ResizeWindow (g.hMain, awdMain, rwaMoveToHere, prTarget);
155 Main_SetActionMenus();
157 // Subclass the Servers window, so we can watch for focus changes
158 // and context-menu requests
160 Main_SubclassServers (hDlg);
161 FastList_SetTextCallback (GetDlgItem (hDlg, IDC_SERVERS), GetItemText, (DWORD)((gr.fPreview && !gr.fVert) ? &gr.diHorz.viewSvr : &gr.diVert.viewSvr));
163 // Create the preview pane and rearrange the children of this dialog.
164 // This also fixes the Servers display--was it in Large Icons view?
165 // What columns were shown?
167 Main_OnPreviewPane (gr.fPreview, gr.fVert, FALSE);
169 // Tell our notification dispatcher to let this window know whenever
170 // a cell gets opened or closed (that's what the NULL does--otherwise,
171 // an LPIDENT would go there to indicate we're interested in a
172 // particular server etc).
174 NotifyMe (WHEN_CELL_OPENED, NULL, hDlg, 0); // tell me about any cell
176 // If we weren't around when the cell was created, we might have
177 // missed some notifications. Send a redraw just in case.
179 StartThread (Main_Redraw_ThreadProc, FALSE);
181 SetTimer (hDlg, ID_DISPATCH_TIMER, 200, NULL); // do all notifications
186 KillTimer (hDlg, ID_DISPATCH_TIMER);
189 case WM_QUERYENDSESSION:
190 if (Action_fAnyActive())
192 ShowWindow (g.hMain, SW_SHOW);
193 if (Message (MB_ICONHAND | MB_YESNO, IDS_CANT_QUIT_TITLE, IDS_CANT_QUIT_REBOOT) != IDYES)
199 if (wp == ID_DISPATCH_TIMER)
201 DispatchNotification_OnPump();
206 if ((lp == 0) || (IsAncestor (g.hMain, (HWND)(((LPHELPINFO)lp)->hItemHandle))))
208 WinHelp (hDlg, cszHELPFILENAME, HELP_FINDER, 0);
212 case WM_NOTIFY_FROM_DISPATCH:
213 Main_OnNotifyFromDispatch ((LPNOTIFYSTRUCT)lp);
214 Delete ((LPNOTIFYSTRUCT)lp);
219 if ((ptp = (LPTASKPACKET)lp) != NULL)
221 if (ptp->idTask == taskSVR_GETWINDOWPOS)
222 Server_Open ((LPIDENT)(ptp->lpUser), &TASKDATA(ptp)->rWindow);
223 else if (ptp->idTask == taskSET_REPPROP_INIT)
224 Filesets_OnEndTask_ShowReplication (ptp);
225 else if (ptp->idTask == taskSET_RENAME_INIT)
226 Filesets_OnEndTask_ShowRename (ptp);
227 FreeTaskPacket (ptp);
231 case WM_OPEN_SERVERS:
232 StartThread (Main_OnOpenServers_ThreadProc, 0);
236 StartTask (taskSVR_GETWINDOWPOS, g.hMain, (LPIDENT)lp);
239 case WM_SHOW_CREATEREP_DIALOG:
240 Filesets_CreateReplica ((LPIDENT)wp, (LPIDENT)lp);
243 case WM_SHOW_YOURSELF:
246 ShowWindow (g.hMain, SW_SHOW);
247 BringWindowToTop (g.hMain);
248 Action_WindowToTop (TRUE);
252 case WM_OPEN_ACTIONS:
256 case WM_REFRESHED_CREDENTIALS:
257 g.hCreds = (PVOID)lp;
258 UpdateDisplay_Cell(FALSE);
259 StartTask (taskREFRESH_CREDS, NULL, g.lpiCell);
263 // if (lp==0), we're minimizing--don't call ResizeWindow().
265 Action_WindowToTop ((lp) ? TRUE : FALSE);
268 rwWindowData *pwdResizeInfo;
271 pwdResizeInfo = awdMain;
273 pwdResizeInfo = awdMainVert;
275 pwdResizeInfo = awdMainHorz;
277 if (fNotifyChildrenForResize)
278 ResizeWindow (hDlg, pwdResizeInfo, rwaFixupGuts);
280 ResizeWindow (hDlg, pwdResizeInfo, rwaJustResync);
285 Action_WindowToTop ((wp) ? TRUE : FALSE);
288 StartTask (taskEXPIRED_CREDS);
295 ptScreen.x = LOWORD(lp);
296 ptScreen.y = HIWORD(lp);
299 ScreenToClient ((HWND)wp, &ptClient);
301 if ((HWND)wp == GetDlgItem (g.hMain, IDC_SERVERS))
302 Server_ShowPopupMenu ((HWND)wp, ptClient, ptScreen);
315 Main_OnPreviewPane (FALSE, gr.fVert, TRUE);
316 UpdateDisplay_Servers (FALSE, NULL, 0);
319 Main_OnPreviewPane (TRUE, FALSE, TRUE);
320 UpdateDisplay_Servers (FALSE, NULL, 0);
323 Main_OnPreviewPane (TRUE, TRUE, TRUE);
324 UpdateDisplay_Servers (FALSE, NULL, 0);
327 case M_SVR_VIEW_LARGE:
328 Main_OnServerView (FLS_VIEW_LARGE);
330 case M_SVR_VIEW_SMALL:
331 Main_OnServerView (FLS_VIEW_SMALL);
333 case M_SVR_VIEW_REPORT:
334 Main_OnServerView (FLS_VIEW_LIST);
339 ShowColumnsDialog (hDlg, NULL);
342 CHILDTAB iTab = Server_GetDisplayedTab (g.hMain);
343 if (iTab == tabSERVICES)
344 ShowColumnsDialog (hDlg, &gr.viewSvc);
345 else if (iTab == tabAGGREGATES)
346 ShowColumnsDialog (hDlg, &gr.viewAgg);
347 else if (iTab == tabFILESETS)
348 ShowColumnsDialog (hDlg, &gr.viewSet);
350 ShowColumnsDialog (hDlg, NULL);
355 if ((gr.fActions = !gr.fActions) == TRUE)
358 Action_CloseWindow();
359 Main_SetActionMenus();
368 case IDC_COVER_BUTTON:
369 // The user must have clicked the "Try Again" or "Credentials"
370 // button on the cover we placed over the Servers list.
371 // Refresh the cell or obtain new credentials, as appropriate.
375 TCHAR szButton[ cchRESOURCE ];
376 GetWindowText ((HWND)lp, szButton, cchRESOURCE);
378 TCHAR szTest[ cchRESOURCE ];
380 GetString (szTest, IDS_ALERT_BUTTON_TRYAGAIN);
381 if (!lstrcmp (szTest, szButton))
383 StartTask (taskREFRESH, NULL, g.lpiCell);
387 GetString (szTest, IDS_ALERT_BUTTON_GETCREDS);
388 if (!lstrcmp (szTest, szButton))
397 StartContextCommand (g.hMain, NULL, NULL, LOWORD(wp));
403 switch (((LPNMHDR)lp)->code)
407 int iPage = TabCtrl_GetCurSel (GetDlgItem (g.hMain, IDC_TABS));
408 Main_DisplayTab ((CHILDTAB)iPage);
415 HWND hServers = GetDlgItem (hDlg, IDC_SERVERS);
416 LPIDENT lpi = (LPIDENT)FL_GetSelectedData (hServers);
418 Server_SelectServer (SERVERWINDOW_PREVIEWPANE, lpi);
424 HWND hServers = GetDlgItem (g.hMain, IDC_SERVERS);
426 if (((LPNMHDR)lp)->hwndFrom == hServers)
428 LPIDENT lpi = (LPIDENT)FL_GetSelectedData (hServers);
430 if (lpi && lpi->fIsServer())
434 if (gr.fDoubleClickOpens == 0)
436 else if (gr.fDoubleClickOpens == 1)
438 else if (gr.fPreview)
440 else // (!gr.Preview)
445 PostMessage (hServers, WM_COMMAND, M_PROPERTIES, 0);
447 else // (fOpenWindow)
449 PostMessage (g.hMain, WM_OPEN_SERVER, 0, (LPARAM)lpi);
463 void Main_OnNotifyFromDispatch (LPNOTIFYSTRUCT lpns)
468 StartTask (taskOPENEDCELL, NULL, lpns->Params.lpi1);
472 StartTask (taskCLOSEDCELL, NULL, lpns->Params.lpi1);
475 case evtRefreshStatusEnd:
476 case evtAlertsChanged:
477 if (lpns->Params.lpi1 && lpns->Params.lpi1->fIsCell())
479 UpdateDisplay_Cell (FALSE);
481 else if (lpns->Params.lpi1 && lpns->Params.lpi1->fIsServer())
483 UpdateDisplay_Servers (FALSE, lpns->Params.lpi1, lpns->Params.status);
487 case evtRefreshServersEnd:
488 if (g.lpiCell || lpns->Params.status == 0)
490 UpdateDisplay_Servers (FALSE, NULL, 0);
497 DWORD WINAPI Main_OnOpenServers_ThreadProc (PVOID lp)
501 if (g.lpiCell != NULL)
504 if ((lpCell = g.lpiCell->OpenCell()) != NULL)
507 for (LPSERVER lpServer = lpCell->ServerFindFirst (&hEnum); lpServer; lpServer = lpCell->ServerFindNext (&hEnum))
510 if ((lpsp = (LPSERVER_PREF)lpServer->GetUserParam()) != NULL)
512 if (lpsp->fOpen && !PropCache_Search (pcSERVER, lpServer->GetIdentifier()))
514 PostMessage (g.hMain, WM_OPEN_SERVER, 0, (LPARAM)(lpServer->GetIdentifier()));
528 DWORD WINAPI Main_Redraw_ThreadProc (PVOID lp)
530 BOOL fInvalidate = (BOOL)lp;
533 if (g.lpiCell == NULL)
535 AfsAppLib_Uncover (GetDlgItem (g.hMain, IDC_SERVERS));
539 TCHAR szName[ cchRESOURCE ];
540 g.lpiCell->GetCellName (szName);
542 LPTSTR pszCover = FormatString (IDS_SEARCHING_FOR_SERVERS, TEXT("%s"), szName);
543 AfsAppLib_CoverWindow (GetDlgItem (g.hMain, IDC_SERVERS), pszCover);
544 FreeString (pszCover);
547 LPCELL lpCell = NULL;
548 if (g.lpiCell != NULL)
549 lpCell = g.lpiCell->OpenCell();
555 lpCell->Invalidate();
556 lpCell->RefreshAll();
560 lpCell->RefreshStatus();
561 lpCell->RefreshServers();
564 else // no cell is selected; we'll have to redraw the window directly.
566 UpdateDisplay_Cell (TRUE);
567 UpdateDisplay_Servers (TRUE, NULL, 0);
578 void Main_OnPreviewPane (BOOL fPreviewNew, BOOL fVertNew, BOOL fStoreCurrentView)
580 if (fStoreCurrentView)
582 if (gr.fPreview && !gr.fVert)
583 FL_StoreView (GetDlgItem (g.hMain, IDC_SERVERS), &gr.diHorz.viewSvr);
585 FL_StoreView (GetDlgItem (g.hMain, IDC_SERVERS), &gr.diVert.viewSvr);
588 GetWindowRect (g.hMain, &gr.rMainPreview);
590 GetWindowRect (g.hMain, &gr.rMain);
593 // If switching from having a preview pane to not (or vice-versa),
594 // and we have an alterate gr.rMain* to switch to, resize the window.
596 if (IsWindowVisible (g.hMain))
599 GetWindowRect (g.hMain, &rNow);
601 LPRECT prTarget = (fPreviewNew) ? &gr.rMainPreview : &gr.rMain;
602 if (prTarget->right == 0)
605 if (gr.fPreview && gr.fVert) // preview pane exists below main window?
608 GetWindowRect (GetDlgItem (g.hMain, IDC_TABS), &rPreview);
610 prTarget->bottom -= cyRECT(rPreview);
613 prTarget->right = prTarget->left + cxRECT(rNow); // keep the same width!
615 fEnforceMinimumSize = FALSE;
616 fNotifyChildrenForResize = FALSE;
618 SetWindowPos (g.hMain, NULL,
619 0, 0, cxRECT(*prTarget), cyRECT(*prTarget),
620 SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOMOVE);
622 fNotifyChildrenForResize = TRUE;
623 fEnforceMinimumSize = TRUE;
626 // Create a tab control if necessary, or remove it if it should be gone.
628 if (fPreviewNew && !GetDlgItem (g.hMain, IDC_TABS))
630 Main_CreateTabControl();
632 if (!fPreviewNew && GetDlgItem (g.hMain, IDC_TABS))
634 Main_DeleteTabControl();
637 // If there's a tab control, we'll need a splitter; if not, not.
639 if (GetDlgItem (g.hMain, IDC_SPLITTER_SERVER))
641 DeleteSplitter (g.hMain, IDC_SPLITTER_SERVER);
644 Main_RearrangeChildren (fPreviewNew, fVertNew);
648 CreateSplitter (g.hMain, IDC_SERVERS, IDC_TABS, IDC_SPLITTER_SERVER,
649 (fVertNew) ? &gr.diVert.cSplitter : &gr.diHorz.cSplitter,
654 if (GetDlgItem (g.hMain, IDC_TABS))
656 ShowWindow (GetDlgItem (g.hMain, IDC_TABS), SW_SHOW);
659 LPVIEWINFO lpvi = (fPreviewNew && !fVertNew) ? &gr.diHorz.viewSvr : &gr.diVert.viewSvr;
661 FL_RestoreView (GetDlgItem (g.hMain, IDC_SERVERS), lpvi);
663 CheckMenuRadioItem (GetMenu (g.hMain),
664 M_DIVIDE_NONE, M_DIVIDE_H,
665 ( (!fPreviewNew) ? M_DIVIDE_NONE :
666 (fVertNew) ? M_DIVIDE_V :
671 gr.fPreview = fPreviewNew;
673 Main_SetServerViewMenus();
677 void Main_OnServerView (int lvsNew)
679 HWND hServers = GetDlgItem (g.hMain, IDC_SERVERS);
681 if (gr.fPreview && !gr.fVert)
682 FL_StoreView (hServers, &gr.diHorz.viewSvr);
684 FL_StoreView (hServers, &gr.diVert.viewSvr);
686 if (gr.fPreview && !gr.fVert)
687 gr.diHorz.viewSvr.lvsView = lvsNew;
689 gr.diVert.viewSvr.lvsView = lvsNew;
691 if (gr.fPreview && !gr.fVert)
692 FL_RestoreView (hServers, &gr.diHorz.viewSvr);
694 FL_RestoreView (hServers, &gr.diVert.viewSvr);
696 Main_SetServerViewMenus();
697 FastList_SetTextCallback (GetDlgItem (g.hMain, IDC_SERVERS), GetItemText, (DWORD)((gr.fPreview && !gr.fVert) ? &gr.diHorz.viewSvr : &gr.diVert.viewSvr));
698 UpdateDisplay_Servers (FALSE, NULL, 0);
702 void Main_SetServerViewMenus (void)
706 if (gr.fPreview && !gr.fVert)
707 lvs = gr.diHorz.viewSvr.lvsView;
709 lvs = gr.diVert.viewSvr.lvsView;
711 CheckMenuRadioItem (GetMenu (g.hMain),
712 M_SVR_VIEW_LARGE, M_SVR_VIEW_REPORT,
713 ( (lvs == FLS_VIEW_SMALL) ? M_SVR_VIEW_SMALL :
714 (lvs == FLS_VIEW_LIST) ? M_SVR_VIEW_REPORT :
718 ICONVIEW ivSvr = Display_GetServerIconView();
720 CheckMenuRadioItem (GetMenu (g.hMain),
721 M_SVR_VIEW_ONEICON, M_SVR_VIEW_STATUS,
722 (ivSvr == ivTWOICONS) ? M_SVR_VIEW_TWOICONS :
723 (ivSvr == ivONEICON) ? M_SVR_VIEW_ONEICON : M_SVR_VIEW_STATUS,
726 EnableMenu (GetMenu (g.hMain), M_SVR_VIEW_ONEICON, (lvs == FLS_VIEW_LIST) ? TRUE : FALSE);
727 EnableMenu (GetMenu (g.hMain), M_SVR_VIEW_TWOICONS, (lvs == FLS_VIEW_LIST) ? TRUE : FALSE);
728 EnableMenu (GetMenu (g.hMain), M_SVR_VIEW_STATUS, (lvs == FLS_VIEW_LIST) ? TRUE : FALSE);
732 void Main_SetActionMenus (void)
734 CheckMenu (GetMenu (g.hMain), M_ACTIONS, gr.fActions);
738 void Main_CreateTabControl (void)
740 HWND hTab = CreateWindowEx (WS_EX_CLIENTEDGE,
743 WS_CHILD | WS_CLIPSIBLINGS | WS_TABSTOP,
744 0, 0, 128, 128, // arbitrary, but not too small
745 SERVERWINDOW_PREVIEWPANE,
752 HFONT hf = (HFONT)GetStockObject (DEFAULT_GUI_FONT);
753 SendMessage (hTab, WM_SETFONT, (WPARAM)hf, MAKELPARAM(TRUE,0));
755 Server_PrepareTabControl (hTab);
757 LPIDENT lpi = (LPIDENT)FL_GetSelectedData (GetDlgItem (g.hMain, IDC_SERVERS));
758 Server_SelectServer (SERVERWINDOW_PREVIEWPANE, lpi);
763 void Main_DeleteTabControl (void)
765 if (GetDlgItem (SERVERWINDOW_PREVIEWPANE, IDC_TABS))
767 DestroyWindow (GetDlgItem (SERVERWINDOW_PREVIEWPANE, IDC_TABS));
772 void Main_DisplayTab (CHILDTAB iTab)
776 Server_DisplayTab (SERVERWINDOW_PREVIEWPANE, iTab);
777 gr.tabLast = (CHILDTAB)iTab;
782 void Main_RearrangeChildren (BOOL fPreviewNew, BOOL fVertNew)
787 // Start with the Servers window taking up the entire dialog's client area,
788 // leaving a space at the top for the cell combobox.
791 GetRectInParent (GetDlgItem (g.hMain, IDC_AFS_ID), &rCell);
793 GetClientRect (g.hMain, &rServers);
794 rServers.top = rCell.bottom +3;
796 // Then, if the preview tab is to be displayed, make the server window
797 // share the space equally with the tab control (vertically or horizontally)
805 rServers.bottom = rServers.top + cyRECT(rServers)/2 - 1;
806 rPreview.top = rServers.bottom + 2;
810 rServers.right = rServers.left + cxRECT(rServers)/2 - 1;
811 rPreview.left = rServers.right + 2;
814 // Adjust the server/tab windows for the Server splitter's position
818 LONG cyMod = gr.diVert.cSplitter;
820 if (cyRECT(rServers) > cyMIN_SERVER)
821 cyMod = min( cyMod, cyRECT(rServers)-cyMIN_SERVER );
822 if (cyRECT(rPreview) > cyMIN_TABS)
823 cyMod = min( cyMod, cyRECT(rPreview)-cyMIN_TABS );
825 rServers.bottom += cyMod;
826 rPreview.top += cyMod;
830 LONG cxMod = gr.diHorz.cSplitter;
832 if (cxRECT(rServers) > cxMIN_SERVER)
833 cxMod = min( cxMod, cxRECT(rServers)-cxMIN_SERVER );
834 if (cxRECT(rPreview) > cxMIN_TABS)
835 cxMod = min( cxMod, cxRECT(rPreview)-cxMIN_TABS );
837 rServers.right += cxMod;
838 rPreview.left += cxMod;
842 // Now move the children to their new places!
845 if (GetDlgItem (g.hMain, IDC_COVERDLG))
847 if (GetDlgItem (g.hMain, IDC_TABS))
849 HDWP dwp = BeginDeferWindowPos (nWindows);
851 DeferWindowPos (dwp, GetDlgItem (g.hMain, IDC_SERVERS), NULL,
852 rServers.left, rServers.top,
853 cxRECT(rServers), cyRECT(rServers),
854 SWP_NOACTIVATE | SWP_NOZORDER);
856 if (GetDlgItem (g.hMain, IDC_COVERDLG))
858 DeferWindowPos (dwp, GetDlgItem (g.hMain, IDC_COVERDLG), NULL,
859 rServers.left, rServers.top,
860 cxRECT(rServers), cyRECT(rServers),
861 SWP_NOACTIVATE | SWP_NOZORDER);
864 if (GetDlgItem (g.hMain, IDC_TABS))
866 DeferWindowPos (dwp, GetDlgItem (g.hMain, IDC_TABS), NULL,
867 rPreview.left, rPreview.top,
868 cxRECT(rPreview), cyRECT(rPreview),
869 SWP_NOACTIVATE | SWP_NOZORDER);
872 EndDeferWindowPos (dwp);
877 static LONG procServers = 0;
879 LRESULT CALLBACK Main_SubclassServersProc (HWND hServers, UINT msg, WPARAM wp, LPARAM lp)
883 if (procServers == 0)
884 rc = DefWindowProc (hServers, msg, wp, lp);
886 rc = CallWindowProc ((WNDPROC)procServers, hServers, msg, wp, lp);
891 if (procServers != 0)
892 SetWindowLong (hServers, GWL_WNDPROC, procServers);
898 case M_SVR_VIEW_LARGE:
899 case M_SVR_VIEW_SMALL:
900 case M_SVR_VIEW_REPORT:
901 SendMessage (g.hMain, msg, wp, lp);
905 case M_VIEW_TWOICONS:
907 SendMessage (g.hMain, msg, wp, lp);
911 ShowColumnsDialog (g.hMain, NULL);
915 StartContextCommand (g.hMain,
917 (LPIDENT)FL_GetSelectedData (hServers),
928 void Main_SubclassServers (HWND hDlg)
930 HWND hServers = GetDlgItem (hDlg, IDC_SERVERS);
931 procServers = GetWindowLong (hServers, GWL_WNDPROC);
932 SetWindowLong (hServers, GWL_WNDPROC, (LONG)Main_SubclassServersProc);
937 void ExportCell (void)
942 TCHAR szFilter[ cchRESOURCE ];
943 lstrcpy (szFilter, TEXT("Text File|*.TXT|"));
944 TCHAR chFilter = szFilter[ lstrlen(szFilter)-1 ];
945 for (LPTSTR pszFilter = szFilter;
946 (*pszFilter) && ((pszFilter = (LPTSTR)lstrchr (pszFilter, chFilter)) != NULL);
949 *pszFilter = TEXT('\0');
952 TCHAR szSaveAs[ MAX_PATH ] = TEXT("export");
955 memset (&sfn, 0x00, sizeof(sfn));
956 sfn.lStructSize = sizeof(sfn);
957 sfn.hwndOwner = g.hMain;
958 sfn.hInstance = THIS_HINST;
959 sfn.lpstrFilter = szFilter;
960 sfn.nFilterIndex = 1;
961 sfn.lpstrFile = szSaveAs;
962 sfn.nMaxFile = MAX_PATH;
963 sfn.Flags = OFN_HIDEREADONLY | OFN_NOREADONLYRETURN |
964 OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST;
965 sfn.lpstrDefExt = TEXT("txt");
967 if (GetSaveFileName (&sfn))
969 LPTSTR psz = CloneString (szSaveAs);
970 StartTask (taskEXPORTCELL, NULL, psz);
976 void Main_StartWorking (void)
978 if (InterlockedIncrement(&nReqWorking) == 1)
980 AfsAppLib_StartAnimation (GetDlgItem (g.hMain, IDC_ANIMATE));
984 void Main_StopWorking (void)
986 if (InterlockedDecrement(&nReqWorking) == 0)
988 AfsAppLib_StopAnimation (GetDlgItem (g.hMain, IDC_ANIMATE));
993 void Main_AnimateIcon (HWND hIcon, int *piFrameLast)
996 static HICON hiFrame[8];
997 static BOOL fLoaded = FALSE;
1001 hiStop = TaLocale_LoadIcon (IDI_SPINSTOP);
1002 hiFrame[0] = TaLocale_LoadIcon (IDI_SPIN1);
1003 hiFrame[1] = TaLocale_LoadIcon (IDI_SPIN2);
1004 hiFrame[2] = TaLocale_LoadIcon (IDI_SPIN3);
1005 hiFrame[3] = TaLocale_LoadIcon (IDI_SPIN4);
1006 hiFrame[4] = TaLocale_LoadIcon (IDI_SPIN5);
1007 hiFrame[5] = TaLocale_LoadIcon (IDI_SPIN6);
1008 hiFrame[6] = TaLocale_LoadIcon (IDI_SPIN7);
1009 hiFrame[7] = TaLocale_LoadIcon (IDI_SPIN8);
1015 *piFrameLast = (*piFrameLast == 7) ? 0 : (1+*piFrameLast);
1018 SendMessage (hIcon, STM_SETICON, (WPARAM)((piFrameLast) ? hiFrame[ *piFrameLast ] : hiStop), 0);
1022 BOOL Main_HandleDialogKeys (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp)
1024 if (msg == WM_COMMAND)
1029 Server_OnKey_Return();
1033 Main_OnKey_CtrlTab (TRUE);
1036 case M_KEY_CTRLBACKTAB:
1037 Main_OnKey_CtrlTab (FALSE);
1041 Main_OnKey_Tab (TRUE);
1045 Main_OnKey_Tab (FALSE);
1049 Server_OnKey_Menu();
1056 case M_KEY_PROPERTIES:
1057 Server_OnKey_Properties();
1066 void Main_OnKey_Tab (BOOL fForward)
1068 // The tab-cycle should go:
1069 // ServerList <-> TabsOnQuickViewPane <-> TabChildControls
1071 // If the quick-view pane isn't showing, there's nowhere to tab to.
1075 HWND hFocus = GetFocus();
1076 HWND hTabChild = GetTabChild (GetDlgItem (g.hMain, IDC_TABS));
1080 if (hFocus == GetDlgItem (g.hMain, IDC_SERVERS))
1082 PostMessage (g.hMain, WM_NEXTDLGCTL, (WPARAM)GetDlgItem (g.hMain, IDC_TABS), TRUE);
1084 else if (hFocus == GetDlgItem (g.hMain, IDC_TABS))
1086 PostMessage (g.hMain, WM_NEXTDLGCTL, (WPARAM)GetNextDlgTabItem (hTabChild, NULL, FALSE), TRUE);
1090 if (GetNextDlgTabItem (hTabChild, hFocus, FALSE) == GetNextDlgTabItem (hTabChild, NULL, FALSE))
1091 PostMessage (g.hMain, WM_NEXTDLGCTL, (WPARAM)GetDlgItem (g.hMain, IDC_SERVERS), TRUE);
1093 PostMessage (g.hMain, WM_NEXTDLGCTL, (WPARAM)GetNextDlgTabItem (hTabChild, hFocus, FALSE), TRUE);
1098 if (hFocus == GetDlgItem (g.hMain, IDC_SERVERS))
1100 PostMessage (g.hMain, WM_NEXTDLGCTL, (WPARAM)GetLastDlgTabItem (hTabChild), TRUE);
1102 else if (hFocus == GetDlgItem (g.hMain, IDC_TABS))
1104 PostMessage (g.hMain, WM_NEXTDLGCTL, (WPARAM)GetDlgItem (g.hMain, IDC_SERVERS), TRUE);
1108 if (hFocus == GetNextDlgTabItem (hTabChild, NULL, FALSE))
1109 PostMessage (g.hMain, WM_NEXTDLGCTL, (WPARAM)GetDlgItem (g.hMain, IDC_TABS), TRUE);
1111 PostMessage (g.hMain, WM_NEXTDLGCTL, (WPARAM)GetNextDlgTabItem (hTabChild, hFocus, TRUE), TRUE);
1118 void Main_OnKey_CtrlTab (BOOL fForward)
1122 Server_OnKey_CtrlTab (SERVERWINDOW_PREVIEWPANE, fForward);