1
// TortoiseGitMerge - a Diff/Patch program
3 // Copyright (C) 2018-2019, 2023 - TortoiseGit
4 // Copyright (C) 2006, 2009, 2015, 2018, 2020 - TortoiseSVN
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software Foundation,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 * \ingroup TortoiseMerge
28 * This is the container for all settings pages. A setting page is
29 * a class derived from CPropertyPage with an additional method called
30 * SaveData(). The SaveData() method is used by the dialog to save
31 * the settings the user has made - if that method is not called then
32 * it means that the changes are discarded! Each settings page has
33 * to make sure that no changes are saved outside that method.
36 class CSettings
: public CPropertySheet
38 DECLARE_DYNAMIC(CSettings
)
41 * Adds all pages to this Settings-Dialog.
45 * Removes the pages and frees up memory.
47 void RemovePropPages();
49 void BuildPropPageArray() override
51 CPropertySheet::BuildPropPageArray();
53 // create a copy of existing PROPSHEETPAGE array which can be modified
54 int nPages
= static_cast<int>(m_pages
.GetSize());
56 for (decltype(nPages
) i
= 0; i
< nPages
; ++i
)
58 auto pPage
= GetPage(i
);
59 nBytes
+= pPage
->m_psp
.dwSize
;
61 auto ppsp0
= static_cast<LPPROPSHEETPAGE
>(malloc(nBytes
));
62 Checked::memcpy_s(ppsp0
, nBytes
, m_psh
.ppsp
, nBytes
);
64 for (decltype(nPages
) i
= 0; i
< nPages
; ++i
)
66 const DLGTEMPLATE
* pResource
= ppsp
->pResource
;
67 CDialogTemplate
dlgTemplate(pResource
);
68 dlgTemplate
.SetFont(L
"Segoe UI", 9);
69 HGLOBAL hNew
= GlobalAlloc(GPTR
, dlgTemplate
.m_dwTemplateSize
);
70 ppsp
->pResource
= static_cast<DLGTEMPLATE
*>(GlobalLock(hNew
));
71 Checked::memcpy_s(const_cast<void*>(static_cast<const void*>(ppsp
->pResource
)), dlgTemplate
.m_dwTemplateSize
, dlgTemplate
.m_hTemplate
, dlgTemplate
.m_dwTemplateSize
);
73 reinterpret_cast<BYTE
*&>(ppsp
) += ppsp
->dwSize
;
75 // free existing PROPSHEETPAGE array and assign the new one
76 free((void*)m_psh
.ppsp
);
81 CSetMainPage
* m_pMainPage
= nullptr;
82 CSetColorPage
* m_pColorPage
= nullptr;
84 int m_themeCallbackId
= 0;
87 CSettings(UINT nIDCaption
, CWnd
* pParentWnd
= nullptr, UINT iSelectPage
= 0);
88 CSettings(LPCWSTR pszCaption
, CWnd
* pParentWnd
= nullptr, UINT iSelectPage
= 0);
92 * Calls the SaveData()-methods of each of the settings pages.
96 BOOL
IsReloadNeeded() const;
97 bool IsDarkMode() const;
100 DECLARE_MESSAGE_MAP()
101 BOOL
OnInitDialog() override
;