wxMac, wxFontDialog and Snow Leopard (Mac OS 10.6)

75 views
Skip to first unread message

Julian Smart

unread,
Aug 31, 2009, 1:47:57 PM8/31/09
to wx-u...@googlegroups.com
Hi,

So far I've only found one show-stopper problem with wxWidgets 2.8
Carbon apps under Snow Leopard, and that is the behaviour of the native
wxFontDialog implementation. When shown, the dialog flashes up and then
disappears almost immediately. This can be seen in samples/font, for
example, built on either 10.5 or 10.6 with the 10.4 SDK and GCC 4.0.1 (I
haven't yet tried using the 10.5 or 10.6 SDK). Go to Choose -> Choose
Font to see the problem. The font dialog is fine in Mac OS 10.5 and below.

My workaround for my own apps (assuming it will be needed) is to use
wxRichTextCtrl's formatting dialog, since it's maybe a bit nicer than
the generic font dialog, and at least consistent with wxRTC formatting
dialogs if you're using them. I append a replacement for the font dialog
that uses wxRichTextFormattingDialog, below. Otherwise you can set
wxMAC_USE_EXPERIMENTAL_FONTDIALOG to 0 in
include/wx/mac/carbon/fontdlg.h and recompile wxMac to get a non-native
font dialog.

BTW to compile with the 10.4 SDK on 10.6 you have to use GCC 4.0 or you
get compile errors in SDK headers. To do this, you can prepend these to
a script that calls configure and make:

export CC=gcc-4.0
export CPP=cpp-4.0
export CXX=g++-4.0

Anyone know whether, if I use the 10.6 SDK, I can still deploy apps on
10.4 including universal binaries? I do currently have
--with-macosx-version-min=10.3,
--with-libiconv-prefix=/Developer/SDKs/MacOSX10.4u.sdk/usr, and
MACOSX_DEPLOYMENT_TARGET=10.3.

(Off-topic, but it might help someone - if you install Snow Leopard on
an external drive, the installer reboots and you then need to boot from
the DVD to finish the install, rather than rebooting from the drive you
were installing to. I've found it handy to use a cheap 1TB firewire
drive [WD MyBook Studio Edition] to store different Mac OS X versions on
several partions, using the shareware 'SuperDuper' utility to copy the
current OS to the relevant partition before installing the latest OS on
top of that. Then when that version seems OK for developing on I can
install the latest version on the main hard drive, and I can test apps
on any OS version by rebooting into the relevant partition. Obvious, but
thought I'd mention it in case people are stressed out by the thought of
juggling different Mac OS X versions.)

Regards,

Julian

--------------

Header:

#include "wx/fontdlg.h"

//
----------------------------------------------------------------------------
// wxRichTextFontDialog: a substitute for wxFontDialog
//
----------------------------------------------------------------------------

class wxRichTextFontDialog: public wxFontDialogBase
{
public:
wxRichTextFontDialog() : wxFontDialogBase() { Init(); /* must be
Create()d later */ }
wxRichTextFontDialog(wxWindow *parent)
: wxFontDialogBase(parent) { Init(); Create(parent); }
wxRichTextFontDialog(wxWindow *parent, const wxFontData& data)
: wxFontDialogBase(parent, data) { Init(); Create(parent, data); }

void Init() { m_title = _("Font"); }

virtual int ShowModal();

virtual void SetTitle( const wxString& title) { m_title = title; }
virtual wxString GetTitle() const { return m_title; }

protected:
wxString m_title;

DECLARE_DYNAMIC_CLASS_NO_COPY(wxRichTextFontDialog)
};

Implementation:

#include "wx/richtext/richtextformatdlg.h"

IMPLEMENT_DYNAMIC_CLASS(wxRichTextFontDialog, wxDialog)

int wxRichTextFontDialog::ShowModal()
{
wxTextAttrEx attr;
if (m_fontData.GetInitialFont().Ok())
attr.SetFont(m_fontData.GetInitialFont());

if (m_fontData.GetColour().Ok())
attr.SetTextColour(m_fontData.GetColour());

wxRichTextFormattingDialog formatDlg(wxRICHTEXT_FORMAT_FONT,
GetParent(), GetTitle());
formatDlg.SetAttributes(attr);

if (formatDlg.ShowModal() == wxID_OK)
{
wxTextAttrEx attr(formatDlg.GetAttributes());

m_fontData.SetChosenFont(attr.GetFont());
m_fontData.SetColour(attr.GetTextColour());

return wxID_OK;
}
else
return wxID_CANCEL;
}

--
Julian Smart, Anthemion Software Ltd.
28/5 Gillespie Crescent, Edinburgh, Midlothian, EH10 4HU
www.anthemion.co.uk | +44 (0)131 229 5306
Tools for writers: www.writerscafe.co.uk
wxWidgets RAD: www.dialogblocks.com
Blog: www.juliansmart.com

Reply all
Reply to author
Forward
0 new messages