13 #include <wx/confbase.h> 31 : m_pProject(project),
61 root = doc.FirstChildElement(
"CodeBlocks_layout_file");
65 root = doc.FirstChildElement(
"Code::Blocks_layout_file");
68 pMsg->
DebugLog(
_T(
"Not a valid Code::Blocks layout file..."));
76 TiXmlElement*
version = root->FirstChildElement(
"FileVersion");
80 version->QueryIntAttribute(
"major", &major);
81 version->QueryIntAttribute(
"minor", &minor);
87 F(
_(
"This project layout file was saved with a newer version of Code::Blocks.\n" 88 "Will try to load, but you might see unexpected results.\n" 89 "In this case close the project, delete %s and reopen the project."),filename.
wx_str()),
100 if (major == 0 && minor == 0)
102 msg <<
_(
"0.0 (unversioned) to 1.0:\n");
103 msg <<
_(
" * save editor-pane layout and order.\n");
110 "The file will automatically be upgraded on close.\n" 111 "But please read the following list of changes, as some of them\n" 112 "might not automatically convert existing (old) settings.\n" 113 "If you don't understand what a change means, you probably don't\n" 114 "use that feature so you don't have to worry about it.\n\n" 115 "List of changes:\n"),
129 warn_msg.
Prepend(
_(
"!!! WARNING !!!\n\n"));
139 elem = root->FirstChildElement(
"ActiveTarget");
142 if (elem->Attribute(
"name"))
146 elem = root->FirstChildElement(
"File");
156 fname =
cbC2U(elem->Attribute(
"name"));
178 if (elem->QueryIntAttribute(
"open", &getInt) == TIXML_SUCCESS)
180 if (elem->QueryIntAttribute(
"top", &getInt) == TIXML_SUCCESS)
185 if (elem->QueryIntAttribute(
"tabpos", &getInt) == TIXML_SUCCESS)
187 if (elem->QueryIntAttribute(
"split", &getInt) == TIXML_SUCCESS)
189 if (elem->QueryIntAttribute(
"active", &getInt) == TIXML_SUCCESS)
191 if (elem->QueryIntAttribute(
"splitpos", &getInt) == TIXML_SUCCESS)
193 if (elem->QueryIntAttribute(
"zoom_1", &getInt) == TIXML_SUCCESS)
195 if (elem->QueryIntAttribute(
"zoom_2", &getInt) == TIXML_SUCCESS)
198 TiXmlElement* cursor = elem->FirstChildElement(
"Cursor");
201 cursor = cursor->FirstChildElement();
204 if (cursor->QueryIntAttribute(
"position", &getInt) == TIXML_SUCCESS)
206 if (cursor->QueryIntAttribute(
"topLine", &getInt) == TIXML_SUCCESS)
210 cursor = cursor->NextSiblingElement();
213 if (cursor->QueryIntAttribute(
"position", &getInt) == TIXML_SUCCESS)
215 if (cursor->QueryIntAttribute(
"topLine", &getInt) == TIXML_SUCCESS)
222 TiXmlElement* folding = elem->FirstChildElement(
"Folding");
225 folding = folding->FirstChildElement();
228 if (folding->QueryIntAttribute(
"line", &getInt) == TIXML_SUCCESS)
231 folding = folding->NextSiblingElement();
235 elem = elem->NextSiblingElement();
239 && (
Manager::Get()->GetConfigManager(
_T(
"app"))->ReadBool(
_T(
"/environment/enable_editor_layout"),
false)) )
241 elem = root->FirstChildElement(
"EditorTabsLayout");
251 const char* ROOT_TAG =
"CodeBlocks_layout_file";
254 doc.SetCondenseWhiteSpace(
false);
255 doc.InsertEndChild(TiXmlDeclaration(
"1.0",
"UTF-8",
"yes"));
256 TiXmlElement* rootnode =
static_cast<TiXmlElement*
>(doc.InsertEndChild(TiXmlElement(ROOT_TAG)));
260 rootnode->InsertEndChild(TiXmlElement(
"FileVersion"));
264 TiXmlElement* tgtidx =
static_cast<TiXmlElement*
>(rootnode->InsertEndChild(TiXmlElement(
"ActiveTarget")));
278 TiXmlElement* node =
static_cast<TiXmlElement*
>(rootnode->InsertEndChild(TiXmlElement(
"File")));
281 node->SetAttribute(
"top", (f == active));
290 TiXmlElement* cursor =
static_cast<TiXmlElement*
>(node->InsertEndChild(TiXmlElement(
"Cursor")));
291 TiXmlElement* cursor_1 =
static_cast<TiXmlElement*
>(cursor->InsertEndChild(TiXmlElement(
"Cursor1")));
292 cursor_1->SetAttribute(
"position", f->
editorPos);
297 TiXmlElement* cursor_2 =
static_cast<TiXmlElement*
>(cursor->InsertEndChild(TiXmlElement(
"Cursor2")));
298 cursor_2->SetAttribute(
"position", f->
editorPos_2);
304 TiXmlElement* folding =
static_cast<TiXmlElement*
>(node->InsertEndChild(TiXmlElement(
"Folding")));
307 TiXmlElement* line =
static_cast<TiXmlElement*
>(folding->InsertEndChild(TiXmlElement(
"Collapse")));
314 for (
unsigned int i = 0; i < en.
GetCount(); ++i)
316 if (!en[i].IsEmpty())
318 TiXmlElement* node =
static_cast<TiXmlElement*
>(rootnode->InsertEndChild(TiXmlElement(
"Expand")));
319 node->SetAttribute(
"folder",
cbU2C(en[i]));
323 if (
Manager::Get()->GetConfigManager(
_T(
"app"))->ReadBool(
_T(
"/environment/enable_editor_layout"),
false))
326 static_cast<TiXmlElement*
>(
327 rootnode->InsertEndChild( TiXmlElement(
"EditorTabsLayout") ) );
ProjectFile * GetFileByFilename(const wxString &filename, bool isRelative=true, bool isUnixFilename=false)
Access a file of the project.
wxString F(const wxChar *msg,...)
sprintf-like function
int editorTabPos
The position of the editor-tab for this file.
#define PROJECT_LAYOUT_FILE_VERSION_MAJOR
wxString relativeFilename
The relative (to the project) filename of this file.
static Manager * Get()
Use Manager::Get() to get a pointer to its instance Manager::Get() is guaranteed to never return an i...
virtual FilesList & GetFilesList()
Provides an easy way to iterate all the files belonging in this target.
int editorSplitActive
Last active splitview (1 or 2).
int editorPos_2
The last known caret position in an editor for this file (right/bottom control if split)...
bool Open(const wxString &filename)
#define PROJECT_LAYOUT_FILE_VERSION_MINOR
bool LoadDocument(const wxString &filename, TiXmlDocument *doc)
int editorZoom
The zoom-factor of the editor for this file (left/top control if split).
Represents a file in a Code::Blocks project.
int editorPos
The last known caret position in an editor for this file (left/top control if split).
ProjectFile * m_TopProjectFile
EditorManager * GetEditorManager() const
DLLIMPORT const wxWX2MBbuf cbU2C(const wxString &str)
Return multibyte (C string) representation of the string.
int editorSplitPos
Last splitter position.
ProjectManager * GetProjectManager() const
Functions returning pointers to the respective sub-manager instances.
int editorTopLine
The last known caret line in an editor for this file (left/top control if split). ...
Represents a Code::Blocks project.
const wxString & GetActiveBuildTarget() const
const wxArrayString & ExpandedNodes()
Convenience function for remembering the project's tree state when refreshing it. ...
DLLIMPORT wxString cbC2U(const char *str)
Return str as a proper unicode-compatible string.
virtual const wxString & GetTitle() const
Read the target's title.
int editorSplit
Split type of the editor as int.
cbEditor * GetBuiltinActiveEditor()
static bool IsBatchBuild()
LogManager * GetLogManager() const
const wxStringCharType * wx_str() const
int editorTopLine_2
The last known caret line in an editor for this file(right/bottom control if split).
ProjectLayoutLoader(cbProject *project)
bool editorOpen
If true, the file is open inside an editor.
const wxString & _(const wxString &string)
wxString m_NotebookLayout
The entry point singleton for working with projects.
void DebugLog(const wxString &msg, Logger::level lv=Logger::info)
wxString & Prepend(const wxString &str)
int editorZoom_2
The zoom-factor of the editor for this file(right/bottom control if split).
ProjectFile * GetProjectFile() const
Read the ProjectFile pointer associated with this editor.
wxArrayInt editorFoldLinesArray
Fold lines.
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,...)
bool Save(const wxString &filename)
Dialog that contains a "Don't annoy me" checkbox.
bool SetActiveBuildTarget(const wxString &name)
Set the active build target.
virtual ~ProjectLayoutLoader()