]> git.saurik.com Git - wxWidgets.git/blob - src/osx/cocoa/aboutdlg.mm
Add missing WXK constants for the control keys
[wxWidgets.git] / src / osx / cocoa / aboutdlg.mm
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/cocoa/aboutdlg.mm
3 // Purpose: native wxAboutBox() implementation for wxMac
4 // Author: Vadim Zeitlin
5 // Created: 2006-10-08
6 // RCS-ID: $Id$
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 // see http://developer.apple.com/mac/library/technotes/tn2006/tn2179.html for
33 // information about the various keys used here
34
35 // helper class for HIAboutBox options
36 class AboutBoxOptions : public wxCFRef<CFMutableDictionaryRef>
37 {
38 public:
39 AboutBoxOptions() : wxCFRef<CFMutableDictionaryRef>
40 (
41 CFDictionaryCreateMutable
42 (
43 kCFAllocatorDefault,
44 4, // there are at most 4 values
45 &kCFTypeDictionaryKeyCallBacks,
46 &kCFTypeDictionaryValueCallBacks
47 )
48 )
49 {
50 }
51
52 void Set(CFStringRef key, const wxString& value)
53 {
54 CFDictionarySetValue(*this, key, wxCFStringRef(value));
55 }
56
57 void SetAttributedString( CFStringRef key, const wxString& value )
58 {
59 wxCFRef<CFAttributedStringRef> attrString(
60 CFAttributedStringCreate(kCFAllocatorDefault, wxCFStringRef(value), NULL) );
61 CFDictionarySetValue(*this, key, attrString);
62 }
63 };
64
65 // ============================================================================
66 // implementation
67 // ============================================================================
68
69 void wxAboutBox(const wxAboutDialogInfo& info, wxWindow *parent)
70 {
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
74
75 if ( info.IsSimple() )
76 {
77 AboutBoxOptions opts;
78
79 opts.Set(CFSTR("ApplicationName"), info.GetName());
80
81 if ( info.HasVersion() )
82 {
83 opts.Set(CFSTR("Version"),info.GetVersion());
84 if ( info.GetLongVersion() != (_("Version ")+info.GetVersion()))
85 opts.Set(CFSTR("ApplicationVersion"),info.GetLongVersion());
86 }
87
88 if ( info.HasCopyright() )
89 opts.Set(CFSTR("Copyright"), info.GetCopyrightToDisplay());
90
91 opts.SetAttributedString(CFSTR("Credits"), info.GetDescriptionAndCredits());
92
93 [[NSApplication sharedApplication] orderFrontStandardAboutPanelWithOptions:((NSDictionary*)(CFDictionaryRef) opts)];
94 }
95 else // simple "native" version is not enough
96 {
97 // we need to use the full-blown generic version
98 wxGenericAboutBox(info, parent);
99 }
100 }
101
102 #endif // wxUSE_ABOUTDLG