Update NEWS for 1.6.22
[pkg-k5-afs_openafs.git] / src / WINNT / afssvrmgr / agg_tab.cpp
blob31fb41d9a3ded473c174eddb40758577972cd5b6
1 /*
2 * Copyright 2000, International Business Machines Corporation and others.
3 * All Rights Reserved.
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
8 */
10 #include <winsock2.h>
11 #include <ws2tcpip.h>
13 extern "C" {
14 #include <afs/param.h>
15 #include <afs/stds.h>
18 #include "svrmgr.h"
19 #include "agg_tab.h"
20 #include "agg_general.h"
21 #include "svr_window.h"
22 #include "svr_general.h"
23 #include "display.h"
24 #include "command.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))
58 return FALSE;
60 switch (msg)
62 case WM_INITDIALOG:
64 RECT rTab;
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);
74 break;
76 case WM_HELP:
77 WinHelp (hDlg, cszHELPFILENAME, HELP_FINDER, 0);
78 break;
80 case WM_DESTROY:
81 DontNotifyMeEver (hDlg);
82 FL_StoreView (GetDlgItem (hDlg, IDC_AGG_LIST), &gr.viewAgg);
83 break;
85 case WM_SIZE:
86 // if (lp==0), we're minimizing--don't call ResizeWindow().
88 if (lp != 0)
89 ResizeWindow (hDlg, awdAggregates, rwaFixupGuts);
90 break;
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 ];
101 LPTSTR pszText;
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);
109 else
110 pszText = FormatString (IDS_AGGREGATES_IN_SERVER, TEXT("%s"), szName);
112 else if (g.lpiCell != NULL)
114 g.lpiCell->GetCellName (szName);
115 if (g.sub)
116 pszText = FormatString (IDS_AGGREGATE_SOME, TEXT("%s"), szName);
117 else
118 pszText = FormatString (IDS_AGGREGATES_IN_CELL, TEXT("%s"), szName);
120 else
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);
130 break;
132 case WM_NOTIFY_FROM_DISPATCH:
133 Aggregates_OnNotifyFromDispatch ((LPNOTIFYSTRUCT)lp);
134 Delete ((LPNOTIFYSTRUCT)lp);
135 break;
137 case WM_NOTIFY:
138 switch (((LPNMHDR)lp)->code)
140 case FLN_LDBLCLICK:
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);
145 return TRUE;
147 break;
149 break;
151 case WM_CONTEXTMENU:
153 POINT ptScreen;
154 POINT ptClient;
155 ptScreen.x = LOWORD(lp);
156 ptScreen.y = HIWORD(lp);
158 ptClient = ptScreen;
159 ScreenToClient ((HWND)wp, &ptClient);
161 if ((HWND)wp == GetDlgItem (hDlg, IDC_AGG_LIST))
162 Aggregates_ShowPopupMenu ((HWND)wp, ptClient, ptScreen);
164 break;
166 case WM_COMMAND:
167 switch (LOWORD(wp))
169 case IDC_AGG_CREATESET:
170 SendMessage (GetDlgItem (hDlg, IDC_AGG_LIST), WM_COMMAND, M_SET_CREATE, 0);
171 break;
173 break;
176 return FALSE;
180 void Aggregates_OnNotifyFromDispatch (LPNOTIFYSTRUCT lpns)
182 switch (lpns->evt)
184 case evtRefreshAggregatesEnd:
185 case evtRefreshStatusEnd:
186 case evtAlertsChanged:
187 case evtDestroy:
188 UpdateDisplay_Aggregates (FALSE, GetDlgItem (lpns->hwndTarget, IDC_AGG_LIST), lpns->Params.lpi1, lpns->Params.status, NULL, NULL, NULL);
189 break;
194 static UINT_PTR procAggregatesList = 0;
196 LRESULT CALLBACK Aggregates_SubclassListProc (HWND hList, UINT msg, WPARAM wp, LPARAM lp)
198 LRESULT rc;
200 if (procAggregatesList == 0)
201 rc = DefWindowProc (hList, msg, wp, lp);
202 else
203 rc = CallWindowProc ((WNDPROC)procAggregatesList, hList, msg, wp, lp);
205 switch (msg)
207 case WM_DESTROY:
208 if (procAggregatesList != 0)
209 SetWindowLongPtr (hList, GWLP_WNDPROC, procAggregatesList);
210 break;
212 case WM_COMMAND:
213 StartContextCommand (Server_GetWindowForChild (GetParent(hList)),
214 Server_GetServerForChild (GetParent(hList)),
215 Aggregates_GetFocused (GetParent(hList)),
216 LOWORD(wp));
217 break;
220 return rc;
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)
236 RECT rWindow;
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);
247 else
249 LPIDENT lpiSelected = NULL;
251 HLISTITEM hItem;
252 if ((hItem = FastList_ItemFromPoint (hList, &ptList, TRUE)) != NULL)
253 lpiSelected = (LPIDENT)FastList_GetItemParam (hList, hItem);
255 if (lpiSelected && (lpiSelected != (LPIDENT)FL_GetSelectedData (hList)))
256 lpiSelected = NULL;
258 if (lpiSelected && lpiSelected->fIsServer())
259 Server_ShowParticularPopupMenu (hList, ptScreen, lpiSelected);
260 else
261 Aggregates_ShowParticularPopupMenu (hList, ptScreen, lpiSelected);
266 void Aggregates_ShowParticularPopupMenu (HWND hParent, POINT ptScreen, LPIDENT lpiAggregate)
268 HMENU hm;
270 if (lpiAggregate == NULL)
271 hm = TaLocale_LoadMenu (MENU_AGG_NONE);
272 else
273 hm = TaLocale_LoadMenu (MENU_AGG);
275 if (hm != NULL)
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,
285 MF_BYCOMMAND);
288 DisplayContextMenu (hm, ptScreen, hParent);