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

Method SetPos

DuiLib/Layout/UIHorizontalLayout.cpp:29–127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27 }
28
29 void CHorizontalLayoutUI::SetPos(RECT rc)
30 {
31 CControlUI::SetPos(rc);
32 rc = m_rcItem;
33
34 // Adjust for inset
35 rc.left += m_rcInset.left;
36 rc.top += m_rcInset.top;
37 rc.right -= m_rcInset.right;
38 rc.bottom -= m_rcInset.bottom;
39
40 if( m_items.GetSize() == 0) {
41 ProcessScrollBar(rc, 0, 0);
42 return;
43 }
44
45 if( m_pVerticalScrollBar && m_pVerticalScrollBar->IsVisible() ) rc.right -= m_pVerticalScrollBar->GetFixedWidth();
46 if( m_pHorizontalScrollBar && m_pHorizontalScrollBar->IsVisible() ) rc.bottom -= m_pHorizontalScrollBar->GetFixedHeight();
47
48 // Determine the width of elements that are sizeable
49 SIZE szAvailable = { rc.right - rc.left, rc.bottom - rc.top };
50 if( m_pHorizontalScrollBar && m_pHorizontalScrollBar->IsVisible() )
51 szAvailable.cx += m_pHorizontalScrollBar->GetScrollRange();
52
53 int nAdjustables = 0;
54 int cxFixed = 0;
55 int nEstimateNum = 0;
56 for( int it1 = 0; it1 < m_items.GetSize(); it1++ ) {
57 CControlUI* pControl = static_cast<CControlUI*>(m_items[it1]);
58 if( !pControl->IsVisible() ) continue;
59 if( pControl->IsFloat() ) continue;
60 SIZE sz = pControl->EstimateSize(szAvailable);
61 if( sz.cx == 0 ) {
62 nAdjustables++;
63 }
64 else {
65 if( sz.cx < pControl->GetMinWidth() ) sz.cx = pControl->GetMinWidth();
66 if( sz.cx > pControl->GetMaxWidth() ) sz.cx = pControl->GetMaxWidth();
67 }
68 cxFixed += sz.cx + pControl->GetPadding().left + pControl->GetPadding().right;
69 nEstimateNum++;
70 }
71 cxFixed += (nEstimateNum - 1) * m_iChildPadding;
72
73 int cxExpand = 0;
74 int cxNeeded = 0;
75 if( nAdjustables > 0 ) cxExpand = MAX(0, (szAvailable.cx - cxFixed) / nAdjustables);
76 // Position the elements
77 SIZE szRemaining = szAvailable;
78 int iPosX = rc.left;
79 if( m_pHorizontalScrollBar && m_pHorizontalScrollBar->IsVisible() ) {
80 iPosX -= m_pHorizontalScrollBar->GetScrollPos();
81 }
82 int iAdjustable = 0;
83 int cxFixedRemaining = cxFixed;
84 for( int it2 = 0; it2 < m_items.GetSize(); it2++ ) {
85 CControlUI* pControl = static_cast<CControlUI*>(m_items[it2]);
86 if( !pControl->IsVisible() ) continue;

Callers

nothing calls this directly

Calls 13

IsVisibleMethod · 0.80
GetFixedWidthMethod · 0.80
GetFixedHeightMethod · 0.80
IsFloatMethod · 0.80
GetMinWidthMethod · 0.80
GetMaxWidthMethod · 0.80
GetPaddingMethod · 0.80
GetMinHeightMethod · 0.80
GetMaxHeightMethod · 0.80
GetSizeMethod · 0.45
GetScrollRangeMethod · 0.45
EstimateSizeMethod · 0.45

Tested by

no test coverage detected