+ if ( !wxApp::OnInit() )
+ return false;
+
+ MyFrame *frame =
+ new MyFrame(NULL, "wxDataViewCtrl sample", 40, 40, 1000, 540);
+
+ frame->Show(true);
+ return true;
+}
+
+
+// ----------------------------------------------------------------------------
+// MyFrame
+// ----------------------------------------------------------------------------
+
+enum
+{
+ ID_CLEARLOG = wxID_HIGHEST+1,
+ ID_BACKGROUND_COLOUR,
+ ID_FOREGROUND_COLOUR,
+ ID_STYLE_MENU,
+
+ // file menu
+ //ID_SINGLE, wxDV_SINGLE==0 so it's always present
+ ID_MULTIPLE,
+ ID_ROW_LINES,
+ ID_HORIZ_RULES,
+ ID_VERT_RULES,
+
+ ID_EXIT = wxID_EXIT,
+
+ // about menu
+ ID_ABOUT = wxID_ABOUT,
+
+
+ // control IDs
+
+ ID_MUSIC_CTRL = 50,
+ ID_ATTR_CTRL = 51,
+
+ ID_ADD_MOZART = 100,
+ ID_DELETE_SEL = 101,
+ ID_DELETE_YEAR = 102,
+ ID_SELECT_NINTH = 103,
+ ID_COLLAPSE = 104,
+ ID_EXPAND = 105,
+ ID_SHOW_CURRENT,
+ ID_SET_NINTH_CURRENT,
+
+ ID_PREPEND_LIST = 200,
+ ID_DELETE_LIST = 201,
+ ID_GOTO = 202,
+ ID_ADD_MANY = 203,
+ ID_HIDE_ATTRIBUTES = 204,
+ ID_SHOW_ATTRIBUTES = 205,
+
+ // Fourth page.
+ ID_DELETE_TREE_ITEM = 400,
+ ID_DELETE_ALL_TREE_ITEMS = 401,
+ ID_ADD_TREE_ITEM = 402,
+ ID_ADD_TREE_CONTAINER_ITEM = 403
+};
+
+BEGIN_EVENT_TABLE(MyFrame, wxFrame)
+ EVT_MENU_RANGE( ID_MULTIPLE, ID_VERT_RULES, MyFrame::OnStyleChange )
+ EVT_MENU( ID_EXIT, MyFrame::OnQuit )
+ EVT_MENU( ID_ABOUT, MyFrame::OnAbout )
+ EVT_MENU( ID_CLEARLOG, MyFrame::OnClearLog )
+
+ EVT_MENU( ID_FOREGROUND_COLOUR, MyFrame::OnSetForegroundColour )
+ EVT_MENU( ID_BACKGROUND_COLOUR, MyFrame::OnSetBackgroundColour )
+
+ EVT_NOTEBOOK_PAGE_CHANGED( wxID_ANY, MyFrame::OnPageChanged )
+
+ EVT_BUTTON( ID_ADD_MOZART, MyFrame::OnAddMozart )
+ EVT_BUTTON( ID_DELETE_SEL, MyFrame::OnDeleteSelected )
+ EVT_BUTTON( ID_DELETE_YEAR, MyFrame::OnDeleteYear )
+ EVT_BUTTON( ID_SELECT_NINTH, MyFrame::OnSelectNinth )
+ EVT_BUTTON( ID_COLLAPSE, MyFrame::OnCollapse )
+ EVT_BUTTON( ID_EXPAND, MyFrame::OnExpand )
+ EVT_BUTTON( ID_SHOW_CURRENT, MyFrame::OnShowCurrent )
+ EVT_BUTTON( ID_SET_NINTH_CURRENT, MyFrame::OnSetNinthCurrent )
+
+ EVT_BUTTON( ID_PREPEND_LIST, MyFrame::OnPrependList )
+ EVT_BUTTON( ID_DELETE_LIST, MyFrame::OnDeleteList )
+ EVT_BUTTON( ID_GOTO, MyFrame::OnGoto)
+ EVT_BUTTON( ID_ADD_MANY, MyFrame::OnAddMany)
+ EVT_BUTTON( ID_HIDE_ATTRIBUTES, MyFrame::OnHideAttributes)
+ EVT_BUTTON( ID_SHOW_ATTRIBUTES, MyFrame::OnShowAttributes)
+ // Fourth page.
+ EVT_BUTTON( ID_DELETE_TREE_ITEM, MyFrame::OnDeleteTreeItem )
+ EVT_BUTTON( ID_DELETE_ALL_TREE_ITEMS, MyFrame::OnDeleteAllTreeItems )
+ EVT_BUTTON( ID_ADD_TREE_ITEM, MyFrame::OnAddTreeItem )
+ EVT_BUTTON( ID_ADD_TREE_CONTAINER_ITEM, MyFrame::OnAddTreeContainerItem )
+
+ EVT_DATAVIEW_ITEM_VALUE_CHANGED( ID_MUSIC_CTRL, MyFrame::OnValueChanged )
+
+ EVT_DATAVIEW_ITEM_ACTIVATED(ID_MUSIC_CTRL, MyFrame::OnActivated )
+ EVT_DATAVIEW_ITEM_EXPANDING(ID_MUSIC_CTRL, MyFrame::OnExpanding)
+ EVT_DATAVIEW_ITEM_EXPANDED(ID_MUSIC_CTRL, MyFrame::OnExpanded)
+ EVT_DATAVIEW_ITEM_COLLAPSING(ID_MUSIC_CTRL, MyFrame::OnCollapsing)
+ EVT_DATAVIEW_ITEM_COLLAPSED(ID_MUSIC_CTRL, MyFrame::OnCollapsed)
+ EVT_DATAVIEW_SELECTION_CHANGED(ID_MUSIC_CTRL, MyFrame::OnSelectionChanged)
+
+ EVT_DATAVIEW_ITEM_START_EDITING(ID_MUSIC_CTRL, MyFrame::OnStartEditing)
+ EVT_DATAVIEW_ITEM_EDITING_STARTED(ID_MUSIC_CTRL, MyFrame::OnEditingStarted)
+ EVT_DATAVIEW_ITEM_EDITING_DONE(ID_MUSIC_CTRL, MyFrame::OnEditingDone)
+
+ EVT_DATAVIEW_COLUMN_HEADER_CLICK(ID_MUSIC_CTRL, MyFrame::OnHeaderClick)
+ EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED(ID_MUSIC_CTRL, MyFrame::OnHeaderRightClick)
+ EVT_DATAVIEW_COLUMN_SORTED(ID_MUSIC_CTRL, MyFrame::OnSorted)
+
+ EVT_DATAVIEW_ITEM_CONTEXT_MENU(ID_MUSIC_CTRL, MyFrame::OnContextMenu)
+
+#if wxUSE_DRAG_AND_DROP
+ EVT_DATAVIEW_ITEM_BEGIN_DRAG( ID_MUSIC_CTRL, MyFrame::OnBeginDrag )
+ EVT_DATAVIEW_ITEM_DROP_POSSIBLE( ID_MUSIC_CTRL, MyFrame::OnDropPossible )
+ EVT_DATAVIEW_ITEM_DROP( ID_MUSIC_CTRL, MyFrame::OnDrop )
+#endif // wxUSE_DRAG_AND_DROP
+
+ EVT_DATAVIEW_COLUMN_HEADER_CLICK(ID_ATTR_CTRL, MyFrame::OnAttrHeaderClick)
+
+END_EVENT_TABLE()
+
+MyFrame::MyFrame(wxFrame *frame, const wxString &title, int x, int y, int w, int h):
+ wxFrame(frame, wxID_ANY, title, wxPoint(x, y), wxSize(w, h))
+{
+ m_log = NULL;
+ m_col = NULL;
+
+ m_ctrl[0] = NULL;
+ m_ctrl[1] = NULL;
+ m_ctrl[2] = NULL;
+ m_ctrl[3] = NULL;
+
+ SetIcon(wxICON(sample));
+
+
+ // build the menus
+ // ----------------
+
+ wxMenu *style_menu = new wxMenu;
+ //style_menu->AppendCheckItem(ID_SINGLE, "Single selection"));
+ style_menu->AppendCheckItem(ID_MULTIPLE, "Multiple selection");
+ style_menu->AppendCheckItem(ID_ROW_LINES, "Alternating colours");
+ style_menu->AppendCheckItem(ID_HORIZ_RULES, "Display horizontal rules");
+ style_menu->AppendCheckItem(ID_VERT_RULES, "Display vertical rules");
+
+ wxMenu *file_menu = new wxMenu;
+ file_menu->Append(ID_CLEARLOG, "&Clear log\tCtrl-L");
+ file_menu->Append(ID_FOREGROUND_COLOUR, "Set &foreground colour...\tCtrl-S");
+ file_menu->Append(ID_BACKGROUND_COLOUR, "Set &background colour...\tCtrl-B");
+ file_menu->Append(ID_STYLE_MENU, "&Style", style_menu);
+ file_menu->AppendSeparator();
+ file_menu->Append(ID_EXIT, "E&xit");
+
+ wxMenu *about_menu = new wxMenu;
+ about_menu->Append(ID_ABOUT, "&About");
+
+ wxMenuBar *menu_bar = new wxMenuBar;
+ menu_bar->Append(file_menu, "&File");
+ menu_bar->Append(about_menu, "&About");
+
+ SetMenuBar(menu_bar);
+ CreateStatusBar();
+
+
+ // redirect logs from our event handlers to text control
+ m_log = new wxTextCtrl( this, wxID_ANY, wxString(), wxDefaultPosition,
+ wxDefaultSize, wxTE_MULTILINE );
+ m_log->SetMinSize(wxSize(-1, 100));
+ m_logOld = wxLog::SetActiveTarget(new wxLogTextCtrl(m_log));
+ wxLogMessage( "This is the log window" );
+
+
+ // first page of the notebook
+ // --------------------------
+
+ m_notebook = new wxNotebook( this, wxID_ANY );