X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/cb305e1e9ff819725734250d3020c1a074ef8174..8a16d7370e3cdc7d583a6f14ab11b3a1d27b73df:/src/mac/carbon/listctrl_mac.cpp diff --git a/src/mac/carbon/listctrl_mac.cpp b/src/mac/carbon/listctrl_mac.cpp index 31dfaa7fa8..b0c23b8a83 100644 --- a/src/mac/carbon/listctrl_mac.cpp +++ b/src/mac/carbon/listctrl_mac.cpp @@ -205,6 +205,46 @@ void wxListCtrl::Init() m_dbImpl = NULL; } +class wxGenericListCtrlHook : public wxGenericListCtrl +{ +public: + wxGenericListCtrlHook(wxListCtrl* parent, + wxWindowID id, + const wxPoint& pos, + const wxSize& size, + long style, + const wxValidator& validator, + const wxString& name) + : wxGenericListCtrl(parent, id, pos, size, style, validator, name), + m_nativeListCtrl(parent) + { + } + + virtual wxListItemAttr * OnGetItemAttr(long item) const + { + return m_nativeListCtrl->OnGetItemAttr(item); + } + + virtual int OnGetItemImage(long item) const + { + return m_nativeListCtrl->OnGetItemImage(item); + } + + virtual int OnGetItemColumnImage(long item, long column) const + { + return m_nativeListCtrl->OnGetItemColumnImage(item, column); + } + + virtual wxString OnGetItemText(long item, long column) const + { + return m_nativeListCtrl->OnGetItemText(item, column); + } + +protected: + wxListCtrl* m_nativeListCtrl; + +}; + bool wxListCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, @@ -217,15 +257,16 @@ bool wxListCtrl::Create(wxWindow *parent, // for now, we'll always use the generic list control for ICON and LIST views, // because they dynamically change the number of columns on resize. // Also, allow the user to set it to use the list ctrl as well. + // Also, use generic list control in VIRTUAL mode. if ( (wxSystemOptions::HasOption( wxMAC_ALWAYS_USE_GENERIC_LISTCTRL ) && (wxSystemOptions::GetOptionInt( wxMAC_ALWAYS_USE_GENERIC_LISTCTRL ) == 1)) || - (style & wxLC_ICON) || (style & wxLC_SMALL_ICON) || (style & wxLC_LIST)) + (style & wxLC_ICON) || (style & wxLC_SMALL_ICON) || (style & wxLC_LIST) || (style & wxLC_VIRTUAL)) { m_macIsUserPane = true; if ( !wxWindow::Create(parent, id, pos, size, style, name) ) return false; - m_genericImpl = new wxGenericListCtrl(this, id, pos, size, style, validator, name); + m_genericImpl = new wxGenericListCtrlHook(this, id, pos, size, style, validator, name); return true; } @@ -382,10 +423,21 @@ bool wxListCtrl::SetColumnWidth(int col, int width) // to the entire window width; investigate why // this is. - //if (m_dbImpl){ - // m_dbImpl->SetColumnWidth(col+1, width); - // return true; - //} + if (m_dbImpl){ + int mywidth = width; + if (width == wxLIST_AUTOSIZE || width == wxLIST_AUTOSIZE_USEHEADER) + mywidth = 150; + + if (col == -1){ + for (int column = 0; column < GetColumnCount(); column++){ + m_dbImpl->SetColumnWidth(col, mywidth); + } + } + else{ + m_dbImpl->SetColumnWidth(col, mywidth); + } + return true; + } return false; } @@ -927,9 +979,10 @@ void wxListCtrl::ClearAll() return; } - DeleteAllItems(); - if ( m_colCount > 0 ) + if (m_dbImpl){ + DeleteAllItems(); DeleteAllColumns(); + } } wxTextCtrl* wxListCtrl::EditLabel(long item, wxClassInfo* textControlClass) @@ -937,6 +990,10 @@ wxTextCtrl* wxListCtrl::EditLabel(long item, wxClassInfo* textControlClass) if (m_genericImpl) return m_genericImpl->EditLabel(item, textControlClass); + if (m_dbImpl){ + wxMacDataItem* id = m_dbImpl->GetItemFromLine(item); + verify_noerr( SetDataBrowserEditItem(m_dbImpl->GetControlRef(), (DataBrowserItemID)id, kMinColumnId) ); + } return NULL; } @@ -945,10 +1002,11 @@ bool wxListCtrl::EndEditLabel(bool cancel) { // TODO: generic impl. doesn't have this method - is it needed for us? if (m_genericImpl) - return false; // m_genericImpl->EndEditLabel(cancel); + return true; // m_genericImpl->EndEditLabel(cancel); - bool b = true; - return b; + if (m_dbImpl) + verify_noerr( SetDataBrowserEditItem(m_dbImpl->GetControlRef(), kDataBrowserNoItem, kMinColumnId) ); + return true; } // Ensures this item is visible @@ -1282,6 +1340,7 @@ void wxMacListCtrlItem::Notification(wxMacDataItemBrowserControl *owner , 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() ) @@ -1345,7 +1404,7 @@ wxMacDataBrowserListCtrlControl::wxMacDataBrowserListCtrlControl( wxWindow *peer } else { - options |= kDataBrowserAlwaysExtendSelection | kDataBrowserCmdTogglesSelection; + options |= kDataBrowserCmdTogglesSelection; } err = SetSelectionFlags( options ); @@ -1354,8 +1413,10 @@ wxMacDataBrowserListCtrlControl::wxMacDataBrowserListCtrlControl( wxWindow *peer if ( style & wxLC_LIST ){ InsertColumn(0, kDataBrowserIconAndTextType, wxEmptyString, -1, -1); verify_noerr( AutoSizeColumns() ); - verify_noerr( SetHeaderButtonHeight( 0 ) ); } + + if ( style & wxLC_LIST || style & wxLC_NO_HEADER ) + verify_noerr( SetHeaderButtonHeight( 0 ) ); SetDataBrowserSortProperty( m_controlRef , kMinColumnId ); if ( style & wxLC_SORT_ASCENDING ) @@ -1376,6 +1437,12 @@ wxMacDataBrowserListCtrlControl::wxMacDataBrowserListCtrlControl( wxWindow *peer SetDataBrowserSortProperty( m_controlRef , kMinColumnId); SetDataBrowserSortOrder( m_controlRef , kDataBrowserOrderIncreasing); } + + if ( style & wxLC_VRULES ){ +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 + verify_noerr( DataBrowserChangeAttributes(m_controlRef, kDataBrowserAttributeListViewDrawColumnDividers, kDataBrowserAttributeNone) ); +#endif + } verify_noerr( AutoSizeColumns() ); verify_noerr( SetHiliteStyle(kDataBrowserTableViewFillHilite ) );