~registry/codeblocks/trunk

« back to all changes in this revision

Viewing changes to src/sdk/projectfile.h

  • Committer: mandrav
  • Date: 2007-02-12 14:55:28 UTC
  • Revision ID: svn-v4:98b59c6a-2706-0410-b7d6-d2fa1a1880c9:trunk:3594
* First part of directories layout re-organization: moved all sdk header files to a new dir named "include".

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#ifndef PROJECTFILE_H
2
 
#define PROJECTFILE_H
3
 
 
4
 
#include "settings.h"
5
 
#include "globals.h"
6
 
#include <wx/dynarray.h>
7
 
#include <wx/filename.h>
8
 
#include <wx/list.h>
9
 
#include <wx/treectrl.h>
10
 
 
11
 
#include "blockallocated.h"
12
 
 
13
 
class cbProject;
14
 
class ProjectBuildTarget;
15
 
class pfDetails;
16
 
 
17
 
WX_DECLARE_HASH_MAP(ProjectBuildTarget*, pfDetails*, wxPointerHash, wxPointerEqual, PFDMap);
18
 
 
19
 
struct pfCustomBuild
20
 
{
21
 
    pfCustomBuild() : useCustomBuildCommand(false) {}
22
 
    wxString buildCommand;
23
 
    bool useCustomBuildCommand;
24
 
};
25
 
WX_DECLARE_HASH_MAP(wxString, pfCustomBuild, wxStringHash, wxStringEqual, pfCustomBuildMap);
26
 
 
27
 
/** Represents a file in a Code::Blocks project. */
28
 
class ProjectFile  : public BlockAllocated<ProjectFile, 1000>
29
 
{
30
 
    public:
31
 
        /// Constructor
32
 
        ProjectFile(cbProject* prj);
33
 
        /// Destructor
34
 
        ~ProjectFile();
35
 
 
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);
39
 
 
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);
46
 
 
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);
50
 
 
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".
54
 
          */
55
 
        bool ShowOptions(wxWindow* parent);
56
 
 
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
60
 
 
61
 
        /** @return The generated object filename. */
62
 
        const wxString& GetObjName(); // returns sdk/cbProject.o
63
 
 
64
 
        /** Set the generated object filename.
65
 
          * @param name The filename for the generated object. */
66
 
        void SetObjName(const wxString& name);
67
 
 
68
 
        /** @return The parent project. */
69
 
        cbProject* GetParentProject(){ return project; }
70
 
 
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);
74
 
 
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);
79
 
 
80
 
        /** Set the visual state (modified, read-only, etc).
81
 
          * @param state The new visual state. */
82
 
                void SetFileState(FileVisualState state);
83
 
 
84
 
        /** @return The visual state (modified, read-only, etc). */
85
 
                FileVisualState GetFileState() const;
86
 
 
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
90
 
          */
91
 
        wxFileName file;
92
 
 
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
96
 
          */
97
 
        wxString relativeFilename;
98
 
 
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;
102
 
 
103
 
        /** Compile flag. If it's true, the file is compiled (generates object file) else it is not. */
104
 
        bool compile;
105
 
 
106
 
        /** Link flag. If it's true, the (generated object) file is linked else it is not. */
107
 
        bool link;
108
 
 
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;
112
 
 
113
 
        /** If true, the file is open inside an editor. */
114
 
        bool editorOpen; // layout info
115
 
 
116
 
        /** The last known caret position in an editor for this file. */
117
 
        int editorPos; // layout info
118
 
 
119
 
        /** The last known caret line in an editor for this file. */
120
 
        int editorTopLine; // layout info
121
 
 
122
 
                /** The position of the editor-tab for this file. */
123
 
                int editorTabPos; // layout info
124
 
 
125
 
        /** A map for custom builds. Key is compiler ID, value is pfCustomBuild struct. */
126
 
        pfCustomBuildMap customBuild;
127
 
 
128
 
        /** The compiler variable used for this file (e.g CPP, CC, etc). */
129
 
        wxString compilerVar;
130
 
 
131
 
        /** An array of strings, containing the names of all the build targets this file belongs to. */
132
 
        wxArrayString buildTargets;
133
 
 
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
136
 
          * hierarchy. */
137
 
        wxString virtual_path;
138
 
    protected:
139
 
        friend class cbProject;
140
 
        void DoUpdateFileDetails(ProjectBuildTarget* target);
141
 
        cbProject* project;
142
 
        FileVisualState m_VisualState;
143
 
        wxTreeItemId m_TreeItemId; // set by the project when building the tree
144
 
        wxString m_ObjName;
145
 
        PFDMap m_PFDMap;
146
 
};
147
 
WX_DECLARE_LIST(ProjectFile, FilesList);
148
 
 
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...
153
 
  */
154
 
class pfDetails : public BlockAllocated<pfDetails, 1000>
155
 
{
156
 
    public:
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;
162
 
        wxString dep_file;
163
 
        wxString object_dir;
164
 
        wxString dep_dir;
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;
177
 
};
178
 
 
179
 
#endif // PROJECTFILE_H