void MyFrame::OnPageChanged( wxBookCtrlEvent& WXUNUSED(event) ) { unsigned int nPanel = m_notebook->GetSelection(); GetMenuBar()->FindItem(ID_STYLE_MENU)->SetItemLabel( wxString::Format("Style of panel #%d", nPanel+1)); for (unsigned int id = ID_MULTIPLE; id <= ID_VERT_RULES; id++) { unsigned long style = 0; switch (id) { /*case ID_SINGLE: style = wxDV_SINGLE; break;*/ case ID_MULTIPLE: style = wxDV_MULTIPLE; break; case ID_ROW_LINES: style = wxDV_ROW_LINES; break; case ID_HORIZ_RULES: style = wxDV_HORIZ_RULES; break; case ID_VERT_RULES: style = wxDV_VERT_RULES; break; default: wxFAIL; } GetMenuBar()->FindItem(id)->Check( m_ctrl[nPanel]->HasFlag(style) ); } }
void MyFrame::OnStyleChange( wxCommandEvent& WXUNUSED(event) ) { unsigned int nPanel = m_notebook->GetSelection(); // build the style unsigned long style = 0; /*if (GetMenuBar()->FindItem(ID_SINGLE)->IsChecked()) style |= wxDV_SINGLE;*/ if (GetMenuBar()->FindItem(ID_MULTIPLE)->IsChecked()) style |= wxDV_MULTIPLE; if (GetMenuBar()->FindItem(ID_ROW_LINES)->IsChecked()) style |= wxDV_ROW_LINES; if (GetMenuBar()->FindItem(ID_HORIZ_RULES)->IsChecked()) style |= wxDV_HORIZ_RULES; if (GetMenuBar()->FindItem(ID_VERT_RULES)->IsChecked()) style |= wxDV_VERT_RULES; wxSizer* sz = m_ctrl[nPanel]->GetContainingSizer(); wxASSERT(sz); sz->Detach(m_ctrl[nPanel]); wxDELETE(m_ctrl[nPanel]); m_ctrl[nPanel] = NULL; if (nPanel == 0) m_music_model.reset(NULL); else if (nPanel == 1) m_list_model.reset(NULL); // rebuild the DVC for the selected panel: BuildDataViewCtrl((wxPanel*)m_notebook->GetPage(nPanel), nPanel, style); sz->Prepend(m_ctrl[nPanel], 1, wxGROW|wxALL, 5); sz->Layout(); }
void MyFrame::OnSetBackgroundColour(wxCommandEvent& WXUNUSED(event)) { wxDataViewCtrl * const dvc = m_ctrl[m_notebook->GetSelection()]; wxColour col = wxGetColourFromUser(this, dvc->GetBackgroundColour()); if ( col.IsOk() ) { dvc->SetBackgroundColour(col); Refresh(); } }