// layman.cpp : レイアウトマネージャ // #include "stdafx.h" #include "layman.h" void CLayoutManager::CData::SetLen(CWnd* p) { CWnd* prt = p->GetParent(); if (!prt) return; CRect r0,r; prt->GetWindowRect(&r0); p->GetWindowRect(&r); m_lenH = r0.right - r.right; m_lenV = r0.bottom - r.bottom; } void CLayoutManager::CData::MovWnd(CWnd* p) { CWnd* prt = p->GetParent(); if (!prt) return; CRect r0,r; prt->GetWindowRect(&r0); p->GetWindowRect(&r); CPoint pnt = r0.BottomRight(); if (m_typeH != Default) { if (m_typeH == FixSize) r.left += r0.right - m_lenH - r.right; r.right = r0.right - m_lenH; } if (m_typeV != Default) { if (m_typeV == FixSize) r.top += r0.bottom - m_lenV - r.bottom; r.bottom = r0.bottom - m_lenV; } prt->GetClientRect(&r0); r.OffsetRect(r0.BottomRight()-pnt+CSize(4,4)); p->MoveWindow(r); } void CLayoutManager::SetType(CWnd* p,EType th,EType tv) { ASSERT(p); CData& dt = m_data[p]; dt.m_typeH = th; dt.m_typeV = tv; } void CLayoutManager::Reset() { map::iterator it; for (it=m_data.begin();it!=m_data.end();++it) { it->second.SetLen(it->first); } } void CLayoutManager::Layout() { CWnd* p = 0; map::iterator it; for (it=m_data.begin();it!=m_data.end();++it) { it->second.MovWnd(it->first); if (!p) p = it->first->GetParent(); } if (p) p->Invalidate(); } void CLayoutManager::Clear() { m_data.clear(); }