Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

408 lines
14 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. // Copyright (C) 1993-1996 Microsoft Corporation. All Rights Reserved.
  3. //
  4. // MODULE: layout.cpp
  5. //
  6. // PURPOSE: Implements the layout property sheet
  7. //
  8. #include "pch.hxx"
  9. #include "resource.h"
  10. #include "goptions.h"
  11. #include "browser.h"
  12. #include "layout.h"
  13. #include "thormsgs.h"
  14. #include <mailnews.h>
  15. #include "instance.h"
  16. ASSERTDATA
  17. static const char c_szPropBrowser[] = "Browser";
  18. static const char c_szPropLayout[] = "Layout";
  19. INT_PTR CALLBACK LayoutProp_General(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  20. BOOL LayoutProp_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam);
  21. void LayoutProp_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify);
  22. LRESULT LayoutProp_OnNotify(HWND hwnd, int idFrom, LPNMHDR pnmhdr);
  23. void LayoutProp_SetOption(HWND hwndDlg, int idCtl, DWORD dwOpt);
  24. void LayoutProp_EnableToolbarControls(HWND hwnd, BOOL fEnable);
  25. void LayoutProp_EnablePreviewControls(HWND hwnd, BOOL fEnable);
  26. typedef struct tagLAYOUT_INFO {
  27. IAthenaBrowser *pBrowser;
  28. LAYOUT *pLayout;
  29. } LAYOUT_INFO, *PLAYOUT_INFO;
  30. //
  31. // FUNCTION: LayoutProp_Create()
  32. //
  33. // PURPOSE: Invokes the Window Layout property sheet
  34. //
  35. // PARAMETERS:
  36. // <in> hwndParent - Handle of the parent of the dialog box
  37. //
  38. // RETURN VALUE:
  39. // <???>
  40. //
  41. // COMMENTS:
  42. // <???>
  43. //
  44. BOOL LayoutProp_Create(HWND hwndParent, IAthenaBrowser *pBrowser, LAYOUT *pLayout)
  45. {
  46. PROPSHEETPAGE psp;
  47. PROPSHEETHEADER psh;
  48. BOOL fReturn;
  49. HICON hIconSmall;
  50. TCHAR szTitle[CCHMAX_STRINGRES];
  51. LAYOUT_INFO rLayout= { pBrowser, pLayout };
  52. // Load the title bar icon
  53. hIconSmall = (HICON) LoadImage(g_hLocRes, MAKEINTRESOURCE(idiWindowLayout),
  54. IMAGE_ICON, 16, 16, 0);
  55. // Load the title bar caption
  56. AthLoadString(idsWindowLayout, szTitle, ARRAYSIZE(szTitle));
  57. ZeroMemory(&psp, sizeof(PROPSHEETPAGE));
  58. psp.dwSize = sizeof(PROPSHEETPAGE);
  59. psp.dwFlags = PSP_DEFAULT;
  60. psp.hInstance = g_hLocRes;
  61. psp.pszTemplate = MAKEINTRESOURCE(iddViewLayout);
  62. psp.pfnDlgProc = LayoutProp_General;
  63. psp.lParam = (LPARAM) pBrowser;
  64. psh.dwSize = sizeof(PROPSHEETHEADER);
  65. psh.dwFlags = PSH_USEHICON | PSH_PROPSHEETPAGE | PSH_PROPTITLE | PSH_USEPAGELANG;
  66. psh.hwndParent = hwndParent;
  67. psh.hInstance = g_hLocRes;
  68. psh.hIcon = hIconSmall;
  69. psh.pszCaption = szTitle;
  70. psh.nPages = 1;
  71. psh.nStartPage = 0;
  72. psh.ppsp = &psp;
  73. fReturn = !!PropertySheet(&psh);
  74. if (hIconSmall)
  75. SideAssert(DestroyIcon(hIconSmall));
  76. return (fReturn);
  77. }
  78. const static HELPMAP g_rgCtxMapLayout[] = {
  79. {IDC_CHECK_FOLDERLIST, IDH_LAYOUT_FOLDER_LIST},
  80. {IDC_CHECK_FOLDERBAR, IDH_LAYOUT_FOLDER_BAR},
  81. {IDC_CHECK_CONTACTS, 35702},
  82. {IDC_CHECK_OUTLOOKBAR, 35700},
  83. {IDC_CHECK_STATUSBAR, 35704},
  84. {IDC_CHECK_TOOLBAR, 35706},
  85. {IDC_CHECK_FILTERBAR, 35708},
  86. {IDC_CHECK_INFOPANE, 35712},
  87. {IDC_BUTTON_CUSTOMIZE, IDH_LAYOUT_CUSTOMIZE_BUTTONS},
  88. {IDC_CHECK_PREVIEW, IDH_LAYOUT_PREVIEW_PANE},
  89. {IDC_RADIO_SPLIT_HORZ, IDH_LAYOUT_PREVIEW_PANE_MOVE},
  90. {IDC_RADIO_SPLIT_VERT, IDH_LAYOUT_PREVIEW_PANE_MOVE},
  91. {IDC_CHECK_PREVIEW_HEADER, IDH_LAYOUT_SHOW_HEADERS},
  92. {idcStatic1, IDH_NEWS_COMM_GROUPBOX},
  93. {idcStatic2, IDH_NEWS_COMM_GROUPBOX},
  94. {idcStatic3, IDH_NEWS_COMM_GROUPBOX},
  95. {idcStatic4, IDH_NEWS_COMM_GROUPBOX},
  96. {idcStatic5, IDH_NEWS_COMM_GROUPBOX},
  97. {idcStatic6, IDH_NEWS_COMM_GROUPBOX},
  98. {idcStatic7, IDH_NEWS_COMM_GROUPBOX},
  99. {idcStatic8, IDH_NEWS_COMM_GROUPBOX},
  100. {0, 0}};
  101. INT_PTR CALLBACK LayoutProp_General(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  102. {
  103. LRESULT lResult;
  104. LAYOUT *pLayout;
  105. switch (uMsg)
  106. {
  107. case WM_INITDIALOG:
  108. return (BOOL) HANDLE_WM_INITDIALOG(hwnd, wParam, lParam,
  109. LayoutProp_OnInitDialog);
  110. case WM_COMMAND:
  111. HANDLE_WM_COMMAND(hwnd, wParam, lParam, LayoutProp_OnCommand);
  112. return (TRUE);
  113. case WM_NOTIFY:
  114. lResult = HANDLE_WM_NOTIFY(hwnd, wParam, lParam, LayoutProp_OnNotify);
  115. SetDlgMsgResult(hwnd, WM_NOTIFY, lResult);
  116. return (TRUE);
  117. case WM_DESTROY:
  118. RemoveProp(hwnd, c_szPropBrowser);
  119. pLayout = (LAYOUT *)GetProp(hwnd, c_szPropLayout);
  120. if (pLayout != NULL)
  121. MemFree(pLayout);
  122. RemoveProp(hwnd, c_szPropLayout);
  123. return (TRUE);
  124. case WM_HELP:
  125. case WM_CONTEXTMENU:
  126. return(OnContextHelp(hwnd, uMsg, wParam, lParam, g_rgCtxMapLayout));
  127. }
  128. return (FALSE);
  129. }
  130. BOOL LayoutProp_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam)
  131. {
  132. IAthenaBrowser *pBrowser = NULL;
  133. CBands *pCoolbar = NULL;
  134. BOOL fText = TRUE;
  135. FOLDERTYPE ftType = FOLDER_ROOTNODE;
  136. BOOL fEnabled = FALSE;
  137. DWORD dwHybrid = hybridNone;
  138. DWORD dwSplitDir = 0;
  139. LAYOUT *pLayout;
  140. BOOL fPreviewPaneHeader = 0;
  141. Assert(lParam);
  142. pBrowser = (IAthenaBrowser *)(((PROPSHEETPAGE *) lParam)->lParam);
  143. Assert(pBrowser != NULL);
  144. if (!MemAlloc((void **)&pLayout, sizeof(LAYOUT)))
  145. return(FALSE);
  146. pLayout->cbSize = sizeof(LAYOUT);
  147. SideAssert(SUCCEEDED(pBrowser->GetLayout(pLayout)));
  148. // Stash the pointer to the browser
  149. SetProp(hwnd, c_szPropBrowser, (HANDLE) pBrowser);
  150. SetProp(hwnd, c_szPropLayout, (HANDLE) pLayout);
  151. // Set the basic checks
  152. Button_SetCheck(GetDlgItem(hwnd, IDC_CHECK_FOLDERBAR), pLayout->fFolderBar);
  153. Button_SetCheck(GetDlgItem(hwnd, IDC_CHECK_FOLDERLIST), pLayout->fFolderList);
  154. Button_SetCheck(GetDlgItem(hwnd, IDC_CHECK_STATUSBAR), pLayout->fStatusBar);
  155. Button_SetCheck(GetDlgItem(hwnd, IDC_CHECK_INFOPANE), pLayout->fInfoPane);
  156. Button_SetCheck(GetDlgItem(hwnd, IDC_CHECK_OUTLOOKBAR), pLayout->fOutlookBar);
  157. Button_SetCheck(GetDlgItem(hwnd, IDC_CHECK_CONTACTS), pLayout->fContacts);
  158. EnableWindow(GetDlgItem(hwnd, IDC_CHECK_CONTACTS), !(g_dwAthenaMode & MODE_OUTLOOKNEWS));
  159. if (!pLayout->fInfoPaneEnabled)
  160. ShowWindow(GetDlgItem(hwnd, IDC_CHECK_INFOPANE), SW_HIDE);
  161. Button_SetCheck(GetDlgItem(hwnd, IDC_CHECK_TOOLBAR), pLayout->fToolbar);
  162. if (!pLayout->fToolbar)
  163. LayoutProp_EnableToolbarControls(hwnd, FALSE);
  164. Button_SetCheck(GetDlgItem(hwnd, IDC_CHECK_FILTERBAR), pLayout->fFilterBar);
  165. // Set the preview pane options
  166. pBrowser->GetFolderType(&ftType);
  167. if (ftType == FOLDER_HTTPMAIL)
  168. ShowWindow(GetDlgItem(hwnd, IDC_CHECK_INFOPANE), SW_HIDE);
  169. if (FOLDER_NEWS == ftType || FOLDER_LOCAL == ftType || FOLDER_HTTPMAIL == ftType || FOLDER_IMAP == ftType)
  170. {
  171. // Mail and news have different preview pane options. We need to
  172. // load those controls separately
  173. if (ftType == FOLDER_NEWS)
  174. {
  175. dwHybrid = pLayout->fNewsPreviewPane;
  176. dwSplitDir = pLayout->fNewsSplitVertically;
  177. fPreviewPaneHeader = pLayout->fNewsPreviewPaneHeader;
  178. }
  179. else
  180. {
  181. dwHybrid = pLayout->fMailPreviewPane;
  182. dwSplitDir = pLayout->fMailSplitVertically;
  183. fPreviewPaneHeader = pLayout->fMailPreviewPaneHeader;
  184. }
  185. Button_SetCheck(GetDlgItem(hwnd, IDC_CHECK_PREVIEW),
  186. hybridNone != dwHybrid);
  187. Button_SetCheck(GetDlgItem(hwnd, IDC_RADIO_SPLIT_HORZ),
  188. dwSplitDir == 0);
  189. Button_SetCheck(GetDlgItem(hwnd, IDC_RADIO_SPLIT_VERT),
  190. dwSplitDir == 1);
  191. Button_SetCheck(GetDlgItem(hwnd, IDC_CHECK_PREVIEW_HEADER),
  192. fPreviewPaneHeader);
  193. if (dwHybrid == hybridNone)
  194. LayoutProp_EnablePreviewControls(hwnd, FALSE);
  195. }
  196. else
  197. {
  198. EnableWindow(GetDlgItem(hwnd, IDC_CHECK_PREVIEW), FALSE);
  199. LayoutProp_EnablePreviewControls(hwnd, FALSE);
  200. }
  201. PropSheet_UnChanged(GetParent(hwnd), hwnd);
  202. return (TRUE);
  203. }
  204. void LayoutProp_EnableToolbarControls(HWND hwnd, BOOL fEnable)
  205. {
  206. EnableWindow(GetDlgItem(hwnd, IDC_BUTTON_CUSTOMIZE), fEnable);
  207. }
  208. void LayoutProp_EnablePreviewControls(HWND hwnd, BOOL fEnable)
  209. {
  210. EnableWindow(GetDlgItem(hwnd, IDC_RADIO_SPLIT_HORZ), fEnable);
  211. EnableWindow(GetDlgItem(hwnd, IDC_RADIO_SPLIT_VERT), fEnable);
  212. EnableWindow(GetDlgItem(hwnd, IDC_CHECK_PREVIEW_HEADER), fEnable);
  213. }
  214. void LayoutProp_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
  215. {
  216. BOOL fChecked;
  217. switch (id)
  218. {
  219. case IDC_CHECK_PREVIEW:
  220. fChecked = Button_GetCheck(hwndCtl);
  221. LayoutProp_EnablePreviewControls(hwnd, fChecked);
  222. break;
  223. case IDC_CHECK_TOOLBAR:
  224. fChecked = Button_GetCheck(hwndCtl);
  225. LayoutProp_EnableToolbarControls(hwnd, fChecked);
  226. break;
  227. case IDC_BUTTON_CUSTOMIZE:
  228. {
  229. CBands *pCoolbar = NULL;
  230. IAthenaBrowser *pBrowser = (IAthenaBrowser *) GetProp(hwnd, c_szPropBrowser);
  231. if (pBrowser)
  232. {
  233. pBrowser->GetCoolbar(&pCoolbar);
  234. if (pCoolbar)
  235. {
  236. pCoolbar->Invoke(idCustomize, 0);
  237. SetForegroundWindow(GetParent(hwnd));
  238. pCoolbar->Release();
  239. }
  240. }
  241. break;
  242. }
  243. }
  244. PropSheet_Changed(GetParent(hwnd), hwnd);
  245. return;
  246. }
  247. LRESULT LayoutProp_OnNotify(HWND hwnd, int idFrom, LPNMHDR pnmhdr)
  248. {
  249. CBands *pCoolbar = NULL;
  250. IAthenaBrowser *pBrowser = (IAthenaBrowser *) GetProp(hwnd, c_szPropBrowser);
  251. LAYOUT *pLayout = (LAYOUT *) GetProp(hwnd, c_szPropLayout);
  252. FOLDERTYPE ftType;
  253. HWND hwndBrowser;
  254. register BOOL fChecked;
  255. BOOL fSplit;
  256. BOOL fHeader;
  257. switch (pnmhdr->code)
  258. {
  259. case PSN_APPLY:
  260. Assert(pBrowser != NULL);
  261. // Basic Options
  262. fChecked = IsDlgButtonChecked(hwnd, IDC_CHECK_FOLDERBAR);
  263. if (fChecked != (BOOL) pLayout->fFolderBar)
  264. {
  265. pBrowser->SetViewLayout(DISPID_MSGVIEW_FOLDERBAR, LAYOUT_POS_NA, fChecked, 0, 0);
  266. pLayout->fFolderBar = fChecked;
  267. }
  268. fChecked = IsDlgButtonChecked(hwnd, IDC_CHECK_FOLDERLIST);
  269. if (fChecked != (BOOL) pLayout->fFolderList)
  270. {
  271. pBrowser->SetViewLayout(DISPID_MSGVIEW_FOLDERLIST, LAYOUT_POS_NA, fChecked, 0, 0);
  272. pLayout->fFolderList = fChecked;
  273. }
  274. fChecked = IsDlgButtonChecked(hwnd, IDC_CHECK_STATUSBAR);
  275. if (fChecked != (BOOL) pLayout->fStatusBar)
  276. {
  277. pBrowser->SetViewLayout(DISPID_MSGVIEW_STATUSBAR, LAYOUT_POS_NA, fChecked, 0, 0);
  278. pLayout->fStatusBar = fChecked;
  279. }
  280. fChecked = IsDlgButtonChecked(hwnd, IDC_CHECK_OUTLOOKBAR);
  281. if (fChecked != (BOOL) pLayout->fOutlookBar)
  282. {
  283. pBrowser->SetViewLayout(DISPID_MSGVIEW_OUTLOOK_BAR, LAYOUT_POS_NA, fChecked, 0, 0);
  284. pLayout->fOutlookBar = fChecked;
  285. }
  286. fChecked = IsDlgButtonChecked(hwnd, IDC_CHECK_CONTACTS);
  287. if (fChecked != (BOOL) pLayout->fContacts)
  288. {
  289. pBrowser->SetViewLayout(DISPID_MSGVIEW_CONTACTS, LAYOUT_POS_NA, fChecked, 0, 0);
  290. pLayout->fContacts = fChecked;
  291. }
  292. if (pLayout->fInfoPaneEnabled)
  293. {
  294. fChecked = IsDlgButtonChecked(hwnd, IDC_CHECK_INFOPANE);
  295. if (fChecked != (BOOL) pLayout->fInfoPane)
  296. {
  297. pBrowser->SetViewLayout(DISPID_MSGVIEW_INFOPANE, LAYOUT_POS_NA, fChecked, 0, 0);
  298. pLayout->fInfoPane = fChecked;
  299. }
  300. }
  301. // Toolbar
  302. fChecked = IsDlgButtonChecked(hwnd, IDC_CHECK_TOOLBAR);
  303. if (fChecked != (BOOL) pLayout->fToolbar)
  304. {
  305. pBrowser->SetViewLayout(DISPID_MSGVIEW_TOOLBAR, LAYOUT_POS_NA, fChecked, 0, 0);
  306. pLayout->fToolbar = fChecked;
  307. }
  308. //Filter Bar
  309. fChecked = IsDlgButtonChecked(hwnd, IDC_CHECK_FILTERBAR);
  310. if (fChecked != (BOOL)pLayout->fFilterBar)
  311. {
  312. pBrowser->SetViewLayout(DISPID_MSGVIEW_FILTERBAR, LAYOUT_POS_NA, fChecked, 0, 0);
  313. pLayout->fFilterBar = fChecked;
  314. }
  315. // Preview Pane
  316. if (IsWindowEnabled(GetDlgItem(hwnd, IDC_CHECK_PREVIEW)))
  317. {
  318. pBrowser->GetFolderType(&ftType);
  319. fChecked = IsDlgButtonChecked(hwnd, IDC_CHECK_PREVIEW);
  320. fSplit = IsDlgButtonChecked(hwnd, IDC_RADIO_SPLIT_VERT);
  321. fHeader = IsDlgButtonChecked(hwnd, IDC_CHECK_PREVIEW_HEADER);
  322. if (ftType == FOLDER_NEWS)
  323. {
  324. pBrowser->SetViewLayout(DISPID_MSGVIEW_PREVIEWPANE_NEWS,
  325. fSplit ? LAYOUT_POS_LEFT : LAYOUT_POS_BOTTOM,
  326. fChecked,
  327. fHeader, 0);
  328. }
  329. else
  330. {
  331. pBrowser->SetViewLayout(DISPID_MSGVIEW_PREVIEWPANE_MAIL,
  332. fSplit ? LAYOUT_POS_LEFT : LAYOUT_POS_BOTTOM,
  333. fChecked,
  334. fHeader, 0);
  335. }
  336. }
  337. PropSheet_UnChanged(GetParent(hwnd), hwnd);
  338. return (0);
  339. }
  340. return (0);
  341. }