X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/292e5e1f17af67a5885f1fdaa8c45a8a5a2a3ca5..c84030e020e56735cb4b7c1534e99d21a8bb48c0:/src/osx/carbon/fontdlg.cpp diff --git a/src/osx/carbon/fontdlg.cpp b/src/osx/carbon/fontdlg.cpp index bfc19e1386..1e83fe0ee2 100644 --- a/src/osx/carbon/fontdlg.cpp +++ b/src/osx/carbon/fontdlg.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: src/mac/carbon/fontdlg.cpp +// Name: src/osx/carbon/fontdlg.cpp // Purpose: wxFontDialog class for carbon 10.2+. // Author: Ryan Norton // Modified by: @@ -41,17 +41,20 @@ #endif #include "wx/fontdlg.h" +#include "wx/fontutil.h" #if wxOSX_USE_EXPERIMENTAL_FONTDIALOG IMPLEMENT_DYNAMIC_CLASS(wxFontDialog, wxDialog) -#include "wx/osx/uma.h" +#include "wx/osx/private.h" // --------------------------------------------------------------------------- // wxFontDialog // --------------------------------------------------------------------------- +#if wxOSX_USE_CARBON + static const EventTypeSpec eventList[] = { { kEventClassFont, kEventFontSelection } , @@ -80,7 +83,9 @@ wxMacCarbonFontPanelHandler(EventHandlerCallRef WXUNUSED(nextHandler), if ( cEvent.GetParameter( kEventParamCTFontDescriptor, typeCTFontDescriptorRef, &descr ) == noErr ) { wxFont font; - font.MacCreateFromCTFontDescriptor(descr); + wxNativeFontInfo fontinfo; + fontinfo.Init(descr); + font.Create(fontinfo); fontdata.SetChosenFont( font ) ; setup = true; } @@ -98,7 +103,7 @@ wxMacCarbonFontPanelHandler(EventHandlerCallRef WXUNUSED(nextHandler), FMFontFamily fontFamily = cEvent.GetParameter(kEventParamFMFontFamily); ATSFontFamilyRef atsfontfamilyref = FMGetATSFontFamilyRefFromFontFamily( fontFamily ) ; OSStatus err = ATSFontFamilyGetName( atsfontfamilyref , kATSOptionFlagsDefault , &cfName ) ; - if ( err == noErr ) + if ( err != noErr ) { wxFAIL_MSG("ATSFontFamilyGetName failed"); } @@ -191,6 +196,7 @@ wxMacCarbonFontPanelHandler(EventHandlerCallRef WXUNUSED(nextHandler), } DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacCarbonFontPanelHandler ) +#endif wxFontDialog::wxFontDialog() { @@ -213,6 +219,8 @@ bool wxFontDialog::Create(wxWindow *WXUNUSED(parent), const wxFontData& data) int wxFontDialog::ShowModal() { +#if wxOSX_USE_CARBON + OSStatus err ; wxFont font = *wxNORMAL_FONT ; if ( m_fontData.m_initialFont.Ok() ) @@ -224,8 +232,9 @@ int wxFontDialog::ShowModal() #if wxOSX_USE_CORE_TEXT if ( UMAGetSystemVersion() >= 0x1050 ) { - CTFontDescriptorRef descr = (CTFontDescriptorRef)font.MacGetCTFontDescriptor(); + CTFontDescriptorRef descr = (CTFontDescriptorRef) CTFontCopyFontDescriptor( (CTFontRef) font.OSXGetCTFont() ); err = SetFontInfoForSelection (kFontSelectionCoreTextType,1, &descr , NULL); + CFRelease( descr ); setup = true; } #endif @@ -247,10 +256,12 @@ int wxFontDialog::ShowModal() if ( !FPIsFontPanelVisible() ) FPShowHideFontPanel(); - +#endif int retval = RunMixedFontDialog(this); +#if wxOSX_USE_CARBON ::RemoveEventHandler(handler); +#endif return retval ; } @@ -501,7 +512,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.")); @@ -577,7 +588,7 @@ void wxFontDialog::CreateControls() wxFontEnumerator enumerator; enumerator.EnumerateFacenames(); wxArrayString facenames = enumerator.GetFacenames(); - if (facenames) + if (!facenames.empty()) { facenames.Add(_("")); facenames.Add(_(""));