void SjMyMusicConfigPage::OnColClick(wxListEvent& event) { int newCol = event.GetColumn(); if( m_currSortCol == newCol ) { m_currSortCol = newCol | 0x00001000; /* toggle! */; } else { m_currSortCol = newCol; } m_listCtrl->SortItems(ListCtrlCompareFunction, m_currSortCol); // this may unselect Items on GTK, however, this should be fixed in wxWidgets/GTK }
void SjMyMusicConfigPage::InitPage(const wxString& selSourceUrl) { // create index list m_listOfSources.Clear(); m_listOfSources.DeleteContents(TRUE); SjModuleList* list = g_mainFrame->m_moduleSystem.GetModules(SJ_MODULETYPE_SCANNER); wxASSERT(list); SjModuleList::Node* moduleNode = list->GetFirst(); SjScannerModule* scannerModule; while( moduleNode ) { scannerModule = (SjScannerModule*)moduleNode->GetData(); wxASSERT(scannerModule); wxASSERT(scannerModule->IsLoaded()); long sourceCount = scannerModule->GetSourceCount(); long currSourceIndex; for( currSourceIndex = 0; currSourceIndex < sourceCount; currSourceIndex++ ) { SjSettingsSourceItem* item = new SjSettingsSourceItem(scannerModule, currSourceIndex, scannerModule->GetSourceUrl(currSourceIndex), scannerModule->GetSourceIcon(currSourceIndex)); m_listOfSources.Append(item); } // next moduleNode = moduleNode->GetNext(); } // get list control m_listCtrl->Freeze(); m_listCtrl->DeleteAllItems(); // go through all search directories SjSettingsSourceItem* item; SjSettingsSourceItemList::Node* itemnode = m_listOfSources.GetFirst(); int i = 0; wxString sourceNotes; while( itemnode ) { item = itemnode->GetData(); wxASSERT(item); wxListItem listitem; listitem.m_mask = wxLIST_MASK_IMAGE | wxLIST_MASK_TEXT | wxLIST_MASK_DATA; listitem.m_itemId = i; listitem.m_text = item->GetUrl(); listitem.SetData((void*)item); listitem.m_image = item->GetScannerModule()->GetSourceIcon(item->GetIndex()); sourceNotes = item->GetScannerModule()->GetSourceNotes(item->GetIndex()); if( !sourceNotes.IsEmpty() ) { listitem.m_text.Append(" ("); listitem.m_text.Append(sourceNotes); listitem.m_text.Append(')'); } m_listCtrl->InsertItem(listitem); itemnode = itemnode->GetNext(); i++; } m_listCtrl->SortItems(ListCtrlCompareFunction, m_currSortCol); m_listCtrl->Thaw(); // select the correct item // (should be done after SortItems() on GTK this may remove the selection ...) int i_cnt = m_listCtrl->GetItemCount(); for( i = 0; i < i_cnt; i ++ ) { item = (SjSettingsSourceItem*)m_listCtrl->GetItemData(i); if( item->GetUrl() == selSourceUrl ) { m_listCtrl->SetItemState(i, wxLIST_STATE_SELECTED|wxLIST_STATE_FOCUSED, wxLIST_STATE_SELECTED|wxLIST_STATE_FOCUSED); break; } } UpdateButtons(); }