From 47a8b1e1ff2c9ee03db80a5ecbded9ab0551ea46 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 5 Jul 2009 15:21:52 +0000 Subject: [PATCH] added EVT_DATAVIEW_CACHE_HINT event (closes #9891) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61331 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + include/wx/dataview.h | 19 +++++++++++++++++-- interface/wx/dataview.h | 12 ++++++++++++ src/common/datavcmn.cpp | 4 ++++ src/generic/datavgen.cpp | 6 ++++++ 5 files changed, 40 insertions(+), 2 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index caedfce93e..b1bd83d833 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -364,6 +364,7 @@ All (GUI): - Added wxFont::[Make]{Bold,Italic,Smaller,Larger} and Scale[d]() methods. - Added wxDC::CopyAttributes() and use it in wxBufferedDC. - Added wxTextWrapper helper class useful for wrapping lines of text. +- Added EVT_DATAVIEW_CACHE_HINT() event (Trigve). GTK: diff --git a/include/wx/dataview.h b/include/wx/dataview.h index 9516534945..25cce4838f 100644 --- a/include/wx/dataview.h +++ b/include/wx/dataview.h @@ -754,7 +754,9 @@ public: m_model(NULL), m_value(wxNullVariant), m_column(NULL), - m_pos(-1,-1) + m_pos(-1,-1), + m_cacheFrom(0), + m_cacheTo(0) #if wxUSE_DRAG_AND_DROP , m_dataObject(NULL), m_dataBuffer(NULL), @@ -769,7 +771,9 @@ public: m_model(event.m_model), m_value(event.m_value), m_column(event.m_column), - m_pos(m_pos) + m_pos(m_pos), + m_cacheFrom(event.m_cacheFrom), + m_cacheTo(event.m_cacheTo) #if wxUSE_DRAG_AND_DROP , m_dataObject(event.m_dataObject), m_dataFormat(event.m_dataFormat), @@ -798,6 +802,12 @@ public: wxPoint GetPosition() const { return m_pos; } void SetPosition( int x, int y ) { m_pos.x = x; m_pos.y = y; } + // For wxEVT_COMMAND_DATAVIEW_CACHE_HINT + int GetCacheFrom() const { return m_cacheFrom; } + int GetCacheTo() const { return m_cacheTo; } + void SetCache(int from, int to) { m_cacheFrom = from; m_cacheTo = to; } + + #if wxUSE_DRAG_AND_DROP // For drag operations void SetDataObject( wxDataObject *obj ) { m_dataObject = obj; } @@ -821,6 +831,8 @@ protected: wxVariant m_value; wxDataViewColumn *m_column; wxPoint m_pos; + int m_cacheFrom; + int m_cacheTo; #if wxUSE_DRAG_AND_DROP wxDataObject *m_dataObject; @@ -853,6 +865,8 @@ wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_ wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED, wxDataViewEvent ); wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED, wxDataViewEvent ); +wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_CACHE_HINT, wxDataViewEvent ); + wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG, wxDataViewEvent ); wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE, wxDataViewEvent ); wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_DROP, wxDataViewEvent ); @@ -883,6 +897,7 @@ typedef void (wxEvtHandler::*wxDataViewEventFunction)(wxDataViewEvent&); #define EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_RIGHT_CLICK, id, fn) #define EVT_DATAVIEW_COLUMN_SORTED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_SORTED, id, fn) #define EVT_DATAVIEW_COLUMN_REORDERED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_REORDERED, id, fn) +#define EVT_DATAVIEW_CACHE_HINT(id, fn) wx__DECLARE_DATAVIEWEVT(CACHE_HINT, id, fn) #define EVT_DATAVIEW_ITEM_BEGIN_DRAG(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_BEGIN_DRAG, id, fn) #define EVT_DATAVIEW_ITEM_DROP_POSSIBLE(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_DROP_POSSIBLE, id, fn) diff --git a/interface/wx/dataview.h b/interface/wx/dataview.h index fcdd636a19..f7497f28d9 100644 --- a/interface/wx/dataview.h +++ b/interface/wx/dataview.h @@ -2318,6 +2318,8 @@ public: Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE event. @event{EVT_DATAVIEW_ITEM_DROP(id, func)} Process a @c wxEVT_COMMAND_DATAVIEW_ITEM_DROP event. + @event{EVT_DATAVIEW_CACHE_HINT(id, func)} + Process a @c wxEVT_COMMAND_DATAVIEW_CACHE_HINT event. @endEventTable @library{wxadv} @@ -2419,5 +2421,15 @@ public: Gets the data buffer for a drop data transfer. */ void *GetDataBuffer() const; + + /** + Return the first row that will be displayed. + */ + int GetCacheFrom() const; + + /** + Return the last row that will be displayed. + */ + int GetCacheTo() const; }; diff --git a/src/common/datavcmn.cpp b/src/common/datavcmn.cpp index ddfbd8c7e6..b54ad1982f 100644 --- a/src/common/datavcmn.cpp +++ b/src/common/datavcmn.cpp @@ -1250,10 +1250,14 @@ wxDEFINE_EVENT( wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK, wxDataViewEven wxDEFINE_EVENT( wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED, wxDataViewEvent ); wxDEFINE_EVENT( wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED, wxDataViewEvent ); +wxDEFINE_EVENT( wxEVT_COMMAND_DATAVIEW_CACHE_HINT, wxDataViewEvent ); + wxDEFINE_EVENT( wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG, wxDataViewEvent ); wxDEFINE_EVENT( wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE, wxDataViewEvent ); wxDEFINE_EVENT( wxEVT_COMMAND_DATAVIEW_ITEM_DROP, wxDataViewEvent ); + + // ------------------------------------- // wxDataViewSpinRenderer // ------------------------------------- diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index 9980dc7ab3..26af4a3b9c 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -1676,6 +1676,12 @@ void wxDataViewMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) ) wxMin( (int)( GetLineAt( wxMax(0,update.y+update.height) ) - item_start + 1), (int)(GetRowCount( ) - item_start)); unsigned int item_last = item_start + item_count; + // Get the parent of DataViewCtrl + wxWindow *parent = GetParent()->GetParent(); + wxDataViewEvent cache_event(wxEVT_COMMAND_DATAVIEW_CACHE_HINT, parent->GetId()); + cache_event.SetEventObject(GetParent()); + cache_event.SetCache(item_start, item_last - 1); + parent->ProcessWindowEvent(cache_event); // compute which columns needs to be redrawn unsigned int cols = GetOwner()->GetColumnCount(); -- 2.45.2