void MyFrame::OnCheckHTMLDocs(wxCommandEvent& event) { wxCheckBoxState state; switch ( event.GetId() ) { case Id_Uncheck_HTMLDocs: state = wxCHK_UNCHECKED; break; case Id_Check_HTMLDocs: state = wxCHK_CHECKED; break; case Id_Indet_HTMLDocs: state = wxCHK_UNDETERMINED; break; default: wxFAIL_MSG( "Unknown check state" ); return; } m_treelist->CheckItem(m_itemHTMLDocs, state); }
void MyFrame::OnItemContextMenu(wxTreeListEvent& event) { enum { Id_Check_Item, Id_Uncheck_Item, Id_Indet_Item, Id_Check_Recursively, Id_Update_Parent }; wxMenu menu; menu.Append(Id_Check_Item, "&Check item"); menu.Append(Id_Uncheck_Item, "&Uncheck item"); if ( m_treelist->HasFlag(wxTL_3STATE) ) menu.Append(Id_Indet_Item, "Make item &indeterminate"); menu.AppendSeparator(); menu.Append(Id_Check_Recursively, "Check &recursively"); menu.Append(Id_Update_Parent, "Update &parent"); const wxTreeListItem item = event.GetItem(); switch ( m_treelist->GetPopupMenuSelectionFromUser(menu) ) { case Id_Check_Item: m_treelist->CheckItem(item); break; case Id_Uncheck_Item: m_treelist->UncheckItem(item); break; case Id_Indet_Item: m_treelist->CheckItem(item, wxCHK_UNDETERMINED); break; case Id_Check_Recursively: m_treelist->CheckItemRecursively(item); break; case Id_Update_Parent: m_treelist->UpdateItemParentStateRecursively(item); break; default: wxFAIL_MSG( "Unexpected menu selection" ); // Fall through. case wxID_NONE: return; } }