|
@@ -1367,163 +1367,204 @@ namespace DuiLib {
|
|
|
{
|
|
{
|
|
|
CControlUI::SetPos(rc, bNeedInvalidate);
|
|
CControlUI::SetPos(rc, bNeedInvalidate);
|
|
|
|
|
|
|
|
- // Adjust for inset
|
|
|
|
|
- int iChildPadding = GetChildPadding();
|
|
|
|
|
- RECT rcInset = GetInset();
|
|
|
|
|
- // Adjust for inset
|
|
|
|
|
- rc.left += rcInset.left;
|
|
|
|
|
- rc.top += rcInset.top;
|
|
|
|
|
- rc.right -= rcInset.right;
|
|
|
|
|
- rc.bottom -= rcInset.bottom;
|
|
|
|
|
|
|
+ for (int nPass = 0; nPass < 2; ++nPass)
|
|
|
|
|
+ {
|
|
|
|
|
+ RECT rcWork = rc;
|
|
|
|
|
|
|
|
- if (m_pOwner->IsFixedScrollbar() && m_pVerticalScrollBar) rc.right -= m_pVerticalScrollBar->GetFixedWidth();
|
|
|
|
|
- else if (m_pVerticalScrollBar && m_pVerticalScrollBar->IsVisible()) rc.right -= m_pVerticalScrollBar->GetFixedWidth();
|
|
|
|
|
- if (m_pHorizontalScrollBar && m_pHorizontalScrollBar->IsVisible()) rc.bottom -= m_pHorizontalScrollBar->GetFixedHeight();
|
|
|
|
|
|
|
+ int iChildPadding = GetChildPadding();
|
|
|
|
|
+ RECT rcInset = GetInset();
|
|
|
|
|
+ rcWork.left += rcInset.left;
|
|
|
|
|
+ rcWork.top += rcInset.top;
|
|
|
|
|
+ rcWork.right -= rcInset.right;
|
|
|
|
|
+ rcWork.bottom -= rcInset.bottom;
|
|
|
|
|
|
|
|
- // Determine the minimum size
|
|
|
|
|
- SIZE szAvailable = { rc.right - rc.left, rc.bottom - rc.top };
|
|
|
|
|
- if (m_pHorizontalScrollBar && m_pHorizontalScrollBar->IsVisible())
|
|
|
|
|
- szAvailable.cx += m_pHorizontalScrollBar->GetScrollRange();
|
|
|
|
|
|
|
+ if (m_pOwner->IsFixedScrollbar() && m_pVerticalScrollBar)
|
|
|
|
|
+ {
|
|
|
|
|
+ rcWork.right -= m_pVerticalScrollBar->GetFixedWidth();
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (m_pVerticalScrollBar && m_pVerticalScrollBar->IsVisible())
|
|
|
|
|
+ {
|
|
|
|
|
+ rcWork.right -= m_pVerticalScrollBar->GetFixedWidth();
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- int cxNeeded = 0;
|
|
|
|
|
- int nAdjustables = 0;
|
|
|
|
|
- int cyFixed = 0;
|
|
|
|
|
- int nEstimateNum = 0;
|
|
|
|
|
- for (int it1 = 0; it1 < m_items.GetSize(); it1++) {
|
|
|
|
|
- CControlUI* pControl = static_cast<CControlUI*>(m_items[it1]);
|
|
|
|
|
- if (!pControl->IsVisible()) continue;
|
|
|
|
|
- if (pControl->IsFloat()) continue;
|
|
|
|
|
- SIZE sz = pControl->EstimateSize(szAvailable);
|
|
|
|
|
- if (sz.cy == 0) {
|
|
|
|
|
- nAdjustables++;
|
|
|
|
|
|
|
+ if (m_pHorizontalScrollBar && m_pHorizontalScrollBar->IsVisible())
|
|
|
|
|
+ {
|
|
|
|
|
+ rcWork.bottom -= m_pHorizontalScrollBar->GetFixedHeight();
|
|
|
}
|
|
}
|
|
|
- else {
|
|
|
|
|
- if (sz.cy < pControl->GetMinHeight()) sz.cy = pControl->GetMinHeight();
|
|
|
|
|
- if (sz.cy > pControl->GetMaxHeight()) sz.cy = pControl->GetMaxHeight();
|
|
|
|
|
|
|
+
|
|
|
|
|
+ SIZE szAvailable = { rcWork.right - rcWork.left, rcWork.bottom - rcWork.top };
|
|
|
|
|
+ if (m_pHorizontalScrollBar && m_pHorizontalScrollBar->IsVisible())
|
|
|
|
|
+ {
|
|
|
|
|
+ szAvailable.cx += m_pHorizontalScrollBar->GetScrollRange();
|
|
|
}
|
|
}
|
|
|
- cyFixed += sz.cy + pControl->GetPadding().top + pControl->GetPadding().bottom;
|
|
|
|
|
|
|
|
|
|
- RECT rcPadding = pControl->GetPadding();
|
|
|
|
|
- sz.cx = MAX(sz.cx, 0);
|
|
|
|
|
- if (sz.cx < pControl->GetMinWidth()) sz.cx = pControl->GetMinWidth();
|
|
|
|
|
- if (sz.cx > pControl->GetMaxWidth()) sz.cx = pControl->GetMaxWidth();
|
|
|
|
|
- cxNeeded = MAX(cxNeeded, sz.cx);
|
|
|
|
|
- nEstimateNum++;
|
|
|
|
|
- }
|
|
|
|
|
- cyFixed += (nEstimateNum - 1) * iChildPadding;
|
|
|
|
|
|
|
+ int cxNeeded = 0;
|
|
|
|
|
+ int nAdjustables = 0;
|
|
|
|
|
+ int cyFixed = 0;
|
|
|
|
|
+ int nEstimateNum = 0;
|
|
|
|
|
|
|
|
- if (m_pOwner) {
|
|
|
|
|
- CListHeaderUI* pHeader = m_pOwner->GetHeader();
|
|
|
|
|
- if (pHeader != NULL && pHeader->GetCount() > 0) {
|
|
|
|
|
- cxNeeded = MAX(0, pHeader->EstimateSize(CDuiSize(rc.right - rc.left, rc.bottom - rc.top)).cx);
|
|
|
|
|
- if (m_pHorizontalScrollBar && m_pHorizontalScrollBar->IsVisible())
|
|
|
|
|
|
|
+ for (int it1 = 0; it1 < m_items.GetSize(); it1++)
|
|
|
|
|
+ {
|
|
|
|
|
+ CControlUI* pControl = static_cast<CControlUI*>(m_items[it1]);
|
|
|
|
|
+ if (!pControl->IsVisible()) continue;
|
|
|
|
|
+ if (pControl->IsFloat()) continue;
|
|
|
|
|
+
|
|
|
|
|
+ SIZE sz = pControl->EstimateSize(szAvailable);
|
|
|
|
|
+ if (sz.cy == 0)
|
|
|
{
|
|
{
|
|
|
- int nOffset = m_pHorizontalScrollBar->GetScrollPos();
|
|
|
|
|
- RECT rcHeader = pHeader->GetPos();
|
|
|
|
|
- rcHeader.left = rc.left - nOffset;
|
|
|
|
|
- pHeader->SetPos(rcHeader);
|
|
|
|
|
|
|
+ nAdjustables++;
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ if (sz.cy < pControl->GetMinHeight()) sz.cy = pControl->GetMinHeight();
|
|
|
|
|
+ if (sz.cy > pControl->GetMaxHeight()) sz.cy = pControl->GetMaxHeight();
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
- // Place elements
|
|
|
|
|
- int cyNeeded = 0;
|
|
|
|
|
- int cyExpand = 0;
|
|
|
|
|
- if (nAdjustables > 0) cyExpand = MAX(0, (szAvailable.cy - cyFixed) / nAdjustables);
|
|
|
|
|
- // Position the elements
|
|
|
|
|
- SIZE szRemaining = szAvailable;
|
|
|
|
|
- int iPosY = rc.top;
|
|
|
|
|
- if (m_pVerticalScrollBar && m_pVerticalScrollBar->IsVisible()) {
|
|
|
|
|
- iPosY -= m_pVerticalScrollBar->GetScrollPos();
|
|
|
|
|
- }
|
|
|
|
|
- int iPosX = rc.left;
|
|
|
|
|
- if (m_pHorizontalScrollBar && m_pHorizontalScrollBar->IsVisible()) {
|
|
|
|
|
- iPosX -= m_pHorizontalScrollBar->GetScrollPos();
|
|
|
|
|
- }
|
|
|
|
|
- int iAdjustable = 0;
|
|
|
|
|
- int cyFixedRemaining = cyFixed;
|
|
|
|
|
- for (int it2 = 0; it2 < m_items.GetSize(); it2++) {
|
|
|
|
|
- CControlUI* pControl = static_cast<CControlUI*>(m_items[it2]);
|
|
|
|
|
- if (!pControl->IsVisible()) continue;
|
|
|
|
|
- if (pControl->IsFloat()) {
|
|
|
|
|
- SetFloatPos(it2);
|
|
|
|
|
- continue;
|
|
|
|
|
|
|
+ cyFixed += sz.cy + pControl->GetPadding().top + pControl->GetPadding().bottom;
|
|
|
|
|
+
|
|
|
|
|
+ RECT rcPadding = pControl->GetPadding();
|
|
|
|
|
+ sz.cx = MAX(sz.cx, 0);
|
|
|
|
|
+ if (sz.cx < pControl->GetMinWidth()) sz.cx = pControl->GetMinWidth();
|
|
|
|
|
+ if (sz.cx > pControl->GetMaxWidth()) sz.cx = pControl->GetMaxWidth();
|
|
|
|
|
+ cxNeeded = MAX(cxNeeded, sz.cx);
|
|
|
|
|
+ nEstimateNum++;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- RECT rcPadding = pControl->GetPadding();
|
|
|
|
|
- szRemaining.cy -= rcPadding.top;
|
|
|
|
|
- SIZE sz = pControl->EstimateSize(szRemaining);
|
|
|
|
|
- if (sz.cy == 0) {
|
|
|
|
|
- iAdjustable++;
|
|
|
|
|
- sz.cy = cyExpand;
|
|
|
|
|
- // Distribute remaining to last element (usually round-off left-overs)
|
|
|
|
|
- if (iAdjustable == nAdjustables) {
|
|
|
|
|
- sz.cy = MAX(0, szRemaining.cy - rcPadding.bottom - cyFixedRemaining);
|
|
|
|
|
|
|
+ cyFixed += (nEstimateNum - 1) * iChildPadding;
|
|
|
|
|
+
|
|
|
|
|
+ if (m_pOwner)
|
|
|
|
|
+ {
|
|
|
|
|
+ CListHeaderUI* pHeader = m_pOwner->GetHeader();
|
|
|
|
|
+ if (pHeader != NULL && pHeader->GetCount() > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ cxNeeded = MAX(0, pHeader->EstimateSize(CDuiSize(rcWork.right - rcWork.left, rcWork.bottom - rcWork.top)).cx);
|
|
|
|
|
+ if (m_pHorizontalScrollBar && m_pHorizontalScrollBar->IsVisible())
|
|
|
|
|
+ {
|
|
|
|
|
+ int nOffset = m_pHorizontalScrollBar->GetScrollPos();
|
|
|
|
|
+ RECT rcHeader = pHeader->GetPos();
|
|
|
|
|
+ rcHeader.left = rcWork.left - nOffset;
|
|
|
|
|
+ pHeader->SetPos(rcHeader);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- if (sz.cy < pControl->GetMinHeight()) sz.cy = pControl->GetMinHeight();
|
|
|
|
|
- if (sz.cy > pControl->GetMaxHeight()) sz.cy = pControl->GetMaxHeight();
|
|
|
|
|
}
|
|
}
|
|
|
- else {
|
|
|
|
|
- if (sz.cy < pControl->GetMinHeight()) sz.cy = pControl->GetMinHeight();
|
|
|
|
|
- if (sz.cy > pControl->GetMaxHeight()) sz.cy = pControl->GetMaxHeight();
|
|
|
|
|
- cyFixedRemaining -= sz.cy;
|
|
|
|
|
|
|
+
|
|
|
|
|
+ int cyNeeded = 0;
|
|
|
|
|
+ int cyExpand = 0;
|
|
|
|
|
+ if (nAdjustables > 0) cyExpand = MAX(0, (szAvailable.cy - cyFixed) / nAdjustables);
|
|
|
|
|
+
|
|
|
|
|
+ SIZE szRemaining = szAvailable;
|
|
|
|
|
+ int iPosY = rcWork.top;
|
|
|
|
|
+ if (m_pVerticalScrollBar && m_pVerticalScrollBar->IsVisible())
|
|
|
|
|
+ {
|
|
|
|
|
+ iPosY -= m_pVerticalScrollBar->GetScrollPos();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- sz.cx = MAX(cxNeeded, szAvailable.cx - rcPadding.left - rcPadding.right);
|
|
|
|
|
|
|
+ int iPosX = rcWork.left;
|
|
|
|
|
+ if (m_pHorizontalScrollBar && m_pHorizontalScrollBar->IsVisible())
|
|
|
|
|
+ {
|
|
|
|
|
+ iPosX -= m_pHorizontalScrollBar->GetScrollPos();
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- if (sz.cx < pControl->GetMinWidth()) sz.cx = pControl->GetMinWidth();
|
|
|
|
|
- if (sz.cx > pControl->GetMaxWidth()) sz.cx = pControl->GetMaxWidth();
|
|
|
|
|
|
|
+ int iAdjustable = 0;
|
|
|
|
|
+ int cyFixedRemaining = cyFixed;
|
|
|
|
|
|
|
|
- RECT rcCtrl = { iPosX + rcPadding.left, iPosY + rcPadding.top, iPosX + rcPadding.left + sz.cx, iPosY + sz.cy + rcPadding.top + rcPadding.bottom };
|
|
|
|
|
- pControl->SetPos(rcCtrl);
|
|
|
|
|
|
|
+ for (int it2 = 0; it2 < m_items.GetSize(); it2++)
|
|
|
|
|
+ {
|
|
|
|
|
+ CControlUI* pControl = static_cast<CControlUI*>(m_items[it2]);
|
|
|
|
|
+ if (!pControl->IsVisible()) continue;
|
|
|
|
|
+ if (pControl->IsFloat())
|
|
|
|
|
+ {
|
|
|
|
|
+ SetFloatPos(it2);
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- iPosY += sz.cy + iChildPadding + rcPadding.top + rcPadding.bottom;
|
|
|
|
|
- cyNeeded += sz.cy + rcPadding.top + rcPadding.bottom;
|
|
|
|
|
- szRemaining.cy -= sz.cy + iChildPadding + rcPadding.bottom;
|
|
|
|
|
- }
|
|
|
|
|
- cyNeeded += (nEstimateNum - 1) * iChildPadding;
|
|
|
|
|
|
|
+ RECT rcPadding = pControl->GetPadding();
|
|
|
|
|
+ szRemaining.cy -= rcPadding.top;
|
|
|
|
|
+ SIZE sz = pControl->EstimateSize(szRemaining);
|
|
|
|
|
|
|
|
- if (m_pHorizontalScrollBar != NULL) {
|
|
|
|
|
- if (cxNeeded > rc.right - rc.left) {
|
|
|
|
|
- if (m_pHorizontalScrollBar->IsVisible()) {
|
|
|
|
|
- m_pHorizontalScrollBar->SetScrollRange(cxNeeded - (rc.right - rc.left));
|
|
|
|
|
|
|
+ if (sz.cy == 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ iAdjustable++;
|
|
|
|
|
+ sz.cy = cyExpand;
|
|
|
|
|
+ if (iAdjustable == nAdjustables)
|
|
|
|
|
+ {
|
|
|
|
|
+ sz.cy = MAX(0, szRemaining.cy - rcPadding.bottom - cyFixedRemaining);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (sz.cy < pControl->GetMinHeight()) sz.cy = pControl->GetMinHeight();
|
|
|
|
|
+ if (sz.cy > pControl->GetMaxHeight()) sz.cy = pControl->GetMaxHeight();
|
|
|
}
|
|
}
|
|
|
- else {
|
|
|
|
|
- m_pHorizontalScrollBar->SetVisible(true);
|
|
|
|
|
- m_pHorizontalScrollBar->SetScrollRange(cxNeeded - (rc.right - rc.left));
|
|
|
|
|
- m_pHorizontalScrollBar->SetScrollPos(0);
|
|
|
|
|
- rc.bottom -= m_pHorizontalScrollBar->GetFixedHeight();
|
|
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ if (sz.cy < pControl->GetMinHeight()) sz.cy = pControl->GetMinHeight();
|
|
|
|
|
+ if (sz.cy > pControl->GetMaxHeight()) sz.cy = pControl->GetMaxHeight();
|
|
|
|
|
+ cyFixedRemaining -= sz.cy;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ sz.cx = MAX(cxNeeded, szAvailable.cx - rcPadding.left - rcPadding.right);
|
|
|
|
|
+ if (sz.cx < pControl->GetMinWidth()) sz.cx = pControl->GetMinWidth();
|
|
|
|
|
+ if (sz.cx > pControl->GetMaxWidth()) sz.cx = pControl->GetMaxWidth();
|
|
|
|
|
+
|
|
|
|
|
+ RECT rcCtrl = {
|
|
|
|
|
+ iPosX + rcPadding.left,
|
|
|
|
|
+ iPosY + rcPadding.top,
|
|
|
|
|
+ iPosX + rcPadding.left + sz.cx,
|
|
|
|
|
+ iPosY + sz.cy + rcPadding.top + rcPadding.bottom
|
|
|
|
|
+ };
|
|
|
|
|
+ pControl->SetPos(rcCtrl);
|
|
|
|
|
+
|
|
|
|
|
+ iPosY += sz.cy + iChildPadding + rcPadding.top + rcPadding.bottom;
|
|
|
|
|
+ cyNeeded += sz.cy + rcPadding.top + rcPadding.bottom;
|
|
|
|
|
+ szRemaining.cy -= sz.cy + iChildPadding + rcPadding.bottom;
|
|
|
}
|
|
}
|
|
|
- else {
|
|
|
|
|
- if (m_pHorizontalScrollBar->IsVisible()) {
|
|
|
|
|
- m_pHorizontalScrollBar->SetVisible(false);
|
|
|
|
|
- m_pHorizontalScrollBar->SetScrollRange(0);
|
|
|
|
|
- m_pHorizontalScrollBar->SetScrollPos(0);
|
|
|
|
|
- rc.bottom += m_pHorizontalScrollBar->GetFixedHeight();
|
|
|
|
|
|
|
+
|
|
|
|
|
+ cyNeeded += (nEstimateNum - 1) * iChildPadding;
|
|
|
|
|
+
|
|
|
|
|
+ if (m_pHorizontalScrollBar != NULL)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (cxNeeded > rcWork.right - rcWork.left)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (m_pHorizontalScrollBar->IsVisible())
|
|
|
|
|
+ {
|
|
|
|
|
+ m_pHorizontalScrollBar->SetScrollRange(cxNeeded - (rcWork.right - rcWork.left));
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ m_pHorizontalScrollBar->SetVisible(true);
|
|
|
|
|
+ m_pHorizontalScrollBar->SetScrollRange(cxNeeded - (rcWork.right - rcWork.left));
|
|
|
|
|
+ m_pHorizontalScrollBar->SetScrollPos(0);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ if (m_pHorizontalScrollBar->IsVisible())
|
|
|
|
|
+ {
|
|
|
|
|
+ m_pHorizontalScrollBar->SetVisible(false);
|
|
|
|
|
+ m_pHorizontalScrollBar->SetScrollRange(0);
|
|
|
|
|
+ m_pHorizontalScrollBar->SetScrollPos(0);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
- UINT uListType = m_pOwner->GetListType();
|
|
|
|
|
- if (uListType == LT_LIST) {
|
|
|
|
|
- // 计算横向尺寸
|
|
|
|
|
- int nItemCount = m_items.GetSize();
|
|
|
|
|
- if (nItemCount > 0)
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (m_pOwner->GetListType() == LT_LIST)
|
|
|
{
|
|
{
|
|
|
- CControlUI* pControl = static_cast<CControlUI*>(m_items[0]);
|
|
|
|
|
- int nFixedWidth = pControl->GetFixedWidth();
|
|
|
|
|
- if (nFixedWidth > 0)
|
|
|
|
|
|
|
+ int nItemCount = m_items.GetSize();
|
|
|
|
|
+ if (nItemCount > 0)
|
|
|
{
|
|
{
|
|
|
- int nRank = (rc.right - rc.left) / nFixedWidth;
|
|
|
|
|
- if (nRank > 0)
|
|
|
|
|
|
|
+ CControlUI* pControl = static_cast<CControlUI*>(m_items[0]);
|
|
|
|
|
+ int nFixedWidth = pControl->GetFixedWidth();
|
|
|
|
|
+ if (nFixedWidth > 0)
|
|
|
{
|
|
{
|
|
|
- cyNeeded = ((nItemCount - 1) / nRank + 1) * pControl->GetFixedHeight();
|
|
|
|
|
|
|
+ int nRank = (rcWork.right - rcWork.left) / nFixedWidth;
|
|
|
|
|
+ if (nRank > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ cyNeeded = ((nItemCount - 1) / nRank + 1) * pControl->GetFixedHeight();
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ ProcessScrollBar(rcWork, cxNeeded, cyNeeded);
|
|
|
}
|
|
}
|
|
|
- // Process the scrollbar
|
|
|
|
|
- ProcessScrollBar(rc, cxNeeded, cyNeeded);
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void CListBodyUI::DoEvent(TEventUI& event)
|
|
void CListBodyUI::DoEvent(TEventUI& event)
|