From f0ed40adbf95b79923f4ef12688876156af89061 Mon Sep 17 00:00:00 2001 From: Kevin Ollivier Date: Sun, 12 Nov 2006 04:08:13 +0000 Subject: [PATCH] Add scrollbars if the columns exceed the horizontal space for the control, also, have SetColumnWidth store the value in the column's wxListItem. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43335 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/mac/carbon/listctrl_mac.cpp | 37 +++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/src/mac/carbon/listctrl_mac.cpp b/src/mac/carbon/listctrl_mac.cpp index 7fc71fe14d..a2c5c20ae3 100644 --- a/src/mac/carbon/listctrl_mac.cpp +++ b/src/mac/carbon/listctrl_mac.cpp @@ -728,6 +728,23 @@ void wxListCtrl::DoSetSize( int x, int y, int width, int height, int sizeFlags ) if (m_genericImpl) m_genericImpl->SetSize(0, 0, width, height, sizeFlags); + + // determine if we need a horizontal scrollbar, and add it if so + if (m_dbImpl) + { + int totalWidth = 0; + for (int column = 0; column < GetColumnCount(); column++) + { + totalWidth += m_dbImpl->GetColumnWidth( column ); + } + + Boolean vertScrollBar; + GetDataBrowserHasScrollBars( m_dbImpl->GetControlRef(), NULL, &vertScrollBar ); + if (totalWidth > width) + SetDataBrowserHasScrollBars( m_dbImpl->GetControlRef(), true, vertScrollBar ); + else + SetDataBrowserHasScrollBars( m_dbImpl->GetControlRef(), false, vertScrollBar ); + } } wxSize wxListCtrl::DoGetBestSize() const @@ -819,6 +836,7 @@ bool wxListCtrl::SetColumn(int col, wxListItem& item) if (m_dbImpl) { + long mask = item.GetMask(); if ( col >= (int)m_colsInfo.GetCount() ) { wxListItem* listItem = new wxListItem(item); @@ -828,7 +846,7 @@ bool wxListCtrl::SetColumn(int col, wxListItem& item) { wxListItem listItem; GetColumn( col, listItem ); - long mask = item.GetMask(); + if (mask & wxLIST_MASK_TEXT) listItem.SetText(item.GetText()); if (mask & wxLIST_MASK_DATA) @@ -842,6 +860,9 @@ bool wxListCtrl::SetColumn(int col, wxListItem& item) if (mask & wxLIST_MASK_WIDTH) listItem.SetWidth(item.GetWidth()); } + + if (mask & wxLIST_MASK_WIDTH) + SetColumnWidth( col, item.GetWidth() ) // change the appearance in the databrowser. DataBrowserListViewHeaderDesc columnDesc; @@ -927,10 +948,22 @@ bool wxListCtrl::SetColumnWidth(int col, int width) { for (int column = 0; column < GetColumnCount(); column++) { + wxListItem colInfo; + GetColumn(col, colInfo); + + colInfo.SetWidth(width); + SetColumn(col, colInfo); + m_dbImpl->SetColumnWidth(col, mywidth); } } - else{ + else + { + wxListItem colInfo; + GetColumn(col, colInfo); + + colInfo.SetWidth(width); + SetColumn(col, colInfo); m_dbImpl->SetColumnWidth(col, mywidth); } return true;