/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/listctrl_mac.cpp
+// Name: src/osx/listctrl_mac.cpp
// Purpose: wxListCtrl
// Author: Julian Smart
// Modified by: Agron Selimaj
if (result == kControlButtonPart){
DataBrowserPropertyID col;
GetDataBrowserSortProperty(controlRef, &col);
- int column = col - kMinColumnId;
+
+ DataBrowserTableViewColumnIndex column = 0;
+ verify_noerr( GetDataBrowserTableViewColumnPosition( controlRef, col, &column ) );
+
le.m_col = column;
// FIXME: we can't use the sort property for virtual listctrls
// so we need to find a better way to determine which column was clicked...
DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacListCtrlEventHandler )
-class wxMacListCtrlItem : public wxMacListBoxItem
+class wxMacListCtrlItem : public wxMacDataItem
{
public:
wxMacListCtrlItem();
// create a list item (can be a subclass of wxMacListBoxItem)
- virtual wxMacDataItem* CreateItem();
-
virtual void MacInsertItem( unsigned int n, wxListItem* item );
virtual void MacSetColumnInfo( unsigned int row, unsigned int column, wxListItem* item );
virtual void MacGetColumnInfo( unsigned int row, unsigned int column, wxListItem& item );
bool wxMacListCtrlEventDelegate::ProcessEvent( wxEvent& event )
{
+ int id = event.GetId();
+ wxObject* obj = event.GetEventObject();
+
// even though we use a generic list ctrl underneath, make sure
// we present ourselves as wxListCtrl.
event.SetEventObject( m_list );
if ( !event.IsKindOf( CLASSINFO( wxCommandEvent ) ) )
{
- if (m_list->HandleWindowEvent( event ))
+ if (m_list->GetEventHandler()->ProcessEvent( event ))
+ {
+ event.SetId(id);
+ event.SetEventObject(obj);
return true;
+ }
}
- return wxEvtHandler::ProcessEvent(event);
+ // Also try with the original id
+ bool success = wxEvtHandler::ProcessEvent(event);
+ event.SetId(id);
+ event.SetEventObject(obj);
+ if (!success && id != m_id)
+ success = wxEvtHandler::ProcessEvent(event);
+ return success;
}
//-----------------------------------------------------------------------------
// implementation
// ============================================================================
-wxMacListControl* wxListCtrl::GetPeer() const
+wxMacDataBrowserListCtrlControl* wxListCtrl::GetListPeer() const
{
- wxMacDataBrowserListCtrlControl *lb = wxDynamicCast(m_peer,wxMacDataBrowserListCtrlControl);
- return lb ? wx_static_cast(wxMacListControl*,lb) : 0 ;
+ return dynamic_cast<wxMacDataBrowserListCtrlControl*> ( GetPeer() );
}
// ----------------------------------------------------------------------------
void wxListCtrl::OnDblClick(wxMouseEvent& event)
{
- m_current = -1;
+ if ( m_renameTimer->IsRunning() )
+ m_renameTimer->Stop();
event.Skip();
}
attr.colFg = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT );
attr.colBg = wxSystemSettings::GetColour( wxSYS_COLOUR_LISTBOX );
- attr.font.MacCreateFromThemeFont(kThemeViewsFont);
+ attr.font.CreateSystemFont(wxOSX_SYSTEM_FONT_VIEWS);
return attr;
}
return rv;
}
-wxColour wxListCtrl::GetBackgroundColour()
+wxColour wxListCtrl::GetBackgroundColour() const
{
if (m_genericImpl)
return m_genericImpl->GetBackgroundColour();
if (m_dbImpl)
{
+ wxASSERT_MSG( col < (int)m_colsInfo.GetCount(), _T("invalid column index in wxMacListCtrlItem") );
+
long mask = item.GetMask();
- if ( col >= (int)m_colsInfo.GetCount() )
- {
- wxListItem* listItem = new wxListItem(item);
- m_colsInfo.Append( listItem );
- }
- else
{
wxListItem listItem;
GetColumn( col, listItem );
// change the appearance in the databrowser.
DataBrowserListViewHeaderDesc columnDesc;
columnDesc.version=kDataBrowserListViewLatestHeaderDesc;
- verify_noerr( m_dbImpl->GetHeaderDesc( kMinColumnId + col, &columnDesc ) );
+
+ DataBrowserTableViewColumnID id = 0;
+ verify_noerr( m_dbImpl->GetColumnIDFromIndex( col, &id ) );
+ verify_noerr( m_dbImpl->GetHeaderDesc( id, &columnDesc ) );
/*
if (item.GetMask() & wxLIST_MASK_TEXT)
}
}
- verify_noerr( m_dbImpl->SetHeaderDesc( kMinColumnId + col, &columnDesc ) );
+ verify_noerr( m_dbImpl->SetHeaderDesc( id, &columnDesc ) );
}
return true;
if (info.m_itemId >= 0 && info.m_itemId < GetItemCount())
{
m_dbImpl->MacGetColumnInfo(info.m_itemId, info.m_col, info);
+ // MacGetColumnInfo returns erroneous information in the state field, so zero it.
+ info.SetState(0);
if (info.GetMask() & wxLIST_MASK_STATE)
{
DataBrowserItemID id = (DataBrowserItemID)m_dbImpl->GetItemFromLine(info.m_itemId);
return rect;
}
+bool wxListCtrl::GetSubItemRect( long item, long subItem, wxRect& rect, int code ) const
+{
+ if (m_genericImpl)
+ return m_genericImpl->GetSubItemRect(item, subItem, rect, code);
+
+ // TODO: implement for DataBrowser implementation
+ return false;
+}
+
// Gets the item rectangle
bool wxListCtrl::GetItemRect(long item, wxRect& rect, int code) const
{
if (m_dbImpl)
{
DataBrowserItemID id;
- DataBrowserPropertyID col = kMinColumnId;
+
+ DataBrowserTableViewColumnID col = 0;
+ verify_noerr( m_dbImpl->GetColumnIDFromIndex( 0, &col ) );
+
Rect bounds;
DataBrowserPropertyPart part = kDataBrowserPropertyEnclosingPart;
if ( code == wxLIST_RECT_LABEL )
if ( !IsVirtual() )
id = (DataBrowserItemID)m_dbImpl->GetItemFromLine(line);
+ if ( (state & wxLIST_STATE_FOCUSED) && (m_current == line))
+ return line;
+
if ( (state == wxLIST_STATE_DONTCARE ) )
return line;
if ( !IsVirtual() )
id = (DataBrowserItemID)m_dbImpl->GetItemFromLine(line);
+ if ( (state & wxLIST_STATE_FOCUSED) && (m_current == line))
+ return line;
+
if ( (state == wxLIST_STATE_DONTCARE ) )
return line;
// Deletes all items
bool wxListCtrl::DeleteAllItems()
{
+ m_current = -1;
if (m_genericImpl)
return m_genericImpl->DeleteAllItems();
return true; // m_genericImpl->EndEditLabel(cancel);
if (m_dbImpl)
- verify_noerr( SetDataBrowserEditItem(m_dbImpl->GetControlRef(), kDataBrowserNoItem, kMinColumnId) );
+ {
+ DataBrowserTableViewColumnID id = 0;
+ verify_noerr( m_dbImpl->GetColumnIDFromIndex( 0, &id ) );
+ verify_noerr( SetDataBrowserEditItem(m_dbImpl->GetControlRef(), kDataBrowserNoItem, id ) );
+ }
return true;
}
just = teFlushRight;
}
m_dbImpl->InsertColumn(col, type, item.GetText(), just, width);
+
+ wxListItem* listItem = new wxListItem(item);
+ m_colsInfo.Insert( col, listItem );
SetColumn(col, item);
// set/remove options based on the wxListCtrl type.
}
-bool wxListCtrl::SortItems(wxListCtrlCompare fn, long data)
+bool wxListCtrl::SortItems(wxListCtrlCompare fn, wxIntPtr data)
{
if (m_genericImpl)
return m_genericImpl->SortItems(fn, data);
// we want to depend on as little as possible to make sure tear-down of controls is safe
if ( message == kDataBrowserItemRemoved)
{
- if ( lb != NULL && lb->GetClientDataType() == wxClientData_Object )
- {
- delete (wxClientData*) (m_data);
- }
-
delete this;
return;
}
wxString text;
wxFont font = wxNullFont;
int imgIndex = -1;
- short listColumn = property - kMinColumnId;
-
+
+ DataBrowserTableViewColumnIndex listColumn = 0;
+ GetColumnPosition( property, &listColumn );
+
wxListCtrl* list = wxDynamicCast( GetWXPeer() , wxListCtrl );
wxMacListCtrlItem* lcItem;
wxColour color = *wxBLACK;
if (!m_isVirtual)
{
lcItem = (wxMacListCtrlItem*) itemID;
- if (lcItem->HasColumnInfo(listColumn)){
+ if (lcItem->HasColumnInfo(listColumn))
+ {
wxListItem* item = lcItem->GetColumnInfo(listColumn);
// we always use the 0 column to get font and text/background colors.
HIThemeTextHorizontalFlush hFlush = kHIThemeTextHorizontalFlushLeft;
HIThemeTextInfo info;
bool setup = false;
-#if wxMAC_USE_CORE_TEXT
+#if wxOSX_USE_CORE_TEXT
if ( UMAGetSystemVersion() >= 0x1050 )
{
info.version = kHIThemeTextInfoVersionOne;
if (font.Ok())
{
info.fontID = kThemeSpecifiedFont;
- info.font = (CTFontRef) font.MacGetCTFont();
+ info.font = (CTFontRef) font.OSXGetCTFont();
setup = true;
}
}
#endif
-#if wxMAC_USE_ATSU_TEXT
+#if wxOSX_USE_ATSU_TEXT
if ( !setup )
{
info.version = kHIThemeTextInfoVersionZero;
{
info.fontID = font.MacGetThemeFontID();
- ::TextSize( (short)(font.MacGetFontSize()) ) ;
+ ::TextSize( (short)(font.GetPointSize()) ) ;
::TextFace( font.MacGetFontStyle() ) ;
}
}
{
wxString text;
int imgIndex = -1;
- short listColumn = property - kMinColumnId;
+
+ DataBrowserTableViewColumnIndex listColumn = 0;
+ verify_noerr( GetColumnPosition( property, &listColumn ) );
OSStatus err = errDataBrowserPropertyNotSupported;
wxListCtrl* list = wxDynamicCast( GetWXPeer() , wxListCtrl );
default:
if ( property >= kMinColumnId )
{
- short listColumn = property - kMinColumnId;
+ DataBrowserTableViewColumnIndex listColumn = 0;
+ verify_noerr( GetColumnPosition( property, &listColumn ) );
// TODO probably send the 'end edit' from here, as we
// can then deal with the veto
long itemOrder;
long otherItemOrder;
- int colId = sortProperty - kMinColumnId;
+ DataBrowserTableViewColumnIndex colId = 0;
+ verify_noerr( GetColumnPosition( sortProperty, &colId ) );
wxListCtrl* list = wxDynamicCast( GetWXPeer() , wxListCtrl );
wxMacListCtrlItem* otherItem = (wxMacListCtrlItem*)itemTwoID;
itemOrder = item->GetOrder();
- otherItemOrder = item->GetOrder();
+ otherItemOrder = otherItem->GetOrder();
wxListCtrlCompare func = list->GetCompareFunc();
if (func != NULL)
{
+
long item1 = -1;
long item2 = -1;
if (item && item->HasColumnInfo(0))
wxASSERT_MSG( dataItem, _T("could not obtain wxMacDataItem for row in MacSetColumnInfo. Is row a valid wxListCtrl row?") );
if (item)
{
- wxMacListCtrlItem* listItem = wx_static_cast(wxMacListCtrlItem*,dataItem);
+ wxMacListCtrlItem* listItem = static_cast<wxMacListCtrlItem *>(dataItem);
bool hasInfo = listItem->HasColumnInfo( column );
listItem->SetColumnInfo( column, item );
listItem->SetOrder(row);
// would be shown. Making sure not to update items until the control is visible
// seems to fix this issue.
if (hasInfo && list->IsShown())
- UpdateItem( wxMacDataBrowserRootContainer, listItem , kMinColumnId + column );
+ {
+ DataBrowserTableViewColumnID id = 0;
+ verify_noerr( GetColumnIDFromIndex( column, &id ) );
+ UpdateItem( wxMacDataBrowserRootContainer, listItem , id );
+ }
}
}
// CS should this guard against dataItem = 0 ? , as item is not a pointer if (item) is not appropriate
//if (item)
{
- wxMacListCtrlItem* listItem =wx_static_cast(wxMacListCtrlItem*,dataItem);
+ wxMacListCtrlItem* listItem = static_cast<wxMacListCtrlItem *>(dataItem);
if (!listItem->HasColumnInfo( column ))
return;
}
}
}
-
+
void wxMacDataBrowserListCtrlControl::MacInsertItem( unsigned int n, wxListItem* item )
{
- wxMacDataItemBrowserControl::MacInsert(n, item->GetText());
+
+ wxMacDataItemBrowserControl::MacInsert(n, new wxMacListCtrlItem() );
MacSetColumnInfo(n, 0, item);
}
-wxMacDataItem* wxMacDataBrowserListCtrlControl::CreateItem()
-{
- return new wxMacListCtrlItem();
-}
-
wxMacListCtrlItem::wxMacListCtrlItem()
{
m_rowItems = wxListItemList();
wxString wxMacListCtrlItem::GetColumnTextValue( unsigned int column )
{
+/* TODO CHECK REMOVE
if ( column == 0 )
return GetLabel();
-
+*/
if ( HasColumnInfo(column) )
return GetColumnInfo(column)->GetText();
if ( HasColumnInfo(column) )
GetColumnInfo(column)->SetText(text);
+/* TODO CHECK REMOVE
// for compatibility with superclass APIs
if ( column == 0 )
SetLabel(text);
+*/
}
wxListItem* wxMacListCtrlItem::GetColumnInfo( unsigned int column )