From f14d6dd133f96d7110b9ff635e977349b1806238 Mon Sep 17 00:00:00 2001
From: Julian Smart <julian@anthemion.co.uk>
Date: Mon, 2 Jan 2006 14:26:36 +0000
Subject: [PATCH] Added caption parameter to wxGetFontFromUser and
 wxGetColourFromUser.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36623 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---
 docs/changes.txt           |  1 +
 docs/latex/wx/function.tex |  8 +++++--
 include/wx/colordlg.h      |  2 +-
 include/wx/fontdlg.h       |  2 +-
 src/common/utilscmn.cpp    | 43 ++++++++++++++++++++++++++++++++++++--
 5 files changed, 50 insertions(+), 6 deletions(-)

diff --git a/docs/changes.txt b/docs/changes.txt
index 3b115f5e13..db153c5031 100644
--- a/docs/changes.txt
+++ b/docs/changes.txt
@@ -44,6 +44,7 @@ All (GUI):
 - Added space after list item number in wxHTML.
 - Implemented <sub> and <sup> handling in wxHTML (based on patch
   by Sandro Sigala)
+- Added caption parameter to wxGetFontFromUser and wxGetColourFromUser.
 
 wxMSW:
 
diff --git a/docs/latex/wx/function.tex b/docs/latex/wx/function.tex
index 98e11967dc..cc3f336e88 100644
--- a/docs/latex/wx/function.tex
+++ b/docs/latex/wx/function.tex
@@ -1904,7 +1904,7 @@ See also \helpref{wxIsBusy}{wxisbusy}, \helpref{wxBusyCursor}{wxbusycursor}.
 
 \membersection{::wxGetColourFromUser}\label{wxgetcolourfromuser}
 
-\func{wxColour}{wxGetColourFromUser}{\param{wxWindow *}{parent}, \param{const wxColour\& }{colInit}}
+\func{wxColour}{wxGetColourFromUser}{\param{wxWindow *}{parent}, \param{const wxColour\& }{colInit}, \param{const wxString\& }{caption = wxEmptyString}}
 
 Shows the colour selection dialog and returns the colour selected by user or
 invalid colour (use \helpref{wxColour::Ok}{wxcolourok} to test whether a colour
@@ -1916,6 +1916,8 @@ is valid) if the dialog was cancelled.
 
 \docparam{colInit}{If given, this will be the colour initially selected in the dialog.}
 
+\docparam{caption}{If given, this will be used for the dialog caption.}
+
 \wxheading{Include files}
 
 <wx/colordlg.h>
@@ -1923,7 +1925,7 @@ is valid) if the dialog was cancelled.
 
 \membersection{::wxGetFontFromUser}\label{wxgetfontfromuser}
 
-\func{wxFont}{wxGetFontFromUser}{\param{wxWindow *}{parent}, \param{const wxFont\& }{fontInit}}
+\func{wxFont}{wxGetFontFromUser}{\param{wxWindow *}{parent}, \param{const wxFont\& }{fontInit}, \param{const wxString\& }{caption = wxEmptyString}}
 
 Shows the font selection dialog and returns the font selected by user or
 invalid font (use \helpref{wxFont::Ok}{wxfontok} to test whether a font
@@ -1935,6 +1937,8 @@ is valid) if the dialog was cancelled.
 
 \docparam{fontInit}{If given, this will be the font initially selected in the dialog.}
 
+\docparam{caption}{If given, this will be used for the dialog caption.}
+
 \wxheading{Include files}
 
 <wx/fontdlg.h>
diff --git a/include/wx/colordlg.h b/include/wx/colordlg.h
index 6992910c67..8fb0ff6af2 100644
--- a/include/wx/colordlg.h
+++ b/include/wx/colordlg.h
@@ -33,7 +33,7 @@
 // get the colour from user and return it
 wxColour WXDLLEXPORT
 wxGetColourFromUser(wxWindow *parent = (wxWindow *)NULL,
-                    const wxColour& colInit = wxNullColour);
+                    const wxColour& colInit = wxNullColour, const wxString& caption = wxEmptyString);
 
 #endif // wxUSE_COLOURDLG
 
diff --git a/include/wx/fontdlg.h b/include/wx/fontdlg.h
index e0d5c8209f..26dc4924f4 100644
--- a/include/wx/fontdlg.h
+++ b/include/wx/fontdlg.h
@@ -102,7 +102,7 @@ protected:
 // cancelled
 wxFont WXDLLEXPORT
 wxGetFontFromUser(wxWindow *parent = (wxWindow *)NULL,
-                  const wxFont& fontInit = wxNullFont);
+                  const wxFont& fontInit = wxNullFont, const wxString& caption = wxEmptyString);
 
 #endif // wxUSE_FONTDLG
 
diff --git a/src/common/utilscmn.cpp b/src/common/utilscmn.cpp
index b048ccd3c6..c0d7e529c8 100644
--- a/src/common/utilscmn.cpp
+++ b/src/common/utilscmn.cpp
@@ -82,6 +82,13 @@
 #include "wx/msw/wince/time.h"
 #endif
 
+#ifdef __WXMAC__
+#include "wx/mac/private.h"
+#ifndef __DARWIN__
+#include "InternetConfig.h"
+#endif
+#endif
+
 #if !defined(__MWERKS__) && !defined(__WXWINCE__)
     #include <sys/types.h>
     #include <sys/stat.h>
@@ -607,6 +614,34 @@ bool wxLaunchDefaultBrowser(const wxString& urlOrig, int flags)
 #endif // __WXDEBUG__
         return true;
     }
+#elif defined(__WXMAC__)
+    OSStatus err;
+    ICInstance inst;
+    SInt32 startSel;
+    SInt32 endSel;
+
+    err = ICStart(&inst, 'STKA'); // put your app creator code here
+    if (err == noErr) {
+#if !TARGET_CARBON
+        err = ICFindConfigFile(inst, 0, nil);
+#endif
+        if (err == noErr)
+        {
+            ConstStr255Param hint = 0;
+            startSel = 0;
+            endSel = url.Length();
+            err = ICLaunchURL(inst, hint, url.fn_str(), endSel, &startSel, &endSel);
+            if (err != noErr)
+                wxLogDebug(wxT("ICLaunchURL error %d"), (int) err);
+        }
+        ICStop(inst);
+        return true;
+    }
+    else
+    {
+        wxLogDebug(wxT("ICStart error %d"), (int) err);
+        return false;
+    }
 #elif wxUSE_MIMETYPE
     // Non-windows way
     wxFileType *ft = wxTheMimeTypesManager->GetFileTypeFromExtension (_T("html"));
@@ -954,7 +989,7 @@ wxString wxGetPasswordFromUser(const wxString& message,
 
 #if wxUSE_COLOURDLG
 
-wxColour wxGetColourFromUser(wxWindow *parent, const wxColour& colInit)
+wxColour wxGetColourFromUser(wxWindow *parent, const wxColour& colInit, const wxString& caption)
 {
     wxColourData data;
     data.SetChooseFull(true);
@@ -965,6 +1000,8 @@ wxColour wxGetColourFromUser(wxWindow *parent, const wxColour& colInit)
 
     wxColour colRet;
     wxColourDialog dialog(parent, &data);
+    if (!caption.IsEmpty())
+        dialog.SetTitle(caption);
     if ( dialog.ShowModal() == wxID_OK )
     {
         colRet = dialog.GetColourData().GetColour();
@@ -978,7 +1015,7 @@ wxColour wxGetColourFromUser(wxWindow *parent, const wxColour& colInit)
 
 #if wxUSE_FONTDLG
 
-wxFont wxGetFontFromUser(wxWindow *parent, const wxFont& fontInit)
+wxFont wxGetFontFromUser(wxWindow *parent, const wxFont& fontInit, const wxString& caption)
 {
     wxFontData data;
     if ( fontInit.Ok() )
@@ -988,6 +1025,8 @@ wxFont wxGetFontFromUser(wxWindow *parent, const wxFont& fontInit)
 
     wxFont fontRet;
     wxFontDialog dialog(parent, data);
+    if (!caption.IsEmpty())
+        dialog.SetTitle(caption);
     if ( dialog.ShowModal() == wxID_OK )
     {
         fontRet = dialog.GetFontData().GetChosenFont();
-- 
2.50.0

