HtcToolchainConfigDialog::HtcToolchainConfigDialog (wxWindow * parent, int id)
: wxPanel (parent, id, wxDefaultPosition, wxDefaultSize)
{
Layout();
}
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"));
}
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.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.
This is the contructor:CodeIn a first step I just wanted an empty window and then work on that. To open i didHtcToolchainConfigDialog::HtcToolchainConfigDialog (wxWindow * parent, int id)
: wxPanel (parent, id, wxDefaultPosition, wxDefaultSize)
{
Layout();
}CodeNothing happens except that C::B crashes when I exit...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"));
}
I then tried to use wxSmath for that and to make the dialog using the gui but that does not work either.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.
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?
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.
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.Yepp! That's exactly what I want and it works :-) Great
But there is no way with wxSmith... After C::B has eaten up more than 700MB of RAM my computer freezes and I am really getting problems...I really don't understand what you mean by this.
So I want to do the creation "by hand" -- that technique is more robust, anyway...I disagree. I believe loading GUI resources from an XRC file is more robust by far. I use this technique constantly. So does C::B itself.
But I cannot find a method to add controls to the wxDialog... There is just a wxWindow::AddChild(wxWindow*) whose documentation states that this method is internal to wxWidgets and should not be called by the user.Merely pass the appropriate parent window (in this case, your derived dialog class) as the parent argument to the control's constructor, and then add the control to the appropriate sizer, making sure to call Layout() when everything has been added. (This assumes you're using sizers for layout, because constraints are deprecated and absolute positioning is evil.)
I guess the addition of a child must be done by sending an appropriate event but the wx documentation keeps silent on that...
Thank for a hint!