Code::Blocks  SVN r11506
globals.h
Go to the documentation of this file.
1 /*
2  * This file is part of the Code::Blocks IDE and licensed under the GNU Lesser General Public License, version 3
3  * http://www.gnu.org/licenses/lgpl-3.0.html
4  */
5 
6 #ifndef SDK_GLOBALS_H
7 #define SDK_GLOBALS_H
8 
9 #include <vector>
10 
11 #include <wx/string.h>
12 #include <wx/treectrl.h>
13 #include <wx/file.h>
14 #include <wx/filename.h>
15 #include <wx/intl.h>
16 #include <wx/msgdlg.h>
17 #include <wx/bitmap.h>
18 
19 #include "settings.h"
20 
21 class TiXmlDocument;
22 
25 {
26  ptNone = 1,
35 };
36 
39 {
46 };
47 
50 {
75 };
76 
82 {
83  // The following are related to (editable, source-) file states
84  fvsNormal = 0,
88  // The following are related to version control systems (vc)
101  // The following are related to C::B workspace/project/folder/virtual
108 
111 };
112 
114 {
115  public:
116  static wxImageList* MakeImageList();
117 
121  static int WorkspaceIconIndex(bool read_only = false);
125  static int ProjectIconIndex(bool read_only = false);
127  static int FolderIconIndex();
129  static int VirtualFolderIconIndex();
130 };
131 
136 {
137  ptvsNone = 0x00,
138  ptvsCategorize = 0x01,
139  ptvsUseFolders = 0x02,
141  ptvsDefault = 0x03
142 };
143 
146 {
152 };
153 
156 {
157  spMac = 0x01,
158  spUnix = 0x02,
159  spWindows = 0x04,
160 
161  spAll = 0xff
162 };
163 // NOTE: if you add/remove platforms, remember to update the relevant Get/Set globals
164 
166 #define HL_AUTO _T(" ")
167 #define HL_NONE _T(" ")
168 
174 
175 // global helper funcs
177 extern DLLIMPORT bool cbRead(wxFile& file, wxString& st, wxFontEncoding encoding = wxFONTENCODING_SYSTEM);
179 extern DLLIMPORT wxString cbReadFileContents(wxFile& file, wxFontEncoding encoding = wxFONTENCODING_SYSTEM);
181 extern DLLIMPORT bool cbWrite(wxFile& file, const wxString& buff, wxFontEncoding encoding = wxFONTENCODING_SYSTEM);
184 extern DLLIMPORT bool cbSaveToFile(const wxString& filename, const wxString& contents, wxFontEncoding encoding = wxFONTENCODING_SYSTEM, bool bom = false);
186 extern DLLIMPORT bool cbSaveTinyXMLDocument(TiXmlDocument* doc, const wxString& filename);
188 extern DLLIMPORT wxString cbC2U(const char* str);
190 extern DLLIMPORT const wxWX2MBbuf cbU2C(const wxString& str);
195 extern DLLIMPORT wxFontEncoding DetectEncodingAndConvert(const char* strIn, wxString& strOut, wxFontEncoding possibleEncoding = wxFONTENCODING_SYSTEM);
196 
198 extern DLLIMPORT int GetPlatformsFromString(const wxString& platforms);
200 extern DLLIMPORT wxString GetStringFromPlatforms(int platforms, bool forceSeparate = false);
201 
202 // see globals.cpp for info on the third argument (bool SeparatorAtEnd)
203 extern DLLIMPORT wxString GetStringFromArray(const wxArrayString& array, const wxString& separator = DEFAULT_ARRAY_SEP, bool SeparatorAtEnd = true);
204 extern DLLIMPORT wxArrayString GetArrayFromString(const wxString& text, const wxString& separator = DEFAULT_ARRAY_SEP, bool trimSpaces = true);
205 typedef std::vector<wxString> wxStringVec;
206 extern DLLIMPORT wxStringVec GetVectorFromString(const wxString& text,
207  const wxString& separator = DEFAULT_ARRAY_SEP,
208  bool trimSpaces = true);
209 extern DLLIMPORT wxArrayString MakeUniqueArray(const wxArrayString& array, bool caseSens);
210 extern DLLIMPORT wxString MakeUniqueString(const wxString& text, const wxString& separator = DEFAULT_ARRAY_SEP, bool caseSens = true);
211 extern DLLIMPORT void AppendArray(const wxArrayString& from, wxArrayString& to);
212 
213 extern DLLIMPORT wxString UnixFilename(const wxString& filename, wxPathFormat format = wxPATH_NATIVE);
214 extern DLLIMPORT void QuoteStringIfNeeded(wxString& str);
215 extern DLLIMPORT bool NeedQuotes(const wxString &str);
216 
218 extern DLLIMPORT wxString EscapeSpaces(const wxString& str);
219 
220 extern DLLIMPORT FileType FileTypeOf(const wxString& filename);
221 extern DLLIMPORT wxString cbFindFileInPATH(const wxString &filename);
222 
223 extern DLLIMPORT void SaveTreeState(wxTreeCtrl* tree, const wxTreeItemId& parent, wxArrayString& nodePaths, wxArrayString& selectedItemPaths);
224 extern DLLIMPORT void RestoreTreeState(wxTreeCtrl* tree, const wxTreeItemId& parent, wxArrayString& nodePaths, wxArrayString& selectedItemPaths);
225 
226 extern DLLIMPORT bool CreateDirRecursively(const wxString& full_path, int perms = 0755);
227 extern DLLIMPORT bool CreateDir(const wxString& full_path, int perms = 0755);
229  const wxString& message = _("Select directory"),
230  const wxString& initialPath = _T(""),
231  const wxString& basePath = _T(""),
232  bool askToMakeRelative = false, // relative to basePath
233  bool showCreateDirButton = false); // where supported
234 
235 extern DLLIMPORT bool NormalizePath(wxFileName& f,const wxString& base);
236 extern DLLIMPORT bool IsSuffixOfPath(wxFileName const & suffix, wxFileName const & path);
237 
243 extern DLLIMPORT bool cbResolveSymLinkedDirPath(wxString& dirpath);
249 
254 extern DLLIMPORT wxString GetEOLStr(int eolMode = -1);
255 
256 extern DLLIMPORT wxString URLEncode(const wxString &str);
257 
259 
269 extern DLLIMPORT wxMenu* CopyMenu(wxMenu* mnu, bool with_accelerators = false);
270 
272 extern DLLIMPORT bool UsesCommonControls6();
273 
278 extern DLLIMPORT wxBitmap cbLoadBitmap(const wxString& filename, wxBitmapType bitmapType = wxBITMAP_TYPE_PNG);
279 
280 // compatibility function
281 inline wxBitmap LoadPNGWindows2000Hack(const wxString& filename){ return cbLoadBitmap(filename); }
282 
293 extern DLLIMPORT bool IsWindowReallyShown(wxWindow* win);
294 
298 {
301 };
302 
303 class wxListCtrl;
304 
319 
320 class wxWindow;
321 
323 {
324  pdlDont = 0,
330 };
331 
332 extern DLLIMPORT void PlaceWindow(wxTopLevelWindow *w, cbPlaceDialogMode mode = pdlBest, bool enforce = false);
333 
336 
343 extern DLLIMPORT int cbMessageBox(const wxString& message, const wxString& caption = wxEmptyString, int style = wxOK, wxWindow *parent = NULL, int x = -1, int y = -1);
344 
345 extern DLLIMPORT int cbGetSingleChoiceIndex(const wxString& message, const wxString& caption,
346  const wxArrayString& choices, wxWindow *parent = NULL,
347  const wxSize &size = wxSize(300, 300),
348  int initialSelection = 0);
349 
354 extern DLLIMPORT wxArrayInt cbGetMultiChoiceDialog(const wxString& message, const wxString& caption,
355  const wxArrayString& choices, wxWindow *parent = nullptr,
356  const wxSize& size = wxSize(300, 300),
357  const wxArrayInt& initialSelection = wxArrayInt());
358 
359 #if wxCHECK_VERSION(3, 0, 0)
360 extern DLLIMPORT const char *cbGetTextFromUserPromptStr;
361 #else
363 #endif // wxCHECK_VERSION
364 
365 extern DLLIMPORT wxString cbGetTextFromUser(const wxString &message,
366  const wxString &caption = cbGetTextFromUserPromptStr,
367  const wxString &default_value = wxEmptyString, wxWindow *parent = NULL,
368  int x = wxDefaultCoord, int y = wxDefaultCoord, bool centre = true);
369 
370 inline void NotifyMissingFile(const wxString &name)
371 {
372  wxString msg;
373  msg.Printf(_T("The file %s could not be found.\nPlease check your installation."), name.c_str());
374  cbMessageBox(msg);
375 }
376 
379 {
383 };
384 
392 
393 namespace platform
394 {
395  typedef enum
396  {
406 
407  extern DLLIMPORT windows_version_t WindowsVersion();
408 }
409 
410 // returns the real path of a file by resolving symlinks
411 // not yet optimal but should do for now
412 // one thing that's not checked yet are circular symlinks - watch out!
413 extern DLLIMPORT wxString realpath(const wxString& path);
414 
415 #endif // SDK_GLOBALS_H
FileVisualState
These are valid values for the state of each project file.
Definition: globals.h:81
DLLIMPORT wxArrayString GetArrayFromString(const wxString &text, const wxString &separator=DEFAULT_ARRAY_SEP, bool trimSpaces=true)
Definition: globals.cpp:134
DLLIMPORT wxStringVec GetVectorFromString(const wxString &text, const wxString &separator=DEFAULT_ARRAY_SEP, bool trimSpaces=true)
Definition: globals.cpp:166
DLLIMPORT bool NeedQuotes(const wxString &str)
Definition: globals.cpp:266
Just here for convenience, "categorise" + "use folders" ON.
Definition: globals.h:141
Definition: globals.h:27
Large icons (default)
Definition: globals.h:299
DLLIMPORT wxString cbFindFileInPATH(const wxString &filename)
Definition: globals.cpp:420
wxBitmap LoadPNGWindows2000Hack(const wxString &filename)
Definition: globals.h:281
Current user has read-write access to the directory.
Definition: globals.h:381
DLLIMPORT windows_version_t WindowsVersion()
Definition: globals.cpp:1338
SettingsIconsStyle
Icons styles for settings dialogs.
Definition: globals.h:297
DLLIMPORT const wxString DEFAULT_CONSOLE_TERM
Definition: globals.cpp:59
DLLIMPORT bool cbResolveSymLinkedDirPath(wxString &dirpath)
If path is pointing to a symlink then the function will set dirpath parameter to the path the symlink...
Definition: globals.cpp:1001
DLLIMPORT const wxString cbDEFAULT_OPEN_FOLDER_CMD
Definition: globals.cpp:66
DLLIMPORT wxString GetStringFromPlatforms(int platforms, bool forceSeparate=false)
Return a string representation of a platform / multiple platforms.
Definition: globals.cpp:90
DLLIMPORT wxFontEncoding DetectEncodingAndConvert(const char *strIn, wxString &strOut, wxFontEncoding possibleEncoding=wxFONTENCODING_SYSTEM)
Try converting a C-string from different encodings until a possible match is found.
Definition: globals.cpp:754
Invalid directory (does not exist).
Definition: globals.h:380
DLLIMPORT wxBitmap cbLoadBitmap(const wxString &filename, wxBitmapType bitmapType=wxBITMAP_TYPE_PNG)
This function loads a bitmap from disk.
Definition: globals.cpp:1102
DLLIMPORT wxString cbGetTextFromUser(const wxString &message, const wxString &caption=cbGetTextFromUserPromptStr, const wxString &default_value=wxEmptyString, wxWindow *parent=NULL, int x=wxDefaultCoord, int y=wxDefaultCoord, bool centre=true)
Definition: globals.cpp:1465
DLLIMPORT SettingsIconsStyle GetSettingsIconsStyle(wxListCtrl *lc)
Get the icons style set in environment-dialog.
DLLIMPORT wxRect cbGetMonitorRectForWindow(wxWindow *window)
Definition: globals.cpp:1153
DLLIMPORT wxString ChooseDirectory(wxWindow *parent, const wxString &message=_("Select directory"), const wxString &initialPath=_T(""), const wxString &basePath=_T(""), bool askToMakeRelative=false, bool showCreateDirButton=false)
Definition: globals.cpp:639
Definition: globals.h:157
DLLIMPORT bool NormalizePath(wxFileName &f, const wxString &base)
Definition: globals.cpp:942
windows_version_t
Definition: globals.h:395
wxBitmapType
wxCStrData c_str() const
DLLIMPORT int cbGetSingleChoiceIndex(const wxString &message, const wxString &caption, const wxArrayString &choices, wxWindow *parent=NULL, const wxSize &size=wxSize(300, 300), int initialSelection=0)
Definition: globals.cpp:1427
#define _T(string)
FileType
Known file types.
Definition: globals.h:49
DLLIMPORT wxString URLEncode(const wxString &str)
Definition: globals.cpp:832
The default style: All "off".
Definition: globals.h:137
DLLIMPORT wxString GetStringFromArray(const wxArrayString &array, const wxString &separator=DEFAULT_ARRAY_SEP, bool SeparatorAtEnd=true)
Definition: globals.cpp:122
DLLIMPORT FileType FileTypeOf(const wxString &filename)
Definition: globals.cpp:285
Definition: globals.h:26
std::vector< wxString > wxStringVec
Definition: globals.h:205
wxFontEncoding
void NotifyMissingFile(const wxString &name)
Definition: globals.h:370
DLLIMPORT DirAccessCheck cbDirAccessCheck(const wxString &dir)
Check what access the current user has in a directory.
Definition: globals.cpp:1271
wxString HighlightLanguage
Definition: globals.h:165
DLLIMPORT const wxWX2MBbuf cbU2C(const wxString &str)
Return multibyte (C string) representation of the string.
Definition: globals.cpp:743
template produces custom output (entirely up to the wizard used)
Definition: globals.h:150
#define DLLIMPORT
Definition: settings.h:16
No icons, just text.
Definition: globals.h:300
If true, create folders as needed. If false, the list is flat (not compatible with "hie folder name")...
Definition: globals.h:139
wxUSE_UNICODE_dependent wxChar
PluginType
Known plugin types.
Definition: globals.h:24
DLLIMPORT wxString cbReadFileContents(wxFile &file, wxFontEncoding encoding=wxFONTENCODING_SYSTEM)
Reads a wxString from a non-unicode file. File must be open. File is closed automatically.
Definition: globals.cpp:697
DLLIMPORT bool UsesCommonControls6()
Check if CommonControls version is at least 6 (XP and up)
Definition: globals.cpp:1065
DLLIMPORT wxString UnixFilename(const wxString &filename, wxPathFormat format=wxPATH_NATIVE)
Definition: globals.cpp:228
If true, the folder name will be hidden and only the file name will be shown (not compatible with "us...
Definition: globals.h:140
DLLIMPORT const char * cbGetTextFromUserPromptStr
Definition: globals.cpp:1460
DLLIMPORT wxMenu * CopyMenu(wxMenu *mnu, bool with_accelerators=false)
This function creates a new wxMenu object on the heap and recursively copies a given menu into it...
Definition: globals.cpp:911
template outputs a new file (or files)
Definition: globals.h:149
DLLIMPORT const wxString DEFAULT_CONSOLE_SHELL
Definition: globals.cpp:63
ModuleType
The type of module offering a context menu.
Definition: globals.h:38
DLLIMPORT wxString cbC2U(const char *str)
Return str as a proper unicode-compatible string.
Definition: globals.cpp:733
DLLIMPORT bool CreateDir(const wxString &full_path, int perms=0755)
Definition: globals.cpp:631
wxPathFormat
DLLIMPORT bool IsSuffixOfPath(wxFileName const &suffix, wxFileName const &path)
Definition: globals.cpp:962
DirAccessCheck
Result values of cbDirAccessCheck()
Definition: globals.h:378
DLLIMPORT wxString cbResolveSymLinkedDirPathRecursive(wxString dirpath)
Call cbResolveSymLinkedPath until the path is not a symlink.
Definition: globals.cpp:1054
DLLIMPORT bool IsWindowReallyShown(wxWindow *win)
Finds out if a window is really shown.
Definition: globals.cpp:931
do not use this, it exists just to know the number of items...
Definition: globals.h:110
SupportedPlatforms
Supported platforms.
Definition: globals.h:155
DLLIMPORT wxArrayInt cbGetMultiChoiceDialog(const wxString &message, const wxString &caption, const wxArrayString &choices, wxWindow *parent=nullptr, const wxSize &size=wxSize(300, 300), const wxArrayInt &initialSelection=wxArrayInt())
wxMultiChoiceDialog wrapper.
Definition: globals.cpp:1441
DLLIMPORT bool cbWrite(wxFile &file, const wxString &buff, wxFontEncoding encoding=wxFONTENCODING_SYSTEM)
Writes a wxString to a non-unicode file. File must be open. File is closed automatically.
Definition: globals.cpp:705
DLLIMPORT wxArrayString MakeUniqueArray(const wxArrayString &array, bool caseSens)
Definition: globals.cpp:198
const wxString & _(const wxString &string)
DLLIMPORT void QuoteStringIfNeeded(wxString &str)
Definition: globals.cpp:260
TemplateOutputType
Template output types.
Definition: globals.h:145
wxArray< int > wxArrayInt
DLLIMPORT const wxString DEFAULT_ARRAY_SEP
Definition: globals.cpp:56
DLLIMPORT void SaveTreeState(wxTreeCtrl *tree, const wxTreeItemId &parent, wxArrayString &nodePaths, wxArrayString &selectedItemPaths)
Definition: globals.cpp:575
DLLIMPORT void PlaceWindow(wxTopLevelWindow *w, cbPlaceDialogMode mode=pdlBest, bool enforce=false)
Definition: globals.cpp:1177
DLLIMPORT void AppendArray(const wxArrayString &from, wxArrayString &to)
Definition: globals.cpp:222
DLLIMPORT wxString GetEOLStr(int eolMode=-1)
Reads settings if eolMode is -1 Expected input (defined in sdk/wxscintilla/include/wx/wxscintilla.h) is: wxSCI_EOL_CRLF=0, wxSCI_EOL_CR=1, or wxSCI_EOL_LF=2.
Definition: globals.cpp:812
cbPlaceDialogMode
Definition: globals.h:322
DLLIMPORT bool cbRead(wxFile &file, wxString &st, wxFontEncoding encoding=wxFONTENCODING_SYSTEM)
Reads a wxString from a non-unicode file. File must be open. File is closed automatically.
Definition: globals.cpp:668
DLLIMPORT const wxString DEFAULT_WORKSPACE
Definition: globals.cpp:55
template adds a new target in a project
Definition: globals.h:148
DLLIMPORT void SetSettingsIconsStyle(wxListCtrl *lc, SettingsIconsStyle style)
Set the icons style for the supplied list control.
Definition: globals.cpp:1125
DLLIMPORT bool cbSaveToFile(const wxString &filename, const wxString &contents, wxFontEncoding encoding=wxFONTENCODING_SYSTEM, bool bom=false)
Writes a wxString to a file.
Definition: globals.cpp:721
DLLIMPORT wxString MakeUniqueString(const wxString &text, const wxString &separator=DEFAULT_ARRAY_SEP, bool caseSens=true)
Definition: globals.cpp:217
template is a user-saved project template
Definition: globals.h:151
template outputs a new project
Definition: globals.h:147
DLLIMPORT int GetPlatformsFromString(const wxString &platforms)
Return an integer representation of a platform string.
Definition: globals.cpp:73
DLLIMPORT bool CreateDirRecursively(const wxString &full_path, int perms=0755)
Definition: globals.cpp:610
DLLIMPORT wxString ExpandBackticks(wxString &str)
Definition: globals.cpp:861
DLLIMPORT wxString EscapeSpaces(const wxString &str)
Escapes spaces and tabs (NOT quoting the string)
Definition: globals.cpp:273
int Printf(const wxString &pszFormat,...)
ProjectTreeVisualState
These are valid values for the visual style of the project tree.
Definition: globals.h:135
DLLIMPORT void RestoreTreeState(wxTreeCtrl *tree, const wxTreeItemId &parent, wxArrayString &nodePaths, wxArrayString &selectedItemPaths)
Definition: globals.cpp:589
DLLIMPORT bool cbSaveTinyXMLDocument(TiXmlDocument *doc, const wxString &filename)
Saves a TinyXML document correctly, even if the path contains unicode characters. ...
Definition: globals.cpp:727
Definition: globals.h:28
If true, use virtual folders like "Sources", "Headers", etc.
Definition: globals.h:138
#define NULL
Definition: prefix.cpp:59
Current user has read-only access to the directory.
Definition: globals.h:382
Definition: globals.h:161
DLLIMPORT int cbMessageBox(const wxString &message, const wxString &caption=wxEmptyString, int style=wxOK, wxWindow *parent=NULL, int x=-1, int y=-1)
wxMessageBox wrapper.
Definition: globals.cpp:1395
DLLIMPORT wxString realpath(const wxString &path)
Definition: globals.cpp:1348