1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: osx/cocoa/aboutdlg.cpp
3 // Purpose: native wxAboutBox() implementation for wxMac
4 // Author: Vadim Zeitlin
6 // RCS-ID: $Id: aboutdlg.cpp 54820 2008-07-29 20:04:11Z SC $
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"
33 @"Credits": An NSAttributedString displayed in the info area of the panel. If not specified, this method then looks for a file named “Credits.html”, “Credits.rtf”, and “Credits.rtfd”, in that order, in the bundle returned by the NSBundle class method mainBundle. The first file found is used. If none is found, the info area is left blank.
34 @"ApplicationName": An NSString object displayed as the application’s name. If not specified, this method then uses the value of CFBundleName (localizable). If neither is found, this method uses [[NSProcessInfo processInfo] processName].
35 @"ApplicationIcon": An NSImage object displayed as the application’s icon. If not specified, this method then looks for an image named “NSApplicationIcon”, using [NSImage imageNamed:@"NSApplicationIcon"]. If neither is available, this method uses the generic application icon.
36 @"Version": An NSString object with the build version number of the application (“58.4”), displayed as “(v58.4)”. If not specified, obtain from the CFBundleVersion key in infoDictionary; if not specified, leave blank (the “(v)” is not displayed).
37 @"Copyright": An NSString object with a line of copyright information. If not specified, this method then looks for the value of NSHumanReadableCopyright in the localized version infoDictionary. If neither is available, this method leaves the space blank.
38 @"ApplicationVersion": An NSString object with the application version (“Mac OS X”, “3”, “WebObjects 4.5”, “AppleWorks 6”,...). If not specified, obtain from the CFBundleShortVersionString key in infoDictionary. If neither is available, the build version, if available, is printed alone, as “Version x.x”.
41 // helper class for HIAboutBox options
42 class AboutBoxOptions : public wxCFRef<CFMutableDictionaryRef>
45 AboutBoxOptions() : wxCFRef<CFMutableDictionaryRef>
47 CFDictionaryCreateMutable
50 4, // there are at most 4 values
51 &kCFTypeDictionaryKeyCallBacks,
52 &kCFTypeDictionaryValueCallBacks
58 void Set(CFStringRef key, const wxString& value)
60 CFDictionarySetValue(*this, key, wxCFStringRef(value));
63 void SetAttributedString( CFStringRef key, const wxString& value )
65 wxCFRef<CFAttributedStringRef> attrString(
66 CFAttributedStringCreate(kCFAllocatorDefault, wxCFStringRef(value), NULL) );
67 CFDictionarySetValue(*this, key, attrString);
71 // ============================================================================
73 // ============================================================================
75 void wxAboutBox(const wxAboutDialogInfo& info)
77 // Mac native about box currently can show only name, version, copyright
78 // and description fields and we also shoehorn the credits text into the
79 // description but if we have anything else we must use the generic version
81 if ( info.IsSimple() )
85 opts.Set(CFSTR("ApplicationName"), info.GetName());
87 if ( info.HasVersion() )
89 opts.Set(CFSTR("Version"),info.GetVersion());
90 opts.Set(CFSTR("ApplicationVersion"),
91 wxString::Format(_("Version %s"), info.GetVersion()));
94 if ( info.HasCopyright() )
95 opts.Set(CFSTR("Copyright"), info.GetCopyrightToDisplay());
97 opts.SetAttributedString(CFSTR("Credits"), info.GetDescriptionAndCredits());
99 [[NSApplication sharedApplication] orderFrontStandardAboutPanelWithOptions:((NSDictionary*)(CFDictionaryRef) opts)];
101 else // simple "native" version is not enough
103 // we need to use the full-blown generic version
104 wxGenericAboutBox(info);
108 #endif // wxUSE_ABOUTDLG