]> git.saurik.com Git - wxWidgets.git/blob - src/osx/cocoa/aboutdlg.mm
make sure NSScrollers are always having the desired orientation, fixes #10803
[wxWidgets.git] / src / osx / cocoa / aboutdlg.mm
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: osx/cocoa/aboutdlg.cpp
3 // Purpose: native wxAboutBox() implementation for wxMac
4 // Author: Vadim Zeitlin
5 // Created: 2006-10-08
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 ///////////////////////////////////////////////////////////////////////////////
10
11 // ============================================================================
12 // declarations
13 // ============================================================================
14
15 // ----------------------------------------------------------------------------
16 // headers
17 // ----------------------------------------------------------------------------
18
19 // for compilers that support precompilation, includes "wx.h".
20 #include "wx/wxprec.h"
21
22 #if wxUSE_ABOUTDLG
23
24 #ifndef WX_PRECOMP
25 #endif //WX_PRECOMP
26
27 #include "wx/aboutdlg.h"
28 #include "wx/generic/aboutdlgg.h"
29
30 #include "wx/osx/private.h"
31
32 /*
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”.
39 */
40
41 // helper class for HIAboutBox options
42 class AboutBoxOptions : public wxCFRef<CFMutableDictionaryRef>
43 {
44 public:
45 AboutBoxOptions() : wxCFRef<CFMutableDictionaryRef>
46 (
47 CFDictionaryCreateMutable
48 (
49 kCFAllocatorDefault,
50 4, // there are at most 4 values
51 &kCFTypeDictionaryKeyCallBacks,
52 &kCFTypeDictionaryValueCallBacks
53 )
54 )
55 {
56 }
57
58 void Set(CFStringRef key, const wxString& value)
59 {
60 CFDictionarySetValue(*this, key, wxCFStringRef(value));
61 }
62
63 void SetAttributedString( CFStringRef key, const wxString& value )
64 {
65 wxCFRef<CFAttributedStringRef> attrString(
66 CFAttributedStringCreate(kCFAllocatorDefault, wxCFStringRef(value), NULL) );
67 CFDictionarySetValue(*this, key, attrString);
68 }
69 };
70
71 // ============================================================================
72 // implementation
73 // ============================================================================
74
75 void wxAboutBox(const wxAboutDialogInfo& info, wxWindow *parent)
76 {
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
80
81 if ( info.IsSimple() )
82 {
83 AboutBoxOptions opts;
84
85 opts.Set(CFSTR("ApplicationName"), info.GetName());
86
87 if ( info.HasVersion() )
88 {
89 opts.Set(CFSTR("Version"),info.GetVersion());
90 opts.Set(CFSTR("ApplicationVersion"),
91 wxString::Format(_("Version %s"), info.GetVersion()));
92 }
93
94 if ( info.HasCopyright() )
95 opts.Set(CFSTR("Copyright"), info.GetCopyrightToDisplay());
96
97 opts.SetAttributedString(CFSTR("Credits"), info.GetDescriptionAndCredits());
98
99 [[NSApplication sharedApplication] orderFrontStandardAboutPanelWithOptions:((NSDictionary*)(CFDictionaryRef) opts)];
100 }
101 else // simple "native" version is not enough
102 {
103 // we need to use the full-blown generic version
104 wxGenericAboutBox(info, parent);
105 }
106 }
107
108 #endif // wxUSE_ABOUTDLG