text
stringlengths 0
2.2M
|
---|
fixedSize = xml.getBoolAttribute ("fixedSize", false);
|
initialWidth = xml.getIntAttribute ("initialWidth", 300);
|
initialHeight = xml.getIntAttribute ("initialHeight", 200);
|
snapGridPixels = xml.getIntAttribute ("snapPixels", snapGridPixels);
|
snapActive = xml.getBoolAttribute ("snapActive", snapActive);
|
snapShown = xml.getBoolAttribute ("snapShown", snapShown);
|
componentOverlayOpacity = (float) xml.getDoubleAttribute ("overlayOpacity", 0.0);
|
activeExtraMethods.clear();
|
if (XmlElement* const methods = xml.getChildByName ("METHODS"))
|
for (auto* e : methods->getChildWithTagNameIterator ("METHOD"))
|
activeExtraMethods.addIfNotAlreadyThere (e->getStringAttribute ("name"));
|
activeExtraMethods.trim();
|
activeExtraMethods.removeEmptyStrings();
|
changed();
|
getUndoManager().clearUndoHistory();
|
return true;
|
}
|
return false;
|
}
|
//==============================================================================
|
void JucerDocument::fillInGeneratedCode (GeneratedCode& code) const
|
{
|
code.className = className;
|
code.componentName = componentName;
|
code.parentClasses = parentClasses;
|
code.constructorParams = constructorParams;
|
code.initialisers.addLines (variableInitialisers);
|
if (! componentName.isEmpty())
|
code.constructorCode << "setName (" + quotedString (componentName, false) + ");\n";
|
// call these now, just to make sure they're the first two methods in the list.
|
code.getCallbackCode (String(), "void", "paint (juce::Graphics& g)", false)
|
<< "//[UserPrePaint] Add your own custom painting code here..\n//[/UserPrePaint]\n\n";
|
code.getCallbackCode (String(), "void", "resized()", false)
|
<< "//[UserPreResize] Add your own custom resize code here..\n//[/UserPreResize]\n\n";
|
if (ComponentLayout* l = getComponentLayout())
|
l->fillInGeneratedCode (code);
|
fillInPaintCode (code);
|
std::unique_ptr<XmlElement> e (createXml());
|
jassert (e != nullptr);
|
code.jucerMetadata = e->toString (XmlElement::TextFormat().withoutHeader());
|
resources.fillInGeneratedCode (code);
|
code.constructorCode
|
<< "\n//[UserPreSize]\n"
|
"//[/UserPreSize]\n";
|
if (initialWidth > 0 || initialHeight > 0)
|
code.constructorCode << "\nsetSize (" << initialWidth << ", " << initialHeight << ");\n";
|
code.getCallbackCode (String(), "void", "paint (juce::Graphics& g)", false)
|
<< "//[UserPaint] Add your own custom painting code here..\n//[/UserPaint]";
|
code.getCallbackCode (String(), "void", "resized()", false)
|
<< "//[UserResized] Add your own custom resize handling here..\n//[/UserResized]";
|
// add optional methods
|
StringArray baseClasses, returnValues, methods, initialContents;
|
getOptionalMethods (baseClasses, returnValues, methods, initialContents);
|
for (int i = 0; i < methods.size(); ++i)
|
{
|
if (isOptionalMethodEnabled (methods[i]))
|
{
|
String baseClassToAdd (baseClasses[i]);
|
if (baseClassToAdd == "juce::Component" || baseClassToAdd == "juce::Button")
|
baseClassToAdd.clear();
|
String& s = code.getCallbackCode (baseClassToAdd, returnValues[i], methods[i], false);
|
if (! s.contains ("//["))
|
{
|
String userCommentTag ("UserCode_");
|
userCommentTag += methods[i].upToFirstOccurrenceOf ("(", false, false).trim();
|
s << "\n//[" << userCommentTag << "] -- Add your code here...\n"
|
<< initialContents[i];
|
if (initialContents[i].isNotEmpty() && ! initialContents[i].endsWithChar ('\n'))
|
s << '\n';
|
s << "//[/" << userCommentTag << "]\n";
|
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.