text
stringlengths 0
2.2M
|
---|
}
|
}
|
}
|
void JucerDocument::fillInPaintCode (GeneratedCode& code) const
|
{
|
for (int i = 0; i < getNumPaintRoutines(); ++i)
|
getPaintRoutine (i)
|
->fillInGeneratedCode (code, code.getCallbackCode (String(), "void", "paint (juce::Graphics& g)", false));
|
}
|
void JucerDocument::setTemplateFile (const String& newFile)
|
{
|
if (templateFile != newFile)
|
{
|
templateFile = newFile;
|
changed();
|
}
|
}
|
//==============================================================================
|
bool JucerDocument::findTemplateFiles (String& headerContent, String& cppContent) const
|
{
|
if (templateFile.isNotEmpty())
|
{
|
const File f (getCppFile().getSiblingFile (templateFile));
|
const File templateCpp (f.withFileExtension (".cpp"));
|
const File templateH (f.withFileExtension (".h"));
|
headerContent = templateH.loadFileAsString();
|
cppContent = templateCpp.loadFileAsString();
|
if (headerContent.isNotEmpty() && cppContent.isNotEmpty())
|
return true;
|
}
|
headerContent = BinaryData::jucer_ComponentTemplate_h;
|
cppContent = BinaryData::jucer_ComponentTemplate_cpp;
|
return true;
|
}
|
bool JucerDocument::flushChangesToDocuments (Project* project, bool isInitial)
|
{
|
String headerTemplate, cppTemplate;
|
if (! findTemplateFiles (headerTemplate, cppTemplate))
|
return false;
|
GeneratedCode generated (this);
|
fillInGeneratedCode (generated);
|
const File headerFile (getHeaderFile());
|
generated.includeFilesCPP.insert (0, headerFile);
|
OpenDocumentManager& odm = ProjucerApplication::getApp().openDocumentManager;
|
if (SourceCodeDocument* header = dynamic_cast<SourceCodeDocument*> (odm.openFile (nullptr, headerFile)))
|
{
|
String existingHeader (header->getCodeDocument().getAllContent());
|
String existingCpp (cpp->getCodeDocument().getAllContent());
|
generated.applyToCode (headerTemplate, headerFile, existingHeader);
|
generated.applyToCode (cppTemplate, headerFile.withFileExtension (".cpp"), existingCpp);
|
if (isInitial)
|
{
|
jassert (project != nullptr);
|
auto lineFeed = project->getProjectLineFeed();
|
headerTemplate = replaceLineFeeds (headerTemplate, lineFeed);
|
cppTemplate = replaceLineFeeds (cppTemplate, lineFeed);
|
}
|
else
|
{
|
headerTemplate = replaceLineFeeds (headerTemplate, getLineFeedForFile (existingHeader));
|
cppTemplate = replaceLineFeeds (cppTemplate, getLineFeedForFile (existingCpp));
|
}
|
if (header->getCodeDocument().getAllContent() != headerTemplate)
|
header->getCodeDocument().replaceAllContent (headerTemplate);
|
if (cpp->getCodeDocument().getAllContent() != cppTemplate)
|
cpp->getCodeDocument().replaceAllContent (cppTemplate);
|
}
|
userDocChangeTimer.reset();
|
return true;
|
}
|
bool JucerDocument::reloadFromDocument()
|
{
|
const String cppContent (cpp->getCodeDocument().getAllContent());
|
std::unique_ptr<XmlElement> newXML (pullMetaDataFromCppFile (cppContent));
|
if (newXML == nullptr || ! newXML->hasTagName (jucerCompXmlTag))
|
return false;
|
if (currentXML != nullptr && currentXML->isEquivalentTo (newXML.get(), true))
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.