From bf31fa26c74df94d13f0b5ffc9842fe9bc3004be Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 21 Jan 2002 17:53:00 +0000 Subject: [PATCH] added wxGetFontFromUser() similar to wxGetColourFromUser() git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@13723 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + include/wx/fontdlg.h | 5 ++++ src/common/utilscmn.cpp | 51 ++++++++++++++++++++++++++++++----------- 3 files changed, 43 insertions(+), 14 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index a1c2b040d3..3c1756b6c5 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -82,6 +82,7 @@ All (GUI): - support for multiple images in one file added to wxImage (TIFF and ICO formats) - support for CUR and ANI files in wxImage added (Chris Elliott) - wxTextCtrl::GetRange() added +- added wxGetFontFromUser() convenience function wxMSW: diff --git a/include/wx/fontdlg.h b/include/wx/fontdlg.h index 88205f033f..681c6ab5c1 100644 --- a/include/wx/fontdlg.h +++ b/include/wx/fontdlg.h @@ -15,6 +15,11 @@ # include "wx/os2/fontdlg.h" #endif +// get the colour from user and return it +wxFont WXDLLEXPORT +wxGetFontFromUser(wxWindow *parent = (wxWindow *)NULL, + const wxFont& fontInit = wxNullFont); + #endif // wxUSE_FONTDLG #endif diff --git a/src/common/utilscmn.cpp b/src/common/utilscmn.cpp index 9962127b6b..488be4bec8 100644 --- a/src/common/utilscmn.cpp +++ b/src/common/utilscmn.cpp @@ -68,6 +68,7 @@ #if wxUSE_GUI #include "wx/colordlg.h" + #include "wx/fontdlg.h" #include "wx/notebook.h" #include "wx/frame.h" #include "wx/statusbr.h" @@ -962,26 +963,48 @@ wxString wxGetPasswordFromUser(const wxString& message, wxColour wxGetColourFromUser(wxWindow *parent, const wxColour& colInit) { - wxColourData data; - data.SetChooseFull(TRUE); - if ( colInit.Ok() ) - { - data.SetColour((wxColour &)colInit); // const_cast - } + wxColourData data; + data.SetChooseFull(TRUE); + if ( colInit.Ok() ) + { + data.SetColour((wxColour &)colInit); // const_cast + } - wxColour colRet; - wxColourDialog dialog(parent, &data); - if ( dialog.ShowModal() == wxID_OK ) - { - colRet = dialog.GetColourData().GetColour(); - } - //else: leave it invalid + wxColour colRet; + wxColourDialog dialog(parent, &data); + if ( dialog.ShowModal() == wxID_OK ) + { + colRet = dialog.GetColourData().GetColour(); + } + //else: leave it invalid - return colRet; + return colRet; } #endif // wxUSE_COLOURDLG +#if wxUSE_FONTDLG + +wxFont wxGetFontFromUser(wxWindow *parent, const wxFont& fontInit) +{ + wxFontData data; + if ( fontInit.Ok() ) + { + data.SetInitialFont(fontInit); + } + + wxFont fontRet; + wxFontDialog dialog(parent, &data); + if ( dialog.ShowModal() == wxID_OK ) + { + fontRet = dialog.GetFontData().GetChosenFont(); + } + //else: leave it invalid + + return fontRet; +} + +#endif // wxUSE_FONTDLG // ---------------------------------------------------------------------------- // missing C RTL functions (FIXME shouldn't be here at all) // ---------------------------------------------------------------------------- -- 2.47.2