Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

WndMonitor.cpp

Go to the documentation of this file.
00001 //
00002 // WndMonitor.cpp
00003 //
00004 // Copyright (c) Shareaza Development Team, 2002-2005.
00005 // This file is part of SHAREAZA (www.shareaza.com)
00006 //
00007 // Shareaza is free software; you can redistribute it
00008 // and/or modify it under the terms of the GNU General Public License
00009 // as published by the Free Software Foundation; either version 2 of
00010 // the License, or (at your option) any later version.
00011 //
00012 // Shareaza is distributed in the hope that it will be useful,
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 // GNU General Public License for more details.
00016 //
00017 // You should have received a copy of the GNU General Public License
00018 // along with Shareaza; if not, write to the Free Software
00019 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020 //
00021 
00022 #include "StdAfx.h"
00023 #include "Shareaza.h"
00024 #include "Settings.h"
00025 #include "GraphItem.h"
00026 #include "CoolInterface.h"
00027 #include "SkinWindow.h"
00028 #include "Skin.h"
00029 
00030 #include "WndMonitor.h"
00031 #include "CtrlMonitorBar.h"
00032 #include "CtrlMediaFrame.h"
00033 
00034 IMPLEMENT_DYNAMIC(CRemoteWnd, CWnd)
00035 
00036 BEGIN_MESSAGE_MAP(CRemoteWnd, CWnd)
00037         ON_WM_CREATE()
00038         ON_WM_DESTROY()
00039         ON_WM_WINDOWPOSCHANGING()
00040         ON_MESSAGE(WM_IDLEUPDATECMDUI, OnIdleUpdateCmdUI)
00041         ON_WM_TIMER()
00042         ON_WM_SIZE()
00043         ON_WM_PAINT()
00044         ON_WM_NCPAINT()
00045         ON_WM_NCACTIVATE()
00046         ON_WM_NCCALCSIZE()
00047         ON_WM_NCHITTEST()
00048         ON_WM_SETCURSOR()
00049         ON_WM_MOUSEMOVE()
00050         ON_WM_LBUTTONDOWN()
00051         ON_WM_LBUTTONUP()
00052         ON_WM_NCLBUTTONDBLCLK()
00053         ON_WM_RBUTTONDOWN()
00054 END_MESSAGE_MAP()
00055 
00056 LPCTSTR CRemoteWnd::m_hClass = NULL;
00057 
00058 #define SNAP_PIXELS 6
00059 
00060 
00062 // CRemoteWnd construction
00063 
00064 CRemoteWnd::CRemoteWnd()
00065 {
00066         if ( m_hClass == NULL ) 
00067                 m_hClass = AfxRegisterWndClass( 0 );
00068 
00069         m_pMonitor              = NULL;
00070         m_pSkin                 = NULL;
00071         m_pCmdHover             = NULL;
00072         m_pCmdDown              = NULL;
00073         m_nTimer                = 0;
00074 
00075         m_bScaler               = FALSE;
00076         m_bMediaSeek    = FALSE;
00077         m_nMediaSeek    = -1;
00078         m_bMediaVol             = FALSE;
00079         m_nMediaVol             = -1;
00080 }
00081 
00082 CRemoteWnd::~CRemoteWnd()
00083 {
00084         for ( POSITION pos = m_pButtons.GetHeadPosition() ; pos ; ) delete m_pButtons.GetNext( pos );
00085 }
00086 
00088 // CRemoteWnd system message handlers
00089 
00090 BOOL CRemoteWnd::Create(CMonitorBarCtrl* pMonitor)
00091 {
00092         ASSERT( m_hWnd == NULL );
00093 
00094         m_pMonitor      = pMonitor;
00095         m_pSkin         = NULL;
00096 
00097         return CreateEx(        WS_EX_TOOLWINDOW, m_hClass, _T("Shareaza Remote"),
00098                                                 WS_OVERLAPPED|WS_CLIPCHILDREN, 0, 0, 0, 0, NULL, 0 );
00099 }
00100 
00101 BOOL CRemoteWnd::IsVisible()
00102 {
00103         return ( m_hWnd != NULL );
00104 }
00105 
00106 int CRemoteWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
00107 {
00108         if ( CWnd::OnCreate( lpCreateStruct ) == -1 ) return -1;
00109         if ( lpCreateStruct->dwExStyle & WS_EX_LAYOUTRTL )
00110         {
00111                 lpCreateStruct->dwExStyle ^= WS_EX_LAYOUTRTL;
00112                 SetWindowLong( this->m_hWnd, GWL_EXSTYLE, lpCreateStruct->dwExStyle );
00113         }
00114 
00115         OnSkinChange();
00116         EnableToolTips();
00117 
00118         int nWindowX = AfxGetApp()->GetProfileInt( _T("Windows"), _T("CRemoteWnd.Left"), 0 );
00119         int nWindowY = AfxGetApp()->GetProfileInt( _T("Windows"), _T("CRemoteWnd.Top"), 0 );
00120 
00121         SetWindowPos( &wndTopMost, nWindowX, nWindowY, 0, 0, SWP_NOSIZE|SWP_SHOWWINDOW );
00122 
00123         SetTimer( 1, 50, NULL );
00124 
00125         return 0;
00126 }
00127 
00128 void CRemoteWnd::OnDestroy()
00129 {
00130         KillTimer( 1 );
00131         Settings.SaveWindow( NULL, this );
00132 
00133         CWnd::OnDestroy();
00134 }
00135 
00137 // CRemoteWnd window movement message handlers
00138 
00139 void CRemoteWnd::OnWindowPosChanging(WINDOWPOS FAR* lpwndpos)
00140 {
00141         CWnd::OnWindowPosChanging( lpwndpos );
00142 
00143         CRect rcWork;
00144         SystemParametersInfo( SPI_GETWORKAREA, 0, &rcWork, 0 );
00145 
00146         if ( abs( lpwndpos->x ) <= ( rcWork.left + SNAP_PIXELS ) )
00147         {
00148                 lpwndpos->x = rcWork.left;
00149         }
00150         else if (       ( lpwndpos->x + lpwndpos->cx ) >= ( rcWork.right - SNAP_PIXELS ) &&
00151                                 ( lpwndpos->x + lpwndpos->cx ) <= ( rcWork.right + SNAP_PIXELS ) )
00152         {
00153                 lpwndpos->x = rcWork.right - lpwndpos->cx;
00154         }
00155 
00156         if ( abs( lpwndpos->y ) <= ( rcWork.top + SNAP_PIXELS ) )
00157         {
00158                 lpwndpos->y = rcWork.top;
00159         }
00160         else if (       ( lpwndpos->y + lpwndpos->cy ) >= ( rcWork.bottom - SNAP_PIXELS) &&
00161                                 ( lpwndpos->y + lpwndpos->cy ) <= ( rcWork.bottom + SNAP_PIXELS ) )
00162         {
00163                 lpwndpos->y = rcWork.bottom - lpwndpos->cy;
00164         }
00165 }
00166 
00168 // CRemoteWnd command UI
00169 
00170 LONG CRemoteWnd::OnIdleUpdateCmdUI(WPARAM wParam, LPARAM lParam)
00171 {
00172         UpdateCmdButtons();
00173         return 0;
00174 }
00175 
00176 void CRemoteWnd::OnTimer(UINT nIDEvent)
00177 {
00178         if ( m_nTimer++ >= 10 )
00179         {
00180                 m_nTimer = 0;
00181                 UpdateCmdButtons();
00182 
00183                 if ( m_pCmdHover != NULL )
00184                 {
00185                         CPoint point;
00186                         GetCursorPos( &point );
00187                         ScreenToClient( &point );
00188                         if ( HitTestButtons( point ) != m_pCmdHover ) m_pCmdHover = NULL;
00189                 }
00190 
00191                 CString strFormat;
00192                 LoadString( strFormat, IDS_TRAY_TIP );
00193                 m_sStatus.Format( strFormat,
00194                         (int)CGraphItem::GetValue( GRC_GNUTELLA_CONNECTIONS, 0 ),
00195                         (LPCTSTR)Settings.SmartVolume( CGraphItem::GetValue( GRC_TOTAL_BANDWIDTH_IN ), FALSE, TRUE ),
00196                         (LPCTSTR)Settings.SmartVolume( CGraphItem::GetValue( GRC_TOTAL_BANDWIDTH_OUT ), FALSE, TRUE ),
00197                         (int)CGraphItem::GetValue( GRC_DOWNLOADS_TRANSFERS ),
00198                         (int)CGraphItem::GetValue( GRC_UPLOADS_TRANSFERS ) );
00199         }
00200 
00201         Invalidate();
00202 }
00203 
00205 // CRemoteWnd command buttons
00206 
00207 CRemoteWnd::CmdButton* CRemoteWnd::HitTestButtons(const CPoint& ptIn, BOOL bAll) const
00208 {
00209         if ( m_pSkin == NULL ) return NULL;
00210 
00211         for ( POSITION pos = m_pButtons.GetHeadPosition() ; pos ; )
00212         {
00213                 CmdButton* pButton = m_pButtons.GetNext( pos );
00214                 if ( pButton->HitTest( ptIn, bAll ) ) return pButton;
00215         }
00216 
00217         return NULL;
00218 }
00219 
00220 void CRemoteWnd::UpdateCmdButtons()
00221 {
00222         BOOL bChanged = FALSE;
00223 
00224         for ( POSITION pos = m_pButtons.GetHeadPosition() ; pos ; )
00225         {
00226                 CmdButton* pButton = m_pButtons.GetNext( pos );
00227                 pButton->m_bChanged = FALSE;
00228                 pButton->DoUpdate( (CCmdTarget*)AfxGetMainWnd(), TRUE );
00229                 bChanged |= pButton->m_bChanged;
00230         }
00231 
00232         if ( bChanged ) Invalidate();
00233 }
00234 
00236 // CRemoteWnd skin change handler
00237 
00238 void CRemoteWnd::OnSkinChange()
00239 {
00240         for ( POSITION pos = m_pButtons.GetHeadPosition() ; pos ; ) delete m_pButtons.GetNext( pos );
00241         m_pCmdHover = m_pCmdDown = NULL;
00242         m_pButtons.RemoveAll();
00243 
00244         m_pSkin = NULL;
00245 
00246         if ( m_hWnd == NULL ) return;
00247 
00248         m_pSkin = Skin.GetWindowSkin( _T("CRemoteWnd") );
00249 
00250         if ( m_pSkin == NULL )
00251         {
00252                 ShowWindow( SW_HIDE );
00253                 return;
00254         }
00255 
00256         if ( ! m_pSkin->GetPart( _T("Background"), m_rcBackground ) )
00257         {
00258                 m_pSkin = NULL;
00259                 ShowWindow( SW_HIDE );
00260                 return;
00261         }
00262 
00263         for ( POSITION pos = m_pSkin->m_pAnchorList.GetStartPosition() ; pos ; )
00264         {
00265                 CRect* prcAnchor;
00266                 CString strAnchor;
00267                 m_pSkin->m_pAnchorList.GetNextAssoc( pos, strAnchor, (void*&)prcAnchor );
00268 
00269                 if ( strAnchor.Find( '_' ) == 0 )
00270                 {
00271                         m_pButtons.AddTail( new CmdButton( strAnchor ) );
00272                 }
00273         }
00274 
00275         m_bsStatusText          = m_pSkin->GetAnchor( _T("StatusText"), m_rcsStatusText );
00276 
00277         m_bsHistoryDest         = m_pSkin->GetAnchor( _T("History"), m_rcsHistoryDest );
00278         m_bsHistoryTx[0]        = m_pSkin->GetPart( _T("HistoryTx1"), m_rcsHistoryTx[0] );
00279         m_bsHistoryTx[1]        = m_pSkin->GetPart( _T("HistoryTx2"), m_rcsHistoryTx[1] );
00280         m_bsHistoryRx[0]        = m_pSkin->GetPart( _T("HistoryRx1"), m_rcsHistoryRx[0] );
00281         m_bsHistoryRx[1]        = m_pSkin->GetPart( _T("HistoryRx2"), m_rcsHistoryRx[1] );
00282         m_bsFlowTxDest          = m_pSkin->GetAnchor( _T("FlowTx"), m_rcsFlowTxDest );
00283         m_bsFlowTxSrc[0]        = m_pSkin->GetPart( _T("FlowTx1"), m_rcsFlowTxSrc[0] );
00284         m_bsFlowTxSrc[1]        = m_pSkin->GetPart( _T("FlowTx2"), m_rcsFlowTxSrc[1] );
00285         m_bsFlowRxDest          = m_pSkin->GetAnchor( _T("FlowRx"), m_rcsFlowRxDest );
00286         m_bsFlowRxSrc[0]        = m_pSkin->GetPart( _T("FlowRx1"), m_rcsFlowRxSrc[0] );
00287         m_bsFlowRxSrc[1]        = m_pSkin->GetPart( _T("FlowRx2"), m_rcsFlowRxSrc[1] );
00288         m_bsScalerTrack         = m_pSkin->GetAnchor( _T("ScalerTrack"), m_rcsScalerTrack );
00289         m_bsScalerTab           = m_pSkin->GetPart( _T("ScalerTab"), m_rcsScalerTab );
00290         m_bsScalerBar           = m_pSkin->GetPart( _T("ScalerBar"), m_rcsScalerBar );
00291 
00292         m_bsMediaSeekTrack      = m_pSkin->GetAnchor( _T("MediaSeekTrack"), m_rcsMediaSeekTrack );
00293         m_bsMediaSeekTab        = m_pSkin->GetPart( _T("MediaSeekTab"), m_rcsMediaSeekTab );
00294         m_bsMediaSeekBar        = m_pSkin->GetPart( _T("MediaSeekBar"), m_rcsMediaSeekBar );
00295         m_bsMediaVolTrack       = m_pSkin->GetAnchor( _T("MediaVolTrack"), m_rcsMediaVolTrack );
00296         m_bsMediaVolTab         = m_pSkin->GetPart( _T("MediaVolTab"), m_rcsMediaVolTab );
00297         m_bsMediaVolBar         = m_pSkin->GetPart( _T("MediaVolBar"), m_rcsMediaVolBar );
00298 
00299         m_bsMediaStates[0][0]   = m_pSkin->GetAnchor( _T("MediaStateStopped"), m_rcsMediaStates[0][0] );
00300         m_bsMediaStates[0][1]   = m_pSkin->GetAnchor( _T("MediaStatePlaying"), m_rcsMediaStates[0][1] );
00301         m_bsMediaStates[0][2]   = m_pSkin->GetAnchor( _T("MediaStatePaused"), m_rcsMediaStates[0][2] );
00302         m_bsMediaStates[1][0]   = m_pSkin->GetPart( _T("MediaStateStopped"), m_rcsMediaStates[1][0] );
00303         m_bsMediaStates[1][1]   = m_pSkin->GetPart( _T("MediaStatePlaying"), m_rcsMediaStates[1][1] );
00304         m_bsMediaStates[1][2]   = m_pSkin->GetPart( _T("MediaStatePaused"), m_rcsMediaStates[1][2] );
00305 
00306         SetWindowPos( NULL, 0, 0, m_rcBackground.Width(), m_rcBackground.Height(), SWP_NOMOVE );
00307         m_pSkin->OnSize( this );
00308         Invalidate();
00309 }
00310 
00312 // CRemoteWnd display message handlers
00313 
00314 void CRemoteWnd::OnSize(UINT nType, int cx, int cy)
00315 {
00316         CWnd::OnSize( nType, cx, cy );
00317         if ( m_pSkin != NULL ) m_pSkin->OnSize( this );
00318         Invalidate();
00319 }
00320 
00321 void CRemoteWnd::OnPaint()
00322 {
00323         CPaintDC dc( this );
00324         CRect rcClient;
00325 
00326         GetClientRect( &rcClient );
00327 
00328         if ( m_pSkin == NULL )
00329         {
00330                 dc.FillSolidRect( &rcClient, GetSysColor( COLOR_BTNFACE ) );
00331                 return;
00332         }
00333 
00334         CDC* pDC = CoolInterface.GetBuffer( dc, rcClient.Size() );
00335         m_pSkin->Prepare( &dc );
00336 
00337         pDC->BitBlt( 0, 0, m_rcBackground.Width(), m_rcBackground.Height(),
00338                 &m_pSkin->m_dcSkin, m_rcBackground.left, m_rcBackground.top, SRCCOPY );
00339 
00340         CFont* pfOld = NULL;
00341 
00342         if ( m_pSkin->m_fnCaption.m_hObject != NULL )
00343         {
00344                 pfOld = (CFont*)pDC->SelectObject( &m_pSkin->m_fnCaption );
00345                 pDC->SetTextColor( m_pSkin->m_crCaptionText );
00346         }
00347         else
00348         {
00349                 pfOld = (CFont*)pDC->SelectObject( &CoolInterface.m_fntNormal );
00350                 pDC->SetTextColor( RGB( 255, 255, 255 ) );
00351         }
00352 
00353         pDC->SetBkMode( TRANSPARENT );
00354         m_bStatus = FALSE;
00355 
00356         PaintHistory( pDC, m_pMonitor->m_pTxItem, m_pMonitor->m_pRxItem, m_pMonitor->m_nMaximum );
00357         PaintFlow( pDC, &m_bsFlowTxDest, &m_rcsFlowTxDest, m_bsFlowTxSrc, m_rcsFlowTxSrc, m_pMonitor->m_pTxItem, m_pMonitor->m_nMaximum );
00358         PaintFlow( pDC, &m_bsFlowRxDest, &m_rcsFlowRxDest, m_bsFlowRxSrc, m_rcsFlowRxSrc, m_pMonitor->m_pRxItem, m_pMonitor->m_nMaximum );
00359         PaintScaler( pDC );
00360         PaintMedia( pDC );
00361         PaintStatus( pDC );
00362 
00363         for ( POSITION pos = m_pButtons.GetHeadPosition() ; pos ; )
00364         {
00365                 m_pButtons.GetNext( pos )->Paint( pDC, rcClient, m_pSkin, m_pCmdHover, m_pCmdDown );
00366         }
00367 
00368         pDC->SelectObject( pfOld );
00369         pDC->SelectClipRgn( NULL );
00370         dc.BitBlt( 0, 0, rcClient.Width(), rcClient.Height(), pDC, 0, 0, SRCCOPY );
00371 }
00372 
00373 void CRemoteWnd::OnNcPaint()
00374 {
00375 }
00376 
00377 BOOL CRemoteWnd::OnNcActivate(BOOL bActive)
00378 {
00379         return TRUE;
00380 }
00381 
00383 // CRemoteWnd paint monitor functionality
00384 
00385 void CRemoteWnd::PaintHistory(CDC* pDC, CGraphItem* pTxItem, CGraphItem* pRxItem, DWORD nMaximum)
00386 {
00387         if ( nMaximum == 0 ) return;
00388         if ( m_bsHistoryDest == FALSE ) return;
00389 
00390         pTxItem->SetHistory( m_rcsHistoryDest.Width(), TRUE );
00391         pRxItem->SetHistory( m_rcsHistoryDest.Width(), TRUE );
00392 
00393         DWORD nMax = min( pTxItem->m_nLength, (DWORD)m_rcsHistoryDest.Width() );
00394         int nX = m_rcsHistoryDest.right - 1;
00395 
00396         for ( DWORD nPos = 0 ; nPos < nMax ; nPos++, nX-- )
00397         {
00398                 DWORD nTxValue = pTxItem->GetValueAt( nPos );
00399                 DWORD nRxValue = pRxItem->GetValueAt( nPos );
00400                 nTxValue = m_rcsHistoryDest.bottom - nTxValue * m_rcsHistoryDest.Height() / nMaximum;
00401                 nRxValue = m_rcsHistoryDest.bottom - nRxValue * m_rcsHistoryDest.Height() / nMaximum;
00402 
00403                 if ( nTxValue < nRxValue )
00404                 {
00405                         if ( nTxValue < (DWORD)m_rcsHistoryDest.bottom && m_bsHistoryTx[0] )
00406                         {
00407                                 pDC->BitBlt( nX, nTxValue, 1, m_rcsHistoryDest.bottom - nTxValue,
00408                                         &m_pSkin->m_dcSkin, m_rcsHistoryTx[0].left + ( nX - m_rcsHistoryDest.left ),
00409                                         m_rcsHistoryTx[0].top + nTxValue - m_rcsHistoryDest.top, SRCCOPY );
00410                         }
00411                         else if ( nTxValue < (DWORD)m_rcsHistoryDest.bottom && m_bsHistoryTx[1] )
00412                         {
00413                                 pDC->BitBlt( nX, nTxValue, 1, m_rcsHistoryDest.bottom - nTxValue,
00414                                         &m_pSkin->m_dcSkin, m_rcsHistoryTx[1].left + ( nX - m_rcsHistoryDest.left ),
00415                                         m_rcsHistoryTx[1].top, SRCCOPY );
00416                         }
00417                         if ( nRxValue < (DWORD)m_rcsHistoryDest.bottom && m_bsHistoryRx[0] )
00418                         {
00419                                 pDC->BitBlt( nX, nRxValue, 1, m_rcsHistoryDest.bottom - nRxValue,
00420                                         &m_pSkin->m_dcSkin, m_rcsHistoryRx[0].left + ( nX - m_rcsHistoryDest.left ),
00421                                         m_rcsHistoryRx[0].top + nRxValue - m_rcsHistoryDest.top, SRCCOPY );
00422                         }
00423                         else if ( nRxValue < (DWORD)m_rcsHistoryDest.bottom && m_bsHistoryRx[1] )
00424                         {
00425                                 pDC->BitBlt( nX, nRxValue, 1, m_rcsHistoryDest.bottom - nRxValue,
00426                                         &m_pSkin->m_dcSkin, m_rcsHistoryRx[1].left + ( nX - m_rcsHistoryDest.left ),
00427                                         m_rcsHistoryRx[1].top, SRCCOPY );
00428                         }
00429                 }
00430                 else
00431                 {
00432                         if ( nRxValue < (DWORD)m_rcsHistoryDest.bottom && m_bsHistoryRx[0] )
00433                         {
00434                                 pDC->BitBlt( nX, nRxValue, 1, m_rcsHistoryDest.bottom - nRxValue,
00435                                         &m_pSkin->m_dcSkin, m_rcsHistoryRx[0].left + ( nX - m_rcsHistoryDest.left ),
00436                                         m_rcsHistoryRx[0].top + nRxValue - m_rcsHistoryDest.top, SRCCOPY );
00437                         }
00438                         else if ( nRxValue < (DWORD)m_rcsHistoryDest.bottom && m_bsHistoryRx[1] )
00439                         {
00440                                 pDC->BitBlt( nX, nRxValue, 1, m_rcsHistoryDest.bottom - nRxValue,
00441                                         &m_pSkin->m_dcSkin, m_rcsHistoryRx[1].left + ( nX - m_rcsHistoryDest.left ),
00442                                         m_rcsHistoryRx[1].top, SRCCOPY );
00443                         }
00444                         if ( nTxValue < (DWORD)m_rcsHistoryDest.bottom && m_bsHistoryTx[0] )
00445                         {
00446                                 pDC->BitBlt( nX, nTxValue, 1, m_rcsHistoryDest.bottom - nTxValue,
00447                                         &m_pSkin->m_dcSkin, m_rcsHistoryTx[0].left + ( nX - m_rcsHistoryDest.left ),
00448                                         m_rcsHistoryTx[0].top + nTxValue - m_rcsHistoryDest.top, SRCCOPY );
00449                         }
00450                         else if ( nTxValue < (DWORD)m_rcsHistoryDest.bottom && m_bsHistoryTx[1] )
00451                         {
00452                                 pDC->BitBlt( nX, nTxValue, 1, m_rcsHistoryDest.bottom - nTxValue,
00453                                         &m_pSkin->m_dcSkin, m_rcsHistoryTx[1].left + ( nX - m_rcsHistoryDest.left ),
00454                                         m_rcsHistoryTx[1].top, SRCCOPY );
00455                         }
00456                 }
00457         }
00458 }
00459 
00460 void CRemoteWnd::PaintFlow(CDC* pDC, BOOL* pbDest, CRect* prcDest, BOOL* pbSrc, CRect* prcSrc, CGraphItem* pItem, DWORD nMaximum)
00461 {
00462         if ( *pbDest == FALSE ) return;
00463         if ( nMaximum == 0 || pItem->m_nLength < 1 ) return;
00464 
00465         DWORD nValue = (DWORD)pItem->GetValue( pItem->m_nCode );
00466         nValue = nValue * prcDest->Height() / nMaximum;
00467 
00468         if ( pbSrc[0] )
00469         {
00470                 pDC->BitBlt( prcDest->left, prcDest->bottom - nValue,
00471                         prcDest->Width(), nValue, &m_pSkin->m_dcSkin,
00472                         prcSrc[0].left, prcSrc[0].bottom - nValue, SRCCOPY );
00473         }
00474         else if ( pbSrc[1] )
00475         {
00476                 pDC->BitBlt( prcDest->left, prcDest->bottom - nValue,
00477                         prcDest->Width(), nValue, &m_pSkin->m_dcSkin,
00478                         prcSrc[1].left, prcSrc[1].top, SRCCOPY );
00479         }
00480 }
00481 
00483 // CRemoteWnd paint bandwidth scaler
00484 
00485 void CRemoteWnd::PaintScaler(CDC* pDC)
00486 {
00487         if ( m_bsScalerTrack )
00488         {
00489                 CRect rcTrack( &m_rcsScalerTrack ), rcPart;
00490                 float nPosition = 0;
00491 
00492                 if ( Settings.Live.BandwidthScale > 100 )
00493                         nPosition = 1.0f;
00494                 else
00495                         nPosition = (float)Settings.Live.BandwidthScale / 105.0f;
00496 
00497                 if ( m_bsScalerTab )
00498                 {
00499                         rcPart.CopyRect( &m_rcsScalerTab );
00500 
00501                         if ( m_bScaler ) rcPart.OffsetRect( rcPart.Width(), 0 );
00502 
00503                         m_rcScalerTab.left              = rcTrack.left + (int)( nPosition * ( rcTrack.Width() - rcPart.Width() ) );
00504                         m_rcScalerTab.right             = m_rcScalerTab.left + rcPart.Width();
00505                         m_rcScalerTab.top               = rcTrack.top;
00506                         m_rcScalerTab.bottom    = rcTrack.top + rcPart.Height();
00507 
00508                         pDC->BitBlt( m_rcScalerTab.left, m_rcScalerTab.top, m_rcScalerTab.Width(),
00509                                 m_rcScalerTab.Height(), &m_pSkin->m_dcSkin, rcPart.left, rcPart.top, SRCCOPY );
00510                         pDC->ExcludeClipRect( &m_rcScalerTab );
00511 
00512                         rcTrack.right = m_rcScalerTab.left;
00513                 }
00514 
00515                 if ( m_bsScalerBar )
00516                 {
00517                         rcPart.CopyRect( &m_rcsScalerBar );
00518                         CRect rcBar( &rcTrack );
00519 
00520                         while ( rcBar.left < rcBar.right )
00521                         {
00522                                 pDC->BitBlt( rcBar.left, rcBar.top, min( rcBar.Width(), rcPart.Width() ),
00523                                         rcPart.Height(), &m_pSkin->m_dcSkin, rcPart.left, rcPart.top, SRCCOPY );
00524                                 rcBar.left += rcPart.Width();
00525                         }
00526                 }
00527         }
00528 }
00529 
00531 // CRemoteWnd paint media functionality
00532 
00533 void CRemoteWnd::PaintMedia(CDC* pDC)
00534 {
00535         if ( m_bsMediaSeekTrack )
00536         {
00537                 float nPosition = m_nMediaSeek >= 0 ? m_nMediaSeek : ( CMediaFrame::g_pMediaFrame != NULL ? CMediaFrame::g_pMediaFrame->GetPosition() : 0 );
00538                 CRect rcTrack( &m_rcsMediaSeekTrack ), rcPart;
00539 
00540                 if ( m_bsMediaSeekTab )
00541                 {
00542                         rcPart.CopyRect( &m_rcsMediaSeekTab );
00543 
00544                         if ( m_bMediaSeek || m_nMediaSeek >= 0 )
00545                                 rcPart.OffsetRect( rcPart.Width(), 0 );
00546 
00547                         m_rcMediaSeekTab.left   = rcTrack.left + (int)( nPosition * ( rcTrack.Width() - rcPart.Width() ) );
00548                         m_rcMediaSeekTab.right  = m_rcMediaSeekTab.left + rcPart.Width();
00549                         m_rcMediaSeekTab.top    = rcTrack.top;
00550                         m_rcMediaSeekTab.bottom = rcTrack.top + rcPart.Height();
00551 
00552                         pDC->BitBlt( m_rcMediaSeekTab.left, m_rcMediaSeekTab.top, m_rcMediaSeekTab.Width(),
00553                                 m_rcMediaSeekTab.Height(), &m_pSkin->m_dcSkin, rcPart.left, rcPart.top, SRCCOPY );
00554                         pDC->ExcludeClipRect( &m_rcMediaSeekTab );
00555 
00556                         rcTrack.right = m_rcMediaSeekTab.left;
00557                 }
00558 
00559                 if ( m_bsMediaSeekBar )
00560                 {
00561                         rcPart.CopyRect( &m_rcsMediaSeekBar );
00562                         CRect rcBar( &rcTrack );
00563 
00564                         while ( rcBar.left < rcBar.right )
00565                         {
00566                                 pDC->BitBlt( rcBar.left, rcBar.top, min( rcBar.Width(), rcPart.Width() ),
00567                                         rcPart.Height(), &m_pSkin->m_dcSkin, rcPart.left, rcPart.top, SRCCOPY );
00568                                 rcBar.left += rcPart.Width();
00569                         }
00570                 }
00571         }
00572 
00573         if ( m_bsMediaVolTrack )
00574         {
00575                 float nPosition = (float)Settings.MediaPlayer.Volume;
00576                 CRect rcTrack( &m_rcsMediaVolTrack ), rcPart;
00577 
00578                 if ( m_bsMediaVolTab )
00579                 {
00580                         rcPart.CopyRect( &m_rcsMediaVolTab );
00581 
00582                         if ( m_bMediaVol || m_nMediaVol >= 0 )
00583                                 rcPart.OffsetRect( rcPart.Width(), 0 );
00584 
00585                         m_rcMediaVolTab.left    = rcTrack.left + (int)( nPosition * ( rcTrack.Width() - rcPart.Width() ) );
00586                         m_rcMediaVolTab.right   = m_rcMediaVolTab.left + rcPart.Width();
00587                         m_rcMediaVolTab.top             = rcTrack.top;
00588                         m_rcMediaVolTab.bottom  = rcTrack.top + rcPart.Height();
00589 
00590                         pDC->BitBlt( m_rcMediaVolTab.left, m_rcMediaVolTab.top, m_rcMediaVolTab.Width(),
00591                                 m_rcMediaVolTab.Height(), &m_pSkin->m_dcSkin, rcPart.left, rcPart.top, SRCCOPY );
00592                         pDC->ExcludeClipRect( &m_rcMediaVolTab );
00593 
00594                         rcTrack.right = m_rcMediaVolTab.left;
00595                 }
00596 
00597                 if ( m_bsMediaVolBar )
00598                 {
00599                         rcPart.CopyRect( &m_rcsMediaVolBar );
00600                         rcTrack.right = min( rcTrack.right, rcTrack.left + rcPart.Width() );
00601                         pDC->BitBlt( rcTrack.left, rcTrack.top, rcTrack.Width(),
00602                                 rcPart.Height(), &m_pSkin->m_dcSkin, rcPart.left, rcPart.top, SRCCOPY );
00603                 }
00604         }
00605 
00606         if ( m_bsStatusText && CMediaFrame::g_pMediaFrame != NULL && ! m_bStatus )
00607         {
00608                 m_bStatus |= CMediaFrame::g_pMediaFrame->PaintStatusMicro( *pDC, m_rcsStatusText );
00609         }
00610 
00611         if ( CMediaFrame::g_pMediaFrame != NULL )
00612         {
00613                 MediaState nState = CMediaFrame::g_pMediaFrame->GetState();
00614                 int nImage = 0;
00615 
00616                 if ( nState >= smsPlaying )
00617                         nImage = 1;
00618                 else if ( nState >= smsPaused )
00619                         nImage = 2;
00620 
00621                 if ( m_bsMediaStates[0][nImage] && m_bsMediaStates[1][nImage] )
00622                 {
00623                         CRect* prcAnchor = &m_rcsMediaStates[0][nImage];
00624                         CRect* prcPart = &m_rcsMediaStates[1][nImage];
00625 
00626                         pDC->BitBlt( prcAnchor->left, prcAnchor->top,
00627                                 prcAnchor->Width(), prcAnchor->Height(), &m_pSkin->m_dcSkin,
00628                                 prcPart->left, prcPart->top, SRCCOPY );
00629                 }
00630         }
00631 }
00632 
00634 // CRemoteWnd paint status functionality
00635 
00636 void CRemoteWnd::PaintStatus(CDC* pDC)
00637 {
00638         if ( m_bsStatusText && ! m_bStatus )
00639         {
00640                 pDC->DrawText( m_sStatus, &m_rcsStatusText, 
00641                         DT_SINGLELINE|DT_CENTER|DT_VCENTER|DT_NOPREFIX|DT_END_ELLIPSIS );
00642 
00643                 if ( theApp.m_bRTL ) 
00644                 {
00645                         CRect rcSrc;
00646                         rcSrc.top = 0; rcSrc.left = 0;
00647                         rcSrc.right = m_rcsStatusText.Width();
00648                         rcSrc.bottom = m_rcsStatusText.Height();
00649 
00650                         pDC->StretchBlt( rcSrc.Width() + m_rcsStatusText.left, 
00651                                 m_rcsStatusText.top, -rcSrc.Width(), rcSrc.Height(),
00652                                 pDC, m_rcsStatusText.left, m_rcsStatusText.top, 
00653                                 rcSrc.Width(), rcSrc.Height(), SRCCOPY );       
00654                 }
00655         }
00656 }
00657 
00659 // CRemoteWnd mouse interaction
00660 
00661 void CRemoteWnd::OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS* lpncsp)
00662 {
00663 }
00664 
00665 UINT CRemoteWnd::OnNcHitTest(CPoint point)
00666 {
00667         return HTCLIENT;
00668 }
00669 
00670 BOOL CRemoteWnd::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
00671 {
00672         CPoint point;
00673         GetCursorPos( &point );
00674         ScreenToClient( &point );
00675 
00676         BOOL bAvailable = CMediaFrame::g_pMediaFrame != NULL;
00677 
00678         if ( m_bsScalerTrack && m_rcScalerTab.PtInRect( point ) )
00679         {
00680                 if ( ! m_bScaler ) Invalidate();
00681                 m_bScaler = TRUE;
00682         }
00683         else if ( bAvailable && m_bsMediaSeekTrack && m_rcMediaSeekTab.PtInRect( point ) )
00684         {
00685                 if ( ! m_bMediaSeek ) Invalidate();
00686                 m_bMediaSeek = TRUE;
00687         }
00688         else if ( bAvailable && m_bsMediaVolTrack && m_rcMediaVolTab.PtInRect( point ) )
00689         {
00690                 if ( ! m_bMediaVol ) Invalidate();
00691                 m_bMediaVol = TRUE;
00692         }
00693         else if ( m_bScaler || m_bMediaSeek || m_bMediaVol )
00694         {
00695                 m_bScaler = m_bMediaSeek = m_bMediaVol = FALSE;
00696                 Invalidate();
00697         }
00698 
00699         if ( HitTestButtons( point ) != NULL )
00700         {
00701                 SetCursor( AfxGetApp()->LoadCursor( IDC_HAND ) );
00702                 return TRUE;
00703         }
00704         else if ( m_bsScalerTrack && m_rcsScalerTrack.PtInRect( point ) )
00705         {
00706                 SetCursor( AfxGetApp()->LoadCursor( IDC_HAND ) );
00707                 return TRUE;
00708         }
00709         else if ( bAvailable && m_bsMediaSeekTrack && m_rcsMediaSeekTrack.PtInRect( point ) )
00710         {
00711                 SetCursor( AfxGetApp()->LoadCursor( IDC_HAND ) );
00712                 return TRUE;
00713         }
00714         else if ( bAvailable && m_bsMediaVolTrack && m_rcsMediaVolTrack.PtInRect( point ) )
00715         {
00716                 SetCursor( AfxGetApp()->LoadCursor( IDC_HAND ) );
00717                 return TRUE;
00718         }
00719     else
00720         {
00721                 SetCursor( AfxGetApp()->LoadStandardCursor( IDC_ARROW ) );
00722                 return TRUE;
00723         }
00724 }
00725 
00726 void CRemoteWnd::OnMouseMove(UINT nFlags, CPoint point)
00727 {
00728         CmdButton* pButton = HitTestButtons( point );
00729 
00730         if ( m_pCmdHover != pButton )
00731         {
00732                 m_pCmdHover = pButton;
00733                 Invalidate();
00734         }
00735 
00736         if ( m_pCmdDown == NULL ) CWnd::OnMouseMove(nFlags, point);
00737 }
00738 
00739 void CRemoteWnd::OnLButtonDown(UINT nFlags, CPoint point)
00740 {
00741         SetActiveWindow();
00742         SetFocus();
00743 
00744         if ( CmdButton* pButton = HitTestButtons( point ) )
00745         {
00746                 m_pCmdDown = m_pCmdHover = pButton;
00747                 Invalidate();
00748                 SetCapture();
00749         }
00750         else if ( m_bsScalerTrack && m_rcsScalerTrack.PtInRect( point ) )
00751         {
00752                 TrackScaler();
00753         }
00754         else if ( m_bsMediaSeekTrack && m_rcsMediaSeekTrack.PtInRect( point ) )
00755         {
00756                 TrackSeek();
00757         }
00758         else if ( m_bsMediaVolTrack && m_rcsMediaVolTrack.PtInRect( point ) )
00759         {
00760                 TrackVol();
00761         }
00762         else
00763         {
00764                 ClientToScreen( &point );
00765                 SendMessage( WM_NCLBUTTONDOWN, HTCAPTION, MAKELONG( point.x, point.y ) );
00766         }
00767 }
00768 
00769 void CRemoteWnd::OnLButtonUp(UINT nFlags, CPoint point)
00770 {
00771         if ( m_pCmdDown != NULL )
00772         {
00773                 BOOL bOK = ( m_pCmdDown == m_pCmdHover );
00774 
00775                 m_pCmdDown = NULL;
00776                 Invalidate();
00777                 ReleaseCapture();
00778 
00779                 if ( bOK )
00780                 {
00781                         UpdateWindow();
00782                         m_pCmdHover->Execute( (CFrameWnd*)AfxGetMainWnd() );
00783                         UpdateCmdButtons();
00784                 }
00785         }
00786         else
00787         {
00788                 ClientToScreen( &point );
00789                 SendMessage( WM_NCLBUTTONUP, HTCAPTION, MAKELONG( point.x, point.y ) );
00790         }
00791 }
00792 
00793 void CRemoteWnd::OnNcLButtonDblClk(UINT nFlags, CPoint point)
00794 {
00795         if ( m_bsHistoryDest && m_rcsHistoryDest.PtInRect( point ) )
00796         {
00797                 AfxGetMainWnd()->PostMessage( WM_COMMAND, ID_TAB_HOME );
00798         }
00799         else if ( m_bsStatusText && m_rcsStatusText.PtInRect( point ) )
00800         {
00801                 AfxGetMainWnd()->PostMessage( WM_COMMAND, ID_TAB_MEDIA );
00802         }
00803         else
00804         {
00805                 AfxGetMainWnd()->PostMessage( WM_COMMAND, ID_TRAY_OPEN );
00806         }
00807 }
00808 
00809 void CRemoteWnd::OnRButtonDown(UINT nFlags, CPoint point)
00810 {
00811         CMenu* pMenu = Skin.GetMenu( _T("CRemoteWnd") );
00812         if ( pMenu == NULL ) pMenu = Skin.GetMenu( _T("CMainWnd.Tray") );
00813         if ( pMenu == NULL ) return;
00814 
00815         MENUITEMINFO pInfo;
00816         pInfo.cbSize    = sizeof(pInfo);
00817         pInfo.fMask             = MIIM_STATE;
00818         GetMenuItemInfo( pMenu->GetSafeHmenu(), ID_TRAY_OPEN, FALSE, &pInfo );
00819         pInfo.fState    |= MFS_DEFAULT;
00820         SetMenuItemInfo( pMenu->GetSafeHmenu(), ID_TRAY_OPEN, FALSE, &pInfo );
00821 
00822         ClientToScreen( &point );
00823         pMenu->TrackPopupMenu( TPM_CENTERALIGN|TPM_TOPALIGN|TPM_RIGHTBUTTON,
00824                 point.x, point.y, AfxGetMainWnd(), NULL );
00825 }
00826 
00827 INT_PTR CRemoteWnd::OnToolHitTest(CPoint point, TOOLINFO* pTI) const
00828 {
00829         if ( CmdButton* pButton = HitTestButtons( point ) )
00830         {
00831                 CString strTip;
00832 
00833                 if ( LoadString( strTip, pButton->m_nID ) )
00834                 {
00835                         if ( LPCTSTR pszBreak = _tcschr( strTip, '\n' ) )
00836                         {
00837                                 pTI->lpszText = _tcsdup( pszBreak + 1 );
00838                         }
00839                         else
00840                         {
00841                                 strTip = strTip.SpanExcluding( _T(".") );
00842                                 pTI->lpszText = _tcsdup( strTip );
00843                         }
00844                 }
00845 
00846                 pTI->hwnd               = GetSafeHwnd();
00847                 pTI->uId                = pButton->m_nID;
00848                 pTI->uFlags             = pTI->uFlags & ~TTF_IDISHWND;
00849                 pTI->rect               = pButton->m_rc;
00850 
00851                 return pTI->uId;
00852         }
00853 
00854         return CWnd::OnToolHitTest( point, pTI );
00855 }
00856 
00858 // CRemoteWnd trackers
00859 
00860 void CRemoteWnd::TrackScaler()
00861 {
00862         MSG* pMsg = &AfxGetThreadState()->m_msgCur;
00863         CRect rcTrack( &m_rcsScalerTrack );
00864         CPoint point;
00865 
00866         ClientToScreen( &rcTrack );
00867         ClipCursor( &rcTrack );
00868         ScreenToClient( &rcTrack );
00869         SetCapture();
00870 
00871         rcTrack.DeflateRect( m_rcScalerTab.Width() / 2, 0 );
00872 
00873         while ( GetAsyncKeyState( VK_LBUTTON ) & 0x8000 )
00874         {
00875                 while ( ::PeekMessage( pMsg, NULL, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE ) );
00876 
00877                 if ( ! AfxGetThread()->PumpMessage() )
00878                 {
00879                         AfxPostQuitMessage( 0 );
00880                         break;
00881                 }
00882 
00883                 GetCursorPos( &point );
00884                 ScreenToClient( &point );
00885 
00886                 int nPosition = (int)( 105.0f * (float)( point.x - rcTrack.left ) / (float)rcTrack.Width() );
00887                 if ( nPosition < 0 ) nPosition = 0;
00888                 else if ( nPosition >= 102 ) nPosition = 101;
00889                 else if ( nPosition >= 100 ) nPosition = 100;
00890 
00891                 if ( nPosition != (int)Settings.Live.BandwidthScale )
00892                 {
00893                         Settings.Live.BandwidthScale = (DWORD)nPosition;
00894                         Invalidate();
00895                 }
00896         }
00897 
00898         ReleaseCapture();
00899         ClipCursor( NULL );
00900         Invalidate();
00901 }
00902 
00903 void CRemoteWnd::TrackSeek()
00904 {
00905         MSG* pMsg = &AfxGetThreadState()->m_msgCur;
00906         CRect rcTrack( &m_rcsMediaSeekTrack );
00907         CPoint point;
00908 
00909         if ( CMediaFrame::g_pMediaFrame == NULL ) return;
00910 
00911         ClientToScreen( &rcTrack );
00912         ClipCursor( &rcTrack );
00913         ScreenToClient( &rcTrack );
00914         SetCapture();
00915 
00916         rcTrack.DeflateRect( m_rcMediaSeekTab.Width() / 2, 0 );
00917 
00918         while ( GetAsyncKeyState( VK_LBUTTON ) & 0x8000 )
00919         {
00920                 while ( ::PeekMessage( pMsg, NULL, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE ) );
00921 
00922                 if ( ! AfxGetThread()->PumpMessage() )
00923                 {
00924                         AfxPostQuitMessage( 0 );
00925                         break;
00926                 }
00927 
00928                 GetCursorPos( &point );
00929                 ScreenToClient( &point );
00930 
00931                 float nPosition = (float)( point.x - rcTrack.left ) / (float)rcTrack.Width();
00932                 if ( nPosition < 0.0f ) nPosition = 0.0f;
00933                 if ( nPosition > 1.0f ) nPosition = 1.0f;
00934 
00935                 if ( nPosition != m_nMediaSeek )
00936                 {
00937                         m_nMediaSeek = nPosition;
00938                         Invalidate();
00939                 }
00940         }
00941 
00942         ReleaseCapture();
00943         ClipCursor( NULL );
00944 
00945         CMediaFrame::g_pMediaFrame->SeekTo( m_nMediaSeek );
00946         m_nMediaSeek = -1;
00947         Invalidate();
00948 }
00949 
00950 void CRemoteWnd::TrackVol()
00951 {
00952         MSG* pMsg = &AfxGetThreadState()->m_msgCur;
00953         CRect rcTrack( &m_rcsMediaVolTrack );
00954         CPoint point;
00955 
00956         if ( CMediaFrame::g_pMediaFrame == NULL ) return;
00957 
00958         ClientToScreen( &rcTrack );
00959         ClipCursor( &rcTrack );
00960         ScreenToClient( &rcTrack );
00961         SetCapture();
00962 
00963         rcTrack.DeflateRect( m_rcMediaVolTab.Width() / 2, 0 );
00964 
00965         while ( GetAsyncKeyState( VK_LBUTTON ) & 0x8000 )
00966         {
00967                 while ( ::PeekMessage( pMsg, NULL, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE ) );
00968 
00969                 if ( ! AfxGetThread()->PumpMessage() )
00970                 {
00971                         AfxPostQuitMessage( 0 );
00972                         break;
00973                 }
00974 
00975                 GetCursorPos( &point );
00976                 ScreenToClient( &point );
00977 
00978                 float nPosition = (float)( point.x - rcTrack.left ) / (float)rcTrack.Width();
00979                 if ( nPosition < 0.0f ) nPosition = 0.0f;
00980                 if ( nPosition > 1.0f ) nPosition = 1.0f;
00981 
00982                 if ( nPosition != m_nMediaVol )
00983                 {
00984                         m_nMediaVol = nPosition;
00985                         CMediaFrame::g_pMediaFrame->SetVolume( m_nMediaVol );
00986                         Invalidate();
00987                 }
00988         }
00989 
00990         ReleaseCapture();
00991         ClipCursor( NULL );
00992 
00993         m_nMediaVol = -1;
00994         Invalidate();
00995 }
00996 
00997 
00999 // CRemoteWnd::CmdButton construction
01000 
01001 CRemoteWnd::CmdButton::CmdButton(LPCTSTR pszName) : m_rc( 0, 0, 0, 0 )
01002 {
01003         m_nID           = CoolInterface.NameToID( pszName + 1 );
01004         m_sName         = pszName;
01005         m_bVisible      = TRUE;
01006         m_bEnabled      = TRUE;
01007         m_bChecked      = FALSE;
01008         if ( m_nID == 0 ) m_nID = 1;
01009 }
01010 
01011 BOOL CRemoteWnd::CmdButton::HitTest(const CPoint& point, BOOL bAll) const
01012 {
01013         return ( bAll || m_bEnabled ) && m_rc.PtInRect( point );
01014 }
01015 
01016 void CRemoteWnd::CmdButton::Show(BOOL bShow)
01017 {
01018         if ( m_bVisible == bShow ) return;
01019         m_bVisible = bShow;
01020         m_bChanged = TRUE;
01021 }
01022 
01023 void CRemoteWnd::CmdButton::Enable(BOOL bOn)
01024 {
01025         m_bEnableChanged = TRUE;
01026         if ( m_bEnabled == bOn ) return;
01027         m_bEnabled = bOn;
01028         m_bChanged = TRUE;
01029 }
01030 
01031 void CRemoteWnd::CmdButton::SetCheck(int nCheck)
01032 {
01033         if ( m_bChecked == ( nCheck != 0 ) ) return;
01034         m_bChecked = ( nCheck != 0 );
01035         m_bChanged = TRUE;
01036 }
01037 
01038 void CRemoteWnd::CmdButton::Execute(CFrameWnd* pTarget)
01039 {
01040         if ( m_bVisible && m_bEnabled )
01041         {
01042                 pTarget->SendMessage( WM_COMMAND, m_nID );
01043         }
01044 }
01045 
01046 void CRemoteWnd::CmdButton::Paint(CDC* pdcWindow, CRect& rcWindow, CSkinWindow* pSkin, CmdButton* pHover, CmdButton* pDown)
01047 {
01048         ASSERT( pSkin != NULL );
01049         pSkin->GetAnchor( m_sName, m_rc );
01050 
01051         if ( ! m_bVisible )
01052         {
01053                 return;
01054         }
01055         else if ( m_bChecked )
01056         {
01057                 if ( ! pSkin->PaintPartOnAnchor( pdcWindow, rcWindow, m_sName + _T(".Checked"), m_sName ) )
01058                         pSkin->PaintPartOnAnchor( pdcWindow, rcWindow, m_sName + _T(".Down"), m_sName );
01059         }
01060         else if ( ! m_bEnabled )
01061         {
01062                 pSkin->PaintPartOnAnchor( pdcWindow, rcWindow, m_sName + _T(".Disabled"), m_sName );
01063         }
01064         else if ( pHover == this && pDown == this )
01065         {
01066                 pSkin->PaintPartOnAnchor( pdcWindow, rcWindow, m_sName + _T(".Down"), m_sName );
01067         }
01068         else if ( ( pHover == this && pDown == NULL ) || ( pDown == this ) )
01069         {
01070                 pSkin->PaintPartOnAnchor( pdcWindow, rcWindow, m_sName + _T(".Hover"), m_sName );
01071         }
01072         else
01073         {
01074                 pSkin->PaintPartOnAnchor( pdcWindow, rcWindow, m_sName + _T(".Up"), m_sName );
01075         }
01076 }

Generated on Thu Dec 15 10:39:53 2005 for Shareaza 2.2.1.0 by  doxygen 1.4.2