1// 2// This file is part of the aMule Project. 3// 4// Copyright (c) 2003-2011 aMule Team ( admin@amule.org / http://www.amule.org ) 5// Copyright (c) 2002-2011 Merkur ( devs@emule-project.net / http://www.emule-project.net ) 6// 7// Any parts of this program derived from the xMule, lMule or eMule project, 8// or contributed by third-party developers are copyrighted by their 9// respective authors. 10// 11// This program is free software; you can redistribute it and/or modify 12// it under the terms of the GNU General Public License as published by 13// the Free Software Foundation; either version 2 of the License, or 14// (at your option) any later version. 15// 16// This program is distributed in the hope that it will be useful, 17// but WITHOUT ANY WARRANTY; without even the implied warranty of 18// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19// GNU General Public License for more details. 20// 21// You should have received a copy of the GNU General Public License 22// along with this program; if not, write to the Free Software 23// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 24// 25 26#include <wx/app.h> 27 28#include <wx/gauge.h> // Do_not_auto_remove (win32) 29 30#include <tags/FileTags.h> 31 32#include "SearchDlg.h" // Interface declarations. 33#include "SearchListCtrl.h" // Needed for CSearchListCtrl 34#include "muuli_wdr.h" // Needed for IDC_STARTS 35#include "amuleDlg.h" // Needed for CamuleDlg 36#include "MuleNotebook.h" 37#include "GetTickCount.h" 38#include "Preferences.h" 39#include "amule.h" // Needed for theApp 40#include "SearchList.h" // Needed for CSearchList 41#include <common/Format.h> 42#include "Logger.h" 43 44#define ID_SEARCHLISTCTRL wxID_HIGHEST+667 45 46// just to keep compiler happy 47static wxCommandEvent nullEvent; 48 49BEGIN_EVENT_TABLE(CSearchDlg, wxPanel) 50 EVT_BUTTON( IDC_STARTS, CSearchDlg::OnBnClickedStart) 51 EVT_TEXT_ENTER( IDC_SEARCHNAME, CSearchDlg::OnBnClickedStart) 52 53 EVT_BUTTON(IDC_CANCELS, CSearchDlg::OnBnClickedStop) 54 55 EVT_LIST_ITEM_SELECTED(ID_SEARCHLISTCTRL, CSearchDlg::OnListItemSelected) 56 57 EVT_BUTTON(IDC_SDOWNLOAD, CSearchDlg::OnBnClickedDownload) 58 EVT_BUTTON(IDC_SEARCH_RESET, CSearchDlg::OnBnClickedReset) 59 EVT_BUTTON(IDC_CLEAR_RESULTS, CSearchDlg::OnBnClickedClear) 60 61 EVT_CHECKBOX(IDC_EXTENDEDSEARCHCHECK,CSearchDlg::OnExtendedSearchChange) 62 EVT_CHECKBOX(IDC_FILTERCHECK,CSearchDlg::OnFilterCheckChange) 63 64 EVT_MULENOTEBOOK_PAGE_CLOSING(ID_NOTEBOOK, CSearchDlg::OnSearchClosing) 65 EVT_NOTEBOOK_PAGE_CHANGED(ID_NOTEBOOK, CSearchDlg::OnSearchPageChanged) 66 67 // Event handlers for the parameter fields getting changed 68 EVT_CUSTOM( wxEVT_COMMAND_TEXT_UPDATED, IDC_SEARCHNAME, CSearchDlg::OnFieldChanged) 69 EVT_CUSTOM( wxEVT_COMMAND_TEXT_UPDATED, IDC_EDITSEARCHEXTENSION, CSearchDlg::OnFieldChanged) 70 EVT_CUSTOM( wxEVT_COMMAND_SPINCTRL_UPDATED, wxID_ANY, CSearchDlg::OnFieldChanged) 71 EVT_CUSTOM( wxEVT_COMMAND_CHOICE_SELECTED, wxID_ANY, CSearchDlg::OnFieldChanged) 72 73 // Event handlers for the filter fields getting changed. 74 EVT_TEXT_ENTER(ID_FILTER_TEXT, CSearchDlg::OnFilteringChange) 75 EVT_CHECKBOX(ID_FILTER_INVERT, CSearchDlg::OnFilteringChange) 76 EVT_CHECKBOX(ID_FILTER_KNOWN, CSearchDlg::OnFilteringChange) 77 EVT_BUTTON(ID_FILTER, CSearchDlg::OnFilteringChange) 78END_EVENT_TABLE() 79 80 81 82CSearchDlg::CSearchDlg(wxWindow* pParent) 83: wxPanel(pParent, -1) 84{ 85 m_last_search_time = 0; 86 87 wxSizer* content = searchDlg(this, true); 88 content->Show(this, true); 89 90 m_progressbar = CastChild( ID_SEARCHPROGRESS, wxGauge ); 91 m_progressbar->SetRange(100); 92 93 m_notebook = CastChild( ID_NOTEBOOK, CMuleNotebook ); 94 95#ifdef __WXMAC__ 96 //#warning TODO: restore the image list if/when wxMac supports locating the image 97#else 98 // Initialise the image list 99 wxImageList* m_ImageList = new wxImageList(16,16); 100 m_ImageList->Add(amuleSpecial(3)); 101 m_ImageList->Add(amuleSpecial(4)); 102 m_notebook->AssignImageList(m_ImageList); 103#endif 104 105 // Sanity sanity 106 wxChoice* searchchoice = CastChild( ID_SEARCHTYPE, wxChoice ); 107 wxASSERT(searchchoice); 108 wxASSERT(searchchoice->GetString(0) == _("Local")); 109 wxASSERT(searchchoice->GetString(2) == _("Kad")); 110 wxASSERT(searchchoice->GetCount() == 4); 111 112 m_searchchoices = searchchoice->GetStrings(); 113 114 // Let's break it now. 115 116 FixSearchTypes(); 117 118 CastChild( IDC_TypeSearch, wxChoice )->SetSelection(0); 119 CastChild( IDC_SEARCHMINSIZE, wxChoice )->SetSelection(2); 120 CastChild( IDC_SEARCHMAXSIZE, wxChoice )->SetSelection(2); 121 122 // Not there initially. 123 s_searchsizer->Show(s_extendedsizer, false); 124 s_searchsizer->Show(s_filtersizer, false); 125 126 Layout(); 127} 128 129 130CSearchDlg::~CSearchDlg() 131{ 132} 133 134void CSearchDlg::FixSearchTypes() 135{ 136 wxChoice* searchchoice = CastChild( ID_SEARCHTYPE, wxChoice ); 137 138 searchchoice->Clear(); 139 140 // We should have only filedonkey now. Let's insert stuff. 141 142 int pos = 0; 143 144 if (thePrefs::GetNetworkED2K()){ 145 searchchoice->Insert(m_searchchoices[0], pos++); 146 searchchoice->Insert(m_searchchoices[1], pos++); 147 } 148 149 if (thePrefs::GetNetworkKademlia()) { 150 searchchoice->Insert(m_searchchoices[2], pos++); 151 } 152 153 searchchoice->Insert(m_searchchoices[3], pos++); 154 155 searchchoice->SetSelection(0); 156} 157 158CSearchListCtrl* CSearchDlg::GetSearchList( wxUIntPtr id ) 159{ 160 int nPages = m_notebook->GetPageCount(); 161 for ( int i = 0; i < nPages; i++ ) { 162 CSearchListCtrl* page = dynamic_cast<CSearchListCtrl*>(m_notebook->GetPage(i)); 163 164 if (page->GetSearchId() == id) { 165 return page; 166 } 167 } 168 169 return NULL; 170} 171 172 173void CSearchDlg::AddResult(CSearchFile* toadd) 174{ 175 CSearchListCtrl* outputwnd = GetSearchList( toadd->GetSearchID() ); 176 177 if ( outputwnd ) { 178 outputwnd->AddResult( toadd ); 179 180 // Update the result count 181 UpdateHitCount( outputwnd ); 182 } 183} 184 185 186void CSearchDlg::UpdateResult(CSearchFile* toupdate) 187{ 188 CSearchListCtrl* outputwnd = GetSearchList( toupdate->GetSearchID() ); 189 190 if ( outputwnd ) { 191 outputwnd->UpdateResult( toupdate ); 192 193 // Update the result count 194 UpdateHitCount( outputwnd ); 195 } 196} 197 198 199void CSearchDlg::OnListItemSelected(wxListEvent& event) 200{ 201 FindWindow(IDC_SDOWNLOAD)->Enable(true); 202 203 event.Skip(); 204} 205 206 207void CSearchDlg::OnExtendedSearchChange(wxCommandEvent& event) 208{ 209 s_searchsizer->Show(s_extendedsizer, event.IsChecked()); 210 211 Layout(); 212} 213 214 215void CSearchDlg::OnFilterCheckChange(wxCommandEvent& event) 216{ 217 s_searchsizer->Show(s_filtersizer, event.IsChecked()); 218 Layout(); 219 220 int nPages = m_notebook->GetPageCount(); 221 for ( int i = 0; i < nPages; i++ ) { 222 CSearchListCtrl* page = dynamic_cast<CSearchListCtrl*>(m_notebook->GetPage(i)); 223 224 page->EnableFiltering(event.IsChecked()); 225 226 UpdateHitCount(page); 227 } 228} 229 230 231void CSearchDlg::OnSearchClosing(wxBookCtrlEvent& evt) 232{ 233 // Abort global search if it was last tab that was closed. 234 if ( evt.GetSelection() == ((int)m_notebook->GetPageCount() - 1 ) ) { 235 OnBnClickedStop(nullEvent); 236 } 237 238 CSearchListCtrl *ctrl = dynamic_cast<CSearchListCtrl*>(m_notebook->GetPage(evt.GetSelection())); 239 wxASSERT(ctrl); 240 // Zero to avoid results added while destructing. 241 ctrl->ShowResults(0); 242 theApp->searchlist->RemoveResults(ctrl->GetSearchId()); 243 244 // Do cleanups if this was the last tab 245 if ( m_notebook->GetPageCount() == 1 ) { 246 FindWindow(IDC_SDOWNLOAD)->Enable(FALSE); 247 FindWindow(IDC_CLEAR_RESULTS)->Enable(FALSE); 248 } 249} 250 251 252void CSearchDlg::OnSearchPageChanged(wxBookCtrlEvent& WXUNUSED(evt)) 253{ 254 int selection = m_notebook->GetSelection(); 255 256 // Workaround for a bug in wxWidgets, where deletions of pages 257 // can result in an invalid selection. This has been reported as 258 // http://sourceforge.net/tracker/index.php?func=detail&aid=1865141&group_id=9863&atid=109863 259 if (selection >= (int)m_notebook->GetPageCount()) { 260 selection = m_notebook->GetPageCount() - 1; 261 } 262 263 // Only enable the Download button for pages where files have been selected 264 if ( selection != -1 ) { 265 CSearchListCtrl *ctrl = dynamic_cast<CSearchListCtrl*>(m_notebook->GetPage(selection)); 266 267 bool enable = (ctrl->GetSelectedItemCount() > 0); 268 FindWindow(IDC_SDOWNLOAD)->Enable( enable ); 269 } 270} 271 272 273void CSearchDlg::OnBnClickedStart(wxCommandEvent& WXUNUSED(evt)) 274{ 275 wxString searchString = CastChild( IDC_SEARCHNAME, wxTextCtrl )->GetValue(); 276 searchString.Trim(true); 277 searchString.Trim(false); 278 279 if ( searchString.IsEmpty() ) { 280 return; 281 } 282 283 wxChoice* choice = CastChild( ID_SEARCHTYPE, wxChoice ); 284 285 // Magic. 286 287 int searchtype = choice->GetSelection(); 288 289 if (!thePrefs::GetNetworkED2K()) { 290 searchtype += 2; 291 } 292 293 if (!thePrefs::GetNetworkKademlia()) { 294 searchtype += 1; 295 } 296 297 switch ( searchtype ) { 298 // Local Search 299 case 0: 300 // Global Search 301 case 1: 302 // Kad Search 303 case 2: 304 // We musn't search more often than once every 2 secs 305 if ((GetTickCount() - m_last_search_time) > 2000) { 306 m_last_search_time = GetTickCount(); 307 308 OnBnClickedStop(nullEvent); 309 310 StartNewSearch(); 311 } 312 313 break; 314 315 // Web Search (FileHash.com) 316 case 3: 317 theApp->amuledlg->LaunchUrl(theApp->amuledlg->GenWebSearchUrl(searchString, CamuleDlg::WS_FILEHASH)); 318 break; 319 320 // Error 321 default: 322 wxFAIL; 323 } 324} 325 326 327void CSearchDlg::OnFieldChanged( wxEvent& WXUNUSED(evt) ) 328{ 329 bool enable = false; 330 331 // These are the IDs of the search-fields 332 int textfields[] = { IDC_SEARCHNAME, IDC_EDITSEARCHEXTENSION }; 333 334 for ( uint16 i = 0; i < itemsof(textfields); i++ ) { 335 enable |= !CastChild( textfields[i], wxTextCtrl )->GetValue().IsEmpty(); 336 } 337 338 // Check if either of the dropdowns have been changed 339 enable |= (CastChild(IDC_SEARCHMINSIZE, wxChoice)->GetSelection() != 2); 340 enable |= (CastChild(IDC_SEARCHMAXSIZE, wxChoice)->GetSelection() != 2); 341 enable |= (CastChild(IDC_TypeSearch, wxChoice)->GetSelection() > 0); 342 enable |= (CastChild(ID_AUTOCATASSIGN, wxChoice)->GetSelection() > 0); 343 344 // These are the IDs of the search-fields 345 int spinfields[] = { IDC_SPINSEARCHMIN, IDC_SPINSEARCHMAX, IDC_SPINSEARCHAVAIBILITY }; 346 for ( uint16 i = 0; i < itemsof(spinfields); i++ ) { 347 enable |= (CastChild( spinfields[i], wxSpinCtrl )->GetValue() > 0); 348 } 349 350 // Enable the "Reset" button if any fields contain text 351 FindWindow(IDC_SEARCH_RESET)->Enable( enable ); 352 353 // Enable the Server Search button if the Name field contains text 354 enable = !CastChild( IDC_SEARCHNAME, wxTextCtrl )->GetValue().IsEmpty(); 355 FindWindow(IDC_STARTS)->Enable( enable ); 356} 357 358 359void CSearchDlg::OnFilteringChange(wxCommandEvent& WXUNUSED(evt)) 360{ 361 wxString filter = CastChild(ID_FILTER_TEXT, wxTextCtrl)->GetValue(); 362 bool invert = CastChild(ID_FILTER_INVERT, wxCheckBox)->GetValue(); 363 bool known = CastChild(ID_FILTER_KNOWN, wxCheckBox)->GetValue(); 364 365 // Check that the expression compiles before we try to assign it 366 // Otherwise we will get an error-dialog for each result-list. 367 if (wxRegEx(filter, wxRE_DEFAULT | wxRE_ICASE).IsValid()) { 368 int nPages = m_notebook->GetPageCount(); 369 for ( int i = 0; i < nPages; i++ ) { 370 CSearchListCtrl* page = dynamic_cast<CSearchListCtrl*>(m_notebook->GetPage(i)); 371 372 page->SetFilter(filter, invert, known); 373 374 UpdateHitCount(page); 375 } 376 } 377} 378 379 380bool CSearchDlg::CheckTabNameExists(const wxString& searchString) 381{ 382 int nPages = m_notebook->GetPageCount(); 383 for ( int i = 0; i < nPages; i++ ) { 384 // The BeforeLast(' ') is to strip the hit-count from the name 385 if ( m_notebook->GetPageText(i).BeforeLast(wxT(' ')) == searchString ) { 386 return true; 387 } 388 } 389 390 return false; 391} 392 393 394void CSearchDlg::CreateNewTab(const wxString& searchString, wxUIntPtr nSearchID) 395{ 396 CSearchListCtrl* list = new CSearchListCtrl( (wxWindow*)m_notebook, ID_SEARCHLISTCTRL, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxNO_BORDER); 397 m_notebook->AddPage(list, searchString, true, 0); 398 399 // Ensure that new results are filtered 400 bool enable = CastChild(IDC_FILTERCHECK, wxCheckBox)->GetValue(); 401 wxString filter = CastChild(ID_FILTER_TEXT, wxTextCtrl)->GetValue(); 402 bool invert = CastChild(ID_FILTER_INVERT, wxCheckBox)->GetValue(); 403 bool known = CastChild(ID_FILTER_KNOWN, wxCheckBox)->GetValue(); 404 405 list->SetFilter(filter, invert, known); 406 list->EnableFiltering(enable); 407 list->ShowResults(nSearchID); 408 409 Layout(); 410 FindWindow(IDC_CLEAR_RESULTS)->Enable(true); 411} 412 413 414void CSearchDlg::OnBnClickedStop(wxCommandEvent& WXUNUSED(evt)) 415{ 416 theApp->searchlist->StopSearch(); 417 ResetControls(); 418} 419 420 421void CSearchDlg::ResetControls() 422{ 423 m_progressbar->SetValue(0); 424 425 FindWindow(IDC_CANCELS)->Disable(); 426 FindWindow(IDC_STARTS)->Enable(!CastChild( IDC_SEARCHNAME, wxTextCtrl )->GetValue().IsEmpty()); 427} 428 429 430void CSearchDlg::LocalSearchEnd() 431{ 432 ResetControls(); 433} 434 435void CSearchDlg::KadSearchEnd(uint32 id) 436{ 437 int nPages = m_notebook->GetPageCount(); 438 for (int i = 0; i < nPages; ++i) { 439 CSearchListCtrl* page = 440 dynamic_cast<CSearchListCtrl*>(m_notebook->GetPage(i)); 441 if (page->GetSearchId() == id || id == 0) { // 0: just update all pages (there is only one KAD search running at a time anyway) 442 wxString rest; 443 if (m_notebook->GetPageText(i).StartsWith(wxT("!"),&rest)) { 444 m_notebook->SetPageText(i,rest); 445 } 446 } 447 } 448} 449 450void CSearchDlg::OnBnClickedDownload(wxCommandEvent& WXUNUSED(evt)) 451{ 452 int sel = m_notebook->GetSelection(); 453 if (sel != -1) { 454 CSearchListCtrl* list = dynamic_cast<CSearchListCtrl*>(m_notebook->GetPage(sel)); 455 456 // Download with items added to category specified in the drop-down menu 457 list->DownloadSelected(); 458 } 459} 460 461 462void CSearchDlg::OnBnClickedClear(wxCommandEvent& WXUNUSED(ev)) 463{ 464 OnBnClickedStop(nullEvent); 465 466 m_notebook->DeleteAllPages(); 467 468 FindWindow(IDC_CLEAR_RESULTS)->Enable(FALSE); 469 FindWindow(IDC_SDOWNLOAD)->Enable(FALSE); 470} 471 472 473void CSearchDlg::StartNewSearch() 474{ 475 static uint32 m_nSearchID = 0; 476 m_nSearchID++; 477 478 FindWindow(IDC_STARTS)->Disable(); 479 FindWindow(IDC_SDOWNLOAD)->Disable(); 480 FindWindow(IDC_CANCELS)->Enable(); 481 482 CSearchList::CSearchParams params; 483 484 params.searchString = CastChild( IDC_SEARCHNAME, wxTextCtrl )->GetValue(); 485 params.searchString.Trim(true); 486 params.searchString.Trim(false); 487 488 if (params.searchString.IsEmpty()) { 489 return; 490 } 491 492 if (CastChild(IDC_EXTENDEDSEARCHCHECK, wxCheckBox)->GetValue()) { 493 params.extension = CastChild( IDC_EDITSEARCHEXTENSION, wxTextCtrl )->GetValue(); 494 495 uint32 sizemin = GetTypeSize( (uint8) CastChild( IDC_SEARCHMINSIZE, wxChoice )->GetSelection() ); 496 uint32 sizemax = GetTypeSize( (uint8) CastChild( IDC_SEARCHMAXSIZE, wxChoice )->GetSelection() ); 497 498 // Parameter Minimum Size 499 params.minSize = (uint64_t)(CastChild( IDC_SPINSEARCHMIN, wxSpinCtrl )->GetValue()) * (uint64_t)sizemin; 500 501 // Parameter Maximum Size 502 params.maxSize = (uint64_t)(CastChild( IDC_SPINSEARCHMAX, wxSpinCtrl )->GetValue()) * (uint64_t)sizemax; 503 504 if ((params.maxSize < params.minSize) && (params.maxSize)) { 505 wxMessageDialog dlg(this, 506 _("Min size must be smaller than max size. Max size ignored."), 507 _("Search warning"), wxOK|wxCENTRE|wxICON_INFORMATION); 508 dlg.ShowModal(); 509 510 params.maxSize = 0; 511 } 512 513 // Parameter Availability 514 params.availability = CastChild( IDC_SPINSEARCHAVAIBILITY, wxSpinCtrl )->GetValue(); 515 516 switch ( CastChild( IDC_TypeSearch, wxChoice )->GetSelection() ) { 517 case 0: params.typeText.Clear(); break; 518 case 1: params.typeText = ED2KFTSTR_ARCHIVE; break; 519 case 2: params.typeText = ED2KFTSTR_AUDIO; break; 520 case 3: params.typeText = ED2KFTSTR_CDIMAGE; break; 521 case 4: params.typeText = ED2KFTSTR_IMAGE; break; 522 case 5: params.typeText = ED2KFTSTR_PROGRAM; break; 523 case 6: params.typeText = ED2KFTSTR_DOCUMENT; break; 524 case 7: params.typeText = ED2KFTSTR_VIDEO; break; 525 default: 526 AddDebugLogLineC( logGeneral, 527 CFormat( wxT("Warning! Unknown search-category (%s) selected!") ) 528 % params.typeText 529 ); 530 break; 531 } 532 } 533 534 SearchType search_type = KadSearch; 535 536 int selection = CastChild( ID_SEARCHTYPE, wxChoice )->GetSelection(); 537 538 if (!thePrefs::GetNetworkED2K()) { 539 selection += 2; 540 } 541 542 if (!thePrefs::GetNetworkKademlia()) { 543 selection += 1; 544 } 545 546 switch (selection) { 547 case 0: // Local Search 548 search_type = LocalSearch; 549 break; 550 case 1: // Global Search 551 search_type = GlobalSearch; 552 break; 553 case 2: // Kad search 554 search_type = KadSearch; 555 break; 556 default: 557 // Should never happen 558 wxFAIL; 559 break; 560 } 561 562 uint32 real_id = m_nSearchID; 563 wxString error = theApp->searchlist->StartNewSearch(&real_id, search_type, params); 564 if (!error.IsEmpty()) { 565 // Search failed / Remote in progress 566 wxMessageBox(error, _("Search warning"), 567 wxOK | wxCENTRE | wxICON_INFORMATION, this); 568 FindWindow(IDC_STARTS)->Enable(); 569 FindWindow(IDC_SDOWNLOAD)->Disable(); 570 FindWindow(IDC_CANCELS)->Disable(); 571 } else { 572 CreateNewTab( 573 ((search_type == KadSearch) ? wxT("!") : wxEmptyString) + 574 params.searchString + wxT(" (0)"), 575 real_id); 576 } 577} 578 579 580void CSearchDlg::UpdateHitCount(CSearchListCtrl* page) 581{ 582 for ( uint32 i = 0; i < (uint32)m_notebook->GetPageCount(); ++i ) { 583 if ( m_notebook->GetPage(i) == page ) { 584 wxString searchtxt = m_notebook->GetPageText(i).BeforeLast(wxT(' ')); 585 586 if ( !searchtxt.IsEmpty() ) { 587 size_t shown = page->GetItemCount(); 588 size_t hidden = page->GetHiddenItemCount(); 589 590 if (hidden) { 591 searchtxt += CFormat(wxT(" (%u/%u)")) % shown % (shown + hidden); 592 } else { 593 searchtxt += CFormat(wxT(" (%u)")) % shown; 594 } 595 596 m_notebook->SetPageText(i, searchtxt); 597 } 598 599 break; 600 } 601 } 602} 603 604 605void CSearchDlg::OnBnClickedReset(wxCommandEvent& WXUNUSED(evt)) 606{ 607 CastChild( IDC_SEARCHNAME, wxTextCtrl )->Clear(); 608 CastChild( IDC_EDITSEARCHEXTENSION, wxTextCtrl )->Clear(); 609 CastChild( IDC_SPINSEARCHMIN, wxSpinCtrl )->SetValue(0); 610 CastChild( IDC_SEARCHMINSIZE, wxChoice )->SetSelection(2); 611 CastChild( IDC_SPINSEARCHMAX, wxSpinCtrl )->SetValue(0); 612 CastChild( IDC_SEARCHMAXSIZE, wxChoice )->SetSelection(2); 613 CastChild( IDC_SPINSEARCHAVAIBILITY, wxSpinCtrl )->SetValue(0); 614 CastChild( IDC_TypeSearch, wxChoice )->SetSelection(0); 615 CastChild( ID_AUTOCATASSIGN, wxChoice )->SetSelection(0); 616 617 FindWindow(IDC_SEARCH_RESET)->Enable(FALSE); 618} 619 620 621void CSearchDlg::UpdateCatChoice() 622{ 623 wxChoice* c_cat = CastChild( ID_AUTOCATASSIGN, wxChoice ); 624 c_cat->Clear(); 625 626 c_cat->Append(_("Main")); 627 628 for ( unsigned i = 1; i < theApp->glob_prefs->GetCatCount(); i++ ) { 629 c_cat->Append( theApp->glob_prefs->GetCategory( i )->title ); 630 } 631 632 c_cat->SetSelection( 0 ); 633} 634 635void CSearchDlg::UpdateProgress(uint32 new_value) { 636 m_progressbar->SetValue(new_value); 637} 638// File_checked_for_headers 639