X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8dcf5bc1a6a60cf04f7f3e38563da212ef715883..48e05747043db02c4e9d2e286eca4fdf5dee7881:/src/osx/carbon/fontdlg.cpp?ds=sidebyside diff --git a/src/osx/carbon/fontdlg.cpp b/src/osx/carbon/fontdlg.cpp index 54f7971d0f..b1ae442c78 100644 --- a/src/osx/carbon/fontdlg.cpp +++ b/src/osx/carbon/fontdlg.cpp @@ -42,6 +42,7 @@ #include "wx/fontdlg.h" #include "wx/fontutil.h" +#include "wx/modalhook.h" #if wxOSX_USE_EXPERIMENTAL_FONTDIALOG @@ -77,7 +78,7 @@ wxMacCarbonFontPanelHandler(EventHandlerCallRef WXUNUSED(nextHandler), { bool setup = false ; #if wxOSX_USE_CORE_TEXT - if ( UMAGetSystemVersion() >= 0x1050 ) + if ( !setup ) { CTFontDescriptorRef descr; if ( cEvent.GetParameter( kEventParamCTFontDescriptor, typeCTFontDescriptorRef, &descr ) == noErr ) @@ -202,6 +203,11 @@ wxFontDialog::wxFontDialog() { } +wxFontDialog::wxFontDialog(wxWindow *parent) +{ + Create(parent); +} + wxFontDialog::wxFontDialog(wxWindow *parent, const wxFontData& data) { Create(parent, data); @@ -211,26 +217,33 @@ wxFontDialog::~wxFontDialog() { } -bool wxFontDialog::Create(wxWindow *WXUNUSED(parent), const wxFontData& data) +bool wxFontDialog::Create(wxWindow *WXUNUSED(parent)) { - m_fontData = data; return true ; } +bool wxFontDialog::Create(wxWindow *parent, const wxFontData& data) +{ + m_fontData = data; + return Create(parent) ; +} + int wxFontDialog::ShowModal() { + WX_HOOK_MODAL_DIALOG(); + #if wxOSX_USE_CARBON OSStatus err ; wxFont font = *wxNORMAL_FONT ; - if ( m_fontData.m_initialFont.Ok() ) + if ( m_fontData.m_initialFont.IsOk() ) { font = m_fontData.m_initialFont ; } bool setup = false; #if wxOSX_USE_CORE_TEXT - if ( UMAGetSystemVersion() >= 0x1050 ) + if ( !setup ) { CTFontDescriptorRef descr = (CTFontDescriptorRef) CTFontCopyFontDescriptor( (CTFontRef) font.OSXGetCTFont() ); err = SetFontInfoForSelection (kFontSelectionCoreTextType,1, &descr , NULL); @@ -257,8 +270,9 @@ int wxFontDialog::ShowModal() if ( !FPIsFontPanelVisible() ) FPShowHideFontPanel(); #endif + wxDialog::OSXBeginModalDialog(); int retval = RunMixedFontDialog(this); - + wxDialog::OSXEndModalDialog(); #if wxOSX_USE_CARBON ::RemoveEventHandler(handler); #endif @@ -315,7 +329,7 @@ void wxFontPreviewCtrl::OnPaint(wxPaintEvent& WXUNUSED(event)) wxSize size = GetSize(); wxFont font = GetFont(); - if ( font.Ok() ) + if ( font.IsOk() ) { dc.SetFont(font); // Calculate vertical centre @@ -401,7 +415,7 @@ void wxFontColourSwatchCtrl::OnMouseEvent(wxMouseEvent& event) dialog->Destroy(); Refresh(); - wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, GetId()); + wxCommandEvent event(wxEVT_BUTTON, GetId()); HandleWindowEvent(event); } } @@ -503,7 +517,7 @@ void wxFontDialog::CreateControls() itemFlexGridSizer4->Add(itemStaticText5, 0, wxALIGN_RIGHT|wxALIGN_TOP|wxALL, 5); wxBoxSizer* itemBoxSizer6 = new wxBoxSizer(wxVERTICAL); - itemFlexGridSizer4->Add(itemBoxSizer6, 0, wxGROW|wxGROW, 5); + itemFlexGridSizer4->Add(itemBoxSizer6, 0, wxGROW, 5); wxString* m_facenameCtrlStrings = NULL; m_facenameCtrl = new wxListBox( itemDialog1, wxID_FONTDIALOG_FACENAME, wxDefaultPosition, wxSize(320, 100), 0, m_facenameCtrlStrings, wxLB_SINGLE ); @@ -512,7 +526,7 @@ void wxFontDialog::CreateControls() wxStaticText* itemStaticText8 = new wxStaticText( itemDialog1, wxID_STATIC, _("Size:"), wxDefaultPosition, wxDefaultSize, 0 ); itemFlexGridSizer4->Add(itemStaticText8, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5); - m_sizeCtrl = new wxSpinCtrl( itemDialog1, wxID_FONTDIALOG_FONTSIZE, _T("12"), wxDefaultPosition, wxSize(60, -1), wxSP_ARROW_KEYS, 1, 300, 12 ); + m_sizeCtrl = new wxSpinCtrl( itemDialog1, wxID_FONTDIALOG_FONTSIZE, wxT("12"), wxDefaultPosition, wxSize(60, -1), wxSP_ARROW_KEYS, 1, 300, 12 ); m_sizeCtrl->SetHelpText(_("The font size in points.")); if (ShowToolTips()) m_sizeCtrl->SetToolTip(_("The font size in points.")); @@ -603,7 +617,7 @@ void wxFontDialog::CreateControls() InitializeControls(); m_previewCtrl->SetFont(m_dialogFont); - if (m_fontData.GetColour().Ok()) + if (m_fontData.GetColour().IsOk()) { m_previewCtrl->SetForegroundColour(m_fontData.GetColour()); } @@ -611,7 +625,7 @@ void wxFontDialog::CreateControls() } /*! - * wxEVT_COMMAND_SPINCTRL_UPDATED event handler for wxID_FONTDIALOG_FONTSIZE + * wxEVT_SPINCTRL event handler for wxID_FONTDIALOG_FONTSIZE */ void wxFontDialog::OnFontdialogFontsizeUpdated( wxSpinEvent& WXUNUSED(event) ) @@ -620,7 +634,7 @@ void wxFontDialog::OnFontdialogFontsizeUpdated( wxSpinEvent& WXUNUSED(event) ) } /*! - * wxEVT_COMMAND_TEXT_UPDATED event handler for wxID_FONTDIALOG_FONTSIZE + * wxEVT_TEXT event handler for wxID_FONTDIALOG_FONTSIZE */ void wxFontDialog::OnFontdialogFontsizeTextUpdated( wxCommandEvent& WXUNUSED(event) ) @@ -629,7 +643,7 @@ void wxFontDialog::OnFontdialogFontsizeTextUpdated( wxCommandEvent& WXUNUSED(eve } /*! - * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for wxID_FONTDIALOG_BOLD + * wxEVT_CHECKBOX event handler for wxID_FONTDIALOG_BOLD */ void wxFontDialog::OnFontdialogBoldClick( wxCommandEvent& WXUNUSED(event) ) @@ -638,7 +652,7 @@ void wxFontDialog::OnFontdialogBoldClick( wxCommandEvent& WXUNUSED(event) ) } /*! - * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for wxID_FONTDIALOG_ITALIC + * wxEVT_CHECKBOX event handler for wxID_FONTDIALOG_ITALIC */ void wxFontDialog::OnFontdialogItalicClick( wxCommandEvent& WXUNUSED(event) ) @@ -647,7 +661,7 @@ void wxFontDialog::OnFontdialogItalicClick( wxCommandEvent& WXUNUSED(event) ) } /*! - * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for wxID_FONTDIALOG_UNDERLINED + * wxEVT_CHECKBOX event handler for wxID_FONTDIALOG_UNDERLINED */ void wxFontDialog::OnFontdialogUnderlinedClick( wxCommandEvent& WXUNUSED(event) ) @@ -656,7 +670,7 @@ void wxFontDialog::OnFontdialogUnderlinedClick( wxCommandEvent& WXUNUSED(event) } /*! - * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK + * wxEVT_BUTTON event handler for wxID_OK */ void wxFontDialog::OnOkClick( wxCommandEvent& event ) @@ -666,7 +680,7 @@ void wxFontDialog::OnOkClick( wxCommandEvent& event ) /*! - * wxEVT_COMMAND_LISTBOX_SELECTED event handler for wxID_FONTDIALOG_FACENAME + * wxEVT_LISTBOX event handler for wxID_FONTDIALOG_FACENAME */ void wxFontDialog::OnFontdialogFacenameSelected( wxCommandEvent& WXUNUSED(event) ) @@ -699,7 +713,7 @@ void wxFontDialog::InitializeFont() bool fontUnderline = false; wxString fontName; - if (m_fontData.m_initialFont.Ok()) + if (m_fontData.m_initialFont.IsOk()) { fontFamily = m_fontData.m_initialFont.GetFamily(); fontWeight = m_fontData.m_initialFont.GetWeight(); @@ -737,7 +751,7 @@ void wxFontDialog::InitializeControls() } m_facenameCtrl->SetStringSelection(facename); - if (m_colourCtrl && m_fontData.GetColour().Ok()) + if (m_colourCtrl && m_fontData.GetColour().IsOk()) { m_colourCtrl->SetColour(m_fontData.GetColour()); m_colourCtrl->Refresh();