Make wxFileDialog::MSWOnXXX() private

These functions were always marked as being implementation-only, but we
can actually do better and make them private, by making the dialog hook
function a (static) member of wxFileDialogMSWData and making this class
(which is now a class and not a struct any more, as it's not just a
collection of fields any longer) a friend of wxFileDialog.

No real changes.
This commit is contained in:
Vadim Zeitlin
2022-05-25 16:54:30 +01:00
parent cf81527cfc
commit 895b4a0710
2 changed files with 28 additions and 20 deletions

View File

@@ -34,22 +34,9 @@ public:
virtual void GetPaths(wxArrayString& paths) const wxOVERRIDE;
virtual void GetFilenames(wxArrayString& files) const wxOVERRIDE;
virtual bool SupportsExtraControl() const wxOVERRIDE { return true; }
void MSWOnInitDialogHook(WXHWND hwnd);
virtual int ShowModal() wxOVERRIDE;
// wxMSW-specific implementation from now on
// -----------------------------------------
// called from the hook procedure on CDN_INITDONE reception
virtual void MSWOnInitDone(WXHWND hDlg);
// called from the hook procedure on CDN_SELCHANGE.
void MSWOnSelChange(WXHWND hDlg);
// called from the hook procedure on CDN_TYPECHANGE.
void MSWOnTypeChange(WXHWND hDlg, int nFilterIndex);
protected:
virtual void DoMoveWindow(int x, int y, int width, int height) wxOVERRIDE;
@@ -58,6 +45,21 @@ protected:
virtual void DoGetPosition( int *x, int *y ) const wxOVERRIDE;
private:
// Allow it to call MSWOnXXX() functions below.
friend class wxFileDialogMSWData;
// called when the dialog is created
void MSWOnInitDialogHook(WXHWND hwnd);
// called from the hook procedure on CDN_INITDONE reception
void MSWOnInitDone(WXHWND hDlg);
// called from the hook procedure on CDN_SELCHANGE.
void MSWOnSelChange(WXHWND hDlg);
// called from the hook procedure on CDN_TYPECHANGE.
void MSWOnTypeChange(WXHWND hDlg, int nFilterIndex);
// The real implementation of ShowModal() using traditional common dialog
// functions.
int ShowCommFileDialog(WXHWND owner);
@@ -66,7 +68,7 @@ private:
int ShowIFileDialog(WXHWND owner);
// Get the data object, allocating it if necessary.
struct wxFileDialogMSWData& MSWData();
wxFileDialogMSWData& MSWData();
wxArrayString m_fileNames;

View File

@@ -149,14 +149,20 @@ void RestoreExceptionPolicy()
// wxFileDialogMSWData: private data used by the dialog
// ----------------------------------------------------------------------------
struct wxFileDialogMSWData
class wxFileDialogMSWData
{
public:
wxFileDialogMSWData()
{
m_bMovedWindow = false;
m_centreDir = 0;
}
// Hook function used by the common dialogs: it's a member of this class
// just to allow it to call the private functions of wxFileDialog.
static UINT_PTR APIENTRY
HookFunction(HWND hDlg, UINT iMsg, WPARAM wParam, LPARAM lParam);
// remember if our SetPosition() or Centre() (which requires special
// treatment) was called
bool m_bMovedWindow;
@@ -168,10 +174,10 @@ struct wxFileDialogMSWData
// ----------------------------------------------------------------------------
UINT_PTR APIENTRY
wxFileDialogHookFunction(HWND hDlg,
UINT iMsg,
WPARAM WXUNUSED(wParam),
LPARAM lParam)
wxFileDialogMSWData::HookFunction(HWND hDlg,
UINT iMsg,
WPARAM WXUNUSED(wParam),
LPARAM lParam)
{
switch ( iMsg )
{
@@ -590,7 +596,7 @@ int wxFileDialog::ShowCommFileDialog(WXHWND hWndParent)
of.lpstrInitialDir = dir.c_str();
of.Flags = msw_flags;
of.lpfnHook = wxFileDialogHookFunction;
of.lpfnHook = wxFileDialogMSWData::HookFunction;
of.lCustData = (LPARAM)this;
wxArrayString wildDescriptions, wildFilters;