]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/treectrl/treetest.cpp
Prealpha, prebeta of new wxTreeCtrl for GTK. It is possible to AddRoot,
[wxWidgets.git] / samples / treectrl / treetest.cpp
index 0eb7d8894645c4cb1be4641f105cfd8026953c03..94a72b0d556884b729dc70dc1f0394c01829b81e 100644 (file)
 #include "wx/wx.h"
 #endif
 
-#ifdef __WXGTK__
-#include "mondrian.xpm"
+#ifndef __WXMSW__
+  #include "icon1.xpm"
+  #include "icon2.xpm"
+  #include "mondrian.xpm"
 #endif
 
 #include "wx/treectrl.h"
@@ -56,10 +58,10 @@ END_EVENT_TABLE()
 IMPLEMENT_APP(MyApp)
 
 // `Main program' equivalent, creating windows and returning main app frame
-bool MyApp::OnInit(void)
+bool MyApp::OnInit()
 {
   // Create the main frame window
-  MyFrame *frame = new MyFrame(NULL, "wxTreeCtrl Test", 50, 50, 450, 340);
+  MyFrame *frame = new MyFrame((wxFrame *) NULL, (char *) "wxTreeCtrl Test", 50, 50, 450, 340);
 
   // This reduces flicker effects - even better would be to define OnEraseBackground
   // to do nothing. When the tree control's scrollbars are show or hidden, the
@@ -67,22 +69,13 @@ bool MyApp::OnInit(void)
   frame->SetBackgroundColour(wxColour(255, 255, 255));
 
   // Give it an icon
-#ifdef __WXMSW__
-  frame->SetIcon(wxIcon("mondrian"));
-#else
-  frame->SetIcon(wxIcon(mondrian_xpm));
-#endif
+  frame->SetIcon(wxICON(mondrian));
 
   // Make an image list containing small icons
   m_imageListNormal = new wxImageList(16, 16, TRUE);
 
-#ifdef __WXMSW__
-  wxIcon icon1("icon1", wxBITMAP_TYPE_ICO_RESOURCE);
-  m_imageListNormal->Add(icon1);
-  wxIcon icon2("icon2", wxBITMAP_TYPE_ICO_RESOURCE);
-  m_imageListNormal->Add(icon2);
-#else
-#endif
+  m_imageListNormal->Add(wxICON(icon1));
+  m_imageListNormal->Add(wxICON(icon2));
 
   // Make a menubar
   wxMenu *file_menu = new wxMenu;
@@ -116,7 +109,7 @@ bool MyApp::OnInit(void)
 
   frame->m_treeCtrl->SetImageList(wxGetApp().m_imageListNormal, wxIMAGE_LIST_NORMAL);
 
-  long rootId = frame->m_treeCtrl->InsertItem(0, "Root", 0);
+  wxTreeItemId rootId = frame->m_treeCtrl->AddRoot("Root", 0);
 
   char buf[20];
   int i;
@@ -126,20 +119,20 @@ bool MyApp::OnInit(void)
   {
        sprintf(buf, "Folder child %d", i);
     str = buf;
-    long id = frame->m_treeCtrl->InsertItem(rootId, str, 0);
+    wxTreeItemId id = frame->m_treeCtrl->AppendItem(rootId, str, 0);
        int j;
     for ( j = 0; j < 5; j++)
     {
          sprintf(buf, "File child %d", j);
       str = buf;
-      frame->m_treeCtrl->InsertItem(id, str, 1);
+      frame->m_treeCtrl->AppendItem(id, str, 1);
     }
   }
   for ( i = 0; i < 10; i++)
   {
        sprintf(buf, "File child %d", i);
     str = buf;
-    frame->m_treeCtrl->InsertItem(rootId, str, 1);
+    frame->m_treeCtrl->AppendItem(rootId, str, 1);
   }
 
   frame->CreateStatusBar(3);
@@ -157,11 +150,11 @@ bool MyApp::OnInit(void)
 MyFrame::MyFrame(wxFrame *frame, char *title, int x, int y, int w, int h):
   wxFrame(frame, -1, title, wxPoint(x, y), wxSize(w, h))
 {
-       m_treeCtrl = NULL;
-       m_logWindow = NULL;
+       m_treeCtrl = (MyTreeCtrl *) NULL;
+       m_logWindow = (wxTextCtrl *) NULL;
 }
 
-MyFrame::~MyFrame(void)
+MyFrame::~MyFrame()
 {
        delete wxGetApp().m_imageListNormal;
 }