]> git.saurik.com Git - wxWidgets.git/blobdiff - contrib/samples/gizmos/splittree/tree.cpp
not needed now
[wxWidgets.git] / contrib / samples / gizmos / splittree / tree.cpp
index 14687eedf8ab98b58ff24ea513afc0249b63627d..d65f57beb8d8c836172ade1f7d6563b382c0a108 100644 (file)
     #include "wx/wx.h"
 #endif
 
+#if !defined(__WXMSW__) || wxUSE_XPM_IN_MSW
+/* Closed folder */
+static char * icon1_xpm[] = {
+/* width height ncolors chars_per_pixel */
+"16 16 6 1",
+/* colors */
+"   s None  c None",
+".  c #000000",
+"+  c #c0c0c0",
+"@  c #808080",
+"#  c #ffff00",
+"$  c #ffffff",
+/* pixels */
+"                ",
+"   @@@@@        ",
+"  @#+#+#@       ",
+" @#+#+#+#@@@@@@ ",
+" @$$$$$$$$$$$$@.",
+" @$#+#+#+#+#+#@.",
+" @$+#+#+#+#+#+@.",
+" @$#+#+#+#+#+#@.",
+" @$+#+#+#+#+#+@.",
+" @$#+#+#+#+#+#@.",
+" @$+#+#+#+#+#+@.",
+" @$#+#+#+#+#+#@.",
+" @@@@@@@@@@@@@@.",
+"  ..............",
+"                ",
+"                "};
+
+/* File */
+static char * icon2_xpm[] = {
+/* width height ncolors chars_per_pixel */
+"16 16 3 1",
+/* colors */
+"     s None    c None",
+".    c #000000",
+"+    c #ffffff",
+/* pixels */
+"                ",
+"  ........      ",
+"  .++++++..     ",
+"  .+.+.++.+.    ",
+"  .++++++....   ",
+"  .+.+.+++++.   ",
+"  .+++++++++.   ",
+"  .+.+.+.+.+.   ",
+"  .+++++++++.   ",
+"  .+.+.+.+.+.   ",
+"  .+++++++++.   ",
+"  .+.+.+.+.+.   ",
+"  .+++++++++.   ",
+"  ...........   ",
+"                ",
+"                "};
+#endif
+
 #include "wx/imaglist.h"
 #include "tree.h"
 
@@ -41,7 +98,7 @@
 // resources
 // ----------------------------------------------------------------------------
 // the application icon
-#if defined(__WXGTK__) || defined(__WXMOTIF__)
+#if defined(__WXGTK__) || defined(__WXX11__) || defined(__WXMOTIF__) || defined(__WXMAC__)
     #include "mondrian.xpm"
 #endif
 
@@ -76,7 +133,7 @@ IMPLEMENT_APP(MyApp)
 bool MyApp::OnInit()
 {
     // create the main application window
-    MyFrame *frame = new MyFrame("Tree Testing",
+    MyFrame *frame = new MyFrame(wxT("Tree Testing"),
                                  wxPoint(50, 50), wxSize(450, 340));
 
     // and show it (the frames, unlike simple controls, are not shown when
@@ -112,8 +169,10 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
     m_splitter = new wxThinSplitterWindow(m_scrolledWindow, idSPLITTER_WINDOW, wxDefaultPosition,
                wxDefaultSize, wxSP_3DBORDER | wxCLIP_CHILDREN /* | wxSP_LIVE_UPDATE */);
        m_splitter->SetSashSize(2);
-    m_tree = new TestTree(m_splitter, idTREE_CTRL, wxDefaultPosition,
-               wxDefaultSize, wxTR_HAS_BUTTONS | wxTR_NO_LINES | wxNO_BORDER );
+
+       /* Note the wxTR_ROW_LINES style: draws horizontal lines between items */
+    m_tree = new TestTree(m_splitter , idTREE_CTRL, wxDefaultPosition,
+               wxDefaultSize, wxTR_HAS_BUTTONS | wxTR_NO_LINES | wxNO_BORDER | wxTR_ROW_LINES );
     m_valueWindow = new TestValueWindow(m_splitter, idVALUE_WINDOW, wxDefaultPosition,
                wxDefaultSize, wxNO_BORDER);
     m_splitter->SplitVertically(m_tree, m_valueWindow);
@@ -123,22 +182,26 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
 
        m_scrolledWindow->EnableScrolling(FALSE, FALSE);
 
+       // Let the two controls know about each other
+       m_valueWindow->SetTreeCtrl(m_tree);
+       m_tree->SetCompanionWindow(m_valueWindow);
+
     // set the frame icon
     SetIcon(wxICON(mondrian));
 
     // create a menu bar
-    wxMenu *menuFile = new wxMenu("", wxMENU_TEAROFF);
+    wxMenu *menuFile = new wxMenu(wxT(""), wxMENU_TEAROFF);
 
     // the "About" item should be in the help menu
     wxMenu *helpMenu = new wxMenu;
-    helpMenu->Append(Minimal_About, "&About...\tCtrl-A", "Show about dialog");
+    helpMenu->Append(Minimal_About, wxT("&About...\tCtrl-A"), wxT("Show about dialog"));
 
-    menuFile->Append(Minimal_Quit, "E&xit\tAlt-X", "Quit this program");
+    menuFile->Append(Minimal_Quit, wxT("E&xit\tAlt-X"), wxT("Quit this program"));
 
     // now append the freshly created menu to the menu bar...
     wxMenuBar *menuBar = new wxMenuBar();
-    menuBar->Append(menuFile, "&File");
-    menuBar->Append(helpMenu, "&Help");
+    menuBar->Append(menuFile, wxT("&File"));
+    menuBar->Append(helpMenu, wxT("&Help"));
 
     // ... and attach this menu bar to the frame
     SetMenuBar(menuBar);
@@ -156,10 +219,10 @@ void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
 void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
 {
     wxString msg;
-    msg.Printf( _T("This is the about dialog of tree sample.\n")
-                _T("Welcome to %s"), wxVERSION_STRING);
+    msg.Printf( wxT("This is the about dialog of splittree sample.\n")
+                wxT("Welcome to %s"), wxVERSION_STRING);
 
-    wxMessageBox(msg, "About Tree Test", wxOK | wxICON_INFORMATION, this);
+    wxMessageBox(msg, wxT("About Tree Test"), wxOK | wxICON_INFORMATION, this);
 }
 
 /*
@@ -179,21 +242,9 @@ TestTree::TestTree(wxWindow* parent, wxWindowID id, const wxPoint& pt,
 #if !defined(__WXMSW__) // || wxUSE_XPM_IN_MSW
     m_imageList->Add(wxIcon(icon1_xpm));
     m_imageList->Add(wxIcon(icon2_xpm));
-    m_imageList->Add(wxIcon(icon3_xpm));
-    m_imageList->Add(wxIcon(icon4_xpm));
-    m_imageList->Add(wxIcon(icon5_xpm));
-    m_imageList->Add(wxIcon(icon6_xpm));
-    m_imageList->Add(wxIcon(icon7_xpm));
-    m_imageList->Add(wxIcon(icon8_xpm));
 #elif defined(__WXMSW__)
     m_imageList->Add(wxIcon(wxT("wxICON_SMALL_CLOSED_FOLDER"), wxBITMAP_TYPE_ICO_RESOURCE));
-    m_imageList->Add(wxIcon(wxT("wxICON_SMALL_OPEN_FOLDER"), wxBITMAP_TYPE_ICO_RESOURCE));
     m_imageList->Add(wxIcon(wxT("wxICON_SMALL_FILE"), wxBITMAP_TYPE_ICO_RESOURCE));
-    m_imageList->Add(wxIcon(wxT("wxICON_SMALL_COMPUTER"), wxBITMAP_TYPE_ICO_RESOURCE));
-    m_imageList->Add(wxIcon(wxT("wxICON_SMALL_DRIVE"), wxBITMAP_TYPE_ICO_RESOURCE));
-    m_imageList->Add(wxIcon(wxT("wxICON_SMALL_CDROM"), wxBITMAP_TYPE_ICO_RESOURCE));
-    m_imageList->Add(wxIcon(wxT("wxICON_SMALL_FLOPPY"), wxBITMAP_TYPE_ICO_RESOURCE));
-    m_imageList->Add(wxIcon(wxT("wxICON_SMALL_REMOVEABLE"), wxBITMAP_TYPE_ICO_RESOURCE));
 #else
 #error "Sorry, we don't have icons available for this platforms."
 #endif
@@ -201,18 +252,18 @@ TestTree::TestTree(wxWindow* parent, wxWindowID id, const wxPoint& pt,
 
                
        // Add some dummy items
-       wxTreeItemId rootId = AddRoot(_("Root"), 3, -1);
+       wxTreeItemId rootId = AddRoot(_("Root"), -1, -1);
        int i;
        for (i = 1; i <= 20; i++)
        {
                wxString label;
                label.Printf(wxT("Item %d"), i);
                wxTreeItemId id = AppendItem(rootId, label, 0);
-               SetItemImage( id, 1, wxTreeItemIcon_Expanded );
+               //SetItemImage( id, 1, wxTreeItemIcon_Expanded );
 
                int j;
                for (j = 0; j < 10; j++)
-                       AppendItem(id, _("Child"), 2);
+                       AppendItem(id, _("Child"), 1);
        }
        Expand(rootId);
 }
@@ -229,19 +280,14 @@ TestTree::~TestTree()
 
 //IMPLEMENT_CLASS(TestValueWindow, wxWindow)
 
-BEGIN_EVENT_TABLE(TestValueWindow, wxWindow)
-       EVT_SIZE(TestValueWindow::OnSize)
+BEGIN_EVENT_TABLE(TestValueWindow, wxTreeCompanionWindow)
 END_EVENT_TABLE()
 
 TestValueWindow::TestValueWindow(wxWindow* parent, wxWindowID id,
       const wxPoint& pos,
       const wxSize& sz,
       long style):
-      wxWindow(parent, id, pos, sz, style)
+      wxTreeCompanionWindow(parent, id, pos, sz, style)
 {
        SetBackgroundColour(* wxWHITE);
 }
-
-void TestValueWindow::OnSize(wxSizeEvent& event)
-{
-}