1 #include "XGUI_MenuGroupPanel.h"
2 #include "XGUI_Command.h"
7 #include <QResizeEvent>
11 XGUI_MenuGroupPanel::XGUI_MenuGroupPanel(QWidget *parent) :
12 QWidget(parent), myNewRow(0), myNewCol(0), myMaxRow(1)
14 myLayout = new QGridLayout(this);
15 myLayout->setSpacing(0);
16 myLayout->setMargin(0);
17 myLayout->setContentsMargins(0,0,0,0);
21 void XGUI_MenuGroupPanel::addCommand(XGUI_Command* theAction)
23 addWidget(theAction->requestWidget(this));
26 void XGUI_MenuGroupPanel::placeWidget(QWidget* theWgt)
28 if (myMaxRow == myNewRow) {
32 myLayout->addWidget(theWgt, myNewRow, myNewCol, Qt::AlignLeft);
36 void XGUI_MenuGroupPanel::addWidget(QWidget* theWgt)
39 myWidgets.append(theWgt);
43 void XGUI_MenuGroupPanel::resizeEvent(QResizeEvent* theEvent)
45 QWidget::resizeEvent(theEvent);
46 if (myWidgets.size() == 0)
49 int aH = theEvent->size().height();
50 int aMaxRow = (int) floor(double(aH / MIN_BUTTON_HEIGHT));
51 if (aMaxRow == myMaxRow)
55 QListIterator<QWidget*> aIt(myWidgets);
58 while (aIt.hasNext()) {
59 placeWidget(aIt.next());