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>
17 #include "agg_general.h"
18 #include "svr_window.h"
19 #include "svr_general.h"
25 * RESIZING WINDOWS ___________________________________________________________
29 rwWindowData awdAggregates[] = {
30 { IDC_AGG_DESC, raSizeX, 0, 0 },
31 { IDC_AGG_LIST, raSizeX | raSizeY, 0, 0 },
32 { IDC_AGG_CREATESET, raMoveX | raMoveY, 0, 0 },
33 { idENDLIST, 0, 0, 0 }
38 * PROTOTYPES _________________________________________________________________
42 void Aggregates_OnNotifyFromDispatch (LPNOTIFYSTRUCT lpns);
44 void Aggregates_SubclassList (HWND hDlg);
48 * ROUTINES ___________________________________________________________________
52 BOOL CALLBACK Aggregates_DlgProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp)
54 if (HandleColumnNotify (hDlg, msg, wp, lp, &gr.viewAgg))
62 GetClientRect (GetParent(hDlg), &rTab);
63 TabCtrl_AdjustRect (GetParent (hDlg), FALSE, &rTab);
64 ResizeWindow (hDlg, awdAggregates, rwaMoveToHere, &rTab);
66 FL_RestoreView (GetDlgItem (hDlg, IDC_AGG_LIST), &gr.viewAgg);
67 FastList_SetTextCallback (GetDlgItem (hDlg, IDC_AGG_LIST), GetItemText, &gr.viewAgg);
69 Aggregates_SubclassList (hDlg);
74 WinHelp (hDlg, cszHELPFILENAME, HELP_FINDER, 0);
78 DontNotifyMeEver (hDlg);
79 FL_StoreView (GetDlgItem (hDlg, IDC_AGG_LIST), &gr.viewAgg);
83 // if (lp==0), we're minimizing--don't call ResizeWindow().
86 ResizeWindow (hDlg, awdAggregates, rwaFixupGuts);
89 case WM_SERVER_CHANGED:
91 LPIDENT lpiServer = Server_GetServerForChild (hDlg);
92 DontNotifyMeEver (hDlg);
93 NotifyMe (WHEN_AGGS_CHANGE, lpiServer, hDlg, 0);
95 // Fix the text at the top of the Aggregates tab:
97 TCHAR szName[ cchRESOURCE ];
100 if (lpiServer != NULL)
102 LPSERVER_PREF lpsp = (LPSERVER_PREF)lpiServer->GetUserParam();
103 lpiServer->GetServerName (szName);
104 if (lpsp && !lpsp->fIsMonitored)
105 pszText = FormatString (IDS_AGGREGATE_UNMON, TEXT("%s"), szName);
107 pszText = FormatString (IDS_AGGREGATES_IN_SERVER, TEXT("%s"), szName);
109 else if (g.lpiCell != NULL)
111 g.lpiCell->GetCellName (szName);
113 pszText = FormatString (IDS_AGGREGATE_SOME, TEXT("%s"), szName);
115 pszText = FormatString (IDS_AGGREGATES_IN_CELL, TEXT("%s"), szName);
119 pszText = FormatString (IDS_AGGREGATES_IN_NOTHING);
122 SetDlgItemText (hDlg, IDC_AGG_DESC, pszText);
123 FreeString (pszText);
125 UpdateDisplay_Aggregates (FALSE, GetDlgItem (hDlg, IDC_AGG_LIST), NULL, 0, NULL, NULL, NULL);
129 case WM_NOTIFY_FROM_DISPATCH:
130 Aggregates_OnNotifyFromDispatch ((LPNOTIFYSTRUCT)lp);
131 Delete ((LPNOTIFYSTRUCT)lp);
135 switch (((LPNMHDR)lp)->code)
138 if (((LPNMHDR)lp)->hwndFrom == GetDlgItem (hDlg, IDC_AGG_LIST))
140 if (FL_GetSelectedData (GetDlgItem (hDlg, IDC_AGG_LIST)))
141 PostMessage (GetDlgItem (hDlg, IDC_AGG_LIST), WM_COMMAND, M_PROPERTIES, 0);
152 ptScreen.x = LOWORD(lp);
153 ptScreen.y = HIWORD(lp);
156 ScreenToClient ((HWND)wp, &ptClient);
158 if ((HWND)wp == GetDlgItem (hDlg, IDC_AGG_LIST))
159 Aggregates_ShowPopupMenu ((HWND)wp, ptClient, ptScreen);
166 case IDC_AGG_CREATESET:
167 SendMessage (GetDlgItem (hDlg, IDC_AGG_LIST), WM_COMMAND, M_SET_CREATE, 0);
177 void Aggregates_OnNotifyFromDispatch (LPNOTIFYSTRUCT lpns)
181 case evtRefreshAggregatesEnd:
182 case evtRefreshStatusEnd:
183 case evtAlertsChanged:
185 UpdateDisplay_Aggregates (FALSE, GetDlgItem (lpns->hwndTarget, IDC_AGG_LIST), lpns->Params.lpi1, lpns->Params.status, NULL, NULL, NULL);
191 static UINT_PTR procAggregatesList = 0;
193 LRESULT CALLBACK Aggregates_SubclassListProc (HWND hList, UINT msg, WPARAM wp, LPARAM lp)
197 if (procAggregatesList == 0)
198 rc = DefWindowProc (hList, msg, wp, lp);
200 rc = CallWindowProc ((WNDPROC)procAggregatesList, hList, msg, wp, lp);
205 if (procAggregatesList != 0)
206 SetWindowLongPtr (hList, GWLP_WNDPROC, procAggregatesList);
210 StartContextCommand (Server_GetWindowForChild (GetParent(hList)),
211 Server_GetServerForChild (GetParent(hList)),
212 Aggregates_GetFocused (GetParent(hList)),
221 void Aggregates_SubclassList (HWND hDlg)
223 HWND hList = GetDlgItem (hDlg, IDC_AGG_LIST);
224 procAggregatesList = GetWindowLongPtr (hList, GWLP_WNDPROC);
225 SetWindowLongPtr (hList, GWLP_WNDPROC, (LONG_PTR)Aggregates_SubclassListProc);
229 void Aggregates_ShowPopupMenu (HWND hList, POINT ptList, POINT ptScreen)
231 if (!ptScreen.x && !ptScreen.y)
234 GetWindowRect (hList, &rWindow);
235 ptScreen.x = rWindow.left + (rWindow.right -rWindow.left)/2;
236 ptScreen.y = rWindow.top + (rWindow.bottom -rWindow.top)/2;
237 Aggregates_ShowParticularPopupMenu (hList, ptScreen, NULL);
239 else if (FL_HitTestForHeaderBar (hList, ptList))
241 HMENU hm = TaLocale_LoadMenu (MENU_COLUMNS);
242 DisplayContextMenu (hm, ptScreen, hList);
246 LPIDENT lpiSelected = NULL;
249 if ((hItem = FastList_ItemFromPoint (hList, &ptList, TRUE)) != NULL)
250 lpiSelected = (LPIDENT)FastList_GetItemParam (hList, hItem);
252 if (lpiSelected && (lpiSelected != (LPIDENT)FL_GetSelectedData (hList)))
255 if (lpiSelected && lpiSelected->fIsServer())
256 Server_ShowParticularPopupMenu (hList, ptScreen, lpiSelected);
258 Aggregates_ShowParticularPopupMenu (hList, ptScreen, lpiSelected);
263 void Aggregates_ShowParticularPopupMenu (HWND hParent, POINT ptScreen, LPIDENT lpiAggregate)
267 if (lpiAggregate == NULL)
268 hm = TaLocale_LoadMenu (MENU_AGG_NONE);
270 hm = TaLocale_LoadMenu (MENU_AGG);
274 if (lpiAggregate == NULL)
276 HMENU hmView = GetSubMenu (hm, 0);
278 CheckMenuRadioItem (hmView,
279 M_VIEW_ONEICON, M_VIEW_STATUS,
280 (gr.ivAgg == ivTWOICONS) ? M_VIEW_TWOICONS :
281 (gr.ivAgg == ivONEICON) ? M_VIEW_ONEICON : M_VIEW_STATUS,
285 DisplayContextMenu (hm, ptScreen, hParent);