示例#1
0
void StackedLayout::resizeStart ()
{
  int minW = 0;
  int minH = 0;

  if (m_vertical)
  {
    for (size_t i = 0; i < m_bands.size(); ++i)
    {
      ResizableChild* c = m_bands[i].resizableChild;
      if (c)
        c->resizeStart ();
    }

    for (size_t i = 0; i < m_bands.size(); ++i)
    {
      ResizableChild* c = m_bands[i].resizableChild;
      if (c)
        c->resizeStart ();
    }

    minH = m_borderSize.getTop();
    int lastH = -1;

    for (size_t i = 0; i < m_bands.size(); ++i)
    {
      Component* c = m_bands[i].component;
      if (c->isVisible ())
      {
        if (lastH != -1)
        {
          minH += m_gapSize + lastH;
        }

        ResizableChild* rc = m_bands[i].resizableChild;
        if (rc)
        {
          lastH = rc->getMinimumHeight ();

          minW = jmax (minW, rc->getMinimumWidth ());
        }
        else
        {
          lastH = m_bands[i].component->getHeight ();
        }
      }
    }

    if (lastH != -1)
    {
      minH += lastH + m_borderSize.getBottom ();
    }
  }
  else
  {
    for (size_t i = 0; i < m_bands.size(); ++i)
    {
      ResizableChild* c = m_bands[i].resizableChild;
      if (c)
        c->resizeStart ();
    }

    for (size_t i = 0; i < m_bands.size(); ++i)
    {
      ResizableChild* c = m_bands[i].resizableChild;
      if (c)
        c->resizeStart ();
    }

    minW = m_borderSize.getLeft ();
    int lastH = -1;

    for (size_t i = 0; i < m_bands.size(); ++i)
    {
      Component* c = m_bands[i].component;
      if (c->isVisible ())
      {
        if (lastH != -1)
        {
          minH += m_gapSize + lastH;
        }

        ResizableChild* rc = m_bands[i].resizableChild;
        if (rc)
        {
          lastH = rc->getMinimumWidth ();

          minH = jmax (minW, rc->getMinimumHeight ());
        }
        else
        {
          lastH = m_bands[i].component->getWidth ();
        }
      }
    }

    if (lastH != -1)
    {
      minW += lastH + m_borderSize.getRight ();
    }
  }

  setMinimumWidth (minW);
  setMinimumHeight (minH);
}