X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/777f9cef025177773ad424e77a72019a0d9b6e94..831b64f32f204d1424e248d100c109974aa4238c:/src/generic/datavgen.cpp diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index 0d226bf965..9e1f5f7d43 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -168,6 +168,7 @@ protected: int m_scrollOffsetX; int m_buttonHeight; + bool m_vetoColumnDrag; bool m_delayedUpdate; wxImageList *m_imageList; @@ -1327,6 +1328,7 @@ bool wxDataViewHeaderWindowMSW::Create( wxDataViewCtrl *parent, wxWindowID id, m_scrollOffsetX = 0; m_delayedUpdate = false; + m_vetoColumnDrag = false; m_buttonHeight = wxRendererNative::Get().GetHeaderButtonHeight( this ); int x = pos.x == wxDefaultCoord ? 0 : pos.x, @@ -1506,6 +1508,13 @@ bool wxDataViewHeaderWindowMSW::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARA NMHEADER *nmHDR = (NMHEADER *)nmhdr; switch ( nmhdr->code ) { + case NM_RELEASEDCAPTURE: + { + // user has released the mouse + m_vetoColumnDrag = false; + } + break; + case HDN_BEGINTRACK: // user has started to resize a column: // do we need to veto it? @@ -1517,11 +1526,21 @@ bool wxDataViewHeaderWindowMSW::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARA break; case HDN_BEGINDRAG: - // user has started to reorder a column - if ((nmHDR->iItem != -1) && (!GetColumn(nmHDR->iItem)->IsReorderable())) + // valid column + if (nmHDR->iItem != -1) + { + // user has started to reorder a valid column + if ((m_vetoColumnDrag == true) || (!GetColumn(nmHDR->iItem)->IsReorderable())) + { + // veto it! + *result = TRUE; + m_vetoColumnDrag = true; + } + } + else { // veto it! - *result = TRUE; + m_vetoColumnDrag = true; } break; @@ -4057,15 +4076,12 @@ wxDataViewCtrl::~wxDataViewCtrl() if (m_notifier) GetModel()->RemoveNotifier( m_notifier ); - wxDataViewColumnList::const_iterator iter; - for (iter = m_cols.begin(); iter!=m_cols.end(); iter++) - { - delete *iter; - } + m_cols.Clear(); } void wxDataViewCtrl::Init() { + m_cols.DeleteContents(true); m_notifier = NULL; } @@ -4229,20 +4245,23 @@ wxDataViewColumn* wxDataViewCtrl::GetColumn( unsigned int pos ) const void wxDataViewCtrl::ColumnMoved( wxDataViewColumn* col, unsigned int new_pos ) { if (new_pos > m_cols.GetCount()) return; + + // Exchange position + m_cols.DeleteContents(false); m_cols.DeleteObject( col ); m_cols.Insert( new_pos, col ); + m_cols.DeleteContents(true); m_clientArea->UpdateDisplay(); } bool wxDataViewCtrl::DeleteColumn( wxDataViewColumn *column ) { - wxDataViewColumnList::compatibility_iterator ret = m_cols.Find( column ); + wxDataViewColumnList::compatibility_iterator ret = m_cols.Find( column ); if (!ret) return false; m_cols.Erase(ret); - delete column; OnColumnChange(); return true; @@ -4250,7 +4269,7 @@ bool wxDataViewCtrl::DeleteColumn( wxDataViewColumn *column ) bool wxDataViewCtrl::ClearColumns() { - m_cols.clear(); + m_cols.Clear(); OnColumnChange(); return true; }