]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/treectrl/treetest.cpp
Moved Clear() implementation into wxDC using a new virtual CocoaGetBounds()
[wxWidgets.git] / samples / treectrl / treetest.cpp
index 3fb9a987d33ad28adac763f63dfff8e502067ab1..dfa0ad4229e50b4f4f32a41141e7ef32ce591620 100644 (file)
@@ -32,8 +32,7 @@
 #include "wx/image.h"
 #include "wx/imaglist.h"
 #include "wx/treectrl.h"
-
-#include "math.h"
+#include "wx/math.h"
 
 #ifdef __WIN32__
     // this is not supported by native control
@@ -137,7 +136,6 @@ BEGIN_EVENT_TABLE(MyTreeCtrl, wxTreeCtrl)
     EVT_TREE_ITEM_EXPANDING(TreeTest_Ctrl, MyTreeCtrl::OnItemExpanding)
     EVT_TREE_ITEM_COLLAPSED(TreeTest_Ctrl, MyTreeCtrl::OnItemCollapsed)
     EVT_TREE_ITEM_COLLAPSING(TreeTest_Ctrl, MyTreeCtrl::OnItemCollapsing)
-    //EVT_TREE_ITEM_RIGHT_CLICK(TreeTest_Ctrl, MyTreeCtrl::OnItemRightClick)
 
     EVT_CONTEXT_MENU(MyTreeCtrl::OnContextMenu)
     EVT_TREE_SEL_CHANGED(TreeTest_Ctrl, MyTreeCtrl::OnSelChanged)
@@ -165,7 +163,10 @@ bool MyApp::OnInit()
 // My frame constructor
 MyFrame::MyFrame(const wxString& title, int x, int y, int w, int h)
        : wxFrame((wxFrame *)NULL, wxID_ANY, title, wxPoint(x, y), wxSize(w, h)),
-         m_treeCtrl(NULL), m_textCtrl(NULL)
+         m_treeCtrl(NULL)
+#if wxUSE_LOG
+         , m_textCtrl(NULL)
+#endif // wxUSE_LOG
 {
     // This reduces flicker effects - even better would be to define
     // OnEraseBackground to do nothing. When the tree control's scrollbars are
@@ -255,10 +256,12 @@ MyFrame::MyFrame(const wxString& title, int x, int y, int w, int h)
     SetMenuBar(menu_bar);
 #endif // wxUSE_MENUS
 
+#if wxUSE_LOG
     // create the controls
     m_textCtrl = new wxTextCtrl(this, wxID_ANY, wxT(""),
                                 wxDefaultPosition, wxDefaultSize,
                                 wxTE_MULTILINE | wxSUNKEN_BORDER);
+#endif // wxUSE_LOG
 
     CreateTreeWithDefStyle();
 
@@ -269,6 +272,7 @@ MyFrame::MyFrame(const wxString& title, int x, int y, int w, int h)
     CreateStatusBar(2);
 #endif // wxUSE_STATUSBAR
 
+#if wxUSE_LOG
 #ifdef __WXMOTIF__
     // For some reason, we get a memcpy crash in wxLogStream::DoLogStream
     // on gcc/wxMotif, if we use wxLogTextCtl. Maybe it's just gcc?
@@ -278,11 +282,14 @@ MyFrame::MyFrame(const wxString& title, int x, int y, int w, int h)
     wxLogTextCtrl *logWindow = new wxLogTextCtrl(m_textCtrl);
     delete wxLog::SetActiveTarget(logWindow);
 #endif
+#endif // wxUSE_LOG
 }
 
 MyFrame::~MyFrame()
 {
+#if wxUSE_LOG
     delete wxLog::SetActiveTarget(NULL);
+#endif // wxUSE_LOG
 }
 
 void MyFrame::CreateTreeWithDefStyle()
@@ -354,7 +361,11 @@ void MyFrame::OnIdle(wxIdleEvent& event)
 
 void MyFrame::OnSize(wxSizeEvent& event)
 {
-    if ( m_treeCtrl && m_textCtrl )
+    if ( m_treeCtrl
+#if wxUSE_LOG
+                    && m_textCtrl
+#endif // wxUSE_LOG
+                                  )
     {
         Resize();
     }
@@ -365,8 +376,13 @@ void MyFrame::OnSize(wxSizeEvent& event)
 void MyFrame::Resize()
 {
     wxSize size = GetClientSize();
-    m_treeCtrl->SetSize(0, 0, size.x, 2*size.y/3);
+    m_treeCtrl->SetSize(0, 0, size.x, size.y
+#if !wxUSE_LOG
+                                            );
+#else
+                                            *2/3);
     m_textCtrl->SetSize(0, 2*size.y/3, size.x, size.y/3);
+#endif
 }
 
 void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
@@ -393,7 +409,7 @@ void MyFrame::OnRename(wxCommandEvent& WXUNUSED(event))
     static wxString s_text;
     s_text = wxGetTextFromUser(wxT("New name: "), wxT("Tree sample question"),
             s_text, this);
-    if ( !s_text.IsEmpty() )
+    if ( !s_text.empty() )
     {
         m_treeCtrl->SetItemText(item, s_text);
     }
@@ -740,10 +756,6 @@ void MyTreeCtrl::CreateButtonsImageList(int WXUNUSED(size))
 #endif
 }
 
-MyTreeCtrl::~MyTreeCtrl()
-{
-}
-
 int MyTreeCtrl::OnCompareItems(const wxTreeItemId& item1,
                                const wxTreeItemId& item2)
 {
@@ -1134,11 +1146,6 @@ void MyTreeCtrl::OnItemActivated(wxTreeEvent& event)
     wxLogMessage(wxT("OnItemActivated"));
 }
 
-void MyTreeCtrl::OnItemRightClick(wxTreeEvent& event)
-{
-    ShowMenu(event.GetItem(), event.GetPoint());
-}
-
 void MyTreeCtrl::OnContextMenu(wxContextMenuEvent& event)
 {
     wxPoint pt = event.GetPosition();
@@ -1150,7 +1157,7 @@ void MyTreeCtrl::OnContextMenu(wxContextMenuEvent& event)
     {
         //attempt to guess where to show the menu
         if (item.IsOk())
-        {   
+        {
             //if an item was clicked, show menu to the right of it
             wxRect rect;
             GetBoundingRect(item, rect, true); //true = only the label
@@ -1166,7 +1173,7 @@ void MyTreeCtrl::OnContextMenu(wxContextMenuEvent& event)
         //event was generated by mouse, use supplied coords
         pt = ScreenToClient(pt);
     }
-    
+
     ShowMenu(item, pt);
 }