diff options
author | Sean Hall <r.sean.hall@gmail.com> | 2020-07-06 16:10:13 +1000 |
---|---|---|
committer | Sean Hall <r.sean.hall@gmail.com> | 2020-07-06 21:30:49 +1000 |
commit | 00bd06f02cf168eb0752e1d0819969a528742ba7 (patch) | |
tree | d4eaed6ff7c29326c97c1551d2f1d7aede4de2b3 | |
parent | 2f762cfb545e025e550e523986db3d79ba1fb5fa (diff) | |
download | wix-00bd06f02cf168eb0752e1d0819969a528742ba7.tar.gz wix-00bd06f02cf168eb0752e1d0819969a528742ba7.tar.bz2 wix-00bd06f02cf168eb0752e1d0819969a528742ba7.zip |
Use the DefaultDPI width and height as the source width and height for images.
-rw-r--r-- | src/dutil/thmutil.cpp | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/src/dutil/thmutil.cpp b/src/dutil/thmutil.cpp index b40868a1..4da489e4 100644 --- a/src/dutil/thmutil.cpp +++ b/src/dutil/thmutil.cpp | |||
@@ -1258,8 +1258,10 @@ DAPI_(HRESULT) ThemeDrawBackground( | |||
1258 | { | 1258 | { |
1259 | HDC hdcMem = ::CreateCompatibleDC(pps->hdc); | 1259 | HDC hdcMem = ::CreateCompatibleDC(pps->hdc); |
1260 | HBITMAP hDefaultBitmap = static_cast<HBITMAP>(::SelectObject(hdcMem, pTheme->hImage)); | 1260 | HBITMAP hDefaultBitmap = static_cast<HBITMAP>(::SelectObject(hdcMem, pTheme->hImage)); |
1261 | DWORD dwSourceWidth = pTheme->nDefaultDpiWidth; | ||
1262 | DWORD dwSourceHeight = pTheme->nDefaultDpiHeight; | ||
1261 | 1263 | ||
1262 | ::StretchBlt(pps->hdc, 0, 0, pTheme->nWidth, pTheme->nHeight, hdcMem, pTheme->nSourceX, pTheme->nSourceY, pTheme->nWidth, pTheme->nHeight, SRCCOPY); | 1264 | ::StretchBlt(pps->hdc, 0, 0, pTheme->nWidth, pTheme->nHeight, hdcMem, pTheme->nSourceX, pTheme->nSourceY, dwSourceWidth, dwSourceHeight, SRCCOPY); |
1263 | 1265 | ||
1264 | ::SelectObject(hdcMem, hDefaultBitmap); | 1266 | ::SelectObject(hdcMem, hDefaultBitmap); |
1265 | ::DeleteDC(hdcMem); | 1267 | ::DeleteDC(hdcMem); |
@@ -3666,6 +3668,8 @@ static HRESULT DrawButton( | |||
3666 | { | 3668 | { |
3667 | int nSourceX = pControl->hImage ? 0 : pControl->nSourceX; | 3669 | int nSourceX = pControl->hImage ? 0 : pControl->nSourceX; |
3668 | int nSourceY = pControl->hImage ? 0 : pControl->nSourceY; | 3670 | int nSourceY = pControl->hImage ? 0 : pControl->nSourceY; |
3671 | DWORD dwSourceWidth = pControl->nDefaultDpiWidth; | ||
3672 | DWORD dwSourceHeight = pControl->nDefaultDpiHeight; | ||
3669 | 3673 | ||
3670 | HDC hdcMem = ::CreateCompatibleDC(pdis->hDC); | 3674 | HDC hdcMem = ::CreateCompatibleDC(pdis->hDC); |
3671 | HBITMAP hDefaultBitmap = static_cast<HBITMAP>(::SelectObject(hdcMem, pControl->hImage ? pControl->hImage : pTheme->hImage)); | 3675 | HBITMAP hDefaultBitmap = static_cast<HBITMAP>(::SelectObject(hdcMem, pControl->hImage ? pControl->hImage : pTheme->hImage)); |
@@ -3674,20 +3678,20 @@ static HRESULT DrawButton( | |||
3674 | // "clicked" gets priority | 3678 | // "clicked" gets priority |
3675 | if (ODS_SELECTED & pdis->itemState) | 3679 | if (ODS_SELECTED & pdis->itemState) |
3676 | { | 3680 | { |
3677 | nSourceY += pControl->nHeight * 2; | 3681 | nSourceY += pControl->nDefaultDpiHeight * 2; |
3678 | } | 3682 | } |
3679 | // then hover | 3683 | // then hover |
3680 | else if (pControl->dwData & THEME_CONTROL_DATA_HOVER) | 3684 | else if (pControl->dwData & THEME_CONTROL_DATA_HOVER) |
3681 | { | 3685 | { |
3682 | nSourceY += pControl->nHeight; | 3686 | nSourceY += pControl->nDefaultDpiHeight; |
3683 | } | 3687 | } |
3684 | // then focused | 3688 | // then focused |
3685 | else if (WS_TABSTOP & dwStyle && ODS_FOCUS & pdis->itemState) | 3689 | else if (WS_TABSTOP & dwStyle && ODS_FOCUS & pdis->itemState) |
3686 | { | 3690 | { |
3687 | nSourceY += pControl->nHeight * 3; | 3691 | nSourceY += pControl->nDefaultDpiHeight * 3; |
3688 | } | 3692 | } |
3689 | 3693 | ||
3690 | ::StretchBlt(pdis->hDC, 0, 0, pControl->nWidth, pControl->nHeight, hdcMem, nSourceX, nSourceY, pControl->nWidth, pControl->nHeight, SRCCOPY); | 3694 | ::StretchBlt(pdis->hDC, 0, 0, pControl->nWidth, pControl->nHeight, hdcMem, nSourceX, nSourceY, dwSourceWidth, dwSourceHeight, SRCCOPY); |
3691 | 3695 | ||
3692 | ::SelectObject(hdcMem, hDefaultBitmap); | 3696 | ::SelectObject(hdcMem, hDefaultBitmap); |
3693 | ::DeleteDC(hdcMem); | 3697 | ::DeleteDC(hdcMem); |
@@ -3773,6 +3777,8 @@ static HRESULT DrawImage( | |||
3773 | DWORD dwWidth = pdis->rcItem.right - pdis->rcItem.left; | 3777 | DWORD dwWidth = pdis->rcItem.right - pdis->rcItem.left; |
3774 | int nSourceX = pControl->hImage ? 0 : pControl->nSourceX; | 3778 | int nSourceX = pControl->hImage ? 0 : pControl->nSourceX; |
3775 | int nSourceY = pControl->hImage ? 0 : pControl->nSourceY; | 3779 | int nSourceY = pControl->hImage ? 0 : pControl->nSourceY; |
3780 | DWORD dwSourceHeight = pControl->nDefaultDpiHeight; | ||
3781 | DWORD dwSourceWidth = pControl->nDefaultDpiWidth; | ||
3776 | 3782 | ||
3777 | BLENDFUNCTION bf = { }; | 3783 | BLENDFUNCTION bf = { }; |
3778 | bf.BlendOp = AC_SRC_OVER; | 3784 | bf.BlendOp = AC_SRC_OVER; |
@@ -3784,9 +3790,9 @@ static HRESULT DrawImage( | |||
3784 | 3790 | ||
3785 | // Try to draw the image with transparency and if that fails (usually because the image has no | 3791 | // Try to draw the image with transparency and if that fails (usually because the image has no |
3786 | // alpha channel) then draw the image as is. | 3792 | // alpha channel) then draw the image as is. |
3787 | if (!::AlphaBlend(pdis->hDC, 0, 0, dwWidth, dwHeight, hdcMem, nSourceX, nSourceY, dwWidth, dwHeight, bf)) | 3793 | if (!::AlphaBlend(pdis->hDC, 0, 0, dwWidth, dwHeight, hdcMem, nSourceX, nSourceY, dwSourceWidth, dwSourceHeight, bf)) |
3788 | { | 3794 | { |
3789 | ::StretchBlt(pdis->hDC, 0, 0, dwWidth, dwHeight, hdcMem, nSourceX, nSourceY, dwWidth, dwHeight, SRCCOPY); | 3795 | ::StretchBlt(pdis->hDC, 0, 0, dwWidth, dwHeight, hdcMem, nSourceX, nSourceY, dwSourceWidth, dwSourceHeight, SRCCOPY); |
3790 | } | 3796 | } |
3791 | 3797 | ||
3792 | ::SelectObject(hdcMem, hDefaultBitmap); | 3798 | ::SelectObject(hdcMem, hDefaultBitmap); |
@@ -3805,29 +3811,30 @@ static HRESULT DrawProgressBar( | |||
3805 | DWORD dwProgressPercentage = LOWORD(pControl->dwData); | 3811 | DWORD dwProgressPercentage = LOWORD(pControl->dwData); |
3806 | DWORD dwHeight = pdis->rcItem.bottom - pdis->rcItem.top; | 3812 | DWORD dwHeight = pdis->rcItem.bottom - pdis->rcItem.top; |
3807 | DWORD dwCenter = (pdis->rcItem.right - 2) * dwProgressPercentage / 100; | 3813 | DWORD dwCenter = (pdis->rcItem.right - 2) * dwProgressPercentage / 100; |
3814 | DWORD dwSourceHeight = pControl->nDefaultDpiHeight; | ||
3808 | int nSourceX = pControl->hImage ? 0 : pControl->nSourceX; | 3815 | int nSourceX = pControl->hImage ? 0 : pControl->nSourceX; |
3809 | int nSourceY = (pControl->hImage ? 0 : pControl->nSourceY) + (dwProgressColor * pControl->nHeight); | 3816 | int nSourceY = (pControl->hImage ? 0 : pControl->nSourceY) + (dwProgressColor * dwSourceHeight); |
3810 | 3817 | ||
3811 | HDC hdcMem = ::CreateCompatibleDC(pdis->hDC); | 3818 | HDC hdcMem = ::CreateCompatibleDC(pdis->hDC); |
3812 | HBITMAP hDefaultBitmap = static_cast<HBITMAP>(::SelectObject(hdcMem, pControl->hImage ? pControl->hImage : pTheme->hImage)); | 3819 | HBITMAP hDefaultBitmap = static_cast<HBITMAP>(::SelectObject(hdcMem, pControl->hImage ? pControl->hImage : pTheme->hImage)); |
3813 | 3820 | ||
3814 | // Draw the left side of the progress bar. | 3821 | // Draw the left side of the progress bar. |
3815 | ::StretchBlt(pdis->hDC, 0, 0, 1, dwHeight, hdcMem, nSourceX, nSourceY, 1, dwHeight, SRCCOPY); | 3822 | ::StretchBlt(pdis->hDC, 0, 0, 1, dwHeight, hdcMem, nSourceX, nSourceY, 1, dwSourceHeight, SRCCOPY); |
3816 | 3823 | ||
3817 | // Draw the filled side of the progress bar, if there is any. | 3824 | // Draw the filled side of the progress bar, if there is any. |
3818 | if (0 < dwCenter) | 3825 | if (0 < dwCenter) |
3819 | { | 3826 | { |
3820 | ::StretchBlt(pdis->hDC, 1, 0, dwCenter, dwHeight, hdcMem, nSourceX + 1, nSourceY, 1, dwHeight, SRCCOPY); | 3827 | ::StretchBlt(pdis->hDC, 1, 0, dwCenter, dwHeight, hdcMem, nSourceX + 1, nSourceY, 1, dwSourceHeight, SRCCOPY); |
3821 | } | 3828 | } |
3822 | 3829 | ||
3823 | // Draw the unfilled side of the progress bar, if there is any. | 3830 | // Draw the unfilled side of the progress bar, if there is any. |
3824 | if (dwCenter < static_cast<DWORD>(pdis->rcItem.right - 2)) | 3831 | if (dwCenter < static_cast<DWORD>(pdis->rcItem.right - 2)) |
3825 | { | 3832 | { |
3826 | ::StretchBlt(pdis->hDC, 1 + dwCenter, 0, pdis->rcItem.right - dwCenter - 1, dwHeight, hdcMem, nSourceX + 2, nSourceY, 1, dwHeight, SRCCOPY); | 3833 | ::StretchBlt(pdis->hDC, 1 + dwCenter, 0, pdis->rcItem.right - dwCenter - 1, dwHeight, hdcMem, nSourceX + 2, nSourceY, 1, dwSourceHeight, SRCCOPY); |
3827 | } | 3834 | } |
3828 | 3835 | ||
3829 | // Draw the right side of the progress bar. | 3836 | // Draw the right side of the progress bar. |
3830 | ::StretchBlt(pdis->hDC, pdis->rcItem.right - 1, 0, 1, dwHeight, hdcMem, nSourceX, nSourceY, 1, dwHeight, SRCCOPY); | 3837 | ::StretchBlt(pdis->hDC, pdis->rcItem.right - 1, 0, 1, dwHeight, hdcMem, nSourceX, nSourceY, 1, dwSourceHeight, SRCCOPY); |
3831 | 3838 | ||
3832 | ::SelectObject(hdcMem, hDefaultBitmap); | 3839 | ::SelectObject(hdcMem, hDefaultBitmap); |
3833 | ::DeleteDC(hdcMem); | 3840 | ::DeleteDC(hdcMem); |