static void AbiMathView_removeFromMenus () { // First we need to get a pointer to the application itself. XAP_App *pApp = XAP_App::getApp(); // remove the edit method EV_EditMethodContainer* pEMC = pApp->getEditMethodContainer() ; EV_EditMethod * pEM = ev_EditMethod_lookup ( "AbiMathView_FileInsert" ) ; pEMC->removeEditMethod ( pEM ) ; DELETEP( pEM ) ; pEM = ev_EditMethod_lookup ( "AbiMathView_LatexInsert" ) ; pEMC->removeEditMethod ( pEM ) ; DELETEP( pEM ) ; // now remove crap from the menus XAP_Menu_Factory * pFact = pApp->getMenuFactory(); pFact->removeMenuItem("Main",NULL,newEquationID); pFact->removeMenuItem("Main",NULL,FromFileID); pFact->removeMenuItem("Main",NULL,FromLatexID); pFact->removeMenuItem("Main",NULL, endEquationID); pApp->rebuildMenus(); }
static void AbiMathView_addToMenus() { // First we need to get a pointer to the application itself. XAP_App *pApp = XAP_App::getApp(); // // Translated Strings // const XAP_StringSet * pSS = pApp->getStringSet(); AbiMathView_MenuLabelEquation= pSS->getValue(AP_STRING_ID_MENU_LABEL_INSERT_EQUATION); AbiMathView_MenuTooltipEquation = pSS->getValue(AP_STRING_ID_MENU_LABEL_TOOLTIP_INSERT_EQUATION); AbiMathView_MenuLabelFileInsert = pSS->getValue(AP_STRING_ID_MENU_LABEL_INSERT_EQUATION_FILE); AbiMathView_MenuTooltipFileInsert = pSS->getValue(AP_STRING_ID_MENU_LABEL_TOOLTIP_INSERT_EQUATION_FILE); AbiMathView_MenuLabelLatexInsert = pSS->getValue(AP_STRING_ID_MENU_LABEL_INSERT_EQUATION_LATEX); AbiMathView_MenuTooltipLatexInsert = pSS->getValue(AP_STRING_ID_MENU_LABEL_TOOLTIP_INSERT_EQUATION_LATEX); // Create an EditMethod that will link our method's name with // it's callback function. This is used to link the name to // the callback. EV_EditMethod *myEditMethodFile = new EV_EditMethod( "AbiMathView_FileInsert", // name of callback function AbiMathView_FileInsert, // callback function itself. 0, // no additional data required. "" // description -- allegedly never used for anything ); EV_EditMethod *myEditMethodLatex = new EV_EditMethod( "AbiMathView_LatexInsert", // name of callback function AbiMathView_LatexInsert, // callback function itself. 0, // no additional data required. "" // description -- allegedly never used for anything ); // Now we need to get the EditMethod container for the application. // This holds a series of Edit Methods and links names to callbacks. EV_EditMethodContainer* pEMC = pApp->getEditMethodContainer(); // We have to add our EditMethod to the application's EditMethodList // so that the application will know what callback to call when a call // to "AbiMathView_FileInsert" is received. pEMC->addEditMethod(myEditMethodFile); pEMC->addEditMethod(myEditMethodLatex); // Now we need to grab an ActionSet. This is going to be used later // on in our for loop. Take a look near the bottom. EV_Menu_ActionSet* pActionSet = pApp->getMenuActionSet(); XAP_Menu_Factory * pFact = pApp->getMenuFactory(); // Put it after Insert Picture in the Main menu newEquationID= pFact->addNewMenuAfter("Main",NULL,AP_MENU_ID_INSERT_GRAPHIC,EV_MLF_BeginSubMenu); UT_DEBUGMSG(("newEquationID %d \n",newEquationID)); pFact->addNewLabel(NULL,newEquationID,AbiMathView_MenuLabelEquation, AbiMathView_MenuTooltipEquation); // Create the Action that will be called. EV_Menu_Action* myEquationAction = new EV_Menu_Action( newEquationID, // id that the layout said we could use 1, // yes, we have a sub menu. 0, // no, we don't raise a dialog. 0, // no, we don't have a checkbox. 0, // no radio buttons for me, thank you NULL, // no callback function to call. NULL, // don't know/care what this is for NULL // don't know/care what this is for ); // Now what we need to do is add this particular action to the ActionSet // of the application. This forms the link between our new ID that we // got for this particular frame with the EditMethod that knows how to // call our callback function. pActionSet->addAction(myEquationAction); FromFileID= pFact->addNewMenuAfter("Main",NULL,newEquationID,EV_MLF_Normal); UT_DEBUGMSG(("FromFile ID %d \n",FromFileID)); pFact->addNewLabel(NULL,FromFileID,AbiMathView_MenuLabelFileInsert, AbiMathView_MenuTooltipFileInsert); // Create the Action that will be called. EV_Menu_Action* myFileAction = new EV_Menu_Action( FromFileID, // id that the layout said we could use 0, // no, we don't have a sub menu. 1, // yes, we raise a dialog. 0, // no, we don't have a checkbox. 0, // no radio buttons for me, thank you "AbiMathView_FileInsert", // name of callback function to call. NULL, // don't know/care what this is for NULL // don't know/care what this is for ); // Now what we need to do is add this particular action to the ActionSet // of the application. This forms the link between our new ID that we // got for this particular frame with the EditMethod that knows how to // call our callback function. pActionSet->addAction(myFileAction); FromLatexID= pFact->addNewMenuAfter("Main",NULL,FromFileID,EV_MLF_Normal); UT_DEBUGMSG(("Latex ID %d \n",FromLatexID)); pFact->addNewLabel(NULL,FromLatexID,AbiMathView_MenuLabelLatexInsert, AbiMathView_MenuTooltipLatexInsert); // Create the Action that will be called. EV_Menu_Action* myLatexAction = new EV_Menu_Action( FromLatexID, // id that the layout said we could use 0, // no, we don't have a sub menu. 1, // yes, we raise a dialog. 0, // no, we don't have a checkbox. 0, // no radio buttons for me, thank you "AbiMathView_LatexInsert", // name of callback function to call. NULL, // don't know/care what this is for NULL // don't know/care what this is for ); pActionSet->addAction(myLatexAction); endEquationID= pFact->addNewMenuAfter("Main",NULL,AbiMathView_MenuLabelLatexInsert,EV_MLF_EndSubMenu); UT_DEBUGMSG(("End Equation ID %d \n",endEquationID)); pFact->addNewLabel(NULL,endEquationID,AbiMathView_MenuEndEquation,NULL); // Create the Action that will be called. EV_Menu_Action* myEndEquationAction = new EV_Menu_Action( endEquationID, // id that the layout said we could use 0, // no, we don't have a sub menu. 0, // no, we raise a dialog. 0, // no, we don't have a checkbox. 0, // no radio buttons for me, thank you NULL, // name of callback function to call. NULL, // don't know/care what this is for NULL // don't know/care what this is for ); pActionSet->addAction(myEndEquationAction); pApp->rebuildMenus(); }