]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
KfW GUI -- update expand/collapse icon rendering
authorKevin Wasserman <kevin.wasserman@painless-security.com>
Mon, 25 Jun 2012 10:03:32 +0000 (06:03 -0400)
committerTom Yu <tlyu@mit.edu>
Mon, 27 Aug 2012 23:27:40 +0000 (19:27 -0400)
Use DrawThemeBackground() to draw the icons from the explorer treeview.

(cherry picked from commit 28d8e44e3474afcc1ea3b472c3336bd1017b55a6)

ticket: 7279
status: resolved

src/windows/leash/LeashView.cpp

index 0460f2c8a15a1c0b1ebebf3176fc01a8d0c5339f..11902dd522bcf3aa4a464419fd846498f8203027 100644 (file)
@@ -37,6 +37,7 @@
 static CHAR THIS_FILE[] = __FILE__;
 #endif
 
+#pragma comment(lib, "uxtheme")
 /////////////////////////////////////////////////////////////////////////////
 // CLeashView
 
@@ -1053,16 +1054,9 @@ void CLeashView::AddDisplayItem(CListCtrl &list,
     TCHAR* localTimeStr=NULL;
     TCHAR* durationStr=NULL;
     TCHAR tempStr[MAX_DURATION_STR+1];
-    int imageIndex;
     time_t now = LeashTime();
-    if (iItem != elem->m_index)
-        imageIndex = -1;
-    else if (elem->m_expanded)
-        imageIndex = 0;
-    else
-        imageIndex = 2;
 
-    list.InsertItem(iItem, principal, imageIndex);
+    list.InsertItem(iItem, principal, -1);
 
     int iSubItem = 1;
     if (sm_viewColumns[TIME_ISSUED].m_enabled) {
@@ -2901,6 +2895,8 @@ void CLeashView::OnNMCustomdraw(NMHDR *pNMHDR, LRESULT *pResult)
     HFONT font;
     CCacheDisplayData *pElem;
     *pResult = CDRF_DODEFAULT;
+    int iItem;
+
     LPNMLVCUSTOMDRAW pNMLVCD = reinterpret_cast<LPNMLVCUSTOMDRAW>(pNMHDR);
     switch (pNMLVCD->nmcd.dwDrawStage) {
     case CDDS_PREPAINT:
@@ -2910,8 +2906,8 @@ void CLeashView::OnNMCustomdraw(NMHDR *pNMHDR, LRESULT *pResult)
         *pResult = CDRF_NOTIFYSUBITEMDRAW;
         break;
     case CDDS_SUBITEM | CDDS_ITEMPREPAINT:
-        pElem = FindCCacheDisplayElem(m_ccacheDisplay,
-                                      pNMLVCD->nmcd.dwItemSpec);
+        iItem = pNMLVCD->nmcd.dwItemSpec;
+        pElem = FindCCacheDisplayElem(m_ccacheDisplay, iItem);
         if (pNMLVCD->iSubItem == 0) {
             // set bold font if default princ
             if (pElem && pElem->m_isDefault) {
@@ -2925,6 +2921,23 @@ void CLeashView::OnNMCustomdraw(NMHDR *pNMHDR, LRESULT *pResult)
             font = GetSubItemFont(pNMLVCD->nmcd.dwItemSpec, pNMLVCD->iSubItem);
         }
         SelectObject(pNMLVCD->nmcd.hdc, font);
+        if (pElem != NULL && pNMLVCD->iSubItem == 0) {
+            CListCtrl &list = GetListCtrl();
+            CRect drawRect, nextRect;
+            if (list.GetSubItemRect(iItem, 0, LVIR_BOUNDS, drawRect)) {
+                HTHEME hTheme = OpenThemeData(pNMLVCD->nmcd.hdr.hwndFrom,
+                                              L"Explorer::TreeView");
+                drawRect.right = drawRect.left +
+                                 (drawRect.bottom - drawRect.top);
+                // @TODO: need hot states, too: TVP_HOTGLYPH, HGLPS_OPENED,
+                //        HGLPS_CLOSED
+                int state = pElem->m_expanded ? GLPS_OPENED : GLPS_CLOSED;
+                DrawThemeBackground(hTheme,
+                                    pNMLVCD->nmcd.hdc,
+                                    TVP_GLYPH, state,
+                                    &drawRect, NULL);
+            }
+        }
         *pResult = CDRF_NEWFONT;
         break;
     default: