void NassiPlugin::BuildModuleMenu(const ModuleType type, wxMenu* menu, const FileTreeData* /*data*/) { //Some library module is ready to display a pop-up menu. //Check the parameter \"type\" and see which module it is //and append any items you need in the menu... //TIP: for consistency, add a separator as the first item... if ( !IsAttached() || !menu ) return; if ( type != mtEditorManager ) return; EditorManager* emngr = Manager::Get()->GetEditorManager(); if ( !emngr ) return; EditorBase *edb = emngr->GetActiveEditor(); if ( !edb || !edb->IsBuiltinEditor() ) return; cbStyledTextCtrl* stc = ((cbEditor*)edb)->GetControl(); if ( !stc ) return; wxMenu *NassiMenu = 0; // check if user can select to generate a diagram from selection if ( stc->GetLexer() == wxSCI_LEX_CPP && stc->GetSelectionEnd() - stc->GetSelectionStart() > 0 ) { if (! NassiMenu ) NassiMenu = new wxMenu(); NassiMenu->Append(idParseC, _("Create diagram")); } // check if user can insert an opened diagram wxArrayString names; for ( int i = 0 ; i < Manager::Get()->GetEditorManager()->GetEditorsCount() ; ++i ) { EditorBase *ed = Manager::Get()->GetEditorManager()->GetEditor( i ); if ( NassiEditorPanel::IsNassiEditor( ed ) ) names.Add(ed->GetTitle( ) ); } if ( stc->GetLexer() == wxSCI_LEX_CPP && names.GetCount() > 0 ) { if (! NassiMenu ) { NassiMenu = new wxMenu(); } else { NassiMenu->AppendSeparator(); } for ( int i = 0; i < static_cast<int>(names.GetCount()) && i < 10 ; ++i ) { NassiMenu->Append(insertCFromDiagram[i], _("insert from ") + names[i] ); } } if ( NassiMenu ) { menu->AppendSeparator(); menu->AppendSubMenu(NassiMenu, _("Nassi Shneiderman")); } }