00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "StdAfx.h"
00023 #include "Shareaza.h"
00024 #include "Settings.h"
00025 #include "Schema.h"
00026 #include "SchemaCache.h"
00027 #include "ManagedSearch.h"
00028 #include "QuerySearch.h"
00029 #include "CtrlSearchPanel.h"
00030 #include "CoolInterface.h"
00031 #include "ShellIcons.h"
00032 #include "XML.h"
00033 #include "Skin.h"
00034
00035 #ifdef _DEBUG
00036 #define new DEBUG_NEW
00037 #undef THIS_FILE
00038 static char THIS_FILE[] = __FILE__;
00039 #endif
00040
00041 IMPLEMENT_DYNAMIC(CSearchPanel, CTaskPanel)
00042 BEGIN_MESSAGE_MAP(CSearchPanel, CTaskPanel)
00043
00044 ON_WM_CREATE()
00045
00046 END_MESSAGE_MAP()
00047
00048 IMPLEMENT_DYNAMIC(CSearchInputBox, CTaskBox)
00049 BEGIN_MESSAGE_MAP(CSearchInputBox, CTaskBox)
00050
00051 ON_WM_CREATE()
00052 ON_WM_SIZE()
00053 ON_WM_PAINT()
00054 ON_CBN_SELCHANGE(IDC_SCHEMAS, OnSelChangeSchemas)
00055 ON_CBN_CLOSEUP(IDC_SCHEMAS, OnCloseUpSchemas)
00056 ON_COMMAND(IDC_SEARCH_START, OnSearchStart)
00057 ON_COMMAND(IDC_SEARCH_STOP, OnSearchStop)
00058
00059 END_MESSAGE_MAP()
00060
00061 IMPLEMENT_DYNAMIC(CSearchAdvancedBox, CTaskBox)
00062 BEGIN_MESSAGE_MAP(CSearchAdvancedBox, CTaskBox)
00063
00064 ON_WM_CREATE()
00065 ON_WM_SIZE()
00066 ON_WM_PAINT()
00067
00068 END_MESSAGE_MAP()
00069
00070 IMPLEMENT_DYNAMIC(CSearchSchemaBox, CTaskBox)
00071 BEGIN_MESSAGE_MAP(CSearchSchemaBox, CTaskBox)
00072
00073 ON_WM_CREATE()
00074 ON_WM_SIZE()
00075
00076 END_MESSAGE_MAP()
00077
00078 IMPLEMENT_DYNAMIC(CSearchResultsBox, CTaskBox)
00079 BEGIN_MESSAGE_MAP(CSearchResultsBox, CTaskBox)
00080
00081 ON_WM_PAINT()
00082
00083 END_MESSAGE_MAP()
00084
00085 #define BOX_MARGIN 10
00086
00087
00089
00090
00091 CSearchPanel::CSearchPanel()
00092 {
00093 m_bSendSearch = FALSE;
00094 m_bAdvanced = FALSE;
00095 }
00096
00097 CSearchPanel::~CSearchPanel()
00098 {
00099 }
00100
00102
00103
00104 BOOL CSearchPanel::Create(CWnd* pParentWnd)
00105 {
00106 CRect rect;
00107 return CTaskPanel::Create( WS_VISIBLE, rect, pParentWnd, IDC_SEARCH_PANEL );
00108 }
00109
00110 int CSearchPanel::OnCreate(LPCREATESTRUCT lpCreateStruct)
00111 {
00112 if ( CTaskPanel::OnCreate( lpCreateStruct ) == -1 )return -1;
00113
00114 m_bAdvanced = ( Settings.General.GUIMode != GUI_BASIC ) && ( Settings.Search.AdvancedPanel );
00115
00116 m_boxSearch.Create( this, 136, _T("Search"), IDR_SEARCHFRAME );
00117 m_boxAdvanced.Create( this, 100, _T("Advanced"), IDR_SEARCHFRAME );
00118 m_boxSchema.Create( this, 0, _T("Schema"), IDR_SEARCHFRAME );
00119 m_boxResults.Create( this, 80, _T("Results"), IDR_HOSTCACHEFRAME );
00120
00121
00122 AddBox( &m_boxSearch );
00123
00124
00125 if ( m_bAdvanced )
00126 {
00127 AddBox( &m_boxAdvanced );
00128
00129 if ( GetSystemMetrics( SM_CYSCREEN ) < 1024 ) m_boxAdvanced.Expand( FALSE );
00130 }
00131
00132
00133 AddBox( &m_boxSchema );
00134
00135
00136 if ( m_bAdvanced ) AddBox( &m_boxResults );
00137
00138
00139 SetStretchBox( &m_boxSchema );
00140
00141 OnSkinChange();
00142
00143 return 0;
00144 }
00145
00146 void CSearchPanel::OnSkinChange()
00147 {
00148 CString strCaption;
00149
00150 LoadString( strCaption, IDS_SEARCH_PANEL_INPUT_CAPTION );
00151 m_boxSearch.SetCaption( strCaption );
00152 LoadString( strCaption, IDS_SEARCH_PANEL_RESULTS_CAPTION );
00153 m_boxResults.SetCaption( strCaption );
00154 LoadString( strCaption, IDS_SEARCH_PANEL_ADVANCED );
00155 m_boxAdvanced.SetCaption( strCaption );
00156
00157 SetWatermark( Skin.GetWatermark( _T("CSearchPanel") ) );
00158 SetFooter( Skin.GetWatermark( _T("CSearchPanel.Footer") ), TRUE );
00159
00160 m_boxSearch.SetWatermark( Skin.GetWatermark( _T("CSearchInputBox") ) );
00161 m_boxSearch.SetCaptionmark( Skin.GetWatermark( _T("CSearchInputBox.Caption") ) );
00162 m_boxSearch.OnSkinChange();
00163
00164 m_boxAdvanced.SetWatermark( Skin.GetWatermark( _T("CSearchAdvancedBox") ) );
00165 m_boxAdvanced.SetCaptionmark( Skin.GetWatermark( _T("CSearchAdvancedBox.Caption") ) );
00166 m_boxAdvanced.OnSkinChange();
00167
00168 m_boxSchema.SetWatermark( Skin.GetWatermark( _T("CSearchSchemaBox") ) );
00169 m_boxSchema.SetCaptionmark( Skin.GetWatermark( _T("CSearchSchemaBox.Caption") ) );
00170
00171 m_boxResults.SetWatermark( Skin.GetWatermark( _T("CSearchResultsBox") ) );
00172 m_boxResults.SetCaptionmark( Skin.GetWatermark( _T("CSearchResultsBox.Caption") ) );
00173
00174 Invalidate();
00175 }
00176
00177 void CSearchPanel::SetSearchFocus()
00178 {
00179 m_boxSearch.m_wndSearch.SetFocus();
00180 }
00181
00182 void CSearchPanel::ShowSearch(CManagedSearch* pSearch)
00183 {
00184 if ( pSearch == NULL )
00185 {
00186 OnSchemaChange();
00187 return;
00188 }
00189
00190 m_boxSearch.m_wndSearch.SetWindowText( pSearch->m_pSearch->m_sSearch );
00191 m_boxSearch.m_wndSchemas.Select( pSearch->m_pSearch->m_pSchema );
00192
00193 if ( m_bAdvanced )
00194 {
00195 if ( pSearch->m_bAllowG2 && ! pSearch->m_bAllowG1 && ! pSearch->m_bAllowED2K )
00196 m_boxAdvanced.m_wndNetworks.SetNetwork( PROTOCOL_G2 );
00197 else if ( ! pSearch->m_bAllowG2 && pSearch->m_bAllowG1 && ! pSearch->m_bAllowED2K )
00198 m_boxAdvanced.m_wndNetworks.SetNetwork( PROTOCOL_G1 );
00199 else if ( ! pSearch->m_bAllowG2 && ! pSearch->m_bAllowG1 && pSearch->m_bAllowED2K )
00200 m_boxAdvanced.m_wndNetworks.SetNetwork( PROTOCOL_ED2K );
00201 else
00202 m_boxAdvanced.m_wndNetworks.SetNetwork( PROTOCOL_NULL );
00203
00204
00205 CString strSize;
00206 if ( pSearch->m_pSearch->m_nMinSize > 0 )
00207 strSize = Settings.SmartVolume( pSearch->m_pSearch->m_nMinSize, FALSE, FALSE, TRUE );
00208 else
00209 strSize.Empty();
00210 if ( m_boxAdvanced.m_wndSizeMin.m_hWnd != NULL ) m_boxAdvanced.m_wndSizeMin.SetWindowText( strSize );
00211
00212
00213 if ( pSearch->m_pSearch->m_nMaxSize < SIZE_UNKNOWN )
00214 strSize = Settings.SmartVolume( pSearch->m_pSearch->m_nMaxSize, FALSE, FALSE, TRUE );
00215 else
00216 strSize.Empty();
00217 if ( m_boxAdvanced.m_wndSizeMax.m_hWnd != NULL ) m_boxAdvanced.m_wndSizeMax.SetWindowText( strSize );
00218 }
00219
00220 OnSchemaChange();
00221
00222 if ( pSearch->m_pSearch->m_pXML != NULL )
00223 {
00224 m_boxSchema.m_wndSchema.UpdateData( pSearch->m_pSearch->m_pXML->GetFirstElement(), FALSE );
00225 }
00226 }
00227
00228 void CSearchPanel::ShowStatus(BOOL bStarted, BOOL bSearching, DWORD nFiles, DWORD nHits, DWORD nHubs, DWORD nLeaves)
00229 {
00230 CString strCaption;
00231
00232 if ( bStarted )
00233 {
00234
00235 if ( bSearching )
00236 {
00237 LoadString( strCaption, IDS_SEARCH_PANEL_SEARCHING );
00238 m_boxSearch.m_wndStart.EnableWindow( FALSE );
00239 }
00240 else
00241 {
00242 LoadString( strCaption, IDS_SEARCH_PANEL_MORE );
00243 m_boxSearch.m_wndStart.EnableWindow( TRUE );
00244 }
00245 }
00246 else
00247 {
00248 LoadString( strCaption, IDS_SEARCH_PANEL_START );
00249 m_boxSearch.m_wndStart.EnableWindow( TRUE );
00250 }
00251 m_boxSearch.m_wndStart.SetText( strCaption );
00252
00253 LoadString( strCaption, bStarted ? IDS_SEARCH_PANEL_STOP : IDS_SEARCH_PANEL_CLEAR );
00254 m_boxSearch.m_wndStop.SetText( strCaption );
00255
00256 m_boxResults.Update( bStarted, nFiles, nHits, nHubs, nLeaves );
00257 }
00258
00259 void CSearchPanel::OnSchemaChange()
00260 {
00261 CSchema* pSchema = m_boxSearch.m_wndSchemas.GetSelected();
00262
00263 m_boxSchema.m_wndSchema.SetSchema( pSchema, TRUE );
00264 m_boxSchema.SetSize( pSchema != NULL ? 1 : 0 );
00265
00266 if ( pSchema != NULL )
00267 {
00268 HICON hIcon = ShellIcons.ExtractIcon( pSchema->m_nIcon16, 16 );
00269
00270 if ( theApp.m_bRTL ) hIcon = CreateMirroredIcon( hIcon );
00271 m_boxSchema.SetIcon( hIcon, TRUE );
00272 CString strTitle = pSchema->m_sTitle;
00273 int nPos = strTitle.Find( ':' );
00274 if ( nPos > 0 ) strTitle = strTitle.Mid( nPos + 1 );
00275 m_boxSchema.SetCaption( strTitle );
00276 }
00277 }
00278
00279 CManagedSearch* CSearchPanel::GetSearch()
00280 {
00281 CManagedSearch* pSearch = new CManagedSearch();
00282
00283 m_boxSearch.m_wndSearch.GetWindowText( pSearch->m_pSearch->m_sSearch );
00284
00285 if ( CSchema* pSchema = m_boxSearch.m_wndSchemas.GetSelected() )
00286 {
00287 pSearch->m_pSearch->m_pSchema = pSchema;
00288 pSearch->m_pSearch->m_pXML = pSchema->Instantiate();
00289
00290 m_boxSchema.m_wndSchema.UpdateData(
00291 pSearch->m_pSearch->m_pXML->AddElement( pSchema->m_sSingular ), TRUE );
00292
00293 Settings.Search.LastSchemaURI = pSchema->m_sURI;
00294 }
00295 else
00296 {
00297 Settings.Search.LastSchemaURI.Empty();
00298 }
00299 if ( m_bAdvanced )
00300 {
00301 if ( m_boxAdvanced.m_wndNetworks.m_hWnd != NULL )
00302 {
00303 switch ( m_boxAdvanced.m_wndNetworks.GetNetwork() )
00304 {
00305 case PROTOCOL_NULL:
00306 pSearch->m_bAllowG2 = TRUE;
00307 pSearch->m_bAllowG1 = TRUE;
00308 pSearch->m_bAllowED2K = TRUE;
00309 break;
00310 case PROTOCOL_G2:
00311 pSearch->m_bAllowG2 = TRUE;
00312 pSearch->m_bAllowG1 = FALSE;
00313 pSearch->m_bAllowED2K = FALSE;
00314 break;
00315 case PROTOCOL_G1:
00316 pSearch->m_bAllowG2 = FALSE;
00317 pSearch->m_bAllowG1 = TRUE;
00318 pSearch->m_bAllowED2K = FALSE;
00319 break;
00320 case PROTOCOL_ED2K:
00321 pSearch->m_bAllowG2 = FALSE;
00322 pSearch->m_bAllowG1 = FALSE;
00323 pSearch->m_bAllowED2K = TRUE;
00324 break;
00325 }
00326 }
00327
00328 if ( m_boxAdvanced.m_wndSizeMin.m_hWnd != NULL )
00329 {
00330 CString strWindowValue;
00331
00332 m_boxAdvanced.m_wndSizeMin.GetWindowText( strWindowValue );
00333 if ( strWindowValue.IsEmpty() || ( _tcsicmp( strWindowValue, _T("any") ) == 0 ) )
00334 pSearch->m_pSearch->m_nMinSize = 0;
00335 else
00336 pSearch->m_pSearch->m_nMinSize = Settings.ParseVolume( strWindowValue, FALSE );
00337
00338
00339 m_boxAdvanced.m_wndSizeMax.GetWindowText( strWindowValue );
00340 if ( strWindowValue.IsEmpty() || ( _tcsicmp( strWindowValue, _T("any") ) == 0 ) || ( _tcsicmp( strWindowValue, _T("max") ) == 0 ) )
00341 pSearch->m_pSearch->m_nMaxSize = SIZE_UNKNOWN;
00342 else
00343 pSearch->m_pSearch->m_nMaxSize = Settings.ParseVolume( strWindowValue, FALSE );
00344
00345
00346 if ( pSearch->m_pSearch->m_nMinSize > pSearch->m_pSearch->m_nMaxSize )
00347 pSearch->m_pSearch->m_nMaxSize = SIZE_UNKNOWN;
00348 }
00349 }
00350
00351 pSearch->m_pSearch->BuildWordList();
00352
00353 if ( ! pSearch->m_pSearch->CheckValid() )
00354 {
00355 delete pSearch;
00356 return NULL;
00357 }
00358
00359 return pSearch;
00360 }
00361
00362 void CSearchPanel::ExecuteSearch()
00363 {
00364 m_bSendSearch = TRUE;
00365 GetParent()->SendMessage( WM_COMMAND, ID_SEARCH_SEARCH );
00366 m_bSendSearch = FALSE;
00367 }
00368
00369 BOOL CSearchPanel::PreTranslateMessage(MSG* pMsg)
00370 {
00371 if ( pMsg->message == WM_KEYDOWN )
00372 {
00373 if ( pMsg->wParam == VK_RETURN )
00374 {
00375 ExecuteSearch();
00376 return TRUE;
00377 }
00378 else if ( pMsg->wParam == VK_TAB )
00379 {
00380 BOOL bShift = GetAsyncKeyState( VK_SHIFT ) & 0x8000;
00381 CWnd* pWnd = GetFocus();
00382
00383 if ( pWnd == &m_boxSearch.m_wndSearch )
00384 {
00385 if ( bShift )
00386 m_boxSchema.m_wndSchema.SetFocus();
00387 else
00388 m_boxSearch.m_wndSchemas.SetFocus();
00389 return TRUE;
00390 }
00391 else if ( pWnd == &m_boxSearch.m_wndSchemas )
00392 {
00393 if ( bShift )
00394 m_boxSearch.m_wndSearch.SetFocus();
00395 else
00396 m_boxSchema.m_wndSchema.SetFocus();
00397 return TRUE;
00398 }
00399 else
00400 {
00401 m_boxSearch.m_wndSearch.SetFocus();
00402 }
00403 }
00404 }
00405
00406 return CTaskPanel::PreTranslateMessage( pMsg );
00407 }
00408
00409 void CSearchPanel::Enable()
00410 {
00411 m_boxSearch.m_wndSearch.EnableWindow( TRUE );
00412 m_boxSearch.m_wndSchemas.EnableWindow( TRUE );
00413
00414 m_boxAdvanced.m_wndNetworks.EnableWindow( TRUE );
00415 m_boxAdvanced.m_wndSizeMin.EnableWindow( TRUE );
00416 m_boxAdvanced.m_wndSizeMax.EnableWindow( TRUE );
00417
00418 m_boxSchema.m_wndSchema.Enable();
00419 }
00420
00421 void CSearchPanel::Disable()
00422 {
00423 m_boxSearch.m_wndSearch.EnableWindow( FALSE );
00424 m_boxSearch.m_wndSchemas.EnableWindow( FALSE );
00425
00426 m_boxAdvanced.m_wndNetworks.EnableWindow( FALSE );
00427 m_boxAdvanced.m_wndSizeMin.EnableWindow( FALSE );
00428 m_boxAdvanced.m_wndSizeMax.EnableWindow( FALSE );
00429
00430 m_boxSchema.m_wndSchema.Disable();
00431 }
00432
00433
00435
00436
00437 CSearchInputBox::CSearchInputBox()
00438 {
00439 }
00440
00441 CSearchInputBox::~CSearchInputBox()
00442 {
00443 }
00444
00446
00447
00448 int CSearchInputBox::OnCreate(LPCREATESTRUCT lpCreateStruct)
00449 {
00450 if ( CTaskBox::OnCreate( lpCreateStruct ) == -1 ) return -1;
00451
00452 CRect rc( 0, 0, 0, 0 );
00453 CString strCaption;
00454
00455 if ( ! m_wndSearch.Create( ES_AUTOHSCROLL|WS_TABSTOP|WS_GROUP, rc,
00456 this, IDC_SEARCH ) ) return -1;
00457
00458 m_wndSearch.SetFont( &theApp.m_gdiFont );
00459 m_wndSearch.ModifyStyleEx( 0, WS_EX_CLIENTEDGE );
00460
00461 if ( ! m_wndSchemas.Create( WS_TABSTOP, rc, this, IDC_SCHEMAS ) ) return -1;
00462
00463 LoadString( m_wndSchemas.m_sNoSchemaText, IDS_SEARCH_PANEL_AFT );
00464 m_wndSchemas.Load( Settings.Search.LastSchemaURI );
00465 m_wndSchemas.SendMessage( CB_SETDROPPEDWIDTH, 200 );
00466
00467 LoadString( strCaption, IDS_SEARCH_PANEL_START );
00468 m_wndStart.Create( rc, this, IDC_SEARCH_START );
00469 m_wndStart.SetWindowText( strCaption );
00470 m_wndStart.SetIcon( CoolInterface.ExtractIcon( ID_SEARCH_SEARCH ) );
00471 m_wndStart.SetHandCursor( TRUE );
00472
00473 LoadString( strCaption, IDS_SEARCH_PANEL_STOP );
00474 m_wndStop.Create( rc, this, IDC_SEARCH_STOP );
00475 m_wndStop.SetWindowText( strCaption );
00476 m_wndStop.SetIcon( CoolInterface.ExtractIcon( ID_SEARCH_STOP ) );
00477 m_wndStop.SetHandCursor( TRUE );
00478
00479 SetPrimary( TRUE );
00480
00481 return 0;
00482 }
00483
00484 void CSearchInputBox::OnSkinChange()
00485 {
00486 CString strCaption;
00487
00488 LoadString( strCaption, IDS_SEARCH_PANEL_START );
00489 m_wndStart.SetWindowText( strCaption );
00490 m_wndStart.SetIcon( CoolInterface.ExtractIcon( ID_SEARCH_SEARCH ) );
00491
00492 LoadString( strCaption, IDS_SEARCH_PANEL_STOP );
00493 m_wndStop.SetWindowText( strCaption );
00494 m_wndStop.SetIcon( CoolInterface.ExtractIcon( ID_SEARCH_STOP ) );
00495 }
00496
00497 void CSearchInputBox::OnSize(UINT nType, int cx, int cy)
00498 {
00499 CTaskBox::OnSize( nType, cx, cy );
00500
00501 HDWP hDWP = BeginDeferWindowPos( 4 );
00502
00503 DeferWindowPos( hDWP, m_wndSearch, NULL, BOX_MARGIN, 27, cx - BOX_MARGIN * 2, 19, SWP_SHOWWINDOW|SWP_NOZORDER );
00504 DeferWindowPos( hDWP, m_wndSchemas, NULL, BOX_MARGIN, 67, cx - BOX_MARGIN * 2, 256, SWP_SHOWWINDOW|SWP_NOZORDER );
00505
00506 DeferWindowPos( hDWP, m_wndStart, NULL, BOX_MARGIN, 102, 90, 24, SWP_SHOWWINDOW|SWP_NOZORDER );
00507 DeferWindowPos( hDWP, m_wndStop, NULL, cx - BOX_MARGIN - 60, 102, 60, 24, SWP_SHOWWINDOW|SWP_NOZORDER );
00508
00509
00510 EndDeferWindowPos( hDWP );
00511 }
00512
00513 void CSearchInputBox::OnPaint()
00514 {
00515 CPaintDC dc( this );
00516 CRect rc, rct;
00517 CString str;
00518
00519 UINT nFlags = ETO_CLIPPED;
00520 CDC* pDC = &dc;
00521
00522 GetClientRect( &rc );
00523
00524 if ( m_bmWatermark.m_hObject != NULL )
00525 {
00526 pDC = CoolInterface.GetBuffer( dc, rc.Size() );
00527 CoolInterface.DrawWatermark( pDC, &rc, &m_bmWatermark );
00528 pDC->SetBkMode( TRANSPARENT );
00529 }
00530 else
00531 {
00532 pDC->SetBkMode( OPAQUE );
00533 pDC->SetBkColor( CoolInterface.m_crTaskBoxClient );
00534 nFlags |= ETO_OPAQUE;
00535 }
00536
00537 CFont* pOldFont = (CFont*)pDC->SelectObject( &CoolInterface.m_fntNormal );
00538
00539 pDC->SetTextColor( 0 );
00540
00541 LoadString( str, IDS_SEARCH_PANEL_INPUT_1 );
00542 rct.SetRect( BOX_MARGIN + 1, BOX_MARGIN, rc.right - BOX_MARGIN, BOX_MARGIN + 16 );
00543 pDC->ExtTextOut( rct.left, rct.top, nFlags, &rct, str, NULL );
00544 pDC->ExcludeClipRect( &rct );
00545
00546 LoadString( str, IDS_SEARCH_PANEL_INPUT_2 );
00547 rct.OffsetRect( 0, 50 - rct.top );
00548 pDC->ExtTextOut( rct.left, rct.top, nFlags, &rct, str, NULL );
00549 pDC->ExcludeClipRect( &rct );
00550
00551 pDC->SelectObject( pOldFont );
00552
00553 if ( pDC != &dc )
00554 {
00555 dc.BitBlt( 0, 0, rc.Width(), rc.Height(), pDC, 0, 0, SRCCOPY );
00556 pDC->SelectClipRgn( NULL );
00557 }
00558 else
00559 {
00560 pDC->FillSolidRect( &rc, CoolInterface.m_crTaskBoxClient );
00561 }
00562 }
00563
00564 void CSearchInputBox::OnSelChangeSchemas()
00565 {
00566 CSearchPanel* pPanel = (CSearchPanel*)GetPanel();
00567 pPanel->OnSchemaChange();
00568 }
00569
00570 void CSearchInputBox::OnCloseUpSchemas()
00571 {
00572 }
00573
00574 void CSearchInputBox::OnSearchStart()
00575 {
00576 CSearchPanel* pPanel = (CSearchPanel*)GetPanel();
00577 pPanel->ExecuteSearch();
00578 }
00579
00580 void CSearchInputBox::OnSearchStop()
00581 {
00582 CString strCaption, strTest;
00583
00584 LoadString( strTest, IDS_SEARCH_PANEL_CLEAR );
00585 m_wndStop.GetWindowText( strCaption );
00586
00587 CWnd* pTarget = GetPanel()->GetParent();
00588
00589 if ( strCaption == strTest )
00590 pTarget->PostMessage( WM_COMMAND, ID_SEARCH_CLEAR );
00591 else
00592 pTarget->PostMessage( WM_COMMAND, ID_SEARCH_STOP );
00593 }
00594
00595
00597
00598
00599 CSearchAdvancedBox::CSearchAdvancedBox()
00600 {
00601 }
00602
00603 CSearchAdvancedBox::~CSearchAdvancedBox()
00604 {
00605 }
00606
00608
00609
00610 int CSearchAdvancedBox::OnCreate(LPCREATESTRUCT lpCreateStruct)
00611 {
00612 if ( CTaskBox::OnCreate( lpCreateStruct ) == -1 ) return -1;
00613
00614 CRect rc( 0, 0, 0, 0 );
00615 CString strCaption;
00616
00617
00618 if ( ! m_wndNetworks.Create( WS_TABSTOP, this, IDC_SEARCH_NETWORKS ) ) return -1;
00619
00620
00621 if ( ! m_wndSizeMin.Create( WS_CHILD|WS_VISIBLE|WS_TABSTOP|CBS_AUTOHSCROLL|CBS_DROPDOWN, rc, this, IDC_SEARCH_SIZEMIN ) ) return -1;
00622 m_wndSizeMin.SetFont( &theApp.m_gdiFont );
00623
00624 m_wndSizeMin.AddString( _T("") );
00625 m_wndSizeMin.AddString( _T("500 KB") );
00626 m_wndSizeMin.AddString( _T("1 MB") );
00627 m_wndSizeMin.AddString( _T("10 MB") );
00628 m_wndSizeMin.AddString( _T("50 MB") );
00629 m_wndSizeMin.AddString( _T("100 MB") );
00630 m_wndSizeMin.AddString( _T("200 MB") );
00631 m_wndSizeMin.AddString( _T("500 MB") );
00632 m_wndSizeMin.AddString( _T("1 GB") );
00633 m_wndSizeMin.AddString( _T("4 GB") );
00634
00635
00636 if ( ! m_wndSizeMax.Create( WS_CHILD|WS_VISIBLE|WS_TABSTOP|CBS_AUTOHSCROLL|CBS_DROPDOWN, rc, this, IDC_SEARCH_SIZEMIN ) ) return -1;
00637 m_wndSizeMax.SetFont( &theApp.m_gdiFont );
00638
00639 m_wndSizeMax.AddString( _T("") );
00640 m_wndSizeMax.AddString( _T("500 KB") );
00641 m_wndSizeMax.AddString( _T("1 MB") );
00642 m_wndSizeMax.AddString( _T("10 MB") );
00643 m_wndSizeMax.AddString( _T("50 MB") );
00644 m_wndSizeMax.AddString( _T("100 MB") );
00645 m_wndSizeMax.AddString( _T("200 MB") );
00646 m_wndSizeMax.AddString( _T("500 MB") );
00647 m_wndSizeMax.AddString( _T("1 GB") );
00648 m_wndSizeMax.AddString( _T("4 GB") );
00649
00650
00651
00652
00653
00654
00655 return 0;
00656 }
00657
00658 void CSearchAdvancedBox::OnSkinChange()
00659 {
00660 if ( m_wndNetworks.m_hWnd != NULL ) m_wndNetworks.OnSkinChange();
00661 }
00662
00663 void CSearchAdvancedBox::OnSize(UINT nType, int cx, int cy)
00664 {
00665 CTaskBox::OnSize( nType, cx, cy );
00666
00667 HDWP hDWP = BeginDeferWindowPos( 3 );
00668
00669 if ( m_wndNetworks.m_hWnd != NULL )
00670 DeferWindowPos( hDWP, m_wndNetworks, NULL, BOX_MARGIN, 27, cx - BOX_MARGIN * 2, 256, SWP_SHOWWINDOW|SWP_NOZORDER );
00671
00672 if ( m_wndSizeMin.m_hWnd != NULL )
00673 {
00674 DeferWindowPos( hDWP, m_wndSizeMin, NULL, BOX_MARGIN, 71, ( cx - BOX_MARGIN * 4 ) /2, 219, SWP_SHOWWINDOW|SWP_NOZORDER );
00675 DeferWindowPos( hDWP, m_wndSizeMax, NULL, ( cx / 2 ) + BOX_MARGIN, 71, ( cx - BOX_MARGIN * 4 ) /2, 219, SWP_SHOWWINDOW|SWP_NOZORDER );
00676 }
00677
00678 EndDeferWindowPos( hDWP );
00679 }
00680
00681 void CSearchAdvancedBox::OnPaint()
00682 {
00683 CPaintDC dc( this );
00684 CRect rc, rct;
00685 CString strControlTitle;
00686
00687 UINT nFlags = ETO_CLIPPED;
00688 CDC* pDC = &dc;
00689
00690 GetClientRect( &rc );
00691
00692 if ( m_bmWatermark.m_hObject != NULL )
00693 {
00694 pDC = CoolInterface.GetBuffer( dc, rc.Size() );
00695 CoolInterface.DrawWatermark( pDC, &rc, &m_bmWatermark );
00696 pDC->SetBkMode( TRANSPARENT );
00697 }
00698 else
00699 {
00700 pDC->SetBkMode( OPAQUE );
00701 pDC->SetBkColor( CoolInterface.m_crTaskBoxClient );
00702 nFlags |= ETO_OPAQUE;
00703 }
00704
00705 CFont* pOldFont = (CFont*)pDC->SelectObject( &CoolInterface.m_fntNormal );
00706
00707 pDC->SetTextColor( 0 );
00708
00709 LoadString( strControlTitle, IDS_SEARCH_PANEL_INPUT_3 );
00710 rct.SetRect( BOX_MARGIN + 1, BOX_MARGIN, rc.right - BOX_MARGIN, BOX_MARGIN + 16 );
00711 pDC->ExtTextOut( rct.left, rct.top, nFlags, &rct, strControlTitle, NULL );
00712 pDC->ExcludeClipRect( &rct );
00713
00714 LoadString( strControlTitle, IDS_SEARCH_PANEL_INPUT_4 );
00715 rct.OffsetRect( 0, 54 - rct.top );
00716 pDC->ExtTextOut( rct.left, rct.top, nFlags, &rct, strControlTitle, NULL );
00717 pDC->ExcludeClipRect( &rct );
00718
00719 LoadString( strControlTitle, IDS_SEARCH_PANEL_INPUT_5 );
00720 rct.OffsetRect( ( rc.Width() / 2 ) - ( BOX_MARGIN * 2 ) , 25 );
00721 pDC->ExtTextOut( rct.left, rct.top, nFlags, &rct, strControlTitle, NULL );
00722 pDC->ExcludeClipRect( &rct );
00723
00724 pDC->SelectObject( pOldFont );
00725
00726 if ( pDC != &dc )
00727 {
00728 dc.BitBlt( 0, 0, rc.Width(), rc.Height(), pDC, 0, 0, SRCCOPY );
00729 pDC->SelectClipRgn( NULL );
00730 }
00731 else
00732 {
00733 pDC->FillSolidRect( &rc, CoolInterface.m_crTaskBoxClient );
00734 }
00735 }
00736
00738
00739
00740 CSearchSchemaBox::CSearchSchemaBox()
00741 {
00742 }
00743
00744 CSearchSchemaBox::~CSearchSchemaBox()
00745 {
00746 }
00747
00749
00750
00751 int CSearchSchemaBox::OnCreate(LPCREATESTRUCT lpCreateStruct)
00752 {
00753 if ( CTaskBox::OnCreate( lpCreateStruct ) == -1 ) return -1;
00754
00755 CRect rc;
00756 if ( ! m_wndSchema.Create( WS_VISIBLE, rc, this, IDC_SCHEMAS ) ) return -1;
00757
00758 m_wndSchema.m_nCaptionWidth = 0;
00759 m_wndSchema.m_nItemHeight = 42;
00760 m_wndSchema.m_bShowBorder = FALSE;
00761
00762 return 0;
00763 }
00764
00765 void CSearchSchemaBox::OnSize(UINT nType, int cx, int cy)
00766 {
00767 CTaskBox::OnSize( nType, cx, cy );
00768 m_wndSchema.SetWindowPos( NULL, 0, 1, cx, cy - 1, SWP_NOZORDER );
00769 }
00770
00771 BOOL CSearchSchemaBox::PreTranslateMessage(MSG* pMsg)
00772 {
00773 if ( pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_TAB )
00774 {
00775 if ( m_wndSchema.OnTab() ) return TRUE;
00776 }
00777
00778 return CTaskBox::PreTranslateMessage( pMsg );
00779 }
00780
00782
00783
00784 CSearchResultsBox::CSearchResultsBox()
00785 {
00786 Expand( theApp.GetProfileInt( _T("Settings"), _T("SearchPanelResults"), TRUE ) );
00787
00788 m_bActive = FALSE;
00789 m_nFiles = 0;
00790 m_nHits = 0;
00791 m_nHubs = 0;
00792 m_nLeaves = 0;
00793 }
00794
00795 CSearchResultsBox::~CSearchResultsBox()
00796 {
00797 }
00798
00800
00801
00802 void CSearchResultsBox::Update(BOOL bSearching, DWORD nFiles, DWORD nHits, DWORD nHubs, DWORD nLeaves)
00803 {
00804 m_bActive = bSearching;
00805 m_nFiles = nFiles;
00806 m_nHits = nHits;
00807 m_nHubs = nHubs;
00808 m_nLeaves = nLeaves;
00809
00810 Invalidate();
00811 }
00812
00813 void CSearchResultsBox::OnPaint()
00814 {
00815 CString strFormat, strText;
00816 CPaintDC dc( this );
00817 CRect rc;
00818
00819 UINT nFlags = ETO_CLIPPED;
00820 CDC* pDC = &dc;
00821
00822 GetClientRect( &rc );
00823
00824 if ( m_bmWatermark.m_hObject )
00825 {
00826 pDC = CoolInterface.GetBuffer( dc, rc.Size() );
00827 CoolInterface.DrawWatermark( pDC, &rc, &m_bmWatermark );
00828 pDC->SetBkMode( TRANSPARENT );
00829 }
00830 else
00831 {
00832 pDC->SetBkMode( OPAQUE );
00833 pDC->SetBkColor( CoolInterface.m_crTaskBoxClient );
00834 nFlags |= ETO_OPAQUE;
00835 }
00836
00837 CFont* pOldFont = (CFont*)pDC->SelectObject( &theApp.m_gdiFontBold );
00838
00839 pDC->SetTextColor( 0 );
00840
00841 LoadString( strText, IDS_SEARCH_PANEL_RESULTS_STATUS );
00842 DrawText( pDC, BOX_MARGIN, BOX_MARGIN, nFlags, strText );
00843 LoadString( strText, IDS_SEARCH_PANEL_RESULTS_FOUND );
00844 DrawText( pDC, BOX_MARGIN, BOX_MARGIN + 32, nFlags, strText );
00845
00846 pDC->SelectObject( &theApp.m_gdiFont );
00847
00848 if ( m_bActive )
00849 {
00850 LoadString( strFormat, IDS_SEARCH_PANEL_RESULTS_ACTIVE );
00851 strText.Format( strFormat, m_nHubs, m_nLeaves );
00852 }
00853 else
00854 {
00855 LoadString( strText, IDS_SEARCH_PANEL_RESULTS_INACTIVE );
00856 }
00857
00858 DrawText( pDC, BOX_MARGIN + 8, BOX_MARGIN + 14, nFlags, strText );
00859
00860 if ( m_nFiles )
00861 {
00862 LoadString( strFormat, IDS_SEARCH_PANEL_RESULTS_FORMAT );
00863
00864 if ( strFormat.Find( '|' ) >= 0 )
00865 {
00866 if ( m_nFiles == 1 && m_nHits == 1 )
00867 Skin.SelectCaption( strFormat, 0 );
00868 else if ( m_nFiles == 1 )
00869 Skin.SelectCaption( strFormat, 1 );
00870 else
00871 Skin.SelectCaption( strFormat, 2 );
00872
00873 strText.Format( strFormat,
00874 m_nFiles, m_nHits );
00875 }
00876 else
00877 {
00878 strText.Format( strFormat,
00879 m_nFiles, m_nFiles != 1 ? _T("s") : _T(""),
00880 m_nHits, m_nHits != 1 ? _T("s") : _T("") );
00881 }
00882 }
00883 else
00884 {
00885 LoadString( strText, IDS_SEARCH_PANEL_RESULTS_NONE );
00886 }
00887
00888 DrawText( pDC, BOX_MARGIN + 8, BOX_MARGIN + 32 + 14, nFlags, strText );
00889
00890 pDC->SelectObject( pOldFont );
00891
00892 if ( pDC != &dc )
00893 {
00894 dc.BitBlt( 0, 0, rc.Width(), rc.Height(), pDC, 0, 0, SRCCOPY );
00895 pDC->SelectClipRgn( NULL );
00896 }
00897 else
00898 {
00899 pDC->FillSolidRect( &rc, CoolInterface.m_crTaskBoxClient );
00900 }
00901 }
00902
00903 void CSearchResultsBox::DrawText(CDC* pDC, int nX, int nY, UINT nFlags, LPCTSTR pszText)
00904 {
00905 CSize cz = pDC->GetTextExtent( pszText, _tcslen( pszText ) );
00906 CRect rc( nX, nY, nX + cz.cx, nY + cz.cy );
00907
00908 pDC->ExtTextOut( nX, nY, nFlags, &rc, pszText, _tcslen( pszText ), NULL );
00909 pDC->ExcludeClipRect( nX, nY, nX + cz.cx, nY + cz.cy );
00910 }
00911
00912 void CSearchResultsBox::OnExpanded(BOOL bOpen)
00913 {
00914 theApp.WriteProfileInt( _T("Settings"), _T("SearchPanelResults"), bOpen );
00915 }