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
14 #include <afsconfig.h>
15 #include <afs/param.h>
24 #include "svr_window.h"
25 #include "svr_general.h"
26 #include "svr_security.h"
27 #include "set_repprop.h"
28 #include "set_createrep.h"
29 #include "set_rename.h"
31 #include "propcache.h"
37 * RESIZING WINDOWS ___________________________________________________________
41 #define cxMIN_SERVER 75
42 #define cyMIN_SERVER 70
44 #define cxMIN_TABS 100
45 #define cyMIN_TABS 100
47 #define cxMIN_WINDOW_PREVIEW 220
48 #define cyMIN_WINDOW_PREVIEW 250
50 #define cxMIN_WINDOW 120
51 #define cyMIN_WINDOW 120
53 rwWindowData awdMain[] = {
54 { IDC_CELL_BORDER, raSizeX, 0, 0 },
55 { IDC_CELL, raSizeX | raRepaint, 0, 0 },
56 { IDC_AFS_ID, raSizeX | raRepaint, 0, 0 },
57 { IDC_SERVERS, raSizeX | raSizeY, MAKELONG(cxMIN_SERVER,cyMIN_SERVER), 0 },
58 { IDC_COVERDLG, raSizeX | raSizeY, 0, 0 },
59 { IDC_ANIMATE, raMoveX, 0, 0 },
60 { idENDLIST, 0, 0, 0 }
63 rwWindowData awdMainVert[] = {
64 { IDC_CELL_BORDER, raSizeX, 0, 0 },
65 { IDC_CELL, raSizeX | raRepaint, 0, 0 },
66 { IDC_AFS_ID, raSizeX | raRepaint, 0, 0 },
67 { IDC_SERVERS, raSizeX, MAKELONG(cxMIN_SERVER,cyMIN_SERVER), 0 },
68 { IDC_SPLITTER_SERVER, raSizeX, 0, 0 },
69 { IDC_TABS, raSizeX | raSizeY, MAKELONG(cxMIN_TABS,cyMIN_TABS), 0 },
70 { IDC_COVERDLG, raSizeX, 0, 0 },
71 { IDC_ANIMATE, raMoveX, 0, 0 },
72 { idENDLIST, 0, 0, 0 }
75 rwWindowData awdMainHorz[] = {
76 { IDC_CELL_BORDER, raSizeX, 0, 0 },
77 { IDC_CELL, raSizeX | raRepaint, 0, 0 },
78 { IDC_AFS_ID, raSizeX | raRepaint, 0, 0 },
79 { IDC_SERVERS, raSizeY, MAKELONG(cxMIN_SERVER,cyMIN_SERVER), 0 },
80 { IDC_SPLITTER_SERVER, raSizeY, 0, 0 },
81 { IDC_TABS, raSizeX | raSizeY, MAKELONG(cxMIN_TABS,cyMIN_TABS), 0 },
82 { IDC_COVERDLG, raSizeY, 0, 0 },
83 { IDC_ANIMATE, raMoveX, 0, 0 },
84 { idENDLIST, 0, 0, 0 }
87 rwWindowData awdSplitServer[] = {
88 { IDC_CELL, raRepaint, 0, 0 },
89 { IDC_AFS_ID, raRepaint, 0, 0 },
90 { IDC_SERVERS, raSizeX | raSizeY, MAKELONG(cxMIN_SERVER,cyMIN_SERVER), 0 },
91 { IDC_SPLITTER_SERVER, raMoveX | raMoveY, 0, 0 },
92 { IDC_TABS, raMoveX | raMoveY | raSizeXB | raSizeYB, MAKELONG(cxMIN_TABS,cyMIN_TABS), 0 },
93 { IDC_COVERDLG, raSizeX | raSizeY, 0, 0 },
94 { IDC_ANIMATE, 0, 0, 0 },
95 { idENDLIST, 0, 0, 0 }
100 * PROTOTYPES _________________________________________________________________
104 void Main_OnNotifyFromDispatch (LPNOTIFYSTRUCT lpns);
106 void Main_OnPreviewPane (BOOL fPreviewNew, BOOL fVertNew, BOOL fStoreView);
107 DWORD WINAPI Main_OnOpenServers_ThreadProc (PVOID lp);
109 void Main_SubclassServers (HWND hDlg);
111 void Main_CreateTabControl (void);
112 void Main_DeleteTabControl (void);
113 void Main_DisplayTab (CHILDTAB iTab);
114 void Main_RearrangeChildren (BOOL fSplitNew, BOOL fVertNew);
116 BOOL Main_HandleDialogKeys (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp);
117 void Main_OnKey_CtrlTab (BOOL fForward);
118 void Main_OnKey_Tab (BOOL fForward);
121 void ExportCell (void);
126 * ROUTINES ___________________________________________________________________
131 static BOOL fEnforceMinimumSize = TRUE;
132 static BOOL fNotifyChildrenForResize = TRUE;
133 static LONG nReqWorking = 0;
134 static int iFrameLast = 0;
136 BOOL CALLBACK Main_DialogProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp)
138 if (HandleColumnNotify (hDlg, msg, wp, lp, (gr.fPreview && !gr.fVert) ? &gr.diHorz.viewSvr : &gr.diVert.viewSvr))
141 if (Main_HandleDialogKeys (hDlg, msg, wp, lp))
144 if (msg == WM_INITDIALOG) // get this out of the way. :)
147 AfsAppLib_SetMainWindow (g.hMain);
154 LPRECT prTarget = (gr.fPreview) ? &gr.rMainPreview : &gr.rMain;
155 if (prTarget->right == 0)
156 GetWindowRect (g.hMain, prTarget);
157 ResizeWindow (g.hMain, awdMain, rwaMoveToHere, prTarget);
159 Main_SetActionMenus();
161 // Subclass the Servers window, so we can watch for focus changes
162 // and context-menu requests
164 Main_SubclassServers (hDlg);
165 FastList_SetTextCallback (GetDlgItem (hDlg, IDC_SERVERS), GetItemText, ((gr.fPreview && !gr.fVert) ? &gr.diHorz.viewSvr : &gr.diVert.viewSvr));
167 // Create the preview pane and rearrange the children of this dialog.
168 // This also fixes the Servers display--was it in Large Icons view?
169 // What columns were shown?
171 Main_OnPreviewPane (gr.fPreview, gr.fVert, FALSE);
173 // Tell our notification dispatcher to let this window know whenever
174 // a cell gets opened or closed (that's what the NULL does--otherwise,
175 // an LPIDENT would go there to indicate we're interested in a
176 // particular server etc).
178 NotifyMe (WHEN_CELL_OPENED, NULL, hDlg, 0); // tell me about any cell
180 // If we weren't around when the cell was created, we might have
181 // missed some notifications. Send a redraw just in case.
183 StartThread (Main_Redraw_ThreadProc, FALSE);
185 SetTimer (hDlg, ID_DISPATCH_TIMER, 200, NULL); // do all notifications
190 KillTimer (hDlg, ID_DISPATCH_TIMER);
193 case WM_QUERYENDSESSION:
194 if (Action_fAnyActive())
196 ShowWindow (g.hMain, SW_SHOW);
197 if (Message (MB_ICONHAND | MB_YESNO, IDS_CANT_QUIT_TITLE, IDS_CANT_QUIT_REBOOT) != IDYES)
203 if (wp == ID_DISPATCH_TIMER)
205 DispatchNotification_OnPump();
210 if ((lp == 0) || (IsAncestor (g.hMain, (HWND)(((LPHELPINFO)lp)->hItemHandle))))
212 WinHelp (hDlg, cszHELPFILENAME, HELP_FINDER, 0);
216 case WM_NOTIFY_FROM_DISPATCH:
217 Main_OnNotifyFromDispatch ((LPNOTIFYSTRUCT)lp);
218 Delete ((LPNOTIFYSTRUCT)lp);
223 if ((ptp = (LPTASKPACKET)lp) != NULL)
225 if (ptp->idTask == taskSVR_GETWINDOWPOS)
226 Server_Open ((LPIDENT)(ptp->lpUser), &TASKDATA(ptp)->rWindow);
227 else if (ptp->idTask == taskSET_REPPROP_INIT)
228 Filesets_OnEndTask_ShowReplication (ptp);
229 else if (ptp->idTask == taskSET_RENAME_INIT)
230 Filesets_OnEndTask_ShowRename (ptp);
231 FreeTaskPacket (ptp);
235 case WM_OPEN_SERVERS:
236 StartThread (Main_OnOpenServers_ThreadProc, 0);
240 StartTask (taskSVR_GETWINDOWPOS, g.hMain, (LPIDENT)lp);
243 case WM_SHOW_CREATEREP_DIALOG:
244 Filesets_CreateReplica ((LPIDENT)wp, (LPIDENT)lp);
247 case WM_SHOW_YOURSELF:
250 ShowWindow (g.hMain, SW_SHOW);
251 BringWindowToTop (g.hMain);
252 Action_WindowToTop (TRUE);
256 case WM_OPEN_ACTIONS:
260 case WM_REFRESHED_CREDENTIALS:
261 g.hCreds = (UINT_PTR)lp;
262 UpdateDisplay_Cell(FALSE);
263 StartTask (taskREFRESH_CREDS, NULL, g.lpiCell);
267 // if (lp==0), we're minimizing--don't call ResizeWindow().
269 Action_WindowToTop ((lp) ? TRUE : FALSE);
272 rwWindowData *pwdResizeInfo;
275 pwdResizeInfo = awdMain;
277 pwdResizeInfo = awdMainVert;
279 pwdResizeInfo = awdMainHorz;
281 if (fNotifyChildrenForResize)
282 ResizeWindow (hDlg, pwdResizeInfo, rwaFixupGuts);
284 ResizeWindow (hDlg, pwdResizeInfo, rwaJustResync);
289 Action_WindowToTop ((wp) ? TRUE : FALSE);
292 StartTask (taskEXPIRED_CREDS);
299 ptScreen.x = LOWORD(lp);
300 ptScreen.y = HIWORD(lp);
303 ScreenToClient ((HWND)wp, &ptClient);
305 if ((HWND)wp == GetDlgItem (g.hMain, IDC_SERVERS))
306 Server_ShowPopupMenu ((HWND)wp, ptClient, ptScreen);
319 Main_OnPreviewPane (FALSE, gr.fVert, TRUE);
320 UpdateDisplay_Servers (FALSE, NULL, 0);
323 Main_OnPreviewPane (TRUE, FALSE, TRUE);
324 UpdateDisplay_Servers (FALSE, NULL, 0);
327 Main_OnPreviewPane (TRUE, TRUE, TRUE);
328 UpdateDisplay_Servers (FALSE, NULL, 0);
331 case M_SVR_VIEW_LARGE:
332 Main_OnServerView (FLS_VIEW_LARGE);
334 case M_SVR_VIEW_SMALL:
335 Main_OnServerView (FLS_VIEW_SMALL);
337 case M_SVR_VIEW_REPORT:
338 Main_OnServerView (FLS_VIEW_LIST);
343 ShowColumnsDialog (hDlg, NULL);
346 CHILDTAB iTab = Server_GetDisplayedTab (g.hMain);
347 if (iTab == tabSERVICES)
348 ShowColumnsDialog (hDlg, &gr.viewSvc);
349 else if (iTab == tabAGGREGATES)
350 ShowColumnsDialog (hDlg, &gr.viewAgg);
351 else if (iTab == tabFILESETS)
352 ShowColumnsDialog (hDlg, &gr.viewSet);
354 ShowColumnsDialog (hDlg, NULL);
359 if ((gr.fActions = !gr.fActions) == TRUE)
362 Action_CloseWindow();
363 Main_SetActionMenus();
372 case IDC_COVER_BUTTON:
373 // The user must have clicked the "Try Again" or "Credentials"
374 // button on the cover we placed over the Servers list.
375 // Refresh the cell or obtain new credentials, as appropriate.
379 TCHAR szButton[ cchRESOURCE ];
380 GetWindowText ((HWND)lp, szButton, cchRESOURCE);
382 TCHAR szTest[ cchRESOURCE ];
384 GetString (szTest, IDS_ALERT_BUTTON_TRYAGAIN);
385 if (!lstrcmp (szTest, szButton))
387 StartTask (taskREFRESH, NULL, g.lpiCell);
391 GetString (szTest, IDS_ALERT_BUTTON_GETCREDS);
392 if (!lstrcmp (szTest, szButton))
401 StartContextCommand (g.hMain, NULL, NULL, LOWORD(wp));
407 switch (((LPNMHDR)lp)->code)
411 int iPage = TabCtrl_GetCurSel (GetDlgItem (g.hMain, IDC_TABS));
412 Main_DisplayTab ((CHILDTAB)iPage);
419 HWND hServers = GetDlgItem (hDlg, IDC_SERVERS);
420 LPIDENT lpi = (LPIDENT)FL_GetSelectedData (hServers);
422 Server_SelectServer (SERVERWINDOW_PREVIEWPANE, lpi);
428 HWND hServers = GetDlgItem (g.hMain, IDC_SERVERS);
430 if (((LPNMHDR)lp)->hwndFrom == hServers)
432 LPIDENT lpi = (LPIDENT)FL_GetSelectedData (hServers);
434 if (lpi && lpi->fIsServer())
438 if (gr.fDoubleClickOpens == 0)
440 else if (gr.fDoubleClickOpens == 1)
442 else if (gr.fPreview)
444 else // (!gr.Preview)
449 PostMessage (hServers, WM_COMMAND, M_PROPERTIES, 0);
451 else // (fOpenWindow)
453 PostMessage (g.hMain, WM_OPEN_SERVER, 0, (LPARAM)lpi);
467 void Main_OnNotifyFromDispatch (LPNOTIFYSTRUCT lpns)
472 StartTask (taskOPENEDCELL, NULL, lpns->Params.lpi1);
476 StartTask (taskCLOSEDCELL, NULL, lpns->Params.lpi1);
479 case evtRefreshStatusEnd:
480 case evtAlertsChanged:
481 if (lpns->Params.lpi1 && lpns->Params.lpi1->fIsCell())
483 UpdateDisplay_Cell (FALSE);
485 else if (lpns->Params.lpi1 && lpns->Params.lpi1->fIsServer())
487 UpdateDisplay_Servers (FALSE, lpns->Params.lpi1, lpns->Params.status);
491 case evtRefreshServersEnd:
492 if (g.lpiCell || lpns->Params.status == 0)
494 UpdateDisplay_Servers (FALSE, NULL, 0);
501 DWORD WINAPI Main_OnOpenServers_ThreadProc (PVOID lp)
505 if (g.lpiCell != NULL)
508 if ((lpCell = g.lpiCell->OpenCell()) != NULL)
511 for (LPSERVER lpServer = lpCell->ServerFindFirst (&hEnum); lpServer; lpServer = lpCell->ServerFindNext (&hEnum))
514 if ((lpsp = (LPSERVER_PREF)lpServer->GetUserParam()) != NULL)
516 if (lpsp->fOpen && !PropCache_Search (pcSERVER, lpServer->GetIdentifier()))
518 PostMessage (g.hMain, WM_OPEN_SERVER, 0, (LPARAM)(lpServer->GetIdentifier()));
532 DWORD WINAPI Main_Redraw_ThreadProc (PVOID lp)
534 BOOL fInvalidate = (BOOL)(UINT_PTR)lp;
537 if (g.lpiCell == NULL)
539 AfsAppLib_Uncover (GetDlgItem (g.hMain, IDC_SERVERS));
543 TCHAR szName[ cchRESOURCE ];
544 g.lpiCell->GetCellName (szName);
546 LPTSTR pszCover = FormatString (IDS_SEARCHING_FOR_SERVERS, TEXT("%s"), szName);
547 AfsAppLib_CoverWindow (GetDlgItem (g.hMain, IDC_SERVERS), pszCover);
548 FreeString (pszCover);
551 LPCELL lpCell = NULL;
552 if (g.lpiCell != NULL)
553 lpCell = g.lpiCell->OpenCell();
559 lpCell->Invalidate();
560 lpCell->RefreshAll();
564 lpCell->RefreshStatus();
565 lpCell->RefreshServers();
568 else // no cell is selected; we'll have to redraw the window directly.
570 UpdateDisplay_Cell (TRUE);
571 UpdateDisplay_Servers (TRUE, NULL, 0);
582 void Main_OnPreviewPane (BOOL fPreviewNew, BOOL fVertNew, BOOL fStoreCurrentView)
584 if (fStoreCurrentView)
586 if (gr.fPreview && !gr.fVert)
587 FL_StoreView (GetDlgItem (g.hMain, IDC_SERVERS), &gr.diHorz.viewSvr);
589 FL_StoreView (GetDlgItem (g.hMain, IDC_SERVERS), &gr.diVert.viewSvr);
592 GetWindowRect (g.hMain, &gr.rMainPreview);
594 GetWindowRect (g.hMain, &gr.rMain);
597 // If switching from having a preview pane to not (or vice-versa),
598 // and we have an alterate gr.rMain* to switch to, resize the window.
600 if (IsWindowVisible (g.hMain))
603 GetWindowRect (g.hMain, &rNow);
605 LPRECT prTarget = (fPreviewNew) ? &gr.rMainPreview : &gr.rMain;
606 if (prTarget->right == 0)
609 if (gr.fPreview && gr.fVert) // preview pane exists below main window?
612 GetWindowRect (GetDlgItem (g.hMain, IDC_TABS), &rPreview);
614 prTarget->bottom -= cyRECT(rPreview);
617 prTarget->right = prTarget->left + cxRECT(rNow); // keep the same width!
619 fEnforceMinimumSize = FALSE;
620 fNotifyChildrenForResize = FALSE;
622 SetWindowPos (g.hMain, NULL,
623 0, 0, cxRECT(*prTarget), cyRECT(*prTarget),
624 SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOMOVE);
626 fNotifyChildrenForResize = TRUE;
627 fEnforceMinimumSize = TRUE;
630 // Create a tab control if necessary, or remove it if it should be gone.
632 if (fPreviewNew && !GetDlgItem (g.hMain, IDC_TABS))
634 Main_CreateTabControl();
636 if (!fPreviewNew && GetDlgItem (g.hMain, IDC_TABS))
638 Main_DeleteTabControl();
641 // If there's a tab control, we'll need a splitter; if not, not.
643 if (GetDlgItem (g.hMain, IDC_SPLITTER_SERVER))
645 DeleteSplitter (g.hMain, IDC_SPLITTER_SERVER);
648 Main_RearrangeChildren (fPreviewNew, fVertNew);
652 CreateSplitter (g.hMain, IDC_SERVERS, IDC_TABS, IDC_SPLITTER_SERVER,
653 (fVertNew) ? &gr.diVert.cSplitter : &gr.diHorz.cSplitter,
658 if (GetDlgItem (g.hMain, IDC_TABS))
660 ShowWindow (GetDlgItem (g.hMain, IDC_TABS), SW_SHOW);
663 LPVIEWINFO lpvi = (fPreviewNew && !fVertNew) ? &gr.diHorz.viewSvr : &gr.diVert.viewSvr;
665 FL_RestoreView (GetDlgItem (g.hMain, IDC_SERVERS), lpvi);
667 CheckMenuRadioItem (GetMenu (g.hMain),
668 M_DIVIDE_NONE, M_DIVIDE_H,
669 ( (!fPreviewNew) ? M_DIVIDE_NONE :
670 (fVertNew) ? M_DIVIDE_V :
675 gr.fPreview = fPreviewNew;
677 Main_SetServerViewMenus();
681 void Main_OnServerView (int lvsNew)
683 HWND hServers = GetDlgItem (g.hMain, IDC_SERVERS);
685 if (gr.fPreview && !gr.fVert)
686 FL_StoreView (hServers, &gr.diHorz.viewSvr);
688 FL_StoreView (hServers, &gr.diVert.viewSvr);
690 if (gr.fPreview && !gr.fVert)
691 gr.diHorz.viewSvr.lvsView = lvsNew;
693 gr.diVert.viewSvr.lvsView = lvsNew;
695 if (gr.fPreview && !gr.fVert)
696 FL_RestoreView (hServers, &gr.diHorz.viewSvr);
698 FL_RestoreView (hServers, &gr.diVert.viewSvr);
700 Main_SetServerViewMenus();
701 FastList_SetTextCallback (GetDlgItem (g.hMain, IDC_SERVERS), GetItemText, ((gr.fPreview && !gr.fVert) ? &gr.diHorz.viewSvr : &gr.diVert.viewSvr));
702 UpdateDisplay_Servers (FALSE, NULL, 0);
706 void Main_SetServerViewMenus (void)
710 if (gr.fPreview && !gr.fVert)
711 lvs = gr.diHorz.viewSvr.lvsView;
713 lvs = gr.diVert.viewSvr.lvsView;
715 CheckMenuRadioItem (GetMenu (g.hMain),
716 M_SVR_VIEW_LARGE, M_SVR_VIEW_REPORT,
717 ( (lvs == FLS_VIEW_SMALL) ? M_SVR_VIEW_SMALL :
718 (lvs == FLS_VIEW_LIST) ? M_SVR_VIEW_REPORT :
722 ICONVIEW ivSvr = Display_GetServerIconView();
724 CheckMenuRadioItem (GetMenu (g.hMain),
725 M_SVR_VIEW_ONEICON, M_SVR_VIEW_STATUS,
726 (ivSvr == ivTWOICONS) ? M_SVR_VIEW_TWOICONS :
727 (ivSvr == ivONEICON) ? M_SVR_VIEW_ONEICON : M_SVR_VIEW_STATUS,
730 EnableMenu (GetMenu (g.hMain), M_SVR_VIEW_ONEICON, (lvs == FLS_VIEW_LIST) ? TRUE : FALSE);
731 EnableMenu (GetMenu (g.hMain), M_SVR_VIEW_TWOICONS, (lvs == FLS_VIEW_LIST) ? TRUE : FALSE);
732 EnableMenu (GetMenu (g.hMain), M_SVR_VIEW_STATUS, (lvs == FLS_VIEW_LIST) ? TRUE : FALSE);
736 void Main_SetActionMenus (void)
738 CheckMenu (GetMenu (g.hMain), M_ACTIONS, gr.fActions);
742 void Main_CreateTabControl (void)
744 HWND hTab = CreateWindowEx (WS_EX_CLIENTEDGE,
747 WS_CHILD | WS_CLIPSIBLINGS | WS_TABSTOP,
748 0, 0, 128, 128, // arbitrary, but not too small
749 SERVERWINDOW_PREVIEWPANE,
756 HFONT hf = (HFONT)GetStockObject (DEFAULT_GUI_FONT);
757 SendMessage (hTab, WM_SETFONT, (WPARAM)hf, MAKELPARAM(TRUE,0));
759 Server_PrepareTabControl (hTab);
761 LPIDENT lpi = (LPIDENT)FL_GetSelectedData (GetDlgItem (g.hMain, IDC_SERVERS));
762 Server_SelectServer (SERVERWINDOW_PREVIEWPANE, lpi);
767 void Main_DeleteTabControl (void)
769 if (GetDlgItem (SERVERWINDOW_PREVIEWPANE, IDC_TABS))
771 DestroyWindow (GetDlgItem (SERVERWINDOW_PREVIEWPANE, IDC_TABS));
776 void Main_DisplayTab (CHILDTAB iTab)
780 Server_DisplayTab (SERVERWINDOW_PREVIEWPANE, iTab);
781 gr.tabLast = (CHILDTAB)iTab;
786 void Main_RearrangeChildren (BOOL fPreviewNew, BOOL fVertNew)
791 // Start with the Servers window taking up the entire dialog's client area,
792 // leaving a space at the top for the cell combobox.
795 GetRectInParent (GetDlgItem (g.hMain, IDC_AFS_ID), &rCell);
797 GetClientRect (g.hMain, &rServers);
798 rServers.top = rCell.bottom +3;
800 // Then, if the preview tab is to be displayed, make the server window
801 // share the space equally with the tab control (vertically or horizontally)
809 rServers.bottom = rServers.top + cyRECT(rServers)/2 - 1;
810 rPreview.top = rServers.bottom + 2;
814 rServers.right = rServers.left + cxRECT(rServers)/2 - 1;
815 rPreview.left = rServers.right + 2;
818 // Adjust the server/tab windows for the Server splitter's position
822 LONG cyMod = gr.diVert.cSplitter;
824 if (cyRECT(rServers) > cyMIN_SERVER)
825 cyMod = min( cyMod, cyRECT(rServers)-cyMIN_SERVER );
826 if (cyRECT(rPreview) > cyMIN_TABS)
827 cyMod = min( cyMod, cyRECT(rPreview)-cyMIN_TABS );
829 rServers.bottom += cyMod;
830 rPreview.top += cyMod;
834 LONG cxMod = gr.diHorz.cSplitter;
836 if (cxRECT(rServers) > cxMIN_SERVER)
837 cxMod = min( cxMod, cxRECT(rServers)-cxMIN_SERVER );
838 if (cxRECT(rPreview) > cxMIN_TABS)
839 cxMod = min( cxMod, cxRECT(rPreview)-cxMIN_TABS );
841 rServers.right += cxMod;
842 rPreview.left += cxMod;
846 // Now move the children to their new places!
849 if (GetDlgItem (g.hMain, IDC_COVERDLG))
851 if (GetDlgItem (g.hMain, IDC_TABS))
853 HDWP dwp = BeginDeferWindowPos (nWindows);
855 DeferWindowPos (dwp, GetDlgItem (g.hMain, IDC_SERVERS), NULL,
856 rServers.left, rServers.top,
857 cxRECT(rServers), cyRECT(rServers),
858 SWP_NOACTIVATE | SWP_NOZORDER);
860 if (GetDlgItem (g.hMain, IDC_COVERDLG))
862 DeferWindowPos (dwp, GetDlgItem (g.hMain, IDC_COVERDLG), NULL,
863 rServers.left, rServers.top,
864 cxRECT(rServers), cyRECT(rServers),
865 SWP_NOACTIVATE | SWP_NOZORDER);
868 if (GetDlgItem (g.hMain, IDC_TABS))
870 DeferWindowPos (dwp, GetDlgItem (g.hMain, IDC_TABS), NULL,
871 rPreview.left, rPreview.top,
872 cxRECT(rPreview), cyRECT(rPreview),
873 SWP_NOACTIVATE | SWP_NOZORDER);
876 EndDeferWindowPos (dwp);
881 static LONG_PTR procServers = 0;
883 LRESULT CALLBACK Main_SubclassServersProc (HWND hServers, UINT msg, WPARAM wp, LPARAM lp)
887 if (procServers == 0)
888 rc = DefWindowProc (hServers, msg, wp, lp);
890 rc = (LRESULT) CallWindowProc ((WNDPROC)procServers, hServers, msg, wp, lp);
895 if (procServers != 0)
896 SetWindowLongPtr (hServers, GWLP_WNDPROC, procServers);
902 case M_SVR_VIEW_LARGE:
903 case M_SVR_VIEW_SMALL:
904 case M_SVR_VIEW_REPORT:
905 SendMessage (g.hMain, msg, wp, lp);
909 case M_VIEW_TWOICONS:
911 SendMessage (g.hMain, msg, wp, lp);
915 ShowColumnsDialog (g.hMain, NULL);
919 StartContextCommand (g.hMain,
921 (LPIDENT)FL_GetSelectedData (hServers),
932 void Main_SubclassServers (HWND hDlg)
934 HWND hServers = GetDlgItem (hDlg, IDC_SERVERS);
935 procServers = GetWindowLongPtr (hServers, GWLP_WNDPROC);
936 SetWindowLongPtr (hServers, GWLP_WNDPROC, (LONG_PTR)Main_SubclassServersProc);
941 void ExportCell (void)
946 TCHAR szFilter[ cchRESOURCE ];
947 lstrcpy (szFilter, TEXT("Text File|*.TXT|"));
948 TCHAR chFilter = szFilter[ lstrlen(szFilter)-1 ];
949 for (LPTSTR pszFilter = szFilter;
950 (*pszFilter) && ((pszFilter = (LPTSTR)lstrchr (pszFilter, chFilter)) != NULL);
953 *pszFilter = TEXT('\0');
956 TCHAR szSaveAs[ MAX_PATH ] = TEXT("export");
959 memset (&sfn, 0x00, sizeof(sfn));
960 sfn.lStructSize = sizeof(sfn);
961 sfn.hwndOwner = g.hMain;
962 sfn.hInstance = THIS_HINST;
963 sfn.lpstrFilter = szFilter;
964 sfn.nFilterIndex = 1;
965 sfn.lpstrFile = szSaveAs;
966 sfn.nMaxFile = MAX_PATH;
967 sfn.Flags = OFN_HIDEREADONLY | OFN_NOREADONLYRETURN |
968 OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST;
969 sfn.lpstrDefExt = TEXT("txt");
971 if (GetSaveFileName (&sfn))
973 LPTSTR psz = CloneString (szSaveAs);
974 StartTask (taskEXPORTCELL, NULL, psz);
980 void Main_StartWorking (void)
982 if (InterlockedIncrement(&nReqWorking) == 1)
984 AfsAppLib_StartAnimation (GetDlgItem (g.hMain, IDC_ANIMATE));
988 void Main_StopWorking (void)
990 if (InterlockedDecrement(&nReqWorking) == 0)
992 AfsAppLib_StopAnimation (GetDlgItem (g.hMain, IDC_ANIMATE));
997 void Main_AnimateIcon (HWND hIcon, int *piFrameLast)
1000 static HICON hiFrame[8];
1001 static BOOL fLoaded = FALSE;
1005 hiStop = TaLocale_LoadIcon (IDI_SPINSTOP);
1006 hiFrame[0] = TaLocale_LoadIcon (IDI_SPIN1);
1007 hiFrame[1] = TaLocale_LoadIcon (IDI_SPIN2);
1008 hiFrame[2] = TaLocale_LoadIcon (IDI_SPIN3);
1009 hiFrame[3] = TaLocale_LoadIcon (IDI_SPIN4);
1010 hiFrame[4] = TaLocale_LoadIcon (IDI_SPIN5);
1011 hiFrame[5] = TaLocale_LoadIcon (IDI_SPIN6);
1012 hiFrame[6] = TaLocale_LoadIcon (IDI_SPIN7);
1013 hiFrame[7] = TaLocale_LoadIcon (IDI_SPIN8);
1019 *piFrameLast = (*piFrameLast == 7) ? 0 : (1+*piFrameLast);
1022 SendMessage (hIcon, STM_SETICON, (WPARAM)((piFrameLast) ? hiFrame[ *piFrameLast ] : hiStop), 0);
1026 BOOL Main_HandleDialogKeys (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp)
1028 if (msg == WM_COMMAND)
1033 Server_OnKey_Return();
1037 Main_OnKey_CtrlTab (TRUE);
1040 case M_KEY_CTRLBACKTAB:
1041 Main_OnKey_CtrlTab (FALSE);
1045 Main_OnKey_Tab (TRUE);
1049 Main_OnKey_Tab (FALSE);
1053 Server_OnKey_Menu();
1060 case M_KEY_PROPERTIES:
1061 Server_OnKey_Properties();
1070 void Main_OnKey_Tab (BOOL fForward)
1072 // The tab-cycle should go:
1073 // ServerList <-> TabsOnQuickViewPane <-> TabChildControls
1075 // If the quick-view pane isn't showing, there's nowhere to tab to.
1079 HWND hFocus = GetFocus();
1080 HWND hTabChild = GetTabChild (GetDlgItem (g.hMain, IDC_TABS));
1084 if (hFocus == GetDlgItem (g.hMain, IDC_SERVERS))
1086 PostMessage (g.hMain, WM_NEXTDLGCTL, (WPARAM)GetDlgItem (g.hMain, IDC_TABS), TRUE);
1088 else if (hFocus == GetDlgItem (g.hMain, IDC_TABS))
1090 PostMessage (g.hMain, WM_NEXTDLGCTL, (WPARAM)GetNextDlgTabItem (hTabChild, NULL, FALSE), TRUE);
1094 if (GetNextDlgTabItem (hTabChild, hFocus, FALSE) == GetNextDlgTabItem (hTabChild, NULL, FALSE))
1095 PostMessage (g.hMain, WM_NEXTDLGCTL, (WPARAM)GetDlgItem (g.hMain, IDC_SERVERS), TRUE);
1097 PostMessage (g.hMain, WM_NEXTDLGCTL, (WPARAM)GetNextDlgTabItem (hTabChild, hFocus, FALSE), TRUE);
1102 if (hFocus == GetDlgItem (g.hMain, IDC_SERVERS))
1104 PostMessage (g.hMain, WM_NEXTDLGCTL, (WPARAM)GetLastDlgTabItem (hTabChild), TRUE);
1106 else if (hFocus == GetDlgItem (g.hMain, IDC_TABS))
1108 PostMessage (g.hMain, WM_NEXTDLGCTL, (WPARAM)GetDlgItem (g.hMain, IDC_SERVERS), TRUE);
1112 if (hFocus == GetNextDlgTabItem (hTabChild, NULL, FALSE))
1113 PostMessage (g.hMain, WM_NEXTDLGCTL, (WPARAM)GetDlgItem (g.hMain, IDC_TABS), TRUE);
1115 PostMessage (g.hMain, WM_NEXTDLGCTL, (WPARAM)GetNextDlgTabItem (hTabChild, hFocus, TRUE), TRUE);
1122 void Main_OnKey_CtrlTab (BOOL fForward)
1126 Server_OnKey_CtrlTab (SERVERWINDOW_PREVIEWPANE, fForward);