Moved wxStandardPathsCF into base library when using CarbonLib or Darwin.

Make wxStandardPathsBase::Get() return a wxStandardPathsBase reference.
Implement it using wxAppTraits::GetStandardPaths() which is overridden by
wxMac and wxCocoa GUI libraries to return a reference to a wxStandardPathsCF.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30506 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
David Elliott 2004-11-12 21:21:00 +00:00
parent b7a2ebe671
commit fc480dc16b
11 changed files with 2731 additions and 1388 deletions

File diff suppressed because it is too large Load Diff

View File

@ -257,6 +257,12 @@ dnl ### begin block 1_COND_PLATFORM_MACOSX_1_TOOLKIT_MAC ###
COND_PLATFORM_MACOSX_1_TOOLKIT_MAC=""
fi
AC_SUBST(COND_PLATFORM_MACOSX_1_TOOLKIT_MAC)
dnl ### begin block 1_COND_PLATFORM_MACOSX_1_TOOLKIT_MAC_USE_GUI_1 ###
COND_PLATFORM_MACOSX_1_TOOLKIT_MAC_USE_GUI_1="#"
if test "x$PLATFORM_MACOSX" = "x1" -a "x$TOOLKIT" = "xMAC" -a "x$USE_GUI" = "x1" ; then
COND_PLATFORM_MACOSX_1_TOOLKIT_MAC_USE_GUI_1=""
fi
AC_SUBST(COND_PLATFORM_MACOSX_1_TOOLKIT_MAC_USE_GUI_1)
dnl ### begin block 1_COND_PLATFORM_MACOSX_1_TOOLKIT_MOTIF ###
COND_PLATFORM_MACOSX_1_TOOLKIT_MOTIF="#"
if test "x$PLATFORM_MACOSX" = "x1" -a "x$TOOLKIT" = "xMOTIF" ; then

View File

@ -43,6 +43,9 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
<!-- wxBase -->
<!-- ====================================================================== -->
<!-- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -->
<!-- UNIX -->
<!-- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -->
<set var="BASE_UNIX_SRC" hints="files">
src/unix/baseunix.cpp
src/unix/dir.cpp
@ -63,6 +66,9 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
wx/unix/stdpaths.h
</set>
<!-- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -->
<!-- Windows -->
<!-- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -->
<set var="BASE_WIN32_SRC" hints="files">
src/msw/basemsw.cpp
src/msw/crashrpt.cpp
@ -101,6 +107,20 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
<if cond="TOOLKIT=='WINCE'">wx/msw/wince/time.h</if>
</set>
<!-- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -->
<!-- Mac -->
<!-- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -->
<!-- Used on Mac OS CarbonLib, Mac OS X wxMac base, and Mac OS X darwin base -->
<set var="BASE_COREFOUNDATION_SRC" hints="files">
src/mac/corefoundation/cfstring.cpp
src/mac/corefoundation/stdpaths_cf.cpp
</set>
<set var="BASE_COREFOUNDATION_HDR" hints="files">
wx/mac/corefoundation/cfstring.h
wx/mac/corefoundation/stdpaths.h
</set>
<!-- Base files used by Carbon on OS X and CarbonLib (not true Classic) -->
<!-- FIXME: Maybe this ought to be named BASE_MAC_CARBON_SRC -->
<set var="BASE_MAC_SRC" hints="files">
@ -112,14 +132,22 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
<!-- One would think MoreFilesX is only for OS X but it seems to
apply to CarbonLib as well (FSRefMakeFSSpec) -->
src/mac/carbon/morefilex/MoreFilesX.c
<!-- Shared wxMac and wxCocoa files -->
src/mac/corefoundation/cfstring.cpp
src/mac/corefoundation/stdpaths_cf.cpp
$(BASE_COREFOUNDATION_SRC)
</set>
<set var="BASE_MAC_HDR" hints="files">
$(BASE_COREFOUNDATION_HDR)
</set>
<!-- Base and GUI files used by both OS X and CarbonLib -->
<set var="BASE_AND_GUI_MAC_SRC" hints="files">
src/mac/carbon/utils.cpp
src/mac/carbon/uma.cpp
</set>
<!-- Base files used by Classic (not CarbonLib or OS X builds) -->
<!-- set var="BASE_MAC_CLASSIC_SRC">
</set -->
<!-- set var="BASE_MAC_CLASSIC_HDR">
</set -->
<!-- Base files used only by CarbonLib builds (not Classic or OS X) -->
<set var="BASE_MAC_CARBONLIB_SRC" hints="files">
@ -133,24 +161,31 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
src/mac/carbon/morefile/MoreFilesExtras.c
src/mac/carbon/morefile/Search.c
</set>
<!-- set var="BASE_MAC_CARBONLIB_HDR" hints="files">
</set -->
<!-- Base files used only by OS X builds (not CarbonLib or Classic) -->
<set var="BASE_MAC_OSX_SRC" hints="files">
src/unix/baseunix.cpp
src/unix/stdpaths.cpp
</set>
<set var="BASE_MAC_OSX_HDR" hints="files">
wx/unix/stdpaths.h
</set>
<!-- Base and GUI files used by both OS X and CarbonLib -->
<set var="BASE_AND_GUI_MAC_SRC" hints="files">
src/mac/carbon/utils.cpp
src/mac/carbon/uma.cpp
</set>
<set var="BASE_MAC_HDR" hints="files">
<!-- Shared wxMac and wxCocoa files -->
wx/mac/corefoundation/cfstring.h
wx/mac/corefoundation/stdpaths.h
<!-- Base files used by non-wxMac OS X builds -->
<set var="BASE_DARWIN_SRC" hints="files">
$(BASE_UNIX_SRC)
$(BASE_COREFOUNDATION_SRC)
</set>
<set var="BASE_DARWIN_HDR" hints="files">
$(BASE_UNIX_HDR)
$(BASE_COREFOUNDATION_HDR)
</set>
<!-- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -->
<!-- OS/2 -->
<!-- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -->
<set var="BASE_OS2_SRC" hints="files">
src/os2/dir.cpp
src/os2/mimetype.cpp
@ -168,6 +203,9 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
wx/os2/stdpaths.h
</set>
<!-- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -->
<!-- Common -->
<!-- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -->
<set var="BASE_CMN_SRC" hints="files">
src/common/appbase.cpp
src/common/clntdata.cpp
@ -1612,10 +1650,18 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
<!-- wxMac -->
<!-- ====================================================================== -->
<set var="MAC_OSX_LOWLEVEL_SRC" hints="files">
<!-- Shared wxMac and wxCocoa files -->
src/mac/corefoundation/gsockosx.cpp
src/mac/corefoundation/utilsexc_cf.cpp
</set>
<set var="MAC_LOWLEVEL_SRC" hints="files">
<if cond="PLATFORM_MACOSX=='1'">$(MAC_OSX_LOWLEVEL_SRC)</if>
</set>
<set var="MAC_LOWLEVEL_HDR" hints="files">
</set>
<set var="MAC_SRC" hints="files">
src/mac/carbon/accel.cpp
src/mac/carbon/aga.cpp
@ -1703,11 +1749,6 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
<!-- wxWebKit files -->
src/html/htmlctrl/webkit/webkit.mm
</set>
<set var="MAC_OSX_SRC" hints="files">
<!-- Shared wxMac and wxCocoa files -->
src/mac/corefoundation/gsockosx.cpp
src/mac/corefoundation/utilsexc_cf.cpp
</set>
<!-- Header files like wx/mac/foo.h which include wx/mac/carbon/foo.h -->
<set var="MAC_CMN_HDR" hints="files">
@ -1896,6 +1937,9 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
<!-- ====================================================================== -->
<set var="COCOA_LOWLEVEL_SRC" hints="files">
<!-- Shared wxMac and wxCocoa files -->
src/mac/corefoundation/gsockosx.cpp
src/mac/corefoundation/utilsexc_cf.cpp
</set>
<set var="COCOA_LOWLEVEL_HDR" hints="files">
</set>
@ -1988,11 +2032,6 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
src/generic/statusbr.cpp
src/generic/tabg.cpp
src/generic/timer.cpp
<!-- Shared wxMac and wxCocoa files -->
src/mac/corefoundation/cfstring.cpp
src/mac/corefoundation/gsockosx.cpp
src/mac/corefoundation/stdpaths_cf.cpp
src/mac/corefoundation/utilsexc_cf.cpp
</set>
<set var="COCOA_HDR" hints="files">
wx/cocoa/NSApplication.h
@ -2076,9 +2115,6 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
wx/generic/region.h
wx/generic/statusbr.h
wx/generic/tabg.h
<!-- Shared wxMac and wxCocoa files -->
wx/mac/corefoundation/cfstring.h
wx/mac/corefoundation/stdpaths.h
</set>
@ -2584,15 +2620,15 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
<!-- These are the files for PLATFORM_MACOSX -->
<set var="BASE_MACOSX_SRC" hints="files">
<if cond="TOOLKIT=='MAC'">$(BASE_MAC_SRC) $(BASE_MAC_OSX_SRC)</if>
<if cond="TOOLKIT=='COCOA'">$(BASE_UNIX_SRC)</if>
<if cond="TOOLKIT=='GTK'">$(BASE_UNIX_SRC)</if>
<if cond="TOOLKIT=='X11'">$(BASE_UNIX_SRC)</if>
<if cond="TOOLKIT=='MOTIF'">$(BASE_UNIX_SRC)</if>
<if cond="TOOLKIT=='COCOA'">$(BASE_DARWIN_SRC)</if>
<if cond="TOOLKIT=='GTK'">$(BASE_DARWIN_SRC)</if>
<if cond="TOOLKIT=='X11'">$(BASE_DARWIN_SRC)</if>
<if cond="TOOLKIT=='MOTIF'">$(BASE_DARWIN_SRC)</if>
<!-- FIXME: TOOLKIT!='MAC' is what we really want -->
<!-- FIXME: a hack because there are two wxBase versions on
Mac; once fixed, this would no longer be needed -->
<if cond="TOOLKIT==''">$(BASE_UNIX_SRC)</if>
<if cond="TOOLKIT==''">$(BASE_DARWIN_SRC)</if>
</set>
<set var="BASE_PLATFORM_SRC" hints="files">
<if cond="PLATFORM_UNIX=='1'">$(BASE_UNIX_SRC)</if>
@ -2614,7 +2650,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
<set var="BASE_PLATFORM_HDR" hints="files">
<if cond="PLATFORM_UNIX=='1'">$(BASE_UNIX_HDR)</if>
<if cond="PLATFORM_WIN32=='1'">$(BASE_WIN32_HDR) $(BASE_WINCE_HDR)</if>
<if cond="TOOLKIT=='MAC'">$(BASE_MAC_HDR)</if>
<if cond="TOOLKIT=='MAC'">$(BASE_MAC_HDR) $(BASE_MAC_OSX_HDR)</if>
<if cond="TOOLKIT=='COCOA'">$(BASE_UNIX_HDR)</if>
</set>
@ -2678,7 +2714,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
<if cond="TOOLKIT=='MOTIF'">$(MOTIF_SRC)</if>
<if cond="TOOLKIT=='MSW'">$(MSW_SRC) $(MSW_ONLY_SRC)</if>
<if cond="TOOLKIT=='WINCE'">$(MSW_SRC) $(WINCE_SRC)</if>
<if cond="TOOLKIT=='MAC'">$(MAC_SRC) $(MAC_OSX_SRC)</if>
<if cond="TOOLKIT=='MAC'">$(MAC_SRC)</if>
<if cond="TOOLKIT=='COCOA'">$(COCOA_SRC)</if>
<if cond="TOOLKIT=='PM'">$(OS2_SRC)</if>
</set>

852
configure vendored

File diff suppressed because one or more lines are too long

View File

@ -49,6 +49,8 @@ struct WXDLLIMPEXP_BASE wxToolkitInfo
// wxAppTraits: this class defines various configurable aspects of wxApp
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_BASE wxStandardPathsBase;
class WXDLLIMPEXP_BASE wxAppTraitsBase
{
public:
@ -75,6 +77,9 @@ public:
// NB: returned pointer will be deleted by the caller
virtual wxRendererNative *CreateRenderer() = 0;
// wxStandardPaths object is normally the same for wxBase and wxGUI
// except in the case of wxMac and wxCocoa
virtual wxStandardPathsBase& GetStandardPaths();
// functions abstracting differences between GUI and console modes
// ------------------------------------------------------------------------

View File

@ -24,10 +24,6 @@ public:
wxStandardPathsCF();
~wxStandardPathsCF();
// return the global standard paths object
// Overrides wxStandardPathsBase version for GUI code.
static wxStandardPathsCF& Get();
// wxMac specific: allow user to specify a different bundle
wxStandardPathsCF(struct __CFBundle *bundle);
void SetBundle(struct __CFBundle *bundle);
@ -43,13 +39,14 @@ protected:
struct __CFBundle *m_bundle;
};
// wxMac has its own base so it always uses this version.
// Otherwise, we want to use this version only when compiling GUI code.
// The CoreFoundation version is always available by its full name to all code.
#if defined(__WXMAC__) || wxUSE_BASE == 0
#define wxStandardPaths wxStandardPathsCF
#else
// If using UNIX (i.e. darwin) then use UNIX standard paths
#if defined(__UNIX__)
#include "wx/unix/stdpaths.h"
#else
// If compiling wxMac for CarbonLib then we are wxStandardPaths
class WXDLLIMPEXP_BASE wxStandardPaths: public wxStandardPathsCF
{
};
#endif
#endif // _WX_MAC_STDPATHS_H_

View File

@ -14,13 +14,6 @@
#include "wx/string.h"
#if defined(__WXMAC__)
class WXDLLIMPEXP_BASE wxStandardPathsCF;
#define wxStandardPaths wxStandardPathsCF
#else
class WXDLLIMPEXP_BASE wxStandardPaths;
#endif
// ----------------------------------------------------------------------------
// wxStandardPaths returns the standard locations in the file system
// ----------------------------------------------------------------------------
@ -29,7 +22,7 @@ class WXDLLIMPEXP_BASE wxStandardPathsBase
{
public:
// return the global standard paths object
static wxStandardPaths& Get();
static wxStandardPathsBase& Get();
// return the directory with system config files:
@ -89,7 +82,8 @@ protected:
#if defined(__WXMSW__)
#include "wx/msw/stdpaths.h"
#elif defined(__WXMAC__) || defined(__WXCOCOA__)
// We want CoreFoundation paths on both CarbonLib and Darwin (for all ports)
#elif defined(__WXMAC__) || defined(__DARWIN__)
#include "wx/mac/corefoundation/stdpaths.h"
#elif defined(__OS2__)
#include "wx/os2/stdpaths.h"

View File

@ -37,6 +37,9 @@ public:
virtual void DetachWriteFDOfEndProcessPipe(wxExecuteData& execData);
virtual int WaitForChild(wxExecuteData& execData);
#if defined(__WXMAC__) || defined(__WXCOCOA__)
virtual wxStandardPathsBase& GetStandardPaths();
#endif
virtual wxToolkitInfo& GetToolkitInfo();
};

View File

@ -27,6 +27,7 @@
#ifndef WX_PRECOMP
#include "wx/app.h"
#endif //WX_PRECOMP
#include "wx/apptrait.h"
#include "wx/filename.h"
#include "wx/stdpaths.h"
@ -42,7 +43,12 @@ static wxStandardPaths gs_stdPaths;
// ============================================================================
/* static */
wxStandardPaths& wxStandardPathsBase::Get()
wxStandardPathsBase& wxStandardPathsBase::Get()
{
return wxTheApp->GetTraits()->GetStandardPaths();
}
wxStandardPathsBase& wxAppTraitsBase::GetStandardPaths()
{
return gs_stdPaths;
}

View File

@ -26,11 +26,6 @@
#include <CFURL.h>
#endif
// See comment in include/wx/mac/corefoundation/stdpaths.h
#ifndef wxStandardPaths
#warning "wxStandardPaths should be defined to wxStandardPathsCF when compiling this file."
#endif
#if defined(__WXCOCOA__) || defined(__WXMAC_OSX__)
#define kDefaultPathStyle kCFURLPOSIXPathStyle
#else
@ -46,50 +41,43 @@ static wxString BundleRelativeURLToPath(CFURLRef relativeURL)
return wxMacCFStringHolder(cfStrPath).AsString(wxLocale::GetSystemEncoding());
}
static wxStandardPaths gs_stdPaths;
/* static */ wxStandardPaths& wxStandardPaths::Get()
{
return gs_stdPaths;
}
wxStandardPaths::wxStandardPaths()
wxStandardPathsCF::wxStandardPathsCF()
: m_bundle(CFBundleGetMainBundle())
{
CFRetain(m_bundle);
}
wxStandardPaths::wxStandardPaths(struct __CFBundle *bundle)
wxStandardPathsCF::wxStandardPathsCF(struct __CFBundle *bundle)
: m_bundle(bundle)
{
CFRetain(m_bundle);
}
wxStandardPaths::~wxStandardPaths()
wxStandardPathsCF::~wxStandardPathsCF()
{
CFRelease(m_bundle);
}
void wxStandardPaths::SetBundle(struct __CFBundle *bundle)
void wxStandardPathsCF::SetBundle(struct __CFBundle *bundle)
{
CFRetain(bundle);
CFRelease(m_bundle);
m_bundle = bundle;
}
wxString wxStandardPaths::GetConfigDir() const
wxString wxStandardPathsCF::GetConfigDir() const
{
// TODO: What do we do for pure Carbon?
return wxT("/Library/Preferences");
}
wxString wxStandardPaths::GetUserConfigDir() const
wxString wxStandardPathsCF::GetUserConfigDir() const
{
// TODO: What do we do for pure Carbon?
return wxFileName::GetHomeDir() + wxT("/Library/Preferences");
}
wxString wxStandardPaths::GetDataDir() const
wxString wxStandardPathsCF::GetDataDir() const
{
wxCHECK_MSG(m_bundle, wxEmptyString, wxT("wxStandardPaths for CoreFoundation only works with bundled apps"));
CFURLRef relativeURL = CFBundleCopySharedSupportURL(m_bundle);
@ -99,17 +87,17 @@ wxString wxStandardPaths::GetDataDir() const
return ret;
}
wxString wxStandardPaths::GetLocalDataDir() const
wxString wxStandardPathsCF::GetLocalDataDir() const
{
return AppendAppName(wxT("/Library/Application Support"));
}
wxString wxStandardPaths::GetUserDataDir() const
wxString wxStandardPathsCF::GetUserDataDir() const
{
return AppendAppName(wxFileName::GetHomeDir() + _T("/Library/Application Support"));
}
wxString wxStandardPaths::GetPluginsDir() const
wxString wxStandardPathsCF::GetPluginsDir() const
{
wxCHECK_MSG(m_bundle, wxEmptyString, wxT("wxStandardPaths for CoreFoundation only works with bundled apps"));
CFURLRef relativeURL = CFBundleCopyBuiltInPlugInsURL(m_bundle);

View File

@ -16,6 +16,8 @@
#include "wx/utils.h"
#endif //ndef WX_PRECOMP
#include "wx/unix/execute.h"
#include "wx/stdpaths.h"
#include "wx/apptrait.h"
#include <CoreFoundation/CFMachPort.h>
#include <sys/wait.h>
@ -109,3 +111,11 @@ int wxAddProcessCallbackForPid(wxEndProcessData *proc_data, int pid)
return 0;
}
// NOTE: This doens't really belong here but this was a handy file to
// put it in because it's already compiled for wxCocoa and wxMac GUI lib.
static wxStandardPathsCF gs_stdPaths;
wxStandardPathsBase& wxGUIAppTraits::GetStandardPaths()
{
return gs_stdPaths;
}