return m_count;
}
+void wxListCtrl::SetItemSpacing( int spacing, bool isSmall )
+{
+ if (m_genericImpl)
+ m_genericImpl->SetItemSpacing(spacing, isSmall);
+}
+
wxSize wxListCtrl::GetItemSpacing() const
{
if (m_genericImpl)
return m_genericImpl->InsertItem(info);
if (m_dbImpl){
+ int count = GetItemCount();
+
+ if (info.m_itemId > count)
+ info.m_itemId = count;
+
m_dbImpl->MacInsertItem(info.m_itemId, &info );
wxListEvent event( wxEVT_COMMAND_LIST_INSERT_ITEM, GetId() );
event.SetEventObject( this );
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){
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;
DataBrowserItemDataRef itemData ) const
{
- wxMacDataBrowserListControl *lb = dynamic_cast<wxMacDataBrowserListControl*>(owner);
+ wxMacDataBrowserListCtrlControl *lb = dynamic_cast<wxMacDataBrowserListCtrlControl*>(owner);
// we want to depend on as little as possible to make sure tear-down of controls is safe
if ( message == kDataBrowserItemRemoved)
delete this;
return;
}
+ else if ( message == kDataBrowserItemAdded )
+ {
+ // we don't issue events on adding, the item is not really stored in the list yet, so we
+ // avoid asserts by gettting out now
+ return ;
+ }
- // TO STEFAN: I'm getting a couple different problems here and I'd appreciate
- // if you could take a look at them.
- // 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.
- // 2) owner->GetLineFromItem( this ) always asserts.
- // 3) the !lb->IsSelectionSuppressed code also fails with EXC_BAD_ACCESS
-
- // To be honest, I think there are casting issues here, but I don't work enough
- // in C++ that these things are clear to me, so I'm hoping another pair of eyes
- // would help. ;-)
- // In any case, I set trigger to false so that these events are not sent.
-
- // during shutdown, this may fail.
wxListCtrl *list = wxDynamicCast( owner->GetPeer() , wxListCtrl );
if ( list ){
bool trigger = false;
- wxCommandEvent event( wxEVT_COMMAND_LIST_ITEM_SELECTED, list->GetId() );
+ wxListEvent event( wxEVT_COMMAND_LIST_ITEM_SELECTED, list->GetId() );
bool isSingle = list->GetWindowStyle() | wxLC_SINGLE_SEL;
+ event.SetEventObject( list );
+ event.m_itemIndex = owner->GetLineFromItem( this ) ;
+ if ( !list->IsVirtual() )
+ {
+ lb->MacGetColumnInfo(event.m_itemIndex,0,event.m_item);
+ }
+
switch (message)
{
case kDataBrowserItemDeselected:
event.SetEventType(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
- //if ( !isSingle )
- // trigger = !lb->IsSelectionSuppressed();
+ if ( !isSingle )
+ trigger = !lb->IsSelectionSuppressed();
break;
case kDataBrowserItemSelected:
- //trigger = !lb->IsSelectionSuppressed();
+ trigger = !lb->IsSelectionSuppressed();
break;
case kDataBrowserItemDoubleClicked:
trigger = true;
break;
+ case kDataBrowserEditStarted :
+ // TODO : how to veto ?
+ event.SetEventType( wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT ) ;
+ trigger = true ;
+ break ;
+
+ case kDataBrowserEditStopped :
+ // TODO probably trigger only upon the value store callback, because
+ // here IIRC we cannot veto
+ event.SetEventType( wxEVT_COMMAND_LIST_END_LABEL_EDIT ) ;
+ trigger = true ;
+ break ;
+
default:
break;
}
if ( trigger )
{
- event.SetEventObject( list );
- //if ( list->HasClientObjectData() )
- // event.SetClientObject( (wxClientData*) m_data );
- //else if ( list->HasClientUntypedData() )
- // event.SetClientData( m_data );
- event.SetString( m_label );
- event.SetInt( owner->GetLineFromItem( this ) );
- event.SetExtraLong( !isSingle ? message == kDataBrowserItemSelected : true );
- wxPostEvent( list->GetEventHandler(), event );
-
// direct notification is not always having the listbox GetSelection() having in synch with event
- // list->GetEventHandler()->ProcessEvent(event);
+ wxPostEvent( list->GetEventHandler(), event );
}
}
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() );
else
{
m_sortOrder = SortOrder_None;
- SetDataBrowserSortProperty( m_controlRef , kNumericOrderColumnId);
+ SetDataBrowserSortProperty( m_controlRef , kMinColumnId);
SetDataBrowserSortOrder( m_controlRef , kDataBrowserOrderIncreasing);
}
void wxMacDataBrowserListCtrlControl::MacGetColumnInfo( unsigned int row, unsigned int column, wxListItem& item )
{
wxMacDataItem* dataItem = GetItemFromLine(row);
- if (item){
+ // CS should this guard against dataItem = 0 ? , as item is not a pointer if (item) is not appropriate
+ //if (item)
+ {
wxMacListCtrlItem* listItem = dynamic_cast<wxMacListCtrlItem*>(dataItem);
wxListItem* oldItem = listItem->GetColumnInfo( column );
DataBrowserItemDataRef itemData,
bool changeValue )
{
+
OSStatus err = errDataBrowserPropertyNotSupported;
+ wxListCtrl* list = wxDynamicCast( owner->GetPeer() , wxListCtrl );
if ( !changeValue )
{
- if ( property >= kMinColumnId ){
- short listColumn = property - kMinColumnId;
-
- if (HasColumnInfo(listColumn)){
- wxListItem* item = GetColumnInfo(listColumn);
- wxMacCFStringHolder cfStr;
-
- if (item->GetText()){
- cfStr.Assign( item->GetText(), wxLocale::GetSystemEncoding() );
- err = ::SetDataBrowserItemDataText( itemData, cfStr );
- err = noErr;
+ switch (property)
+ {
+ case kDataBrowserItemIsEditableProperty :
+ if ( list && list->HasFlag( wxLC_EDIT_LABELS ) )
+ {
+ verify_noerr(SetDataBrowserItemDataBooleanValue( itemData, true ));
+ err = noErr ;
}
-
- int imgIndex = item->GetImage();
- if (imgIndex != -1){
- wxListCtrl* list = wxDynamicCast( owner->GetPeer() , wxListCtrl );
- wxImageList* imageList = list->GetImageList(wxIMAGE_LIST_SMALL);
- if (imageList && imageList->GetImageCount() > 0){
- wxBitmap bmp = imageList->GetBitmap(imgIndex);
- IconRef icon = bmp.GetBitmapData()->GetIconRef();
- ::SetDataBrowserItemDataIcon(itemData, icon);
+ break ;
+ default :
+ if ( property >= kMinColumnId ){
+ short listColumn = property - kMinColumnId;
+
+ if (HasColumnInfo(listColumn)){
+ wxListItem* item = GetColumnInfo(listColumn);
+ wxMacCFStringHolder cfStr;
+
+ if (item->GetText()){
+ cfStr.Assign( item->GetText(), wxLocale::GetSystemEncoding() );
+ err = ::SetDataBrowserItemDataText( itemData, cfStr );
+ err = noErr;
+ }
+
+ int imgIndex = item->GetImage();
+ if ( (item->GetMask() & wxLIST_MASK_IMAGE) ){
+ wxImageList* imageList = list->GetImageList(wxIMAGE_LIST_SMALL);
+ if (imageList && imageList->GetImageCount() > 0){
+ wxBitmap bmp = imageList->GetBitmap(imgIndex);
+ IconRef icon = bmp.GetBitmapData()->GetIconRef();
+ ::SetDataBrowserItemDataIcon(itemData, icon);
+ }
+ }
+
}
}
-
- }
+ break ;
}
}
else
{
switch (property)
{
- // no editable props here
- default:
+ default:
+ if ( property >= kMinColumnId ){
+ short listColumn = property - kMinColumnId;
+
+ if (HasColumnInfo(listColumn)){
+ // TODO probably send the 'end edit' from here, as we
+ // can then deal with the veto
+ CFStringRef sr ;
+ verify_noerr( GetDataBrowserItemDataText( itemData , &sr ) ) ;
+ wxMacCFStringHolder cfStr(sr) ;;
+ list->SetItem( owner->GetLineFromItem(this) , listColumn, cfStr.AsString() ) ;
+ err = noErr ;
+ }
+ }
break;
}
}