Ejemplo n.º 1
0
void Window::mousePressed(gcn::MouseEvent &event)
{
    // Let Guichan move window to top and figure out title bar drag
    gcn::Window::mousePressed(event);

    if (event.getButton() == gcn::MouseEvent::LEFT)
    {
        const int x = event.getX();
        const int y = event.getY();

        // Handle close button
        if (mCloseButton)
        {
            gcn::Rectangle closeButtonRect(
                getWidth() - mSkin->getCloseImage()->getWidth() - getPadding(),
                getPadding(),
                mSkin->getCloseImage()->getWidth(),
                mSkin->getCloseImage()->getHeight());

            if (closeButtonRect.isPointInRect(x, y))
                close();
        }

        // Handle window resizing
        mouseResize = getResizeHandles(event);
    }
}
Ejemplo n.º 2
0
EditDialog::EditDialog(const std::string &title, const std::string &msg,
                       const std::string &eventOk, const int width,
                       Window *const parent, const bool modal):
    Window(title, modal, parent, "edit.xml"),
    gcn::ActionListener(),
    mEventOk(eventOk),
    mTextField(new TextField(this))
{
    mTextField->setText(msg);
    // TRANSLATORS: edit dialog label
    Button *const okButton = new Button(this, _("OK"), mEventOk, this);

    const int numRows = 1;
    const int fontHeight = getFont()->getHeight();
    const int height = numRows * fontHeight;

    setContentSize(width, height + fontHeight + okButton->getHeight());
    mTextField->setPosition(getPadding(), getPadding());
    mTextField->setWidth(width - (2 * getPadding()));

    okButton->setPosition((width - okButton->getWidth()) / 2,
        height + getOption("buttonPadding", 8));

    add(mTextField);
    add(okButton);

    center();
    setVisible(true);
    okButton->requestFocus();
}
Ejemplo n.º 3
0
void Panel::calcSize()
{
	int width = 0;
	int height = 0;

	// sucht die width/height indem alle Komponenten durchlaufen werden und die am weitesten rechts und unten gespeichert werden
	for (unsigned int i = 0; i < getComponents().size(); i++)
	{
		width = std::max(width, getComponents()[i]->getRelativeRect().getRight() + getPadding().x);
		height = std::max(height, getComponents()[i]->getRelativeRect().getBot() + getPadding().y);
	}

	if (width != getRelativeRect().getSize().x)
	{
		setRelativeRect(PixelRect(
			getRelativeRect().getPosition().x,
			getRelativeRect().getPosition().y,
			width,
			getRelativeRect().getSize().y));
	}

	if (height != getRelativeRect().getSize().y)
	{
		setRelativeRect(PixelRect(
			getRelativeRect().getPosition().x,
			getRelativeRect().getPosition().y,
			getRelativeRect().getSize().x,
			height));
	}
}
Ejemplo n.º 4
0
void Layout::onStateChange()
{
    if(myIsHandlingStateChange)
        return;

    myIsHandlingStateChange = true;

    sf::Vector2f position = getPadding();
    for(int index = 0, size = getNumChildren(); index < size; index++)
    {
        std::shared_ptr<Widget> child = getChild(index);
        child->setPosition(position);
        if(myStyle == Style::Vertical)
        {
            position.y += child->getSize().y + getPadding().y;
        }
        else
        {
            position.x += child->getSize().x + getPadding().x;
        }
    }

    setSize(getSize() + getPadding());

    myIsHandlingStateChange = false;

    Container::onStateChange();
}
Ejemplo n.º 5
0
void Window::draw(gcn::Graphics *graphics)
{
    Graphics *g = static_cast<Graphics*>(graphics);

    g->drawImageRect(0, 0, getWidth(), getHeight(), mSkin->getBorder());

    // Draw title
    if (mShowTitle)
    {
        g->setColor(Theme::getThemeColor(Theme::TEXT));
        g->setFont(getFont());
        g->drawText(getCaption(), 7, 5, gcn::Graphics::LEFT);
    }

    // Draw Close Button
    if (mCloseButton)
    {
        g->drawImage(mSkin->getCloseImage(),
            getWidth() - mSkin->getCloseImage()->getWidth() - getPadding(),
            getPadding());
    }

    // Draw Sticky Button
    if (mStickyButton)
    {
        Image *button = mSkin->getStickyImage(mSticky);
        int x = getWidth() - button->getWidth() - getPadding();
        if (mCloseButton)
            x -= mSkin->getCloseImage()->getWidth();

        g->drawImage(button, x, getPadding());
    }

    drawChildren(graphics);
}
Ejemplo n.º 6
0
 void generateStats(struct Stats& stats) {
     stats.uninhabitable += getPadding();
     stats.totalMetaData += bitsPerPage-getPadding()-getDataBits()*getMaxCount();
     stats.inhabitedMetaData += (getSizeBits()+architectureSize)*header.count;
     stats.totalPayload += getDataBits()*getMaxCount();
     stats.inhabitedPayload += getDataBits()*header.count;
 }
Ejemplo n.º 7
0
std::string Sequence::getCStylePattern() const
{
	if( getPadding() )
		return getPrefix() + "%0" + boost::lexical_cast<std::string > ( getPadding() ) + "d" + getSuffix();
	else
		return getPrefix() + "%d" + getSuffix();
}
Ejemplo n.º 8
0
ItemPopup::ItemPopup():
    Popup("ItemPopup"),
    mIcon(0)
{
    // Item Name
    mItemName = new Label;
    mItemName->setFont(boldFont);
    mItemName->setPosition(getPadding(), getPadding());

    // Item Description
    mItemDesc = new TextBox;
    mItemDesc->setEditable(false);

    // Item Effect
    mItemEffect = new TextBox;
    mItemEffect->setEditable(false);

    // Item Weight
    mItemWeight = new TextBox;
    mItemWeight->setEditable(false);

    mIcon = new Icon(0);

    add(mItemName);
    add(mItemDesc);
    add(mItemEffect);
    add(mItemWeight);
    add(mIcon);

    addMouseListener(this);
}
Ejemplo n.º 9
0
 Rectangle Window::getChildrenArea()
 {
     return Rectangle(getPadding(),
                      getTitleBarHeight(),
                      getWidth() - getPadding() * 2,
                      getHeight() - getPadding() - getTitleBarHeight());
 }
Ejemplo n.º 10
0
void Minimap::setMap(Map *map)
{
    // Set the title for the Minimap
    std::string caption;

    if (map)
        caption = map->getName();

    if (caption.empty())
        caption = _("Map");

    minimap->setCaption(caption);

    // Adapt the image
    if (mMapImage)
    {
        mMapImage->decRef();
        mMapImage = 0;
    }

    if (map)
    {
        ResourceManager *resman = ResourceManager::getInstance();
        mMapImage = resman->getImage(map->getProperty("minimap"));
    }

    if (mMapImage)
    {
        const int offsetX = 2 * getPadding();
        const int offsetY = getTitleBarHeight() + getPadding();
        const int titleWidth = getFont()->getWidth(getCaption()) + 15;
        const int mapWidth = mMapImage->getWidth() < 100 ?
                             mMapImage->getWidth() + offsetX : 100;
        const int mapHeight = mMapImage->getHeight() < 100 ?
                              mMapImage->getHeight() + offsetY : 100;

        setMinWidth(mapWidth > titleWidth ? mapWidth : titleWidth);
        setMinHeight(mapHeight);

        mWidthProportion = (float) mMapImage->getWidth() / map->getWidth();
        mHeightProportion = (float) mMapImage->getHeight() / map->getHeight();

        setMaxWidth(mMapImage->getWidth() > titleWidth ?
                    mMapImage->getWidth() + offsetX : titleWidth);
        setMaxHeight(mMapImage->getHeight() + offsetY);

        setDefaultSize(getX(), getY(), getWidth(), getHeight());
        resetToDefaultSize();

        if (mShow)
            setVisible(true);
    }
    else
    {
        if (!isSticky())
            setVisible(false);
    }
}
Ejemplo n.º 11
0
void Node::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *ev)
{
    QString new_text = QInputDialog::getText(ev->widget(), QObject::tr("Редактирование текста"), QObject::tr("Введите новый текст"), QLineEdit::Normal, text);
    if (!new_text.isEmpty())
    {
        setText(new_text);
        setPadding(getPadding().width(), getPadding().height());
    }
}
Ejemplo n.º 12
0
void PlayerOctopus::update()
{
    if (isActive() && _character)
    {
        // update position based on cell

        //LOGINFO << "Position: " << getPosition() << endl;
        if (!real_cell)
            teleport(real_cell = _character->getCell());
        else if (!move_wanted)
        {
            teleport(real_cell = destination_cell);
            moving = false;
            pathNext();
        }
        else if (real_cell != destination_cell && _land_time + move_delay < TIMESERVICE->time())
        {
            //LOGINFO << "Moving" << endl;

            // delta time in milliseconds
            Uint32 dt = (TIMESERVICE->time() - movement_begin);

            Point origin_pos = toContainerCoordinates(_grid->toAbsoluteCoordinates(_grid->getCellCenter(real_cell)));
            Point dest_pos = toContainerCoordinates(_grid->toAbsoluteCoordinates(_grid->getCellCenter(destination_cell)));
            Point delta = abs(origin_pos - dest_pos);
            Point middle = (origin_pos - dest_pos) / 2;

            Point step = ((dest_pos - origin_pos) * dt)/move_time;

            // jump
            Point jump(0, sqrt(pow(jump_height, 2) - (pow(jump_height,2) * abs(delta.y - step.y))/pow( delta.y, 2)));

            Point pos = origin_pos + step - jump;
            Point newPos = pos + getPadding();


            step = abs(step);
            if (step.x >= delta.x && step.y >= delta.y)
            {
                //LOGINFO << "Landing on new cell" << endl;
                newPos = dest_pos + getPadding();
                real_cell = destination_cell;

                moving = false;

                _grid->unmark(destination_cell->getNumber());
                pathNext();
            }

            setPosition(newPos);
        }

        // update z-index
        setZIndex(_grid->getZIndexFromCell(destination_cell->getNumber()));
    }
}
Ejemplo n.º 13
0
void Window::widgetResized(const gcn::Event &event)
{
    const gcn::Rectangle area = getChildrenArea();

    if (mGrip)
        mGrip->setPosition(getWidth() - mGrip->getWidth() - area.x,
                           getHeight() - mGrip->getHeight() - area.y);

    if (mClose)
        mClose->setPosition(getWidth() - getPadding() - mClose->getWidth(),
                            getPadding());

    refreshLayout();
}
Ejemplo n.º 14
0
void Windowiki::mousePressed(gcn::MouseEvent &event)
{
    // Let Guichan move window to top and figure out title bar drag
    gcn::Window::mousePressed(event);

    const int x = event.getX();
    const int y = event.getY();
    mMouseResize = 0;

    // Activate resizing handles as appropriate
    if (event.getSource() == this && isResizable() &&
            event.getButton() == gcn::MouseEvent::LEFT &&
            !getChildrenArea().isPointInRect(x, y))
    {
        mMouseResize |= (x > getWidth() - resizeBorderWidthiki) ? RIGHT :
                        (x < resizeBorderWidthiki) ? LEFT : 0;
        mMouseResize |= (y > getHeight() - resizeBorderWidthiki) ? BOTTOM :
                        (y < resizeBorderWidthiki) ? TOP : 0;
    }
    else if (event.getSource() == mGrip)
    {
        mDragOffsetX = x + mGrip->getX();
        mDragOffsetY = y + mGrip->getY();
        mMouseResize |= BOTTOM | RIGHT;
        mIsMoving = false;
    }

    if (event.getButton() == gcn::MouseEvent::LEFT)
    {
        const int x = event.getX();
        const int y = event.getY();

        // Handle close button
        if (mCloseButton)
        {
            gcn::Rectangle closeButtonRect(
                getWidth() - closeImage->getWidth() - getPadding(),
                getPadding(),
                closeImage->getWidth(),
                closeImage->getHeight());

            if (closeButtonRect.isPointInRect(x, y))
            {
                setVisible(false);
            }
        }

        // Handle window resizing
    }
}
Ejemplo n.º 15
0
void ItemPopup::setItem(const ItemInfo &item)
{
    if (item.getName() == mItemName->getCaption())
        return;

    mItemType = item.getType();

    mItemName->setCaption(item.getName());
    mItemName->adjustSize();
    mItemName->setForegroundColor(getColor(mItemType));

    mItemDesc->setTextWrapped(item.getDescription(), 196);
    mItemEffect->setTextWrapped(item.getEffect(), 196);
    mItemWeight->setTextWrapped(strprintf(_("Weight: %s"),
                                Units::formatWeight(item.getWeight()).c_str()),
                                196);

    int minWidth = mItemName->getWidth();

    if (mItemDesc->getMinWidth() > minWidth)
        minWidth = mItemDesc->getMinWidth();
    if (mItemEffect->getMinWidth() > minWidth)
        minWidth = mItemEffect->getMinWidth();
    if (mItemWeight->getMinWidth() > minWidth)
        minWidth = mItemWeight->getMinWidth();

    minWidth += 8;
    setWidth(minWidth);

    const int numRowsDesc = mItemDesc->getNumberOfRows();
    const int numRowsEffect = mItemEffect->getNumberOfRows();
    const int numRowsWeight = mItemWeight->getNumberOfRows();
    const int height = getFont()->getHeight();

    if (item.getEffect().empty())
    {
        setContentSize(minWidth, (numRowsDesc + numRowsWeight + getPadding()) *
                       height);

        mItemWeight->setPosition(getPadding(), (numRowsDesc + getPadding()) *
                                 height);
    }
    else
    {
        setContentSize(minWidth, (numRowsDesc + numRowsEffect + numRowsWeight +
                       getPadding()) * height);

        mItemWeight->setPosition(getPadding(), (numRowsDesc + numRowsEffect +
                                 getPadding()) * height);
    }

    mItemDesc->setPosition(getPadding(), 2 * height);
    mItemEffect->setPosition(getPadding(), (numRowsDesc + getPadding()) * height);
}
Ejemplo n.º 16
0
void RadioButton::updateBounds()
{
    Label::updateBounds();

    Vector2 size;
    if (_selected)
    {
        const Rectangle& selectedRegion = getImageRegion("selected", NORMAL);
        size.set(selectedRegion.width, selectedRegion.height);
    }
    else
    {
        const Rectangle& unselectedRegion = getImageRegion("unselected", NORMAL);
        size.set(unselectedRegion.width, unselectedRegion.height);
    }

    if (_autoSize & AUTO_SIZE_HEIGHT)
    {
        // Text-only width was already measured in Label::update - append image
        const Theme::Border& border = getBorder(NORMAL);
        const Theme::Border& padding = getPadding();
        setHeightInternal(std::max(_bounds.height, size.y + border.top + border.bottom + padding.top + padding.bottom));
    }

    if (_autoSize & AUTO_SIZE_WIDTH)
    {
        // Text-only width was already measured in Label::update - append image
        setWidthInternal(_bounds.height + 5 + _bounds.width);
    }
}
Ejemplo n.º 17
0
void EquipmentWindow::loadEquipBoxes()
{
    if (mEquipBox)
        delete[] mEquipBox;

    // Load equipment boxes.
    mBoxesNumber = mEquipment->getSlotNumber();
    mEquipBox = new EquipBox[mBoxesNumber];

    for (int i = 0; i < mBoxesNumber; ++i)
    {
        Position boxPosition = Net::getInventoryHandler()->getBoxPosition(i);
        mEquipBox[i].posX = boxPosition.x + getPadding();
        mEquipBox[i].posY = boxPosition.y + getTitleBarHeight();

        const std::string &backgroundFile =
            Net::getInventoryHandler()->getBoxBackground(i);

        if (!backgroundFile.empty())
        {
            mEquipBox[i].backgroundImage =
                Theme::instance()->getImageFromTheme(backgroundFile);
        }
    }
}
Ejemplo n.º 18
0
void Window::setContentSize(int width, int height)
{
    width = width + 2 * getPadding();
    height = height + getPadding() + getTitleBarHeight();

    if (getMinWidth() > width)
        width = getMinWidth();
    else if (getMaxWidth() < width)
        width = getMaxWidth();
    if (getMinHeight() > height)
        height = getMinHeight();
    else if (getMaxHeight() < height)
        height = getMaxHeight();

    setSize(width, height);
}
Ejemplo n.º 19
0
void Slider::updateValue(int x, int y)
{
    State state = getState();

    // Horizontal case.
    const Theme::Border& border = getBorder(state);
    const Theme::Padding& padding = getPadding();
    const Rectangle& minCapRegion = _minImage->getRegion();
    const Rectangle& maxCapRegion = _maxImage->getRegion();
    const Rectangle& markerRegion = _markerImage->getRegion();

    float markerPosition = (x - markerRegion.width * 0.5f) / (_viewportBounds.width - markerRegion.width);
            
    if (markerPosition > 1.0f)
    {
        markerPosition = 1.0f;
    }
    else if (markerPosition < 0.0f)
    {
        markerPosition = 0.0f;
    }

    float value = (markerPosition * (_max - _min)) + _min;
    if (_step > 0.0f)
    {            
        int numSteps = round(value / _step);
        value = _step * numSteps;
    }

    setValue(value);
}
Ejemplo n.º 20
0
Setup::Setup():
    Window(_("Setup"))
{
    setWindowName("Setup");
    saveVisibility(false);
    setCloseButton(true);
    int width = 340 + 2 * getPadding();
    int height = 340 + 2 * getPadding() + getTitleBarHeight();

    static const char *buttonNames[] = {
        N_("Reset Windows"), N_("Cancel"), N_("Apply"), 0
    };

    mPanel = new TabbedArea();
    mPanel->setDimension(gcn::Rectangle(5, 5, width - 10, height - 40));

    mTabs.push_back(new Setup_Video());
    mTabs.push_back(new Setup_Audio());
    mTabs.push_back(new Setup_Input());
    mTabs.push_back(new Setup_Colors());

    for (std::list<SetupTabContainer*>::iterator i = mTabs.begin(),
         i_end = mTabs.end(); i != i_end; ++i)
    {
        SetupTabContainer *tab = *i;
        mPanel->addTab(tab->getName(), tab);
    }

    place(0, 0, mPanel, 7, 6).setPadding(2);

    for (int i = 0; buttonNames[i] != NULL; ++i)
    {
        Button *btn = new Button(gettext(buttonNames[i]), buttonNames[i], this);
        place(i + 4, 6, btn);

        // Store this button, as it needs to be enabled/disabled
        if (!strcmp(buttonNames[i], N_("Reset Windows")))
            mResetWindows = btn;
    }

    setDefaultSize(width, height, ImageRect::CENTER);

    Layout &layout = getLayout();
    layout.setRowHeight(0, Layout::AUTO_SET);

    loadWindowState();
}
Ejemplo n.º 21
0
void SpeechBubble::setText(std::string text)
{
    mText = text;

    int width = mCaption->getWidth() + 2 * getPadding();
    mSpeechBox->setTextColor(&guiPalette->getColor(Palette::TEXT));
    mSpeechBox->setTextWrapped(text, 130 > width ? 130 : width);
}
Ejemplo n.º 22
0
void TextInputDialog::adjustSize()
{
    const int titleWidth = 3 * getFont()->getWidth(getCaption()) / 2;
    const int fontHeight = getFont()->getHeight();

    setWidth(titleWidth + 4 * getPadding());
    setHeight(fontHeight + mOkButton->getHeight() +
              mValueField->getHeight() + 8 * getPadding());

    setDefaultSize(getWidth(), getHeight(), ImageRect::CENTER);

    Layout &layout = getLayout();
    layout.setRowHeight(0, Layout::AUTO_SET);
    layout.setRowHeight(1, Layout::AUTO_SET);
    layout.setColWidth(2, Layout::AUTO_SET);
    layout.setColWidth(3, Layout::AUTO_SET);
}
Ejemplo n.º 23
0
void Popup::setContentSize(int width, int height)
{
    width += 2 * getPadding();
    height += 2 * getPadding();

    if (getMinWidth() > width)
        width = getMinWidth();
    else if (getMaxWidth() < width)
        width = getMaxWidth();
    if (getMinHeight() > height)
        height = getMinHeight();
    else if (getMaxHeight() < height)
        height = getMaxHeight();

    setSize(width, height);
    mRedraw = true;
}
Ejemplo n.º 24
0
ItemPopup::ItemPopup(gcn::Container *parent):
    Popup("ItemPopup", "graphics/gui/gui.xml", parent)
{
    mItemType = "";

    // Item Name
    mItemName = new gcn::Label("");
    mItemName->setFont(gui->getBoldFont());
    mItemName->setPosition(getPadding(), getPadding());

    const int fontHeight = getFont()->getHeight();

    // Item Description
    mItemDesc = new TextBox(new WordTextWrapHandler());
    mItemDesc->setPosition(getPadding(), fontHeight);

    // Item Effect
    mItemEffect = new TextBox(new WordTextWrapHandler());
    mItemEffect->setPosition(getPadding(), 2 * fontHeight + 2 * getPadding());

    // Item Weight
    mItemWeight = new TextBox(new WordTextWrapHandler());
    mItemWeight->setPosition(getPadding(), 3 * fontHeight + 4 * getPadding());

    add(mItemName);
    add(mItemDesc);
    add(mItemEffect);
    add(mItemWeight);

    loadPopupConfiguration();
}
Ejemplo n.º 25
0
BeingPopup::BeingPopup() :
    Popup("BeingPopup", "beingpopup.xml"),
    mBeingName(new Label("A")),
    mBeingParty(new Label("A")),
    mBeingGuild(new Label("A")),
    mBeingRank(new Label("A")),
    mBeingComment(new Label("A"))
{
    // Being Name
    mBeingName->setFont(boldFont);
    mBeingName->setPosition(getPadding(), getPadding());

    const int fontHeight = mBeingName->getHeight() + getPadding();

    // Being's party
    mBeingParty->setPosition(getPadding(), fontHeight);

    // Being's party
    mBeingGuild->setPosition(getPadding(), 2 * fontHeight);

    mBeingRank->setPosition(getPadding(), 3 * fontHeight);

    mBeingComment->setPosition(getPadding(), 4 * fontHeight);

    add(mBeingName);
    add(mBeingParty);
    add(mBeingGuild);
    add(mBeingRank);
    add(mBeingComment);
}
Ejemplo n.º 26
0
ItemPopup::ItemPopup():
    Popup("ItemPopup")
{
    // Item Name
    mItemName = new gcn::Label;
    mItemName->setFont(boldFont);
    mItemName->setPosition(getPadding(), getPadding());

    const int fontHeight = getFont()->getHeight();

    // Item Description
    mItemDesc = new TextBox;
    mItemDesc->setEditable(false);
    mItemDesc->setPosition(getPadding(), fontHeight);

    // Item Effect
    mItemEffect = new TextBox;
    mItemEffect->setEditable(false);
    mItemEffect->setPosition(getPadding(), 2 * fontHeight + 2 * getPadding());

    // Item Weight
    mItemWeight = new TextBox;
    mItemWeight->setEditable(false);
    mItemWeight->setPosition(getPadding(), 3 * fontHeight + 4 * getPadding());

    add(mItemName);
    add(mItemDesc);
    add(mItemEffect);
    add(mItemWeight);

    addMouseListener(this);

    loadPopupConfiguration();
}
Ejemplo n.º 27
0
    void ASCIIFormat::serialize(boost::property_tree::ptree& parentNode)
    {
        boost::property_tree::ptree node;

        node.put("<xmlattr>.type", getType());
        node.put("ASCIILength", getASCIILength());
        node.put("Padding", getPadding());

        parentNode.add_child(getDefaultXmlNodeName(), node);
    }
Ejemplo n.º 28
0
void UINodeCheckbox::render (int x, int y) const
{
	UINodeButton::render(x, y);

	if (_label.empty())
		return;

	x += getRenderX() + getRenderWidth() + getPadding() * _frontend->getWidth();
	y += getRenderCenterY() - _font->getTextHeight(_label) / 2;
	_font->print(_label, _fontColor, x, y);
}
Ejemplo n.º 29
0
PopupMenu::PopupMenu(MenuType type, gcn::Container *parent):
    Popup("PopupMenu", "graphics/gui/gui.xml", parent),
    mPreviousFocus(NULL),
    mBeing(NULL),
    mFloorItem(NULL),
    mItem(NULL),
    mEmote(-1),
    mType(type)
{
    mModel = new LinkMappedListModel();

    mMappedListBox = new MappedListBox(mModel);
    mMappedListBox->setPosition(getPadding(), getPadding());
    mMappedListBox->setWrappingEnabled(true);
    mMappedListBox->setFollowingMouse(true);
    mMappedListBox->addActionListener(this);
    add(mMappedListBox);

    loadPopupConfiguration();
}
Ejemplo n.º 30
0
    void Window::resizeToContent()
    {
        WidgetListIterator it;

        int w = 0, h = 0;
        for (it = mWidgets.begin(); it != mWidgets.end(); it++)
        {
            if ((*it)->getX() + (*it)->getWidth() > w)
            {
                w = (*it)->getX() + (*it)->getWidth();
            }

            if ((*it)->getY() + (*it)->getHeight() > h)
            {
                h = (*it)->getY() + (*it)->getHeight();
            }
        }

        setSize(w + 2* getPadding(), h + getPadding() + getTitleBarHeight());
    }