| 1 |
#ifndef WXCPROJECTMETADATA_H |
| 2 |
#define WXCPROJECTMETADATA_H |
| 3 |
|
| 4 |
#include "json_node.h" |
| 5 |
#include "wxc_widget.h" |
| 6 |
|
| 7 |
#include <wx/event.h> |
| 8 |
#include <wx/filename.h> |
| 9 |
#include <wx/string.h> |
| 10 |
|
| 11 |
extern const wxEventType wxEVT_CMD_WXCRAFTER_PROJECT_MODIFIED; |
| 12 |
extern const wxEventType wxEVT_CMD_WXCRAFTER_PROJECT_SYNCHED; |
| 13 |
|
| 14 |
class wxcProjectMetadata |
| 15 |
{ |
| 16 |
enum GenerateCodeType { wxcGenerateCPPCode = 1, wxcGenerateXRC }; |
| 17 |
|
| 18 |
protected: |
| 19 |
wxString m_projectFile; |
| 20 |
wxString m_bitmapsFile; |
| 21 |
size_t m_objCounter; |
| 22 |
wxString m_generatedFilesDir; |
| 23 |
wxArrayString m_includeFiles; |
| 24 |
wxFileName m_generatedHeader; // Derived class |
| 25 |
wxFileName m_generatedSource; // Derived class |
| 26 |
wxString m_generatedClassName; // Derived class |
| 27 |
wxString m_virtualFolder; |
| 28 |
wxString m_bitmapFunction; |
| 29 |
int m_GenerateCodeTypes; |
| 30 |
CustomControlTemplateMap_t m_projctCustomControls; |
| 31 |
wxStringMap_t m_additionalFiles; |
| 32 |
wxString m_outputFileName; |
| 33 |
bool m_useHpp; |
| 34 |
int m_firstWindowId; |
| 35 |
bool m_useEnum; |
| 36 |
bool m_useUnderscoreMacro; |
| 37 |
bool m_addHandlers; |
| 38 |
|
| 39 |
private: |
| 40 |
wxcProjectMetadata(); |
| 41 |
virtual ~wxcProjectMetadata(); |
| 42 |
void DoGenerateBitmapFunctionName(); |
| 43 |
wxString DoGenerateBitmapsFile() const; |
| 44 |
|
| 45 |
public: |
| 46 |
/** |
| 47 |
* @brief fix various paths to be relative |
| 48 |
*/ |
| 49 |
void UpdatePaths(); |
| 50 |
|
| 51 |
void SetAddHandlers(bool addHandlers) { this->m_addHandlers = addHandlers; } |
| 52 |
bool IsAddHandlers() const { return m_addHandlers; } |
| 53 |
|
| 54 |
void SetProjctCustomControls(const CustomControlTemplateMap_t& projctCustomControls) |
| 55 |
{ |
| 56 |
this->m_projctCustomControls = projctCustomControls; |
| 57 |
} |
| 58 |
const CustomControlTemplateMap_t& GetProjctCustomControls() const { return m_projctCustomControls; } |
| 59 |
|
| 60 |
static wxcProjectMetadata& Get(); |
| 61 |
void Reset(); |
| 62 |
void ClearAggregatedData(); |
| 63 |
|
| 64 |
void SetFirstWindowId(int firstWindowId) { this->m_firstWindowId = firstWindowId; } |
| 65 |
void SetUseEnum(bool useEnum) { this->m_useEnum = useEnum; } |
| 66 |
int GetFirstWindowId() const { return m_firstWindowId; } |
| 67 |
bool IsUseEnum() const { return m_useEnum; } |
| 68 |
void SetOutputFileName(const wxString& outputFileName) { this->m_outputFileName = outputFileName; } |
| 69 |
wxString GetOutputFileName() const; |
| 70 |
wxString GetHeaderFileExt() const; |
| 71 |
|
| 72 |
bool IsLoaded() const { return m_projectFile.IsEmpty() == false; } |
| 73 |
|
| 74 |
wxString GetCppFileName() const; |
| 75 |
wxString GetHeaderFileName() const; |
| 76 |
wxString GetXrcFileName() const; |
| 77 |
|
| 78 |
void SetBitmapsFile(const wxString& bitmapsFile) { this->m_bitmapsFile = bitmapsFile; } |
| 79 |
|
| 80 |
wxString GetBitmapsFile() const; |
| 81 |
|
| 82 |
void SetAdditionalFiles(const wxStringMap_t& additionalFiles) { this->m_additionalFiles = additionalFiles; } |
| 83 |
const wxStringMap_t& GetAdditionalFiles() const { return m_additionalFiles; } |
| 84 |
void SetGeneratedClassName(const wxString& generatedClassName) { this->m_generatedClassName = generatedClassName; } |
| 85 |
const wxString& GetGeneratedClassName() const { return m_generatedClassName; } |
| 86 |
void SetBitmapFunction(const wxString& bitmapFunction) { this->m_bitmapFunction = bitmapFunction; } |
| 87 |
const wxString& GetBitmapFunction() const { return m_bitmapFunction; } |
| 88 |
void SetVirtualFolder(const wxString& virtualFolder) { this->m_virtualFolder = virtualFolder; } |
| 89 |
const wxString& GetVirtualFolder() const { return m_virtualFolder; } |
| 90 |
void SetGeneratedHeader(const wxFileName& generatedHeader) { this->m_generatedHeader = generatedHeader; } |
| 91 |
void SetGeneratedSource(const wxFileName& generatedSource) { this->m_generatedSource = generatedSource; } |
| 92 |
const wxFileName& GetGeneratedHeader() const { return m_generatedHeader; } |
| 93 |
const wxFileName& GetGeneratedSource() const { return m_generatedSource; } |
| 94 |
void SetIncludeFiles(const wxArrayString& includeFiles) { this->m_includeFiles = includeFiles; } |
| 95 |
const wxArrayString& GetIncludeFiles() const { return m_includeFiles; } |
| 96 |
wxString GetProjectPath() const; |
| 97 |
void SetGeneratedFilesDir(const wxString& generatedFilesDir) { this->m_generatedFilesDir = generatedFilesDir; } |
| 98 |
wxFileName BaseCppFile() const; |
| 99 |
wxFileName BaseHeaderFile() const; |
| 100 |
wxString GetGeneratedFilesDir() const; |
| 101 |
void SetProjectFile(const wxString& filename); |
| 102 |
void SetObjCounter(size_t objCounter) { this->m_objCounter = objCounter; } |
| 103 |
const wxString& GetProjectFile() const { return m_projectFile; } |
| 104 |
wxFileName GetProjectFileName() const { return wxFileName(m_projectFile); } |
| 105 |
size_t GetObjCounter() const { return m_objCounter; } |
| 106 |
|
| 107 |
void SetUseUnderscoreMacro(bool useUnderscoreMacro) { this->m_useUnderscoreMacro = useUnderscoreMacro; } |
| 108 |
bool IsUseUnderscoreMacro() const { return m_useUnderscoreMacro; } |
| 109 |
|
| 110 |
void GenerateBitmapFunctionName() { DoGenerateBitmapFunctionName(); } |
| 111 |
|
| 112 |
void AppendCustomControlsJSON(const wxArrayString& controls, JSONElement& element) const; |
| 113 |
JSONElement ToJSON(); |
| 114 |
void FromJSON(const JSONElement& json); |
| 115 |
|
| 116 |
void SetGenerateCPPCode(bool GenerateCPPCode) |
| 117 |
{ |
| 118 |
GenerateCPPCode ? m_GenerateCodeTypes |= wxcGenerateCPPCode : m_GenerateCodeTypes &= ~wxcGenerateCPPCode; |
| 119 |
} |
| 120 |
void SetGenerateXRC(bool GenerateXRC) |
| 121 |
{ |
| 122 |
GenerateXRC ? m_GenerateCodeTypes |= wxcGenerateXRC : m_GenerateCodeTypes &= ~wxcGenerateXRC; |
| 123 |
} |
| 124 |
bool GetGenerateCPPCode() const { return m_GenerateCodeTypes & wxcGenerateCPPCode; } |
| 125 |
bool GetGenerateXRC() const { return m_GenerateCodeTypes & wxcGenerateXRC; } |
| 126 |
|
| 127 |
/** |
| 128 |
* @brief save list of top level wrappers into filename. In addition this method also saves the |
| 129 |
* an empty project content |
| 130 |
*/ |
| 131 |
void Serialize(const wxcWidget::List_t& topLevelsList, const wxFileName& filename); |
| 132 |
}; |
| 133 |
|
| 134 |
#endif // WXCPROJECTMETADATA_H |