+void MyFrame::OnTableAddColumn(wxCommandEvent& WXUNUSED(event))
+{
+ wxRichTextTable* table = wxDynamicCast(m_richTextCtrl->FindTable(), wxRichTextTable);
+ if (table)
+ {
+ wxRichTextAttr cellAttr = table->GetCell(0, 0)->GetAttributes();
+ table->AddColumns(table->GetColumnCount(), 1, cellAttr);
+ }
+}
+
+void MyFrame::OnTableAddRow(wxCommandEvent& WXUNUSED(event))
+{
+ wxRichTextTable* table = wxDynamicCast(m_richTextCtrl->FindTable(), wxRichTextTable);
+ if (table)
+ {
+ wxRichTextAttr cellAttr = table->GetCell(0, 0)->GetAttributes();
+ table->AddRows(table->GetRowCount(), 1, cellAttr);
+ }
+}
+
+void MyFrame::OnTableDeleteColumn(wxCommandEvent& WXUNUSED(event))
+{
+ wxRichTextTable* table = wxDynamicCast(m_richTextCtrl->FindTable(), wxRichTextTable);
+ if (table)
+ {
+ int col = table->GetFocusedCell().GetCol();
+ if (col == -1)
+ {
+ col = table->GetColumnCount() - 1;
+ }
+
+ table->DeleteColumns(col, 1);
+ }
+}
+
+void MyFrame::OnTableDeleteRow(wxCommandEvent& WXUNUSED(event))
+{
+ wxRichTextTable* table = wxDynamicCast(m_richTextCtrl->FindTable(), wxRichTextTable);
+ if (table)
+ {
+ int row = table->GetFocusedCell().GetRow();
+ if (row == -1)
+ {
+ row = table->GetRowCount() - 1;
+ }
+
+ table->DeleteRows(row, 1);
+ }
+}
+
+void MyFrame::OnTableFocusedUpdateUI(wxUpdateUIEvent& event)
+{
+ event.Enable(m_richTextCtrl->FindTable() != NULL);
+}
+
+void MyFrame::OnTableHasCellsUpdateUI(wxUpdateUIEvent& event)
+{
+ bool enable(false);
+ wxRichTextTable* table = wxDynamicCast(m_richTextCtrl->FindTable(), wxRichTextTable);
+ if (table)
+ {
+ if (event.GetId() == ID_TABLE_DELETE_COLUMN)
+ {
+ enable = table->GetColumnCount() > 1;
+ }
+ else
+ {
+ enable = table->GetRowCount() > 1;
+ }
+ }
+
+ event.Enable(enable);
+}
+