Ejemplo n.º 1
0
void CEditPropExternals::OnLvnGetdispinfoExternalslist(NMHDR *pNMHDR, LRESULT *pResult)
{
    NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);
    *pResult = 0;

    if (pDispInfo)
    {
        if ((pDispInfo->item.iItem >= 0)&&(pDispInfo->item.iItem < (int)m_externals.size()))
        {
            SVNExternal ext = m_externals[pDispInfo->item.iItem];
            if (pDispInfo->item.mask & LVIF_TEXT)
            {
                switch (pDispInfo->item.iSubItem)
                {
                case 0: // folder or file
                    {
                        lstrcpyn(m_columnbuf, ext.targetDir, pDispInfo->item.cchTextMax - 1);
                    }
                    break;
                case 1: // url
                    {
                        lstrcpyn(m_columnbuf, ext.url, pDispInfo->item.cchTextMax - 1);
                        int cWidth = m_ExtList.GetColumnWidth(1);
                        cWidth = max(14, cWidth-14);
                        CDC * pDC = m_ExtList.GetDC();
                        if (pDC != NULL)
                        {
                            CFont * pFont = pDC->SelectObject(m_ExtList.GetFont());
                            PathCompactPath(pDC->GetSafeHdc(), m_columnbuf, cWidth);
                            pDC->SelectObject(pFont);
                            ReleaseDC(pDC);
                        }
                    }
                    break;
                case 2: // peg
                    if ((ext.pegrevision.kind == svn_opt_revision_number) && (ext.pegrevision.value.number >= 0))
                        swprintf_s(m_columnbuf, L"%ld", ext.pegrevision.value.number);
                    else
                        m_columnbuf[0] = 0;
                    break;
                case 3: // operative
                    if ((ext.revision.kind == svn_opt_revision_number) && (ext.revision.value.number >= 0) && (ext.revision.value.number != ext.pegrevision.value.number))
                        swprintf_s(m_columnbuf, L"%ld", ext.revision.value.number);
                    else
                        m_columnbuf[0] = 0;
                    break;
                case 4: // head revision
                    if (ext.headrev != SVN_INVALID_REVNUM)
                        swprintf_s(m_columnbuf, L"%ld", ext.headrev);
                    else
                        m_columnbuf[0] = 0;
                    break;
                default:
                    m_columnbuf[0] = 0;
                }
                pDispInfo->item.pszText = m_columnbuf;
            }
        }
    }
}
Ejemplo n.º 2
0
void CFilePatchesDlg::SetTitleWithPath(int width)
{
	CString title;
	title.LoadString(IDS_PATCH_TITLE);
	title += _T("  ") + m_sPath;
	title = title.Left(MAX_PATH-1);
	PathCompactPath(GetDC()->m_hDC, title.GetBuffer(), width);
	title.ReleaseBuffer();
	SetWindowText(title);
}
Ejemplo n.º 3
0
CString CFilePath::GetCompactStr(
    HDC hDC,
    UINT unDx,
    DWORD dwEPPFlags)
{
    CString sRet = GetStr(dwEPPFlags);
    PathCompactPath(hDC, CStringLock(sRet), unDx);

    return sRet;
}
Ejemplo n.º 4
0
void CFileDiffDlg::OnLvnGetdispinfoFilelist(NMHDR *pNMHDR, LRESULT *pResult)
{
	NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);

	if (pDispInfo)
	{
		if (pDispInfo->item.iItem < (int)m_arFilteredList.size())
		{
			const FileDiff * data = &m_arFilteredList[pDispInfo->item.iItem];
			if (pDispInfo->item.mask & LVIF_TEXT)
			{
				switch (pDispInfo->item.iSubItem)
				{
				case 0:	// path
					{
						lstrcpyn(m_columnbuf, data->path.GetSVNPathString(), pDispInfo->item.cchTextMax);
						int cWidth = m_cFileList.GetColumnWidth(0);
						cWidth = max(28, cWidth-28);
						CDC * pDC = m_cFileList.GetDC();
						if (pDC != NULL)
						{
							CFont * pFont = pDC->SelectObject(m_cFileList.GetFont());
							PathCompactPath(pDC->GetSafeHdc(), m_columnbuf, cWidth);
							pDC->SelectObject(pFont);
							ReleaseDC(pDC);
						}
					}
					break;
				case 1:	// action
					lstrcpyn(m_columnbuf, GetSummarizeActionText(data->kind), pDispInfo->item.cchTextMax);
					break;
				default:
					m_columnbuf[0] = 0;
				}
				pDispInfo->item.pszText = m_columnbuf;
			}
			if (pDispInfo->item.mask & LVIF_IMAGE)
			{
				int icon_idx = 0;
				if (data->node == svn_node_dir)
					icon_idx = m_nIconFolder;
				else
				{
					icon_idx = SYS_IMAGE_LIST().GetPathIconIndex(data->path);
				}
				pDispInfo->item.iImage = icon_idx;
			}
		}
	}
	*pResult = 0;
}
Ejemplo n.º 5
0
void CFilePatchesDlg::SetTitleWithPath(int width)
{
	CString title;
	title.LoadString(IDS_PATCH_TITLE);
	title += _T("  ") + m_sPath;
	title = title.Left(MAX_PATH-1);
	CDC * pDC = GetDC();
	if (pDC)
	{
		PathCompactPath(pDC->GetSafeHdc(), title.GetBuffer(), width);
		ReleaseDC(pDC);
	}
	title.ReleaseBuffer();
	SetWindowText(title);
}
Ejemplo n.º 6
0
void CFilePatchesDlg::OnSize(UINT nType, int cx, int cy)
{
	CDialog::OnSize(nType, cx, cy);
	if (this->IsWindowVisible())
	{
		CRect rect;
		GetClientRect(rect);
		GetDlgItem(IDC_FILELIST)->MoveWindow(rect.left, rect.top, cx, cy);
		m_cFileList.SetColumnWidth(0, cx);
	}
	CString title;
	title.LoadString(IDS_PATCH_TITLE);
	title += _T("  ") + m_sPath;
	PathCompactPath(GetDC()->m_hDC, title.GetBuffer(), cx);
	title.ReleaseBuffer();
	SetWindowText(title);
}
Ejemplo n.º 7
0
void CPathEdit::FitPathToWidth(CString& path)
{
    CRect rect;
    GetClientRect(&rect);
    rect.right -= 5;    // assume a border size of 5 pixels

    CDC * pDC = GetDC();
    if (pDC)
    {
        CFont* previousFont = pDC->SelectObject(GetFont());
        path = path.Left(MAX_PATH - 1);
        PathCompactPath(pDC->m_hDC, path.GetBuffer(MAX_PATH), rect.Width());
        path.ReleaseBuffer();
        m_sFitText = path;
        pDC->SelectObject(previousFont);
        ReleaseDC(pDC);
    }
    path.Replace('\\', '/');
}
Ejemplo n.º 8
0
void CInsertControlDlg::OnControlsSelChange()
{
   int iItem;
   POSITION posControl;
   CString strServerPath;
   CLSID clsid;
   CDC dc;
   CFont* pFont;
   LPTSTR pszServerPath;
   CRect rect;
   CFont* pOldFont;

   iItem = m_lbControls.GetCurSel();
   if( iItem != LB_ERR )
   {
	  m_butOK.EnableWindow( TRUE );
	  posControl = POSITION( m_lbControls.GetItemDataPtr( iItem ) );
	  clsid = m_lControls.GetAt( posControl );
	  GetClassServerPath( clsid, strServerPath );

	  dc.CreateCompatibleDC( NULL );

	  pFont = m_staticServerPath.GetFont();
	  pOldFont = dc.SelectObject( pFont );

	  // Workaround for SHLWAPI bug (in weird cases, PathCompactPath actually
	  // expands the pathname)
	  pszServerPath = strServerPath.GetBuffer( MAX_PATH+2 );
	  m_staticServerPath.GetWindowRect( &rect );
	  PathCompactPath( dc, pszServerPath, rect.Width() );
	  strServerPath.ReleaseBuffer();

	  dc.SelectObject( pOldFont );

	  m_staticServerPath.SetWindowText( strServerPath );
   }
   else
   {
	  m_butOK.EnableWindow( FALSE );
	  m_staticServerPath.SetWindowText( NULL );
   }
}
Ejemplo n.º 9
0
void CGitProgressList::OnLvnGetdispinfoSvnprogress(NMHDR *pNMHDR, LRESULT *pResult)
{
	NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);

	if (pDispInfo)
	{
		if (pDispInfo->item.mask & LVIF_TEXT)
		{
			if (pDispInfo->item.iItem < (int)m_arData.size())
			{
				const NotificationData * data = m_arData[pDispInfo->item.iItem];
				switch (pDispInfo->item.iSubItem)
				{
				case 0:
					lstrcpyn(m_columnbuf, data->sActionColumnText, MAX_PATH);
					break;
				case 1:
					lstrcpyn(m_columnbuf, data->sPathColumnText, pDispInfo->item.cchTextMax);
					if (!data->bAuxItem)
					{
						int cWidth = GetColumnWidth(1);
						cWidth = max(12, cWidth-12);
						CDC * pDC = GetDC();
						if (pDC != NULL)
						{
							CFont * pFont = pDC->SelectObject(GetFont());
							PathCompactPath(pDC->GetSafeHdc(), m_columnbuf, cWidth);
							pDC->SelectObject(pFont);
							ReleaseDC(pDC);
						}
					}
					break;
				default:
					m_columnbuf[0] = 0;
				}
				pDispInfo->item.pszText = m_columnbuf;
			}
		}
	}
	*pResult = 0;
}
Ejemplo n.º 10
0
CString CFilenameEdit::GetDisplayName()
{
    // Get the DC for the control, and the rectangle into which we draw text
    CDC * pDC = GetDC();
    CRect rectClient;
    GetRect(&rectClient);

    // Select the correct font into the DC
    CFont * pFontOld = pDC->SelectObject(GetFont());

    // Get the display name, and truncate it to fit into the control
    // Note that we make the buffer larger than max path in case we have some bizarre
    // situation where a load of ellipsis are inserted and it overruns the buffer
    CString strDisplayName = m_strFilename;
    PathCompactPath(pDC->GetSafeHdc(), strDisplayName.GetBuffer(_MAX_PATH + 1 + BUFFER_EXTRA), rectClient.Width());
    strDisplayName.ReleaseBuffer();

    // Clean up!
    pDC->SelectObject(pFontOld);
    ReleaseDC(pDC);

    return strDisplayName;
}
Ejemplo n.º 11
0
void CCopyDlg::OnLvnGetdispinfoExternalslist(NMHDR *pNMHDR, LRESULT *pResult)
{
    NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);
    *pResult = 0;

    if (m_ExtList.HasText())
        return;

    if (pDispInfo)
    {
        if (pDispInfo->item.iItem < (int)m_externals.size())
        {
            SVNExternal ext = m_externals[pDispInfo->item.iItem];
            if (pDispInfo->item.mask & LVIF_INDENT)
            {
                pDispInfo->item.iIndent = 0;
            }
            if (pDispInfo->item.mask & LVIF_IMAGE)
            {
                pDispInfo->item.mask |= LVIF_STATE;
                pDispInfo->item.stateMask = LVIS_STATEIMAGEMASK;

                if (ext.adjust)
                {
                    //Turn check box on
                    pDispInfo->item.state = INDEXTOSTATEIMAGEMASK(2);
                }
                else
                {
                    //Turn check box off
                    pDispInfo->item.state = INDEXTOSTATEIMAGEMASK(1);
                }
            }
            if (pDispInfo->item.mask & LVIF_TEXT)
            {
                switch (pDispInfo->item.iSubItem)
                {
                case 0: // folder
                    {
                        CTSVNPath p = ext.path;
                        p.AppendPathString(ext.targetDir);
                        lstrcpyn(m_columnbuf, p.GetWinPath(), min(MAX_PATH-2, pDispInfo->item.cchTextMax));
                        int cWidth = m_ExtList.GetColumnWidth(0);
                        cWidth = max(28, cWidth-28);
                        CDC * pDC = m_ExtList.GetDC();
                        if (pDC != NULL)
                        {
                            CFont * pFont = pDC->SelectObject(m_ExtList.GetFont());
                            PathCompactPath(pDC->GetSafeHdc(), m_columnbuf, cWidth);
                            pDC->SelectObject(pFont);
                            ReleaseDC(pDC);
                        }
                    }
                    break;
                case 1: // url
                    {
                        lstrcpyn(m_columnbuf, ext.url, min(MAX_PATH-2, pDispInfo->item.cchTextMax));
                        SVNRev peg(ext.pegrevision);
                        if (peg.IsValid() && !peg.IsHead())
                        {
                            wcscat_s(m_columnbuf, L"@");
                            wcscat_s(m_columnbuf, peg.ToString());
                        }
                        int cWidth = m_ExtList.GetColumnWidth(1);
                        cWidth = max(14, cWidth-14);
                        CDC * pDC = m_ExtList.GetDC();
                        if (pDC != NULL)
                        {
                            CFont * pFont = pDC->SelectObject(m_ExtList.GetFont());
                            PathCompactPath(pDC->GetSafeHdc(), m_columnbuf, cWidth);
                            pDC->SelectObject(pFont);
                            ReleaseDC(pDC);
                        }
                    }
                    break;
                case 2: // tagged
                    m_columnbuf[0] = 0;
                    if (ext.origrevision.kind == svn_opt_revision_number)
                        swprintf_s(m_columnbuf, L"%ld", ext.origrevision.value.number);
                    else if (ext.origrevision.kind == svn_opt_revision_date)
                    {
                        SVNRev r(ext.origrevision);
                        wcscpy_s(m_columnbuf, (LPCTSTR)r.ToString());
                    }
                    break;
                default:
                    m_columnbuf[0] = 0;
                }
                pDispInfo->item.pszText = m_columnbuf;
            }
        }
    }
}
Ejemplo n.º 12
0
INT_PTR TconvolverPage::msgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    switch (uMsg) {
        case WM_DESTROY:
            cfgSet(IDFF_lvConvolverWidth0,ListView_GetColumnWidth(hlv,0));
            cfgSet(IDFF_lvConvolverWidth1,ListView_GetColumnWidth(hlv,1));
            cfgSet(IDFF_lvConvolverWidth2,ListView_GetColumnWidth(hlv,2));
            cfgSet(IDFF_lvConvolverSelected,lvGetSelItem(IDC_LV_CONVOLVER_FILES));
            break;
        case WM_COMMAND:
            switch (LOWORD(wParam)) {
                case IDC_ED_CONVOLVER_FILE:
                    if (HIWORD(wParam)==EN_CHANGE && !isSetWindowText) {
                        char_t flnm[MAX_PATH];
                        GetDlgItemText(m_hwnd,IDC_ED_CONVOLVER_FILE,flnm,MAX_PATH);
                        cfgSet(IDFF_convolverFile,flnm);
                        format2dlg(flnm);
                    }
                    return TRUE;
            }
            break;
        case WM_NOTIFY: {
            NMHDR *nmhdr=LPNMHDR(lParam);
            if (nmhdr->hwndFrom==hlv && nmhdr->idFrom==IDC_LV_CONVOLVER_FILES)
                switch (nmhdr->code) {
                    case LVN_ITEMCHANGED: {
                        NMLISTVIEW *nmlv=LPNMLISTVIEW(lParam);
                        enableMapping(nmlv->iItem!=-1);
                        return TRUE;
                    }
                    case NM_DBLCLK: {
                        NMITEMACTIVATE *nmia=(NMITEMACTIVATE*)lParam;
                        if (nmia->iItem==-1 || nmia->iSubItem!=1) {
                            return FALSE;
                        }
                        onManualFileSet();
                        return TRUE;
                    }
                    case LVN_GETDISPINFO: {
                        NMLVDISPINFO *nmdi=(NMLVDISPINFO*)lParam;
                        int i=nmdi->item.iItem;
                        if (i==-1) {
                            break;
                        }
                        if (nmdi->item.mask&LVIF_TEXT)
                            switch (nmdi->item.iSubItem) {
                                case 0: {
                                    static const int speakers[]= {SPEAKER_FRONT_LEFT,SPEAKER_FRONT_RIGHT,SPEAKER_FRONT_CENTER,SPEAKER_LOW_FREQUENCY,SPEAKER_BACK_LEFT,SPEAKER_BACK_RIGHT};
                                    strcpy(nmdi->item.pszText,_(IDC_LV_CONVOLVER_FILES,TsampleFormat::getSpeakerName(speakers[i])));
                                    break;
                                }
                                case 1: {
                                    int dx=ListView_GetColumnWidth(hlv,1);
                                    char_t flnm[MAX_PATH];
                                    cfgGet(speakersIdffs[i],flnm,MAX_PATH);
                                    HDC dc=GetDC(hlv);
                                    HGDIOBJ old=SelectObject(dc,(HGDIOBJ)SendMessage(hlv,WM_GETFONT,0,0));
                                    PathCompactPath(dc,flnm,std::max(20,dx-15));
                                    SelectObject(dc,old);
                                    ReleaseDC(hlv,dc);
                                    strcpy(nmdi->item.pszText,flnm);
                                    break;
                                }
                                case 2:
                                    if (const char_t *flnm=cfgGetStr(speakersIdffs[i]))
                                        if (flnm[0] && !speakerFormats[i]) {
                                            speakerFormats[i]=getWavDesc(flnm,IDC_LV_CONVOLVER_FILES);
                                        }
                                    strcpy(nmdi->item.pszText,speakerFormats[i].c_str());
                                    break;
                            }
                        return TRUE;
                    }
                }
            break;
        }
    }
    return TconfPageDecAudio::msgProc(uMsg,wParam,lParam);
}
Ejemplo n.º 13
0
static LRESULT CALLBACK PropProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
	switch ( uMsg )
	{
		case	WM_INITDIALOG:
		{
			LPCLASSDATA	lpcd = ( LPCLASSDATA )lParam;
			HDC		hDC;
			RECT		rcClient;
			HWND		hControl;
			HFONT		hFont, hOFont;
			TCHAR		szBuffer[ MAX_PATH ];
			int		i;

			/*
			 *	Save data.
			 */
			nFileMode = Parser->nFileMode;
			nTabSize  = Parser->nTabSize;

			/*
			 *	Setup class data pointer as
			 *	the dialog user data.
			 */
			SetWindowLong( hDlg, DWL_USER, ( LONG )lpcd );

			/*
			 *	Get handle to the file name control.
			 */
			hControl = GetDlgItem( hDlg, IDC_PROP_FILENAME );

			/*
			 *	Copy the file name into
			 *	a buffer.
			 */
			_tcsncpy_s( szBuffer, MAX_PATH, lpcd->szFileName, MAX_PATH );

			/*
			 *	Get the client rectangle of
			 *	the file name control.
			 */
			GetClientRect( hControl, &rcClient );

			/*
			 *	Get the device context.
			 */
			if (( hDC = GetDC( hControl )) != NULL )
			{
				/*
				 *	Get the dialog font.
				 */
				if (( hFont = ( HFONT )SendMessage( hDlg, WM_GETFONT, 0, 0 )) != NULL )
				{
					/*
					 *	Make sure we use the correct font.
					 */
					hOFont = SelectObject( hDC, hFont );

					/*
					 *	Compact the path.
					 */
					PathCompactPath( hDC, szBuffer, rcClient.right );

					/*
					 *	Reset the font.
					 */
					SelectObject( hDC, hOFont );
				}
				/*
				 *	Release the device context.
				 */
				ReleaseDC( hControl, hDC );
			}

			/*
			 *	Set the path.
			 */
			SetWindowText( hControl, szBuffer );

			/*
			 *	Unicode?
			 */
			SetDlgItemText( hDlg, IDC_PROP_UNICODE, GetString( lpcd->bUnicode ? IDS_TRUE : IDS_FALSE ));

			/*
			 *	Setup the up/down range
			 *	and the tab stop.
			 */
			SendDlgItemMessage( hDlg, IDC_PROP_TABSPIN, UDM_SETRANGE, 0, MAKELPARAM( 24,2 ));

			/*
			 *	Setup file modes.
			 */
			for ( i = FMODE_MSDOS; i <= FMODE_MACINTOSH; i++ )
				SendDlgItemMessage( hDlg, IDC_PROP_TYPE, CB_ADDSTRING, 0, ( LPARAM )lpszFileModes[ i ] );

			/*
			 *	Setup the file size and the
			 *	tab size controls.
			 */
			SetSizeControls( hDlg );

			/*
			 *	Valid file date?
			 */
			if ( lpcd->ftFileTime.dwHighDateTime == 0 && lpcd->ftFileTime.dwLowDateTime == 0 )
				SetDlgItemText( hDlg, IDC_PROP_DATE, GetString( IDS_NOT_SAVED ));
			else
			{
				FILETIME	ft;
				SYSTEMTIME	st;

				/*
				 *	Convert file time to
				 *	system time.
				 */
				FileTimeToLocalFileTime( &lpcd->ftFileTime, &ft );
				FileTimeToSystemTime( &ft, &st );

				/*
				 *	Format time.
				 */
				GetTimeFormat( LOCALE_USER_DEFAULT,
					       0, //LOCALE_NOUSEROVERRIDE,
					       &st,
					       NULL,
					       szBuffer,
					       256 );

				/*
				 *	Add space.
				 */
				_tcscat_s( szBuffer, MAX_PATH, _T(" "));

				/*
				 *	Format date.
				 */
				GetDateFormat( LOCALE_USER_DEFAULT,
					       0, //LOCALE_NOUSEROVERRIDE,
					       &st,
					       NULL,
					       &szBuffer[ _tcslen( szBuffer ) ],
					       256 - _tcslen( szBuffer ));

				/*
				 *	Output result.
				 */
				SetDlgItemText( hDlg, IDC_PROP_DATE, szBuffer );
			}

			/*
			 *	Focus the OK button.
			 */
			return TRUE;
		}

		case	WM_CLOSE:
			/*
			 *	Bye...
			 */
			EndDialog( hDlg, 0 );
			break;

		case	WM_COMMAND:
		{
			LPCLASSDATA	lpcd = ( LPCLASSDATA )GetWindowLong( hDlg, DWL_USER );

			switch ( LOWORD( wParam ))
			{
				case	IDC_PROP_TYPE:
					/*
					 *	Get file mode.
					 */
					Parser->nFileMode = SendDlgItemMessage( hDlg, IDC_PROP_TYPE, CB_GETCURSEL, 0, 0 );

					/*
					 *	Send status message.
					 */
					SendStatusMessage( lpcd );
					break;

				case	IDC_PROP_TABSIZE:
				{
					/*
					 *	Lost focus on the edit control?
					 */
					if ( HIWORD( wParam ) == EN_KILLFOCUS )
					{
						/*
						 *	Get value.
						 */
						int	nTabStop = GetDlgItemInt( hDlg, IDC_PROP_TABSIZE, NULL, FALSE );

						/*
						 *	Clamp entered value between 2 and 24.
						 */
						if (      nTabStop < 2  ) nTabStop = 2;
						else if ( nTabStop > 24 ) nTabStop = 24;

						/*
						 *	Set this value to the 
						 *	edit control.
						 */
						SetDlgItemInt( hDlg, IDC_PROP_TABSIZE, ( UINT )nTabStop, FALSE );

						/*
						 *	Save tab value.
						 */
						Parser->nTabSize = nTabStop;

						/*
						 *	Re-render if it changed...
						 */
						if ( nTabStop != nTabSize )
							InvalidateRect( lpcd->hWnd, NULL, FALSE );
					}
					break;
				}

				case	IDCANCEL:
					/*
					 *	Reset tabsize.
					 */
					if ( Parser->nTabSize != nTabSize )
					{
						Parser->nTabSize = nTabSize;
						InvalidateRect( lpcd->hWnd, NULL, FALSE );
					}

					/*
					 *	And file mode.
					 */
					if ( Parser->nFileMode != nFileMode )
					{
						Parser->nFileMode = nFileMode;
						SendStatusMessage( lpcd );
					}

					/*
					 *	Fall through...
					 */

				case	IDOK:
					/*
					 *	Bye...
					 */
					EndDialog( hDlg, 0 );
					break;
			}
		}
	}
	return 0;
}
Ejemplo n.º 14
0
void CHTMLListCtrl::DrawItem(CDC *pDC, CRect rcItem, HTMLLIST_ITEM *pItem, BOOL bSelected)
{
	CRect rcClipBox;
	pDC->GetClipBox(&rcClipBox);

	if(!IsRectVisible(rcClipBox,rcItem))
	{
		return;
	}

	COLORREF clrText = RGB(0,0,0);
	COLORREF clrOld;
	CRect rcImage(0,0,0,0);
		
	if(bSelected)
	{
		clrText = m_clrTextSelectedItem;
		pDC->FillSolidRect(&rcItem,m_clrBkSelectedItem);
	}
	else
	{
		clrText = m_clrTextCtrlItem;
		pDC->FillSolidRect(&rcItem,m_clrBkCtrlItem);
	}

	if(m_dwExtendedStyles & HTMLLIST_STYLE_GRIDLINES)
	{
		pDC->DrawEdge(&rcItem,BDR_SUNKENINNER,BF_LEFT|BF_BOTTOM|BF_FLAT);
	}
	
	CPoint ptCheckBox = rcItem.TopLeft();

	if(m_dwExtendedStyles & HTMLLIST_STYLE_CHECKBOX)
	{
		ptCheckBox.x += ITEM_PADDING_CHECKBOX_LEFT;
		ptCheckBox.y += rcItem.Height() / 2 - 8;
		
		m_ImageList.Draw(pDC,pItem->bChecked?1:0,ptCheckBox,ILD_TRANSPARENT);
		ptCheckBox.x += ITEM_CHECKBOX_WIDTH;
	}
	
	//Draw image if an imagelist is attached
	if(m_dwExtendedStyles & HTMLLIST_STYLE_IMAGES)
	{
		if(m_pImageList)
		{
			IMAGEINFO imgInfo = {0};
			m_pImageList->GetImageInfo(0,&imgInfo);
			rcImage = imgInfo.rcImage;
			
			CPoint pt = ptCheckBox;
			pt.x += ITEM_IMAGE_PADDING_LEFT;
			pt.y = rcItem.top;
			pt.y += rcItem.Height() / 2 - rcImage.Height()/2;
			
			m_pImageList->Draw(pDC,pItem->uiImage,pt,ILD_TRANSPARENT);			
		}
	}
	
	if(pItem->nStyle == NORMAL_TEXT)
	{
		clrOld = pDC->SetTextColor(clrText);
		
		CRect rc = rcItem;
		
		if(rcImage.Width())
		{
			//make space for the Image already drawn
			rc.DeflateRect(rcImage.Width() + ITEM_IMAGE_PADDING_LEFT + ITEM_IMAGE_PADDING_RIGHT,0,0,0);
		}
		
		if(m_dwExtendedStyles & HTMLLIST_STYLE_CHECKBOX)
		{
			rc.left += ITEM_PADDING_LEFT + ITEM_CHECKBOX_WIDTH;
		}
		else
		{
			rc.left += ITEM_PADDING_LEFT;
		}
		
		if(!pItem->bHeightSpecified)
			rc.top += ITEM_PADDING_TOP;
		
		pDC->DrawText(pItem->sItemText,pItem->sItemText.GetLength(),&rc,
			DT_LEFT|DT_WORDBREAK);
	}
	else if(pItem->nStyle == HTML_TEXT)
	{
		//Draw HTML
		clrOld = pDC->SetTextColor(clrText);
		
		CRect rc = rcItem;
		if(rcImage.Width())
		{
			//make space for the Image already drawn
			rc.DeflateRect(rcImage.Width() + ITEM_IMAGE_PADDING_LEFT + ITEM_IMAGE_PADDING_RIGHT,0,0,0);
		}
		if(m_dwExtendedStyles & HTMLLIST_STYLE_CHECKBOX)
		{
			rc.left += ITEM_PADDING_LEFT + ITEM_CHECKBOX_WIDTH;
		}
		else
		{
			rc.left += ITEM_PADDING_LEFT;
		}
		
		if(!pItem->bHeightSpecified)
			rc.top += ITEM_PADDING_TOP;
		
		DrawHTML(pDC->GetSafeHdc(),pItem->sItemText,pItem->sItemText.GetLength(),
			&rc,DT_LEFT|DT_WORDBREAK);
	}
	else if(pItem->nStyle == SINGLE_LINE_TEXT)
	{
		clrOld = pDC->SetTextColor(clrText);
		
		CRect rc = rcItem;
		if(rcImage.Width())
		{
			//make space for the Image already drawn
			rc.DeflateRect(rcImage.Width() + ITEM_IMAGE_PADDING_LEFT + ITEM_IMAGE_PADDING_RIGHT,0,0,0);
		}
		if(m_dwExtendedStyles & HTMLLIST_STYLE_CHECKBOX)
		{
			rc.left += ITEM_PADDING_LEFT + ITEM_CHECKBOX_WIDTH;
		}
		else
		{
			rc.left += ITEM_PADDING_LEFT;
		}
		
		if(!pItem->bHeightSpecified)
			rc.top += ITEM_PADDING_TOP;
		
		//See if we can fit the text in one line
		char szBuffer[_MAX_PATH];
		memset(szBuffer,0,_MAX_PATH);
		
		_tcscpy(szBuffer,pItem->sItemText);
		
		if(PathCompactPath(pDC->GetSafeHdc(),szBuffer,rc.Width()))
		{
			pDC->DrawText(szBuffer,_tcslen(szBuffer),&rc,
				DT_LEFT|DT_SINGLELINE|DT_VCENTER);	
		}
		else
		{
			pDC->DrawText(pItem->sItemText,pItem->sItemText.GetLength(),&rc,
				DT_LEFT|DT_SINGLELINE|DT_VCENTER);
		}
	}
	
	pDC->SetTextColor(clrOld);
	
	//Draw the focus rect if focused
	if(m_bHasFocus && (bSelected))
	{
		pDC->DrawFocusRect(&rcItem);
	}
}
Ejemplo n.º 15
0
BOOL CFilePatchesDlg::Init(CPatch * pPatch, CPatchFilesDlgCallBack * pCallBack, CString sPath, CWnd * pParent)
{
	if ((pCallBack==NULL)||(pPatch==NULL))
	{
		m_cFileList.DeleteAllItems();
		return FALSE;
	}
	m_arFileStates.RemoveAll();
	m_pPatch = pPatch;
	m_pCallBack = pCallBack;
	m_sPath = sPath;
	if (m_sPath.IsEmpty())
	{
		CString title(MAKEINTRESOURCE(IDS_DIFF_TITLE));
		SetWindowText(title);
	}
	else
	{
		CString title;
		title.LoadString(IDS_PATCH_TITLE);
		title += _T("  ") + m_sPath;
		CRect rect;
		GetClientRect(&rect);
		PathCompactPath(GetDC()->m_hDC, title.GetBuffer(), rect.Width());
		title.ReleaseBuffer();
		SetWindowText(title);
		if (m_sPath.Right(1).Compare(_T("\\"))==0)
			m_sPath = m_sPath.Left(m_sPath.GetLength()-1);

		m_sPath = m_sPath + _T("\\");
		for (int i=m_ImgList.GetImageCount();i>0;i--)
		{
			m_ImgList.Remove(0);
		}
	}

	m_cFileList.SetExtendedStyle(LVS_EX_INFOTIP | LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER);
	m_cFileList.DeleteAllItems();
	int c = ((CHeaderCtrl*)(m_cFileList.GetDlgItem(0)))->GetItemCount()-1;
	while (c>=0)
		m_cFileList.DeleteColumn(c--);
	m_cFileList.InsertColumn(0, _T(""));

	m_cFileList.SetRedraw(false);

	for(int i=0; i<m_pPatch->GetNumberOfFiles(); i++)
	{
		CString sFile = CPathUtils::GetFileNameFromPath(m_pPatch->GetFilename2(i));
		if(sFile == _T("NUL"))
			sFile = CPathUtils::GetFileNameFromPath(m_pPatch->GetFilename(i));

		DWORD state;
		if (m_sPath.IsEmpty())
			state = FPDLG_FILESTATE_GOOD;
		else
		{
			state = 0;
			if(m_pPatch->GetFilename(i) != m_pPatch->GetFilename2(i))
			{
				if( m_pPatch->GetFilename(i) == _T("NUL"))
					state = FPDLG_FILESTATE_NEW;
				else if (m_pPatch->GetFilename2(i) == _T("NUL"))
					state = FPDLG_FILESTATE_DELETE;
				else
					state = FPDLG_FILESTATE_RENAME;
			}

			if (m_pPatch->PatchFile(GetFullPath(i)))
			{
				if(state != FPDLG_FILESTATE_NEW &&
				   state != FPDLG_FILESTATE_RENAME &&
				   state != FPDLG_FILESTATE_DELETE)
				state = FPDLG_FILESTATE_GOOD;
			}
			else
				state = FPDLG_FILESTATE_CONFLICTED;
		}
		m_arFileStates.Add(state);
		SHFILEINFO    sfi;
		SHGetFileInfo(
			GetFullPath(i), 
			FILE_ATTRIBUTE_NORMAL,
			&sfi, 
			sizeof(SHFILEINFO), 
			SHGFI_ICON | SHGFI_SMALLICON | SHGFI_USEFILEATTRIBUTES);
		m_cFileList.InsertItem(i, sFile, m_ImgList.Add(sfi.hIcon));

	}
	int mincol = 0;
	int maxcol = ((CHeaderCtrl*)(m_cFileList.GetDlgItem(0)))->GetItemCount()-1;
	int col;
	for (col = mincol; col <= maxcol; col++)
	{
		m_cFileList.SetColumnWidth(col,LVSCW_AUTOSIZE_USEHEADER);
	}

	m_cFileList.SetImageList(&m_ImgList, LVSIL_SMALL);
	m_cFileList.SetRedraw(true);

	RECT parentrect;
	pParent->GetWindowRect(&parentrect);
	RECT windowrect;
	GetWindowRect(&windowrect);

	int width = windowrect.right - windowrect.left;
	int height = windowrect.bottom - windowrect.top;
	windowrect.right = parentrect.left;
	windowrect.left = windowrect.right - width;
	if (windowrect.left < 0)
	{
		windowrect.left = 0;
		windowrect.right = width;
	}
	windowrect.top = parentrect.top;
	windowrect.bottom = windowrect.top + height;

	SetWindowPos(NULL, windowrect.left, windowrect.top, width, height, SWP_NOACTIVATE | SWP_NOZORDER);

	m_nWindowHeight = windowrect.bottom - windowrect.top;
	m_pMainFrame = pParent;
	return TRUE;
}