void PHPCodeGenerator::GenVirtualEventHandlers( const EventVector& events, const wxString& eventHandlerPostfix ) { if ( events.size() > 0 ) { // There are problems if we create "pure" virtual handlers, because some // events could be triggered in the constructor in which virtual methods are // execute properly. // So we create a default handler which will skip the event. m_source->WriteLn( wxEmptyString ); m_source->WriteLn( wxT("// Virtual event handlers, overide them in your derived class") ); std::set<wxString> generatedHandlers; for ( size_t i = 0; i < events.size(); i++ ) { PEvent event = events[i]; wxString aux = wxT("function ") + event->GetValue() + wxT("( $event ){"); if (generatedHandlers.find(aux) == generatedHandlers.end()) { m_source->WriteLn(aux); m_source->Indent(); m_source->WriteLn(eventHandlerPostfix); m_source->Unindent(); m_source->WriteLn(wxT("}")); generatedHandlers.insert(aux); } if( i < (events.size()-1) ) m_source->WriteLn(); } m_source->WriteLn( wxEmptyString ); } }
void EventSheetEditor::CreateEventSelectionVector(SelectedEventVector& pSelectedEventList,EventVector& EventList) { for(int a = 0 ; a < EventList.size() ; a ++) { if(EventList[a]->m_select(this)) pSelectedEventList.push_back(EventList[a]); CreateEventSelectionVector(pSelectedEventList, EventList[a]->m_EventList); } }
void EventSheetEditor::CreateActionSelectionVector(SelectedActionVector& pSelectedActionList, EventVector& EventList) { for(int a = 0 ; a < EventList.size() ; a ++) { for(int c = 0; c < EventList[a]->m_Actions.size(); c ++ ) if( EventList[a]->m_Actions[c]->m_select(this)) pSelectedActionList.push_back(EventList[a]->m_Actions[c]); CreateActionSelectionVector(pSelectedActionList,EventList[a]->m_EventList); } }
void EventSheetEditor::CreateConditionSelectionVector(SelectedConditionVector& pSelectedConditionList, EventVector& EventList) { for(int a = 0 ; a < EventList.size() ; a ++) { for(int c = 0; c < EventList[a]->m_Conditions.size(); c ++ ) if( EventList[a]->m_Conditions[c]->m_select(this) && !EventList[a]->m_Conditions[c]->m_Anim.m_bDestroyed) pSelectedConditionList.push_back(EventList[a]->m_Conditions[c]); CreateConditionSelectionVector(pSelectedConditionList,EventList[a]->m_EventList); } }
void PHPCodeGenerator::GenEvents( PObjectBase class_obj, const EventVector &events, bool disconnect ) { if ( events.empty() ) { return; } if( disconnect ) { m_source->WriteLn( wxT("// Disconnect Events") ); } else { m_source->WriteLn(); m_source->WriteLn( wxT("// Connect Events") ); } PProperty propName = class_obj->GetProperty( wxT("name") ); if ( !propName ) { wxLogError(wxT("Missing \"name\" property on \"%s\" class. Review your XML object description"), class_obj->GetClassName().c_str()); return; } wxString class_name = propName->GetValue(); if ( class_name.empty() ) { wxLogError( wxT("Object name cannot be null") ); return; } wxString base_class; wxString handlerName; PProperty propSubclass = class_obj->GetProperty( wxT("subclass") ); if ( propSubclass ) { wxString subclass = propSubclass->GetChildFromParent( wxT("name") ); if ( !subclass.empty() ) { base_class = subclass; } } if ( base_class.empty() ) base_class = wxT("wx") + class_obj->GetClassName(); if ( events.size() > 0 ) { for ( size_t i = 0; i < events.size(); i++ ) { PEvent event = events[i]; handlerName = event->GetValue(); wxString templateName = wxString::Format( wxT("connect_%s"), event->GetName().c_str() ); PObjectBase obj = event->GetObject(); if ( !GenEventEntry( obj, obj->GetObjectInfo(), templateName, handlerName, disconnect ) ) { wxLogError( wxT("Missing \"evt_%s\" template for \"%s\" class. Review your XML object description"), templateName.c_str(), class_name.c_str() ); } } } }
void PHPCodeGenerator::GenerateInheritedClass( PObjectBase userClasses, PObjectBase form ) { if (!userClasses) { wxLogError(wxT("There is no object to generate inherited class")); return; } if ( wxT("UserClasses") != userClasses->GetClassName() ) { wxLogError(wxT("This not a UserClasses object")); return; } wxString type = userClasses->GetPropertyAsString( wxT("type") ); // Start file wxString code = GetCode( userClasses, wxT("file_comment") ); m_source->WriteLn( code ); m_source->WriteLn( wxEmptyString ); code = GetCode( userClasses, wxT("source_include") ); m_source->WriteLn( code ); m_source->WriteLn( wxEmptyString ); code = GetCode( userClasses, wxT("class_decl") ); m_source->WriteLn( code ); m_source->Indent(); code = GetCode( userClasses, type + wxT("_cons_def") ); m_source->WriteLn( code ); // Do events EventVector events; FindEventHandlers( form, events ); if ( events.size() > 0 ) { code = GetCode( userClasses, wxT("event_handler_comment") ); m_source->WriteLn( code ); std::set<wxString> generatedHandlers; for ( size_t i = 0; i < events.size(); i++ ) { PEvent event = events[i]; if ( generatedHandlers.find( event->GetValue() ) == generatedHandlers.end() ) { m_source->WriteLn( wxString::Format( wxT("function %s( event ){"), event->GetValue().c_str() ) ); m_source->Indent(); m_source->WriteLn( wxString::Format( wxT("// TODO: Implement %s"), event->GetValue().c_str() ) ); m_source->Unindent(); m_source->WriteLn( wxT("}") ); m_source->WriteLn( wxEmptyString ); generatedHandlers.insert(event->GetValue()); } } m_source->WriteLn( wxEmptyString ); } m_source->Unindent(); }