Ejemplo n.º 1
0
void ListItem::onResize(ResizeEvent& ev)
{
  setBoundsQuietly(ev.getBounds());

  Rect crect = getChildrenBounds();
  UI_FOREACH_WIDGET(getChildren(), it)
    (*it)->setBounds(crect);
}
Ejemplo n.º 2
0
void StatusBar::onResize(ResizeEvent& ev)
{
  setBoundsQuietly(ev.getBounds());

  Rect rc = ev.getBounds();
  rc.x = rc.x2() - m_notificationsBox->getPreferredSize().w;
  rc.w = m_notificationsBox->getPreferredSize().w;
  m_notificationsBox->setBounds(rc);

  rc = ev.getBounds();
  rc.w -= rc.w/4 + 4*jguiscale();
  m_commandsBox->setBounds(rc);
}
Ejemplo n.º 3
0
void ListBox::onResize(ResizeEvent& ev)
{
  setBoundsQuietly(ev.getBounds());

  Rect cpos = getChildrenBounds();

  UI_FOREACH_WIDGET(getChildren(), it) {
    Widget* child = *it;

    cpos.h = child->getPreferredSize().h;
    child->setBounds(cpos);

    cpos.y += child->getBounds().h + this->childSpacing();
  }
Ejemplo n.º 4
0
void Splitter::onResize(ResizeEvent& ev)
{
#define FIXUP(x, y, w, h, l, t, r, b)                                   \
  do {                                                                  \
    avail = rect.w - this->child_spacing;                               \
                                                                        \
    pos.x = rect.x;                                                     \
    pos.y = rect.y;                                                     \
    switch (m_type) {                                                   \
      case ByPercentage:                                                \
        pos.w = avail*m_pos/100;                                        \
        break;                                                          \
      case ByPixel:                                                     \
        pos.w = m_pos;                                                  \
        break;                                                          \
    }                                                                   \
                                                                        \
    /* TODO uncomment this to make a restricted splitter */             \
    /* pos.w = MID(reqSize1.w, pos.w, avail-reqSize2.w); */             \
    pos.h = rect.h;                                                     \
                                                                        \
    child1->setBounds(pos);                                             \
    gfx::Rect child1Pos = child1->getBounds();                          \
                                                                        \
    pos.x = child1Pos.x + child1Pos.w + this->child_spacing;            \
    pos.y = rect.y;                                                     \
    pos.w = avail - child1Pos.w;                                        \
    pos.h = rect.h;                                                     \
                                                                        \
    child2->setBounds(pos);                                             \
  } while(0)

  gfx::Rect rect(ev.getBounds());
  gfx::Rect pos(0, 0, 0, 0);
  int avail;

  setBoundsQuietly(rect);

  if (getChildren().size() == 2) {
    Widget* child1 = getChildren()[0];
    Widget* child2 = getChildren()[1];

    if (this->getAlign() & JI_HORIZONTAL)
      FIXUP(x, y, w, h, l, t, r, b);
    else
      FIXUP(y, x, h, w, t, l, b, r);
  }
}
Ejemplo n.º 5
0
void Menu::onResize(ResizeEvent& ev)
{
  setBoundsQuietly(ev.getBounds());

  Rect cpos = getChildrenBounds();
  bool isBar = (getParent()->type == kMenuBarWidget);

  UI_FOREACH_WIDGET(getChildren(), it) {
    Widget* child = *it;
    Size reqSize = child->getPreferredSize();

    if (isBar)
      cpos.w = reqSize.w;
    else
      cpos.h = reqSize.h;

    child->setBounds(cpos);

    if (isBar)
      cpos.x += cpos.w;
    else
      cpos.y += cpos.h;
  }
Ejemplo n.º 6
0
void Menu::onResize(ResizeEvent& ev)
{
  setBoundsQuietly(ev.bounds());

  Rect cpos = childrenBounds();
  bool isBar = (parent()->type() == kMenuBarWidget);

  for (auto child : children()) {
    Size reqSize = child->sizeHint();

    if (isBar)
      cpos.w = reqSize.w;
    else
      cpos.h = reqSize.h;

    child->setBounds(cpos);

    if (isBar)
      cpos.x += cpos.w;
    else
      cpos.y += cpos.h;
  }
}