From b656febdf03cfa90ed14151cdf3d56a685f8af74 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Thu, 28 Sep 2000 22:25:07 +0000 Subject: [PATCH] added wxNotebook::AssingImageList git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@8439 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/latex/wx/notebook.tex | 18 ++++++++++++++++-- include/wx/gtk/notebook.h | 2 ++ include/wx/gtk1/notebook.h | 2 ++ include/wx/msw/notebook.h | 2 ++ src/gtk/notebook.cpp | 10 ++++++++++ src/gtk1/notebook.cpp | 10 ++++++++++ src/msw/notebook.cpp | 10 ++++++++++ 7 files changed, 52 insertions(+), 2 deletions(-) diff --git a/docs/latex/wx/notebook.tex b/docs/latex/wx/notebook.tex index 2ec54d1b11..e25921c0c5 100644 --- a/docs/latex/wx/notebook.tex +++ b/docs/latex/wx/notebook.tex @@ -123,6 +123,18 @@ Do not delete the page, it will be deleted by the notebook. Cycles through the tabs. +\membersection{wxNotebook::AssignImageList}\label{wxnotebookassignimagelist} + +\func{void}{AssignImageList}{\param{wxImageList*}{ imageList}} + +Sets the image list for the page control and takes ownership of +the list. + +\wxheading{See also} + +\helpref{wxImageList}{wximagelist}, +\helpref{SetImageList}{wxnotebooksetimagelist} + \membersection{wxNotebook::Create}\label{wxnotebookcreate} \func{bool}{Create}{\param{wxWindow*}{ parent}, \param{wxWindowID }{id}, \param{const wxPoint\&}{ pos = wxDefaultPosition}, @@ -242,11 +254,13 @@ Deletes the specified page, without deleting the associated window. \func{void}{SetImageList}{\param{wxImageList*}{ imageList}} -Sets the image list for the page control. +Sets the image list for the page control. It does not take +ownership of the image list, you must delete it yourself. \wxheading{See also} -\helpref{wxImageList}{wximagelist} +\helpref{wxImageList}{wximagelist}, +\helpref{AssignImageList}{wxnotebookassignimagelist} \membersection{wxNotebook::SetPadding}\label{wxnotebooksetpadding} diff --git a/include/wx/gtk/notebook.h b/include/wx/gtk/notebook.h index ef09df8f89..4b297ddf32 100644 --- a/include/wx/gtk/notebook.h +++ b/include/wx/gtk/notebook.h @@ -89,6 +89,7 @@ public: // 3) set for each page it's image // associate image list with a control void SetImageList(wxImageList* imageList); + void AssignImageList(wxImageList* imageList); // get pointer (may be NULL) to the associated image list wxImageList *GetImageList() const { return m_imageList; } @@ -157,6 +158,7 @@ public: wxGtkNotebookPage* GetNotebookPage(int page) const; wxImageList* m_imageList; + bool m_ownsImageList; wxList m_pages; int m_lastSelection; /* hack */ diff --git a/include/wx/gtk1/notebook.h b/include/wx/gtk1/notebook.h index ef09df8f89..4b297ddf32 100644 --- a/include/wx/gtk1/notebook.h +++ b/include/wx/gtk1/notebook.h @@ -89,6 +89,7 @@ public: // 3) set for each page it's image // associate image list with a control void SetImageList(wxImageList* imageList); + void AssignImageList(wxImageList* imageList); // get pointer (may be NULL) to the associated image list wxImageList *GetImageList() const { return m_imageList; } @@ -157,6 +158,7 @@ public: wxGtkNotebookPage* GetNotebookPage(int page) const; wxImageList* m_imageList; + bool m_ownsImageList; wxList m_pages; int m_lastSelection; /* hack */ diff --git a/include/wx/msw/notebook.h b/include/wx/msw/notebook.h index 4b95a47eb7..fde5197f80 100644 --- a/include/wx/msw/notebook.h +++ b/include/wx/msw/notebook.h @@ -92,6 +92,7 @@ public: // 3) set for each page it's image // associate image list with a control void SetImageList(wxImageList* imageList); + void AssignImageList(wxImageList* imageList); // get pointer (may be NULL) to the associated image list wxImageList* GetImageList() const { return m_pImageList; } @@ -157,6 +158,7 @@ protected: void ChangePage(int nOldSel, int nSel); // change pages wxImageList *m_pImageList; // we can have an associated image list + bool m_bOwnsImageList; wxArrayPages m_aPages; // array of pages int m_nSelection; // the current selection (-1 if none) diff --git a/src/gtk/notebook.cpp b/src/gtk/notebook.cpp index a05a2f1b00..1554c9e801 100644 --- a/src/gtk/notebook.cpp +++ b/src/gtk/notebook.cpp @@ -214,6 +214,7 @@ END_EVENT_TABLE() void wxNotebook::Init() { m_imageList = (wxImageList *) NULL; + m_ownsImageList = FALSE; m_pages.DeleteContents( TRUE ); m_lastSelection = -1; m_themeEnabled = TRUE; @@ -239,6 +240,7 @@ wxNotebook::~wxNotebook() GTK_SIGNAL_FUNC(gtk_notebook_page_change_callback), (gpointer) this ); DeleteAllPages(); + if (m_ownsImageList) delete m_imageList; } bool wxNotebook::Create(wxWindow *parent, wxWindowID id, @@ -388,7 +390,15 @@ void wxNotebook::AdvanceSelection( bool forward ) void wxNotebook::SetImageList( wxImageList* imageList ) { + if (m_ownsImageList) delete m_imageList; m_imageList = imageList; + m_ownsImageList = FALSE; +} + +void wxNotebook::AssignImageList( wxImageList* imageList ) +{ + SetImageList(imageList); + m_ownsImageList = TRUE; } bool wxNotebook::SetPageText( int page, const wxString &text ) diff --git a/src/gtk1/notebook.cpp b/src/gtk1/notebook.cpp index a05a2f1b00..1554c9e801 100644 --- a/src/gtk1/notebook.cpp +++ b/src/gtk1/notebook.cpp @@ -214,6 +214,7 @@ END_EVENT_TABLE() void wxNotebook::Init() { m_imageList = (wxImageList *) NULL; + m_ownsImageList = FALSE; m_pages.DeleteContents( TRUE ); m_lastSelection = -1; m_themeEnabled = TRUE; @@ -239,6 +240,7 @@ wxNotebook::~wxNotebook() GTK_SIGNAL_FUNC(gtk_notebook_page_change_callback), (gpointer) this ); DeleteAllPages(); + if (m_ownsImageList) delete m_imageList; } bool wxNotebook::Create(wxWindow *parent, wxWindowID id, @@ -388,7 +390,15 @@ void wxNotebook::AdvanceSelection( bool forward ) void wxNotebook::SetImageList( wxImageList* imageList ) { + if (m_ownsImageList) delete m_imageList; m_imageList = imageList; + m_ownsImageList = FALSE; +} + +void wxNotebook::AssignImageList( wxImageList* imageList ) +{ + SetImageList(imageList); + m_ownsImageList = TRUE; } bool wxNotebook::SetPageText( int page, const wxString &text ) diff --git a/src/msw/notebook.cpp b/src/msw/notebook.cpp index b8ac425b2e..dbaa99823a 100644 --- a/src/msw/notebook.cpp +++ b/src/msw/notebook.cpp @@ -106,6 +106,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent, wxNotifyEvent) void wxNotebook::Init() { m_pImageList = NULL; + m_bOwnsImageList = FALSE; m_nSelection = -1; } @@ -188,6 +189,7 @@ bool wxNotebook::Create(wxWindow *parent, // dtor wxNotebook::~wxNotebook() { + if (m_bOwnsImageList) delete m_pImageList; } // ---------------------------------------------------------------------------- @@ -276,10 +278,18 @@ bool wxNotebook::SetPageImage(int nPage, int nImage) void wxNotebook::SetImageList(wxImageList* imageList) { + if (m_bOwnsImageList) delete m_pImageList; m_pImageList = imageList; + m_bOwnsImageList = FALSE; TabCtrl_SetImageList(m_hwnd, (HIMAGELIST)imageList->GetHIMAGELIST()); } +void wxNotebook::AssignImageList(wxImageList* imageList) +{ + SetImageList(imageList); + m_bOwnsImageList = TRUE; +} + // ---------------------------------------------------------------------------- // wxNotebook size settings // ---------------------------------------------------------------------------- -- 2.45.2