I'm trying to make a user control in wxWidgets to represent a channel in an audio mixer. So, each channel has a standard set of controls inside itself (some sliders, buttons, etc..).
So inside my class I have a sizer in which I add the various child controls I need. So far that works.
But the problems I have are
if I derive from wxPanel, the layout of the control works as I expect it (it gets expanded in the sizer to fit the child controls), however none of the children get any events (like EVT_LEFT_DOWN etc). I tried connecting an event for the main control that runs event.Skip() but that didn't help.
If I change my class to derive from wxControl instead (or wxFrame, or possibly a number of others I tried), the child controls do get events, but the whole thing doesn't get expanded in the sizer it's located in, it just gets drawn as a tiny box (some 10-20 square px) even though the child controls take up much more space.
Any ideas?
Update:
mangoMixerStrip.cpp
mangoMixerStrip::mangoMixerStrip(wxFrame* parent, HostChannel* channel) : wxPanel(parent)
{
myChannel = channel;
SetBackgroundColour(wxColour(172,81,90));
wxBoxSizer* s = new wxBoxSizer(wxVERTICAL);
// some custom controls i made which all work fine when added like any other control, derived from wxPanel also
faderPan = new mangoFader(parent, 200, false, 55);
faderGain = new mangoFader(parent, 200, true, 126);
buttonSolo = new mangoButton(parent, false, ButtonGraphic::Solo);
s->Add(faderPan);
s->Add(buttonSolo);
s->Add(faderGain);
this->SetSizer(s);
this->Connect(wxEVT_LEFT_DOWN, wxMouseEventHandler(mangoMixerStrip::mouseDown)); // this function simply contains event.Skip()
}
in my main wxFrame
mangoFrameMain::mangoFrameMain(wxWindow* parent) : FrameMain( parent )
{
HostChannel* h = new HostChannel();
h->setName("what up"); // these 2 lines unrelated to the UI
mangoMixerStrip *test = new mangoMixerStrip(this, h);
this->GetSizer()->Add(test, 1, wxFIXED_MINSIZE, 0);
}
And to clarify: the mangoMixerStrip instance itself gets any events I connect to it, but its child controls do not.
Your controls should be children of your class derived from wxPanel, NOT children of the panel's parent.
faderPan = new mangoFader(parent, 200, false, 55);
should be
faderPan = new mangoFader(this, 200, false, 55);