void BasicContainer::ShowWidgetPart( WidgetPtr widget, Rectangle area ) { Rectangle widgetArea = getChildrenArea(); area.x += widget->GetX(); area.y += widget->GetY(); if (area.x + area.width > widgetArea.width) { widget->SetX(widget->GetX() - area.x - area.width + widgetArea.width); } if (area.y + area.height > widgetArea.height) { widget->SetY(widget->GetY() - area.y - area.height + widgetArea.height); } if (area.x < 0) { widget->SetX(widget->GetX() - area.x); } if (area.y < 0) { widget->SetY(widget->GetY() - area.y); } }
void Stack::AddChild( WidgetPtr child ) { int x = 0; int y = 0; if (mWidgets.size() > 0) { WidgetPtr last = mWidgets.back(); if (mOrientation == OrientationVertical) { y = last->GetY() + last->GetHeight() + mSpacing; } else { x = last->GetX() + last->GetWidth() + mSpacing; } } child->SetPosition(x, y); BasicContainer::Add(child); if (mOrientation == OrientationVertical) { SetSize(std::max(GetWidth(), child->GetWidth()), y + child->GetHeight()); } else { SetSize(x + child->GetWidth(), std::max(GetHeight(), child->GetHeight())); } }