]> git.saurik.com Git - wxWidgets.git/commitdiff
added wxNotebook::AssingImageList
authorVáclav Slavík <vslavik@fastmail.fm>
Thu, 28 Sep 2000 22:25:07 +0000 (22:25 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Thu, 28 Sep 2000 22:25:07 +0000 (22:25 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@8439 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/latex/wx/notebook.tex
include/wx/gtk/notebook.h
include/wx/gtk1/notebook.h
include/wx/msw/notebook.h
src/gtk/notebook.cpp
src/gtk1/notebook.cpp
src/msw/notebook.cpp

index 2ec54d1b11eb8080c3039a5eb15d098d181afe8b..e25921c0c55d2b8df2e128d3359fbc2cb30d3b5a 100644 (file)
@@ -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}
 
index ef09df8f89db3e5c7422838ee0685b4d2abcc917..4b297ddf323b6e5c697da75d4b1aeb4333b7f247 100644 (file)
@@ -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 */
 
index ef09df8f89db3e5c7422838ee0685b4d2abcc917..4b297ddf323b6e5c697da75d4b1aeb4333b7f247 100644 (file)
@@ -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 */
 
index 4b95a47eb7c3b2b6c2bcbd5dd50057a182f8c3f8..fde5197f806eb7024a4025855a92edc6f8259a17 100644 (file)
@@ -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)
index a05a2f1b0058df1af8f062b8e007e7af8436897e..1554c9e8011ff3fb066bfe88d3673b2657056699 100644 (file)
@@ -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 )
index a05a2f1b0058df1af8f062b8e007e7af8436897e..1554c9e8011ff3fb066bfe88d3673b2657056699 100644 (file)
@@ -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 )
index b8ac425b2e9234a2cdada25fd631ccac2907cf1c..dbaa99823a4ae7038f975c9c1b6d5b81445fc6b2 100644 (file)
@@ -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
 // ----------------------------------------------------------------------------