MCPcopy Create free account
hub / github.com/cinience/RedisStudio / PaintStatusImage

Method PaintStatusImage

DuiLib/Control/UIComboBox.cpp:24–82  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22 }
23
24 void CComboBoxUI::PaintStatusImage(HDC hDC)
25 {
26 if (m_sArrowImage.IsEmpty())
27 CComboUI::PaintStatusImage(hDC);
28 else
29 {
30 // get index
31 if( IsFocused() ) m_uButtonState |= UISTATE_FOCUSED;
32 else m_uButtonState &= ~ UISTATE_FOCUSED;
33 if( !IsEnabled() ) m_uButtonState |= UISTATE_DISABLED;
34 else m_uButtonState &= ~ UISTATE_DISABLED;
35
36 int nIndex = 0;
37 if ((m_uButtonState & UISTATE_DISABLED) != 0)
38 nIndex = 4;
39 else if ((m_uButtonState & UISTATE_PUSHED) != 0)
40 nIndex = 2;
41 else if ((m_uButtonState & UISTATE_HOT) != 0)
42 nIndex = 1;
43 else if ((m_uButtonState & UISTATE_FOCUSED) != 0)
44 nIndex = 3;
45
46 // make modify string
47 CDuiString sModify = m_sArrowImage;
48
49 int nPos1 = sModify.Find(_T("source"));
50 int nPos2 = sModify.Find(_T("'"), nPos1 + 7);
51 if (nPos2 == -1) return; //first
52 int nPos3 = sModify.Find(_T("'"), nPos2 + 1);
53 if (nPos3 == -1) return; //second
54
55 CDuiRect rcBmpPart;
56 LPTSTR lpszValue = NULL;
57 rcBmpPart.left = _tcstol(sModify.GetData() + nPos2 + 1, &lpszValue, 10); ASSERT(lpszValue);
58 rcBmpPart.top = _tcstol(lpszValue + 1, &lpszValue, 10); ASSERT(lpszValue);
59 rcBmpPart.right = _tcstol(lpszValue + 1, &lpszValue, 10); ASSERT(lpszValue);
60 rcBmpPart.bottom = _tcstol(lpszValue + 1, &lpszValue, 10); ASSERT(lpszValue);
61
62 m_nArrowWidth = rcBmpPart.GetWidth() / 5;
63 rcBmpPart.left += nIndex * m_nArrowWidth;
64 rcBmpPart.right = rcBmpPart.left + m_nArrowWidth;
65
66 CDuiRect rcDest(0, 0, m_rcItem.right - m_rcItem.left, m_rcItem.bottom - m_rcItem.top);
67 rcDest.Deflate(GetBorderSize(), GetBorderSize());
68 rcDest.left = rcDest.right - m_nArrowWidth;
69
70 CDuiString sSource = sModify.Mid(nPos1, nPos3 + 1 - nPos1);
71 CDuiString sReplace;
72 sReplace.SmallFormat(_T("source='%d,%d,%d,%d' dest='%d,%d,%d,%d'"),
73 rcBmpPart.left, rcBmpPart.top, rcBmpPart.right, rcBmpPart.bottom,
74 rcDest.left, rcDest.top, rcDest.right, rcDest.bottom);
75
76 sModify.Replace(sSource, sReplace);
77
78 // draw image
79 if (!DrawImage(hDC, m_sArrowImage, sModify))
80 m_sNormalImage.Empty();
81 }

Callers

nothing calls this directly

Calls 10

DrawImageFunction · 0.85
IsEmptyMethod · 0.80
DeflateMethod · 0.80
MidMethod · 0.80
SmallFormatMethod · 0.80
ReplaceMethod · 0.80
FindMethod · 0.45
GetDataMethod · 0.45
GetWidthMethod · 0.45
EmptyMethod · 0.45

Tested by

no test coverage detected