~ubuntu-branches/ubuntu/trusty/codeblocks/trusty-proposed

« back to all changes in this revision

Viewing changes to src/include/cbproject.h

  • Committer: Package Import Robot
  • Author(s): Vincent Cheng
  • Date: 2013-05-06 00:20:02 UTC
  • mfrom: (6.1.2 experimental)
  • Revision ID: package-import@ubuntu.com-20130506002002-ngc7bwkewnak8fja
Tags: 12.11-3
* Upload to unstable.
* Update watch file, thanks to Bart Martens.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
#include "compiletargetbase.h"
17
17
#include "cbplugin.h"
18
18
#include "projectbuildtarget.h"
 
19
#include "projectmanager.h"
19
20
 
20
21
#include <map>
 
22
#include <vector>
21
23
 
22
24
// forward decl
23
25
class cbProject;
80
82
  */
81
83
enum PCHMode
82
84
{
83
 
    pchSourceDir = 0,   /// In a dir (named by the PCH) on the same level as the source header (default).
84
 
    pchObjectDir,       /// In the objects output dir, along with other object files.
85
 
    pchSourceFile,      /// In a file alongside the source header (with .gch appended).
 
85
    pchSourceDir = 0, /// In a dir (named by the PCH) on the same level as the source header (default).
 
86
    pchObjectDir,     /// In the objects output dir, along with other object files.
 
87
    pchSourceFile     /// In a file alongside the source header (with .gch appended).
86
88
};
87
89
 
88
90
/** @brief Represents a Code::Blocks project.
105
107
        /** (Re)build the project tree.
106
108
          * @param tree The wxTreeCtrl to use.
107
109
          * @param root The tree item to use as root. The project is built as a child of this item.
108
 
          * @param categorize If true, use virtual folders like "Sources", "Headers", etc.
109
 
          * @param useFolders If true, create folders as needed. If false, the list is flat.
 
110
          * @param ptvs The visual style of the project tree
110
111
          * @param fgam If not NULL, use these file groups and masks for virtual folders.
111
112
          */
112
 
        void BuildTree(wxTreeCtrl* tree, const wxTreeItemId& root, bool categorize, bool useFolders, FilesGroupsAndMasks* fgam = 0L);
 
113
        void BuildTree(cbTreeCtrl* tree, const wxTreeItemId& root, int ptvs, FilesGroupsAndMasks* fgam = 0L);
113
114
 
114
115
        /** This resets the project to a clear state. Like it's just been new'ed. */
115
116
        void ClearAllProperties();
146
147
        ProjectFile* GetFileByFilename(const wxString& filename, bool isRelative = true, bool isUnixFilename = false);
147
148
 
148
149
        /** @return The number of files in the project. */
149
 
        int GetFilesCount(){ return m_Files.GetCount(); }
 
150
        int GetFilesCount(){ return m_Files.size(); }
150
151
 
151
152
        /** Set the Makefile filename used when exporting a Makefile for the project,
152
153
          * or when using a custom Makefile to build the project.
204
205
        void SetDefaultExecuteTarget(const wxString& name);
205
206
 
206
207
        /** @return The number of build targets this project contains. */
207
 
        int GetBuildTargetsCount(){ return m_Targets.GetCount(); }
 
208
        int GetBuildTargetsCount() { return m_Targets.GetCount(); }
208
209
 
209
210
        /** Access a build target.
210
211
          * @param index The build target index. Must be greater or equal to zero and less than GetBuildTargetsCount().
326
327
        /** Close all project files.
327
328
          * @param dontsave If true, no project file will be saved even if modified.
328
329
          * If false, any modified file will be saved (default).
329
 
          * @return True if succesfull, false otherwise.
 
330
          * @return True if successful, false otherwise.
330
331
          */
331
332
        bool CloseAllFiles(bool dontsave=false);
332
333
 
333
334
        /** Save all project files.
334
 
          * @return True if succesfull, false otherwise.
 
335
          * @return True if successful, false otherwise.
335
336
          */
336
337
        bool SaveAllFiles();
337
338
 
338
339
        /** Save the project.
339
 
          * @return True if succesfull, false otherwise.
 
340
          * @return True if successful, false otherwise.
340
341
          */
341
342
        bool Save();
342
343
 
343
344
        /** Save the project under a different name.
344
345
          * A dialog pops up for the user to choose a new filename for the project.
345
 
          * @return True if succesfull, false otherwise.
 
346
          * @return True if successful, false otherwise.
346
347
          */
347
348
        bool SaveAs();
348
349
 
349
350
        /** Save the project's layout.
350
351
          * Layout is the list of open project files, which one is active,
351
352
          * where the cursor is located on each one of those, etc.
352
 
          * @return True if succesfull, false otherwise.
 
353
          * @return True if successful, false otherwise.
353
354
          */
354
355
        bool SaveLayout();
355
356
 
356
357
        /** Load the project's layout.
357
358
          * @see SaveLayout() for info.
358
 
          * @return True if succesfull, false otherwise.
 
359
          * @return True if successful, false otherwise.
359
360
          */
360
361
        bool LoadLayout();
361
 
        
 
362
 
362
363
        /** Notify that file(s) will be added shortly.
363
364
          * This function should be called before calling AddFile().
364
365
          * When done calling AddFile() as many times as needed, call
367
368
          * This sequence of function calls ensures proper events dispatching.
368
369
          * This function broadcasts the cbEVT_PROJECT_BEGIN_ADD_FILES event.
369
370
          */
370
 
                void BeginAddFiles();
 
371
        void BeginAddFiles();
371
372
 
372
373
        /** Notify that file(s) addition finished.
373
374
          * This function should be called when done calling AddFile() as many times as needed.
376
377
          * This function broadcasts the cbEVT_PROJECT_END_ADD_FILES event.
377
378
          * @see BeginAddFiles().
378
379
          */
379
 
                void EndAddFiles();
 
380
        void EndAddFiles();
380
381
 
381
382
        /** Notify that file(s) will be removed shortly.
382
383
          * This function should be called before calling RemoveFile().
386
387
          * This sequence of function calls ensures proper events dispatching.
387
388
          * This function broadcasts the cbEVT_PROJECT_BEGIN_REMOVE_FILES event.
388
389
          */
389
 
                void BeginRemoveFiles();
 
390
        void BeginRemoveFiles();
390
391
 
391
392
        /** Notify that file(s) removal finished.
392
393
          * This function should be called when done calling RemoveFile() as many times as needed.
395
396
          * This function broadcasts the cbEVT_PROJECT_END_REMOVE_FILES event.
396
397
          * @see BeginRemoveFiles().
397
398
          */
398
 
                void EndRemoveFiles();
 
399
        void EndRemoveFiles();
399
400
 
400
401
        /** Add a file to the project.
401
402
          * This variation, takes a target name as first parameter.
420
421
        ProjectFile* AddFile(int targetIndex, const wxString& filename, bool compile = true, bool link = true, unsigned short int weight = 50);
421
422
 
422
423
        /** Remove a file from the project.
423
 
          * @param index The index of the file.
424
 
          * @return True if @c index was valid, false if not.
425
 
          */
426
 
        bool RemoveFile(int index);
427
 
 
428
 
        /** Remove a file from the project.
429
424
          * @param pf The pointer to ProjectFile.
430
425
          * @return True if @c pf was a valid project file, false if not.
431
426
          */
432
427
        bool RemoveFile(ProjectFile* pf);
433
428
 
 
429
        struct Glob
 
430
        {
 
431
            wxString m_Path;
 
432
            wxString m_WildCard;
 
433
            bool m_Recursive;
 
434
            Glob(const wxString& path, const wxString& wildCard, bool recursive) : m_Path(path), m_WildCard(wildCard), m_Recursive(recursive) {}
 
435
        };
 
436
 
 
437
        /** Set the globs to the project, this are directory paths do retrieve files from to be added to the project, the path can be searched recursively
 
438
          * @param globs the globs to add to the project.
 
439
        */
 
440
        void SetGlobs(const std::vector<Glob>& globs);
 
441
 
 
442
        /** Retrieve the current globs from the project
 
443
          * @return globs the globs to add to the project.
 
444
        */
 
445
        std::vector<Glob> GetGlobs() const;
 
446
 
434
447
        /** Display the project options dialog.
435
448
          * @return True if the dialog was closed with "OK", false if closed with "Cancel".
436
449
          */
439
452
        /** Convenience function for remembering the project's tree state when refreshing it.
440
453
          * @return An array of strings containing the tree-path names of expanded nodes.
441
454
          */
442
 
        const wxArrayString& ExpandedNodes(){ return m_ExpandedNodes; }
 
455
        const wxArrayString& ExpandedNodes() { return m_ExpandedNodes; }
443
456
 
444
457
        /** Convenience function for remembering the project's tree state when refreshing it.
445
458
          * Adds an expanded node in this internal list.
446
459
          * @param path The tree-path to add.
447
460
          */
448
 
        void AddExpandedNode(const wxString& path){ m_ExpandedNodes.Add(path); }
 
461
        void AddExpandedNode(const wxString& path) { m_ExpandedNodes.Add(path); }
449
462
 
450
463
        /** Convenience function for remembering the project's tree state when refreshing it.
451
464
          * @param tree The tree control to save its expanded state.
478
491
          * @return While the project is being built, this function returns the currently building
479
492
          * target. For all other times, NULL is returned.
480
493
          */
481
 
        ProjectBuildTarget* GetCurrentlyCompilingTarget(){ return m_CurrentlyCompilingTarget; }
 
494
        ProjectBuildTarget* GetCurrentlyCompilingTarget() { return m_CurrentlyCompilingTarget; }
482
495
 
483
496
        /** Set the currently compiling target.
484
497
          * @note This function is for internal use by compilers only.
558
571
          */
559
572
        bool CanDragNode(wxTreeCtrl* tree, wxTreeItemId node);
560
573
 
561
 
        /** Notify that a specific tree node has been dragged.
 
574
        /** Notify that an array of tree nodes has been dragged.
562
575
          *
563
576
          * @note Called by ProjectManager.
564
577
          * @return True if succeeded, false if not.
565
578
          */
566
 
        bool NodeDragged(wxTreeCtrl* tree, wxTreeItemId from, wxTreeItemId to);
 
579
        bool NodeDragged(wxTreeCtrl* tree, wxArrayTreeItemIds& fromArray, wxTreeItemId to);
567
580
 
568
581
        /** Notify that a virtual folder has been added.
569
582
          * @return True if it is allowed, false if not. */
678
691
          * instead of re-using the existing one (if any).
679
692
          */
680
693
        virtual void AddToExtensions(const wxString& stringDesc);
681
 
        
 
694
 
682
695
        /** Internal use only.
683
696
          * Updates the internal hashmap of project files.
684
697
          */
685
698
        virtual void ProjectFileRenamed(ProjectFile* pf);
686
699
 
 
700
        /** Provides an easy way to iterate all the files belonging in this target.
 
701
          * @return A list of files belonging in this target.
 
702
          */
 
703
        virtual FilesList& GetFilesList(){ return m_Files; }
 
704
 
687
705
    private:
688
706
        void Open();
689
707
        void ExpandVirtualBuildTargetGroup(const wxString& alias, wxArrayString& result) const;
695
713
        void NotifyPlugins(wxEventType type, const wxString& targetName = wxEmptyString, const wxString& oldTargetName = wxEmptyString);
696
714
        void CopyTreeNodeRecursively(wxTreeCtrl* tree, const wxTreeItemId& item, const wxTreeItemId& new_parent);
697
715
        bool VirtualFolderDragged(wxTreeCtrl* tree, wxTreeItemId from, wxTreeItemId to);
 
716
        void SortChildrenRecursive(cbTreeCtrl* tree, const wxTreeItemId& parent);
698
717
 
699
718
        // properties
700
719
        VirtualBuildTargetsMap m_VirtualTargets;
701
 
        BuildTargets m_Targets;
702
 
        wxString m_ActiveTarget;
703
 
        wxString  m_LastSavedActiveTarget;
704
 
        wxString m_DefaultExecuteTarget;
705
 
        wxString m_Makefile;
706
 
        bool m_CustomMakefile;
707
 
        mutable wxString m_MakefileExecutionDir;
 
720
        BuildTargets           m_Targets;
 
721
        wxString               m_ActiveTarget;
 
722
        wxString               m_LastSavedActiveTarget;
 
723
        wxString               m_DefaultExecuteTarget;
 
724
        wxString               m_Makefile;
 
725
        bool                   m_CustomMakefile;
 
726
        mutable wxString       m_MakefileExecutionDir;
708
727
 
709
 
        FilesList m_Files;
710
 
        wxArrayString m_ExpandedNodes;
711
 
        bool m_Loaded;
712
 
        wxTreeItemId m_ProjectNode;
 
728
        std::vector<Glob> m_Globs;
 
729
        FilesList         m_Files;
 
730
        ProjectFileArray  m_FileArray;
 
731
        wxArrayString     m_ExpandedNodes;
 
732
        wxArrayString     m_SelectedNodes;
 
733
        bool              m_Loaded;
 
734
        wxTreeItemId      m_ProjectNode;
713
735
 
714
736
        wxArrayString m_VirtualFolders; // not saved, just used throughout cbProject's lifetime
715
737
 
716
 
        bool m_CurrentlyLoading;
 
738
        bool     m_CurrentlyLoading;
717
739
        wxString m_CommonTopLevelPath;
718
740
        wxString m_BasePath;
719
741
 
720
742
        PCHMode m_PCHMode;
721
743
 
722
744
        // hashmap for fast searches in cbProject::GetFileByFilename()
723
 
        ProjectFiles m_ProjectFilesMap; // keeps UnixFilename(ProjectFile::relativeFilename)
 
745
        ProjectFiles        m_ProjectFilesMap; // keeps UnixFilename(ProjectFile::relativeFilename)
724
746
        ProjectBuildTarget* m_CurrentlyCompilingTarget;
725
747
 
726
748
        wxDateTime m_LastModified;
727
749
 
728
 
        bool m_ExtendedObjectNamesGeneration;
 
750
        bool     m_ExtendedObjectNamesGeneration;
729
751
        wxString m_Notes;
730
 
        bool m_AutoShowNotesOnLoad;
 
752
        bool     m_AutoShowNotesOnLoad;
731
753
 
732
754
        // copy of <Extensions> element, in case certain plugins are disabled
733
755
        // so that the contents are not lost