diff --git a/include/wx/propgrid/manager.h b/include/wx/propgrid/manager.h index bbd0bb94d8..b707ce9ffd 100644 --- a/include/wx/propgrid/manager.h +++ b/include/wx/propgrid/manager.h @@ -544,6 +544,7 @@ protected: void OnResize( wxSizeEvent& event ); void OnPropertyGridSelect( wxPropertyGridEvent& event ); void OnPGColDrag( wxPropertyGridEvent& event ); + void OnPGScrollH(wxPropertyGridEvent& evt); wxPropertyGrid* m_pPropGrid; diff --git a/include/wx/propgrid/propgrid.h b/include/wx/propgrid/propgrid.h index 114a02f19b..4cbda4c90d 100644 --- a/include/wx/propgrid/propgrid.h +++ b/include/wx/propgrid/propgrid.h @@ -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 { diff --git a/src/propgrid/manager.cpp b/src/propgrid/manager.cpp index 9437e48c89..51556e6eb2 100644 --- a/src/propgrid/manager.cpp +++ b/src/propgrid/manager.cpp @@ -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) ) diff --git a/src/propgrid/propgrid.cpp b/src/propgrid/propgrid.cpp index e630dead3d..4dfbddc3c7 100644 --- a/src/propgrid/propgrid.cpp +++ b/src/propgrid/propgrid.cpp @@ -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); // -----------------------------------------------------------------------