]> git.saurik.com Git - wxWidgets.git/blame - src/osx/cocoa/aboutdlg.mm
The alignment controls are now left-aligned if the floating controls are not shown.
[wxWidgets.git] / src / osx / cocoa / aboutdlg.mm
CommitLineData
fb8dcb05 1///////////////////////////////////////////////////////////////////////////////
80fdcdb9 2// Name: src/osx/cocoa/aboutdlg.mm
fb8dcb05
SC
3// Purpose: native wxAboutBox() implementation for wxMac
4// Author: Vadim Zeitlin
5// Created: 2006-10-08
fb8dcb05
SC
6// Copyright: (c) 2006 Vadim Zeitlin <vadim@wxwindows.org>
7// Licence: wxWindows licence
8///////////////////////////////////////////////////////////////////////////////
9
10// ============================================================================
11// declarations
12// ============================================================================
13
14// ----------------------------------------------------------------------------
15// headers
16// ----------------------------------------------------------------------------
17
18// for compilers that support precompilation, includes "wx.h".
19#include "wx/wxprec.h"
20
21#if wxUSE_ABOUTDLG
22
23#ifndef WX_PRECOMP
24#endif //WX_PRECOMP
25
26#include "wx/aboutdlg.h"
27#include "wx/generic/aboutdlgg.h"
28
29#include "wx/osx/private.h"
30
e9670814
VZ
31// see http://developer.apple.com/mac/library/technotes/tn2006/tn2179.html for
32// information about the various keys used here
fb8dcb05
SC
33
34// helper class for HIAboutBox options
35class AboutBoxOptions : public wxCFRef<CFMutableDictionaryRef>
36{
37public:
38 AboutBoxOptions() : wxCFRef<CFMutableDictionaryRef>
39 (
40 CFDictionaryCreateMutable
41 (
42 kCFAllocatorDefault,
43 4, // there are at most 4 values
44 &kCFTypeDictionaryKeyCallBacks,
45 &kCFTypeDictionaryValueCallBacks
46 )
47 )
48 {
49 }
50
51 void Set(CFStringRef key, const wxString& value)
52 {
53 CFDictionarySetValue(*this, key, wxCFStringRef(value));
54 }
55
56 void SetAttributedString( CFStringRef key, const wxString& value )
57 {
953aebc2 58 wxCFRef<CFAttributedStringRef> attrString(
fb8dcb05
SC
59 CFAttributedStringCreate(kCFAllocatorDefault, wxCFStringRef(value), NULL) );
60 CFDictionarySetValue(*this, key, attrString);
61 }
62};
63
64// ============================================================================
65// implementation
66// ============================================================================
67
7d7cb800 68void wxAboutBox(const wxAboutDialogInfo& info, wxWindow *parent)
fb8dcb05
SC
69{
70 // Mac native about box currently can show only name, version, copyright
71 // and description fields and we also shoehorn the credits text into the
72 // description but if we have anything else we must use the generic version
73
74 if ( info.IsSimple() )
75 {
76 AboutBoxOptions opts;
77
78 opts.Set(CFSTR("ApplicationName"), info.GetName());
79
80 if ( info.HasVersion() )
81 {
82 opts.Set(CFSTR("Version"),info.GetVersion());
f43a3988
SC
83 if ( info.GetLongVersion() != (_("Version ")+info.GetVersion()))
84 opts.Set(CFSTR("ApplicationVersion"),info.GetLongVersion());
fb8dcb05
SC
85 }
86
87 if ( info.HasCopyright() )
953aebc2 88 opts.Set(CFSTR("Copyright"), info.GetCopyrightToDisplay());
fb8dcb05
SC
89
90 opts.SetAttributedString(CFSTR("Credits"), info.GetDescriptionAndCredits());
91
92 [[NSApplication sharedApplication] orderFrontStandardAboutPanelWithOptions:((NSDictionary*)(CFDictionaryRef) opts)];
93 }
94 else // simple "native" version is not enough
95 {
96 // we need to use the full-blown generic version
7d7cb800 97 wxGenericAboutBox(info, parent);
fb8dcb05
SC
98 }
99}
100
101#endif // wxUSE_ABOUTDLG