13 #include <wx/confbase.h> 72 TiXmlElement* root = doc.FirstChildElement(
"CodeBlocks_workspace_file");
76 root = doc.FirstChildElement(
"Code::Blocks_workspace_file");
83 TiXmlElement* wksp = root->FirstChildElement(
"Workspace");
90 Title =
cbC2U(wksp->Attribute(
"title"));
92 TiXmlElement* proj = wksp->FirstChildElement(
"Project");
121 proj = proj->NextSiblingElement(
"Project");
125 proj = wksp->FirstChildElement(
"Project");
145 TiXmlElement* dep = proj->FirstChildElement(
"Depends");
150 fname.MakeAbsolute(wfname.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR));
154 dep = dep->NextSiblingElement(
"Depends");
157 proj = proj->NextSiblingElement(
"Project");
165 const char* ROOT_TAG =
"CodeBlocks_workspace_file";
168 doc.SetCondenseWhiteSpace(
false);
169 doc.InsertEndChild(TiXmlDeclaration(
"1.0",
"UTF-8",
"yes"));
170 TiXmlElement* rootnode =
static_cast<TiXmlElement*
>(doc.InsertEndChild(TiXmlElement(ROOT_TAG)));
174 TiXmlElement* wksp =
static_cast<TiXmlElement*
>(rootnode->InsertEndChild(TiXmlElement(
"Workspace")));
175 wksp->SetAttribute(
"title",
cbU2C(title));
178 for (
unsigned int i = 0; i < arr->GetCount(); ++i)
186 TiXmlElement* node =
static_cast<TiXmlElement*
>(wksp->InsertEndChild(TiXmlElement(
"Project")));
190 if (deps && deps->GetCount())
192 for (
size_t j = 0; j < deps->GetCount(); ++j)
196 fname.MakeRelativeTo(wfname.
GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR));
197 TiXmlElement* dnode =
static_cast<TiXmlElement*
>(node->InsertEndChild(TiXmlElement(
"Depends")));
207 const char* ROOT_TAG =
"CodeBlocks_workspace_layout_file";
210 doc.SetCondenseWhiteSpace(
false);
211 doc.InsertEndChild(TiXmlDeclaration(
"1.0",
"UTF-8",
"yes"));
212 TiXmlElement* rootnode =
static_cast<TiXmlElement*
>(doc.InsertEndChild(TiXmlElement(ROOT_TAG)));
216 rootnode->InsertEndChild(TiXmlElement(
"FileVersion"));
228 static_cast<TiXmlElement*
>(
229 rootnode->InsertEndChild( TiXmlElement(
"ActiveProject") ) );
240 const wxString preferredTarget = wsp->GetPreferredTarget();
241 if ( ! preferredTarget.
IsEmpty() )
244 static_cast<TiXmlElement*
>(
245 rootnode->InsertEndChild( TiXmlElement(
"PreferredTarget") ) );
246 el->SetAttribute(
"name",
cbU2C(preferredTarget) );
252 if (
Manager::Get()->GetConfigManager(
_T(
"app"))->ReadBool(
_T(
"/environment/enable_editor_layout"),
false))
255 static_cast<TiXmlElement*
>(
256 rootnode->InsertEndChild( TiXmlElement(
"EditorTabsLayout") ) );
257 el->SetAttribute(
"layout",
cbU2C(
Manager::Get()->GetEditorManager()->GetNotebook()->SavePerspective() ));
273 TiXmlElement* root = doc.FirstChildElement(
"CodeBlocks_workspace_layout_file");
276 GetpMsg()->
DebugLog(
_T(
"Unable to load Code::Blocks workspace layout file: File is invalid."));
283 TiXmlElement*
version = root->FirstChildElement(
"FileVersion");
288 version->QueryIntAttribute(
"major", &major);
289 version->QueryIntAttribute(
"minor", &minor);
295 F(
_(
"This workspace layout file was saved with a newer version of Code::Blocks.\n" 296 "Will try to load, but you might see unexpected results.\n" 297 "In this case close the workspace, delete %s and reopen the workspace."),filename.
wx_str()),
308 if (major == 0 && minor == 0)
310 msg <<
_(
"0.0 (unversioned) to 1.0:\n");
311 msg <<
_(
" * save editor-pane layout and order.\n");
318 "The file will automatically be upgraded on close.\n" 319 "But please read the following list of changes, as some of them\n" 320 "might not automatically convert existing (old) settings.\n" 321 "If you don't understand what a change means, you probably don't\n" 322 "use that feature so you don't have to worry about it.\n\n" 323 "List of changes:\n"),
337 warn_msg.
Prepend(
_(
"!!! WARNING !!!\n\n"));
348 if (TiXmlElement* el = root->FirstChildElement(
"ActiveProject"))
352 fname.
MakeAbsolute( wfname.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR) );
365 if (TiXmlElement* el = root->FirstChildElement(
"PreferredTarget"))
375 && (
Manager::Get()->GetConfigManager(
_T(
"app"))->ReadBool(
_T(
"/environment/enable_editor_layout"),
false)) )
377 if (TiXmlElement* el = root->FirstChildElement(
"EditorTabsLayout"))
379 if (el->Attribute(
"layout"))
wxString F(const wxChar *msg,...)
sprintf-like function
bool LoadPerspective(const wxString &layout, bool mergeLayouts=false)
Loads serialized notebook layout.
cbProject * IsOpen(const wxString &filename)
Check if a project is open based on the project's filename.
static Manager * Get()
Use Manager::Get() to get a pointer to its instance Manager::Get() is guaranteed to never return an i...
static bool IsAppShuttingDown()
#define WORKSPACE_LAYOUT_FILE_VERSION_MAJOR
bool SaveLayout(const wxString &filename)
bool LoadDocument(const wxString &filename, TiXmlDocument *doc)
~WorkspaceLoader() override
ProjectManager * GetpMan()
EditorManager * GetEditorManager() const
DLLIMPORT const wxWX2MBbuf cbU2C(const wxString &str)
Return multibyte (C string) representation of the string.
ProjectManager * GetProjectManager() const
Functions returning pointers to the respective sub-manager instances.
bool MakeRelativeTo(const wxString &pathBase=wxEmptyString, wxPathFormat format=wxPATH_NATIVE)
DLLIMPORT wxString UnixFilename(const wxString &filename, wxPathFormat format=wxPATH_NATIVE)
Represents a Code::Blocks project.
virtual const wxString & GetFilename() const
cbProject * LoadProject(const wxString &filename, bool activateIt=true)
Load a project from disk.
DLLIMPORT wxString cbC2U(const char *str)
Return str as a proper unicode-compatible string.
static bool IsBatchBuild()
LogManager * GetLogManager() const
cbProject * GetActiveProject()
Retrieve the active project.
void SetPreferredTarget(const wxString &target)
Set the preferred target for this workspace.
const wxStringCharType * wx_str() const
bool AddProjectDependency(cbProject *base, cbProject *dependsOn)
Adds a project as a dependency of another project.
bool Save(const wxString &title, const wxString &filename) override
const wxString & _(const wxString &string)
bool Open(const wxString &filename, wxString &Title) override
cbWorkspace * GetWorkspace()
Get the current workspace filename.
void SetProject(cbProject *project, bool refresh=true)
Set the active project.
wxString GetPath(int flags=wxPATH_GET_VOLUME, wxPathFormat format=wxPATH_NATIVE) const
The entry point singleton for working with projects.
cbAuiNotebook * GetNotebook()
void DebugLog(const wxString &msg, Logger::level lv=Logger::info)
wxString & Prepend(const wxString &str)
ProjectsArray * GetProjects()
Retrieve an array of all the opened projects.
bool MakeAbsolute(const wxString &cwd=wxEmptyString, wxPathFormat format=wxPATH_NATIVE)
bool LoadLayout(const wxString &filename)
wxString GetFullPath(wxPathFormat format=wxPATH_NATIVE) const
DLLIMPORT bool cbSaveTinyXMLDocument(TiXmlDocument *doc, const wxString &filename)
Saves a TinyXML document correctly, even if the path contains unicode characters. ...
wxArtID wxART_INFORMATION
static wxString Format(const wxString &format,...)
Dialog that contains a "Don't annoy me" checkbox.
#define WORKSPACE_LAYOUT_FILE_VERSION_MINOR
const ProjectsArray * GetDependenciesForProject(cbProject *base)
Get the array of projects base depends on.
DLLIMPORT int cbMessageBox(const wxString &message, const wxString &caption=wxEmptyString, int style=wxOK, wxWindow *parent=NULL, int x=-1, int y=-1)
wxMessageBox wrapper.