/usr/include/codeblocks/globals.h is in codeblocks-dev 10.05-2.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 | /*
* This file is part of the Code::Blocks IDE and licensed under the GNU Lesser General Public License, version 3
* http://www.gnu.org/licenses/lgpl-3.0.html
*/
#ifndef SDK_GLOBALS_H
#define SDK_GLOBALS_H
#include "settings.h"
#include <wx/string.h>
#include <wx/treectrl.h>
#include <wx/file.h>
#include <wx/filename.h>
#include <wx/intl.h>
#include <wx/msgdlg.h>
#include <wx/bitmap.h>
class TiXmlDocument;
/// Known plugin types
enum PluginType
{
ptNone = 1,
ptTool,
ptMime,
ptCompiler,
ptDebugger,
ptCodeCompletion,
ptWizard,
ptOther
};
/// The type of module offering a context menu.
enum ModuleType
{
mtProjectManager = 1,
mtEditorManager,
mtLogManager,
mtOpenFilesList, //pecan 2006/03/22
mtUnknown
};
/// Known file types
enum FileType
{
ftCodeBlocksProject = 0,
ftCodeBlocksWorkspace,
ftDevCppProject,
ftMSVC6Project,
ftMSVC7Project,
ftMSVC6Workspace,
ftMSVC7Workspace,
ftXcode1Project,
ftXcode2Project,
ftSource,
ftHeader,
ftObject,
ftXRCResource,
ftResource,
ftResourceBin,
ftStaticLib,
ftDynamicLib,
ftExecutable,
ftNative,
ftXMLDocument,
ftScript,
ftOther
};
/** These are valid values for the state of each project file.
If a value is casted to integer, it corresponds to the tree's imagelist index for the state.
NOTE: Keep in sync with icons loaded in ProjectManager::BuildTree()!
*/
enum FileVisualState
{
// The following are related to (editable, source-) file states
fvsNormal = 0,
fvsMissing,
fvsModified,
fvsReadOnly,
// The following are related to version control systems (vc)
fvsVcAdded,
fvsVcConflict,
fvsVcMissing,
fvsVcModified,
fvsVcOutOfDate,
fvsVcUpToDate,
fvsVcRequiresLock,
fvsVcExternal,
fvsVcGotLock,
fvsVcLockStolen,
fvsVcMismatch,
fvsVcNonControlled,
// The following are related to C::B workspace/project/folder/virtual
fvsWorkspace,
fvsWorkspaceReadOnly,
fvsProject,
fvsProjectReadOnly,
fvsFolder,
fvsVirtualFolder,
/// do *not* use this, it exists just to know the number of items...
fvsLast
};
/** Template output types. */
enum TemplateOutputType
{
totProject = 0, ///< template outputs a new project
totTarget, ///< template adds a new target in a project
totFiles, ///< template outputs a new file (or files)
totCustom, ///< template produces custom output (entirely up to the wizard used)
totUser ///< template is a user-saved project template
};
/** Supported platforms */
enum SupportedPlatforms
{
spMac = 0x01,
spUnix = 0x02,
spWindows = 0x04,
spAll = 0xff
};
// NOTE: if you add/remove platforms, remember to update the relevant Get/Set globals
typedef wxString HighlightLanguage;
#define HL_AUTO _T(" ")
#define HL_NONE _T(" ")
extern DLLIMPORT const wxString DEFAULT_WORKSPACE;
extern DLLIMPORT const wxString DEFAULT_ARRAY_SEP;
extern DLLIMPORT const wxString DEFAULT_CONSOLE_TERM;
extern DLLIMPORT const wxString DEFAULT_CONSOLE_SHELL;
// global helper funcs
/// Reads a wxString from a non-unicode file. File must be open. File is closed automatically.
extern 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.
extern DLLIMPORT wxString cbReadFileContents(wxFile& file, wxFontEncoding encoding = wxFONTENCODING_SYSTEM);
/// Writes a wxString to a non-unicode file. File must be open. File is closed automatically.
extern DLLIMPORT bool cbWrite(wxFile& file, const wxString& buff, wxFontEncoding encoding = wxFONTENCODING_SYSTEM);
/// Writes a wxString to a file. Takes care of unicode and uses a temporary file
/// to save first and then it copies it over the original.
extern DLLIMPORT bool cbSaveToFile(const wxString& filename, const wxString& contents, wxFontEncoding encoding = wxFONTENCODING_SYSTEM, bool bom = false);
/// Saves a TinyXML document correctly, even if the path contains unicode characters.
extern DLLIMPORT bool cbSaveTinyXMLDocument(TiXmlDocument* doc, const wxString& filename);
/// Return @c str as a proper unicode-compatible string
extern DLLIMPORT wxString cbC2U(const char* str);
/// Return multibyte (C string) representation of the string
extern DLLIMPORT const wxWX2MBbuf cbU2C(const wxString& str);
/// Try converting a C-string from different encodings until a possible match is found.
/// This tries the following encoding converters (in the same order):
/// utf8, system, default and iso8859-1 to iso8859-15.
/// Returns the final encoding detected.
extern DLLIMPORT wxFontEncoding DetectEncodingAndConvert(const char* strIn, wxString& strOut, wxFontEncoding possibleEncoding = wxFONTENCODING_SYSTEM);
extern DLLIMPORT int GetPlatformsFromString(const wxString& platforms);
extern DLLIMPORT wxString GetStringFromPlatforms(int platforms, bool forceSeparate = false);
// see globals.cpp for info on the third argument (bool SeparatorAtEnd)
extern DLLIMPORT wxString GetStringFromArray(const wxArrayString& array, const wxString& separator = DEFAULT_ARRAY_SEP, bool SeparatorAtEnd = true);
extern DLLIMPORT wxArrayString GetArrayFromString(const wxString& text, const wxString& separator = DEFAULT_ARRAY_SEP, bool trimSpaces = true);
extern DLLIMPORT void AppendArray(const wxArrayString& from, wxArrayString& to);
extern DLLIMPORT wxString UnixFilename(const wxString& filename);
extern DLLIMPORT void QuoteStringIfNeeded(wxString& str);
/// Escapes spaces and tabs (NOT quoting the string)
extern DLLIMPORT wxString EscapeSpaces(const wxString& str);
extern DLLIMPORT FileType FileTypeOf(const wxString& filename);
extern DLLIMPORT void SaveTreeState(wxTreeCtrl* tree, const wxTreeItemId& parent, wxArrayString& nodePaths);
extern DLLIMPORT void RestoreTreeState(wxTreeCtrl* tree, const wxTreeItemId& parent, wxArrayString& nodePaths);
extern DLLIMPORT bool CreateDirRecursively(const wxString& full_path, int perms = 0755);
extern DLLIMPORT bool CreateDir(const wxString& full_path, int perms = 0755);
extern DLLIMPORT wxString ChooseDirectory(wxWindow* parent,
const wxString& message = _("Select directory"),
const wxString& initialPath = _T(""),
const wxString& basePath = _T(""),
bool askToMakeRelative = false, // relative to basePath
bool showCreateDirButton = false); // where supported
extern DLLIMPORT bool NormalizePath(wxFileName& f,const wxString& base);
extern DLLIMPORT bool IsSuffixOfPath(wxFileName const & suffix, wxFileName const & path);
extern DLLIMPORT wxString URLEncode(const wxString &str);
/// Check if CommonControls version is at least 6 (XP and up)
extern DLLIMPORT bool UsesCommonControls6();
/** This function loads a bitmap from disk.
* Always use this to load bitmaps because it takes care of various
* issues with pre-XP windows (actually common controls < 6.00).
*/
extern DLLIMPORT wxBitmap cbLoadBitmap(const wxString& filename, wxBitmapType bitmapType = wxBITMAP_TYPE_PNG);
// compatibility function
inline wxBitmap LoadPNGWindows2000Hack(const wxString& filename){ return cbLoadBitmap(filename); }
/** Finds out if a window is really shown.
*
* win->IsShown() is not that good because we don't know if the
* window's container (parent) is actually shown or not...
*
* This is usually used to find out if docked windows are shown.
*
* @param win The window in question.
* @return True if @c win is shown, false if not.
*/
extern DLLIMPORT bool IsWindowReallyShown(wxWindow* win);
/** Icons styles for settings dialogs.
*/
enum SettingsIconsStyle
{
sisLargeIcons = 0, ///< Large icons (default)
sisNoIcons = 1, ///< No icons, just text
};
class wxListCtrl;
/** Set the icons style for the supplied list control.
* @param lc The wxListCtrl.
* @param style The style to use.
*/
extern DLLIMPORT void SetSettingsIconsStyle(wxListCtrl* lc, SettingsIconsStyle style);
/** Get the icons style for the supplied list control.
* @return The icons style.
*/
extern DLLIMPORT SettingsIconsStyle GetSettingsIconsStyle(wxListCtrl* lc);
class wxWindow;
enum cbPlaceDialogMode
{
pdlDont = 0,
pdlBest,
pdlCentre,
pdlHead,
pdlConstrain,
pdlClip
};
extern DLLIMPORT void PlaceWindow(wxTopLevelWindow *w, cbPlaceDialogMode mode = pdlBest, bool enforce = false);
/** wxMessageBox wrapper.
*
* Use this instead of wxMessageBox(), as this uses PlaceWindow() to show it in the correct monitor.
* @note The return value for wxOK would be wxID_OK and so on for other buttons.
* So, read wxMessageDialog 's documentation, *not* wxMessageBox 's...
*/
inline int cbMessageBox(const wxString& message, const wxString& caption = wxEmptyString, int style = wxOK, wxWindow *parent = NULL, int x = -1, int y = -1)
{
// Cannot create a wxMessageDialog with a NULL as parent
if (!parent)
{
// wxMessage*Box* returns any of: wxYES, wxNO, wxCANCEL, wxOK.
int answer = wxMessageBox(message, caption, style, parent, x, y);
switch (answer)
{
// map answer to the one of wxMessage*Dialog* to ensure compatibility
case (wxOK):
return wxID_OK;
case (wxCANCEL):
return wxID_CANCEL;
case (wxYES):
return wxID_YES;
case (wxNO):
return wxID_NO;
default:
return -1; // NOTE: Cannot happen unless wxWidgets API changes
}
}
wxMessageDialog dlg(parent, message, caption, style, wxPoint(x,y));
PlaceWindow(&dlg);
// wxMessage*Dialog* returns any of wxID_OK, wxID_CANCEL, wxID_YES, wxID_NO
return dlg.ShowModal();
};
inline void NotifyMissingFile(const wxString &name)
{
wxString msg;
msg.Printf(_T("The file %s could not be found.\nPlease check your installation."), name.c_str());
cbMessageBox(msg);
};
/// Result values of cbDirAccessCheck()
enum DirAccessCheck
{
dacInvalidDir, ///< Invalid directory (does not exist).
dacReadWrite, ///< Current user has read-write access to the directory.
dacReadOnly ///< Current user has read-only access to the directory.
};
/** Check what access the current user has in a directory.
*
* @param dir The directory in question.
* It may or may not contain an ending path separator.
* @return The type of access the current user has in the directory.
*/
extern DLLIMPORT DirAccessCheck cbDirAccessCheck(const wxString& dir);
namespace platform
{
typedef enum
{
winver_NotWindows = 0,
winver_UnknownWindows,
winver_Windows9598ME,
winver_WindowsNT2000,
winver_WindowsXP,
winver_Vista, // untested!
}windows_version_t;
extern DLLIMPORT windows_version_t WindowsVersion();
};
// returns the real path of a file by resolving symlinks
// not yet optimal but should do for now
// one thing that's not checked yet are circular symlinks - watch out!
extern DLLIMPORT wxString realpath(const wxString& path);
#endif // SDK_GLOBALS_H
|