A more complete fix for the generic control border issue, a fix for getting/setting wxListItemAttr info for the native control, fixes for HitTest considering the column the 0 item, and for GetItemRect being one off in virtual mode. Also a fix for the function call when using a custom sort routine.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43299 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Kevin Ollivier
2006-11-11 05:41:12 +00:00
parent 80a06ad284
commit d2af7584c0

View File

@@ -390,11 +390,12 @@ wxListCtrlTextCtrlWrapper::wxListCtrlTextCtrlWrapper(wxListCtrl *owner,
m_aboutToFinish = false; m_aboutToFinish = false;
wxRect rectLabel; wxRect rectLabel;
int offset = 8;
owner->GetItemRect(itemEdit, rectLabel); owner->GetItemRect(itemEdit, rectLabel);
m_text->Create(owner, wxID_ANY, m_startValue, m_text->Create(owner, wxID_ANY, m_startValue,
wxPoint(rectLabel.x+8,rectLabel.y), wxPoint(rectLabel.x+offset,rectLabel.y),
wxSize(rectLabel.width,rectLabel.height)); wxSize(rectLabel.width-offset,rectLabel.height));
m_text->SetFocus(); m_text->SetFocus();
m_text->PushEventHandler(this); m_text->PushEventHandler(this);
@@ -627,7 +628,13 @@ bool wxListCtrl::Create(wxWindow *parent,
{ {
m_macIsUserPane = true; m_macIsUserPane = true;
if ( !wxWindow::Create(parent, id, pos, size, style | wxNO_BORDER, name) ) long paneStyle = style;
paneStyle &= ~wxSIMPLE_BORDER;
paneStyle &= ~wxDOUBLE_BORDER;
paneStyle &= ~wxSUNKEN_BORDER;
paneStyle &= ~wxRAISED_BORDER;
paneStyle &= ~wxSTATIC_BORDER;
if ( !wxWindow::Create(parent, id, pos, size, paneStyle | wxNO_BORDER, name) )
return false; return false;
// since the generic control is a child, make sure we position it at 0, 0 // since the generic control is a child, make sure we position it at 0, 0
@@ -1041,10 +1048,10 @@ bool wxListCtrl::SetItemState(long item, long state, long stateMask)
return m_genericImpl->SetItemState(item, state, stateMask); return m_genericImpl->SetItemState(item, state, stateMask);
wxListItem info; wxListItem info;
info.m_itemId = item;
info.m_mask = wxLIST_MASK_STATE; info.m_mask = wxLIST_MASK_STATE;
info.m_stateMask = stateMask; info.m_stateMask = stateMask;
info.m_state = state; info.m_state = state;
info.m_itemId = item;
return SetItem(info); return SetItem(info);
} }
@@ -1168,7 +1175,7 @@ bool wxListCtrl::GetItemRect(long item, wxRect& rect, int code) const
id = (DataBrowserItemID) thisItem; id = (DataBrowserItemID) thisItem;
} }
else else
id = item; id = item+1;
GetDataBrowserItemPartBounds( m_dbImpl->GetControlRef(), id, col, part, &bounds ); GetDataBrowserItemPartBounds( m_dbImpl->GetControlRef(), id, col, part, &bounds );
@@ -1680,6 +1687,9 @@ wxListCtrl::HitTest(const wxPoint& point, int& flags, long *ptrSubItem) const
if ( !(GetWindowStyleFlag() & wxLC_NO_HEADER) ) if ( !(GetWindowStyleFlag() & wxLC_NO_HEADER) )
y -= colHeaderHeight; y -= colHeaderHeight;
if ( y < 0 )
return -1;
int row = y / rowHeight; int row = y / rowHeight;
DataBrowserItemID id; DataBrowserItemID id;
m_dbImpl->GetItemID( (DataBrowserTableViewRowIndex) row, &id ); m_dbImpl->GetItemID( (DataBrowserTableViewRowIndex) row, &id );
@@ -2659,12 +2669,9 @@ Boolean wxMacDataBrowserListCtrlControl::CompareItems(DataBrowserItemID itemOneI
wxString itemText; wxString itemText;
wxString otherItemText; wxString otherItemText;
int colId = sortProperty - kMinColumnId; int colId = sortProperty - kMinColumnId;
long itemNum = 0;
long otherItemNum = 0;
wxListCtrl* list = wxDynamicCast( GetPeer() , wxListCtrl ); wxListCtrl* list = wxDynamicCast( GetPeer() , wxListCtrl );
// means we need to
if (colId >= 0) if (colId >= 0)
{ {
if (!m_isVirtual) if (!m_isVirtual)
@@ -2672,11 +2679,12 @@ Boolean wxMacDataBrowserListCtrlControl::CompareItems(DataBrowserItemID itemOneI
wxMacListCtrlItem* item = (wxMacListCtrlItem*)itemOneID; wxMacListCtrlItem* item = (wxMacListCtrlItem*)itemOneID;
wxMacListCtrlItem* otherItem = (wxMacListCtrlItem*)itemTwoID; wxMacListCtrlItem* otherItem = (wxMacListCtrlItem*)itemTwoID;
wxListCtrlCompare func = list->GetCompareFunc(); wxListCtrlCompare func = list->GetCompareFunc();
if (func != NULL && item->HasColumnInfo(colId) && otherItem->HasColumnInfo(colId)) long item1 = GetLineFromItem(item);
return func(item->GetColumnInfo(colId)->GetData(), otherItem->GetColumnInfo(colId)->GetData(), list->GetCompareFuncData()) >= 0; long item2 = GetLineFromItem(otherItem);
if (func != NULL && item->HasColumnInfo(colId) && otherItem->HasColumnInfo(colId))
return func(item1, item2, list->GetCompareFuncData()) >= 0;
itemNum = item->GetOrder();
otherItemNum = otherItem->GetOrder();
if (item->HasColumnInfo(colId)) if (item->HasColumnInfo(colId))
itemText = item->GetColumnInfo(colId)->GetText(); itemText = item->GetColumnInfo(colId)->GetText();
if (otherItem->HasColumnInfo(colId)) if (otherItem->HasColumnInfo(colId))
@@ -2684,8 +2692,9 @@ Boolean wxMacDataBrowserListCtrlControl::CompareItems(DataBrowserItemID itemOneI
} }
else else
{ {
itemNum = (long)itemOneID;
otherItemNum = (long)itemTwoID; long itemNum = (long)itemOneID;
long otherItemNum = (long)itemTwoID;
itemText = list->OnGetItemText( itemNum-1, colId ); itemText = list->OnGetItemText( itemNum-1, colId );
otherItemText = list->OnGetItemText( otherItemNum-1, colId ); otherItemText = list->OnGetItemText( otherItemNum-1, colId );
@@ -2751,29 +2760,36 @@ void wxMacDataBrowserListCtrlControl::MacGetColumnInfo( unsigned int row, unsign
//if (item) //if (item)
{ {
wxMacListCtrlItem* listItem = dynamic_cast<wxMacListCtrlItem*>(dataItem); wxMacListCtrlItem* listItem = dynamic_cast<wxMacListCtrlItem*>(dataItem);
if (!listItem->HasColumnInfo( column ))
return;
wxListItem* oldItem = listItem->GetColumnInfo( column ); wxListItem* oldItem = listItem->GetColumnInfo( column );
long mask = item.GetMask(); if (oldItem)
if ( !mask ) {
// by default, get everything for backwards compatibility long mask = item.GetMask();
mask = -1; if ( !mask )
// by default, get everything for backwards compatibility
mask = -1;
if ( mask & wxLIST_MASK_TEXT ) if ( mask & wxLIST_MASK_TEXT )
item.SetText(oldItem->GetText()); item.SetText(oldItem->GetText());
if ( mask & wxLIST_MASK_IMAGE ) if ( mask & wxLIST_MASK_IMAGE )
item.SetImage(oldItem->GetImage()); item.SetImage(oldItem->GetImage());
if ( mask & wxLIST_MASK_DATA ) if ( mask & wxLIST_MASK_DATA )
item.SetData(oldItem->GetData()); item.SetData(oldItem->GetData());
if ( mask & wxLIST_MASK_STATE ) if ( mask & wxLIST_MASK_STATE )
item.SetState(oldItem->GetState()); item.SetState(oldItem->GetState());
if ( mask & wxLIST_MASK_WIDTH ) if ( mask & wxLIST_MASK_WIDTH )
item.SetWidth(oldItem->GetWidth()); item.SetWidth(oldItem->GetWidth());
if ( mask & wxLIST_MASK_FORMAT ) if ( mask & wxLIST_MASK_FORMAT )
item.SetAlign(oldItem->GetAlign()); item.SetAlign(oldItem->GetAlign());
item.SetTextColour(oldItem->GetTextColour()); item.SetTextColour(oldItem->GetTextColour());
item.SetBackgroundColour(oldItem->GetBackgroundColour()); item.SetBackgroundColour(oldItem->GetBackgroundColour());
item.SetFont(oldItem->GetFont()); item.SetFont(oldItem->GetFont());
}
} }
} }
@@ -2858,9 +2874,17 @@ void wxMacListCtrlItem::SetColumnInfo( unsigned int column, wxListItem* item )
if (mask & wxLIST_MASK_WIDTH) if (mask & wxLIST_MASK_WIDTH)
listItem->SetWidth(item->GetWidth()); listItem->SetWidth(item->GetWidth());
listItem->SetTextColour(item->GetTextColour()); if ( item->HasAttributes() )
listItem->SetBackgroundColour(item->GetBackgroundColour()); {
listItem->SetFont(item->GetFont()); if ( listItem->HasAttributes() )
listItem->GetAttributes()->AssignFrom(*item->GetAttributes());
else
{
listItem->SetTextColour(item->GetTextColour());
listItem->SetBackgroundColour(item->GetBackgroundColour());
listItem->SetFont(item->GetFont());
}
}
} }
} }