+void wxFontDialog::SetData(wxFontData& fontdata)
+{
+ m_fontData = fontdata;
+}
+
+bool wxFontDialog::Create(wxWindow *parent, const wxFontData& data)
+{
+ m_dialogParent = parent;
+ m_fontData = data;
+
+ //Register the events that will return this dialog
+ EventTypeSpec ftEventList[] = { { kEventClassFont, kEventFontSelection } };
+
+ OSStatus err = noErr;
+
+//FIXMEFIXME: Why doesn't it recieve events if there's a parent?
+// if (parent)
+// {
+// err = InstallWindowEventHandler(
+// MAC_WXHWND(parent->GetHandle()),
+// GetwxFontDialogEventHandlerUPP(),
+// GetEventTypeCount(ftEventList), ftEventList,
+// this, (&(EventHandlerRef&)m_pEventHandlerRef));
+//
+// }
+// else //no parent - send to app
+// {
+ err = InstallApplicationEventHandler(
+ GetwxFontDialogEventHandlerUPP(),
+ GetEventTypeCount(ftEventList), ftEventList,
+ this, (&(EventHandlerRef&)m_pEventHandlerRef));
+// }
+
+ return err == noErr;
+}
+
+bool wxFontDialog::IsShown() const
+{
+ return FPIsFontPanelVisible();
+}
+
+int wxFontDialog::ShowModal()
+{
+ wxASSERT(!FPIsFontPanelVisible());
+
+ //set up initial font
+ wxFont theInitialFont = m_fontData.GetInitialFont();
+
+ //create ATSU style
+ ATSUStyle theStyle;
+ OSStatus status = ATSUCreateStyle(&theStyle);
+ check_noerr(status);
+
+ //put stuff into the style - we don't need kATSUColorTag
+ ATSUFontID fontid = theInitialFont.MacGetATSUFontID();
+ Fixed fontsize = theInitialFont.MacGetFontSize() << 16;
+ ATSUAttributeTag theTags[2] = { kATSUFontTag, kATSUSizeTag };
+ ByteCount theSizes[2] = { sizeof(ATSUFontID), sizeof(Fixed) };
+ ATSUAttributeValuePtr theValues[2] = { &fontid,
+ &fontsize };
+
+ //set the stuff for the ATSU style
+ verify_noerr (ATSUSetAttributes (theStyle, 2, theTags, theSizes, theValues) );
+
+ //they set us up the bomb! Set the initial font of the dialog
+ SetFontInfoForSelection(kFontSelectionATSUIType,
+ 1,
+ &theStyle,
+ (HIObjectRef)
+ (m_dialogParent ?
+ GetWindowEventTarget(MAC_WXHWND(m_dialogParent->GetHandle())) :
+ GetApplicationEventTarget())
+ );
+
+ //dispose of the style
+ status = ATSUDisposeStyle(theStyle);
+ check_noerr(status);
+
+ //in case the user doesn't choose anything -
+ //if he doesn't we'll get a bad font with red text
+ m_fontData.SetChosenFont(m_fontData.GetInitialFont());
+ m_fontData.SetColour(wxColour(0,0,0));
+
+ //finally, show the font dialog
+ if( (status = FPShowHideFontPanel()) == noErr)
+ {
+ while(FPIsFontPanelVisible())
+ {
+ //yeild so we can get events
+ ::wxSafeYield(m_dialogParent, false);
+ }
+ }
+ else
+ return wxID_CANCEL;
+
+ return wxID_OK;
+}
+
+
+#else
+ //10.2+ only
+
+
+//
+// no native implementation
+//