]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/treelay.cpp
submenu preparation in two methods encapsulated
[wxWidgets.git] / src / generic / treelay.cpp
index 44ab82d2331d1f8c86a3280c9bb9f7921f10dfbc..16f82ebd0f46c79fad362e73859c033a93b4709b 100644 (file)
@@ -21,6 +21,8 @@
 #endif
 
 #ifndef WX_PRECOMP
+#include "wx/dc.h"
+#include "wx/event.h"
 #endif
 
 #if wxUSE_TREELAYOUT
@@ -138,7 +140,7 @@ void wxTreeLayout::CalcLayout(long nodeId, int level, wxDC& dc)
 {
     wxList children;
     GetChildren(nodeId, children);
-    int n = children.Number();
+    int n = children.GetCount();
 
     if (m_orientation == FALSE)
     {
@@ -156,11 +158,11 @@ void wxTreeLayout::CalcLayout(long nodeId, int level, wxDC& dc)
             SetNodeX(nodeId, (long)(GetNodeX(parentId) + m_xSpacing + x));
         }
 
-        wxNode *node = children.First();
+        wxNode *node = children.GetFirst();
         while (node)
         {
-            CalcLayout((long)node->Data(), level+1, dc);
-            node = node->Next();
+            CalcLayout((long)node->GetData(), level+1, dc);
+            node = node->GetNext();
         }
 
         // Y Calculations
@@ -170,11 +172,11 @@ void wxTreeLayout::CalcLayout(long nodeId, int level, wxDC& dc)
         if (n > 0)
         {
             averageY = 0;
-            node = children.First();
+            node = children.GetFirst();
             while (node)
             {
-                averageY += GetNodeY((long)node->Data());
-                node = node->Next();
+                averageY += GetNodeY((long)node->GetData());
+                node = node->GetNext();
             }
             averageY = averageY / n;
             SetNodeY(nodeId, averageY);
@@ -205,11 +207,11 @@ void wxTreeLayout::CalcLayout(long nodeId, int level, wxDC& dc)
             SetNodeY(nodeId, (long)(GetNodeY(parentId) + m_ySpacing + y));
         }
 
-        wxNode *node = children.First();
+        wxNode *node = children.GetFirst();
         while (node)
         {
-            CalcLayout((long)node->Data(), level+1, dc);
-            node = node->Next();
+            CalcLayout((long)node->GetData(), level+1, dc);
+            node = node->GetNext();
         }
 
         // X Calculations
@@ -219,11 +221,11 @@ void wxTreeLayout::CalcLayout(long nodeId, int level, wxDC& dc)
         if (n > 0)
         {
             averageX = 0;
-            node = children.First();
+            node = children.GetFirst();
             while (node)
             {
-                averageX += GetNodeX((long)node->Data());
-                node = node->Next();
+                averageX += GetNodeX((long)node->GetData());
+                node = node->GetNext();
             }
             averageX = averageX / n;
             SetNodeX(nodeId, averageX);
@@ -268,7 +270,7 @@ void wxTreeLayoutStored::Initialize(int n)
     int i;
     for (i = 0; i < n; i++)
     {
-        m_nodes[i].m_name = "";
+        m_nodes[i].m_name = wxT("");
         m_nodes[i].m_active = FALSE;
         m_nodes[i].m_parentId = -1;
         m_nodes[i].m_x = 0;
@@ -298,6 +300,32 @@ long wxTreeLayoutStored::AddChild(const wxString& name, const wxString& parent)
         return -1;
 }
 
+long wxTreeLayoutStored::AddChild(const wxString& name, long parent)
+{
+    if (m_num < (m_maxNodes -1 ) && parent < m_num)
+    {
+        long i = -1;
+        if (parent != -1)
+        {
+          i = parent;
+        }
+        else 
+        {
+          m_parentNode = m_num;
+        }
+        
+        m_nodes[m_num].m_parentId = i;
+        m_nodes[m_num].m_name = name;
+        m_nodes[m_num].m_x = m_nodes[m_num].m_y = 0;
+        m_nodes[m_num].m_clientData = 0;
+        m_num ++;
+        
+        return (m_num - 1);
+    }
+    else
+        return -1;
+}
+
 long wxTreeLayoutStored::NameToId(const wxString& name)
 {
     long i;
@@ -436,7 +464,7 @@ wxString wxTreeLayoutStored::HitTest(wxMouseEvent& event, wxDC& dc)
         }
     }
 
-    return wxString("");
+    return wxString( wxT("") );
 }
 
 #endif