Example #1
0
 void NFrameBase::AutoSize()
 {
     if(!IsAutoSize() || layout_ != LayoutNone)
         return;
     Base::NSize autoSize = GetAutoSize();
     SetSizeImpl(autoSize.Width, autoSize.Height, true);
 }
Example #2
0
 void NFrameBase::SetMinSize(int minWidth, int minHeight)
 {
     if(minSize_.Width == minWidth && minSize_.Height == minHeight)
         return;
     minSize_.Width = minWidth;
     minSize_.Height = minHeight;
     int width = frameRect_.Width() < minSize_.Width ? minSize_.Width : frameRect_.Width();
     int height = frameRect_.Height() < minSize_.Height ? minSize_.Height : frameRect_.Height();
     SetSizeImpl(width, height, true);
 }
Example #3
0
 bool NFrameBase::AutoSize()
 {
     if(layout_ != LayoutNone)
     {
         ReLayout();
         return true;
     }
     if(!IsAutoSize())
         return false;
     Base::NSize autoSize = GetAutoSize();
     return SetSizeImpl(autoSize.Width, autoSize.Height, true);
 }
Example #4
0
 bool NFrameBase::SetMaxSize(int maxWidth, int maxHeight)
 {
     if(maxSize_.Width == maxWidth && maxSize_.Height == maxHeight)
         return false;
     maxSize_.Width = maxWidth;
     maxSize_.Height = maxHeight;
     if(IsAutoSize())
     {
         return AutoSize();
     }
     else if(frameRect_.Width() > maxSize_.Width || frameRect_.Height() > maxSize_.Height)
     {
         int width = frameRect_.Width() > maxSize_.Width ? maxSize_.Width : frameRect_.Width();
         int height = frameRect_.Height() > maxSize_.Height ? maxSize_.Height : frameRect_.Height();
         return SetSizeImpl(width, height, true);
     }
     return false;
 }
Example #5
0
        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);
        }
Example #6
0
 void NFrameBase::SetSize(int width, int height)
 {
     SetSizeImpl(width, height, false);
 }
Example #7
0
        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);
        }
Example #8
0
 bool NFrameBase::SetSize(int width, int height)
 {
     return SetSizeImpl(width, height, false);
 }