I have dialog class (derived from wxDialog) with fixed min size. The dialog class has wxCustomPanel* member (derived from wxPanel) also some collapsible panels are present on dialog. wxCustomPanel* member is used as a template type for wxScrolled<>:
Code: Select all
wxCustomPanel* wxRTSharesManagerDialog::CreateContent()
{
wxScrolled<wxCustomPanel> *contentPanel = new wxScrolled<wxCustomPanel>(m_dialogContent);
auto contentSizer = new wxBoxSizer(wxVERTICAL);
SetMinSize(FromDIP(wxSize(-1, minHeight)));
// more controls are created here
m_usersPane = new wxRTUsersPane(contentPanel, wxID_ANY, wxEmptyString, m_usedShares, true); // collapsible pain
m_usersSizer = m_usersPane->CreateContent(contentPanel);
m_usersSizer->SetSizeHints(m_usersPane);
contentSizer->Add(m_usersSizer, wxSizerFlags(0).Align(wxALIGN_LEFT).Expand());
contentPanel->SetSizer(contentSizer);
contentPanel->SetAutoLayout(true);
contentPanel->SetScrollRate(0, 16);
contentSizer->Fit(m_dialogContent);
return contentPanel;
}
Code: Select all
void wxCustomDialog::UpdateLayout()
{
m_dialogContent->GetSizer()->SetSizeHints(m_dialogContent);
Fit();
Layout();
Refresh();
}
void wxCustomDialog::Fit()
{
m_dialogContent->Fit(); // m_dialogContent has wxCustomPanel type. This is the object that is used as wxScrolled base
m_dialogContent->Layout();
wxDialog::Fit();
}
Here is code for resize:
Code: Select all
void wxRTSharesManagerDialog::OnMouseMove(wxMouseEvent& event)
{
wxPoint pt = event.GetPosition();
wxRect windowRect = this->GetRect();
bool isInResizePos = false;
if (windowRect.GetHeight() - pt.y < 5)
{
SetCursor(wxCURSOR_SIZENS);
m_isResizePos = true;
}
else
{
SetCursor(wxCURSOR_DEFAULT);
m_isResizePos = false;
}
if (m_isResizeMode)
{
if (event.Dragging() && event.LeftIsDown())
{
wxPoint pos = ClientToScreen(pt);
wxSize sz = GetSize();
sz.y += pos.y - windowRect.GetBottom();
if (sz.y > minHeight)
{
SetSize(sz);
}
}
}
}