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 opts.Set(CFSTR("ApplicationVersion"),info.GetLongVersion());
87 if ( info.HasCopyright() )
88 opts.Set(CFSTR("Copyright"), info.GetCopyrightToDisplay());
90 opts.SetAttributedString(CFSTR("Credits"), info.GetDescriptionAndCredits());
92 [[NSApplication sharedApplication] orderFrontStandardAboutPanelWithOptions:((NSDictionary*)(CFDictionaryRef) opts)];
94 else // simple "native" version is not enough
96 // we need to use the full-blown generic version
97 wxGenericAboutBox(info, parent);
101 #endif // wxUSE_ABOUTDLG