]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/generic/treectlg.h
optimize FindItem(data) performance (closes #9870)
[wxWidgets.git] / include / wx / generic / treectlg.h
index a9a6318ce9a416f8516e083c3afa6d51fa392b78..71dea9fc13a3c7bab2639f1e12046d853ddb1e49 100644 (file)
 // forward declaration
 // -----------------------------------------------------------------------------
 
-class WXDLLEXPORT wxGenericTreeItem;
+class WXDLLIMPEXP_FWD_CORE wxGenericTreeItem;
 
-class WXDLLEXPORT wxTreeItemData;
+class WXDLLIMPEXP_FWD_CORE wxTreeItemData;
 
-class WXDLLEXPORT wxTreeRenameTimer;
-class WXDLLEXPORT wxTreeFindTimer;
-class WXDLLEXPORT wxTreeTextCtrl;
-class WXDLLEXPORT wxTextCtrl;
+class WXDLLIMPEXP_FWD_CORE wxTreeRenameTimer;
+class WXDLLIMPEXP_FWD_CORE wxTreeFindTimer;
+class WXDLLIMPEXP_FWD_CORE wxTreeTextCtrl;
+class WXDLLIMPEXP_FWD_CORE wxTextCtrl;
 
 // -----------------------------------------------------------------------------
 // wxGenericTreeCtrl - the tree control
 // -----------------------------------------------------------------------------
 
-class WXDLLEXPORT wxGenericTreeCtrl : public wxTreeCtrlBase,
+class WXDLLIMPEXP_CORE wxGenericTreeCtrl : public wxTreeCtrlBase,
                                       public wxScrollHelper
 {
 public:
@@ -112,7 +112,13 @@ public:
     // ----------
 
     virtual wxTreeItemId GetRootItem() const { return m_anchor; }
-    virtual wxTreeItemId GetSelection() const { return m_current; }
+    virtual wxTreeItemId GetSelection() const
+    {
+        wxASSERT_MSG( !HasFlag(wxTR_MULTIPLE),
+                       wxT("must use GetSelections() with this control") );
+
+        return m_current;
+    }
     virtual size_t GetSelections(wxArrayTreeItemIds&) const;
 
     virtual wxTreeItemId GetItemParent(const wxTreeItemId& item) const;
@@ -185,29 +191,12 @@ public:
     void Edit( const wxTreeItemId& item ) { EditLabel(item); }
 #endif // WXWIN_COMPATIBILITY_2_6
 
-#if WXWIN_COMPATIBILITY_2_4
-    // deprecated functions: use Set/GetItemImage directly
-    wxDEPRECATED( int GetItemSelectedImage(const wxTreeItemId& item) const );
-    wxDEPRECATED( void SetItemSelectedImage(const wxTreeItemId& item, int image) );
-
-    // use the versions taking wxTreeItemIdValue cookies (note that
-    // GetNextChild() is not inside wxDEPRECATED on purpose, as otherwise we
-    // get twice as many warnings without any added benefit: it is always used
-    // with GetFirstChild() anyhow)
-    wxDEPRECATED( wxTreeItemId GetFirstChild(const wxTreeItemId& item,
-                                             long& cookie) const );
-    wxTreeItemId GetNextChild(const wxTreeItemId& item,
-                              long& cookie) const;
-#endif // WXWIN_COMPATIBILITY_2_4
-
     // implementation only from now on
 
     // overridden base class virtuals
     virtual bool SetBackgroundColour(const wxColour& colour);
     virtual bool SetForegroundColour(const wxColour& colour);
 
-    virtual void Freeze();
-    virtual void Thaw();
     virtual void Refresh(bool eraseBackground = true, const wxRect *rect = NULL);
 
     virtual bool SetFont( const wxFont &font );
@@ -262,14 +251,18 @@ protected:
     bool                 m_lastOnSame;  // last click on the same item as prev
     wxImageList         *m_imageListButtons;
 
-    int                  m_freezeCount;
     int                  m_dragCount;
     wxPoint              m_dragStart;
     wxGenericTreeItem   *m_dropTarget;
     wxCursor             m_oldCursor;  // cursor is changed while dragging
     wxGenericTreeItem   *m_oldSelection;
     wxGenericTreeItem   *m_underMouse; // for visual effects
+    
+    enum { NoEffect, BorderEffect, AboveEffect, BelowEffect } m_dndEffect;
+    wxGenericTreeItem   *m_dndEffectItem; 
+    
     wxTreeTextCtrl      *m_textCtrl;
+    
 
     wxTimer             *m_renameTimer;
 
@@ -282,6 +275,9 @@ protected:
     // the common part of all ctors
     void Init();
 
+    // overridden wxWindow methods 
+    virtual void DoThaw();
+
     // misc helpers
     void SendDeleteEvent(wxGenericTreeItem *itemBeingDeleted);
 
@@ -293,6 +289,9 @@ protected:
                       bool unselect_others = true,
                       bool extended_select = false);
 
+    virtual int DoGetItemState(const wxTreeItemId& item) const;
+    virtual void DoSetItemState(const wxTreeItemId& item, int state);
+
     virtual wxTreeItemId DoInsertItem(const wxTreeItemId& parent,
                                       size_t previous,
                                       const wxString& text,
@@ -321,7 +320,6 @@ protected:
 
     void CalculateLevel( wxGenericTreeItem *item, wxDC &dc, int level, int &y );
     void CalculatePositions();
-    void CalculateSize( wxGenericTreeItem *item, wxDC &dc );
 
     void RefreshSubtree( wxGenericTreeItem *item );
     void RefreshLine( wxGenericTreeItem *item );
@@ -345,10 +343,12 @@ protected:
 
     void DoDirtyProcessing();
 
+    virtual wxSize DoGetBestSize() const;
+
 private:
     DECLARE_EVENT_TABLE()
     DECLARE_DYNAMIC_CLASS(wxGenericTreeCtrl)
-    DECLARE_NO_COPY_CLASS(wxGenericTreeCtrl)
+    wxDECLARE_NO_COPY_CLASS(wxGenericTreeCtrl);
 };
 
 #if !defined(__WXMSW__) || defined(__WXUNIVERSAL__)
@@ -357,7 +357,7 @@ private:
  * the run-time information.
  */
 
-class WXDLLEXPORT wxTreeCtrl: public wxGenericTreeCtrl
+class WXDLLIMPEXP_CORE wxTreeCtrl: public wxGenericTreeCtrl
 {
     DECLARE_DYNAMIC_CLASS(wxTreeCtrl)