const String GeneratedCode::getCallbackDefinitions() const { String s; for (int i = 0; i < callbacks.size(); ++i) { CallbackMethod* const cm = callbacks.getUnchecked(i); const String userCodeBlockName (T("User") + makeValidCppIdentifier (cm->prototype.upToFirstOccurrenceOf (T("("), false, false), true, true, false).trim()); if (userCodeBlockName.isNotEmpty() && cm->hasPrePostUserSections) { s << cm->returnType << " " << className << "::" << cm->prototype << "\n{\n //[" << userCodeBlockName << "_Pre]\n //[/" << userCodeBlockName << "_Pre]\n\n " << indentCode (cm->content.trim(), 4) << "\n\n //[" << userCodeBlockName << "_Post]\n //[/" << userCodeBlockName << "_Post]\n}\n\n"; } else { s << cm->returnType << " " << className << "::" << cm->prototype << "\n{\n " << indentCode (cm->content.trim(), 4) << "\n}\n\n"; } } return s; }
void ComponentTypeHandler::fillInMemberVariableDeclarations (GeneratedCode& code, Component* component, const String& memberVariableName) { const String virtualName (component->getProperties() ["virtualName"].toString()); if (virtualName.isNotEmpty()) { code.privateMemberDeclarations << makeValidCppIdentifier (virtualName, false, false, true); } else { code.privateMemberDeclarations << getClassName (component); } code.privateMemberDeclarations << "* " << memberVariableName << ";\n"; code.initialisers.add (memberVariableName + " (0)"); }
void ComponentTypeHandler::fillInCreationCode (GeneratedCode& code, Component* component, const String& memberVariableName) { String params (getCreationParameters (component)); const String virtualName (component->getProperties() ["virtualName"].toString()); String s; s << "addAndMakeVisible (" << memberVariableName << " = new "; if (virtualName.isNotEmpty()) s << makeValidCppIdentifier (virtualName, false, false, true); else s << getClassName (component); if (params.isEmpty()) s << "());\n"; else { StringArray lines; lines.addLines (params); params = lines.joinIntoString ("\n" + String::repeatedString (" ", s.length() + 2)); s << " (" << params << "));\n"; } SettableTooltipClient* ttc = dynamic_cast <SettableTooltipClient*> (component); if (ttc != 0 && ttc->getTooltip().isNotEmpty()) { s << memberVariableName << "->setTooltip (" << quotedString (ttc->getTooltip()) << ");\n"; } if (component->getExplicitFocusOrder() > 0) s << memberVariableName << "->setExplicitFocusOrder (" << component->getExplicitFocusOrder() << ");\n"; code.constructorCode += s; }