Code::Blocks  SVN r11506
projectfile.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 PROJECTFILE_H
7 #define PROJECTFILE_H
8 
9 #include <vector>
10 
11 #include "settings.h"
12 #include "globals.h"
13 #include "prep.h"
14 #include <wx/dynarray.h>
15 #include <wx/filename.h>
16 #include <wx/treectrl.h>
17 #include <wx/hashset.h>
18 
19 class cbProject;
20 class ProjectBuildTarget;
21 class pfDetails;
22 
23 WX_DECLARE_HASH_MAP(ProjectBuildTarget*, pfDetails*, wxPointerHash, wxPointerEqual, PFDMap);
24 
26 {
30 };
31 WX_DECLARE_HASH_MAP(wxString, pfCustomBuild, wxStringHash, wxStringEqual, pfCustomBuildMap);
32 
34 typedef std::vector<ProjectFile*> ProjectFilesVector;
35 
37 
40 {
41  public:
43  ProjectFile(cbProject* prj);
45  ~ProjectFile();
46 
53  void Rename(const wxString& new_name);
54 
57  void AddBuildTarget(const wxString& targetName);
58 
64  void RenameBuildTarget(const wxString& oldTargetName, const wxString& newTargetName);
65 
68  void RemoveBuildTarget(const wxString& targetName);
69 
73  const wxArrayString& GetBuildTargets() const;
74 
79  bool ShowOptions(wxWindow* parent);
80 
81  // take as example the relative file sdk/cbProject.cpp
83  wxString GetBaseName() const; // returns sdk/cbProject
84 
86  const wxString& GetObjName(); // returns sdk/cbProject.o
87 
90  void SetObjName(const wxString& name);
91 
93  cbProject* GetParentProject(){ return project; }
94 
97  void UpdateFileDetails(ProjectBuildTarget* target = nullptr);
98 
102  const pfDetails& GetFileDetails(ProjectBuildTarget* target);
103 
106  void SetFileState(FileVisualState state);
107 
109  FileVisualState GetFileState() const;
110 
112  void SetUseCustomBuildCommand(const wxString& compilerId, bool useCustomBuildCommand);
113 
115  void SetCustomBuildCommand(const wxString& compilerId, const wxString& newBuildCommand);
116 
118  bool GetUseCustomBuildCommand(const wxString& compilerId);
119 
121  wxString GetCustomBuildCommand(const wxString& compilerId);
122 
127 
132 
136 
138  bool compile;
139 
141  bool link;
142 
145  unsigned short int weight;
146 
148  bool editorOpen; // layout info
149 
151  int editorSplit; // layout info
152 
154  int editorSplitActive; // layout info
155 
157  int editorSplitPos; // layout info
158 
160  int editorPos; // layout info
161 
163  int editorTopLine; // layout info
164 
166  int editorZoom; // layout info
167 
169  int editorPos_2; // layout info
170 
172  int editorTopLine_2; // layout info
173 
175  int editorZoom_2; // layout info
176 
178  int editorTabPos; // layout info
179 
182 
184  pfCustomBuildMap customBuild;
185 
188 
191 
196 
198  ProjectFile* autoGeneratedBy; // deprecated --> use the method ; die public member var's
199 
201  ProjectFile* AutoGeneratedBy() const { return autoGeneratedBy;}
202 
204  void SetAutoGeneratedBy(ProjectFile* TheFile) { autoGeneratedBy = TheFile; }
205 
208 
210  const wxTreeItemId& GetTreeItemId() const { return m_TreeItemId; }
211 
213  void SetTreeItemId(wxTreeItemId id) { m_TreeItemId = id; }
214 
222  static int CompareProjectFiles(ProjectFile* item1, ProjectFile* item2);
223  protected:
224  friend class cbProject;
225 
226  void DoUpdateFileDetails(ProjectBuildTarget* target);
229  wxTreeItemId m_TreeItemId; // set by the project when building the tree
231  PFDMap m_PFDMap;
232 };
233 WX_DECLARE_HASH_SET ( ProjectFile*, wxPointerHash, wxPointerEqual, FilesList );
234 WX_DEFINE_SORTED_ARRAY( ProjectFile*, ProjectFileArray );
235 
242 {
243  public:
245  void Update(ProjectBuildTarget* target, ProjectFile* pf);
246  // all the members below, are set in the constructor
254  // those below, have no UnixFilename() applied, nor QuoteStringIfNeeded()
266 };
267 
268 #endif // PROJECTFILE_H
FileVisualState
These are valid values for the state of each project file.
Definition: globals.h:81
wxString object_file_flat_native
Definition: projectfile.h:265
wxString object_dir_flat
Definition: projectfile.h:251
int editorTabPos
The position of the editor-tab for this file.
Definition: projectfile.h:178
wxString relativeToCommonTopLevelPath
The relative filename to the common top-level path.
Definition: projectfile.h:135
wxString dep_file
Definition: projectfile.h:249
const wxTreeItemId & GetTreeItemId() const
Returns the wxTreeItemId for the file.
Definition: projectfile.h:210
unsigned short int weight
The weight.
Definition: projectfile.h:145
wxString relativeFilename
The relative (to the project) filename of this file.
Definition: projectfile.h:131
WX_DECLARE_HASH_SET(ProjectFile *, wxPointerHash, wxPointerEqual, FilesList)
ProjectFile * autoGeneratedBy
If this is an auto-generated file, which file is generating it?
Definition: projectfile.h:198
wxString source_file_absolute_native
Definition: projectfile.h:261
wxString object_file
Definition: projectfile.h:248
int editorSplitActive
Last active splitview (1 or 2).
Definition: projectfile.h:154
wxFileName file
The full filename of this file.
Definition: projectfile.h:126
int editorPos_2
The last known caret position in an editor for this file (right/bottom control if split)...
Definition: projectfile.h:169
cbProject * project
Definition: projectfile.h:227
bool compile
Compile flag.
Definition: projectfile.h:138
wxString object_file_native
Definition: projectfile.h:256
wxString object_file_flat_absolute_native
Definition: projectfile.h:263
wxString object_dir_native
Definition: projectfile.h:258
void SetAutoGeneratedBy(ProjectFile *TheFile)
If this is an auto-generated file, set the file which is generating it?
Definition: projectfile.h:204
int editorZoom
The zoom-factor of the editor for this file (left/top control if split).
Definition: projectfile.h:166
Represents a file in a Code::Blocks project.
Definition: projectfile.h:39
int editorPos
The last known caret position in an editor for this file (left/top control if split).
Definition: projectfile.h:160
wxString source_file
Definition: projectfile.h:247
#define DLLIMPORT
Definition: settings.h:16
wxString dep_file_absolute_native
Definition: projectfile.h:264
int editorSplitPos
Last splitter position.
Definition: projectfile.h:157
wxString object_dir_flat_native
Definition: projectfile.h:259
std::vector< ProjectFile * > ProjectFilesVector
Definition: projectfile.h:33
int editorTopLine
The last known caret line in an editor for this file (left/top control if split). ...
Definition: projectfile.h:163
wxTreeItemId m_TreeItemId
Definition: projectfile.h:229
Represents a Code::Blocks project.
Definition: cbproject.h:96
int editorSplit
Split type of the editor as int.
Definition: projectfile.h:151
wxString dep_file_native
Definition: projectfile.h:257
WX_DEFINE_ARRAY_INT(int, editorFoldLinesArray)
pfCustomBuildMap customBuild
A map for custom builds.
Definition: projectfile.h:184
This is a helper class that caches various filenames for one ProjectFile.
Definition: projectfile.h:241
PFDMap m_PFDMap
Definition: projectfile.h:231
int editorTopLine_2
The last known caret line in an editor for this file(right/bottom control if split).
Definition: projectfile.h:172
bool editorOpen
If true, the file is open inside an editor.
Definition: projectfile.h:148
wxString buildCommand
Definition: projectfile.h:28
ProjectFilesVector generatedFiles
Auto-generated files when compiling this file.
Definition: projectfile.h:207
bool useCustomBuildCommand
Definition: projectfile.h:29
wxArray< int > wxArrayInt
wxString compilerVar
The compiler variable used for this file (e.g CPP, CC, etc).
Definition: projectfile.h:187
wxString dep_dir_native
Definition: projectfile.h:260
void SetTreeItemId(wxTreeItemId id)
Sets the tree item id for the file.
Definition: projectfile.h:213
wxString object_dir
Definition: projectfile.h:250
WX_DEFINE_SORTED_ARRAY(ProjectFile *, ProjectFileArray)
wxString object_file_absolute_native
Definition: projectfile.h:262
WX_DECLARE_HASH_MAP(ProjectBuildTarget *, pfDetails *, wxPointerHash, wxPointerEqual, PFDMap)
wxString dep_dir
Definition: projectfile.h:252
FileVisualState m_VisualState
Definition: projectfile.h:228
wxString virtual_path
A string that represents the virtual folder this file will appear in.
Definition: projectfile.h:195
cbProject * GetParentProject()
Definition: projectfile.h:93
int editorZoom_2
The zoom-factor of the editor for this file(right/bottom control if split).
Definition: projectfile.h:175
Represents a Code::Blocks project build target.
ProjectFile * AutoGeneratedBy() const
If this is an auto-generated file, which file is generating it?
Definition: projectfile.h:201
wxArrayInt editorFoldLinesArray
Fold lines.
Definition: projectfile.h:181
wxString source_file_native
Definition: projectfile.h:255
wxString m_ObjName
Definition: projectfile.h:230
wxArrayString buildTargets
An array of strings, containing the names of all the build targets this file belongs to...
Definition: projectfile.h:190
wxString object_file_flat
Definition: projectfile.h:253