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

docs/latex/wx/treectrl.tex
include/wx/generic/treectlg.h
src/generic/treectlg.cpp

index 90244948cc0d8577cc0dd05c51b8b8d057e7ae6e..e71fd44f33b9b620e74bfd60c9b591d8e7c26366 100644 (file)
@@ -136,6 +136,25 @@ Appends an item to the end of the branch identified by {\it parent}, return a ne
 If {\it image} > -1 and {\it selImage} is -1, the same image is used for
 both selected and unselected items.
 
 If {\it image} > -1 and {\it selImage} is -1, the same image is used for
 both selected and unselected items.
 
+\membersection{wxTreeCtrl::AssignImageList}\label{wxtreectrlassignimagelist}
+
+\func{void}{AssignImageList}{\param{wxImageList*}{ imageList}}
+
+Sets the normal image list. Image list assigned with this method will
+be deleted by wxTreeCtrl's destructor (i.e. it takes ownership of it).
+
+See also \helpref{SetImageList}{wxtreectrlsetimagelist}.
+
+\membersection{wxTreeCtrl::AssignStateImageList}\label{wxtreectrlassignstateimagelist}
+
+\func{void}{AssignStateImageList}{\param{wxImageList*}{ imageList}}
+
+Sets the state image list. Image list assigned with this method will
+be deleted by wxTreeCtrl's destructor (i.e. it takes ownership of it).
+
+See also \helpref{SetStateImageList}{wxtreectrlsetstateimagelist}.
+
+
 \membersection{wxTreeCtrl::Collapse}\label{wxtreectrlcollapse}
 
 \func{void}{Collapse}{\param{const wxTreeItemId\&}{ item}}
 \membersection{wxTreeCtrl::Collapse}\label{wxtreectrlcollapse}
 
 \func{void}{Collapse}{\param{const wxTreeItemId\&}{ item}}
@@ -560,7 +579,11 @@ Sets the indentation for the tree control.
 
 \func{void}{SetImageList}{\param{wxImageList*}{ imageList}}
 
 
 \func{void}{SetImageList}{\param{wxImageList*}{ imageList}}
 
-Sets the normal image list.
+Sets the normal image list. Image list assigned with this method will
+{\bf not} be deleted by wxTreeCtrl's destructor, you must delete it yourself.
+
+See also \helpref{AssignImageList}{wxtreectrlassignimagelist}.
+
 
 \membersection{wxTreeCtrl::SetItemBackgroundColour}\label{wxtreectrlsetitembackgroundcolour}
 
 
 \membersection{wxTreeCtrl::SetItemBackgroundColour}\label{wxtreectrlsetitembackgroundcolour}
 
@@ -642,6 +665,10 @@ Sets the colour of the items text.
 \func{void}{SetStateImageList}{\param{wxImageList*}{ imageList}}
 
 Sets the state image list (from which application-defined state images are taken).
 \func{void}{SetStateImageList}{\param{wxImageList*}{ imageList}}
 
 Sets the state image list (from which application-defined state images are taken).
+Image list assigned with this method will
+{\bf not} be deleted by wxTreeCtrl's destructor, you must delete it yourself.
+
+See also \helpref{AssignStateImageList}{wxtreectrlassignstateimagelist}.
 
 \membersection{wxTreeCtrl::SortChildren}\label{wxtreectrlsortchildren}
 
 
 \membersection{wxTreeCtrl::SortChildren}\label{wxtreectrlsortchildren}
 
index 1bc9bd11032d2edd01d2a2fefc276b6f76efb332..08761557d25728303580a2ef6450553818717f1b 100644 (file)
@@ -87,9 +87,11 @@ public:
     void SetSpacing(unsigned int spacing);
 
         // image list: these functions allow to associate an image list with
     void SetSpacing(unsigned int spacing);
 
         // image list: these functions allow to associate an image list with
-        // the control and retrieve it. Note that the control does _not_ delete
+        // the control and retrieve it. Note that when assigned with 
+        // SetImageList, the control does _not_ delete
         // the associated image list when it's deleted in order to allow image
         // the associated image list when it's deleted in order to allow image
-        // lists to be shared between different controls.
+        // lists to be shared between different controls. If you use 
+        // AssignImageList, the control _does_ delete the image list.
         //
         // The normal image list is for the icons which correspond to the
         // normal tree item state (whether it is selected or not).
         //
         // The normal image list is for the icons which correspond to the
         // normal tree item state (whether it is selected or not).
@@ -101,6 +103,8 @@ public:
 
     void SetImageList(wxImageList *imageList);
     void SetStateImageList(wxImageList *imageList);
 
     void SetImageList(wxImageList *imageList);
     void SetStateImageList(wxImageList *imageList);
+    void AssignImageList(wxImageList *imageList);
+    void AssignStateImageList(wxImageList *imageList);
 
     // Functions to work with tree ctrl items.
 
 
     // Functions to work with tree ctrl items.
 
@@ -353,6 +357,8 @@ protected:
     wxBrush             *m_hilightBrush;
     wxImageList         *m_imageListNormal,
                         *m_imageListState;
     wxBrush             *m_hilightBrush;
     wxImageList         *m_imageListNormal,
                         *m_imageListState;
+    bool                 m_ownsImageListNormal, 
+                         m_ownsImageListState;
 
     int                  m_dragCount;
     wxPoint              m_dragStart;
 
     int                  m_dragCount;
     wxPoint              m_dragStart;
index e9a1973d8b2acb80ffd0f2702a73890b9b279fe0..e45f6f08f74d9b5bf0955331a65788c8d3034c09 100644 (file)
@@ -615,6 +615,8 @@ void wxGenericTreeCtrl::Init()
 
     m_imageListNormal =
     m_imageListState = (wxImageList *) NULL;
 
     m_imageListNormal =
     m_imageListState = (wxImageList *) NULL;
+    m_ownsImageListNormal = 
+    m_ownsImageListState = FALSE;
 
     m_dragCount = 0;
     m_isDragging = FALSE;
 
     m_dragCount = 0;
     m_isDragging = FALSE;
@@ -658,6 +660,8 @@ wxGenericTreeCtrl::~wxGenericTreeCtrl()
     DeleteAllItems();
 
     delete m_renameTimer;
     DeleteAllItems();
 
     delete m_renameTimer;
+    if (m_ownsImageListNormal) delete m_imageListNormal;
+    if (m_ownsImageListState) delete m_imageListState;
 }
 
 // -----------------------------------------------------------------------------
 }
 
 // -----------------------------------------------------------------------------
@@ -1629,7 +1633,10 @@ wxImageList *wxGenericTreeCtrl::GetStateImageList() const
 
 void wxGenericTreeCtrl::SetImageList(wxImageList *imageList)
 {
 
 void wxGenericTreeCtrl::SetImageList(wxImageList *imageList)
 {
+    if (m_ownsImageListNormal) delete m_imageListNormal;
+
     m_imageListNormal = imageList;
     m_imageListNormal = imageList;
+    m_ownsImageListNormal = FALSE;
 
     if ( !m_imageListNormal )
         return;
 
     if ( !m_imageListNormal )
         return;
@@ -1656,7 +1663,21 @@ void wxGenericTreeCtrl::SetImageList(wxImageList *imageList)
 
 void wxGenericTreeCtrl::SetStateImageList(wxImageList *imageList)
 {
 
 void wxGenericTreeCtrl::SetStateImageList(wxImageList *imageList)
 {
+    if (m_ownsImageListState) delete m_imageListState;
     m_imageListState = imageList;
     m_imageListState = imageList;
+    m_ownsImageListState = FALSE;
+}
+
+void wxGenericTreeCtrl::AssignImageList(wxImageList *imageList)
+{
+    SetImageList(imageList);
+    m_ownsImageListNormal = TRUE;
+}
+
+void wxGenericTreeCtrl::AssignStateImageList(wxImageList *imageList)
+{
+    SetStateImageList(imageList);
+    m_ownsImageListState = TRUE;
 }
 
 // -----------------------------------------------------------------------------
 }
 
 // -----------------------------------------------------------------------------