6
#include <wx/dynarray.h>
7
#include <wx/filename.h>
9
#include <wx/treectrl.h>
11
#include "blockallocated.h"
14
class ProjectBuildTarget;
17
WX_DECLARE_HASH_MAP(ProjectBuildTarget*, pfDetails*, wxPointerHash, wxPointerEqual, PFDMap);
21
pfCustomBuild() : useCustomBuildCommand(false) {}
22
wxString buildCommand;
23
bool useCustomBuildCommand;
25
WX_DECLARE_HASH_MAP(wxString, pfCustomBuild, wxStringHash, wxStringEqual, pfCustomBuildMap);
27
/** Represents a file in a Code::Blocks project. */
28
class ProjectFile : public BlockAllocated<ProjectFile, 1000>
32
ProjectFile(cbProject* prj);
36
/** Make this file belong to an additional build target.
37
* @param targetName The build target to add this file to. */
38
void AddBuildTarget(const wxString& targetName);
40
/** Rename a build target this file belongs in.
41
* @param oldTargetName The build target's old name.
42
* @param newTargetName The build target's new name.
43
* @note This does *not* change the build target's name, just the reference in the project file.
44
* This is actually used by cbProject::RenameBuildTarget(). */
45
void RenameBuildTarget(const wxString& oldTargetName, const wxString& newTargetName);
47
/** Remove this file from the specified build target.
48
* @param targetName The build target's name to remove this file from. */
49
void RemoveBuildTarget(const wxString& targetName);
51
/** Show the file properties dialog.
52
* @param parent The parent window for the dialog (can be NULL).
53
* @return True if the user closed the dialog with "OK", false if closed it with "Cancel".
55
bool ShowOptions(wxWindow* parent);
57
// take as example the relative file sdk/cbProject.cpp
58
/** @return The relative (to the project) filename without extension. */
59
wxString GetBaseName() const; // returns sdk/cbProject
61
/** @return The generated object filename. */
62
const wxString& GetObjName(); // returns sdk/cbProject.o
64
/** Set the generated object filename.
65
* @param name The filename for the generated object. */
66
void SetObjName(const wxString& name);
68
/** @return The parent project. */
69
cbProject* GetParentProject(){ return project; }
71
/** This is called automatically when adding/removing build targets.
72
* @param target A pointer to the build target whose file details should be updated. */
73
void UpdateFileDetails(ProjectBuildTarget* target = 0);
75
/** Access the file details for this project file for the specified target.
76
* @param target A pointer to the build target whose file details should be updated.
77
* @return The details for this project file for the specified build target. */
78
const pfDetails& GetFileDetails(ProjectBuildTarget* target);
80
/** Set the visual state (modified, read-only, etc).
81
* @param state The new visual state. */
82
void SetFileState(FileVisualState state);
84
/** @return The visual state (modified, read-only, etc). */
85
FileVisualState GetFileState() const;
87
/** The full filename of this file. Usually you need to read from it and never write to it.
88
* @note If you set this anywhere in code,
89
* you *MUST* call UpdateFileDetails() afterwards or it won't compile anymore
93
/** The relative (to the project) filename of this file. Usually you need to read from it and never write to it.
94
* @note If you set this anywhere in code,
95
* you *MUST* call UpdateFileDetails() afterwards or it won't compile anymore
97
wxString relativeFilename;
99
/** The relative filename to the common top-level path.
100
* This is used mainly for the tree, as this is guaranteed to not contain '..' */
101
wxString relativeToCommonTopLevelPath;
103
/** Compile flag. If it's true, the file is compiled (generates object file) else it is not. */
106
/** Link flag. If it's true, the (generated object) file is linked else it is not. */
109
/** The weight. This is a number between 0 and 100 (defaults to 50).
110
* Files with smaller weights are compiled earlier than those with larger weights. */
111
unsigned short int weight;
113
/** If true, the file is open inside an editor. */
114
bool editorOpen; // layout info
116
/** The last known caret position in an editor for this file. */
117
int editorPos; // layout info
119
/** The last known caret line in an editor for this file. */
120
int editorTopLine; // layout info
122
/** The position of the editor-tab for this file. */
123
int editorTabPos; // layout info
125
/** A map for custom builds. Key is compiler ID, value is pfCustomBuild struct. */
126
pfCustomBuildMap customBuild;
128
/** The compiler variable used for this file (e.g CPP, CC, etc). */
129
wxString compilerVar;
131
/** An array of strings, containing the names of all the build targets this file belongs to. */
132
wxArrayString buildTargets;
134
/** A string that represents the virtual folder this file will appear in.
135
* This is a relative path which doesn't have to exist in the filesystem
137
wxString virtual_path;
139
friend class cbProject;
140
void DoUpdateFileDetails(ProjectBuildTarget* target);
142
FileVisualState m_VisualState;
143
wxTreeItemId m_TreeItemId; // set by the project when building the tree
147
WX_DECLARE_LIST(ProjectFile, FilesList);
149
/** This is a helper class that caches various filenames for one ProjectFile.
150
* These include the source filename, the generated object filename,
151
* relative and absolute versions of the above, etc.
152
* Mainly used by the compiler...
154
class pfDetails : public BlockAllocated<pfDetails, 1000>
157
pfDetails(ProjectBuildTarget* target, ProjectFile* pf);
158
void Update(ProjectBuildTarget* target, ProjectFile* pf);
159
// all the members below, are set in the constructor
160
wxString source_file;
161
wxString object_file;
165
wxString object_file_flat;
166
// those below, have no UnixFilename() applied, nor QuoteStringIfNeeded()
167
wxString source_file_native;
168
wxString object_file_native;
169
wxString dep_file_native;
170
wxString object_dir_native;
171
wxString dep_dir_native;
172
wxString source_file_absolute_native;
173
wxString object_file_absolute_native;
174
wxString object_file_flat_absolute_native;
175
wxString dep_file_absolute_native;
176
wxString object_file_flat_native;
179
#endif // PROJECTFILE_H