X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/905069b18f8e2bbed946e429830446bb29828b14..07890fbeb5e65f242e8632ed957c54e188779af2:/src/generic/listbkg.cpp diff --git a/src/generic/listbkg.cpp b/src/generic/listbkg.cpp index 487b6494a2..e7dd71235d 100644 --- a/src/generic/listbkg.cpp +++ b/src/generic/listbkg.cpp @@ -54,10 +54,9 @@ // ---------------------------------------------------------------------------- IMPLEMENT_DYNAMIC_CLASS(wxListbook, wxBookCtrlBase) -IMPLEMENT_DYNAMIC_CLASS(wxListbookEvent, wxNotifyEvent) -const wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING = wxNewEventType(); -const wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED = wxNewEventType(); +wxDEFINE_EVENT( wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING, wxBookCtrlEvent ); +wxDEFINE_EVENT( wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED, wxBookCtrlEvent ); BEGIN_EVENT_TABLE(wxListbook, wxBookCtrlBase) EVT_SIZE(wxListbook::OnSize) @@ -299,28 +298,14 @@ bool wxListbook::SetPageImage(size_t n, int imageId) void wxListbook::SetImageList(wxImageList *imageList) { +#ifdef CAN_USE_REPORT_VIEW wxListView * const list = GetListView(); -#ifdef CAN_USE_REPORT_VIEW // If imageList presence has changed, we update the list control view if ( (imageList != NULL) != (GetImageList() != NULL) ) { - wxArrayString labels; - labels.Alloc(GetPageCount()); - - wxArrayInt imageIds; - imageIds.Alloc(GetPageCount()); - + // Preserve the selection which is lost when changing the mode const int oldSel = GetSelection(); - size_t i; - - // Grab snapshot of all list control items before changing the window - // style (which deletes the items) - for ( i = 0; i < GetPageCount(); i++ ) - { - labels.Add(GetPageText(i)); - imageIds.Add(GetPageImage(i)); - } // Update the style to use icon view for images, report view otherwise long style = wxLC_SINGLE_SEL; @@ -337,12 +322,6 @@ void wxListbook::SetImageList(wxImageList *imageList) if ( !imageList ) list->InsertColumn(0, wxT("Pages")); - // Add back the list control items - for ( i = 0; i < GetPageCount(); i++ ) - { - list->InsertItem(i, labels[i], imageIds[i]); - } - // Restore selection if ( oldSel != wxNOT_FOUND ) SetSelection(oldSel); @@ -370,12 +349,12 @@ int wxListbook::GetSelection() const return m_selection; } -wxBookCtrlBaseEvent* wxListbook::CreatePageChangingEvent() const +wxBookCtrlEvent* wxListbook::CreatePageChangingEvent() const { - return new wxListbookEvent(wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING, m_windowId); + return new wxBookCtrlEvent(wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING, m_windowId); } -void wxListbook::MakeChangedEvent(wxBookCtrlBaseEvent &event) +void wxListbook::MakeChangedEvent(wxBookCtrlEvent &event) { event.SetEventType(wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED); }