X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2cb1f3dae3688542c8217781d9b590f43602bb77..bc14c8b21fe31a7bff1abf0fbb0eae2d5dd839df:/src/generic/listctrl.cpp diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp index a51113da01..cd1e3dd934 100644 --- a/src/generic/listctrl.cpp +++ b/src/generic/listctrl.cpp @@ -23,11 +23,6 @@ // headers // ---------------------------------------------------------------------------- -#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) - #pragma implementation "listctrl.h" - #pragma implementation "listctrlbase.h" -#endif - // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" @@ -367,7 +362,7 @@ public: void GetItem( int index, wxListItem &info ); wxString GetText(int index) const; - void SetText( int index, const wxString s ); + void SetText( int index, const wxString& s ); wxListItemAttr *GetAttr() const; void SetAttr(wxListItemAttr *attr); @@ -471,7 +466,7 @@ private: // generate and process the list event of the given type, return true if // it wasn't vetoed, i.e. if we should proceed - bool SendListEvent(wxEventType type, wxPoint pos); + bool SendListEvent(wxEventType type, const wxPoint& pos); DECLARE_DYNAMIC_CLASS(wxListHeaderWindow) DECLARE_EVENT_TABLE() @@ -674,6 +669,7 @@ public: wxString GetItemText(long item) const { wxListItem info; + info.m_mask = wxLIST_MASK_TEXT; info.m_itemId = item; GetItem( info ); return info.m_text; @@ -721,7 +717,7 @@ public: // send out a wxListEvent void SendNotify( size_t line, wxEventType command, - wxPoint point = wxDefaultPosition ); + const wxPoint& point = wxDefaultPosition ); // override base class virtual to reset m_lineHeight when the font changes virtual bool SetFont(const wxFont& font) @@ -997,9 +993,19 @@ int wxListItemData::GetHeight() const void wxListItemData::GetItem( wxListItem &info ) const { - info.m_text = m_text; - info.m_image = m_image; - info.m_data = m_data; + long mask = info.m_mask; + if ( !mask ) + { + // by default, get everything for backwards compatibility + mask = -1; + } + + if ( mask & wxLIST_MASK_TEXT ) + info.m_text = m_text; + if ( mask & wxLIST_MASK_IMAGE ) + info.m_image = m_image; + if ( mask & wxLIST_MASK_DATA ) + info.m_data = m_data; if ( m_attr ) { @@ -1359,7 +1365,7 @@ wxString wxListLineData::GetText(int index) const return s; } -void wxListLineData::SetText( int index, const wxString s ) +void wxListLineData::SetText( int index, const wxString& s ) { wxListItemDataList::compatibility_iterator node = m_items.Item( index ); if (node) @@ -2003,7 +2009,7 @@ void wxListHeaderWindow::OnSetFocus( wxFocusEvent &WXUNUSED(event) ) m_owner->Update(); } -bool wxListHeaderWindow::SendListEvent(wxEventType type, wxPoint pos) +bool wxListHeaderWindow::SendListEvent(wxEventType type, const wxPoint& pos) { wxWindow *parent = GetParent(); wxListEvent le( type, parent->GetId() ); @@ -2243,9 +2249,6 @@ wxListMainWindow::wxListMainWindow( wxWindow *parent, wxSOLID ); - wxSize sz = size; - sz.y = 25; - SetScrollbars( 0, 0, 0, 0, 0, 0 ); wxVisualAttributes attr = wxGenericListCtrl::GetClassDefaultAttributes(); @@ -2791,7 +2794,7 @@ void wxListMainWindow::HighlightAll( bool on ) void wxListMainWindow::SendNotify( size_t line, wxEventType command, - wxPoint point ) + const wxPoint& point ) { wxListEvent le( command, GetParent()->GetId() ); le.SetEventObject( GetParent() ); @@ -3651,6 +3654,10 @@ void wxListMainWindow::SetItem( wxListItem &item ) wxListLineData *line = GetLine((size_t)id); line->SetItem( item.m_col, item ); + // Set item state if user wants + if ( item.m_mask & wxLIST_MASK_STATE ) + SetItemState( item.m_itemId, item.m_state, item.m_state ); + if (InReportView()) { // update the Max Width Cache if needed @@ -3719,8 +3726,8 @@ void wxListMainWindow::SetItemState( long litem, long state, long stateMask ) return; } - wxCHECK_RET( litem >= 0 && (size_t)litem < GetItemCount(), - _T("invalid list ctrl item index in SetItem") ); + wxCHECK_RET( litem >= 0 && (size_t)litem < GetItemCount(), + _T("invalid list ctrl item index in SetItem") ); size_t oldCurrent = m_current; size_t item = (size_t)litem; // safe because of the check above @@ -3834,6 +3841,11 @@ void wxListMainWindow::GetItem( wxListItem &item ) const wxListLineData *line = GetLine((size_t)item.m_itemId); line->GetItem( item.m_col, item ); + + // Get item state if user wants it + if ( item.m_mask & wxLIST_MASK_STATE ) + item.m_state = GetItemState( item.m_itemId, wxLIST_STATE_SELECTED | + wxLIST_STATE_FOCUSED ); } // ---------------------------------------------------------------------------- @@ -4999,6 +5011,7 @@ void wxGenericListCtrl::SetItemText( long item, const wxString& str ) wxUIntPtr wxGenericListCtrl::GetItemData( long item ) const { wxListItem info; + info.m_mask = wxLIST_MASK_DATA; info.m_itemId = item; m_mainWin->GetItem( info ); return info.m_data; @@ -5097,6 +5110,22 @@ wxColour wxGenericListCtrl::GetItemBackgroundColour( long item ) const return info.GetBackgroundColour(); } +void wxGenericListCtrl::SetItemFont( long item, const wxFont &f ) +{ + wxListItem info; + info.m_itemId = item; + info.SetFont( f ); + m_mainWin->SetItem( info ); +} + +wxFont wxGenericListCtrl::GetItemFont( long item ) const +{ + wxListItem info; + info.m_itemId = item; + m_mainWin->GetItem( info ); + return info.GetFont(); +} + int wxGenericListCtrl::GetSelectedItemCount() const { return m_mainWin->GetSelectedItemCount();