- // 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 frame is sent a background erase event.
- SetBackgroundColour(wxColour(255, 255, 255));
-
- // Give it an icon
- SetIcon(wxICON(mondrian));
-
- // Make a menubar
- wxMenu *file_menu = new wxMenu;
-
- file_menu->Append(TREE_ABOUT, "&About...");
- file_menu->Append(TREE_QUIT, "E&xit");
- wxMenuBar *menu_bar = new wxMenuBar;
- menu_bar->Append(file_menu, "&File");
- SetMenuBar(menu_bar);
-
- // Make a panel with a message
- m_treeCtrl = new MyTreeCtrl(this, TREE_CTRL,
- wxDefaultPosition, wxDefaultSize,
- wxTR_HAS_BUTTONS | wxSUNKEN_BORDER);
- wxTextCtrl *textCtrl = new wxTextCtrl(this, -1, "",
- wxDefaultPosition, wxDefaultSize,
- wxTE_MULTILINE | wxSUNKEN_BORDER);
-
- wxLayoutConstraints *c = new wxLayoutConstraints;
- c->top.SameAs(this, wxTop);
- c->left.SameAs(this, wxLeft);
- c->right.SameAs(this, wxRight);
- c->height.PercentOf(this, wxHeight, 66);
- m_treeCtrl->SetConstraints(c);
-
- c = new wxLayoutConstraints;
- c->top.Below(m_treeCtrl);
- c->left.SameAs(this, wxLeft);
- c->right.SameAs(this, wxRight);
- c->bottom.SameAs(this, wxBottom);
- textCtrl->SetConstraints(c);
- SetAutoLayout(TRUE);
-
- // create a status bar with 3 panes
- CreateStatusBar(3);
- SetStatusText("", 0);
-
- // set our text control as the log target
- wxLogTextCtrl *logWindow = new wxLogTextCtrl(textCtrl);
- delete wxLog::SetActiveTarget(logWindow);
+ // 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 frame is sent a background erase event.
+ SetBackgroundColour(wxColour(255, 255, 255));
+
+ // Give it an icon
+ SetIcon(wxICON(mondrian));
+
+ // Make a menubar
+ wxMenu *file_menu = new wxMenu,
+ *tree_menu = new wxMenu,
+ *item_menu = new wxMenu;
+
+ file_menu->Append(TreeTest_About, "&About...");
+ file_menu->AppendSeparator();
+ file_menu->Append(TreeTest_Quit, "E&xit");
+
+ tree_menu->Append(TreeTest_Recreate, "&Recreate the tree");
+ tree_menu->Append(TreeTest_CollapseAndReset, "C&ollapse and reset");
+ tree_menu->AppendSeparator();
+ tree_menu->Append(TreeTest_AddItem, "Append a &new item");
+ tree_menu->Append(TreeTest_InsertItem, "&Insert a new item");
+ tree_menu->Append(TreeTest_Delete, "&Delete this item");
+ tree_menu->Append(TreeTest_DeleteChildren, "Delete &children");
+ tree_menu->Append(TreeTest_DeleteAll, "Delete &all items");
+ tree_menu->AppendSeparator();
+ tree_menu->Append(TreeTest_Count, "Count children of current item");
+ tree_menu->Append(TreeTest_CountRec, "Recursively count children of current item");
+ tree_menu->AppendSeparator();
+ tree_menu->Append(TreeTest_Sort, "Sort children of current item");
+ tree_menu->Append(TreeTest_SortRev, "Sort in reversed order");
+ tree_menu->AppendSeparator();
+ tree_menu->Append(TreeTest_EnsureVisible, "Make the last item &visible");
+ tree_menu->AppendSeparator();
+ tree_menu->Append(TreeTest_IncIndent, "Add 5 points to indentation\tAlt-I");
+ tree_menu->Append(TreeTest_DecIndent, "Reduce indentation by 5 points\tAlt-R");
+ tree_menu->AppendSeparator();
+ tree_menu->Append(TreeTest_IncSpacing, "Add 5 points to spacing\tCtrl-I");
+ tree_menu->Append(TreeTest_DecSpacing, "Reduce spacing by 5 points\tCtrl-R");
+
+ item_menu->Append(TreeTest_Dump, "&Dump item children");
+ item_menu->Append(TreeTest_Rename, "&Rename item...");
+
+ item_menu->AppendSeparator();
+ item_menu->Append(TreeTest_Bold, "Make item &bold");
+ item_menu->Append(TreeTest_UnBold, "Make item ¬ bold");
+ item_menu->AppendSeparator();
+ item_menu->Append(TreeTest_ToggleIcon, "Toggle the items &icon");
+
+#ifndef NO_MULTIPLE_SELECTION
+ item_menu->AppendSeparator();
+ item_menu->Append(TreeTest_DumpSelected, "Dump selected items\tAlt-D");
+ item_menu->Append(TreeTest_Select, "Select current item\tAlt-S");
+ item_menu->Append(TreeTest_Unselect, "Unselect everything\tAlt-U");
+#endif
+
+ wxMenuBar *menu_bar = new wxMenuBar;
+ menu_bar->Append(file_menu, "&File");
+ menu_bar->Append(tree_menu, "&Tree");
+ menu_bar->Append(item_menu, "&Item");
+ SetMenuBar(menu_bar);
+
+ m_treeCtrl = new MyTreeCtrl(this, TreeTest_Ctrl,
+ wxDefaultPosition, wxDefaultSize,
+ wxTR_HAS_BUTTONS |
+ wxTR_EDIT_LABELS |
+#ifndef NO_MULTIPLE_SELECTION
+ wxTR_MULTIPLE |
+#endif
+#ifndef NO_VARIABLE_HEIGHT
+ wxTR_HAS_VARIABLE_ROW_HEIGHT |
+#endif
+ wxSUNKEN_BORDER);
+
+ m_treeCtrl->SetBackgroundColour(wxColour(204, 205, 79));
+
+ wxTextCtrl *textCtrl = new wxTextCtrl(this, -1, "",
+ wxDefaultPosition, wxDefaultSize,
+ wxTE_MULTILINE | wxSUNKEN_BORDER);
+
+ wxLayoutConstraints *c = new wxLayoutConstraints;
+ c->top.SameAs(this, wxTop);
+ c->left.SameAs(this, wxLeft);
+ c->right.SameAs(this, wxRight);
+ c->height.PercentOf(this, wxHeight, 66);
+ m_treeCtrl->SetConstraints(c);
+
+ c = new wxLayoutConstraints;
+ c->top.Below(m_treeCtrl);
+ c->left.SameAs(this, wxLeft);
+ c->right.SameAs(this, wxRight);
+ c->bottom.SameAs(this, wxBottom);
+ textCtrl->SetConstraints(c);
+ SetAutoLayout(TRUE);
+
+ // create a status bar with 3 panes
+ CreateStatusBar(3);
+ SetStatusText("", 0);
+
+#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?
+ delete wxLog::SetActiveTarget(new wxLogStderr);
+#else
+ // set our text control as the log target
+ wxLogTextCtrl *logWindow = new wxLogTextCtrl(textCtrl);
+ delete wxLog::SetActiveTarget(logWindow);
+#endif