Implement wxFontDialog::SetTitle() in wxMSW
Base class SetTitle() implementation didnd't work for this class as it used the (invalid) HWND of not yet existing dialog, so add a hook procedure for the common font dialog, similar to the existing one for wxColourDialog, which allows us to set the dialog title when the dialog is really created. Closes https://github.com/wxWidgets/wxWidgets/pull/865 Closes #18177.
This commit is contained in:
committed by
Vadim Zeitlin
parent
4430ab8661
commit
a02efd1fc7
@@ -124,6 +124,7 @@ wxMSW:
|
|||||||
- Fix positioning windows at positions >= SHORT_MAX (Cătălin Răceanu).
|
- Fix positioning windows at positions >= SHORT_MAX (Cătălin Răceanu).
|
||||||
- Honour alignment flags for multiline buttons using custom colours too.
|
- Honour alignment flags for multiline buttons using custom colours too.
|
||||||
- Support MSVC auto-linking when using monolithic build too (PB).
|
- Support MSVC auto-linking when using monolithic build too (PB).
|
||||||
|
- Implement wxFontDialog::SetTitle() (Vitaly Stakhovsky).
|
||||||
- Fix build in ANSI (non-Unicode) mode.
|
- Fix build in ANSI (non-Unicode) mode.
|
||||||
|
|
||||||
wxOSX:
|
wxOSX:
|
||||||
|
@@ -25,8 +25,12 @@ public:
|
|||||||
: wxFontDialogBase(parent, data) { Create(parent, data); }
|
: wxFontDialogBase(parent, data) { Create(parent, data); }
|
||||||
|
|
||||||
virtual int ShowModal() wxOVERRIDE;
|
virtual int ShowModal() wxOVERRIDE;
|
||||||
|
virtual void SetTitle(const wxString& title) wxOVERRIDE;
|
||||||
|
virtual wxString GetTitle() const wxOVERRIDE;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
wxString m_title;
|
||||||
|
|
||||||
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxFontDialog);
|
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxFontDialog);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -49,10 +49,45 @@ wxIMPLEMENT_DYNAMIC_CLASS(wxFontDialog, wxDialog);
|
|||||||
// implementation
|
// implementation
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// font dialog hook proc used for setting the dialog title if necessary
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
static
|
||||||
|
UINT_PTR CALLBACK
|
||||||
|
wxFontDialogHookProc(HWND hwnd,
|
||||||
|
UINT uiMsg,
|
||||||
|
WPARAM WXUNUSED(wParam),
|
||||||
|
LPARAM lParam)
|
||||||
|
{
|
||||||
|
if ( uiMsg == WM_INITDIALOG )
|
||||||
|
{
|
||||||
|
CHOOSEFONT *pCH = (CHOOSEFONT *)lParam;
|
||||||
|
wxFontDialog * const
|
||||||
|
dialog = reinterpret_cast<wxFontDialog *>(pCH->lCustData);
|
||||||
|
|
||||||
|
::SetWindowText(hwnd, dialog->GetTitle().t_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxFontDialog
|
// wxFontDialog
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void wxFontDialog::SetTitle(const wxString& title)
|
||||||
|
{
|
||||||
|
// Just store the title here, we can't set it right now because the dialog
|
||||||
|
// doesn't exist yet -- it will be created only when ShowModal() is called.
|
||||||
|
m_title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxString wxFontDialog::GetTitle() const
|
||||||
|
{
|
||||||
|
return m_title;
|
||||||
|
}
|
||||||
|
|
||||||
int wxFontDialog::ShowModal()
|
int wxFontDialog::ShowModal()
|
||||||
{
|
{
|
||||||
WX_HOOK_MODAL_DIALOG();
|
WX_HOOK_MODAL_DIALOG();
|
||||||
@@ -71,6 +106,15 @@ int wxFontDialog::ShowModal()
|
|||||||
chooseFontStruct.hwndOwner = hWndParent;
|
chooseFontStruct.hwndOwner = hWndParent;
|
||||||
chooseFontStruct.lpLogFont = &logFont;
|
chooseFontStruct.lpLogFont = &logFont;
|
||||||
|
|
||||||
|
// Currently we only use the hook to set the title, so only set it up if
|
||||||
|
// we really need to do this.
|
||||||
|
if ( !m_title.empty() )
|
||||||
|
{
|
||||||
|
flags |= CF_ENABLEHOOK;
|
||||||
|
chooseFontStruct.lCustData = (LPARAM)this;
|
||||||
|
chooseFontStruct.lpfnHook = wxFontDialogHookProc;
|
||||||
|
}
|
||||||
|
|
||||||
if ( m_fontData.m_initialFont.IsOk() )
|
if ( m_fontData.m_initialFont.IsOk() )
|
||||||
{
|
{
|
||||||
flags |= CF_INITTOLOGFONTSTRUCT;
|
flags |= CF_INITTOLOGFONTSTRUCT;
|
||||||
|
Reference in New Issue
Block a user