Improved handling of column widths, removed need for hidden column for sorting, and put in a stub for editing support.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41310 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -909,7 +909,7 @@ public :
|
||||
DataBrowserPropertyID property) const;
|
||||
|
||||
void InsertColumn(int colId, DataBrowserPropertyType colType,
|
||||
const wxString& title, SInt16 just = teFlushDefault, int minWidth = -1, int maxWidth = -1);
|
||||
const wxString& title, SInt16 just = teFlushDefault, int defaultWidth = -1);
|
||||
|
||||
int GetColumnWidth(int colId);
|
||||
void SetColumnWidth(int colId, int width);
|
||||
@@ -986,6 +986,8 @@ public :
|
||||
|
||||
virtual wxClientDataType GetClientDataType() const;
|
||||
virtual void SetClientDataType(wxClientDataType clientDataItemsType);
|
||||
virtual ListSortOrder GetSortOrder() const;
|
||||
virtual void SetSortOrder(const ListSortOrder sort);
|
||||
|
||||
|
||||
|
||||
|
@@ -1085,8 +1085,9 @@ long wxListCtrl::InsertColumn(long col, wxListItem& item)
|
||||
return m_genericImpl->InsertColumn(col, item);
|
||||
|
||||
if (m_dbImpl){
|
||||
if ( !(item.GetMask() & wxLIST_MASK_WIDTH) ) //item.GetWidth() == 0)
|
||||
item.SetWidth(300);
|
||||
if ( !(item.GetMask() & wxLIST_MASK_WIDTH) )
|
||||
item.SetWidth(150);
|
||||
|
||||
DataBrowserPropertyType type = kDataBrowserTextType;
|
||||
wxImageList* imageList = GetImageList(wxIMAGE_LIST_SMALL);
|
||||
if (imageList && imageList->GetImageCount() > 0){
|
||||
@@ -1105,7 +1106,17 @@ long wxListCtrl::InsertColumn(long col, wxListItem& item)
|
||||
else if (item.GetAlign() == wxLIST_FORMAT_RIGHT)
|
||||
just = teFlushRight;
|
||||
}
|
||||
m_dbImpl->InsertColumn(col, type, item.GetText(), just, -1, item.GetWidth());
|
||||
m_dbImpl->InsertColumn(col, type, item.GetText(), just, item.GetWidth());
|
||||
|
||||
if (GetWindowStyleFlag() & wxLC_EDIT_LABELS)
|
||||
{
|
||||
DataBrowserTableViewColumnID id;
|
||||
m_dbImpl->GetColumnIDFromIndex(col, &id);
|
||||
DataBrowserPropertyFlags flags;
|
||||
verify_noerr(m_dbImpl->GetPropertyFlags(id, &flags));
|
||||
flags |= kDataBrowserPropertyIsEditable;
|
||||
verify_noerr(m_dbImpl->SetPropertyFlags(id, flags));
|
||||
}
|
||||
}
|
||||
|
||||
return col;
|
||||
@@ -1259,15 +1270,6 @@ void wxMacListCtrlItem::Notification(wxMacDataItemBrowserControl *owner ,
|
||||
return;
|
||||
}
|
||||
|
||||
// CS : couldn't reproduce this problem, what are the steps to test ?
|
||||
// 1) wxDynamicCast fails during shutdown. This doesn't suprise me, but
|
||||
// you have similar listbox code, so I'm wondering why this case is different.
|
||||
|
||||
// CS: these two should be fixed now
|
||||
// 2) owner->GetLineFromItem( this ) always asserts.
|
||||
// 3) the !lb->IsSelectionSuppressed code also fails with EXC_BAD_ACCESS
|
||||
|
||||
// during shutdown, this may fail.
|
||||
wxListCtrl *list = wxDynamicCast( owner->GetPeer() , wxListCtrl );
|
||||
if ( list ){
|
||||
bool trigger = false;
|
||||
@@ -1329,31 +1331,6 @@ wxMacDataBrowserListCtrlControl::wxMacDataBrowserListCtrlControl( wxWindow *peer
|
||||
err = SetSelectionFlags( options );
|
||||
verify_noerr( err );
|
||||
|
||||
// create the numeric order column
|
||||
DataBrowserListViewColumnDesc columnDesc;
|
||||
columnDesc.headerBtnDesc.titleOffset = 0;
|
||||
columnDesc.headerBtnDesc.version = kDataBrowserListViewLatestHeaderDesc;
|
||||
|
||||
columnDesc.headerBtnDesc.btnFontStyle.flags =
|
||||
kControlUseFontMask | kControlUseJustMask;
|
||||
|
||||
columnDesc.headerBtnDesc.btnContentInfo.contentType = kControlNoContent;
|
||||
columnDesc.headerBtnDesc.btnFontStyle.just = teFlushDefault;
|
||||
columnDesc.headerBtnDesc.btnFontStyle.font = kControlFontViewSystemFont;
|
||||
columnDesc.headerBtnDesc.btnFontStyle.style = normal;
|
||||
columnDesc.headerBtnDesc.titleString = NULL;
|
||||
|
||||
columnDesc.headerBtnDesc.minimumWidth = 0;
|
||||
columnDesc.headerBtnDesc.maximumWidth = 0;
|
||||
columnDesc.propertyDesc.propertyID = kNumericOrderColumnId;
|
||||
columnDesc.propertyDesc.propertyType = kDataBrowserPropertyRelevanceRankPart;
|
||||
columnDesc.propertyDesc.propertyFlags = kDataBrowserTableViewSelectionColumn;
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
|
||||
columnDesc.propertyDesc.propertyFlags |= kDataBrowserListViewTypeSelectColumn;
|
||||
#endif
|
||||
|
||||
verify_noerr( AddColumn( &columnDesc, kDataBrowserListViewAppendColumn ) );
|
||||
|
||||
if ( style & wxLC_LIST ){
|
||||
InsertColumn(0, kDataBrowserIconAndTextType, wxEmptyString, -1, -1);
|
||||
verify_noerr( AutoSizeColumns() );
|
||||
@@ -1376,7 +1353,7 @@ wxMacDataBrowserListCtrlControl::wxMacDataBrowserListCtrlControl( wxWindow *peer
|
||||
else
|
||||
{
|
||||
m_sortOrder = SortOrder_None;
|
||||
SetDataBrowserSortProperty( m_controlRef , kNumericOrderColumnId);
|
||||
SetDataBrowserSortProperty( m_controlRef , kMinColumnId);
|
||||
SetDataBrowserSortOrder( m_controlRef , kDataBrowserOrderIncreasing);
|
||||
}
|
||||
|
||||
@@ -1546,6 +1523,7 @@ OSStatus wxMacListCtrlItem::GetSetData( wxMacDataItemBrowserControl *owner ,
|
||||
DataBrowserItemDataRef itemData,
|
||||
bool changeValue )
|
||||
{
|
||||
|
||||
OSStatus err = errDataBrowserPropertyNotSupported;
|
||||
if ( !changeValue )
|
||||
{
|
||||
|
@@ -1646,11 +1646,11 @@ bool wxMacDataItem::IsLessThan(wxMacDataItemBrowserControl *owner ,
|
||||
const wxMacDataItem* otherItem = dynamic_cast<const wxMacDataItem*>(rhs);
|
||||
bool retval = false;
|
||||
|
||||
if ( sortProperty == m_colId ){
|
||||
if ( sortProperty == m_colId && owner->GetSortOrder() != SortOrder_None){
|
||||
retval = m_label.CmpNoCase( otherItem->m_label) < 0;
|
||||
}
|
||||
|
||||
else if ( sortProperty == kNumericOrderColumnId )
|
||||
else if ( owner->GetSortOrder() == SortOrder_None || sortProperty == kNumericOrderColumnId )
|
||||
retval = m_order < otherItem->m_order;
|
||||
|
||||
return retval;
|
||||
@@ -1703,6 +1703,16 @@ wxMacDataItemBrowserControl::wxMacDataItemBrowserControl( wxWindow* peer , const
|
||||
m_clientDataItemsType = wxClientData_None;
|
||||
}
|
||||
|
||||
ListSortOrder wxMacDataItemBrowserControl::GetSortOrder() const
|
||||
{
|
||||
return m_sortOrder;
|
||||
}
|
||||
|
||||
void wxMacDataItemBrowserControl::SetSortOrder(const ListSortOrder sort)
|
||||
{
|
||||
m_sortOrder = sort;
|
||||
}
|
||||
|
||||
wxMacDataItem* wxMacDataItemBrowserControl::CreateItem()
|
||||
{
|
||||
return new wxMacDataItem();
|
||||
@@ -1870,7 +1880,7 @@ void wxMacDataItemBrowserControl::UpdateItems(const wxMacDataItem *container,
|
||||
}
|
||||
|
||||
void wxMacDataItemBrowserControl::InsertColumn(int colId, DataBrowserPropertyType colType,
|
||||
const wxString& title, SInt16 just, int minWidth, int maxWidth)
|
||||
const wxString& title, SInt16 just, int defaultWidth)
|
||||
{
|
||||
DataBrowserListViewColumnDesc columnDesc;
|
||||
columnDesc.headerBtnDesc.titleOffset = 0;
|
||||
@@ -1894,16 +1904,9 @@ void wxMacDataItemBrowserControl::InsertColumn(int colId, DataBrowserPropertyTyp
|
||||
wxMacCFStringHolder cfTitle;
|
||||
cfTitle.Assign( title, enc );
|
||||
columnDesc.headerBtnDesc.titleString = cfTitle;
|
||||
|
||||
int colMinWidth = 0;
|
||||
if (minWidth != -1)
|
||||
colMinWidth = minWidth;
|
||||
columnDesc.headerBtnDesc.minimumWidth = colMinWidth;
|
||||
|
||||
int colMaxWidth = 500;
|
||||
if (maxWidth != -1)
|
||||
colMaxWidth = maxWidth;
|
||||
columnDesc.headerBtnDesc.maximumWidth = colMaxWidth;
|
||||
|
||||
columnDesc.headerBtnDesc.minimumWidth = 0;
|
||||
columnDesc.headerBtnDesc.maximumWidth = 30000;
|
||||
|
||||
columnDesc.propertyDesc.propertyID = (kMinColumnId + colId);
|
||||
columnDesc.propertyDesc.propertyType = colType;
|
||||
@@ -1913,6 +1916,11 @@ void wxMacDataItemBrowserControl::InsertColumn(int colId, DataBrowserPropertyTyp
|
||||
#endif
|
||||
|
||||
verify_noerr( AddColumn( &columnDesc, kDataBrowserListViewAppendColumn ) );
|
||||
|
||||
if (defaultWidth > 0){
|
||||
SetColumnWidth(colId, defaultWidth);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void wxMacDataItemBrowserControl::SetColumnWidth(int colId, int width)
|
||||
|
Reference in New Issue
Block a user