1 ///////////////////////////////////////////////////////////////////////////////
 
   2 // Name:        src/osx/cocoa/aboutdlg.mm
 
   3 // Purpose:     native wxAboutBox() implementation for wxMac
 
   4 // Author:      Vadim Zeitlin
 
   6 // Copyright:   (c) 2006 Vadim Zeitlin <vadim@wxwindows.org>
 
   7 // Licence:     wxWindows licence
 
   8 ///////////////////////////////////////////////////////////////////////////////
 
  10 // ============================================================================
 
  12 // ============================================================================
 
  14 // ----------------------------------------------------------------------------
 
  16 // ----------------------------------------------------------------------------
 
  18 // for compilers that support precompilation, includes "wx.h".
 
  19 #include "wx/wxprec.h"
 
  26 #include "wx/aboutdlg.h"
 
  27 #include "wx/generic/aboutdlgg.h"
 
  29 #include "wx/osx/private.h"
 
  31 // see http://developer.apple.com/mac/library/technotes/tn2006/tn2179.html for
 
  32 // information about the various keys used here
 
  34 // helper class for HIAboutBox options
 
  35 class AboutBoxOptions : public wxCFRef<CFMutableDictionaryRef>
 
  38     AboutBoxOptions() : wxCFRef<CFMutableDictionaryRef>
 
  40                           CFDictionaryCreateMutable
 
  43                            4, // there are at most 4 values
 
  44                            &kCFTypeDictionaryKeyCallBacks,
 
  45                            &kCFTypeDictionaryValueCallBacks
 
  51     void Set(CFStringRef key, const wxString& value)
 
  53         CFDictionarySetValue(*this, key, wxCFStringRef(value));
 
  56     void SetAttributedString( CFStringRef key, const wxString& value )
 
  58           wxCFRef<CFAttributedStringRef> attrString(
 
  59             CFAttributedStringCreate(kCFAllocatorDefault, wxCFStringRef(value), NULL) );
 
  60         CFDictionarySetValue(*this, key, attrString);
 
  64 // ============================================================================
 
  66 // ============================================================================
 
  68 void wxAboutBox(const wxAboutDialogInfo& info, wxWindow *parent)
 
  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
 
  74     if ( info.IsSimple() )
 
  78         opts.Set(CFSTR("ApplicationName"), info.GetName());
 
  80         if ( info.HasVersion() )
 
  82             opts.Set(CFSTR("Version"),info.GetVersion());
 
  83             if ( info.GetLongVersion() != (_("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