1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
| void
SoQtFullViewer::createViewerButtons(QWidget * parent, SbPList * buttonlist)
{
for (int i=0; i <= SEEK_BUTTON; i++) {
QPushButton * p = new QPushButton(parent);
// Button focus doesn't really make sense in the way we're using
// the pushbuttons.
p->setFocusPolicy(QTWIDGET_NOFOCUS);
#if QT_VERSION >= 0x040000 // Qt 4.*
// In some GUI styles in Qt4, a default button is drawn with an
// extra frame around it, up to 3 pixels or more. This causes
// pixmaps on buttons to look tiny, which is not what we want.
p->setIconSize(QSize(24, 24));
#endif
#if (defined Q_WS_MAC && QT_VERSION >= 0x030100) && defined(HAVE_QSTYLEFACTORY_H)
// Since Qt/Mac 3.1.x, all pushbuttons (even those < 32x32) are drawn
// using the Aqua style, i.e. with rounded edges and shading. This
// looks really ugly in the viewer decoration. Drawing the buttons
// in the Windows style gives us the flat, square buttons we want.
QStyle * style = QStyleFactory::create("windows");
if (style) { p->setStyle(style); }
#endif
// FIXME: its wrong to cast xpm data to (const char **), it
// _should_ be (const char * const []), but this is not valid ANSI
// C++. Not sure what to do about this (and the wrong cast can
// (and has) in fact lead to bugs, so the situation should be
// resolved). 20000505 mortene.
switch (i) {
case INTERACT_BUTTON:
PRIVATE(this)->interactbutton = p;
p->setToggleButton(TRUE);
p->setPixmap(QPixmap((const char **)pick_xpm));
p->setOn(this->isViewing() ? FALSE : TRUE);
QObject::connect(p, SIGNAL(clicked()),
PRIVATE(this), SLOT(interactbuttonClicked()));
break;
case EXAMINE_BUTTON:
PRIVATE(this)->viewbutton = p;
p->setToggleButton(TRUE);
p->setPixmap(QPixmap((const char **)view_xpm));
p->setOn(this->isViewing());
QObject::connect(p, SIGNAL(clicked()),
PRIVATE(this), SLOT(viewbuttonClicked()));
break;
case HOME_BUTTON:
QObject::connect(p, SIGNAL(clicked()), PRIVATE(this), SLOT(homebuttonClicked()));
p->setPixmap(QPixmap((const char **)home_xpm));
break;
case SET_HOME_BUTTON:
QObject::connect(p, SIGNAL(clicked()),
PRIVATE(this), SLOT(sethomebuttonClicked()));
p->setPixmap(QPixmap((const char **)set_home_xpm));
break;
case VIEW_ALL_BUTTON:
QObject::connect(p, SIGNAL(clicked()),
PRIVATE(this), SLOT(viewallbuttonClicked()));
p->setPixmap(QPixmap((const char **)view_all_xpm));
break;
case SEEK_BUTTON:
QObject::connect(p, SIGNAL(clicked()), PRIVATE(this), SLOT(seekbuttonClicked()));
p->setPixmap(QPixmap((const char **)seek_xpm));
break;
default:
assert(0);
break;
}
p->adjustSize();
buttonlist->append(p);
}
} |
Partager