Bugfix patch from Alberto
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@24581 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1580,7 +1580,7 @@ wxTreeListItem *wxTreeListItem::HitTest(const wxPoint& point,
|
|||||||
{
|
{
|
||||||
// evaluate the item
|
// evaluate the item
|
||||||
int h = theCtrl->GetLineHeight(this);
|
int h = theCtrl->GetLineHeight(this);
|
||||||
if ((point.y > m_y) && (point.y < m_y + h))
|
if ((point.y > m_y) && (point.y <= m_y + h))
|
||||||
{
|
{
|
||||||
int y_mid = m_y + h/2;
|
int y_mid = m_y + h/2;
|
||||||
if (point.y < y_mid )
|
if (point.y < y_mid )
|
||||||
@@ -1649,15 +1649,16 @@ wxTreeListItem *wxTreeListItem::HitTest(const wxPoint& point,
|
|||||||
column = theCtrl->GetMainColumn(); //-1;
|
column = theCtrl->GetMainColumn(); //-1;
|
||||||
wxTreeListItem* res = HitTest(point, theCtrl, flags, level);
|
wxTreeListItem* res = HitTest(point, theCtrl, flags, level);
|
||||||
|
|
||||||
if(!res) {
|
if (!res) {
|
||||||
column = -1;
|
column = -1;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (point.x >= theCtrl->m_owner->GetHeaderWindow()->GetWidth())
|
if (point.x >= theCtrl->m_owner->GetHeaderWindow()->GetWidth())
|
||||||
column = -1;
|
column = -1;
|
||||||
else if(flags & wxTREE_HITTEST_ONITEMINDENT) {
|
else if (flags & wxTREE_HITTEST_ONITEMINDENT) {
|
||||||
int x = 0;
|
int x = 0;
|
||||||
for(size_t i = 0; i < theCtrl->GetMainColumn(); ++i) {
|
for (int i = 0; i < column; ++i) {
|
||||||
int w = theCtrl->m_owner->GetHeaderWindow()->GetColumnWidth(i);
|
int w = theCtrl->m_owner->GetHeaderWindow()->GetColumnWidth(i);
|
||||||
if(point.x >= x && point.x < x+w) {
|
if(point.x >= x && point.x < x+w) {
|
||||||
flags ^= wxTREE_HITTEST_ONITEMINDENT;
|
flags ^= wxTREE_HITTEST_ONITEMINDENT;
|
||||||
@@ -1665,23 +1666,24 @@ wxTreeListItem *wxTreeListItem::HitTest(const wxPoint& point,
|
|||||||
column = i;
|
column = i;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
x += w;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(flags & wxTREE_HITTEST_ONITEMRIGHT) {
|
else if (flags & wxTREE_HITTEST_ONITEMRIGHT) {
|
||||||
int x = 0;
|
int x = 0;
|
||||||
size_t i;
|
int i;
|
||||||
for(i = 0; i < theCtrl->GetMainColumn()+1; ++i) {
|
for (i = 0; i < column+1; ++i) {
|
||||||
x += theCtrl->m_owner->GetHeaderWindow()->GetColumnWidth(i);
|
x += theCtrl->m_owner->GetHeaderWindow()->GetColumnWidth(i);
|
||||||
}
|
}
|
||||||
for(i = theCtrl->GetMainColumn()+1;
|
for (i = column+1; i < theCtrl->GetColumnCount(); ++i) {
|
||||||
i < theCtrl->GetColumnCount(); ++i) {
|
|
||||||
int w = theCtrl->m_owner->GetHeaderWindow()->GetColumnWidth(i);
|
int w = theCtrl->m_owner->GetHeaderWindow()->GetColumnWidth(i);
|
||||||
if(point.x >= x && point.x < x+w) {
|
if (point.x >= x && point.x < x+w) {
|
||||||
flags ^= wxTREE_HITTEST_ONITEMRIGHT;
|
flags ^= wxTREE_HITTEST_ONITEMRIGHT;
|
||||||
flags |= wxTREE_HITTEST_ONITEMCOLUMN;
|
flags |= wxTREE_HITTEST_ONITEMCOLUMN;
|
||||||
column = i;
|
column = i;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
x += w;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2457,12 +2459,91 @@ void wxTreeListMainWindow::SendDeleteEvent(wxTreeListItem *item)
|
|||||||
m_owner->ProcessEvent( event );
|
m_owner->ProcessEvent( event );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// inline
|
||||||
|
// void wxTreeListMainWindow::DeleteChildren(const wxTreeItemId& itemId)
|
||||||
|
// {
|
||||||
|
// m_dirty = TRUE; // do this first so stuff below doesn't cause flicker
|
||||||
|
|
||||||
|
// wxTreeListItem *item = (wxTreeListItem*) itemId.m_pItem;
|
||||||
|
// item->DeleteChildren(this);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// inline
|
||||||
|
// void wxTreeListMainWindow::Delete(const wxTreeItemId& itemId)
|
||||||
|
// {
|
||||||
|
// m_dirty = TRUE; // do this first so stuff below doesn't cause flicker
|
||||||
|
|
||||||
|
// wxTreeListItem *item = (wxTreeListItem*) itemId.m_pItem;
|
||||||
|
|
||||||
|
// // don't stay with invalid m_key_current or we will crash in
|
||||||
|
// // the next call to OnChar()
|
||||||
|
// bool changeKeyCurrent = FALSE;
|
||||||
|
// wxTreeListItem *itemKey = m_key_current;
|
||||||
|
// while ( itemKey )
|
||||||
|
// {
|
||||||
|
// if ( itemKey == item )
|
||||||
|
// {
|
||||||
|
// // m_key_current is a descendant of the item being deleted
|
||||||
|
// changeKeyCurrent = TRUE;
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// itemKey = itemKey->GetParent();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// wxTreeListItem *parent = item->GetParent();
|
||||||
|
// if ( parent )
|
||||||
|
// {
|
||||||
|
// parent->GetChildren().Remove( item ); // remove by value
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if ( changeKeyCurrent )
|
||||||
|
// {
|
||||||
|
// // may be NULL or not
|
||||||
|
// m_key_current = parent;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// item->DeleteChildren(this);
|
||||||
|
// SendDeleteEvent(item);
|
||||||
|
// delete item;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// inline
|
||||||
|
// void wxTreeListMainWindow::DeleteAllItems()
|
||||||
|
// {
|
||||||
|
// if ( m_anchor )
|
||||||
|
// {
|
||||||
|
// m_dirty = TRUE;
|
||||||
|
|
||||||
|
// m_anchor->DeleteChildren(this);
|
||||||
|
// delete m_anchor;
|
||||||
|
|
||||||
|
// m_anchor = NULL;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
inline
|
inline
|
||||||
void wxTreeListMainWindow::DeleteChildren(const wxTreeItemId& itemId)
|
void wxTreeListMainWindow::DeleteChildren(const wxTreeItemId& itemId)
|
||||||
{
|
{
|
||||||
m_dirty = TRUE; // do this first so stuff below doesn't cause flicker
|
m_dirty = TRUE; // do this first so stuff below doesn't cause flicker
|
||||||
|
|
||||||
wxTreeListItem *item = (wxTreeListItem*) itemId.m_pItem;
|
wxTreeListItem *item = (wxTreeListItem*) itemId.m_pItem;
|
||||||
|
|
||||||
|
// mst:16.10.03
|
||||||
|
// moved from Delete()
|
||||||
|
// don't stay with invalid m_key_current or we will crash in
|
||||||
|
// the next call to OnChar()
|
||||||
|
wxTreeListItem *itemKey = m_key_current;
|
||||||
|
while ( itemKey )
|
||||||
|
{
|
||||||
|
if ( itemKey == item )
|
||||||
|
{
|
||||||
|
// m_key_current is a descendant of the item which childrens being deleted
|
||||||
|
m_key_current = item;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
itemKey = itemKey->GetParent();
|
||||||
|
}
|
||||||
|
|
||||||
item->DeleteChildren(this);
|
item->DeleteChildren(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2473,35 +2554,19 @@ void wxTreeListMainWindow::Delete(const wxTreeItemId& itemId)
|
|||||||
|
|
||||||
wxTreeListItem *item = (wxTreeListItem*) itemId.m_pItem;
|
wxTreeListItem *item = (wxTreeListItem*) itemId.m_pItem;
|
||||||
|
|
||||||
// don't stay with invalid m_key_current or we will crash in
|
// mst:16.10.03
|
||||||
// the next call to OnChar()
|
item->DeleteChildren(this);
|
||||||
bool changeKeyCurrent = FALSE;
|
|
||||||
wxTreeListItem *itemKey = m_key_current;
|
|
||||||
while ( itemKey )
|
|
||||||
{
|
|
||||||
if ( itemKey == item )
|
|
||||||
{
|
|
||||||
// m_key_current is a descendant of the item being deleted
|
|
||||||
changeKeyCurrent = TRUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
itemKey = itemKey->GetParent();
|
|
||||||
}
|
|
||||||
|
|
||||||
wxTreeListItem *parent = item->GetParent();
|
wxTreeListItem *parent = item->GetParent();
|
||||||
|
|
||||||
if ( parent )
|
if ( parent )
|
||||||
{
|
parent->GetChildren().Remove( item ); // remove by value
|
||||||
parent->GetChildren().Remove( item ); // remove by value
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( changeKeyCurrent )
|
if (m_key_current == item)
|
||||||
{
|
m_key_current = parent;
|
||||||
// may be NULL or not
|
|
||||||
m_key_current = parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
item->DeleteChildren(this);
|
|
||||||
SendDeleteEvent(item);
|
SendDeleteEvent(item);
|
||||||
|
|
||||||
delete item;
|
delete item;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2512,6 +2577,8 @@ void wxTreeListMainWindow::DeleteAllItems()
|
|||||||
{
|
{
|
||||||
m_dirty = TRUE;
|
m_dirty = TRUE;
|
||||||
|
|
||||||
|
m_key_current = NULL; // mst:16.10.03
|
||||||
|
|
||||||
m_anchor->DeleteChildren(this);
|
m_anchor->DeleteChildren(this);
|
||||||
delete m_anchor;
|
delete m_anchor;
|
||||||
|
|
||||||
@@ -2519,6 +2586,7 @@ void wxTreeListMainWindow::DeleteAllItems()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void wxTreeListMainWindow::Expand(const wxTreeItemId& itemId)
|
void wxTreeListMainWindow::Expand(const wxTreeItemId& itemId)
|
||||||
{
|
{
|
||||||
wxTreeListItem *item = (wxTreeListItem*) itemId.m_pItem;
|
wxTreeListItem *item = (wxTreeListItem*) itemId.m_pItem;
|
||||||
@@ -3772,12 +3840,8 @@ wxTreeItemId wxTreeListMainWindow::HitTest(const wxPoint& point, int& flags,
|
|||||||
return wxTreeItemId();
|
return wxTreeItemId();
|
||||||
}
|
}
|
||||||
|
|
||||||
wxClientDC dc(this);
|
wxTreeListItem *hit = m_anchor->HitTest(CalcUnscrolledPosition(point),
|
||||||
PrepareDC(dc);
|
this, flags, column, 0);
|
||||||
wxCoord x = dc.DeviceToLogicalX( point.x );
|
|
||||||
wxCoord y = dc.DeviceToLogicalY( point.y );
|
|
||||||
wxTreeListItem *hit = m_anchor->HitTest(wxPoint(x, y), this, flags,
|
|
||||||
column, 0);
|
|
||||||
if (hit == NULL)
|
if (hit == NULL)
|
||||||
{
|
{
|
||||||
flags = wxTREE_HITTEST_NOWHERE;
|
flags = wxTREE_HITTEST_NOWHERE;
|
||||||
@@ -4259,7 +4323,8 @@ void wxTreeListMainWindow::RefreshSubtree(wxTreeListItem *item)
|
|||||||
|
|
||||||
int cw = 0;
|
int cw = 0;
|
||||||
int ch = 0;
|
int ch = 0;
|
||||||
GetClientSize( &cw, &ch );
|
//GetClientSize( &cw, &ch );
|
||||||
|
GetVirtualSize(&cw, &ch);
|
||||||
|
|
||||||
wxRect rect;
|
wxRect rect;
|
||||||
rect.x = dc.LogicalToDeviceX( 0 );
|
rect.x = dc.LogicalToDeviceX( 0 );
|
||||||
@@ -4281,7 +4346,8 @@ void wxTreeListMainWindow::RefreshLine( wxTreeListItem *item )
|
|||||||
|
|
||||||
int cw = 0;
|
int cw = 0;
|
||||||
int ch = 0;
|
int ch = 0;
|
||||||
GetClientSize( &cw, &ch );
|
//GetClientSize( &cw, &ch );
|
||||||
|
GetVirtualSize(&cw, &ch);
|
||||||
|
|
||||||
wxRect rect;
|
wxRect rect;
|
||||||
rect.x = dc.LogicalToDeviceX( 0 );
|
rect.x = dc.LogicalToDeviceX( 0 );
|
||||||
@@ -4667,8 +4733,7 @@ void wxTreeListCtrl::ScrollTo(const wxTreeItemId& item)
|
|||||||
wxTreeItemId wxTreeListCtrl::HitTest(const wxPoint& pos, int& flags,
|
wxTreeItemId wxTreeListCtrl::HitTest(const wxPoint& pos, int& flags,
|
||||||
int& column)
|
int& column)
|
||||||
{
|
{
|
||||||
return m_main_win->HitTest(m_main_win->ScreenToClient(ClientToScreen(pos)),
|
return m_main_win->HitTest(pos, flags, column);
|
||||||
flags, column);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxTreeListCtrl::GetBoundingRect(const wxTreeItemId& item, wxRect& rect,
|
bool wxTreeListCtrl::GetBoundingRect(const wxTreeItemId& item, wxRect& rect,
|
||||||
|
Reference in New Issue
Block a user