diff --git a/extras/Introjucer/Source/Application/jucer_MainWindow.cpp b/extras/Introjucer/Source/Application/jucer_MainWindow.cpp index ffffd1d03c..bfd7abf7e6 100644 --- a/extras/Introjucer/Source/Application/jucer_MainWindow.cpp +++ b/extras/Introjucer/Source/Application/jucer_MainWindow.cpp @@ -285,7 +285,7 @@ void MainWindow::updateTitle (const String& documentName) void MainWindow::showNewProjectWizard() { jassert (currentProject == nullptr); - setContentOwned (NewProjectWizard::createComponent(), true); + setContentOwned (createNewProjectWizardComponent(), true); makeVisible(); } diff --git a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_MSVC.h b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_MSVC.h index 6142af0b8b..eae8ad6f36 100644 --- a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_MSVC.h +++ b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_MSVC.h @@ -39,11 +39,7 @@ public: if (getTargetLocationString().isEmpty()) getTargetLocationValue() = getDefaultBuildsRootFolder() + folderName; - if ((int) getLibraryType().getValue() <= 0) - getLibraryType() = 1; - projectGUID = createGUID (project.getProjectUID()); - updateOldSettings(); } @@ -61,16 +57,8 @@ public: #endif } - void createExporterProperties (PropertyListBuilder& props) + void createExporterProperties (PropertyListBuilder&) { - if (projectType.isLibrary()) - { - const char* const libTypes[] = { "Static Library (.lib)", "Dynamic Library (.dll)", nullptr }; - const int libTypeValues[] = { 1, 2 }; - props.add (new ChoicePropertyComponent (getLibraryType(), "Library Type", - StringArray (libTypes), - Array (libTypeValues, numElementsInArray (libTypeValues)))); - } } protected: @@ -78,11 +66,9 @@ protected: mutable File rcFile, iconFile; File getProjectFile (const String& extension) const { return getTargetFolder().getChildFile (project.getProjectFilenameRoot()).withFileExtension (extension); } - File getSLNFile() const { return getProjectFile (".sln"); } + File getSLNFile() const { return getProjectFile (".sln"); } - Value getLibraryType() { return getSetting (Ids::libraryType); } - String getLibraryString() const { return getSettingString (Ids::libraryType); } - bool isLibraryDLL() const { return msvcIsDLL || (projectType.isLibrary() && (int) settings [Ids::libraryType] == 2); } + bool isLibraryDLL() const { return msvcIsDLL || projectType.isDynamicLibrary(); } static String prependIfNotAbsolute (const String& file, const char* prefix) { @@ -435,7 +421,7 @@ protected: bool hasResourceFile() const { - return ! projectType.isLibrary(); + return ! projectType.isStaticLibrary(); } void createResourcesAndIcon() const @@ -684,7 +670,8 @@ protected: const RelativePath path (projectItem.getFile(), getTargetFolder(), RelativePath::buildTargetFolder); addFile (path, parent, - projectItem.shouldBeAddedToBinaryResources() || (shouldFileBeCompiledByDefault (path) && ! projectItem.shouldBeCompiled()), + projectItem.shouldBeAddedToBinaryResources() + || (shouldFileBeCompiledByDefault (path) && ! projectItem.shouldBeCompiled()), shouldFileBeCompiledByDefault (path) && (bool) projectItem.shouldUseStdCall()); } } @@ -718,7 +705,7 @@ protected: if (config.getIntermediatesPath().isNotEmpty()) xml.setAttribute ("IntermediateDirectory", FileHelpers::windowsStylePath (config.getIntermediatesPath())); - xml.setAttribute ("ConfigurationType", isLibraryDLL() ? "2" : (projectType.isLibrary() ? "4" : "1")); + xml.setAttribute ("ConfigurationType", isLibraryDLL() ? "2" : (projectType.isStaticLibrary() ? "4" : "1")); xml.setAttribute ("UseOfMFC", "0"); xml.setAttribute ("ATLMinimizesCRunTimeLibraryUsage", "false"); xml.setAttribute ("CharacterSet", "2"); @@ -738,7 +725,7 @@ protected: createToolElement (xml, "VCXMLDataGeneratorTool"); createToolElement (xml, "VCWebServiceProxyGeneratorTool"); - if (! projectType.isLibrary()) + if (! projectType.isStaticLibrary()) { XmlElement* midl = createToolElement (xml, "VCMIDLTool"); midl->setAttribute ("PreprocessorDefinitions", isDebug ? "_DEBUG" : "NDEBUG"); @@ -757,7 +744,7 @@ protected: if (isDebug) { compiler->setAttribute ("BufferSecurityCheck", ""); - compiler->setAttribute ("DebugInformationFormat", projectType.isLibrary() ? "3" : "4"); + compiler->setAttribute ("DebugInformationFormat", projectType.isStaticLibrary() ? "3" : "4"); } else { @@ -792,7 +779,7 @@ protected: createToolElement (xml, "VCPreLinkEventTool"); - if (! projectType.isLibrary()) + if (! projectType.isStaticLibrary()) { XmlElement* linker = createToolElement (xml, "VCLinkerTool"); @@ -870,7 +857,7 @@ protected: createToolElement (xml, "VCFxCopTool"); - if (! projectType.isLibrary()) + if (! projectType.isStaticLibrary()) createToolElement (xml, "VCAppVerifierTool"); XmlElement* postBuildEvent = createToolElement (xml, "VCPostBuildEventTool"); @@ -1331,7 +1318,7 @@ protected: { if (projectType.isGUIApplication() || projectType.isCommandLineApp()) return "Application"; if (isLibraryDLL()) return "DynamicLibrary"; - if (projectType.isLibrary()) return "StaticLibrary"; + if (projectType.isStaticLibrary()) return "StaticLibrary"; jassertfalse; return String::empty; diff --git a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Make.h b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Make.h index 61bc95eb30..c03fac8c31 100644 --- a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Make.h +++ b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Make.h @@ -230,14 +230,14 @@ private: String targetName (config.getTargetBinaryNameString()); - if (projectType.isLibrary()) + if (projectType.isStaticLibrary() || projectType.isDynamicLibrary()) targetName = getLibbedFilename (targetName); else targetName = targetName.upToLastOccurrenceOf (".", false, false) + makefileTargetSuffix; out << " TARGET := " << escapeSpaces (targetName) << newLine; - if (projectType.isLibrary()) + if (projectType.isStaticLibrary()) out << " BLDCMD = ar -rcs $(OUTDIR)/$(TARGET) $(OBJECTS) $(TARGET_ARCH)" << newLine; else out << " BLDCMD = $(CXX) -o $(OUTDIR)/$(TARGET) $(OBJECTS) $(LDFLAGS) $(RESOURCES) $(TARGET_ARCH)" << newLine; @@ -267,7 +267,7 @@ private: << "endif" << newLine << newLine; - if (! projectType.isLibrary()) + if (! projectType.isStaticLibrary()) out << "ifeq ($(TARGET_ARCH),)" << newLine << " TARGET_ARCH := -march=native" << newLine << "endif" << newLine << newLine; diff --git a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_XCode.h b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_XCode.h index 66f6b88bed..f76ad02c81 100644 --- a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_XCode.h +++ b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_XCode.h @@ -124,14 +124,6 @@ public: "A comma-separated list of extra frameworks that should be added to the build. " "(Don't include the .framework extension in the name)"); - if (projectType.isLibrary()) - { - const char* const libTypes[] = { "Static Library (.a)", "Dynamic Library (.dylib)", 0 }; - const int libTypeValues[] = { 1, 2, 0 }; - props.add (new ChoicePropertyComponent (getLibraryType(), "Library Type", - StringArray (libTypes), Array (libTypeValues))); - } - props.add (new TextPropertyComponent (getPreBuildScriptValue(), "Pre-build shell script", 32768, true), "Some shell-script that will be run before a build starts."); @@ -173,10 +165,6 @@ public: } protected: - Value getLibraryType() { return getSetting (Ids::libraryType); } - bool isStaticLibrary() const { return projectType.isLibrary() && (int) settings [Ids::libraryType] == 1; } - - //============================================================================== class XcodeBuildConfiguration : public BuildConfiguration { @@ -366,7 +354,7 @@ private: addShellScriptBuildPhase ("Pre-build script", getPreBuildScript()); - if (! isStaticLibrary()) + if (! projectType.isStaticLibrary()) addBuildPhase ("PBXResourcesBuildPhase", resourceIDs); if (rezFileIDs.size() > 0) @@ -374,7 +362,7 @@ private: addBuildPhase ("PBXSourcesBuildPhase", sourceIDs); - if (! isStaticLibrary()) + if (! projectType.isStaticLibrary()) addBuildPhase ("PBXFrameworksBuildPhase", frameworkIDs); addShellScriptBuildPhase ("Post-build script", getPostBuildScript()); @@ -637,7 +625,7 @@ private: s.add ("WARNING_CFLAGS = -Wreorder"); s.add ("GCC_MODEL_TUNING = G5"); - if (projectType.isLibrary()) + if (projectType.isStaticLibrary()) { s.add ("GCC_INLINES_ARE_PRIVATE_EXTERN = NO"); s.add ("GCC_SYMBOLS_PRIVATE_EXTERN = NO"); @@ -711,12 +699,6 @@ private: s.add ("CONFIGURATION_BUILD_DIR = \"$(PROJECT_DIR)/build/$(CONFIGURATION)\""); } - if (projectType.isLibrary()) - { - s.add ("CONFIGURATION_BUILD_DIR = \"$(BUILD_DIR)\""); - s.add ("DEPLOYMENT_LOCATION = YES"); - } - String gccVersion ("com.apple.compilers.llvm.clang.1_0"); if (! iOS) @@ -823,7 +805,7 @@ private: void addFrameworks() const { - if (! isStaticLibrary()) + if (! projectType.isStaticLibrary()) { StringArray s (xcodeFrameworks); s.addTokens (getExtraFrameworksString(), ",;", "\"'"); diff --git a/extras/Introjucer/Source/Project/jucer_NewProjectWizard.cpp b/extras/Introjucer/Source/Project/jucer_NewProjectWizard.cpp index 0fc7e10437..c656e24845 100644 --- a/extras/Introjucer/Source/Project/jucer_NewProjectWizard.cpp +++ b/extras/Introjucer/Source/Project/jucer_NewProjectWizard.cpp @@ -30,534 +30,609 @@ #include "../Application/jucer_Application.h" #include "../Application/jucer_MainWindow.h" -static void createFileCreationOptionComboBox (Component& setupComp, - OwnedArray& itemsCreated, - const char** fileOptions) + +struct NewProjectWizardClasses { - ComboBox* c = new ComboBox(); - itemsCreated.add (c); - setupComp.addChildAndSetID (c, "filesToCreate"); - - c->addItemList (StringArray (fileOptions), 1); - c->setSelectedId (1, false); - - Label* l = new Label (String::empty, "Files to Auto-Generate:"); - l->attachToComponent (c, true); - itemsCreated.add (l); - - c->setBounds ("parent.width / 2 + 160, 10, parent.width - 10, top + 22"); -} - -static void setExecutableNameForAllTargets (Project& project, const String& exeName) -{ - for (Project::ExporterIterator exporter (project); exporter.next();) - for (ProjectExporter::ConfigIterator config (*exporter); config.next();) - config->getTargetBinaryName() = exeName; -} - -//============================================================================== -class GUIAppWizard : public NewProjectWizard -{ -public: - GUIAppWizard() {} - - String getName() { return "GUI Application"; } - String getDescription() { return "Creates a standard application"; } - - void addSetupItems (Component& setupComp, OwnedArray& itemsCreated) + //============================================================================== + static void createFileCreationOptionComboBox (Component& setupComp, + OwnedArray& itemsCreated, + const StringArray& fileOptions) { - const char* fileOptions[] = { "Create a Main.cpp file", - "Create a Main.cpp file and a basic window", - "Don't create any files", 0 }; + ComboBox* c = new ComboBox(); + itemsCreated.add (c); + setupComp.addChildAndSetID (c, "filesToCreate"); - createFileCreationOptionComboBox (setupComp, itemsCreated, fileOptions); + c->addItemList (fileOptions, 1); + c->setSelectedId (1, false); + + Label* l = new Label (String::empty, TRANS("Files to Auto-Generate") + ":"); + l->attachToComponent (c, true); + itemsCreated.add (l); + + c->setBounds ("parent.width / 2 + 160, 10, parent.width - 10, top + 22"); } - Result processResultsFromSetupItems (Component& setupComp) + static int getFileCreationComboResult (Component& setupComp) { - ComboBox* cb = dynamic_cast (setupComp.findChildWithID ("filesToCreate")); - jassert (cb != nullptr); - createMainCpp = createWindow = false; + if (ComboBox* cb = dynamic_cast (setupComp.findChildWithID ("filesToCreate"))) + return cb->getSelectedItemIndex(); - switch (cb->getSelectedItemIndex()) + jassertfalse; + return 0; + } + + static void setExecutableNameForAllTargets (Project& project, const String& exeName) + { + for (Project::ExporterIterator exporter (project); exporter.next();) + for (ProjectExporter::ConfigIterator config (*exporter); config.next();) + config->getTargetBinaryName() = exeName; + } + + static Project::Item createSourceGroup (Project& project) + { + return project.getMainGroup().addNewSubGroup ("Source", 0); + } + + static File& getLastWizardFolder() + { + #if JUCE_WINDOWS + static File lastFolder (File::getSpecialLocation (File::userDocumentsDirectory)); + #else + static File lastFolder (File::getSpecialLocation (File::userHomeDirectory)); + #endif + + return lastFolder; + } + + //============================================================================== + struct NewProjectWizard + { + NewProjectWizard() {} + virtual ~NewProjectWizard() {} + + //============================================================================== + virtual String getName() = 0; + virtual String getDescription() = 0; + + virtual void addSetupItems (Component&, OwnedArray&) {} + virtual Result processResultsFromSetupItems (Component&) { return Result::ok(); } + + virtual bool initialiseProject (Project& project) = 0; + + String appTitle; + File targetFolder, projectFile; + Component* ownerWindow; + StringArray failedFiles; + + //============================================================================== + Project* runWizard (Component* window, + const String& projectName, + const File& target) { - case 0: createMainCpp = true; break; - case 1: createMainCpp = createWindow = true; break; - case 2: break; - default: jassertfalse; break; - } + ownerWindow = window; + appTitle = projectName; + targetFolder = target; - return Result::ok(); - } - - bool initialiseProject (Project& project) - { - if (! getSourceFilesFolder().createDirectory()) - failedFiles.add (getSourceFilesFolder().getFullPathName()); - - File mainCppFile = getSourceFilesFolder().getChildFile ("Main.cpp"); - File contentCompCpp = getSourceFilesFolder().getChildFile ("MainComponent.cpp"); - File contentCompH = contentCompCpp.withFileExtension (".h"); - String contentCompName = "MainContentComponent"; - - project.getProjectTypeValue() = ProjectType::getGUIAppTypeName(); - - Project::Item sourceGroup (project.getMainGroup().addNewSubGroup ("Source", 0)); - - setExecutableNameForAllTargets (project, File::createLegalFileName (appTitle)); - - String appHeaders (CodeHelpers::createIncludeStatement (project.getAppIncludeFile(), mainCppFile)); - - if (createWindow) - { - appHeaders << newLine << CodeHelpers::createIncludeStatement (contentCompH, mainCppFile); - - String windowH = project.getFileTemplate ("jucer_ContentCompTemplate_h") - .replace ("INCLUDE_JUCE", CodeHelpers::createIncludeStatement (project.getAppIncludeFile(), contentCompH), false) - .replace ("CONTENTCOMPCLASS", contentCompName, false) - .replace ("HEADERGUARD", CodeHelpers::makeHeaderGuardName (contentCompH), false); - - String windowCpp = project.getFileTemplate ("jucer_ContentCompTemplate_cpp") - .replace ("INCLUDE_JUCE", CodeHelpers::createIncludeStatement (project.getAppIncludeFile(), contentCompCpp), false) - .replace ("INCLUDE_CORRESPONDING_HEADER", CodeHelpers::createIncludeStatement (contentCompH, contentCompCpp), false) - .replace ("CONTENTCOMPCLASS", contentCompName, false); - - if (! FileHelpers::overwriteFileWithNewDataIfDifferent (contentCompH, windowH)) - failedFiles.add (contentCompH.getFullPathName()); - - if (! FileHelpers::overwriteFileWithNewDataIfDifferent (contentCompCpp, windowCpp)) - failedFiles.add (contentCompCpp.getFullPathName()); - - sourceGroup.addFile (contentCompCpp, -1, true); - sourceGroup.addFile (contentCompH, -1, false); - } - - if (createMainCpp) - { - String mainCpp = project.getFileTemplate (createWindow ? "jucer_MainTemplate_Window_cpp" - : "jucer_MainTemplate_NoWindow_cpp") - .replace ("APPHEADERS", appHeaders, false) - .replace ("APPCLASSNAME", CodeHelpers::makeValidIdentifier (appTitle + "Application", false, true, false), false) - .replace ("APPNAME", CodeHelpers::addEscapeChars (appTitle), false) - .replace ("CONTENTCOMPCLASS", contentCompName, false) - .replace ("ALLOWMORETHANONEINSTANCE", "true", false); - - if (! FileHelpers::overwriteFileWithNewDataIfDifferent (mainCppFile, mainCpp)) - failedFiles.add (mainCppFile.getFullPathName()); - - sourceGroup.addFile (mainCppFile, -1, true); - } - - project.createExporterForCurrentPlatform(); - - return true; - } - -private: - bool createMainCpp, createWindow; -}; - -//============================================================================== -class ConsoleAppWizard : public NewProjectWizard -{ -public: - ConsoleAppWizard() {} - - String getName() { return "Console Application"; } - String getDescription() { return "Creates a command-line application with no GUI features"; } - - void addSetupItems (Component& setupComp, OwnedArray& itemsCreated) - { - const char* fileOptions[] = { "Create a Main.cpp file", - "Don't create any files", 0 }; - - createFileCreationOptionComboBox (setupComp, itemsCreated, fileOptions); - } - - Result processResultsFromSetupItems (Component& setupComp) - { - ComboBox* cb = dynamic_cast (setupComp.findChildWithID ("filesToCreate")); - jassert (cb != nullptr); - - createMainCpp = false; - - switch (cb->getSelectedItemIndex()) - { - case 0: createMainCpp = true; break; - case 1: break; - default: jassertfalse; break; - } - - return Result::ok(); - } - - bool initialiseProject (Project& project) - { - if (! getSourceFilesFolder().createDirectory()) - failedFiles.add (getSourceFilesFolder().getFullPathName()); - - File mainCppFile = getSourceFilesFolder().getChildFile ("Main.cpp"); - - project.getProjectTypeValue() = ProjectType::getConsoleAppTypeName(); - - Project::Item sourceGroup (project.getMainGroup().addNewSubGroup ("Source", 0)); - - setExecutableNameForAllTargets (project, File::createLegalFileName (appTitle)); - - if (createMainCpp) - { - String appHeaders (CodeHelpers::createIncludeStatement (project.getAppIncludeFile(), mainCppFile)); - - String mainCpp = project.getFileTemplate ("jucer_MainConsoleAppTemplate_cpp") - .replace ("APPHEADERS", appHeaders, false); - - if (! FileHelpers::overwriteFileWithNewDataIfDifferent (mainCppFile, mainCpp)) - failedFiles.add (mainCppFile.getFullPathName()); - - sourceGroup.addFile (mainCppFile, -1, true); - } - - project.createExporterForCurrentPlatform(); - - return true; - } - -private: - bool createMainCpp; -}; - -//============================================================================== -class AudioPluginAppWizard : public NewProjectWizard -{ -public: - AudioPluginAppWizard() {} - - String getName() { return "Audio Plug-In"; } - String getDescription() { return "Creates an audio plugin project"; } - - void addSetupItems (Component&, OwnedArray& /*itemsCreated*/) - { - } - - Result processResultsFromSetupItems (Component&) - { - return Result::ok(); - } - - bool initialiseProject (Project& project) - { - if (! getSourceFilesFolder().createDirectory()) - failedFiles.add (getSourceFilesFolder().getFullPathName()); - - String filterClassName = CodeHelpers::makeValidIdentifier (appTitle, true, true, false) + "AudioProcessor"; - filterClassName = filterClassName.substring (0, 1).toUpperCase() + filterClassName.substring (1); - String editorClassName = filterClassName + "Editor"; - - File filterCppFile = getSourceFilesFolder().getChildFile ("PluginProcessor.cpp"); - File filterHFile = filterCppFile.withFileExtension (".h"); - File editorCppFile = getSourceFilesFolder().getChildFile ("PluginEditor.cpp"); - File editorHFile = editorCppFile.withFileExtension (".h"); - - project.getProjectTypeValue() = ProjectType::getAudioPluginTypeName(); - project.addModule ("juce_audio_plugin_client", true); - - Project::Item sourceGroup (project.getMainGroup().addNewSubGroup ("Source", 0)); - project.getConfigFlag ("JUCE_QUICKTIME") = Project::configFlagDisabled; // disabled because it interferes with RTAS build on PC - - setExecutableNameForAllTargets (project, File::createLegalFileName (appTitle)); - - String appHeaders (CodeHelpers::createIncludeStatement (project.getAppIncludeFile(), filterCppFile)); - - String filterCpp = project.getFileTemplate ("jucer_AudioPluginFilterTemplate_cpp") - .replace ("FILTERHEADERS", CodeHelpers::createIncludeStatement (filterHFile, filterCppFile) - + newLine + CodeHelpers::createIncludeStatement (editorHFile, filterCppFile), false) - .replace ("FILTERCLASSNAME", filterClassName, false) - .replace ("EDITORCLASSNAME", editorClassName, false); - - String filterH = project.getFileTemplate ("jucer_AudioPluginFilterTemplate_h") - .replace ("APPHEADERS", appHeaders, false) - .replace ("FILTERCLASSNAME", filterClassName, false) - .replace ("HEADERGUARD", CodeHelpers::makeHeaderGuardName (filterHFile), false); - - String editorCpp = project.getFileTemplate ("jucer_AudioPluginEditorTemplate_cpp") - .replace ("EDITORCPPHEADERS", CodeHelpers::createIncludeStatement (filterHFile, filterCppFile) - + newLine + CodeHelpers::createIncludeStatement (editorHFile, filterCppFile), false) - .replace ("FILTERCLASSNAME", filterClassName, false) - .replace ("EDITORCLASSNAME", editorClassName, false); - - String editorH = project.getFileTemplate ("jucer_AudioPluginEditorTemplate_h") - .replace ("EDITORHEADERS", appHeaders + newLine + CodeHelpers::createIncludeStatement (filterHFile, filterCppFile), false) - .replace ("FILTERCLASSNAME", filterClassName, false) - .replace ("EDITORCLASSNAME", editorClassName, false) - .replace ("HEADERGUARD", CodeHelpers::makeHeaderGuardName (editorHFile), false); - - if (! FileHelpers::overwriteFileWithNewDataIfDifferent (filterCppFile, filterCpp)) - failedFiles.add (filterCppFile.getFullPathName()); - - if (! FileHelpers::overwriteFileWithNewDataIfDifferent (filterHFile, filterH)) - failedFiles.add (filterHFile.getFullPathName()); - - if (! FileHelpers::overwriteFileWithNewDataIfDifferent (editorCppFile, editorCpp)) - failedFiles.add (editorCppFile.getFullPathName()); - - if (! FileHelpers::overwriteFileWithNewDataIfDifferent (editorHFile, editorH)) - failedFiles.add (editorHFile.getFullPathName()); - - sourceGroup.addFile (filterCppFile, -1, true); - sourceGroup.addFile (filterHFile, -1, false); - sourceGroup.addFile (editorCppFile, -1, true); - sourceGroup.addFile (editorHFile, -1, false); - - project.createExporterForCurrentPlatform(); - - return true; - } -}; - -//============================================================================== -//============================================================================== -NewProjectWizard::NewProjectWizard() {} -NewProjectWizard::~NewProjectWizard() {} - -StringArray NewProjectWizard::getWizards() -{ - StringArray s; - - for (int i = 0; i < getNumWizards(); ++i) - { - ScopedPointer wiz (createWizard (i)); - s.add (wiz->getName()); - } - - return s; -} - -int NewProjectWizard::getNumWizards() -{ - return 3; -} - -NewProjectWizard* NewProjectWizard::createWizard (int index) -{ - switch (index) - { - case 0: return new GUIAppWizard(); - case 1: return new ConsoleAppWizard(); - case 2: return new AudioPluginAppWizard(); - //case 3: return new BrowserPluginAppWizard(); - default: jassertfalse; break; - } - - return 0; -} - -File& NewProjectWizard::getLastWizardFolder() -{ - #if JUCE_WINDOWS - static File lastFolder (File::getSpecialLocation (File::userDocumentsDirectory)); - #else - static File lastFolder (File::getSpecialLocation (File::userHomeDirectory)); - #endif - return lastFolder; -} - -//============================================================================== -Project* NewProjectWizard::runWizard (Component* ownerWindow_, - const String& projectName, - const File& targetFolder_) -{ - ownerWindow = ownerWindow_; - appTitle = projectName; - targetFolder = targetFolder_; - - if (! targetFolder.exists()) - { - if (! targetFolder.createDirectory()) - failedFiles.add (targetFolder.getFullPathName()); - } - else if (FileHelpers::containsAnyNonHiddenFiles (targetFolder)) - { - if (! AlertWindow::showOkCancelBox (AlertWindow::InfoIcon, "New Juce Project", - "The folder you chose isn't empty - are you sure you want to create the project there?\n\nAny existing files with the same names may be overwritten by the new files.")) - return nullptr; - } - - projectFile = targetFolder.getChildFile (File::createLegalFileName (appTitle)) - .withFileExtension (Project::projectFileExtension); - - ScopedPointer project (new Project (projectFile)); - project->addDefaultModules (true); - - if (failedFiles.size() == 0) - { - project->setFile (projectFile); - project->setTitle (appTitle); - project->getBundleIdentifier() = project->getDefaultBundleIdentifier(); - - if (! initialiseProject (*project)) - return nullptr; - - if (project->save (false, true) != FileBasedDocument::savedOk) - return nullptr; - - project->setChangedFlag (false); - } - - if (failedFiles.size() > 0) - { - AlertWindow::showMessageBox (AlertWindow::WarningIcon, - "Errors in Creating Project!", - "The following files couldn't be written:\n\n" - + failedFiles.joinIntoString ("\n", 0, 10)); - return nullptr; - } - - return project.release(); -} - -//============================================================================== -class NewProjectWizard::WizardComp : public Component, - private ButtonListener, - private ComboBoxListener, - private TextEditorListener -{ -public: - WizardComp() - : projectName ("Project name"), - nameLabel (String::empty, "Project Name:"), - typeLabel (String::empty, "Project Type:"), - fileBrowser (FileBrowserComponent::saveMode | FileBrowserComponent::canSelectDirectories, - getLastWizardFolder(), nullptr, nullptr), - fileOutline (String::empty, "Project Folder:"), - createButton ("Create..."), - cancelButton ("Cancel") - { - setOpaque (true); - setSize (600, 500); - - addChildAndSetID (&projectName, "projectName"); - projectName.setText ("NewProject"); - projectName.setBounds ("100, 14, parent.width / 2 - 10, top + 22"); - nameLabel.attachToComponent (&projectName, true); - projectName.addListener (this); - - addChildAndSetID (&projectType, "projectType"); - projectType.addItemList (getWizards(), 1); - projectType.setSelectedId (1, true); - projectType.setBounds ("100, projectName.bottom + 4, projectName.right, top + 22"); - typeLabel.attachToComponent (&projectType, true); - projectType.addListener (this); - - addChildAndSetID (&fileOutline, "fileOutline"); - fileOutline.setColour (GroupComponent::outlineColourId, Colours::black.withAlpha (0.2f)); - fileOutline.setTextLabelPosition (Justification::centred); - fileOutline.setBounds ("10, projectType.bottom + 20, projectType.right, parent.height - 10"); - - addChildAndSetID (&fileBrowser, "fileBrowser"); - fileBrowser.setBounds ("fileOutline.left + 10, fileOutline.top + 20, fileOutline.right - 10, fileOutline.bottom - 12"); - fileBrowser.setFilenameBoxLabel ("Folder:"); - - addChildAndSetID (&createButton, "createButton"); - createButton.setBounds ("right - 140, bottom - 24, parent.width - 10, parent.height - 10"); - createButton.addListener (this); - - addChildAndSetID (&cancelButton, "cancelButton"); - cancelButton.addShortcut (KeyPress (KeyPress::escapeKey)); - cancelButton.setBounds ("right - 140, createButton.top, createButton.left - 10, createButton.bottom"); - cancelButton.addListener (this); - - updateCustomItems(); - updateCreateButton(); - } - - void paint (Graphics& g) - { - g.fillAll (Colour::greyLevel (0.93f)); - } - - void buttonClicked (Button* b) - { - if (b == &createButton) - { - createProject(); - } - else - { - MainWindow* mw = dynamic_cast (getTopLevelComponent()); - jassert (mw != nullptr); - - IntrojucerApp::getApp().mainWindowList.closeWindow (mw); - } - } - - void createProject() - { - MainWindow* mw = Component::findParentComponentOfClass(); - jassert (mw != nullptr); - - ScopedPointer wizard (createWizard()); - - if (wizard != nullptr) - { - Result result (wizard->processResultsFromSetupItems (*this)); - - if (result.failed()) + if (! targetFolder.exists()) { - AlertWindow::showMessageBox (AlertWindow::WarningIcon, "Create Project", result.getErrorMessage()); - return; + if (! targetFolder.createDirectory()) + failedFiles.add (targetFolder.getFullPathName()); + } + else if (FileHelpers::containsAnyNonHiddenFiles (targetFolder)) + { + if (! AlertWindow::showOkCancelBox (AlertWindow::InfoIcon, + TRANS("New Juce Project"), + TRANS("The folder you chose isn't empty - are you sure you want to create the project there?") + + "\n\n" + + TRANS("Any existing files with the same names may be overwritten by the new files."))) + return nullptr; } - ScopedPointer project (wizard->runWizard (mw, projectName.getText(), - fileBrowser.getSelectedFile (0))); + projectFile = targetFolder.getChildFile (File::createLegalFileName (appTitle)) + .withFileExtension (Project::projectFileExtension); - if (project != nullptr) - mw->setProject (project.release()); + ScopedPointer project (new Project (projectFile)); + project->addDefaultModules (true); + + if (failedFiles.size() == 0) + { + project->setFile (projectFile); + project->setTitle (appTitle); + project->getBundleIdentifier() = project->getDefaultBundleIdentifier(); + + if (! initialiseProject (*project)) + return nullptr; + + if (project->save (false, true) != FileBasedDocument::savedOk) + return nullptr; + + project->setChangedFlag (false); + } + + if (failedFiles.size() > 0) + { + AlertWindow::showMessageBox (AlertWindow::WarningIcon, + TRANS("Errors in Creating Project!"), + TRANS("The following files couldn't be written:") + + "\n\n" + + failedFiles.joinIntoString ("\n", 0, 10)); + return nullptr; + } + + return project.release(); } + + //============================================================================== + File getSourceFilesFolder() const + { + return projectFile.getSiblingFile ("Source"); + } + + void createSourceFolder() + { + if (! getSourceFilesFolder().createDirectory()) + failedFiles.add (getSourceFilesFolder().getFullPathName()); + } + }; + + //============================================================================== + struct GUIAppWizard : public NewProjectWizard + { + GUIAppWizard() {} + + String getName() { return TRANS("GUI Application"); } + String getDescription() { return TRANS("Creates a standard application"); } + + void addSetupItems (Component& setupComp, OwnedArray& itemsCreated) + { + const String fileOptions[] = { TRANS("Create a Main.cpp file"), + TRANS("Create a Main.cpp file and a basic window"), + TRANS("Don't create any files") }; + + createFileCreationOptionComboBox (setupComp, itemsCreated, + StringArray (fileOptions, numElementsInArray (fileOptions))); + } + + Result processResultsFromSetupItems (Component& setupComp) + { + createMainCpp = createWindow = false; + + switch (getFileCreationComboResult (setupComp)) + { + case 0: createMainCpp = true; break; + case 1: createMainCpp = createWindow = true; break; + case 2: break; + default: jassertfalse; break; + } + + return Result::ok(); + } + + bool initialiseProject (Project& project) + { + createSourceFolder(); + + File mainCppFile = getSourceFilesFolder().getChildFile ("Main.cpp"); + File contentCompCpp = getSourceFilesFolder().getChildFile ("MainComponent.cpp"); + File contentCompH = contentCompCpp.withFileExtension (".h"); + String contentCompName = "MainContentComponent"; + + project.getProjectTypeValue() = ProjectType::getGUIAppTypeName(); + + Project::Item sourceGroup (createSourceGroup (project)); + + setExecutableNameForAllTargets (project, File::createLegalFileName (appTitle)); + + String appHeaders (CodeHelpers::createIncludeStatement (project.getAppIncludeFile(), mainCppFile)); + + if (createWindow) + { + appHeaders << newLine << CodeHelpers::createIncludeStatement (contentCompH, mainCppFile); + + String windowH = project.getFileTemplate ("jucer_ContentCompTemplate_h") + .replace ("INCLUDE_JUCE", CodeHelpers::createIncludeStatement (project.getAppIncludeFile(), contentCompH), false) + .replace ("CONTENTCOMPCLASS", contentCompName, false) + .replace ("HEADERGUARD", CodeHelpers::makeHeaderGuardName (contentCompH), false); + + String windowCpp = project.getFileTemplate ("jucer_ContentCompTemplate_cpp") + .replace ("INCLUDE_JUCE", CodeHelpers::createIncludeStatement (project.getAppIncludeFile(), contentCompCpp), false) + .replace ("INCLUDE_CORRESPONDING_HEADER", CodeHelpers::createIncludeStatement (contentCompH, contentCompCpp), false) + .replace ("CONTENTCOMPCLASS", contentCompName, false); + + if (! FileHelpers::overwriteFileWithNewDataIfDifferent (contentCompH, windowH)) + failedFiles.add (contentCompH.getFullPathName()); + + if (! FileHelpers::overwriteFileWithNewDataIfDifferent (contentCompCpp, windowCpp)) + failedFiles.add (contentCompCpp.getFullPathName()); + + sourceGroup.addFile (contentCompCpp, -1, true); + sourceGroup.addFile (contentCompH, -1, false); + } + + if (createMainCpp) + { + String mainCpp = project.getFileTemplate (createWindow ? "jucer_MainTemplate_Window_cpp" + : "jucer_MainTemplate_NoWindow_cpp") + .replace ("APPHEADERS", appHeaders, false) + .replace ("APPCLASSNAME", CodeHelpers::makeValidIdentifier (appTitle + "Application", false, true, false), false) + .replace ("APPNAME", CodeHelpers::addEscapeChars (appTitle), false) + .replace ("CONTENTCOMPCLASS", contentCompName, false) + .replace ("ALLOWMORETHANONEINSTANCE", "true", false); + + if (! FileHelpers::overwriteFileWithNewDataIfDifferent (mainCppFile, mainCpp)) + failedFiles.add (mainCppFile.getFullPathName()); + + sourceGroup.addFile (mainCppFile, -1, true); + } + + project.createExporterForCurrentPlatform(); + + return true; + } + + private: + bool createMainCpp, createWindow; + }; + + //============================================================================== + struct ConsoleAppWizard : public NewProjectWizard + { + ConsoleAppWizard() {} + + String getName() { return TRANS("Console Application"); } + String getDescription() { return TRANS("Creates a command-line application with no GUI features"); } + + void addSetupItems (Component& setupComp, OwnedArray& itemsCreated) + { + const String fileOptions[] = { TRANS("Create a Main.cpp file"), + TRANS("Don't create any files") }; + + createFileCreationOptionComboBox (setupComp, itemsCreated, + StringArray (fileOptions, numElementsInArray (fileOptions))); + } + + Result processResultsFromSetupItems (Component& setupComp) + { + createMainCpp = false; + + switch (getFileCreationComboResult (setupComp)) + { + case 0: createMainCpp = true; break; + case 1: break; + default: jassertfalse; break; + } + + return Result::ok(); + } + + bool initialiseProject (Project& project) + { + createSourceFolder(); + + project.getProjectTypeValue() = ProjectType::getConsoleAppTypeName(); + + Project::Item sourceGroup (createSourceGroup (project)); + + setExecutableNameForAllTargets (project, File::createLegalFileName (appTitle)); + + if (createMainCpp) + { + File mainCppFile = getSourceFilesFolder().getChildFile ("Main.cpp"); + String appHeaders (CodeHelpers::createIncludeStatement (project.getAppIncludeFile(), mainCppFile)); + + String mainCpp = project.getFileTemplate ("jucer_MainConsoleAppTemplate_cpp") + .replace ("APPHEADERS", appHeaders, false); + + if (! FileHelpers::overwriteFileWithNewDataIfDifferent (mainCppFile, mainCpp)) + failedFiles.add (mainCppFile.getFullPathName()); + + sourceGroup.addFile (mainCppFile, -1, true); + } + + project.createExporterForCurrentPlatform(); + + return true; + } + + private: + bool createMainCpp; + }; + + //============================================================================== + struct AudioPluginAppWizard : public NewProjectWizard + { + AudioPluginAppWizard() {} + + String getName() { return TRANS("Audio Plug-In"); } + String getDescription() { return TRANS("Creates an audio plugin project"); } + + bool initialiseProject (Project& project) + { + createSourceFolder(); + + String filterClassName = CodeHelpers::makeValidIdentifier (appTitle, true, true, false) + "AudioProcessor"; + filterClassName = filterClassName.substring (0, 1).toUpperCase() + filterClassName.substring (1); + String editorClassName = filterClassName + "Editor"; + + File filterCppFile = getSourceFilesFolder().getChildFile ("PluginProcessor.cpp"); + File filterHFile = filterCppFile.withFileExtension (".h"); + File editorCppFile = getSourceFilesFolder().getChildFile ("PluginEditor.cpp"); + File editorHFile = editorCppFile.withFileExtension (".h"); + + project.getProjectTypeValue() = ProjectType::getAudioPluginTypeName(); + project.addModule ("juce_audio_plugin_client", true); + + Project::Item sourceGroup (createSourceGroup (project)); + project.getConfigFlag ("JUCE_QUICKTIME") = Project::configFlagDisabled; // disabled because it interferes with RTAS build on PC + + setExecutableNameForAllTargets (project, File::createLegalFileName (appTitle)); + + String appHeaders (CodeHelpers::createIncludeStatement (project.getAppIncludeFile(), filterCppFile)); + + String filterCpp = project.getFileTemplate ("jucer_AudioPluginFilterTemplate_cpp") + .replace ("FILTERHEADERS", CodeHelpers::createIncludeStatement (filterHFile, filterCppFile) + + newLine + CodeHelpers::createIncludeStatement (editorHFile, filterCppFile), false) + .replace ("FILTERCLASSNAME", filterClassName, false) + .replace ("EDITORCLASSNAME", editorClassName, false); + + String filterH = project.getFileTemplate ("jucer_AudioPluginFilterTemplate_h") + .replace ("APPHEADERS", appHeaders, false) + .replace ("FILTERCLASSNAME", filterClassName, false) + .replace ("HEADERGUARD", CodeHelpers::makeHeaderGuardName (filterHFile), false); + + String editorCpp = project.getFileTemplate ("jucer_AudioPluginEditorTemplate_cpp") + .replace ("EDITORCPPHEADERS", CodeHelpers::createIncludeStatement (filterHFile, filterCppFile) + + newLine + CodeHelpers::createIncludeStatement (editorHFile, filterCppFile), false) + .replace ("FILTERCLASSNAME", filterClassName, false) + .replace ("EDITORCLASSNAME", editorClassName, false); + + String editorH = project.getFileTemplate ("jucer_AudioPluginEditorTemplate_h") + .replace ("EDITORHEADERS", appHeaders + newLine + CodeHelpers::createIncludeStatement (filterHFile, filterCppFile), false) + .replace ("FILTERCLASSNAME", filterClassName, false) + .replace ("EDITORCLASSNAME", editorClassName, false) + .replace ("HEADERGUARD", CodeHelpers::makeHeaderGuardName (editorHFile), false); + + if (! FileHelpers::overwriteFileWithNewDataIfDifferent (filterCppFile, filterCpp)) + failedFiles.add (filterCppFile.getFullPathName()); + + if (! FileHelpers::overwriteFileWithNewDataIfDifferent (filterHFile, filterH)) + failedFiles.add (filterHFile.getFullPathName()); + + if (! FileHelpers::overwriteFileWithNewDataIfDifferent (editorCppFile, editorCpp)) + failedFiles.add (editorCppFile.getFullPathName()); + + if (! FileHelpers::overwriteFileWithNewDataIfDifferent (editorHFile, editorH)) + failedFiles.add (editorHFile.getFullPathName()); + + sourceGroup.addFile (filterCppFile, -1, true); + sourceGroup.addFile (filterHFile, -1, false); + sourceGroup.addFile (editorCppFile, -1, true); + sourceGroup.addFile (editorHFile, -1, false); + + project.createExporterForCurrentPlatform(); + + return true; + } + }; + + //============================================================================== + struct StaticLibraryWizard : public NewProjectWizard + { + StaticLibraryWizard() {} + + String getName() { return TRANS("Static Library"); } + String getDescription() { return TRANS("Creates a static library"); } + + bool initialiseProject (Project& project) + { + createSourceFolder(); + project.getProjectTypeValue() = ProjectType::getStaticLibTypeName(); + createSourceGroup (project); + setExecutableNameForAllTargets (project, File::createLegalFileName (appTitle)); + project.createExporterForCurrentPlatform(); + + return true; + } + }; + + //============================================================================== + struct DynamicLibraryWizard : public NewProjectWizard + { + DynamicLibraryWizard() {} + + String getName() { return TRANS("Dynamic Library"); } + String getDescription() { return TRANS("Creates a dynamic library"); } + + bool initialiseProject (Project& project) + { + createSourceFolder(); + project.getProjectTypeValue() = ProjectType::getDynamicLibTypeName(); + createSourceGroup (project); + setExecutableNameForAllTargets (project, File::createLegalFileName (appTitle)); + project.createExporterForCurrentPlatform(); + + return true; + } + }; + + //============================================================================== + class WizardComp : public Component, + private ButtonListener, + private ComboBoxListener, + private TextEditorListener + { + public: + WizardComp() + : projectName (TRANS("Project name")), + nameLabel (String::empty, TRANS("Project Name") + ":"), + typeLabel (String::empty, TRANS("Project Type") + ":"), + fileBrowser (FileBrowserComponent::saveMode | FileBrowserComponent::canSelectDirectories, + getLastWizardFolder(), nullptr, nullptr), + fileOutline (String::empty, TRANS("Project Folder") + ":"), + createButton (TRANS("Create") + "..."), + cancelButton (TRANS("Cancel")) + { + setOpaque (true); + setSize (600, 500); + + addChildAndSetID (&projectName, "projectName"); + projectName.setText ("NewProject"); + projectName.setBounds ("100, 14, parent.width / 2 - 10, top + 22"); + nameLabel.attachToComponent (&projectName, true); + projectName.addListener (this); + + addChildAndSetID (&projectType, "projectType"); + projectType.addItemList (getWizardNames(), 1); + projectType.setSelectedId (1, true); + projectType.setBounds ("100, projectName.bottom + 4, projectName.right, top + 22"); + typeLabel.attachToComponent (&projectType, true); + projectType.addListener (this); + + addChildAndSetID (&fileOutline, "fileOutline"); + fileOutline.setColour (GroupComponent::outlineColourId, Colours::black.withAlpha (0.2f)); + fileOutline.setTextLabelPosition (Justification::centred); + fileOutline.setBounds ("10, projectType.bottom + 20, projectType.right, parent.height - 10"); + + addChildAndSetID (&fileBrowser, "fileBrowser"); + fileBrowser.setBounds ("fileOutline.left + 10, fileOutline.top + 20, fileOutline.right - 10, fileOutline.bottom - 12"); + fileBrowser.setFilenameBoxLabel ("Folder:"); + + addChildAndSetID (&createButton, "createButton"); + createButton.setBounds ("right - 140, bottom - 24, parent.width - 10, parent.height - 10"); + createButton.addListener (this); + + addChildAndSetID (&cancelButton, "cancelButton"); + cancelButton.addShortcut (KeyPress (KeyPress::escapeKey)); + cancelButton.setBounds ("right - 140, createButton.top, createButton.left - 10, createButton.bottom"); + cancelButton.addListener (this); + + updateCustomItems(); + updateCreateButton(); + } + + void paint (Graphics& g) + { + g.fillAll (Colour::greyLevel (0.93f)); + } + + void buttonClicked (Button* b) + { + if (b == &createButton) + { + createProject(); + } + else + { + if (MainWindow* mw = dynamic_cast (getTopLevelComponent())) + IntrojucerApp::getApp().mainWindowList.closeWindow (mw); + } + } + + void createProject() + { + MainWindow* mw = Component::findParentComponentOfClass(); + jassert (mw != nullptr); + + ScopedPointer wizard (createWizard()); + + if (wizard != nullptr) + { + Result result (wizard->processResultsFromSetupItems (*this)); + + if (result.failed()) + { + AlertWindow::showMessageBox (AlertWindow::WarningIcon, + TRANS("Create Project"), + result.getErrorMessage()); + return; + } + + ScopedPointer project (wizard->runWizard (mw, projectName.getText(), + fileBrowser.getSelectedFile (0))); + + if (project != nullptr) + mw->setProject (project.release()); + } + } + + void updateCustomItems() + { + customItems.clear(); + + ScopedPointer wizard (createWizard()); + + if (wizard != nullptr) + wizard->addSetupItems (*this, customItems); + } + + void comboBoxChanged (ComboBox*) + { + updateCustomItems(); + } + + void textEditorTextChanged (TextEditor&) + { + updateCreateButton(); + + fileBrowser.setFileName (File::createLegalFileName (projectName.getText())); + } + + private: + ComboBox projectType; + TextEditor projectName; + Label nameLabel, typeLabel; + FileBrowserComponent fileBrowser; + GroupComponent fileOutline; + TextButton createButton, cancelButton; + OwnedArray customItems; + + NewProjectWizard* createWizard() + { + return createWizardType (projectType.getSelectedItemIndex()); + } + + void updateCreateButton() + { + createButton.setEnabled (projectName.getText().trim().isNotEmpty()); + } + }; + + //============================================================================== + static int getNumWizards() + { + return 5; } - void updateCustomItems() + static NewProjectWizard* createWizardType (int index) { - customItems.clear(); + switch (index) + { + case 0: return new GUIAppWizard(); + case 1: return new ConsoleAppWizard(); + case 2: return new AudioPluginAppWizard(); + case 3: return new StaticLibraryWizard(); + case 4: return new DynamicLibraryWizard(); + default: jassertfalse; break; + } - ScopedPointer wizard (createWizard()); - - if (wizard != nullptr) - wizard->addSetupItems (*this, customItems); + return 0; } - void comboBoxChanged (ComboBox*) + static StringArray getWizardNames() { - updateCustomItems(); - } + StringArray s; - void textEditorTextChanged (TextEditor&) - { - updateCreateButton(); + for (int i = 0; i < getNumWizards(); ++i) + { + ScopedPointer wiz (createWizardType (i)); + s.add (wiz->getName()); + } - fileBrowser.setFileName (File::createLegalFileName (projectName.getText())); - } - -private: - ComboBox projectType; - TextEditor projectName; - Label nameLabel, typeLabel; - FileBrowserComponent fileBrowser; - GroupComponent fileOutline; - TextButton createButton, cancelButton; - OwnedArray customItems; - - NewProjectWizard* createWizard() - { - return NewProjectWizard::createWizard (projectType.getSelectedItemIndex()); - } - - void updateCreateButton() - { - createButton.setEnabled (projectName.getText().trim().isNotEmpty()); + return s; } }; -Component* NewProjectWizard::createComponent() +Component* createNewProjectWizardComponent() { - return new WizardComp(); + return new NewProjectWizardClasses::WizardComp(); } diff --git a/extras/Introjucer/Source/Project/jucer_NewProjectWizard.h b/extras/Introjucer/Source/Project/jucer_NewProjectWizard.h index 5c6ae1dbfd..35ee5ff647 100644 --- a/extras/Introjucer/Source/Project/jucer_NewProjectWizard.h +++ b/extras/Introjucer/Source/Project/jucer_NewProjectWizard.h @@ -27,48 +27,8 @@ #define __JUCER_NEWPROJECTWIZARD_JUCEHEADER__ #include "../jucer_Headers.h" -#include "jucer_Project.h" - -//============================================================================== -class NewProjectWizard -{ -public: - virtual ~NewProjectWizard(); - - //============================================================================== - static StringArray getWizards(); - static int getNumWizards(); - static NewProjectWizard* createWizard (int index); - - static Component* createComponent(); - - //============================================================================== - virtual String getName() = 0; - virtual String getDescription() = 0; - - virtual void addSetupItems (Component& setupComp, OwnedArray& itemsCreated) = 0; - virtual Result processResultsFromSetupItems (Component& setupComp) = 0; - virtual bool initialiseProject (Project& project) = 0; - -protected: - String appTitle; - File targetFolder, projectFile; - Component* ownerWindow; - StringArray failedFiles; - - //============================================================================== - NewProjectWizard(); - Project* runWizard (Component* ownerWindow, - const String& projectName, - const File& targetFolder); - - class WizardComp; - friend class WizardComp; - - File getSourceFilesFolder() const { return projectFile.getSiblingFile ("Source"); } - static File& getLastWizardFolder(); -}; +Component* createNewProjectWizardComponent(); #endif // __JUCER_NEWPROJECTWIZARD_JUCEHEADER__ diff --git a/extras/Introjucer/Source/Project/jucer_ProjectType.cpp b/extras/Introjucer/Source/Project/jucer_ProjectType.cpp index 0997166b40..55593ce732 100644 --- a/extras/Introjucer/Source/Project/jucer_ProjectType.cpp +++ b/extras/Introjucer/Source/Project/jucer_ProjectType.cpp @@ -30,8 +30,8 @@ //============================================================================== -ProjectType::ProjectType (const String& type_, const String& desc_) - : type (type_), desc (desc_) +ProjectType::ProjectType (const String& t, const String& d) + : type (t), desc (d) { getAllTypes().add (this); } @@ -123,13 +123,13 @@ public: }; //============================================================================== -class ProjectType_Library : public ProjectType +class ProjectType_StaticLibrary : public ProjectType { public: - ProjectType_Library() : ProjectType (getTypeName(), "Static Library") {} + ProjectType_StaticLibrary() : ProjectType (getTypeName(), "Static Library") {} static const char* getTypeName() noexcept { return "library"; } - bool isLibrary() const { return true; } + bool isStaticLibrary() const { return true; } void setMissingProjectProperties (Project&) const { @@ -142,22 +142,41 @@ public: void prepareExporter (ProjectExporter& exporter) const { exporter.xcodeCreatePList = false; + exporter.xcodeFileType = "archive.ar"; + exporter.xcodeProductType = "com.apple.product-type.library.static"; + exporter.xcodeProductInstallPath = String::empty; + exporter.makefileTargetSuffix = ".a"; + exporter.msvcTargetSuffix = ".lib"; + exporter.msvcExtraPreprocessorDefs.set ("_LIB", ""); + } +}; - if (exporter.getSetting (Ids::libraryType) == 2) - { - exporter.xcodeFileType = "compiled.mach-o.dylib"; - exporter.xcodeProductType = "com.apple.product-type.library.dynamic"; - exporter.xcodeBundleExtension = ".dylib"; - } - else - { - exporter.xcodeFileType = "archive.ar"; - exporter.xcodeProductType = "com.apple.product-type.library.static"; - } +//============================================================================== +class ProjectType_DLL : public ProjectType +{ +public: + ProjectType_DLL() : ProjectType (getTypeName(), "Dynamic Library") {} + static const char* getTypeName() noexcept { return "dll"; } + bool isDynamicLibrary() const { return true; } + + void setMissingProjectProperties (Project&) const + { + } + + void createPropertyEditors (Project&, PropertyListBuilder&) const + { + } + + void prepareExporter (ProjectExporter& exporter) const + { + exporter.xcodeCreatePList = false; + exporter.xcodeFileType = "compiled.mach-o.dylib"; + exporter.xcodeProductType = "com.apple.product-type.library.dynamic"; + exporter.xcodeBundleExtension = ".dylib"; exporter.xcodeProductInstallPath = String::empty; exporter.makefileTargetSuffix = ".so"; - exporter.msvcTargetSuffix = exporter.getSetting (Ids::libraryType) == 2 ? ".dll" : ".lib"; + exporter.msvcTargetSuffix = ".dll"; exporter.msvcExtraPreprocessorDefs.set ("_LIB", ""); } }; @@ -321,12 +340,15 @@ public: }; //============================================================================== -static ProjectType_GUIApp guiType; -static ProjectType_ConsoleApp consoleType; -static ProjectType_Library libraryType; -static ProjectType_AudioPlugin audioPluginType; +static ProjectType_GUIApp guiType; +static ProjectType_ConsoleApp consoleType; +static ProjectType_StaticLibrary libraryType; +static ProjectType_DLL dllType; +static ProjectType_AudioPlugin audioPluginType; //============================================================================== const char* ProjectType::getGUIAppTypeName() { return ProjectType_GUIApp::getTypeName(); } const char* ProjectType::getConsoleAppTypeName() { return ProjectType_ConsoleApp::getTypeName(); } +const char* ProjectType::getStaticLibTypeName() { return ProjectType_StaticLibrary::getTypeName(); } +const char* ProjectType::getDynamicLibTypeName() { return ProjectType_DLL::getTypeName(); } const char* ProjectType::getAudioPluginTypeName() { return ProjectType_AudioPlugin::getTypeName(); } diff --git a/extras/Introjucer/Source/Project/jucer_ProjectType.h b/extras/Introjucer/Source/Project/jucer_ProjectType.h index 37959acec9..d9b3e7f433 100644 --- a/extras/Introjucer/Source/Project/jucer_ProjectType.h +++ b/extras/Introjucer/Source/Project/jucer_ProjectType.h @@ -45,7 +45,8 @@ public: static const ProjectType* findType (const String& typeCode); //============================================================================== - virtual bool isLibrary() const { return false; } + virtual bool isStaticLibrary() const { return false; } + virtual bool isDynamicLibrary() const { return false; } virtual bool isGUIApplication() const { return false; } virtual bool isCommandLineApp() const { return false; } virtual bool isAudioPlugin() const { return false; } @@ -53,6 +54,8 @@ public: static const char* getGUIAppTypeName(); static const char* getConsoleAppTypeName(); + static const char* getStaticLibTypeName(); + static const char* getDynamicLibTypeName(); static const char* getAudioPluginTypeName(); virtual void setMissingProjectProperties (Project&) const = 0; diff --git a/extras/Introjucer/Source/Utility/jucer_PresetIDs.h b/extras/Introjucer/Source/Utility/jucer_PresetIDs.h index 81ce57e656..5acd20a92a 100644 --- a/extras/Introjucer/Source/Utility/jucer_PresetIDs.h +++ b/extras/Introjucer/Source/Utility/jucer_PresetIDs.h @@ -59,7 +59,6 @@ namespace Ids DECLARE_ID (externalLibraries); DECLARE_ID (extraDefs); DECLARE_ID (projectType); - DECLARE_ID (libraryType); DECLARE_ID (isDebug); DECLARE_ID (alwaysGenerateDebugSymbols); DECLARE_ID (targetName);