]> git.saurik.com Git - wxWidgets.git/blobdiff - contrib/samples/gizmos/splittree/tree.cpp
don't process VK_OEM_XXX key presses
[wxWidgets.git] / contrib / samples / gizmos / splittree / tree.cpp
index 9276e9b423587eb4c4e558509b3a80a8b7cacb05..2a776cc8c280250afdf797d7f25a7996313a44b4 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"
 
@@ -123,6 +180,10 @@ 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));
 
@@ -156,7 +217,7 @@ 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")
+    msg.Printf( _T("This is the about dialog of splittree sample.\n")
                 _T("Welcome to %s"), wxVERSION_STRING);
 
     wxMessageBox(msg, "About Tree Test", wxOK | wxICON_INFORMATION, this);
@@ -180,21 +241,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
@@ -202,18 +251,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);
 }
@@ -233,36 +282,28 @@ void TestTree::OnPaint(wxPaintEvent& event)
     // Reset the device origin since it may have been set
     dc.SetDeviceOrigin(0, 0);
 
-       wxSize sz = GetClientSize();
-
        wxPen pen(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DLIGHT), 1, wxSOLID);
        dc.SetPen(pen);
        dc.SetBrush(* wxTRANSPARENT_BRUSH);
 
+    wxSize clientSize = GetClientSize();
        wxRect itemRect;
-       if (GetBoundingRect(GetRootItem(), itemRect))
+       int cy=0;
+       wxTreeItemId h, lastH;
+       for(h=GetFirstVisibleItem();h;h=GetNextVisible(h))
        {
-               int itemHeight = itemRect.GetHeight();
-               wxRect rcClient = GetRect();
-               wxRect itemRect;
-               int cy=0;
-               wxTreeItemId h, lastH;
-               for(h=GetFirstVisibleItem();h;h=GetNextVisible(h))
-               {
-                       if (GetBoundingRect(h, itemRect))
-                       {
-                               cy = itemRect.GetTop();
-                               dc.DrawLine(rcClient.x, cy, rcClient.x + rcClient.width, cy);
-                               lastH = h;
-                               //cy += itemHeight;
-                       }
-               }
-               if (GetBoundingRect(lastH, itemRect))
+               if (GetBoundingRect(h, itemRect))
                {
-                       cy = itemRect.GetBottom();
-                       dc.DrawLine(rcClient.x, cy, rcClient.x + rcClient.width, cy);
+                       cy = itemRect.GetTop();
+                       dc.DrawLine(0, cy, clientSize.x, cy);
+                       lastH = h;
                }
        }
+       if (GetBoundingRect(lastH, itemRect))
+       {
+               cy = itemRect.GetBottom();
+               dc.DrawLine(0, cy, clientSize.x, cy);
+       }
 }
 
 /*
@@ -271,19 +312,14 @@ void TestTree::OnPaint(wxPaintEvent& event)
 
 //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)
-{
-}