Fix horizontal scrolling of wxPropertyGrid header
wxPropertyGridHeader associated with wxPropertyGrid has to be notified about every horizontal scroll of the grid. New position is sent with dedicated wxEVT_PG_HSCROLL event being handled by wxPropertyGridManager which in turn scrolls the header accordingly. See #18313.
This commit is contained in:
parent
8555f4abb0
commit
eb40eb4b84
@ -544,6 +544,7 @@ protected:
|
||||
void OnResize( wxSizeEvent& event );
|
||||
void OnPropertyGridSelect( wxPropertyGridEvent& event );
|
||||
void OnPGColDrag( wxPropertyGridEvent& event );
|
||||
void OnPGScrollH(wxPropertyGridEvent& evt);
|
||||
|
||||
|
||||
wxPropertyGrid* m_pPropGrid;
|
||||
|
@ -1456,7 +1456,10 @@ public:
|
||||
virtual bool SetFont( const wxFont& font ) wxOVERRIDE;
|
||||
virtual void SetExtraStyle( long exStyle ) wxOVERRIDE;
|
||||
virtual bool Reparent( wxWindowBase *newParent ) wxOVERRIDE;
|
||||
|
||||
virtual void ScrollWindow(int dx, int dy, const wxRect* rect) wxOVERRIDE;
|
||||
virtual void SetScrollbars(int pixelsPerUnitX, int pixelsPerUnitY,
|
||||
int noUnitsX, int noUnitsY,
|
||||
int xPos, int yPos, bool noRefresh) wxOVERRIDE;
|
||||
protected:
|
||||
virtual void DoThaw() wxOVERRIDE;
|
||||
|
||||
@ -1928,6 +1931,8 @@ protected:
|
||||
unsigned int selFlags = wxPG_SEL_NOVALIDATE,
|
||||
unsigned int column = 1 );
|
||||
|
||||
void SendEvent(wxEventType eventType, int intVal);
|
||||
|
||||
// This function only moves focus to the wxPropertyGrid if it already
|
||||
// was on one of its child controls.
|
||||
void SetFocusOnCanvas();
|
||||
@ -2025,6 +2030,7 @@ wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID,
|
||||
wxEVT_PG_COL_DRAGGING, wxPropertyGridEvent );
|
||||
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID,
|
||||
wxEVT_PG_COL_END_DRAG, wxPropertyGridEvent );
|
||||
wxDECLARE_EVENT(wxEVT_PG_HSCROLL, wxPropertyGridEvent);
|
||||
|
||||
#else
|
||||
enum {
|
||||
|
@ -321,7 +321,7 @@ private:
|
||||
else if ( i == colCount-1 )
|
||||
{
|
||||
// Compensate for the internal border and scrollbar
|
||||
int margin = pg->GetMarginWidth() + borderWidth + sbWidth;
|
||||
int margin = borderWidth;
|
||||
|
||||
colWidth += margin;
|
||||
colMinWidth += margin;
|
||||
@ -378,8 +378,12 @@ private:
|
||||
}
|
||||
else if ( evtType == wxEVT_HEADER_BEGIN_RESIZE )
|
||||
{
|
||||
// Don't allow resizing the rightmost column
|
||||
// (like it's not allowed for the rightmost wxPropertyGrid splitter)
|
||||
if ( col == (int)m_page->GetColumnCount() - 1 )
|
||||
hcEvent->Veto();
|
||||
// Never allow column resize if layout is static
|
||||
if ( m_manager->HasFlag(wxPG_STATIC_SPLITTER) )
|
||||
else if ( m_manager->HasFlag(wxPG_STATIC_SPLITTER) )
|
||||
hcEvent->Veto();
|
||||
// Allow application to veto dragging
|
||||
else if ( pg->SendEvent(wxEVT_PG_COL_BEGIN_DRAG,
|
||||
@ -1936,6 +1940,7 @@ void wxPropertyGridManager::ReconnectEventHandlers(wxWindowID oldId, wxWindowID
|
||||
oldId);
|
||||
Unbind(wxEVT_PG_COL_DRAGGING, &wxPropertyGridManager::OnPGColDrag, this,
|
||||
oldId);
|
||||
Unbind(wxEVT_PG_HSCROLL, &wxPropertyGridManager::OnPGScrollH, this, oldId);
|
||||
}
|
||||
|
||||
if (newId != wxID_NONE)
|
||||
@ -1944,6 +1949,7 @@ void wxPropertyGridManager::ReconnectEventHandlers(wxWindowID oldId, wxWindowID
|
||||
newId);
|
||||
Bind(wxEVT_PG_COL_DRAGGING, &wxPropertyGridManager::OnPGColDrag, this,
|
||||
newId);
|
||||
Bind(wxEVT_PG_HSCROLL, &wxPropertyGridManager::OnPGScrollH, this, newId);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1970,6 +1976,16 @@ wxPropertyGridManager::OnPGColDrag( wxPropertyGridEvent& WXUNUSED(event) )
|
||||
#endif
|
||||
}
|
||||
|
||||
void wxPropertyGridManager::OnPGScrollH(wxPropertyGridEvent& evt)
|
||||
{
|
||||
#if wxUSE_HEADERCTRL
|
||||
if ( m_pHeaderCtrl )
|
||||
{
|
||||
m_pHeaderCtrl->ScrollWindow(evt.GetInt(), 0);
|
||||
}
|
||||
#endif // wxUSE_HEADERCTRL
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
void wxPropertyGridManager::OnResize( wxSizeEvent& WXUNUSED(event) )
|
||||
|
@ -1275,6 +1275,38 @@ bool wxPropertyGrid::Reparent( wxWindowBase *newParent )
|
||||
return res;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
void wxPropertyGrid::ScrollWindow(int dx, int dy, const wxRect* rect)
|
||||
{
|
||||
wxControl::ScrollWindow(dx, dy, rect);
|
||||
if ( dx != 0 )
|
||||
{
|
||||
// Notify wxPropertyGridManager about the grid being scrolled horizontally
|
||||
// to scroll the column header, if present.
|
||||
SendEvent(wxEVT_PG_HSCROLL, dx);
|
||||
}
|
||||
}
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
void wxPropertyGrid::SetScrollbars(int pixelsPerUnitX, int pixelsPerUnitY,
|
||||
int noUnitsX, int noUnitsY,
|
||||
int xPos, int yPos, bool noRefresh)
|
||||
{
|
||||
int oldX;
|
||||
CalcUnscrolledPosition(0, 0, &oldX, NULL);
|
||||
wxScrollHelper::SetScrollbars(pixelsPerUnitX, pixelsPerUnitY,
|
||||
noUnitsX, noUnitsY, xPos, yPos, noRefresh);
|
||||
int newX;
|
||||
CalcUnscrolledPosition(0, 0, &newX, NULL);
|
||||
if ( newX != oldX )
|
||||
{
|
||||
// Notify wxPropertyGridManager about the grid being scrolled horizontally
|
||||
// to scroll the column header, if present.
|
||||
SendEvent(wxEVT_PG_HSCROLL, oldX - newX);
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// wxPropertyGrid Font and Colour Methods
|
||||
// -----------------------------------------------------------------------
|
||||
@ -4752,6 +4784,21 @@ bool wxPropertyGrid::SendEvent( int eventType, wxPGProperty* p,
|
||||
return evt.WasVetoed();
|
||||
}
|
||||
|
||||
void wxPropertyGrid::SendEvent(wxEventType eventType, int intVal)
|
||||
{
|
||||
wxPropertyGridEvent evt(eventType, m_eventObject->GetId());
|
||||
evt.SetPropertyGrid(this);
|
||||
evt.SetEventObject(m_eventObject);
|
||||
evt.SetProperty(NULL);
|
||||
evt.SetColumn(0);
|
||||
evt.SetInt(intVal);
|
||||
|
||||
wxPropertyGridEvent* prevProcessedEvent = m_processedEvent;
|
||||
m_processedEvent = &evt;
|
||||
m_eventObject->HandleWindowEvent(evt);
|
||||
m_processedEvent = prevProcessedEvent;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
// Return false if should be skipped
|
||||
@ -6276,6 +6323,7 @@ wxDEFINE_EVENT( wxEVT_PG_LABEL_EDIT_ENDING, wxPropertyGridEvent );
|
||||
wxDEFINE_EVENT( wxEVT_PG_COL_BEGIN_DRAG, wxPropertyGridEvent );
|
||||
wxDEFINE_EVENT( wxEVT_PG_COL_DRAGGING, wxPropertyGridEvent );
|
||||
wxDEFINE_EVENT( wxEVT_PG_COL_END_DRAG, wxPropertyGridEvent );
|
||||
wxDEFINE_EVENT( wxEVT_PG_HSCROLL, wxPropertyGridEvent);
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user