Page 5 of 5

Posted: Sat Jan 01, 2011 10:41 am
by evstevemd
So far this is what I have done:
1. Made A plugin Interface that have common methods (getName,et al). Each plugin constructor receives pointer to IManager.

2. The Manager Interface have virtual Methods for accessing Application resources.

I have two problems:One is how to Integrate IManager interface with application itself (i.e. wxFrame) and second one is that I need to add one method that will return the instance of plugins. something like:

Code: Select all

IPlugin* RegisterMe(){
    return new ThisPlugin();
}
I have seen this line in CodeLite which I guess does what I want but cannot understand (I'm somehow poor at Macros)

Code: Select all

//Every dll must contain at least this function

typedef IPlugin*    (*GET_PLUGIN_CREATE_FUNC)            (IManager*);

typedef PluginInfo  (*GET_PLUGIN_INFO_FUNC)              ();

typedef int         (*GET_PLUGIN_INTERFACE_VERSION_FUNC) ();
Thanks!

Posted: Fri Jan 14, 2011 12:39 pm
by evstevemd
I'm now almost done!
The final stage is connecting event that seems not to work.
I can hook the Menu Item to Tools Menu and in my plugin I have something like:

Code: Select all


void MyPlugin::createPluginMenu(wxMenu* toolsMenu) {
	toolsMenu->Append(ID_PLUGIN_TEST, wxT("Test panel!"));
	Connect(ID_PLUGIN_TEST, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MyPlugin::addPannel), NULL, this);
}
and somewhere in same file I have

Code: Select all


void MyPlugin::addPannel(wxCommandEvent& e) {
	wxMessageBox(wxT("It works!"));
}
But it doesn't work. ID_PLUGIN_TEST is defined in Enum of my personal IDs so it should not be the issue as all other works. I guess I mess somewhere with event sinking.

Thanks

Posted: Fri Jan 14, 2011 12:54 pm
by evstevemd
I changed my connect to one below and it works!
I'm not sure if that is good way, but it works

Code: Select all

void MyPlugin::createPluginMenu(wxMenu* toolsMenu) {
        toolsMenu->Append(ID_PLUGIN_TEST, wxT("Test panel!"));
         toolsMenu->Connect(ID_PLUGIN_TEST, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MyPlugin::addPannel), NULL, this);
}