]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/stdpaths.h
Don't define __STRICT_ANSI__, we should build both with and without it.
[wxWidgets.git] / include / wx / stdpaths.h
... / ...
CommitLineData
1///////////////////////////////////////////////////////////////////////////////
2// Name: wx/stdpaths.h
3// Purpose: declaration of wxStandardPaths class
4// Author: Vadim Zeitlin
5// Modified by:
6// Created: 2004-10-17
7// Copyright: (c) 2004 Vadim Zeitlin <vadim@wxwindows.org>
8// Licence: wxWindows licence
9///////////////////////////////////////////////////////////////////////////////
10
11#ifndef _WX_STDPATHS_H_
12#define _WX_STDPATHS_H_
13
14#include "wx/defs.h"
15
16#include "wx/string.h"
17#include "wx/filefn.h"
18
19class WXDLLIMPEXP_FWD_BASE wxStandardPaths;
20
21// ----------------------------------------------------------------------------
22// wxStandardPaths returns the standard locations in the file system
23// ----------------------------------------------------------------------------
24
25// NB: This is always compiled in, wxUSE_STDPATHS=0 only disables native
26// wxStandardPaths class, but a minimal version is always available
27class WXDLLIMPEXP_BASE wxStandardPathsBase
28{
29public:
30 // possible resources categories
31 enum ResourceCat
32 {
33 // no special category
34 ResourceCat_None,
35
36 // message catalog resources
37 ResourceCat_Messages,
38
39 // end of enum marker
40 ResourceCat_Max
41 };
42
43 // what should we use to construct paths unique to this application:
44 // (AppInfo_AppName and AppInfo_VendorName can be combined together)
45 enum
46 {
47 AppInfo_None = 0, // nothing
48 AppInfo_AppName = 1, // the application name
49 AppInfo_VendorName = 2 // the vendor name
50 };
51
52
53 // return the global standard paths object
54 static wxStandardPaths& Get();
55
56 // return the path (directory+filename) of the running executable or
57 // wxEmptyString if it couldn't be determined.
58 // The path is returned as an absolute path whenever possible.
59 // Default implementation only try to use wxApp->argv[0].
60 virtual wxString GetExecutablePath() const;
61
62 // return the directory with system config files:
63 // /etc under Unix, c:\Documents and Settings\All Users\Application Data
64 // under Windows, /Library/Preferences for Mac
65 virtual wxString GetConfigDir() const = 0;
66
67 // return the directory for the user config files:
68 // $HOME under Unix, c:\Documents and Settings\username under Windows,
69 // ~/Library/Preferences under Mac
70 //
71 // only use this if you have a single file to put there, otherwise
72 // GetUserDataDir() is more appropriate
73 virtual wxString GetUserConfigDir() const = 0;
74
75 // return the location of the applications global, i.e. not user-specific,
76 // data files
77 //
78 // prefix/share/appname under Unix, c:\Program Files\appname under Windows,
79 // appname.app/Contents/SharedSupport app bundle directory under Mac
80 virtual wxString GetDataDir() const = 0;
81
82 // return the location for application data files which are host-specific
83 //
84 // same as GetDataDir() except under Unix where it is /etc/appname
85 virtual wxString GetLocalDataDir() const;
86
87 // return the directory for the user-dependent application data files
88 //
89 // $HOME/.appname under Unix,
90 // c:\Documents and Settings\username\Application Data\appname under Windows
91 // and ~/Library/Application Support/appname under Mac
92 virtual wxString GetUserDataDir() const = 0;
93
94 // return the directory for user data files which shouldn't be shared with
95 // the other machines
96 //
97 // same as GetUserDataDir() for all platforms except Windows where it is
98 // the "Local Settings\Application Data\appname" directory
99 virtual wxString GetUserLocalDataDir() const;
100
101 // return the directory where the loadable modules (plugins) live
102 //
103 // prefix/lib/appname under Unix, program directory under Windows and
104 // Contents/Plugins app bundle subdirectory under Mac
105 virtual wxString GetPluginsDir() const = 0;
106
107 // get resources directory: resources are auxiliary files used by the
108 // application and include things like image and sound files
109 //
110 // same as GetDataDir() for all platforms except Mac where it returns
111 // Contents/Resources subdirectory of the app bundle
112 virtual wxString GetResourcesDir() const { return GetDataDir(); }
113
114 // get localized resources directory containing the resource files of the
115 // specified category for the given language
116 //
117 // in general this is just GetResourcesDir()/lang under Windows and Unix
118 // and GetResourcesDir()/lang.lproj under Mac but is something quite
119 // different under Unix for message catalog category (namely the standard
120 // prefix/share/locale/lang/LC_MESSAGES)
121 virtual wxString
122 GetLocalizedResourcesDir(const wxString& lang,
123 ResourceCat WXUNUSED(category)
124 = ResourceCat_None) const
125 {
126 return GetResourcesDir() + wxFILE_SEP_PATH + lang;
127 }
128
129 // return the "Documents" directory for the current user
130 //
131 // C:\Documents and Settings\username\My Documents under Windows,
132 // $HOME under Unix and ~/Documents under Mac
133 virtual wxString GetDocumentsDir() const;
134
135 // return the directory for the documents files used by this application:
136 // it's a subdirectory of GetDocumentsDir() constructed using the
137 // application name/vendor if it exists or just GetDocumentsDir() otherwise
138 virtual wxString GetAppDocumentsDir() const;
139
140 // return the temporary directory for the current user
141 virtual wxString GetTempDir() const;
142
143
144 // virtual dtor for the base class
145 virtual ~wxStandardPathsBase();
146
147 // Information used by AppendAppInfo
148 void UseAppInfo(int info)
149 {
150 m_usedAppInfo = info;
151 }
152
153 bool UsesAppInfo(int info) const { return (m_usedAppInfo & info) != 0; }
154
155
156protected:
157 // Ctor is protected as this is a base class which should never be created
158 // directly.
159 wxStandardPathsBase();
160
161 // append the path component, with a leading path separator if a
162 // path separator or dot (.) is not already at the end of dir
163 static wxString AppendPathComponent(const wxString& dir, const wxString& component);
164
165 // append application information determined by m_usedAppInfo to dir
166 wxString AppendAppInfo(const wxString& dir) const;
167
168
169 // combination of AppInfo_XXX flags used by AppendAppInfo()
170 int m_usedAppInfo;
171};
172
173#if wxUSE_STDPATHS
174 #if defined(__WINDOWS__)
175 #include "wx/msw/stdpaths.h"
176 #define wxHAS_NATIVE_STDPATHS
177 // We want CoreFoundation paths on both CarbonLib and Darwin (for all ports)
178 #elif defined(__WXMAC__) || defined(__DARWIN__)
179 #include "wx/osx/core/stdpaths.h"
180 #define wxHAS_NATIVE_STDPATHS
181 #elif defined(__OS2__)
182 #include "wx/os2/stdpaths.h"
183 #define wxHAS_NATIVE_STDPATHS
184 #elif defined(__UNIX__)
185 #include "wx/unix/stdpaths.h"
186 #define wxHAS_NATIVE_STDPATHS
187 #endif
188#endif
189
190// ----------------------------------------------------------------------------
191// Minimal generic implementation
192// ----------------------------------------------------------------------------
193
194// NB: Note that this minimal implementation is compiled in even if
195// wxUSE_STDPATHS=0, so that our code can still use wxStandardPaths.
196
197#ifndef wxHAS_NATIVE_STDPATHS
198class WXDLLIMPEXP_BASE wxStandardPaths : public wxStandardPathsBase
199{
200public:
201 void SetInstallPrefix(const wxString& prefix) { m_prefix = prefix; }
202 wxString GetInstallPrefix() const { return m_prefix; }
203
204 virtual wxString GetExecutablePath() const { return m_prefix; }
205 virtual wxString GetConfigDir() const { return m_prefix; }
206 virtual wxString GetUserConfigDir() const { return m_prefix; }
207 virtual wxString GetDataDir() const { return m_prefix; }
208 virtual wxString GetLocalDataDir() const { return m_prefix; }
209 virtual wxString GetUserDataDir() const { return m_prefix; }
210 virtual wxString GetPluginsDir() const { return m_prefix; }
211 virtual wxString GetDocumentsDir() const { return m_prefix; }
212
213protected:
214 // Ctor is protected because wxStandardPaths::Get() should always be used
215 // to access the global wxStandardPaths object of the correct type instead
216 // of creating one of a possibly wrong type yourself.
217 wxStandardPaths() { }
218
219private:
220 wxString m_prefix;
221};
222#endif // !wxHAS_NATIVE_STDPATHS
223
224#endif // _WX_STDPATHS_H_
225