Ensure that scrollbars are shown in scrolled popup in the popup sample.
Don't call SetScrollbars(), this is overridden by sizer logic later. Instead, add a sufficiently big window to the popup and make fix the size of the popup itself to be smaller to ensure that the scrollbars do show. Closes #14900. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73319 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
ef68861e11
commit
b7bd58d09a
@ -66,7 +66,7 @@ enum
|
|||||||
class SimpleTransientPopup: public wxPopupTransientWindow
|
class SimpleTransientPopup: public wxPopupTransientWindow
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SimpleTransientPopup( wxWindow *parent );
|
SimpleTransientPopup( wxWindow *parent, bool scrolled );
|
||||||
virtual ~SimpleTransientPopup();
|
virtual ~SimpleTransientPopup();
|
||||||
|
|
||||||
// wxPopupTransientWindow virtual methods are all overridden to log them
|
// wxPopupTransientWindow virtual methods are all overridden to log them
|
||||||
@ -75,8 +75,6 @@ public:
|
|||||||
virtual bool ProcessLeftDown(wxMouseEvent& event);
|
virtual bool ProcessLeftDown(wxMouseEvent& event);
|
||||||
virtual bool Show( bool show = true );
|
virtual bool Show( bool show = true );
|
||||||
|
|
||||||
wxScrolledWindow* GetChild() { return m_panel; }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wxScrolledWindow *m_panel;
|
wxScrolledWindow *m_panel;
|
||||||
wxButton *m_button;
|
wxButton *m_button;
|
||||||
@ -110,7 +108,7 @@ BEGIN_EVENT_TABLE(SimpleTransientPopup,wxPopupTransientWindow)
|
|||||||
EVT_SPINCTRL( Minimal_PopupSpinctrl, SimpleTransientPopup::OnSpinCtrl )
|
EVT_SPINCTRL( Minimal_PopupSpinctrl, SimpleTransientPopup::OnSpinCtrl )
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
SimpleTransientPopup::SimpleTransientPopup( wxWindow *parent )
|
SimpleTransientPopup::SimpleTransientPopup( wxWindow *parent, bool scrolled )
|
||||||
:wxPopupTransientWindow( parent )
|
:wxPopupTransientWindow( parent )
|
||||||
{
|
{
|
||||||
m_panel = new wxScrolledWindow( this, wxID_ANY );
|
m_panel = new wxScrolledWindow( this, wxID_ANY );
|
||||||
@ -142,9 +140,30 @@ SimpleTransientPopup::SimpleTransientPopup( wxWindow *parent )
|
|||||||
topSizer->Add( m_spinCtrl, 0, wxALL, 5 );
|
topSizer->Add( m_spinCtrl, 0, wxALL, 5 );
|
||||||
topSizer->Add( m_mouseText, 0, wxCENTRE|wxALL, 5 );
|
topSizer->Add( m_mouseText, 0, wxCENTRE|wxALL, 5 );
|
||||||
|
|
||||||
|
if ( scrolled )
|
||||||
|
{
|
||||||
|
// Add a big window to ensure that scrollbars are shown when we set the
|
||||||
|
// panel size to a lesser size below.
|
||||||
|
topSizer->Add(new wxPanel(m_panel, wxID_ANY, wxDefaultPosition,
|
||||||
|
wxSize(600, 900)));
|
||||||
|
}
|
||||||
|
|
||||||
m_panel->SetSizer( topSizer );
|
m_panel->SetSizer( topSizer );
|
||||||
topSizer->Fit(m_panel);
|
if ( scrolled )
|
||||||
topSizer->Fit(this);
|
{
|
||||||
|
// Set the fixed size to ensure that the scrollbars are shown.
|
||||||
|
m_panel->SetSize(300, 300);
|
||||||
|
|
||||||
|
// And also actually enable them.
|
||||||
|
m_panel->SetScrollRate(10, 10);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Use the fitting size for the panel if we don't need scrollbars.
|
||||||
|
topSizer->Fit(m_panel);
|
||||||
|
}
|
||||||
|
|
||||||
|
SetClientSize(m_panel->GetSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
SimpleTransientPopup::~SimpleTransientPopup()
|
SimpleTransientPopup::~SimpleTransientPopup()
|
||||||
@ -389,7 +408,7 @@ void MyFrame::OnStartSimplePopup(wxCommandEvent& event)
|
|||||||
{
|
{
|
||||||
wxLogMessage( wxT("================================================") );
|
wxLogMessage( wxT("================================================") );
|
||||||
delete m_simplePopup;
|
delete m_simplePopup;
|
||||||
m_simplePopup = new SimpleTransientPopup( this );
|
m_simplePopup = new SimpleTransientPopup( this, false );
|
||||||
wxWindow *btn = (wxWindow*) event.GetEventObject();
|
wxWindow *btn = (wxWindow*) event.GetEventObject();
|
||||||
wxPoint pos = btn->ClientToScreen( wxPoint(0,0) );
|
wxPoint pos = btn->ClientToScreen( wxPoint(0,0) );
|
||||||
wxSize sz = btn->GetSize();
|
wxSize sz = btn->GetSize();
|
||||||
@ -402,8 +421,7 @@ void MyFrame::OnStartScrolledPopup(wxCommandEvent& event)
|
|||||||
{
|
{
|
||||||
wxLogMessage( wxT("================================================") );
|
wxLogMessage( wxT("================================================") );
|
||||||
delete m_scrolledPopup;
|
delete m_scrolledPopup;
|
||||||
m_scrolledPopup = new SimpleTransientPopup( this );
|
m_scrolledPopup = new SimpleTransientPopup( this, true );
|
||||||
m_scrolledPopup->GetChild()->SetScrollbars(1, 1, 1000, 1000);
|
|
||||||
wxWindow *btn = (wxWindow*) event.GetEventObject();
|
wxWindow *btn = (wxWindow*) event.GetEventObject();
|
||||||
wxPoint pos = btn->ClientToScreen( wxPoint(0,0) );
|
wxPoint pos = btn->ClientToScreen( wxPoint(0,0) );
|
||||||
wxSize sz = btn->GetSize();
|
wxSize sz = btn->GetSize();
|
||||||
@ -466,7 +484,7 @@ void MyDialog::OnStartSimplePopup(wxCommandEvent& event)
|
|||||||
{
|
{
|
||||||
wxLogMessage( wxT("================================================") );
|
wxLogMessage( wxT("================================================") );
|
||||||
delete m_simplePopup;
|
delete m_simplePopup;
|
||||||
m_simplePopup = new SimpleTransientPopup( this );
|
m_simplePopup = new SimpleTransientPopup( this, false );
|
||||||
wxWindow *btn = (wxWindow*) event.GetEventObject();
|
wxWindow *btn = (wxWindow*) event.GetEventObject();
|
||||||
wxPoint pos = btn->ClientToScreen( wxPoint(0,0) );
|
wxPoint pos = btn->ClientToScreen( wxPoint(0,0) );
|
||||||
wxSize sz = btn->GetSize();
|
wxSize sz = btn->GetSize();
|
||||||
@ -479,8 +497,7 @@ void MyDialog::OnStartScrolledPopup(wxCommandEvent& event)
|
|||||||
{
|
{
|
||||||
wxLogMessage( wxT("================================================") );
|
wxLogMessage( wxT("================================================") );
|
||||||
delete m_scrolledPopup;
|
delete m_scrolledPopup;
|
||||||
m_scrolledPopup = new SimpleTransientPopup( this );
|
m_scrolledPopup = new SimpleTransientPopup( this, true );
|
||||||
m_scrolledPopup->GetChild()->SetScrollbars(1, 1, 1000, 1000);
|
|
||||||
wxWindow *btn = (wxWindow*) event.GetEventObject();
|
wxWindow *btn = (wxWindow*) event.GetEventObject();
|
||||||
wxPoint pos = btn->ClientToScreen( wxPoint(0,0) );
|
wxPoint pos = btn->ClientToScreen( wxPoint(0,0) );
|
||||||
wxSize sz = btn->GetSize();
|
wxSize sz = btn->GetSize();
|
||||||
|
Loading…
Reference in New Issue
Block a user