Fix usage of wxWithImages::Images in wxTreebook

This commit is contained in:
Alexander Koshelev
2022-02-22 17:17:22 +01:00
committed by Vadim Zeitlin
parent c3b232dcfd
commit ca1eefdba2
2 changed files with 10 additions and 11 deletions

View File

@@ -132,14 +132,14 @@ public:
virtual int SetSelection(size_t n) wxOVERRIDE { return DoSetSelection(n, SetSelection_SendEvent); } virtual int SetSelection(size_t n) wxOVERRIDE { return DoSetSelection(n, SetSelection_SendEvent); }
virtual int ChangeSelection(size_t n) wxOVERRIDE { return DoSetSelection(n); } virtual int ChangeSelection(size_t n) wxOVERRIDE { return DoSetSelection(n); }
virtual int HitTest(const wxPoint& pt, long *flags = NULL) const wxOVERRIDE; virtual int HitTest(const wxPoint& pt, long *flags = NULL) const wxOVERRIDE;
virtual void SetImageList(wxImageList *imageList) wxOVERRIDE;
virtual void AssignImageList(wxImageList *imageList);
virtual bool DeleteAllPages() wxOVERRIDE; virtual bool DeleteAllPages() wxOVERRIDE;
protected: protected:
// Implementation of a page removal. See DeletPage for comments. // Implementation of a page removal. See DeletPage for comments.
wxTreebookPage *DoRemovePage(size_t pos) wxOVERRIDE; wxTreebookPage *DoRemovePage(size_t pos) wxOVERRIDE;
virtual void OnImagesChanged() wxOVERRIDE;
// This subclass of wxBookCtrlBase accepts NULL page pointers (empty pages) // This subclass of wxBookCtrlBase accepts NULL page pointers (empty pages)
virtual bool AllowNullPage() const wxOVERRIDE { return true; } virtual bool AllowNullPage() const wxOVERRIDE { return true; }
virtual wxWindow *TryGetNonNullPage(size_t page) wxOVERRIDE; virtual wxWindow *TryGetNonNullPage(size_t page) wxOVERRIDE;

View File

@@ -564,16 +564,15 @@ wxWindow *wxTreebook::TryGetNonNullPage(size_t n)
return page; return page;
} }
void wxTreebook::SetImageList(wxImageList *imageList) void wxTreebook::OnImagesChanged()
{ {
wxBookCtrlBase::SetImageList(imageList); // Propagate the images to the tree control which will actually use them.
GetTreeCtrl()->SetImageList(imageList); wxTreeCtrl* const tree = GetTreeCtrl();
} const Images& images = GetImages();
if ( !images.empty() )
void wxTreebook::AssignImageList(wxImageList *imageList) tree->SetImages(images);
{ else
wxBookCtrlBase::AssignImageList(imageList); tree->SetImageList(GetImageList());
GetTreeCtrl()->SetImageList(imageList);
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------