int m_scrollOffsetX;
int m_buttonHeight;
+ bool m_vetoColumnDrag;
bool m_delayedUpdate;
wxImageList *m_imageList;
m_scrollOffsetX = 0;
m_delayedUpdate = false;
+ m_vetoColumnDrag = false;
m_buttonHeight = wxRendererNative::Get().GetHeaderButtonHeight( this );
int x = pos.x == wxDefaultCoord ? 0 : pos.x,
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?
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;
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;
}
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;
bool wxDataViewCtrl::ClearColumns()
{
- m_cols.clear();
+ m_cols.Clear();
OnColumnChange();
return true;
}