added wxTreeCtrl::AssignImageList

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@8438 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2000-09-28 22:19:57 +00:00
parent 8fd2b35cbe
commit 46cd520d1e
3 changed files with 57 additions and 3 deletions

View 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 If {\it image} > -1 and {\it selImage} is -1, the same image is used for
both selected and unselected items. 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} \membersection{wxTreeCtrl::Collapse}\label{wxtreectrlcollapse}
\func{void}{Collapse}{\param{const wxTreeItemId\&}{ item}} \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}} \func{void}{SetStateImageList}{\param{wxImageList*}{ imageList}}
Sets the state image list (from which application-defined state images are taken). 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}

View File

@@ -87,9 +87,11 @@ public:
void SetSpacing(unsigned int spacing); void SetSpacing(unsigned int spacing);
// image list: these functions allow to associate an image list with // 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 // The normal image list is for the icons which correspond to the
// normal tree item state (whether it is selected or not). // normal tree item state (whether it is selected or not).
@@ -101,6 +103,8 @@ public:
void SetImageList(wxImageList *imageList); void SetImageList(wxImageList *imageList);
void SetStateImageList(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; wxBrush *m_hilightBrush;
wxImageList *m_imageListNormal, wxImageList *m_imageListNormal,
*m_imageListState; *m_imageListState;
bool m_ownsImageListNormal,
m_ownsImageListState;
int m_dragCount; int m_dragCount;
wxPoint m_dragStart; wxPoint m_dragStart;

View File

@@ -615,6 +615,8 @@ void wxGenericTreeCtrl::Init()
m_imageListNormal = m_imageListNormal =
m_imageListState = (wxImageList *) NULL; m_imageListState = (wxImageList *) NULL;
m_ownsImageListNormal =
m_ownsImageListState = FALSE;
m_dragCount = 0; m_dragCount = 0;
m_isDragging = FALSE; m_isDragging = FALSE;
@@ -658,6 +660,8 @@ wxGenericTreeCtrl::~wxGenericTreeCtrl()
DeleteAllItems(); DeleteAllItems();
delete m_renameTimer; 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 ) if ( !m_imageListNormal )
return; 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;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------