void NFrameBase::ReLayout() { if(layout_ == LayoutNone) return; int width = 0; int height = 0; if(GetParent() != NULL) { Base::NRect rcParent = GetParent()->GetRect(); width = rcParent.Width(); height = rcParent.Height(); } else if(window_ != NULL) { Base::NRect rcWnd; window_->GetRect(rcWnd); width = rcWnd.Width(); height = rcWnd.Height(); } else { return; } Base::NSize size = GetAutoSize(); Base::NRect rcNew; if(layout_ & LayoutLeft) { rcNew.Left = margin_.Left; rcNew.Right = rcNew.Left + size.Width; } else if(layout_ & LayoutRight) { rcNew.Right = width - margin_.Right; rcNew.Left = rcNew.Right - size.Width; } else if(layout_ & LayoutHCenter) { rcNew.Left = (width - margin_.Width() - size.Width) / 2; rcNew.Right = rcNew.Left + size.Width; } else if(layout_ & LayoutHFill) { rcNew.Left = margin_.Left; rcNew.Right = width - margin_.Right; } if(layout_ & LayoutTop) { rcNew.Top = margin_.Top; rcNew.Bottom = rcNew.Top + size.Height; } else if(layout_ & LayoutBottom) { rcNew.Bottom = height - margin_.Bottom; rcNew.Top = rcNew.Bottom - size.Height; } else if(layout_ & LayoutVCenter) { rcNew.Top = (height - margin_.Height() - size.Height) / 2; rcNew.Bottom = rcNew.Top + size.Height; } else if(layout_ & LayoutVFill) { rcNew.Top = margin_.Top; rcNew.Bottom = height - margin_.Bottom; } SetPosImpl(rcNew.Left, rcNew.Top, true); SetSizeImpl(rcNew.Width(), rcNew.Height(), true); }
void NFrameBase::ReLayout() { if(layout_ == LayoutNone || !IsLayoutable()) return; int width = 0; int height = 0; if(GetParent() != NULL) { Base::NRect rcParent = GetParent()->GetRect(); width = rcParent.Width(); height = rcParent.Height(); } else if(window_ != NULL) { Base::NRect rcWnd; window_->GetRect(rcWnd); width = rcWnd.Width(); height = rcWnd.Height(); } else { return; } Base::NSize size = IsAutoSize() ? GetAutoSize() : frameRect_.GetSize(); Base::NRect rcNew(frameRect_.Left, frameRect_.Top, frameRect_.Left + size.Width, frameRect_.Top + size.Height); if(layout_ & LayoutHFill) { rcNew.Left = margin_.Left; rcNew.Right = width - margin_.Right; } else if(layout_ & LayoutHCenter) { size.Width = (minSize_.Width <= 0 || size.Width > minSize_.Width) ? size.Width : minSize_.Width; size.Width = (maxSize_.Width <= 0 || size.Width < maxSize_.Width) ? size.Width : maxSize_.Width; rcNew.Left = (width - margin_.Width() - size.Width) / 2; rcNew.Right = rcNew.Left + size.Width; } else if(layout_ & LayoutLeft) { rcNew.Left = margin_.Left; rcNew.Right = rcNew.Left + size.Width; } else if(layout_ & LayoutRight) { rcNew.Right = width - margin_.Right; rcNew.Left = rcNew.Right - size.Width; } if(layout_ & LayoutVFill) { rcNew.Top = margin_.Top; rcNew.Bottom = height - margin_.Bottom; } else if(layout_ & LayoutVCenter) { size.Height = (minSize_.Height <= 0 || size.Height > minSize_.Height) ? size.Height : minSize_.Height; size.Height = (maxSize_.Height <= 0 || size.Height < maxSize_.Height) ? size.Height : maxSize_.Height; rcNew.Top = (height - margin_.Height() - size.Height) / 2; rcNew.Bottom = rcNew.Top + size.Height; } else if(layout_ & LayoutTop) { rcNew.Top = margin_.Top; rcNew.Bottom = rcNew.Top + size.Height; } else if(layout_ & LayoutBottom) { rcNew.Bottom = height - margin_.Bottom; rcNew.Top = rcNew.Bottom - size.Height; } SetPosImpl(rcNew.Left, rcNew.Top, true); SetSizeImpl(rcNew.Width(), rcNew.Height(), true); }
void NFrameBase::SetPos(int left, int top) { SetPosImpl(left, top, false); }
bool NFrameBase::SetPos(int left, int top) { return SetPosImpl(left, top, false); }