Get rid of QtGetScrollBarsContainer() from wxWindow API under wxQt
Because It is simpler to initialize (the inherited) m_qtContainer member directly in derived classes during construction process, and make the API a little bit cleaner.
This commit is contained in:
parent
5fb8a54e14
commit
31aac5fac4
8 changed files with 25 additions and 47 deletions
|
|
@ -51,7 +51,6 @@ public:
|
|||
virtual void RemoveChild( wxWindowBase *child ) override;
|
||||
|
||||
QMainWindow *GetQMainWindow() const;
|
||||
virtual QAbstractScrollArea *QtGetScrollBarsContainer() const override;
|
||||
|
||||
protected:
|
||||
virtual wxPoint GetClientAreaOrigin() const override;
|
||||
|
|
|
|||
|
|
@ -87,8 +87,6 @@ protected:
|
|||
|
||||
virtual int DoListHitTest(const wxPoint& point) const override;
|
||||
|
||||
virtual QAbstractScrollArea *QtGetScrollBarsContainer() const override;
|
||||
|
||||
#if wxUSE_CHECKLISTBOX
|
||||
bool m_hasCheckBoxes;
|
||||
#endif // wxUSE_CHECKLISTBOX
|
||||
|
|
|
|||
|
|
@ -93,8 +93,6 @@ protected:
|
|||
virtual bool DoLoadFile(const wxString& file, int fileType) override;
|
||||
virtual bool DoSaveFile(const wxString& file, int fileType) override;
|
||||
|
||||
virtual QAbstractScrollArea *QtGetScrollBarsContainer() const override;
|
||||
|
||||
// From wxTextEntry:
|
||||
virtual wxWindow *GetEditableWindow() override { return this; }
|
||||
|
||||
|
|
|
|||
|
|
@ -181,8 +181,6 @@ public:
|
|||
virtual void QtHandleShortcut ( int command );
|
||||
#endif // wxUSE_ACCEL
|
||||
|
||||
virtual QAbstractScrollArea *QtGetScrollBarsContainer() const;
|
||||
|
||||
#if wxUSE_TOOLTIPS
|
||||
// applies tooltip to the widget.
|
||||
virtual void QtApplyToolTip(const wxString& text);
|
||||
|
|
@ -228,11 +226,13 @@ protected:
|
|||
// itself.
|
||||
virtual QWidget* QtGetParentWidget() const { return GetHandle(); }
|
||||
|
||||
QWidget *m_qtWindow;
|
||||
QWidget *m_qtWindow;
|
||||
QAbstractScrollArea *m_qtContainer; // either nullptr or the same as m_qtWindow pointer
|
||||
// if m_qtWindow derives from QAbstractScrollArea,
|
||||
// e.g. QListWidget and QTextEdit.
|
||||
|
||||
private:
|
||||
void Init();
|
||||
QAbstractScrollArea *m_qtContainer; // either nullptr or the same as m_qtWindow pointer
|
||||
|
||||
// Return the viewport of m_qtContainer, if it's used, or just m_qtWindow.
|
||||
//
|
||||
|
|
|
|||
|
|
@ -209,11 +209,6 @@ void wxFrame::RemoveChild( wxWindowBase *child )
|
|||
wxFrameBase::RemoveChild( child );
|
||||
}
|
||||
|
||||
QAbstractScrollArea *wxFrame::QtGetScrollBarsContainer() const
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// get the origin of the client area in the client coordinates
|
||||
// excluding any menubar and toolbar if any.
|
||||
wxPoint wxFrame::GetClientAreaOrigin() const
|
||||
|
|
|
|||
|
|
@ -178,6 +178,7 @@ void wxListBox::DoCreate(wxWindow* parent, long style)
|
|||
Init();
|
||||
|
||||
m_qtWindow =
|
||||
m_qtContainer =
|
||||
m_qtListWidget = new wxQtListWidget( parent, this );
|
||||
|
||||
if ( style & wxLB_SORT )
|
||||
|
|
@ -368,11 +369,6 @@ void wxListBox::QtSendEvent(wxEventType evtType, int rowIndex, bool selected)
|
|||
SendEvent(evtType, rowIndex, selected);
|
||||
}
|
||||
|
||||
QAbstractScrollArea *wxListBox::QtGetScrollBarsContainer() const
|
||||
{
|
||||
return static_cast<QAbstractScrollArea*>(m_qtListWidget);
|
||||
}
|
||||
|
||||
void wxListBox::UnSelectAll()
|
||||
{
|
||||
Q_FOREACH(QListWidgetItem* l, m_qtListWidget->selectedItems())
|
||||
|
|
|
|||
|
|
@ -676,6 +676,9 @@ bool wxTextCtrl::Create(wxWindow *parent,
|
|||
|
||||
m_qtEdit->SetStyleFlags(style);
|
||||
|
||||
m_qtWindow =
|
||||
m_qtContainer = m_qtEdit->ScrollBarsContainer();
|
||||
|
||||
if ( QtCreateControl( parent, id, pos, size, style, validator, name ) )
|
||||
{
|
||||
// set the initial text value without sending the event:
|
||||
|
|
@ -910,8 +913,3 @@ QWidget *wxTextCtrl::GetHandle() const
|
|||
{
|
||||
return (QWidget *) m_qtEdit->GetHandle();
|
||||
}
|
||||
|
||||
QAbstractScrollArea *wxTextCtrl::QtGetScrollBarsContainer() const
|
||||
{
|
||||
return m_qtEdit->ScrollBarsContainer();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -443,8 +443,8 @@ void wxWindowQt::AddChild( wxWindowBase *child )
|
|||
{
|
||||
// Make sure all children are children of the inner scroll area widget (if any):
|
||||
|
||||
if ( QtGetScrollBarsContainer() )
|
||||
QtReparent( child->GetHandle(), QtGetScrollBarsContainer()->viewport() );
|
||||
if ( m_qtContainer )
|
||||
QtReparent( child->GetHandle(), m_qtContainer->viewport() );
|
||||
|
||||
wxWindowBase::AddChild( child );
|
||||
}
|
||||
|
|
@ -548,9 +548,9 @@ void wxWindowQt::Update()
|
|||
{
|
||||
wxLogTrace(TRACE_QT_WINDOW, wxT("wxWindow::Update %s"), GetName());
|
||||
// send the paint event to the inner widget in scroll areas:
|
||||
if ( QtGetScrollBarsContainer() )
|
||||
if ( m_qtContainer )
|
||||
{
|
||||
QtGetScrollBarsContainer()->viewport()->repaint();
|
||||
m_qtContainer->viewport()->repaint();
|
||||
} else {
|
||||
GetHandle()->repaint();
|
||||
}
|
||||
|
|
@ -561,9 +561,9 @@ void wxWindowQt::Refresh( bool WXUNUSED( eraseBackground ), const wxRect *rect )
|
|||
QWidget *widget;
|
||||
|
||||
// get the inner widget in scroll areas:
|
||||
if ( QtGetScrollBarsContainer() )
|
||||
if ( m_qtContainer )
|
||||
{
|
||||
widget = QtGetScrollBarsContainer()->viewport();
|
||||
widget = m_qtContainer->viewport();
|
||||
} else {
|
||||
widget = GetHandle();
|
||||
}
|
||||
|
|
@ -701,15 +701,14 @@ QWidget *wxWindowQt::QtGetClientWidget() const
|
|||
/* Returns a scrollbar for the given orientation */
|
||||
QScrollBar *wxWindowQt::QtGetScrollBar( int orientation ) const
|
||||
{
|
||||
QAbstractScrollArea *scrollArea = QtGetScrollBarsContainer();
|
||||
wxCHECK_MSG( scrollArea, nullptr, "Window without scrolling area" );
|
||||
wxCHECK_MSG( m_qtContainer, nullptr, "Window without scrolling area" );
|
||||
|
||||
if ( orientation == wxHORIZONTAL )
|
||||
{
|
||||
return scrollArea->horizontalScrollBar();
|
||||
return m_qtContainer->horizontalScrollBar();
|
||||
}
|
||||
|
||||
return scrollArea->verticalScrollBar();
|
||||
return m_qtContainer->verticalScrollBar();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -780,8 +779,8 @@ void wxWindowQt::ScrollWindow( int dx, int dy, const wxRect *rect )
|
|||
{
|
||||
// check if this is a scroll area (scroll only inner viewport)
|
||||
QWidget *widget;
|
||||
if ( QtGetScrollBarsContainer() )
|
||||
widget = QtGetScrollBarsContainer()->viewport();
|
||||
if ( m_qtContainer )
|
||||
widget = m_qtContainer->viewport();
|
||||
else
|
||||
widget = GetHandle();
|
||||
// scroll the widget or the specified rect (not children)
|
||||
|
|
@ -1166,8 +1165,8 @@ bool wxWindowQt::QtSetBackgroundStyle()
|
|||
{
|
||||
QWidget *widget;
|
||||
// if it is a scroll area, don't make transparent (invisible) scroll bars:
|
||||
if ( QtGetScrollBarsContainer() )
|
||||
widget = QtGetScrollBarsContainer()->viewport();
|
||||
if ( m_qtContainer )
|
||||
widget = m_qtContainer->viewport();
|
||||
else
|
||||
widget = GetHandle();
|
||||
// check if the control is created (wxGTK requires calling it before):
|
||||
|
|
@ -1283,8 +1282,8 @@ bool wxWindowQt::QtHandlePaintEvent ( QWidget *handler, QPaintEvent *event )
|
|||
* for the client area (the scrolled part). Events for the whole window
|
||||
* (including scrollbars and maybe status or menu bars are handled by Qt */
|
||||
|
||||
if ( (QtGetScrollBarsContainer() &&
|
||||
QtGetScrollBarsContainer() != handler) || handler != GetHandle() )
|
||||
if ( (m_qtContainer &&
|
||||
m_qtContainer != handler) || handler != GetHandle() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1294,10 +1293,10 @@ bool wxWindowQt::QtHandlePaintEvent ( QWidget *handler, QPaintEvent *event )
|
|||
|
||||
// Prepare the Qt painter for wxWindowDC:
|
||||
bool ok = false;
|
||||
if ( QtGetScrollBarsContainer() )
|
||||
if ( m_qtContainer )
|
||||
{
|
||||
// QScrollArea can only draw in the viewport:
|
||||
ok = m_qtPainter->begin( QtGetScrollBarsContainer()->viewport() );
|
||||
ok = m_qtPainter->begin( m_qtContainer->viewport() );
|
||||
}
|
||||
if ( !ok )
|
||||
{
|
||||
|
|
@ -1774,11 +1773,6 @@ QWidget *wxWindowQt::GetHandle() const
|
|||
return m_qtWindow;
|
||||
}
|
||||
|
||||
QAbstractScrollArea *wxWindowQt::QtGetScrollBarsContainer() const
|
||||
{
|
||||
return m_qtContainer;
|
||||
}
|
||||
|
||||
void wxWindowQt::QtSetPicture( QPicture* pict )
|
||||
{
|
||||
m_qtPicture.reset(pict);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue