www.pudn.com > TurboPadSource.tar.gz > project.h


/** 
*    \class Project 
*    Project Class 
* 
*    Handles all aspects of project files. 
*    \todo Modify Line private function to modify a project file line. 
*    \todo Make SetName and SetPath update the project file with the 
*       new information. 
*/ 
 
#ifndef Project_H 
#define Project_H 
 
#include  
#include  
 
WX_DEFINE_ARRAY(wxWindow*, WPtrArray); 
 
enum PrjErr 
{ 
    None, 
    DoesntExist, 
    OpenFile, 
    Parse 
}; 
 
class Project 
{ 
    public: 
        Project();                                                     // Default ctor, call Create() || Load() 
        Project(const wxString &fileName);                             // Ctor from existing file 
        Project(const wxString &prjName, const wxString &prjPath);     // Ctor creating a new file 
 
        bool IsOpen();                                      // Check to see if a project is open 
        bool Ready();                                       // Check to see if the project is ready 
 
        bool Create(const wxString &prjName, const wxString &prjPath);  // Create a new project file 
        PrjErr Load(const wxString &fileName);                          // Load a project from a file 
        void Close();                                                   // Close the current project 
 
        void AddFile(const wxString &fileName, bool upd = true);  // Add file to project file 
        void AddFrame(wxWindow* frame);                           // Add frame to array of pointers 
        void UpdateFileCount();                                   // Update the file count 
 
        int GetNumFiles() { return numFiles; }               // Returns number of files in project 
        wxArrayString& GetFiles() { return files; }          // Returns array of files 
        wxString GetBuildCommand() { return buildCommand; }  // Returns the build command for the project 
        wxString GetName() { return name; }                  // Returns project name 
        wxString GetPath() { return path; }                  // Returns path of project file 
 
        void SetBuildCommand(wxString newBuildCommand); 
        void SetName(wxString newName); 
        void SetPath(wxString newPath); 
 
        wxString& GetFile(int index) { return files[index]; } 
        WPtrArray& GetFrames() { return frames; } 
        wxWindow* GetFrame(int index) { return frames[index]; } 
 
    private: 
        wxString name;           // Project name 
        wxString path;           // Project path 
        wxString buildCommand;   // Build command for the current project 
        long numFiles;           // Number of files in the project 
 
        wxTextFile prjFile; 
 
        WPtrArray frames;       // Array of pointers to project frames 
        wxArrayString files;    // Array of filenames (corresponds to frames) 
 
        inline void RemoveWhitespace(wxString &str); 
}; 
 
#endif