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 <afs/param.h>
20 #include "agg_general.h"
21 #include "svr_window.h"
22 #include "svr_general.h"
28 * RESIZING WINDOWS ___________________________________________________________
32 rwWindowData awdAggregates[] = {
33 { IDC_AGG_DESC, raSizeX, 0, 0 },
34 { IDC_AGG_LIST, raSizeX | raSizeY, 0, 0 },
35 { IDC_AGG_CREATESET, raMoveX | raMoveY, 0, 0 },
36 { idENDLIST, 0, 0, 0 }
41 * PROTOTYPES _________________________________________________________________
45 void Aggregates_OnNotifyFromDispatch (LPNOTIFYSTRUCT lpns);
47 void Aggregates_SubclassList (HWND hDlg);
51 * ROUTINES ___________________________________________________________________
55 BOOL CALLBACK Aggregates_DlgProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp)
57 if (HandleColumnNotify (hDlg, msg, wp, lp, &gr.viewAgg))
65 GetClientRect (GetParent(hDlg), &rTab);
66 TabCtrl_AdjustRect (GetParent (hDlg), FALSE, &rTab);
67 ResizeWindow (hDlg, awdAggregates, rwaMoveToHere, &rTab);
69 FL_RestoreView (GetDlgItem (hDlg, IDC_AGG_LIST), &gr.viewAgg);
70 FastList_SetTextCallback (GetDlgItem (hDlg, IDC_AGG_LIST), GetItemText, &gr.viewAgg);
72 Aggregates_SubclassList (hDlg);
77 WinHelp (hDlg, cszHELPFILENAME, HELP_FINDER, 0);
81 DontNotifyMeEver (hDlg);
82 FL_StoreView (GetDlgItem (hDlg, IDC_AGG_LIST), &gr.viewAgg);
86 // if (lp==0), we're minimizing--don't call ResizeWindow().
89 ResizeWindow (hDlg, awdAggregates, rwaFixupGuts);
92 case WM_SERVER_CHANGED:
94 LPIDENT lpiServer = Server_GetServerForChild (hDlg);
95 DontNotifyMeEver (hDlg);
96 NotifyMe (WHEN_AGGS_CHANGE, lpiServer, hDlg, 0);
98 // Fix the text at the top of the Aggregates tab:
100 TCHAR szName[ cchRESOURCE ];
103 if (lpiServer != NULL)
105 LPSERVER_PREF lpsp = (LPSERVER_PREF)lpiServer->GetUserParam();
106 lpiServer->GetServerName (szName);
107 if (lpsp && !lpsp->fIsMonitored)
108 pszText = FormatString (IDS_AGGREGATE_UNMON, TEXT("%s"), szName);
110 pszText = FormatString (IDS_AGGREGATES_IN_SERVER, TEXT("%s"), szName);
112 else if (g.lpiCell != NULL)
114 g.lpiCell->GetCellName (szName);
116 pszText = FormatString (IDS_AGGREGATE_SOME, TEXT("%s"), szName);
118 pszText = FormatString (IDS_AGGREGATES_IN_CELL, TEXT("%s"), szName);
122 pszText = FormatString (IDS_AGGREGATES_IN_NOTHING);
125 SetDlgItemText (hDlg, IDC_AGG_DESC, pszText);
126 FreeString (pszText);
128 UpdateDisplay_Aggregates (FALSE, GetDlgItem (hDlg, IDC_AGG_LIST), NULL, 0, NULL, NULL, NULL);
132 case WM_NOTIFY_FROM_DISPATCH:
133 Aggregates_OnNotifyFromDispatch ((LPNOTIFYSTRUCT)lp);
134 Delete ((LPNOTIFYSTRUCT)lp);
138 switch (((LPNMHDR)lp)->code)
141 if (((LPNMHDR)lp)->hwndFrom == GetDlgItem (hDlg, IDC_AGG_LIST))
143 if (FL_GetSelectedData (GetDlgItem (hDlg, IDC_AGG_LIST)))
144 PostMessage (GetDlgItem (hDlg, IDC_AGG_LIST), WM_COMMAND, M_PROPERTIES, 0);
155 ptScreen.x = LOWORD(lp);
156 ptScreen.y = HIWORD(lp);
159 ScreenToClient ((HWND)wp, &ptClient);
161 if ((HWND)wp == GetDlgItem (hDlg, IDC_AGG_LIST))
162 Aggregates_ShowPopupMenu ((HWND)wp, ptClient, ptScreen);
169 case IDC_AGG_CREATESET:
170 SendMessage (GetDlgItem (hDlg, IDC_AGG_LIST), WM_COMMAND, M_SET_CREATE, 0);
180 void Aggregates_OnNotifyFromDispatch (LPNOTIFYSTRUCT lpns)
184 case evtRefreshAggregatesEnd:
185 case evtRefreshStatusEnd:
186 case evtAlertsChanged:
188 UpdateDisplay_Aggregates (FALSE, GetDlgItem (lpns->hwndTarget, IDC_AGG_LIST), lpns->Params.lpi1, lpns->Params.status, NULL, NULL, NULL);
194 static UINT_PTR procAggregatesList = 0;
196 LRESULT CALLBACK Aggregates_SubclassListProc (HWND hList, UINT msg, WPARAM wp, LPARAM lp)
200 if (procAggregatesList == 0)
201 rc = DefWindowProc (hList, msg, wp, lp);
203 rc = CallWindowProc ((WNDPROC)procAggregatesList, hList, msg, wp, lp);
208 if (procAggregatesList != 0)
209 SetWindowLongPtr (hList, GWLP_WNDPROC, procAggregatesList);
213 StartContextCommand (Server_GetWindowForChild (GetParent(hList)),
214 Server_GetServerForChild (GetParent(hList)),
215 Aggregates_GetFocused (GetParent(hList)),
224 void Aggregates_SubclassList (HWND hDlg)
226 HWND hList = GetDlgItem (hDlg, IDC_AGG_LIST);
227 procAggregatesList = GetWindowLongPtr (hList, GWLP_WNDPROC);
228 SetWindowLongPtr (hList, GWLP_WNDPROC, (LONG_PTR)Aggregates_SubclassListProc);
232 void Aggregates_ShowPopupMenu (HWND hList, POINT ptList, POINT ptScreen)
234 if (!ptScreen.x && !ptScreen.y)
237 GetWindowRect (hList, &rWindow);
238 ptScreen.x = rWindow.left + (rWindow.right -rWindow.left)/2;
239 ptScreen.y = rWindow.top + (rWindow.bottom -rWindow.top)/2;
240 Aggregates_ShowParticularPopupMenu (hList, ptScreen, NULL);
242 else if (FL_HitTestForHeaderBar (hList, ptList))
244 HMENU hm = TaLocale_LoadMenu (MENU_COLUMNS);
245 DisplayContextMenu (hm, ptScreen, hList);
249 LPIDENT lpiSelected = NULL;
252 if ((hItem = FastList_ItemFromPoint (hList, &ptList, TRUE)) != NULL)
253 lpiSelected = (LPIDENT)FastList_GetItemParam (hList, hItem);
255 if (lpiSelected && (lpiSelected != (LPIDENT)FL_GetSelectedData (hList)))
258 if (lpiSelected && lpiSelected->fIsServer())
259 Server_ShowParticularPopupMenu (hList, ptScreen, lpiSelected);
261 Aggregates_ShowParticularPopupMenu (hList, ptScreen, lpiSelected);
266 void Aggregates_ShowParticularPopupMenu (HWND hParent, POINT ptScreen, LPIDENT lpiAggregate)
270 if (lpiAggregate == NULL)
271 hm = TaLocale_LoadMenu (MENU_AGG_NONE);
273 hm = TaLocale_LoadMenu (MENU_AGG);
277 if (lpiAggregate == NULL)
279 HMENU hmView = GetSubMenu (hm, 0);
281 CheckMenuRadioItem (hmView,
282 M_VIEW_ONEICON, M_VIEW_STATUS,
283 (gr.ivAgg == ivTWOICONS) ? M_VIEW_TWOICONS :
284 (gr.ivAgg == ivONEICON) ? M_VIEW_ONEICON : M_VIEW_STATUS,
288 DisplayContextMenu (hm, ptScreen, hParent);