added wxGetFontFromUser() similar to wxGetColourFromUser()

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@13723 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2002-01-21 17:53:00 +00:00
parent d741c58382
commit bf31fa26c7
3 changed files with 43 additions and 14 deletions

View File

@ -82,6 +82,7 @@ All (GUI):
- support for multiple images in one file added to wxImage (TIFF and ICO formats) - 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) - support for CUR and ANI files in wxImage added (Chris Elliott)
- wxTextCtrl::GetRange() added - wxTextCtrl::GetRange() added
- added wxGetFontFromUser() convenience function
wxMSW: wxMSW:

View File

@ -15,6 +15,11 @@
# include "wx/os2/fontdlg.h" # include "wx/os2/fontdlg.h"
#endif #endif
// get the colour from user and return it
wxFont WXDLLEXPORT
wxGetFontFromUser(wxWindow *parent = (wxWindow *)NULL,
const wxFont& fontInit = wxNullFont);
#endif // wxUSE_FONTDLG #endif // wxUSE_FONTDLG
#endif #endif

View File

@ -68,6 +68,7 @@
#if wxUSE_GUI #if wxUSE_GUI
#include "wx/colordlg.h" #include "wx/colordlg.h"
#include "wx/fontdlg.h"
#include "wx/notebook.h" #include "wx/notebook.h"
#include "wx/frame.h" #include "wx/frame.h"
#include "wx/statusbr.h" #include "wx/statusbr.h"
@ -962,26 +963,48 @@ wxString wxGetPasswordFromUser(const wxString& message,
wxColour wxGetColourFromUser(wxWindow *parent, const wxColour& colInit) wxColour wxGetColourFromUser(wxWindow *parent, const wxColour& colInit)
{ {
wxColourData data; wxColourData data;
data.SetChooseFull(TRUE); data.SetChooseFull(TRUE);
if ( colInit.Ok() ) if ( colInit.Ok() )
{ {
data.SetColour((wxColour &)colInit); // const_cast data.SetColour((wxColour &)colInit); // const_cast
} }
wxColour colRet; wxColour colRet;
wxColourDialog dialog(parent, &data); wxColourDialog dialog(parent, &data);
if ( dialog.ShowModal() == wxID_OK ) if ( dialog.ShowModal() == wxID_OK )
{ {
colRet = dialog.GetColourData().GetColour(); colRet = dialog.GetColourData().GetColour();
} }
//else: leave it invalid //else: leave it invalid
return colRet; return colRet;
} }
#endif // wxUSE_COLOURDLG #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) // missing C RTL functions (FIXME shouldn't be here at all)
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------