]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/treectlg.cpp
Doc/distribution script mods
[wxWidgets.git] / src / generic / treectlg.cpp
index 384ebdb37217c13ade8a5c444f9405caf004a7c3..01072caca3c3c063db6b535915f1014d6a950aa7 100644 (file)
@@ -178,10 +178,10 @@ public:
 
     // status inquiries
     bool HasChildren() const { return !m_children.IsEmpty(); }
-    bool IsSelected()  const { return m_hasHilight; }
+    bool IsSelected()  const { return m_hasHilight != 0; }
     bool IsExpanded()  const { return !m_isCollapsed; }
     bool HasPlus()     const { return m_hasPlus || HasChildren(); }
-    bool IsBold()      const { return m_isBold; }
+    bool IsBold()      const { return m_isBold != 0; }
 
     // attributes
         // get them - may be NULL
@@ -615,6 +615,8 @@ void wxGenericTreeCtrl::Init()
 
     m_imageListNormal =
     m_imageListState = (wxImageList *) NULL;
+    m_ownsImageListNormal = 
+    m_ownsImageListState = FALSE;
 
     m_dragCount = 0;
     m_isDragging = FALSE;
@@ -638,8 +640,6 @@ bool wxGenericTreeCtrl::Create(wxWindow *parent, wxWindowID id,
                         const wxValidator &validator,
                         const wxString& name )
 {
-    Init();
-
     wxScrolledWindow::Create( parent, id, pos, size, style|wxHSCROLL|wxVSCROLL, name );
 
 #if wxUSE_VALIDATORS
@@ -660,6 +660,8 @@ wxGenericTreeCtrl::~wxGenericTreeCtrl()
     DeleteAllItems();
 
     delete m_renameTimer;
+    if (m_ownsImageListNormal) delete m_imageListNormal;
+    if (m_ownsImageListState) delete m_imageListState;
 }
 
 // -----------------------------------------------------------------------------
@@ -1631,7 +1633,10 @@ wxImageList *wxGenericTreeCtrl::GetStateImageList() const
 
 void wxGenericTreeCtrl::SetImageList(wxImageList *imageList)
 {
+    if (m_ownsImageListNormal) delete m_imageListNormal;
+
     m_imageListNormal = imageList;
+    m_ownsImageListNormal = FALSE;
 
     if ( !m_imageListNormal )
         return;
@@ -1658,7 +1663,21 @@ void wxGenericTreeCtrl::SetImageList(wxImageList *imageList)
 
 void wxGenericTreeCtrl::SetStateImageList(wxImageList *imageList)
 {
+    if (m_ownsImageListState) delete m_imageListState;
     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;
 }
 
 // -----------------------------------------------------------------------------
@@ -1818,7 +1837,7 @@ void wxGenericTreeCtrl::PaintLevel( wxGenericTreeItem *item, wxDC &dc, int level
             if ( attr && attr->HasTextColour() )
                 colText = attr->GetTextColour();
             else
-                colText = *wxBLACK;
+                colText = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_WINDOWTEXT );
         }
 
         // prepare to draw
@@ -2416,16 +2435,22 @@ void wxGenericTreeCtrl::OnMouse( wxMouseEvent &event )
             nevent.SetEventObject(this);
             GetEventHandler()->ProcessEvent(nevent);
         }
-        else if ( event.LeftUp() && m_lastOnSame )
+        else if ( event.LeftUp() )
         {
-            if ( (item == m_current) &&
-                 (flags & wxTREE_HITTEST_ONITEMLABEL) &&
-                 HasFlag(wxTR_EDIT_LABELS) )
+            if ( m_lastOnSame )
             {
-                m_renameTimer->Start( 100, TRUE );
-            }
+                if ( (item == m_current) &&
+                     (flags & wxTREE_HITTEST_ONITEMLABEL) &&
+                     HasFlag(wxTR_EDIT_LABELS) )
+                {
+                    if ( m_renameTimer->IsRunning() )
+                        m_renameTimer->Stop();
 
-            m_lastOnSame = FALSE;
+                    m_renameTimer->Start( 100, TRUE );
+                }
+
+                m_lastOnSame = FALSE;
+            }
         }
         else
         {