1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/cocoa/aboutdlg.mm
3 // Purpose: native wxAboutBox() implementation for wxMac
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2006 Vadim Zeitlin <vadim@wxwindows.org>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 // ============================================================================
13 // ============================================================================
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
19 // for compilers that support precompilation, includes "wx.h".
20 #include "wx/wxprec.h"
27 #include "wx/aboutdlg.h"
28 #include "wx/generic/aboutdlgg.h"
30 #include "wx/osx/private.h"
32 // see http://developer.apple.com/mac/library/technotes/tn2006/tn2179.html for
33 // information about the various keys used here
35 // helper class for HIAboutBox options
36 class AboutBoxOptions : public wxCFRef<CFMutableDictionaryRef>
39 AboutBoxOptions() : wxCFRef<CFMutableDictionaryRef>
41 CFDictionaryCreateMutable
44 4, // there are at most 4 values
45 &kCFTypeDictionaryKeyCallBacks,
46 &kCFTypeDictionaryValueCallBacks
52 void Set(CFStringRef key, const wxString& value)
54 CFDictionarySetValue(*this, key, wxCFStringRef(value));
57 void SetAttributedString( CFStringRef key, const wxString& value )
59 wxCFRef<CFAttributedStringRef> attrString(
60 CFAttributedStringCreate(kCFAllocatorDefault, wxCFStringRef(value), NULL) );
61 CFDictionarySetValue(*this, key, attrString);
65 // ============================================================================
67 // ============================================================================
69 void wxAboutBox(const wxAboutDialogInfo& info, wxWindow *parent)
71 // Mac native about box currently can show only name, version, copyright
72 // and description fields and we also shoehorn the credits text into the
73 // description but if we have anything else we must use the generic version
75 if ( info.IsSimple() )
79 opts.Set(CFSTR("ApplicationName"), info.GetName());
81 if ( info.HasVersion() )
83 opts.Set(CFSTR("Version"),info.GetVersion());
84 if ( info.GetLongVersion() != (_("Version ")+info.GetVersion()))
85 opts.Set(CFSTR("ApplicationVersion"),info.GetLongVersion());
88 if ( info.HasCopyright() )
89 opts.Set(CFSTR("Copyright"), info.GetCopyrightToDisplay());
91 opts.SetAttributedString(CFSTR("Credits"), info.GetDescriptionAndCredits());
93 [[NSApplication sharedApplication] orderFrontStandardAboutPanelWithOptions:((NSDictionary*)(CFDictionaryRef) opts)];
95 else // simple "native" version is not enough
97 // we need to use the full-blown generic version
98 wxGenericAboutBox(info, parent);
102 #endif // wxUSE_ABOUTDLG