Plugin oriented App Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2292
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania
Contact:

Post by evstevemd » Sat Jan 01, 2011 10:41 am

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!
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
[Ubuntu 19.04/Windows 10 Pro/MacOS 10.13 - GCC/MinGW/Clang, CodeLite IDE]

User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2292
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania
Contact:

Post by evstevemd » Fri Jan 14, 2011 12:39 pm

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
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
[Ubuntu 19.04/Windows 10 Pro/MacOS 10.13 - GCC/MinGW/Clang, CodeLite IDE]

User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2292
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania
Contact:

Post by evstevemd » Fri Jan 14, 2011 12:54 pm

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);
}
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
[Ubuntu 19.04/Windows 10 Pro/MacOS 10.13 - GCC/MinGW/Clang, CodeLite IDE]

Post Reply