As I am newbee, I had a peek at the sources of the code snippets plugin and how the windows stuff is implemented. So I tried to do the same: Derive a dialog from wxPanel and send a message to the dialog to let the window pop up. However, it does not work and I am clueless why no window is shown and C::B crashes.
This is the contructor:
HtcToolchainConfigDialog::HtcToolchainConfigDialog (wxWindow * parent, int id)
: wxPanel (parent, id, wxDefaultPosition, wxDefaultSize)
{
Layout();
}
In a first step I just wanted an empty window and then work on that. To open i did
void HtcToolchainPlugin::OnItemConfig (wxCommandEvent& event)
{
if (!m_pConfigDialog)
return;
CodeBlocksDockEvent evt (cbEVT_SHOW_DOCK_WINDOW);
evt.pWindow = m_pConfigDialog;
Manager::Get()->GetAppWindow()->ProcessEvent (evt);
Log (_("HTC: Config opened"));
}
Nothing happens except that C::B crashes when I exit...
The particular CodeSnippetsWindow you appear to be copying is actually not a traditional dialog window at all. It uses wxAUI, the docking system C::B uses, to create a panel that can float anywhere or be docked between other wxAUI panels. wxAUI panels are a bit tricker to create than more basic dialogs, so it's easy to miss something and mess things up.
It appears that, in emulating the CodeSnippets window, you missed a few important things that appear in the CodeSnippets::CreateSnippetWindow() function. Lines 198-210 in codesnippets.cpp perform the necessary initialization, informing the main Code::Blocks window of a new wxAUI panel to be added by using a cbEVT_ADD_DOCK_WINDOW CodeBlocksDockEvent. Only after this event has been successfully processed should a cbEVT_SHOW_DOCK_WINDOW event be used to show the panel.
If you don't need your dialog to be dockable, don't make it so. It's much simpler to just derive from wxDialog and show it modally or modelessly -- also, there are a few good helper functions in the C::B SDK for working with dialogs.
I then tried to use wxSmath for that and to make the dialog using the gui but that does not work either.
No windows comes up and C::B crashes *badly*: I coun not even login via ssh and had to hard reset my computer. Is tere som manual on the wxSmith stuff?
wxSmith is a generator for standard wxWidgets XRC and C++, so the XRC ("XML-based ResourCe system") section of the wxWidgets documentation would probably be helpful. Reading the generated code, as well.
BTW: What is the ::Config method of the plugin for? There are no plugin configs in C::B's menues and the method has no effect and gets never called.
It's a relic from RC2 days. The GetConfigurationPanel method is used now. The "Environment", "Editor", and "Compiler and debugger" settings dialogs are all candidates to contain plugin configuration pages; the plugin gets to choose which one to use.