diff options
author | Sean Hall <r.sean.hall@gmail.com> | 2020-07-06 16:09:24 +1000 |
---|---|---|
committer | Sean Hall <r.sean.hall@gmail.com> | 2020-07-06 21:30:49 +1000 |
commit | 2f762cfb545e025e550e523986db3d79ba1fb5fa (patch) | |
tree | 7c5e9bc9bbbbff1dbd462d127c5e1da46ec8b350 | |
parent | 07175b9e5d5c89171e34e93b3fb3fb2c11601146 (diff) | |
download | wix-2f762cfb545e025e550e523986db3d79ba1fb5fa.tar.gz wix-2f762cfb545e025e550e523986db3d79ba1fb5fa.tar.bz2 wix-2f762cfb545e025e550e523986db3d79ba1fb5fa.zip |
Scale the base width of list view columns according to the DPI.
-rw-r--r-- | src/dutil/inc/thmutil.h | 1 | ||||
-rw-r--r-- | src/dutil/thmutil.cpp | 23 |
2 files changed, 20 insertions, 4 deletions
diff --git a/src/dutil/inc/thmutil.h b/src/dutil/inc/thmutil.h index 41b1e916..c75f9587 100644 --- a/src/dutil/inc/thmutil.h +++ b/src/dutil/inc/thmutil.h | |||
@@ -86,6 +86,7 @@ struct THEME_COLUMN | |||
86 | { | 86 | { |
87 | LPWSTR pszName; | 87 | LPWSTR pszName; |
88 | UINT uStringId; | 88 | UINT uStringId; |
89 | int nDefaultDpiBaseWidth; | ||
89 | int nBaseWidth; | 90 | int nBaseWidth; |
90 | int nWidth; | 91 | int nWidth; |
91 | BOOL fExpands; | 92 | BOOL fExpands; |
diff --git a/src/dutil/thmutil.cpp b/src/dutil/thmutil.cpp index 1c3ae683..b40868a1 100644 --- a/src/dutil/thmutil.cpp +++ b/src/dutil/thmutil.cpp | |||
@@ -3137,6 +3137,7 @@ static HRESULT ParseColumns( | |||
3137 | IXMLDOMNodeList* pixnl = NULL; | 3137 | IXMLDOMNodeList* pixnl = NULL; |
3138 | IXMLDOMNode* pixnChild = NULL; | 3138 | IXMLDOMNode* pixnChild = NULL; |
3139 | BSTR bstrText = NULL; | 3139 | BSTR bstrText = NULL; |
3140 | DWORD dwValue = 0; | ||
3140 | 3141 | ||
3141 | hr = XmlSelectNodes(pixn, L"Column", &pixnl); | 3142 | hr = XmlSelectNodes(pixn, L"Column", &pixnl); |
3142 | ThmExitOnFailure(hr, "Failed to select child column nodes."); | 3143 | ThmExitOnFailure(hr, "Failed to select child column nodes."); |
@@ -3152,24 +3153,28 @@ static HRESULT ParseColumns( | |||
3152 | i = 0; | 3153 | i = 0; |
3153 | while (S_OK == (hr = XmlNextElement(pixnl, &pixnChild, NULL))) | 3154 | while (S_OK == (hr = XmlNextElement(pixnl, &pixnChild, NULL))) |
3154 | { | 3155 | { |
3156 | THEME_COLUMN* pColumn = pControl->ptcColumns + i; | ||
3157 | |||
3155 | hr = XmlGetText(pixnChild, &bstrText); | 3158 | hr = XmlGetText(pixnChild, &bstrText); |
3156 | ThmExitOnFailure(hr, "Failed to get inner text of column element."); | 3159 | ThmExitOnFailure(hr, "Failed to get inner text of column element."); |
3157 | 3160 | ||
3158 | hr = XmlGetAttributeNumber(pixnChild, L"Width", reinterpret_cast<DWORD*>(&pControl->ptcColumns[i].nBaseWidth)); | 3161 | hr = XmlGetAttributeNumber(pixnChild, L"Width", &dwValue); |
3159 | if (S_FALSE == hr) | 3162 | if (S_FALSE == hr) |
3160 | { | 3163 | { |
3161 | pControl->ptcColumns[i].nBaseWidth = 100; | 3164 | dwValue = 100; |
3162 | } | 3165 | } |
3163 | ThmExitOnFailure(hr, "Failed to get column width attribute."); | 3166 | ThmExitOnFailure(hr, "Failed to get column width attribute."); |
3164 | 3167 | ||
3165 | hr = XmlGetYesNoAttribute(pixnChild, L"Expands", reinterpret_cast<BOOL*>(&pControl->ptcColumns[i].fExpands)); | 3168 | pColumn->nBaseWidth = pColumn->nDefaultDpiBaseWidth = dwValue; |
3169 | |||
3170 | hr = XmlGetYesNoAttribute(pixnChild, L"Expands", reinterpret_cast<BOOL*>(&pColumn->fExpands)); | ||
3166 | if (E_NOTFOUND == hr) | 3171 | if (E_NOTFOUND == hr) |
3167 | { | 3172 | { |
3168 | hr = S_OK; | 3173 | hr = S_OK; |
3169 | } | 3174 | } |
3170 | ThmExitOnFailure(hr, "Failed to get expands attribute."); | 3175 | ThmExitOnFailure(hr, "Failed to get expands attribute."); |
3171 | 3176 | ||
3172 | hr = StrAllocString(&(pControl->ptcColumns[i].pszName), bstrText, 0); | 3177 | hr = StrAllocString(&pColumn->pszName, bstrText, 0); |
3173 | ThmExitOnFailure(hr, "Failed to copy column name."); | 3178 | ThmExitOnFailure(hr, "Failed to copy column name."); |
3174 | 3179 | ||
3175 | ++i; | 3180 | ++i; |
@@ -5495,6 +5500,16 @@ static void ScaleControl( | |||
5495 | } | 5500 | } |
5496 | } | 5501 | } |
5497 | 5502 | ||
5503 | if (THEME_CONTROL_TYPE_LISTVIEW == pControl->type) | ||
5504 | { | ||
5505 | for (DWORD i = 0; i < pControl->cColumns; ++i) | ||
5506 | { | ||
5507 | THEME_COLUMN* pColumn = pControl->ptcColumns + i; | ||
5508 | |||
5509 | pColumn->nBaseWidth = DpiuScaleValue(pColumn->nDefaultDpiBaseWidth, nDpi); | ||
5510 | } | ||
5511 | } | ||
5512 | |||
5498 | pControl->nWidth = DpiuScaleValue(pControl->nDefaultDpiWidth, nDpi); | 5513 | pControl->nWidth = DpiuScaleValue(pControl->nDefaultDpiWidth, nDpi); |
5499 | pControl->nHeight = DpiuScaleValue(pControl->nDefaultDpiHeight, nDpi); | 5514 | pControl->nHeight = DpiuScaleValue(pControl->nDefaultDpiHeight, nDpi); |
5500 | pControl->nX = DpiuScaleValue(pControl->nDefaultDpiX, nDpi); | 5515 | pControl->nX = DpiuScaleValue(pControl->nDefaultDpiX, nDpi); |