X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/681be2ef80274e6c39b243922a594c59e4983dab..7d6a4d96961eac84d05db8bb24c64d39003f6e54:/src/generic/listbkg.cpp?ds=sidebyside diff --git a/src/generic/listbkg.cpp b/src/generic/listbkg.cpp index fddedd14ae..88a3c4a7ff 100644 --- a/src/generic/listbkg.cpp +++ b/src/generic/listbkg.cpp @@ -38,24 +38,6 @@ #include "wx/sysopt.h" -namespace -{ - -// FIXME: This function exists because native OS X wxListCtrl seems to have -// problems with report view, either imperfect display or reported hanging, so -// disable it for now (but it should be fixed, and this function removed). -bool CanUseReportView() -{ -#if defined(__WXMAC__) && !defined(__WXUNIVERSAL__) && wxOSX_USE_CARBON - if (wxSystemOptions::GetOptionInt(wxMAC_ALWAYS_USE_GENERIC_LISTCTRL) == 0) - return false; - else -#endif - return true; -} - -} // anonymous namespace - // ---------------------------------------------------------------------------- // various wxWidgets macros // ---------------------------------------------------------------------------- @@ -118,13 +100,10 @@ wxListbook::Create(wxWindow *parent, wxDefaultPosition, wxDefaultSize, wxLC_SINGLE_SEL | - (CanUseReportView() ? GetListCtrlReportViewFlags() - : GetListCtrlIconViewFlags()) + (IsVertical() ? wxLC_ALIGN_LEFT : wxLC_ALIGN_TOP) | + wxLC_LIST ); - if ( CanUseReportView() ) - GetListView()->InsertColumn(0, wxT("Pages")); - #ifdef __WXMSW__ // On XP with themes enabled the GetViewRect used in GetControllerSize() to // determine the space needed for the list view will incorrectly return @@ -138,20 +117,6 @@ wxListbook::Create(wxWindow *parent, return true; } -// ---------------------------------------------------------------------------- -// wxListCtrl flags -// ---------------------------------------------------------------------------- - -long wxListbook::GetListCtrlIconViewFlags() const -{ - return (IsVertical() ? wxLC_ALIGN_LEFT : wxLC_ALIGN_TOP) | wxLC_ICON; -} - -long wxListbook::GetListCtrlReportViewFlags() const -{ - return wxLC_REPORT | wxLC_NO_HEADER; -} - // ---------------------------------------------------------------------------- // wxListbook geometry management // ---------------------------------------------------------------------------- @@ -259,39 +224,34 @@ bool wxListbook::SetPageImage(size_t n, int imageId) void wxListbook::SetImageList(wxImageList *imageList) { - if ( CanUseReportView() ) + wxListView * const list = GetListView(); + + // If imageList presence has changed, we update the list control style + if ( (imageList != NULL) != (GetImageList() != NULL) ) { - wxListView * const list = GetListView(); + // Preserve the selection which is lost when changing the mode + const int oldSel = GetSelection(); - // If imageList presence has changed, we update the list control view - if ( (imageList != NULL) != (GetImageList() != NULL) ) + // Update the style to use icon view for images, list view otherwise + long style = list->GetWindowStyle() & ~wxLC_MASK_TYPE; + if ( imageList ) { - // Preserve the selection which is lost when changing the mode - const int oldSel = GetSelection(); - - // Update the style to use icon view for images, report view otherwise - long style = wxLC_SINGLE_SEL; - if ( imageList ) - { - style |= GetListCtrlIconViewFlags(); - } - else // no image list - { - style |= GetListCtrlReportViewFlags(); - } - - list->SetWindowStyleFlag(style); - if ( !imageList ) - list->InsertColumn(0, wxT("Pages")); - - // Restore selection - if ( oldSel != wxNOT_FOUND ) - SetSelection(oldSel); + style |= wxLC_ICON; } + else // no image list + { + style |= wxLC_LIST; + } + + list->SetWindowStyleFlag(style); - list->SetImageList(imageList, wxIMAGE_LIST_NORMAL); + // Restore selection + if ( oldSel != wxNOT_FOUND ) + SetSelection(oldSel); } + list->SetImageList(imageList, wxIMAGE_LIST_NORMAL); + wxBookCtrlBase::SetImageList(imageList); } @@ -343,20 +303,9 @@ wxListbook::InsertPage(size_t n, GetListView()->Focus(m_selection); } - // some page should be selected: either this one or the first one if there - // is still no selection - int selNew = wxNOT_FOUND; - if ( bSelect ) - selNew = n; - else if ( m_selection == wxNOT_FOUND ) - selNew = 0; - - if ( selNew != m_selection ) + if ( !DoSetSelectionAfterInsertion(n, bSelect) ) page->Hide(); - if ( selNew != wxNOT_FOUND ) - SetSelection(selNew); - UpdateSize(); return true;