Changeset 181
- Timestamp:
- Mar 3, 2008, 4:16:32 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/styles/qwarp4style.cpp
r179 r181 747 747 p.drawLine(pt2, pt += QPoint(5, 1)); 748 748 pt2 = pt + QPoint(sz - 7, sz - 7); 749 p.drawLine(pt2 + QPoint(0, 1), pt2 + QPoint(0, 4));749 p.drawLine(pt2 + QPoint(0, 1), pt2 + QPoint(0, 5)); 750 750 751 751 // corner … … 792 792 p.drawLine(pt2, pt += QPoint(5, -1)); 793 793 pt2 = pt + QPoint(sz - 7, -sz + 7); 794 p.drawLine(pt2 + QPoint(0, -1), pt2 + QPoint(0, - 4));794 p.drawLine(pt2 + QPoint(0, -1), pt2 + QPoint(0, -5)); 795 795 796 796 // corner … … 835 835 p.drawLine(pt2, pt += QPoint(-5, 1)); 836 836 pt2 = pt + QPoint(7 - sz, sz - 7); 837 p.drawLine(pt2 + QPoint(0, 1), pt2 + QPoint(0, 5)); 837 838 838 839 // corner … … 886 887 p.drawLine(pt2, pt += QPoint(-5, -1)); 887 888 pt2 = pt + QPoint(7 - sz, 7 - sz); 889 p.drawLine(pt2 + QPoint(0, -1), pt2 + QPoint(0, -5)); 888 890 889 891 // corner … … 1239 1241 Q_OBJECT 1240 1242 1243 #ifndef QT_PM_NO_TABWIDGET_HEADERS 1244 1241 1245 public: 1242 QWarpTabPanelHeader(QTabWidget* tw); 1246 1247 QWarpTabPanelHeader (QTabWidget* tw); 1243 1248 1244 1249 protected: 1245 virtual bool eventFilter(QObject* watched, QEvent* ev); 1246 virtual void paintEvent(QPaintEvent* pev); 1247 virtual void mouseReleaseEvent(QMouseEvent* e); 1250 1251 virtual bool eventFilter (QObject* watched, QEvent* ev); 1252 virtual void paintEvent (QPaintEvent* pev); 1253 virtual void mouseReleaseEvent (QMouseEvent* e); 1248 1254 1249 1255 private: 1256 1250 1257 bool _bottom; 1251 1258 1252 QTabWidget * getTabWidget();1253 QWidgetStack * getPanel();1254 QTabBar * getTabBar();1255 QWidget * getTabBarBase();1256 1257 void setupLayout (QSize sz);1258 1259 void drawBentCornerTR(QPoint pt, int h, QPainter& p);1260 void drawBentCornerTL(QPoint pt, int h, QPainter& p);1261 void drawBentCornerBR(QPoint pt, int h, QPainter& p);1262 void drawBentCornerBL(QPoint pt, int h, QPainter& p);1263 void drawPlusButton(QPoint pt, QPainter& p);1264 void drawMinusButton(QPoint pt, QPainter& p);1259 QTabWidget *_tabWidget; 1260 QWidgetStack *_widgetStack; 1261 QTabBar *_tabBar; 1262 QWidget *_tabBarBase; 1263 1264 void setupLayout (QRect rect); 1265 1266 static void drawBentCornerTR (QPoint pt, int h, QPainter& p); 1267 static void drawBentCornerTL (QPoint pt, int h, QPainter& p); 1268 static void drawBentCornerBR (QPoint pt, int h, QPainter& p); 1269 static void drawBentCornerBL (QPoint pt, int h, QPainter& p); 1270 static void drawPlusButton (QPoint pt, QPainter& p); 1271 static void drawMinusButton (QPoint pt, QPainter& p); 1265 1272 1266 1273 int currentInx(); 1267 1274 1268 public: 1269 static void addIfNotPresent(QTabBar const* tb); 1275 #endif // QT_PM_NO_TABWIDGET_HEADERS 1270 1276 }; 1271 1277 1272 QWarpTabPanelHeader::QWarpTabPanelHeader(QTabWidget* tw) 1273 : QWidget(tw, "qt_warp_tabpanel_header") 1274 { 1275 if(0 == tw) 1278 #ifndef QT_PM_NO_TABWIDGET_HEADERS 1279 1280 QWarpTabPanelHeader::QWarpTabPanelHeader (QTabWidget *tw) 1281 : QWidget (tw, "qt_warp_tabpanel_header") 1282 , _bottom (false), _tabWidget (0), _widgetStack (0) 1283 , _tabBar (0), _tabBarBase (0) 1284 { 1285 Q_ASSERT (tw); 1286 if (tw == 0) 1276 1287 return; 1277 1288 1278 // adapt the panel area size ("QWidgetStack")1279 // note: the same effect could also be achieved by increasing the frame line1280 // width for tab widgets, but this would also affect the tabbar layout in a1281 // "very strange" (buggy??) way (it only works correctly for frame line widths1282 // between 0 and 2)1283 // also note that this reduction must be compensated when drawing the frame1284 // (see PE_PanelTabWidget)1285 1286 1289 _bottom = tw->tabPosition() == QTabWidget::Bottom; 1287 QWidgetStack* tp = getPanel(); 1288 if(0 != tp) 1289 { 1290 QRect r = tp->frameRect(); 1291 if(_bottom) 1292 r.addCoords(11, 11, -14, 0); 1293 else 1294 r.addCoords(11, 0, -14, -11); 1295 tp->setFrameRect(r); 1296 } 1297 1298 // now we are "abusing" the otherwise unused "midLineWidth" of the tab panel 1299 // stack for signalling whether the tab bar is on top or at the bottom. 1300 // note that we can retrieve this information later in PE_PanelTabWidget from 1301 // the "opt" parameter (we don't have access to any widget from where we could 1302 // get that information "legally"! 1303 1304 tp->setMidLineWidth((int)_bottom); // now 1 is "bottom", 0 is "top" 1305 1306 // we also need to catch resize events from the tab widget, in order to adapt 1290 1291 _tabWidget = tw; 1292 1293 _widgetStack = (QWidgetStack *) tw->child ("tab pages", "QWidgetStack", false); 1294 Q_ASSERT (_widgetStack != 0); 1295 if (_widgetStack == 0) 1296 return; 1297 1298 _tabBar = (QTabBar *) tw->child (NULL, "QTabBar", false); 1299 Q_ASSERT (_tabBar != 0); 1300 if (_tabBar == 0) 1301 return; 1302 1303 _tabBarBase = (QWidget *) tw->child ("tab base", "QWidget", false); 1304 Q_ASSERT (_tabBarBase != 0); 1305 if (_tabBarBase == 0) 1306 return; 1307 1308 setupLayout (_tabBarBase->geometry()); 1309 1310 // catch resize/move events from the tab bar base widget in order to adapt 1307 1311 // the size of this panel header widget accordingly 1308 1312 1309 tw->installEventFilter(this); 1310 1311 // note that size 0/0 means that the size is taken from that widget 1312 1313 setupLayout(QSize(0, 0)); 1314 1315 // make this panel header widget visible: it displays the tab title 1316 1317 #ifndef QT_PM_NO_TABWIDGET_HEADERS 1313 _tabBarBase->installEventFilter (this); 1314 1315 // make this visible: it displays the tab title 1318 1316 show(); 1319 #else 1320 hide(); 1321 #endif 1322 } 1323 1324 bool QWarpTabPanelHeader::eventFilter(QObject* watched, QEvent* ev) 1325 { 1326 if(!watched->inherits("QTabWidget") || 1327 (QEvent::Resize != ev->type())) 1317 } 1318 1319 bool QWarpTabPanelHeader::eventFilter (QObject *watched, QEvent *ev) 1320 { 1321 if ((ev->type() != QEvent::Resize && ev->type() != QEvent::Move)) 1328 1322 return false; 1329 1323 1330 // resize the panel header widget if the main tab widget is being resized1331 1332 setupLayout (((QResizeEvent*)ev)->size());1324 // adapt the panel header widget position if the tab bar base widget is 1325 // being resized/moved 1326 setupLayout (((QWidget *) watched)->geometry()); 1333 1327 1334 1328 return false; … … 1337 1331 void QWarpTabPanelHeader::paintEvent(QPaintEvent* pev) 1338 1332 { 1339 #ifndef QT_PM_NO_TABWIDGET_HEADERS 1333 if (_tabWidget == 0) 1334 return; // should never happen 1340 1335 1341 1336 // draw the caption of the page in the tab bar base area 1342 1337 1343 QRect r (geometry());1338 QRect r (rect()); 1344 1339 QPainter p(this); 1345 1340 bool reverse = QApplication::reverseLayout(); 1346 1341 1347 r.addCoords(-r.left(), -r.top(), -r.left(), -r.top()); 1348 p.setClipRect(r); 1349 QFont f = QApplication::font(); 1350 f.setBold(true); 1351 p.setFont(f); 1352 QRect fr = QFontMetrics(f).boundingRect(caption()); 1342 QFont f = _tabWidget->font(); 1343 f.setBold (true); 1344 p.setFont (f); 1345 QRect fr = QFontMetrics(f).boundingRect (caption()); 1353 1346 1354 1347 int x = (reverse ? … … 1359 1352 QString cap = caption(); 1360 1353 cap.remove (cap.find ('&'), 1); 1361 p.drawText (x, y, cap);1354 p.drawText (x, y, cap); 1362 1355 1363 1356 QPoint pt1l, pt1r, pt2l, pt2r; 1364 int hh = r.height() + 1;1365 if (_bottom)1366 { 1367 pt1l = QPoint (1, r.bottom());1368 pt1r = QPoint (r.width() - hh, r.bottom());1369 pt2l = QPoint (5, r.top());1370 pt2r = QPoint (r.width() - hh, r.top());1357 int hh = r.height(); 1358 if (_bottom) 1359 { 1360 pt1l = QPoint (1, r.bottom()); 1361 pt1r = QPoint (r.width() - hh, r.bottom()); 1362 pt2l = QPoint (5, r.top() + 1); 1363 pt2r = QPoint (r.width() - hh, r.top() + 1); 1371 1364 } 1372 1365 else 1373 1366 { 1374 pt1l = QPoint(1, r.top()); 1375 pt1r = QPoint(r.width() - hh, r.top()); 1376 pt2l = QPoint(5, r.bottom() - 1); 1377 pt2r = QPoint(r.width() - hh, r.bottom() - 1); 1378 } 1379 if(reverse) 1380 { 1381 pt1l.setX(r.right() - pt1l.x()); 1382 pt1r.setX(r.right() - pt1r.x()); 1383 pt2l.setX(r.right() - pt2l.x()); 1384 pt2r.setX(r.right() - pt2r.x()); 1367 pt1l = QPoint (1, r.top()); 1368 pt1r = QPoint (r.width() - hh, r.top()); 1369 pt2l = QPoint (5, hh - 3); 1370 pt2r = QPoint (r.width() - hh, hh - 3); 1371 } 1372 if (reverse) 1373 { 1374 pt1l.setX (r.right() - pt1l.x()); 1375 pt1r.setX (r.right() - pt1r.x()); 1376 pt2l.setX (r.right() - pt2l.x()); 1377 pt2r.setX (r.right() - pt2r.x()); 1378 } 1379 1380 const QColorGroup &cg = colorGroup(); 1381 p.setPen (cg.dark()); 1382 p.drawLine (pt1l, pt1r); 1383 p.drawLine (pt2l, pt2r); 1384 p.setPen (cg.light()); 1385 ++ pt2l.ry(); 1386 ++ pt2r.ry(); 1387 p.drawLine (pt2l, pt2r); 1388 1389 if (_tabBar == 0) 1390 return; // should never happen 1391 1392 int inx = currentInx(); 1393 bool noPlus = inx >= _tabBar->count() - 1, 1394 noMinus = inx <= 0; 1395 1396 QPoint cpt (pt1r); 1397 if (_bottom) 1398 { 1399 if (reverse) 1400 { 1401 cpt += QPoint (-hh, -hh + 1); 1402 drawBentCornerBL (cpt, hh, p); 1403 if (!noPlus) 1404 drawPlusButton (cpt + QPoint (5, hh - 12), p); 1405 if (!noMinus) 1406 drawMinusButton (cpt + QPoint (hh - 15, 7), p); 1407 } 1408 else 1409 { 1410 cpt += QPoint (1, -hh + 1); 1411 drawBentCornerBR (cpt, hh, p); 1412 if (!noPlus) 1413 drawPlusButton (cpt + QPoint (hh - 12, hh - 12), p); 1414 if (!noMinus) 1415 drawMinusButton (cpt + QPoint (8, 7), p); 1416 } 1385 1417 } 1386 1418 else 1387 1419 { 1388 pt1l.setX(r.left() + pt1l.x());1389 pt1r.setX(r.left() + pt1r.x());1390 pt2l.setX(r.left() + pt2l.x());1391 pt2r.setX(r.left() + pt2r.x());1392 }1393 QColorGroup cg = colorGroup();1394 p.setPen(cg.dark());1395 p.drawLine(pt1l, pt1r);1396 p.drawLine(pt2l, pt2r);1397 p.setPen(cg.light());1398 pt2l += QPoint(0, 1);1399 pt2r += QPoint(0, 1);1400 p.drawLine(pt2l, pt2r);1401 1402 int inx = currentInx();1403 QTabBar* tb = getTabBar();1404 if(0 == tb)1405 return; // should never happen1406 bool noPlus = (tb->count() - 1) <= inx,1407 noMinus = 0 >= inx;1408 1409 QPoint cpt(pt1r);1410 if(_bottom)1411 {1412 1420 if(reverse) 1413 1421 { 1414 cpt += QPoint (-hh, -hh + 1);1415 drawBentCorner BL(cpt, hh, p);1416 if (!noPlus)1417 drawPlusButton (cpt + QPoint(5, hh - 12), p);1418 if (!noMinus)1419 drawMinusButton (cpt + QPoint(hh - 15, 7), p);1422 cpt += QPoint (-hh, 0); 1423 drawBentCornerTL (cpt, hh, p); 1424 if (!noPlus) 1425 drawPlusButton (cpt + QPoint (5, 5), p); 1426 if (!noMinus) 1427 drawMinusButton (cpt + QPoint (hh - 15, hh - 14), p); 1420 1428 } 1421 1429 else 1422 1430 { 1423 cpt += QPoint(1, -hh + 1); 1424 drawBentCornerBR(cpt, hh, p); 1425 if(!noPlus) 1426 drawPlusButton(cpt + QPoint(hh - 12, hh - 12), p); 1427 if(!noMinus) 1428 drawMinusButton(cpt + QPoint(8, 7), p); 1429 } 1430 } 1431 else 1432 { 1433 if(reverse) 1434 { 1435 cpt += QPoint(-hh, 0); 1436 drawBentCornerTL(cpt, hh, p); 1437 if(!noPlus) 1438 drawPlusButton(cpt + QPoint(5, 5), p); 1439 if(!noMinus) 1440 drawMinusButton(cpt + QPoint(hh - 15, hh - 14), p); 1441 } 1442 else 1443 { 1444 cpt += QPoint(1, 0); 1445 drawBentCornerTR(cpt, hh, p); 1446 if(!noPlus) 1447 drawPlusButton(cpt + QPoint(hh - 12, 5), p); 1448 if(!noMinus) 1449 drawMinusButton(cpt + QPoint(8, hh - 14), p); 1450 } 1451 } 1452 #endif 1431 cpt += QPoint (1, 0); 1432 drawBentCornerTR (cpt, hh, p); 1433 if (!noPlus) 1434 drawPlusButton (cpt + QPoint (hh - 12, 5), p); 1435 if (!noMinus) 1436 drawMinusButton (cpt + QPoint (8, hh - 14), p); 1437 } 1438 } 1453 1439 } 1454 1440 … … 1491 1477 --inx; 1492 1478 1493 QTabBar* tb = getTabBar(); 1494 if(0 == tb) 1479 if(_tabBar == 0) 1495 1480 return; // should never happen 1496 if((0 <= inx) && (tb->count() > inx)) 1497 tb->setCurrentTab(tb->tabAt(inx)->identifier()); 1481 1482 if (inx >= 0 && _tabBar->count() > inx) 1483 _tabBar->setCurrentTab (_tabBar->tabAt (inx)->identifier()); 1498 1484 } 1499 1485 1500 1486 void QWarpTabPanelHeader::drawBentCornerTR(QPoint pt, int h, QPainter& p) 1501 1487 { 1502 p.drawPixmap (pt, *qWarpSystemPixmaps.getPixmap(QWarpPixmap::tabheadertr,1503 QWarpPixmap::internal, h));1488 p.drawPixmap (pt, *qWarpSystemPixmaps.getPixmap (QWarpPixmap::tabheadertr, 1489 QWarpPixmap::internal, h)); 1504 1490 } 1505 1491 1506 1492 void QWarpTabPanelHeader::drawBentCornerTL(QPoint pt, int h, QPainter& p) 1507 1493 { 1508 p.drawPixmap (pt, *qWarpSystemPixmaps.getPixmap(QWarpPixmap::tabheadertl,1509 QWarpPixmap::internal, h));1494 p.drawPixmap (pt, *qWarpSystemPixmaps.getPixmap (QWarpPixmap::tabheadertl, 1495 QWarpPixmap::internal, h)); 1510 1496 } 1511 1497 1512 1498 void QWarpTabPanelHeader::drawBentCornerBR(QPoint pt, int h, QPainter& p) 1513 1499 { 1514 p.drawPixmap (pt, *qWarpSystemPixmaps.getPixmap(QWarpPixmap::tabheaderbr,1515 QWarpPixmap::internal, h));1500 p.drawPixmap (pt, *qWarpSystemPixmaps.getPixmap (QWarpPixmap::tabheaderbr, 1501 QWarpPixmap::internal, h)); 1516 1502 } 1517 1503 1518 1504 void QWarpTabPanelHeader::drawBentCornerBL(QPoint pt, int h, QPainter& p) 1519 1505 { 1520 p.drawPixmap (pt, *qWarpSystemPixmaps.getPixmap(QWarpPixmap::tabheaderbl,1521 QWarpPixmap::internal, h));1506 p.drawPixmap (pt, *qWarpSystemPixmaps.getPixmap (QWarpPixmap::tabheaderbl, 1507 QWarpPixmap::internal, h)); 1522 1508 } 1523 1509 1524 1510 void QWarpTabPanelHeader::drawPlusButton(QPoint pt, QPainter& p) 1525 1511 { 1526 p.drawPixmap (pt, *qWarpSystemPixmaps.getPixmap(QWarpPixmap::tabhdrplus,1527 QWarpPixmap::internal));1512 p.drawPixmap (pt, *qWarpSystemPixmaps.getPixmap (QWarpPixmap::tabhdrplus, 1513 QWarpPixmap::internal)); 1528 1514 } 1529 1515 1530 1516 void QWarpTabPanelHeader::drawMinusButton(QPoint pt, QPainter& p) 1531 1517 { 1532 p.drawPixmap(pt, *qWarpSystemPixmaps.getPixmap(QWarpPixmap::tabhdrminus, 1533 QWarpPixmap::internal)); 1534 } 1535 1536 QTabWidget* QWarpTabPanelHeader::getTabWidget() 1537 { 1538 QWidget* ww = parentWidget(); 1539 if((0 == ww) || !ww->inherits("QTabWidget")) 1540 return 0; 1541 1542 return (QTabWidget*)ww; 1543 } 1544 1545 QWidgetStack* QWarpTabPanelHeader::getPanel() 1546 { 1547 QTabWidget* tw = getTabWidget(); 1548 if(0 == tw) 1549 return 0; 1550 1551 return (QWidgetStack*)tw->child("tab pages", "QWidgetStack", false); 1552 } 1553 1554 QTabBar* QWarpTabPanelHeader::getTabBar() 1555 { 1556 QTabWidget* tw = getTabWidget(); 1557 if(0 == tw) 1558 return 0; 1559 1560 QObjectList* childList = tw->queryList("QTabBar", 0, false, false); 1561 if(childList->isEmpty()) 1562 return 0; 1563 1564 return (QTabBar*)childList->at(0); 1565 } 1566 1567 QWidget* QWarpTabPanelHeader::getTabBarBase() 1568 { 1569 QTabWidget* tw = getTabWidget(); 1570 if(0 == tw) 1571 return 0; 1572 1573 return (QWidget*)tw->child("tab base", "QWidget", false); 1518 p.drawPixmap (pt, *qWarpSystemPixmaps.getPixmap (QWarpPixmap::tabhdrminus, 1519 QWarpPixmap::internal)); 1574 1520 } 1575 1521 1576 1522 int QWarpTabPanelHeader::currentInx() 1577 1523 { 1578 QTabBar* tb = getTabBar(); 1579 if(0 == tb) 1524 if (_tabBar == 0) 1580 1525 return 0; // should never happen 1581 int id = tb->currentTab(); 1582 1583 return (id == 0) ? 0 : tb->indexOf(id); 1584 } 1585 1586 void QWarpTabPanelHeader::setupLayout(QSize sz) 1587 { 1588 QTabWidget* tw = getTabWidget(); 1589 if(0 == tw) 1590 return; 1591 1592 if(QSize(0, 0) == sz) 1593 sz = tw->size(); 1594 1595 QTabBar* tb = getTabBar(); 1596 if(0 == tb) 1597 return; 1598 1599 int th = tb->size().height(); 1600 int fh = QFontMetrics(QApplication::font()).boundingRect("X").height(); 1601 1602 QRect r(17, 0, sz.width() - 37, 0); 1603 if(_bottom) 1604 { 1605 r.setBottom(sz.height() - th - 17); 1606 r.setTop(r.bottom() - fh); 1607 r.addCoords(-5, -7, 6, 6); 1526 int id = _tabBar->currentTab(); 1527 1528 return (id == 0) ? 0 : _tabBar->indexOf (id); 1529 } 1530 1531 void QWarpTabPanelHeader::setupLayout (QRect rect) 1532 { 1533 QRect r (rect); 1534 bool reverse = QApplication::reverseLayout(); 1535 if (_bottom) 1536 { 1537 if (reverse) 1538 r.addCoords (14, 0, -12, -13); 1539 else 1540 r.addCoords (12, 0, -14, -13); 1608 1541 } 1609 1542 else 1610 1543 { 1611 r.setTop(th + 14); 1612 r.setBottom(r.top() + fh); 1613 r.addCoords(-5, -6, 6, 7); 1614 } 1615 1616 setGeometry(r); 1617 } 1618 1619 void QWarpTabPanelHeader::addIfNotPresent(QTabBar const* tb) 1620 { 1621 QWidget* ww = tb->parentWidget(); 1622 if((0 == ww) || !ww->inherits("QTabWidget")) 1623 return; 1624 QTabWidget* tw = (QTabWidget*)ww; 1625 1626 if(0 != tw->child("qt_warp_tabpanel_header", "QWarpTabPanelHeader", false)) 1627 return; // header already there 1628 1629 // create if not yet present, with the tab widget as parent 1630 // note: deletion occurs when the tab widget is destroyed 1631 1632 new QWarpTabPanelHeader(tw); 1633 } 1544 if (reverse) 1545 r.addCoords (14, 13, -12, 0); 1546 else 1547 r.addCoords (12, 13, -14, 0); 1548 } 1549 1550 setGeometry (r); 1551 } 1552 1553 #endif // QT_PM_NO_TABWIDGET_HEADERS 1634 1554 1635 1555 /*----------------------------------------------------------------------*\ … … 1830 1750 1831 1751 /*! \reimp */ 1832 void QWarp4Style::polish (QApplication*app)1752 void QWarp4Style::polish (QApplication *app) 1833 1753 { 1834 1754 #ifndef QT_NO_ICONSET … … 1845 1765 1846 1766 /*! \reimp */ 1847 void QWarp4Style::unPolish (QApplication*)1767 void QWarp4Style::unPolish (QApplication *) 1848 1768 { 1849 1769 #ifndef QT_NO_ICONSET … … 1868 1788 1869 1789 /*! \reimp */ 1870 void QWarp4Style::polish(QWidget* widget) 1871 { 1872 QCommonStyle::polish(widget); 1790 void QWarp4Style::polish (QWidget *widget) 1791 { 1792 if (widget != 0 && widget->inherits ("QTabWidget")) 1793 { 1794 QTabWidget *tw = (QTabWidget *) widget; 1795 1796 #ifndef QT_PM_NO_TABWIDGET_HEADERS 1797 // create the tab panel header widget 1798 new QWarpTabPanelHeader (tw); 1799 #endif 1800 1801 // reduce the widget stack's frame rect to get space for drawing 1802 // PE_PanelTabWidget. Hackish, but there seems to be no any official way 1803 // in the QStyle framework to change the tab the width of the frame 1804 // drawn by PE_PanelTabWidget (QFrame::TabWidgetPanel style). 1805 QWidgetStack *ws = (QWidgetStack *) tw->child ("tab pages", 1806 "QWidgetStack", false); 1807 Q_ASSERT (ws); 1808 if (ws) 1809 { 1810 QRect r = ws->rect(); 1811 #ifndef QT_PM_NO_TABWIDGET_HEADERS 1812 bool reverse = QApplication::reverseLayout(); 1813 if (reverse) 1814 { 1815 if (tw->tabPosition() == QTabWidget::Bottom) 1816 r.addCoords (15, 12, -12, 0); 1817 else 1818 r.addCoords (15, 0, -12, -12); 1819 } 1820 else 1821 { 1822 if (tw->tabPosition() == QTabWidget::Bottom) 1823 r.addCoords (12, 12, -15, 0); 1824 else 1825 r.addCoords (12, 0, -15, -12); 1826 } 1827 #else 1828 if (tw->tabPosition() == QTabWidget::Bottom) 1829 r.addCoords (12, 12, -12, 0); 1830 else 1831 r.addCoords (12, 0, -12, -12); 1832 #endif 1833 ws->setFrameRect (r); 1834 } 1835 } 1836 1837 QCommonStyle::polish (widget); 1873 1838 } 1874 1839 1875 1840 /*! \reimp */ 1876 void QWarp4Style::unPolish(QWidget* widget) 1877 { 1878 QCommonStyle::polish(widget); 1841 void QWarp4Style::unPolish (QWidget *widget) 1842 { 1843 if (widget != 0 && widget->inherits ("QTabWidget")) 1844 { 1845 QTabWidget *tw = (QTabWidget *) widget; 1846 1847 // restore the widget stack's frame rect 1848 QWidgetStack *ws = (QWidgetStack *) tw->child ("tab pages", 1849 "QWidgetStack", false); 1850 Q_ASSERT (ws); 1851 if (ws) 1852 ws->setFrameRect (QRect()); 1853 1854 #ifndef QT_PM_NO_TABWIDGET_HEADERS 1855 // delete the tab panel header widget 1856 QWarpTabPanelHeader* tph = 1857 (QWarpTabPanelHeader *) tw->child ("qt_warp_tabpanel_header", 1858 "QWarpTabPanelHeader", false); 1859 Q_ASSERT (tph); 1860 if (tph != 0) 1861 delete tph; 1862 #endif 1863 } 1864 1865 QCommonStyle::unPolish (widget); 1879 1866 } 1880 1867 1881 1868 /*! \reimp */ 1882 void QWarp4Style::polish (QPalette&pal)1883 { 1884 QCommonStyle::polish (pal);1869 void QWarp4Style::polish (QPalette &pal) 1870 { 1871 QCommonStyle::polish (pal); 1885 1872 } 1886 1873 … … 2188 2175 case PE_PanelTabWidget: 2189 2176 { 2190 // compensate for artificially reduced frame size 2191 // note that we get the information about "bottom" or "top" tabs 2192 // from the "mid line width" in the "opt" parameter 2193 // (see also QWarpTabPanelHeader::QWarpTabPanelHeader) 2194 bool bottom = (bool)opt.midLineWidth(); 2195 QRect rr1(rr), rr2(rr); 2196 if(bottom) 2197 { 2198 rr1.addCoords(-11, -11, 14, 0); 2199 rr2.addCoords(0, 0, 3, 0); 2177 bool reverse = QApplication::reverseLayout(); 2178 2179 QRect rr2 (rr); 2180 2181 // compensate for reduced frame rect in polish(). Note that due to 2182 // this frame rect hack, it's not possible to draw a 2183 // QFrame::TabWidgetPanel styled frame outside the QTabWidget 2184 // context. 2185 #ifndef QT_PM_NO_TABWIDGET_HEADERS 2186 if (reverse) 2187 { 2188 rr.addCoords (-15, -12, 12, 12); 2189 rr2.addCoords (-4, -1, 1, 1); 2200 2190 } 2201 2191 else 2202 2192 { 2203 rr1.addCoords(-11, 0, 14, 11); 2204 rr2.addCoords(0, 0, 3, 0); 2205 } 2206 p->setClipRect(rr1); 2207 2208 p->setPen(cg.light()); 2209 if(bottom) 2210 { 2211 p->drawLine(rr1.left(), rr1.top(), rr1.left(), rr1.bottom()); 2212 p->drawLine(rr1.left(), rr1.top(), rr1.right(), rr1.top()); 2213 p->drawLine(rr2.right(), rr2.top(), rr2.right(), rr2.bottom()); 2214 } 2193 rr.addCoords (-12, -12, 15, 12); 2194 rr2.addCoords (-1, -1, 4, 1); 2195 } 2196 #else 2197 rr.addCoords (-12, -12, 12, 12); 2198 rr2.addCoords (-1, -1, 1, 1); 2199 #endif 2200 2201 p->setClipRect (rr); 2202 2203 for (int i = 0; i < 2; ++ i) 2204 { 2205 p->setPen (i == 0 ? cg.light() : cg.dark()); 2206 if (i > 0) 2207 { 2208 QRect rt = rr2; 2209 rr2 = rr; 2210 rr = rt; 2211 } 2212 2213 p->drawLine (rr.left(), rr.top(), rr.left(), rr.bottom() - 1); 2214 p->drawLine (rr.left(), rr.top(), rr.right(), rr.top()); 2215 p->drawLine (rr2.left(), rr2.bottom(), rr2.right(), rr2.bottom()); 2216 p->drawLine (rr2.right(), rr2.top() + 1, rr2.right(), rr2.bottom()); 2217 } 2218 2219 #ifndef QT_PM_NO_TABWIDGET_HEADERS 2220 if (reverse) 2221 p->drawLine (rr.left() + 3, rr.bottom() - 2, 2222 rr.left() + 3, rr.top() + 2); 2215 2223 else 2216 { 2217 p->drawLine(rr1.left(), rr1.top(), rr1.left(), rr1.bottom() - 1); 2218 p->drawLine(rr2.left(), rr2.bottom(), rr2.right(), rr2.bottom()); 2219 p->drawLine(rr2.right(), rr2.top(), rr2.right(), rr2.bottom()); 2220 } 2221 2222 p->setPen(cg.dark()); 2223 if(bottom) 2224 { 2225 p->drawLine(rr1.right(), rr1.top(), rr1.right(), rr1.bottom()); 2226 p->drawLine(rr2.left(), rr2.top(), rr2.right(), rr2.top()); 2227 p->drawLine(rr2.left(), rr2.top(), rr2.left(), rr2.bottom()); 2228 rr2.addCoords(0, 2, -3, 0); 2229 p->drawLine(rr2.right(), rr2.top(), rr2.right(), rr2.bottom()); 2230 } 2224 p->drawLine (rr.right() - 3, rr.bottom() - 2, 2225 rr.right() - 3, rr.top() + 2); 2226 #endif 2227 break; 2228 } 2229 2230 case PE_PanelMenuBar: 2231 { 2232 // It looks like this code is never being called! 2233 break; 2234 } 2235 2236 case PE_PanelGroupBox: 2237 { 2238 qDrawWarpPanel(p, rr, cg, 0); 2239 break; 2240 } 2241 2242 case PE_TabBarBase: 2243 { 2244 bool bottom = flags & Style_Bottom; 2245 2246 QRect rr2 (rr); 2247 if (bottom) 2248 rr2.addCoords (11, 0, -11, -11); 2231 2249 else 2232 { 2233 p->drawLine(rr1.left(), rr1.bottom(), rr1.right(), rr1.bottom()); 2234 p->drawLine(rr1.right(), rr1.top(), rr1.right(), rr1.bottom()); 2235 p->drawLine(rr2.left(), rr2.top(), rr2.left(), rr2.bottom() - 1); 2236 rr2.addCoords(0, 0, -3, -2); 2237 p->drawLine(rr2.right(), rr2.top(), rr2.right(), rr2.bottom()); 2238 } 2239 2240 break; 2241 } 2242 2243 case PE_PanelMenuBar: 2244 { 2245 // It looks like this code is never being called! 2246 break; 2247 } 2248 2249 case PE_PanelGroupBox: 2250 { 2251 qDrawWarpPanel(p, rr, cg, 0); 2252 break; 2253 } 2254 2255 case PE_TabBarBase: 2256 { 2257 bool bottom = flags & Style_Bottom; 2258 if(bottom) 2259 rr.addCoords(0, 0, 0, -1); 2260 else 2261 rr.addCoords(0, 1, 0, 0); 2262 QRect rr2(rr); 2263 if(bottom) 2264 rr2.addCoords(11, 0, -11, -11); 2265 else 2266 rr2.addCoords(11, 11, -11, 0); 2267 2268 p->setPen(cg.light()); 2269 if(bottom) 2270 { 2271 p->drawLine(rr.left(), rr.top(), rr.left(), rr.bottom()); 2272 p->drawLine(rr2.right(), rr2.top(), rr2.right(), rr2.bottom()); 2273 p->drawLine(rr2.left(), rr2.bottom(), rr2.right(), rr2.bottom()); 2274 #ifndef QT_PM_NO_TABWIDGET_HEADERS 2275 p->drawLine(rr2.left() + 6, rr2.top() + 2, rr2.right() - 9, rr2.top() + 2); 2276 #endif 2277 } 2278 else 2279 { 2280 p->drawLine(rr.left(), rr.top(), rr.right(), rr.top()); 2281 p->drawLine(rr.left(), rr.top(), rr.left(), rr.bottom()); 2282 p->drawLine(rr2.right(), rr2.top() + 1, rr2.right(), rr2.bottom()); 2283 #ifndef QT_PM_NO_TABWIDGET_HEADERS 2284 p->drawLine(rr2.left() + 6, rr2.bottom() - 1, rr2.right() - 9, rr2.bottom() - 1); 2285 #endif 2286 } 2287 2288 p->setPen(cg.dark()); 2289 if(bottom) 2290 { 2291 p->drawLine(rr.left(), rr.bottom(), rr.right(), rr.bottom()); 2292 p->drawLine(rr.right(), rr.top(), rr.right(), rr.bottom()); 2293 p->drawLine(rr2.left(), rr2.top(), rr2.left(), rr2.bottom() - 1); 2294 #ifndef QT_PM_NO_TABWIDGET_HEADERS 2295 p->drawLine(rr2.left() + 6, rr2.top() + 1, rr2.right() - 9, rr2.top() + 1); 2296 #endif 2297 rr2.addCoords(2, 0, -3, -2); 2298 p->drawLine(rr2.left(), rr2.bottom(), rr2.right(), rr2.bottom()); 2299 p->drawLine(rr2.right(), rr2.top(), rr2.right(), rr2.bottom()); 2300 } 2301 else 2302 { 2303 p->drawLine(rr.right(), rr.top(), rr.right(), rr.bottom()); 2304 p->drawLine(rr2.left(), rr2.top(), rr2.right(), rr2.top()); 2305 p->drawLine(rr2.left(), rr2.top(), rr2.left(), rr2.bottom()); 2306 #ifndef QT_PM_NO_TABWIDGET_HEADERS 2307 p->drawLine(rr2.left() + 6, rr2.bottom() - 2, rr2.right() - 9, rr2.bottom() - 2); 2308 #endif 2309 rr2.addCoords(2, 2, -3, 0); 2310 p->drawLine(rr2.left(), rr2.top(), rr2.right(), rr2.top()); 2311 p->drawLine(rr2.right(), rr2.top(), rr2.right(), rr2.bottom()); 2250 rr2.addCoords (11, 11, -11, 0); 2251 2252 for (int i = 0; i < 2; ++ i) 2253 { 2254 p->setPen (i == 0 ? cg.light() : cg.dark()); 2255 if (i > 0) 2256 { 2257 QRect rt = rr2; 2258 rr2 = rr; 2259 rr = rt; 2260 } 2261 2262 if(bottom) 2263 { 2264 p->drawLine (rr.left(), rr.top(), rr.left(), rr.bottom() - 1); 2265 p->drawLine (rr2.right(), rr2.top(), rr2.right(), rr2.bottom()); 2266 p->drawLine (rr2.left(), rr2.bottom(), rr2.right(), rr2.bottom()); 2267 } 2268 else 2269 { 2270 p->drawLine (rr.left(), rr.top(), rr.right(), rr.top()); 2271 p->drawLine (rr.left(), rr.top(), rr.left(), rr.bottom()); 2272 p->drawLine (rr2.right(), rr2.top() + 1, rr2.right(), rr2.bottom()); 2273 } 2312 2274 } 2313 2275 … … 2629 2591 (QTabBar::TriangularBelow == tb->shape()); 2630 2592 int id = tb->indexOf(t->identifier()); 2631 2632 // check if the panel header widget is already present and2633 // create them here2634 // note that this is the only place to do it from within the2635 // style class!2636 QWarpTabPanelHeader::addIfNotPresent(tb);2637 2593 2638 2594 static const QColor tabCols[10] = … … 2698 2654 tr.addCoords(-hdiff / 2, 0, hdiff / 2, 0); 2699 2655 2656 #ifndef QT_PM_NO_TABWIDGET_HEADERS 2700 2657 QWidget* pw = widget->parentWidget(); 2701 if ((0 != pw) && (pw->inherits("QTabWidget")))2658 if (pw != 0 && pw->inherits ("QTabWidget")) 2702 2659 { 2703 QTabWidget * tw = (QTabWidget*)pw;2704 QWarpTabPanelHeader * twh =2705 (QWarpTabPanelHeader *)tw->child("qt_warp_tabpanel_header",2706 "QWarpTabPanelHeader", false);2707 if (0 != twh)2660 QTabWidget *tw = (QTabWidget *) pw; 2661 QWarpTabPanelHeader *tph = 2662 (QWarpTabPanelHeader *) tw->child ("qt_warp_tabpanel_header", 2663 "QWarpTabPanelHeader", false); 2664 if (tph != 0) 2708 2665 { 2709 t wh->setCaption(t->text());2710 QRect r (twh->visibleRect());2711 t wh->repaint();2666 tph->setCaption (t->text()); 2667 QRect r (tph->visibleRect()); 2668 tph->repaint(); 2712 2669 } 2713 2670 } 2671 #endif // QT_PM_NO_TABWIDGET_HEADERS 2714 2672 } 2715 2673 … … 3160 3118 \reimp 3161 3119 */ 3162 int QWarp4Style::pixelMetric (PixelMetric metric, QWidget const*widget) const3120 int QWarp4Style::pixelMetric (PixelMetric metric, const QWidget *widget) const 3163 3121 { 3164 3122 int ret; … … 3177 3135 case PM_ExclusiveIndicatorWidth: 3178 3136 { 3179 QPixmap const* ip = qWarpSystemPixmaps.getPixmap (QWarpPixmap::chkboxnormal,3180 QWarpPixmap::internal);3137 QPixmap const* ip = qWarpSystemPixmaps.getPixmap (QWarpPixmap::chkboxnormal, 3138 QWarpPixmap::internal); 3181 3139 ret = ip->width(); 3182 3140 break; … … 3186 3144 case PM_ExclusiveIndicatorHeight: 3187 3145 { 3188 QPixmap const* ip = qWarpSystemPixmaps.getPixmap (QWarpPixmap::chkboxnormal,3189 QWarpPixmap::internal);3146 QPixmap const* ip = qWarpSystemPixmaps.getPixmap (QWarpPixmap::chkboxnormal, 3147 QWarpPixmap::internal); 3190 3148 ret = ip->height(); 3191 3149 break; 3192 3150 } 3193 3151 3194 #ifndef QT_NO_SCROLLBAR 3195 case PM_ScrollBarExtent: 3196 { 3197 if(!widget) 3198 { 3199 ret = 16; 3200 } 3201 else 3202 { 3203 QScrollBar const* bar = (QScrollBar const*)widget; 3204 int s = (bar->orientation() == Qt::Horizontal) ? 3205 QApplication::globalStrut().height() : 3206 QApplication::globalStrut().width(); 3207 ret = QMAX(16, s); 3208 } 3209 3152 #ifndef QT_NO_SCROLLBAR 3153 case PM_ScrollBarExtent: 3154 { 3155 if (!widget) 3156 { 3157 ret = 16; 3158 } 3159 else 3160 { 3161 const QScrollBar * bar = (const QScrollBar *) widget; 3162 int s = (bar->orientation() == Qt::Horizontal) ? 3163 QApplication::globalStrut().height() : 3164 QApplication::globalStrut().width(); 3165 ret = QMAX(16, s); 3166 } 3167 3168 break; 3169 } 3170 3171 case PM_ScrollBarSliderMin: 3172 { 3173 ret = 20; 3174 break; 3175 } 3176 #endif 3177 3178 case PM_MaximumDragDistance: 3179 { 3180 ret = -1; 3181 break; 3182 } 3183 3184 #ifndef QT_NO_SLIDER 3185 case PM_SliderThickness: 3186 { 3187 ret = 20; 3188 break; 3189 } 3190 3191 case PM_SliderLength: 3192 { 3193 // we increase the "length" by 2 x 2, but then draw the slider 2 pixels 3194 // smaller than indicated, so we get the effect of a slider that does 3195 // not fully touch the extreme ends of the "groove" 3196 ret = 12 + 4; 3197 break; 3198 } 3199 3200 // Returns the number of pixels to use for the business part of the 3201 // slider (i.e., the non-tickmark portion). The remaining space is shared 3202 // equally between the tickmark regions. 3203 case PM_SliderControlThickness: 3204 { 3205 QSlider const* sl = (QSlider const*) widget; 3206 int space = (sl->orientation() == Horizontal) ? sl->height() : sl->width(); 3207 int ticks = sl->tickmarks(); 3208 int n = 0; 3209 if (ticks & QSlider::Above) 3210 n++; 3211 if (ticks & QSlider::Below) 3212 n++; 3213 if (!n) 3214 { 3215 ret = space; 3210 3216 break; 3211 3217 } 3212 3218 3213 case PM_ScrollBarSliderMin: 3214 { 3215 ret = 20; 3219 int thick = 6; // Magic constant to get 5 + 16 + 5 3220 if (ticks != QSlider::Both && ticks != QSlider::NoMarks) 3221 thick += pixelMetric (PM_SliderLength, sl) / 4; 3222 3223 space -= thick; 3224 //### the two sides may be unequal in size 3225 if(space > 0) 3226 thick += (space * 2) / (n + 2); 3227 ret = thick; 3228 3229 break; 3230 } 3231 #endif // QT_NO_SLIDER 3232 3233 case PM_MenuBarFrameWidth: 3234 { 3235 ret = 0; 3236 break; 3237 } 3238 3239 case PM_MenuBarItemSpacing: 3240 { 3241 ret = 8; 3242 break; 3243 } 3244 3245 case PM_PopupMenuFrameHorizontalExtra: 3246 { 3247 ret = 0; 3248 break; 3249 } 3250 3251 case PM_PopupMenuFrameVerticalExtra: 3252 { 3253 ret = 1; 3254 break; 3255 } 3256 3257 case PM_DefaultFrameWidth: 3258 { 3259 if (widget && widget->inherits ("QWidgetStack") && 3260 !qstrcmp (widget->name(), "tab pages")) 3261 { 3262 #ifndef QT_PM_NO_TABWIDGET_HEADERS 3263 // cause 1px overlap with the tab header base widget to get the 3264 // left vertical line joined with the bended corner (see the 3265 // PE_PanelTabWidget primitive and QTabWidget::setUpLayout()) 3266 ret = 1; 3267 #else 3268 // no frame is drawn within the the widget stack frame rect 3269 ret = 0; 3270 #endif 3216 3271 break; 3217 3272 } 3218 #endif 3219 3220 case PM_MaximumDragDistance: 3221 { 3222 ret = -1; 3223 break; 3224 } 3225 3226 #ifndef QT_NO_SLIDER 3227 case PM_SliderThickness: 3228 { 3229 ret = 20; 3230 break; 3231 } 3232 3233 case PM_SliderLength: 3234 { 3235 // we increase the "length" by 2 x 2, but then draw the slider 2 pixels 3236 // smaller than indicated, so we get the effect of a slider that does 3237 // not fully touch the extreme ends of the "groove" 3238 ret = 12 + 4; 3239 break; 3240 } 3241 3242 // Returns the number of pixels to use for the business part of the 3243 // slider (i.e., the non-tickmark portion). The remaining space is shared 3244 // equally between the tickmark regions. 3245 case PM_SliderControlThickness: 3246 { 3247 QSlider const* sl = (QSlider const*) widget; 3248 int space = (sl->orientation() == Horizontal) ? sl->height() : sl->width(); 3249 int ticks = sl->tickmarks(); 3250 int n = 0; 3251 if(ticks & QSlider::Above) 3252 n++; 3253 if(ticks & QSlider::Below) 3254 n++; 3255 if(!n) 3256 { 3257 ret = space; 3258 break; 3259 } 3260 3261 int thick = 6; // Magic constant to get 5 + 16 + 5 3262 if(ticks != QSlider::Both && ticks != QSlider::NoMarks) 3263 thick += pixelMetric(PM_SliderLength, sl) / 4; 3264 3265 space -= thick; 3266 //### the two sides may be unequal in size 3267 if(space > 0) 3268 thick += (space * 2) / (n + 2); 3269 ret = thick; 3270 3271 break; 3272 } 3273 #endif // QT_NO_SLIDER 3274 3275 case PM_MenuBarFrameWidth: 3276 { 3277 ret = 0; 3278 break; 3279 } 3280 3281 case PM_MenuBarItemSpacing: 3282 { 3283 ret = 8; 3284 break; 3285 } 3286 3287 case PM_PopupMenuFrameHorizontalExtra: 3288 { 3289 ret = 0; 3290 break; 3291 } 3292 3293 case PM_PopupMenuFrameVerticalExtra: 3294 { 3295 ret = 1; 3273 ret = QCommonStyle::pixelMetric (metric, widget); 3296 3274 break; 3297 3275 } … … 3306 3284 { 3307 3285 #ifndef QT_PM_NO_TABWIDGET_HEADERS 3308 ret = QFontMetrics (QApplication::font()).boundingRect("X").height() + 29;3286 ret = QFontMetrics (widget->font()).boundingRect ("X").height() + 28; 3309 3287 #else 3310 ret = 1 6;3288 ret = 12; 3311 3289 #endif 3312 3290 break; … … 3315 3293 case PM_TabBarBaseOverlap: 3316 3294 { 3317 ret = 6;3295 ret = 5; 3318 3296 break; 3319 3297 } … … 3375 3353 { 3376 3354 #ifndef QT_NO_PUSHBUTTON 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3355 const QPushButton* button = (const QPushButton*)widget; 3356 sz = QCommonStyle::sizeFromContents(contents, widget, contentsSize, opt); 3357 int w = sz.width(), 3358 h = sz.height(); 3359 3360 int defwidth = 0; 3361 if(button->isDefault() || button->autoDefault()) 3362 defwidth = 2 * pixelMetric(PM_ButtonDefaultIndicator, widget); 3363 if(w < 80 + defwidth && !button->pixmap()) 3364 w = 80 + defwidth; 3365 if(h < 23 + defwidth) 3366 h = 23 + defwidth; 3367 3368 sz = QSize(w, h); 3391 3369 #endif // QT_NO_PUSHBUTTON 3392 3370 … … 3405 3383 { 3406 3384 #ifndef QT_NO_POPUPMENU 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3385 if(! widget || opt.isDefault()) 3386 break; 3387 3388 QPopupMenu const* popup = (QPopupMenu const*)widget; 3389 QMenuItem* mi = opt.menuItem(); 3390 int iconw = QMAX(11, opt.maxIconWidth()); 3391 QString s = mi->text(); 3392 int w = sz.width(), 3393 h = sz.height(); 3394 3395 if(mi->custom()) 3396 { 3397 w = mi->custom()->sizeHint().width(); 3398 h = mi->custom()->sizeHint().height(); 3399 if(!mi->custom()->fullSpan()) 3400 w += iconw; 3401 } 3402 else if(mi->widget()) 3403 { 3404 } 3405 else if(mi->isSeparator()) 3406 { 3407 w = 10; // arbitrary 3408 h = 8; 3409 } 3410 else 3411 { 3412 if(mi->pixmap()) 3413 h = QMAX(h, mi->pixmap()->height() + 3); 3414 else if(!s.isNull()) 3415 h = QMAX(h, popup->fontMetrics().height() + 1); 3416 3417 if(mi->iconSet()) 3418 { 3419 h = QMAX(h, mi->iconSet()-> 3420 pixmap(QIconSet::Small, QIconSet::Normal).height() + 3); 3421 w = QMAX(w, iconw); 3422 } 3423 } 3424 3425 if(!s.isNull()) 3426 { 3427 w += 19; 3428 } 3429 3430 if(qPopupMenuHasSub(popup)) 3431 { 3432 w += 19; 3433 } 3434 3435 w += 9; 3436 3437 sz = QSize(w, h); 3460 3438 #endif // QT_NO_POPUPMENU 3461 3439 … … 3515 3493 QStyleOption const& opt) const 3516 3494 { 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3495 #ifndef QT_NO_IMAGEIO_XPM 3496 switch (stylepixmap) 3497 { 3498 // SP_TitleBarShadeButton - shade button on titlebars. 3499 case SP_TitleBarShadeButton: 3500 return *qWarpSystemPixmaps.getPixmap(54, // any SBMP_ value?? 3501 QWarpPixmap::bmp); 3502 3503 // SP_TitleBarUnshadeButton - unshade button on titlebars. 3504 case SP_TitleBarUnshadeButton: 3505 return *qWarpSystemPixmaps.getPixmap(56, // any SBMP_ value?? 3506 QWarpPixmap::bmp); 3507 3508 // SP_TitleBarNormalButton - normal (restore) button on titlebars. 3509 case SP_TitleBarNormalButton: 3510 return *qWarpSystemPixmaps.getPixmap(SBMP_RESTOREBUTTON, 3511 QWarpPixmap::bmp); 3512 3513 // SP_TitleBarMinButton - minimize button on titlebars. For example, in a QWorkspace. 3514 case SP_TitleBarMinButton: 3515 return *qWarpSystemPixmaps.getPixmap(SBMP_MINBUTTON, 3516 QWarpPixmap::bmp); 3517 3518 // SP_TitleBarMaxButton - maximize button on titlebars. 3519 case SP_TitleBarMaxButton: 3520 return *qWarpSystemPixmaps.getPixmap(SBMP_MAXBUTTON, 3521 QWarpPixmap::bmp); 3522 3523 // SP_TitleBarCloseButton - close button on titlebars. 3524 case SP_TitleBarCloseButton: 3525 return *qWarpSystemPixmaps.getPixmap(52, // any SBMP_ value?? 3526 QWarpPixmap::bmp); 3527 3528 // SP_DockWindowCloseButton - close button on dock windows; see also QDockWindow. 3529 case SP_DockWindowCloseButton: 3530 return *qWarpSystemPixmaps.getPixmap(52, // should be a bit smaller! 3531 QWarpPixmap::bmp); 3532 3533 // SP_MessageBoxInformation - the 'information' icon. 3534 case SP_MessageBoxInformation: 3535 return *qWarpSystemPixmaps.getPixmap(SPTR_ICONINFORMATION, 3536 QWarpPixmap::ico); 3537 3538 // SP_MessageBoxWarning - the 'warning' icon. 3539 case SP_MessageBoxWarning: 3540 return *qWarpSystemPixmaps.getPixmap(SPTR_ICONWARNING, 3541 QWarpPixmap::ico); 3542 3543 // SP_MessageBoxCritical - the 'critical' icon. 3544 case SP_MessageBoxCritical: 3545 return *qWarpSystemPixmaps.getPixmap(SPTR_ICONERROR, 3546 QWarpPixmap::ico); 3547 3548 // SP_MessageBoxQuestion - the 'question' icon. 3549 case SP_MessageBoxQuestion: 3550 return *qWarpSystemPixmaps.getPixmap(SPTR_ICONQUESTION, 3551 QWarpPixmap::ico); 3552 3553 default: 3554 break; 3555 } 3556 #endif //QT_NO_IMAGEIO_XPM 3579 3557 3580 3558 return QCommonStyle::stylePixmap(stylepixmap, widget, opt); … … 3594 3572 switch (ctrl) 3595 3573 { 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3574 #ifndef QT_NO_SCROLLBAR 3575 case CC_ScrollBar: 3576 { 3577 QScrollBar const* scrollbar = (QScrollBar const*)widget; 3578 bool maxedOut = (scrollbar->minValue() == scrollbar->maxValue()); 3579 3580 QRect subline = querySubControlMetrics(ctrl, widget, SC_ScrollBarSubLine, opt), 3581 addline = querySubControlMetrics(ctrl, widget, SC_ScrollBarAddLine, opt), 3582 subpage = querySubControlMetrics(ctrl, widget, SC_ScrollBarSubPage, opt), 3583 addpage = querySubControlMetrics(ctrl, widget, SC_ScrollBarAddPage, opt), 3584 slider = querySubControlMetrics(ctrl, widget, SC_ScrollBarSlider, opt); 3585 if(!scrollbar->isEnabled()) 3586 { 3587 subpage.unite(addpage).unite(slider); // fill the whole, empty bar 3588 addpage = slider = QRect(); // invalid rectangle 3589 maxedOut = true; // to avoid setting the Style_Enabled flag 3590 } 3591 bool isMin = scrollbar->value() <= scrollbar->minValue(), 3592 isMax = scrollbar->value() >= scrollbar->maxValue(); 3593 3594 if((sub & SC_ScrollBarSubLine) && subline.isValid()) 3595 drawPrimitive(PE_ScrollBarSubLine, p, subline, cg, 3596 ((maxedOut || isMin) ? Style_Default : Style_Enabled) | 3597 ((!isMin && (subActive == SC_ScrollBarSubLine)) ? Style_Down : Style_Default) | 3598 ((scrollbar->orientation() == Qt::Horizontal) ? Style_Horizontal : 0)); 3599 if((sub & SC_ScrollBarAddLine) && addline.isValid()) 3600 drawPrimitive(PE_ScrollBarAddLine, p, addline, cg, 3601 ((maxedOut || isMax) ? Style_Default : Style_Enabled) | 3602 ((!isMax && (subActive == SC_ScrollBarAddLine)) ? Style_Down : Style_Default) | 3603 ((scrollbar->orientation() == Qt::Horizontal) ? Style_Horizontal : 0)); 3604 if((sub & SC_ScrollBarSubPage) && subpage.isValid()) 3605 drawPrimitive(PE_ScrollBarSubPage, p, subpage, cg, 3606 ((maxedOut) ? Style_Default : Style_Enabled) | 3607 ((subActive == SC_ScrollBarSubPage) ? Style_Down : Style_Default) | 3608 ((scrollbar->orientation() == Qt::Horizontal) ? Style_Horizontal : 0)); 3609 if((sub & SC_ScrollBarAddPage) && addpage.isValid()) 3610 drawPrimitive(PE_ScrollBarAddPage, p, addpage, cg, 3611 ((maxedOut) ? Style_Default : Style_Enabled) | 3612 ((subActive == SC_ScrollBarAddPage) ? Style_Down : Style_Default) | 3613 ((scrollbar->orientation() == Qt::Horizontal) ? Style_Horizontal : 0)); 3614 if((sub & SC_ScrollBarSlider) && slider.isValid()) 3615 drawPrimitive(PE_ScrollBarSlider, p, slider, cg, 3616 ((maxedOut) ? Style_Default : Style_Enabled) | 3617 ((subActive == SC_ScrollBarSlider) ? Style_Down : Style_Default) | 3618 ((scrollbar->orientation() == Qt::Horizontal) ? Style_Horizontal : 0)); 3619 3620 break; 3621 } 3622 #endif // QT_NO_SCROLLBAR 3645 3623 3646 3624 case CC_SpinWidget: 3647 3625 { 3648 #ifndef QT_NO_SPINWIDGET 3649 QSpinWidget const* sw = (QSpinWidget const*)widget; 3650 SFlags flags; 3651 PrimitiveElement pe; 3652 3653 if(sub & SC_SpinWidgetFrame) 3654 { 3655 qDrawWarpPanel(p, r, cg, -1); 3656 } 3657 3658 if((sub & SC_SpinWidgetUp) || 3659 (sub & SC_SpinWidgetDown)) 3660 { 3661 flags = Style_Enabled; 3662 if((subActive == SC_SpinWidgetUp) || 3663 (subActive == SC_SpinWidgetDown)) 3664 flags |= Style_Sunken; 3626 #ifndef QT_NO_SPINWIDGET 3627 QSpinWidget const* sw = (QSpinWidget const*)widget; 3628 SFlags flags; 3629 PrimitiveElement pe; 3630 3631 if(sub & SC_SpinWidgetFrame) 3632 { 3633 qDrawWarpPanel(p, r, cg, -1); 3634 } 3635 3636 if((sub & SC_SpinWidgetUp) || 3637 (sub & SC_SpinWidgetDown)) 3638 { 3639 flags = Style_Enabled; 3640 if((subActive == SC_SpinWidgetUp) || 3641 (subActive == SC_SpinWidgetDown)) 3642 flags |= Style_Sunken; 3643 else 3644 flags |= Style_Raised; 3645 3646 // we "misuse" the On flag to indicate whether the 3647 // "up" part or the "down" part of the button is sunken 3648 if(subActive == SC_SpinWidgetUp) 3649 flags |= Style_On; 3650 3651 if(sub & SC_SpinWidgetUp) 3652 { 3653 if(sw->buttonSymbols() == QSpinWidget::PlusMinus) 3654 pe = PE_SpinWidgetPlus; 3665 3655 else 3666 flags |= Style_Raised; 3667 3668 // we "misuse" the On flag to indicate whether the 3669 // "up" part or the "down" part of the button is sunken 3670 if(subActive == SC_SpinWidgetUp) 3671 flags |= Style_On; 3672 3673 if(sub & SC_SpinWidgetUp) 3656 pe = PE_SpinWidgetUp; 3657 } 3658 else 3659 { 3660 if(sw->buttonSymbols() == QSpinWidget::PlusMinus) 3661 pe = PE_SpinWidgetMinus; 3662 else 3663 pe = PE_SpinWidgetDown; 3664 } 3665 3666 QRect re = sw->upRect(); 3667 re.setWidth(re.width() - 2); 3668 bool reverse = QApplication::reverseLayout(); 3669 if(!reverse) 3670 re.moveLeft(re.left() + 2); 3671 drawPrimitive(pe, p, re, cg, flags); 3672 3673 // doesn't work yet... 3674 int x = re.left() - 1; 3675 if(reverse) 3676 { 3677 x = re.right() + 2; 3678 p->setPen(cg.light()); 3679 } 3680 else 3681 { 3682 p->setPen(cg.dark()); 3683 } 3684 p->drawLine(x, re.top(), x, re.bottom()); 3685 p->setPen(cg.button()); 3686 x--; 3687 p->drawLine(x, re.top(), x, re.bottom()); 3688 } 3689 3690 //if(sub & SC_SpinWidgetDown) 3691 //{ 3692 // do nothing! 3693 // note: for the Warp style we put all the up/down button 3694 // functionality into the "up" button with the diagonal 3695 // separator 3696 //} 3697 #endif 3698 3699 break; 3700 } 3701 3702 #ifndef QT_NO_TOOLBUTTON 3703 case CC_ToolButton: 3704 { 3705 bool right; 3706 if((right = (QString("qt_right_btn") == widget->name())) || 3707 (QString("qt_left_btn") == widget->name())) 3708 { 3709 QToolButton* tb = (QToolButton*)widget; 3710 QTabBar* ptb = (QTabBar*)tb->parentWidget(); 3711 if((0 == ptb) || !ptb->inherits("QTabBar")) 3712 return; 3713 bool bottom = (QTabBar::RoundedBelow == ptb->shape()) || 3714 (QTabBar::TriangularBelow == ptb->shape()); 3715 3716 QRect r(visualRect(querySubControlMetrics(ctrl, widget, SC_ToolButton, opt), widget)); 3717 if(right) 3718 r.addCoords(-3, 0, 0, 0); 3719 else 3720 r.addCoords(0, 0, 3, 0); 3721 p->setClipRect(r); 3722 3723 p->setPen(cg.dark()); 3724 if(right) 3725 { 3726 if(bottom) 3727 p->drawLine(r.right(), r.top(), r.right(), r.top() + 3); 3728 else 3729 p->drawLine(r.right(), r.bottom(), r.right(), r.bottom() - 3); 3730 } 3731 3732 QRect tr1(r), tr2(r); 3733 if(right) 3734 { 3735 tr1.addCoords(-1, 0, 1, 0); 3736 tr2.addCoords(-21, 0, -21, 0); 3737 } 3738 else 3739 { 3740 tr1.addCoords(21, 0, 21, 0); 3741 tr2.addCoords(-1, 0, 1, 0); 3742 } 3743 3744 QColorGroup const& cg(tb->colorGroup()); 3745 qDrawTabBar(p, tr1, cg, cg.background(), false, bottom); 3746 qDrawTabBar(p, tr2, cg, cg.background(), false, bottom); 3747 3748 if(bottom) 3749 r.addCoords(0, 2, 0, 2); 3750 QPointArray triang; 3751 if(right) 3752 { 3753 triang.putPoints(0, 3, 3754 r.left() + 8, r.top() + 6, 3755 r.left() + 19, r.top() + 12, 3756 r.left() + 8, r.top() + 18); 3757 } 3758 else 3759 { 3760 triang.putPoints(0, 3, 3761 r.right() - 10, r.top() + 6, 3762 r.right() - 21, r.top() + 12, 3763 r.right() - 10, r.top() + 18); 3764 } 3765 p->setBrush(QColor(0, 0, 255)); 3766 p->setPen(QPen::NoPen); 3767 p->drawPolygon(triang); 3768 } 3769 3770 else 3771 { 3772 QCommonStyle::drawComplexControl(ctrl, p, widget, r, cg, flags, sub, 3773 subActive, opt); 3774 } 3775 3776 break; 3777 } 3778 #endif // QT_NO_TOOLBUTTON 3779 3780 #ifndef QT_NO_LISTVIEW 3781 case CC_ListView: 3782 { 3783 if(sub & SC_ListView) 3784 { 3785 QCommonStyle::drawComplexControl(ctrl, p, widget, r, cg, flags, sub, subActive, opt); 3786 } 3787 3788 if(sub & (SC_ListViewBranch | SC_ListViewExpand)) 3789 { 3790 QListViewItem *item = opt.listViewItem(), 3791 *child = item->firstChild(); 3792 QListView* v = item->listView(); 3793 int y = r.y(); 3794 int bx = r.width() / 2; 3795 int // linetop = 0, 3796 linebot = 0; 3797 3798 // skip the stuff above the exposed rectangle 3799 while(child && ((y + child->height()) <= 0)) 3800 { 3801 y += child->totalHeight(); 3802 child = child->nextSibling(); 3803 } 3804 3805 // notes about drawing lines for Warp: 3806 // 1. Warp type lines follow a different logic than the "normal" lines 3807 // for "tree views" in Qt (which follows more or less Windows) 3808 // 2. In order to ensure partial repaints, it looks like we have to 3809 // draw some lines twice: once with the parent and once with the 3810 // child (and hopefully to the same place...) 3811 3812 while(child && (y < r.height())) 3813 { 3814 if(child->isVisible()) 3674 3815 { 3675 if(sw->buttonSymbols() == QSpinWidget::PlusMinus) 3676 pe = PE_SpinWidgetPlus; 3816 int lh; 3817 if(!item->multiLinesEnabled()) 3818 lh = child->height(); 3677 3819 else 3678 pe = PE_SpinWidgetUp; 3679 } 3680 else 3681 { 3682 if(sw->buttonSymbols() == QSpinWidget::PlusMinus) 3683 pe = PE_SpinWidgetMinus; 3684 else 3685 pe = PE_SpinWidgetDown; 3686 } 3687 3688 QRect re = sw->upRect(); 3689 re.setWidth(re.width() - 2); 3690 bool reverse = QApplication::reverseLayout(); 3691 if(!reverse) 3692 re.moveLeft(re.left() + 2); 3693 drawPrimitive(pe, p, re, cg, flags); 3694 3695 // doesn't work yet... 3696 int x = re.left() - 1; 3697 if(reverse) 3698 { 3699 x = re.right() + 2; 3700 p->setPen(cg.light()); 3701 } 3702 else 3703 { 3704 p->setPen(cg.dark()); 3705 } 3706 p->drawLine(x, re.top(), x, re.bottom()); 3707 p->setPen(cg.button()); 3708 x--; 3709 p->drawLine(x, re.top(), x, re.bottom()); 3710 } 3711 3712 //if(sub & SC_SpinWidgetDown) 3713 //{ 3714 // do nothing! 3715 // note: for the Warp style we put all the up/down button 3716 // functionality into the "up" button with the diagonal 3717 // separator 3718 //} 3719 #endif 3720 3721 break; 3722 } 3723 3724 #ifndef QT_NO_TOOLBUTTON 3725 case CC_ToolButton: 3726 { 3727 bool right; 3728 if((right = (QString("qt_right_btn") == widget->name())) || 3729 (QString("qt_left_btn") == widget->name())) 3730 { 3731 QToolButton* tb = (QToolButton*)widget; 3732 QTabBar* ptb = (QTabBar*)tb->parentWidget(); 3733 if((0 == ptb) || !ptb->inherits("QTabBar")) 3734 return; 3735 bool bottom = (QTabBar::RoundedBelow == ptb->shape()) || 3736 (QTabBar::TriangularBelow == ptb->shape()); 3737 3738 QRect r(visualRect(querySubControlMetrics(ctrl, widget, SC_ToolButton, opt), widget)); 3739 if(right) 3740 r.addCoords(-3, 0, 0, 0); 3741 else 3742 r.addCoords(0, 0, 3, 0); 3743 p->setClipRect(r); 3744 3745 p->setPen(cg.dark()); 3746 if(right) 3747 { 3748 if(bottom) 3749 p->drawLine(r.right(), r.top(), r.right(), r.top() + 3); 3750 else 3751 p->drawLine(r.right(), r.bottom(), r.right(), r.bottom() - 3); 3752 } 3753 3754 QRect tr1(r), tr2(r); 3755 if(right) 3756 { 3757 tr1.addCoords(-1, 0, 1, 0); 3758 tr2.addCoords(-21, 0, -21, 0); 3759 } 3760 else 3761 { 3762 tr1.addCoords(21, 0, 21, 0); 3763 tr2.addCoords(-1, 0, 1, 0); 3764 } 3765 3766 QColorGroup const& cg(tb->colorGroup()); 3767 qDrawTabBar(p, tr1, cg, cg.background(), false, bottom); 3768 qDrawTabBar(p, tr2, cg, cg.background(), false, bottom); 3769 3770 if(bottom) 3771 r.addCoords(0, 2, 0, 2); 3772 QPointArray triang; 3773 if(right) 3774 { 3775 triang.putPoints(0, 3, 3776 r.left() + 8, r.top() + 6, 3777 r.left() + 19, r.top() + 12, 3778 r.left() + 8, r.top() + 18); 3779 } 3780 else 3781 { 3782 triang.putPoints(0, 3, 3783 r.right() - 10, r.top() + 6, 3784 r.right() - 21, r.top() + 12, 3785 r.right() - 10, r.top() + 18); 3786 } 3787 p->setBrush(QColor(0, 0, 255)); 3788 p->setPen(QPen::NoPen); 3789 p->drawPolygon(triang); 3790 } 3791 3792 else 3793 { 3794 QCommonStyle::drawComplexControl(ctrl, p, widget, r, cg, flags, sub, 3795 subActive, opt); 3796 } 3797 3798 break; 3799 } 3800 #endif // QT_NO_TOOLBUTTON 3801 3802 #ifndef QT_NO_LISTVIEW 3803 case CC_ListView: 3804 { 3805 if(sub & SC_ListView) 3806 { 3807 QCommonStyle::drawComplexControl(ctrl, p, widget, r, cg, flags, sub, subActive, opt); 3808 } 3809 3810 if(sub & (SC_ListViewBranch | SC_ListViewExpand)) 3811 { 3812 QListViewItem *item = opt.listViewItem(), 3813 *child = item->firstChild(); 3814 QListView* v = item->listView(); 3815 int y = r.y(); 3816 int bx = r.width() / 2; 3817 int // linetop = 0, 3818 linebot = 0; 3819 3820 // skip the stuff above the exposed rectangle 3821 while(child && ((y + child->height()) <= 0)) 3822 { 3823 y += child->totalHeight(); 3824 child = child->nextSibling(); 3825 } 3826 3827 // notes about drawing lines for Warp: 3828 // 1. Warp type lines follow a different logic than the "normal" lines 3829 // for "tree views" in Qt (which follows more or less Windows) 3830 // 2. In order to ensure partial repaints, it looks like we have to 3831 // draw some lines twice: once with the parent and once with the 3832 // child (and hopefully to the same place...) 3833 3834 while(child && (y < r.height())) 3835 { 3836 if(child->isVisible()) 3820 lh = p->fontMetrics().height() + 2 * v->itemMargin(); 3821 lh = QMAX(lh, QApplication::globalStrut().height()); 3822 if((lh % 2) > 0) 3823 lh++; 3824 linebot = y + lh / 2; 3825 p->setPen(cg.shadow()); 3826 3827 // parents and grandparents 3828 int vlx = bx - v->treeStepSize() + 2, 3829 vlyt = linebot - child->height() + 8, 3830 vlyb = linebot - child->height() + 9 + child->totalHeight(); 3831 if(0 <= item->depth()) 3837 3832 { 3838 int lh; 3839 if(!item->multiLinesEnabled()) 3840 lh = child->height(); 3841 else 3842 lh = p->fontMetrics().height() + 2 * v->itemMargin(); 3843 lh = QMAX(lh, QApplication::globalStrut().height()); 3844 if((lh % 2) > 0) 3845 lh++; 3846 linebot = y + lh / 2; 3833 // vertical line for parent 3834 if(item->isOpen()) 3835 { 3836 if(0 == child->nextSibling()) 3837 p->drawLine(vlx, vlyt, vlx, linebot - 2); 3838 else 3839 p->drawLine(vlx, vlyt, vlx, vlyb); 3840 } 3841 3842 // vertical lines for grandparents and "older" 3843 QListViewItem* gp = item; 3844 while(0 < gp->depth()) 3845 { 3846 gp = gp->parent(); 3847 vlx -= v->treeStepSize(); 3848 if(0 != gp->nextSibling()) 3849 p->drawLine(vlx, vlyt, vlx, vlyb); 3850 } 3851 } 3852 3853 // draw child itself 3854 if((child->isExpandable() || child->childCount()) && 3855 (child->height() > 0)) 3856 { 3857 // horizontal line up to button 3858 if((0 <= item->depth()) && item->isOpen()) 3859 { 3860 p->drawLine(bx - v->treeStepSize() + 3, linebot - 2, 3861 bx - 6, linebot - 2); 3862 } 3863 3864 // button 3865 QRect rr(bx - 6, linebot - 9, 16, 16); 3866 drawPrimitive(PE_ButtonCommand, p, rr, cg, 3867 Style_Raised | Style_ButtonDefault); 3868 3869 // plus or minus 3870 p->setPen(cg.light()); 3871 p->drawLine(bx, linebot - 1, bx + 6, linebot - 1); 3872 if(!child->isOpen()) 3873 p->drawLine(bx + 3, linebot + 2, bx + 3, linebot - 4); 3847 3874 p->setPen(cg.shadow()); 3848 3849 // parents and grandparents3850 int vlx = bx - v->treeStepSize() + 2,3851 vlyt = linebot - child->height() + 8, 3852 vlyb = linebot - child->height() + 9 + child->totalHeight();3853 if( 0 <= item->depth())3875 p->drawLine(bx - 1, linebot - 2, bx + 5, linebot - 2); 3876 if(!child->isOpen()) 3877 p->drawLine(bx + 2, linebot + 1, bx + 2, linebot - 5); 3878 3879 // lines below expanded child 3880 if(child->isOpen()) 3854 3881 { 3855 // vertical line for parent 3856 if(item->isOpen()) 3882 // vertical line 3883 p->drawLine(bx + 2, 3884 linebot + child->height() - 15, 3885 bx + 2, 3886 linebot + child->totalHeight() - child->height() - 2); 3887 3888 // horizontal lines at child's children 3889 QListViewItem* child2 = child->firstChild(); 3890 int y2 = linebot + child->height() - 2; 3891 while(child2 && (y2 < r.height())) 3857 3892 { 3858 if(0 == child->nextSibling()) 3859 p->drawLine(vlx, vlyt, vlx, linebot - 2); 3860 else 3861 p->drawLine(vlx, vlyt, vlx, vlyb); 3862 } 3863 3864 // vertical lines for grandparents and "older" 3865 QListViewItem* gp = item; 3866 while(0 < gp->depth()) 3867 { 3868 gp = gp->parent(); 3869 vlx -= v->treeStepSize(); 3870 if(0 != gp->nextSibling()) 3871 p->drawLine(vlx, vlyt, vlx, vlyb); 3893 if(child2->isVisible()) 3894 { 3895 p->drawLine(bx + 2, y2, 3896 bx + v->treeStepSize() - 12, y2); 3897 y2 += child2->totalHeight(); 3898 } 3899 child2 = child2->nextSibling(); 3872 3900 } 3873 3901 } 3874 3875 // draw child itself3876 if((child->isExpandable() || child->childCount()) &&3877 (child->height() > 0))3878 {3879 // horizontal line up to button3880 if((0 <= item->depth()) && item->isOpen())3881 {3882 p->drawLine(bx - v->treeStepSize() + 3, linebot - 2,3883 bx - 6, linebot - 2);3884 }3885 3886 // button3887 QRect rr(bx - 6, linebot - 9, 16, 16);3888 drawPrimitive(PE_ButtonCommand, p, rr, cg,3889 Style_Raised | Style_ButtonDefault);3890 3891 // plus or minus3892 p->setPen(cg.light());3893 p->drawLine(bx, linebot - 1, bx + 6, linebot - 1);3894 if(!child->isOpen())3895 p->drawLine(bx + 3, linebot + 2, bx + 3, linebot - 4);3896 p->setPen(cg.shadow());3897 p->drawLine(bx - 1, linebot - 2, bx + 5, linebot - 2);3898 if(!child->isOpen())3899 p->drawLine(bx + 2, linebot + 1, bx + 2, linebot - 5);3900 3901 // lines below expanded child3902 if(child->isOpen())3903 {3904 // vertical line3905 p->drawLine(bx + 2,3906 linebot + child->height() - 15,3907 bx + 2,3908 linebot + child->totalHeight() - child->height() - 2);3909 3910 // horizontal lines at child's children3911 QListViewItem* child2 = child->firstChild();3912 int y2 = linebot + child->height() - 2;3913 while(child2 && (y2 < r.height()))3914 {3915 if(child2->isVisible())3916 {3917 p->drawLine(bx + 2, y2,3918 bx + v->treeStepSize() - 12, y2);3919 y2 += child2->totalHeight();3920 }3921 child2 = child2->nextSibling();3922 }3923 }3924 }3925 else if((0 <= item->depth()) && item->isOpen())3926 {3927 // horizontal line without button3928 p->setPen(cg.shadow());3929 p->drawLine(bx - v->treeStepSize() + 3, linebot - 2,3930 bx + 8, linebot - 2);3931 }3932 3933 y += child->totalHeight();3934 3902 } 3935 child = child->nextSibling(); 3903 else if((0 <= item->depth()) && item->isOpen()) 3904 { 3905 // horizontal line without button 3906 p->setPen(cg.shadow()); 3907 p->drawLine(bx - v->treeStepSize() + 3, linebot - 2, 3908 bx + 8, linebot - 2); 3909 } 3910 3911 y += child->totalHeight(); 3936 3912 } 3937 } 3938 3939 break; 3940 } 3941 #endif //QT_NO_LISTVIEW 3942 3943 #ifndef QT_NO_COMBOBOX 3944 case CC_ComboBox: 3945 { 3946 if(sub & SC_ComboBoxFrame) 3913 child = child->nextSibling(); 3914 } 3915 } 3916 3917 break; 3918 } 3919 #endif //QT_NO_LISTVIEW 3920 3921 #ifndef QT_NO_COMBOBOX 3922 case CC_ComboBox: 3923 { 3924 if(sub & SC_ComboBoxFrame) 3925 { 3926 qDrawWarpPanel(p, r, cg, -1); 3927 p->setPen(cg.dark()); 3928 int x = r.right() - 2 - 16; 3929 p->drawLine(x, r.top() + 2, x, r.bottom() - 2); 3930 } 3931 3932 if(sub & SC_ComboBoxArrow) 3933 { 3934 QRect ar = visualRect(querySubControlMetrics(CC_ComboBox, widget, 3935 SC_ComboBoxArrow), 3936 widget); 3937 QBrush fill = cg.brush(QColorGroup::Button); 3938 bool sunken = subActive == SC_ComboBoxArrow; 3939 qDrawWarpFilledRect(p, ar, cg.dark(), cg.light(), &fill, 2, sunken); 3940 p->setPen(cg.button()); 3941 p->drawLine(ar.bottomLeft(), ar.topRight()); 3942 QPixmap const* pm = qWarpSystemPixmaps.getPixmap(SBMP_COMBODOWN, 3943 QWarpPixmap::bmp); 3944 QPoint ppt = ar.topLeft() + 3945 QPoint((ar.width() - pm->width()) / 2, 3946 (ar.height() - pm->height()) / 2); 3947 p->drawPixmap(ppt, *pm); 3948 } 3949 3950 if(sub & SC_ComboBoxEditField) 3951 { 3952 QComboBox const* cb = (QComboBox const*)widget; 3953 QRect re = QStyle::visualRect(querySubControlMetrics(CC_ComboBox, widget, 3954 SC_ComboBoxEditField), 3955 widget); 3956 p->fillRect(re, cg.brush(QColorGroup::Base)); 3957 3958 if(cb->hasFocus()) 3959 { 3960 p->setPen(cg.highlightedText()); 3961 p->setBackgroundColor(cg.highlight()); 3962 } 3963 else 3964 { 3965 p->setPen(cg.text()); 3966 p->setBackgroundColor(cg.background()); 3967 } 3968 3969 if(cb->hasFocus() && !cb->editable()) 3970 { 3971 re = QStyle::visualRect(subRect(SR_ComboBoxFocusRect, cb), widget); 3972 p->fillRect(re, cg.brush(QColorGroup::Highlight)); 3973 } 3974 } 3975 3976 break; 3977 } 3978 #endif // QT_NO_COMBOBOX 3979 3980 #ifndef QT_NO_SLIDER 3981 case CC_Slider: 3982 { 3983 QSlider const* sl = (QSlider const*)widget; 3984 QRect groove = querySubControlMetrics(CC_Slider, widget, SC_SliderGroove, opt), 3985 handle = querySubControlMetrics(CC_Slider, widget, SC_SliderHandle, opt); 3986 3987 // reducing the handle length by 2 on each side 3988 if(sl->orientation() == Horizontal) 3989 { 3990 handle.setLeft(handle.left() + 2); 3991 handle.setRight(handle.right() - 2); 3992 } 3993 else 3994 { 3995 handle.setTop(handle.top() + 2); 3996 handle.setBottom(handle.bottom() - 2); 3997 } 3998 3999 if((sub & SC_SliderGroove) && groove.isValid()) 4000 { 4001 if(sl->orientation() == Horizontal) 4002 { 4003 groove.setTop(groove.top() + 4); 4004 groove.setBottom(groove.bottom() - 4); 4005 } 4006 else 4007 { 4008 groove.setLeft(groove.left() + 4); 4009 groove.setRight(groove.right() - 4); 4010 } 4011 4012 qDrawWarpFilledRect(p, groove, cg.dark(), cg.light(), 4013 &cg.brush(QColorGroup::Button), 2, true); 4014 4015 groove.setTop(groove.top() + 2); 4016 groove.setLeft(groove.left() + 2); 4017 if(sl->orientation() == Horizontal) 4018 { 4019 groove.setRight(groove.right() - 2); 4020 groove.setBottom(groove.bottom() - 1); 4021 } 4022 else 4023 { 4024 groove.setRight(groove.right() - 1); 4025 groove.setBottom(groove.bottom() - 2); 4026 } 4027 4028 if(flags & Style_HasFocus) 4029 p->setPen(cg.shadow()); 4030 else 4031 p->setPen(cg.dark()); 4032 4033 p->drawRect(groove); 4034 } 4035 4036 if(sub & SC_SliderTickmarks) 4037 { 4038 int tickOffset = pixelMetric(PM_SliderTickmarkOffset, sl); 4039 int thickness = pixelMetric(PM_SliderControlThickness, sl); 4040 int len = pixelMetric(PM_SliderLength, sl); 4041 int ticks = sl->tickmarks(); 4042 int available = pixelMetric(PM_SliderSpaceAvailable, sl); 4043 int interval = sl->tickInterval(); 4044 4045 if(interval <= 0 ) 4046 { 4047 interval = sl->lineStep(); 4048 if((qPositionFromValue(sl, interval, available) - 4049 qPositionFromValue(sl, 0, available)) < 3) 4050 interval = sl->pageStep(); 4051 } 4052 4053 int fudge = len / 2; 4054 int pos; 4055 4056 if(ticks & QSlider::Above) 4057 { 4058 if(sl->orientation() == Horizontal) 4059 p->fillRect(0, 0, sl->width(), tickOffset, 4060 cg.brush(QColorGroup::Background)); 4061 else 4062 p->fillRect(0, 0, tickOffset, sl->width(), 4063 cg.brush(QColorGroup::Background)); 4064 int v = sl->minValue(); 4065 if (!interval) 4066 interval = 1; 4067 while(v <= sl->maxValue() + 1) 3947 4068 { 3948 qDrawWarpPanel(p, r, cg, -1); 3949 p->setPen(cg.dark()); 3950 int x = r.right() - 2 - 16; 3951 p->drawLine(x, r.top() + 2, x, r.bottom() - 2); 3952 } 3953 3954 if(sub & SC_ComboBoxArrow) 3955 { 3956 QRect ar = visualRect(querySubControlMetrics(CC_ComboBox, widget, 3957 SC_ComboBoxArrow), 3958 widget); 3959 QBrush fill = cg.brush(QColorGroup::Button); 3960 bool sunken = subActive == SC_ComboBoxArrow; 3961 qDrawWarpFilledRect(p, ar, cg.dark(), cg.light(), &fill, 2, sunken); 3962 p->setPen(cg.button()); 3963 p->drawLine(ar.bottomLeft(), ar.topRight()); 3964 QPixmap const* pm = qWarpSystemPixmaps.getPixmap(SBMP_COMBODOWN, 3965 QWarpPixmap::bmp); 3966 QPoint ppt = ar.topLeft() + 3967 QPoint((ar.width() - pm->width()) / 2, 3968 (ar.height() - pm->height()) / 2); 3969 p->drawPixmap(ppt, *pm); 3970 } 3971 3972 if(sub & SC_ComboBoxEditField) 3973 { 3974 QComboBox const* cb = (QComboBox const*)widget; 3975 QRect re = QStyle::visualRect(querySubControlMetrics(CC_ComboBox, widget, 3976 SC_ComboBoxEditField), 3977 widget); 3978 p->fillRect(re, cg.brush(QColorGroup::Base)); 3979 3980 if(cb->hasFocus()) 4069 pos = qPositionFromValue(sl, v, available) + fudge; 4070 if(sl->orientation() == Horizontal) 3981 4071 { 3982 p->setPen(cg.highlightedText()); 3983 p->setBackgroundColor(cg.highlight()); 4072 p->setPen(cg.dark()); 4073 p->drawLine(pos - 1, 0, pos - 1, tickOffset - 1); 4074 p->setPen(cg.light()); 4075 p->drawLine(pos, 0, pos, tickOffset - 1); 3984 4076 } 3985 4077 else 3986 4078 { 3987 p->setPen(cg.text()); 3988 p->setBackgroundColor(cg.background()); 4079 p->setPen(cg.dark()); 4080 p->drawLine(0, pos - 1, tickOffset - 1, pos - 1); 4081 p->setPen(cg.light()); 4082 p->drawLine(0, pos, tickOffset - 1, pos); 3989 4083 } 3990 3991 if(cb->hasFocus() && !cb->editable()) 4084 v += interval; 4085 } 4086 } 4087 4088 if(ticks & QSlider::Below) 4089 { 4090 if(sl->orientation() == Horizontal) 4091 p->fillRect(0, tickOffset + thickness, sl->width(), tickOffset, 4092 cg.brush(QColorGroup::Background)); 4093 else 4094 p->fillRect(tickOffset + thickness, 0, tickOffset, sl->height(), 4095 cg.brush(QColorGroup::Background)); 4096 int v = sl->minValue(); 4097 if(!interval) 4098 interval = 1; 4099 while(v <= sl->maxValue() + 1) 4100 { 4101 pos = qPositionFromValue(sl, v, available) + fudge; 4102 if(sl->orientation() == Horizontal) 3992 4103 { 3993 re = QStyle::visualRect(subRect(SR_ComboBoxFocusRect, cb), widget); 3994 p->fillRect(re, cg.brush(QColorGroup::Highlight)); 4104 p->setPen(cg.dark()); 4105 p->drawLine(pos - 1, tickOffset + thickness + 1, 4106 pos - 1, tickOffset + thickness + 1 + available - 1); 4107 p->setPen(cg.light()); 4108 p->drawLine(pos, tickOffset + thickness + 1, 4109 pos, tickOffset + thickness + 1 + available - 1); 3995 4110 } 4111 else 4112 { 4113 p->setPen(cg.dark()); 4114 p->drawLine(tickOffset + thickness + 1, pos - 1, 4115 tickOffset + thickness + 1 + available - 1, pos - 1); 4116 p->setPen(cg.light()); 4117 p->drawLine(tickOffset + thickness + 1, pos, 4118 tickOffset + thickness + 1 + available - 1, pos); 4119 } 4120 v += interval; 3996 4121 } 3997 3998 break;3999 } 4000 #endif // QT_NO_COMBOBOX4001 4002 #ifndef QT_NO_SLIDER4003 case CC_Slider:4004 { 4005 QSlider const* sl = (QSlider const*)widget;4006 QRect groove = querySubControlMetrics(CC_Slider, widget, SC_SliderGroove, opt),4007 handle = querySubControlMetrics(CC_Slider, widget, SC_SliderHandle, opt);4008 4009 // reducing the handle length by 2 on each side 4122 } 4123 } 4124 4125 if(sub & SC_SliderHandle) 4126 { 4127 qDrawWarpFilledRect(p, handle, cg.dark(), cg.light(), 4128 &cg.brush(QColorGroup::Button), 2, false); 4129 4130 if(flags & Style_HasFocus) 4131 p->setPen(cg.shadow()); 4132 else 4133 p->setPen(cg.dark()); 4134 4010 4135 if(sl->orientation() == Horizontal) 4011 { 4012 handle.setLeft(handle.left() + 2); 4013 handle.setRight(handle.right() - 2); 4014 } 4136 p->drawLine(handle.topLeft() + QPoint(5, 2), 4137 handle.bottomLeft() + QPoint(5, -2)); 4015 4138 else 4016 { 4017 handle.setTop(handle.top() + 2); 4018 handle.setBottom(handle.bottom() - 2); 4019 } 4020 4021 if((sub & SC_SliderGroove) && groove.isValid()) 4022 { 4023 if(sl->orientation() == Horizontal) 4024 { 4025 groove.setTop(groove.top() + 4); 4026 groove.setBottom(groove.bottom() - 4); 4027 } 4028 else 4029 { 4030 groove.setLeft(groove.left() + 4); 4031 groove.setRight(groove.right() - 4); 4032 } 4033 4034 qDrawWarpFilledRect(p, groove, cg.dark(), cg.light(), 4035 &cg.brush(QColorGroup::Button), 2, true); 4036 4037 groove.setTop(groove.top() + 2); 4038 groove.setLeft(groove.left() + 2); 4039 if(sl->orientation() == Horizontal) 4040 { 4041 groove.setRight(groove.right() - 2); 4042 groove.setBottom(groove.bottom() - 1); 4043 } 4044 else 4045 { 4046 groove.setRight(groove.right() - 1); 4047 groove.setBottom(groove.bottom() - 2); 4048 } 4049 4050 if(flags & Style_HasFocus) 4051 p->setPen(cg.shadow()); 4052 else 4053 p->setPen(cg.dark()); 4054 4055 p->drawRect(groove); 4056 } 4057 4058 if(sub & SC_SliderTickmarks) 4059 { 4060 int tickOffset = pixelMetric(PM_SliderTickmarkOffset, sl); 4061 int thickness = pixelMetric(PM_SliderControlThickness, sl); 4062 int len = pixelMetric(PM_SliderLength, sl); 4063 int ticks = sl->tickmarks(); 4064 int available = pixelMetric(PM_SliderSpaceAvailable, sl); 4065 int interval = sl->tickInterval(); 4066 4067 if(interval <= 0 ) 4068 { 4069 interval = sl->lineStep(); 4070 if((qPositionFromValue(sl, interval, available) - 4071 qPositionFromValue(sl, 0, available)) < 3) 4072 interval = sl->pageStep(); 4073 } 4074 4075 int fudge = len / 2; 4076 int pos; 4077 4078 if(ticks & QSlider::Above) 4079 { 4080 if(sl->orientation() == Horizontal) 4081 p->fillRect(0, 0, sl->width(), tickOffset, 4082 cg.brush(QColorGroup::Background)); 4083 else 4084 p->fillRect(0, 0, tickOffset, sl->width(), 4085 cg.brush(QColorGroup::Background)); 4086 int v = sl->minValue(); 4087 if (!interval) 4088 interval = 1; 4089 while(v <= sl->maxValue() + 1) 4090 { 4091 pos = qPositionFromValue(sl, v, available) + fudge; 4092 if(sl->orientation() == Horizontal) 4093 { 4094 p->setPen(cg.dark()); 4095 p->drawLine(pos - 1, 0, pos - 1, tickOffset - 1); 4096 p->setPen(cg.light()); 4097 p->drawLine(pos, 0, pos, tickOffset - 1); 4098 } 4099 else 4100 { 4101 p->setPen(cg.dark()); 4102 p->drawLine(0, pos - 1, tickOffset - 1, pos - 1); 4103 p->setPen(cg.light()); 4104 p->drawLine(0, pos, tickOffset - 1, pos); 4105 } 4106 v += interval; 4107 } 4108 } 4109 4110 if(ticks & QSlider::Below) 4111 { 4112 if(sl->orientation() == Horizontal) 4113 p->fillRect(0, tickOffset + thickness, sl->width(), tickOffset, 4114 cg.brush(QColorGroup::Background)); 4115 else 4116 p->fillRect(tickOffset + thickness, 0, tickOffset, sl->height(), 4117 cg.brush(QColorGroup::Background)); 4118 int v = sl->minValue(); 4119 if(!interval) 4120 interval = 1; 4121 while(v <= sl->maxValue() + 1) 4122 { 4123 pos = qPositionFromValue(sl, v, available) + fudge; 4124 if(sl->orientation() == Horizontal) 4125 { 4126 p->setPen(cg.dark()); 4127 p->drawLine(pos - 1, tickOffset + thickness + 1, 4128 pos - 1, tickOffset + thickness + 1 + available - 1); 4129 p->setPen(cg.light()); 4130 p->drawLine(pos, tickOffset + thickness + 1, 4131 pos, tickOffset + thickness + 1 + available - 1); 4132 } 4133 else 4134 { 4135 p->setPen(cg.dark()); 4136 p->drawLine(tickOffset + thickness + 1, pos - 1, 4137 tickOffset + thickness + 1 + available - 1, pos - 1); 4138 p->setPen(cg.light()); 4139 p->drawLine(tickOffset + thickness + 1, pos, 4140 tickOffset + thickness + 1 + available - 1, pos); 4141 } 4142 v += interval; 4143 } 4144 } 4145 } 4146 4147 if(sub & SC_SliderHandle) 4148 { 4149 qDrawWarpFilledRect(p, handle, cg.dark(), cg.light(), 4150 &cg.brush(QColorGroup::Button), 2, false); 4151 4152 if(flags & Style_HasFocus) 4153 p->setPen(cg.shadow()); 4154 else 4155 p->setPen(cg.dark()); 4156 4157 if(sl->orientation() == Horizontal) 4158 p->drawLine(handle.topLeft() + QPoint(5, 2), 4159 handle.bottomLeft() + QPoint(5, -2)); 4160 else 4161 p->drawLine(handle.topLeft() + QPoint(2, 5), 4162 handle.topRight() + QPoint(-2, 5)); 4163 4164 p->setPen(cg.light()); 4165 4166 if(sl->orientation() == Horizontal) 4167 p->drawLine(handle.topLeft() + QPoint(6, 2), 4168 handle.bottomLeft() + QPoint(6, -2)); 4169 else 4170 p->drawLine(handle.topLeft() + QPoint(2, 6), 4171 handle.topRight() + QPoint(-2, 6)); 4172 } 4173 4174 break; 4175 } 4176 #endif // QT_NO_SLIDER 4139 p->drawLine(handle.topLeft() + QPoint(2, 5), 4140 handle.topRight() + QPoint(-2, 5)); 4141 4142 p->setPen(cg.light()); 4143 4144 if(sl->orientation() == Horizontal) 4145 p->drawLine(handle.topLeft() + QPoint(6, 2), 4146 handle.bottomLeft() + QPoint(6, -2)); 4147 else 4148 p->drawLine(handle.topLeft() + QPoint(2, 6), 4149 handle.topRight() + QPoint(-2, 6)); 4150 } 4151 4152 break; 4153 } 4154 #endif // QT_NO_SLIDER 4177 4155 4178 4156 default: … … 4193 4171 switch(control) 4194 4172 { 4195 #ifndef QT_NO_SCROLLBAR 4196 case CC_ScrollBar: 4197 { 4198 QScrollBar const* scrollbar = (QScrollBar const*)widget; 4199 int sbextent = pixelMetric(PM_ScrollBarExtent, widget); 4200 int maxlen = ((scrollbar->orientation() == Qt::Horizontal) ? 4201 scrollbar->width() : scrollbar->height()) - 4202 (2 * 21); // 2 buttons incl. lines 4203 int sliderstart = scrollbar->sliderStart(); 4204 4205 // calculate slider length 4206 int sliderlen; 4207 if(scrollbar->maxValue() != scrollbar->minValue()) 4208 { 4209 uint range = scrollbar->maxValue() - scrollbar->minValue(); 4210 sliderlen = (scrollbar->pageStep() * maxlen) / 4211 (range + scrollbar->pageStep()); 4212 int slidermin = pixelMetric(PM_ScrollBarSliderMin, widget); 4213 if((sliderlen < slidermin) || (range > INT_MAX / 2)) 4214 sliderlen = slidermin; 4215 if(sliderlen > maxlen) 4216 sliderlen = maxlen; 4217 } 4218 else 4219 { 4173 #ifndef QT_NO_SCROLLBAR 4174 case CC_ScrollBar: 4175 { 4176 QScrollBar const* scrollbar = (QScrollBar const*)widget; 4177 int sbextent = pixelMetric(PM_ScrollBarExtent, widget); 4178 int maxlen = ((scrollbar->orientation() == Qt::Horizontal) ? 4179 scrollbar->width() : scrollbar->height()) - 4180 (2 * 21); // 2 buttons incl. lines 4181 int sliderstart = scrollbar->sliderStart(); 4182 4183 // calculate slider length 4184 int sliderlen; 4185 if(scrollbar->maxValue() != scrollbar->minValue()) 4186 { 4187 uint range = scrollbar->maxValue() - scrollbar->minValue(); 4188 sliderlen = (scrollbar->pageStep() * maxlen) / 4189 (range + scrollbar->pageStep()); 4190 int slidermin = pixelMetric(PM_ScrollBarSliderMin, widget); 4191 if((sliderlen < slidermin) || (range > INT_MAX / 2)) 4192 sliderlen = slidermin; 4193 if(sliderlen > maxlen) 4220 4194 sliderlen = maxlen; 4221 } 4222 4223 // calculate button width (for vertical scroll bars this is the height) 4224 // note: the "button" includes the lines at the extreme ends of the sb 4225 int buttonWidth; 4226 if(scrollbar->orientation() == Qt::Horizontal) 4227 buttonWidth = QMIN(scrollbar->width() / 2, 21); 4228 else 4229 buttonWidth = QMIN(scrollbar->height() / 2, 21); 4230 4231 switch(sc) 4232 { 4233 case SC_ScrollBarSubLine: // top/left button 4234 { 4235 if(scrollbar->orientation() == Qt::Horizontal) 4236 return QRect(0, 0, buttonWidth, sbextent); 4237 else 4238 return QRect(0, 0, sbextent, buttonWidth); 4239 } 4240 4241 case SC_ScrollBarAddLine: // bottom/right button 4242 { 4243 if(scrollbar->orientation() == Qt::Horizontal) 4244 return QRect(scrollbar->width() - buttonWidth, 0, 4245 buttonWidth, sbextent); 4246 else 4247 return QRect(0, scrollbar->height() - buttonWidth, 4248 sbextent, buttonWidth); 4249 } 4250 4251 case SC_ScrollBarSubPage: // between top/left button and slider 4252 { 4253 if(scrollbar->orientation() == Qt::Horizontal) 4254 return QRect(buttonWidth, 0, 4255 sliderstart - buttonWidth, sbextent); 4256 else 4257 return QRect(0, buttonWidth, 4258 sbextent, sliderstart - buttonWidth); 4259 } 4260 4261 case SC_ScrollBarAddPage: // between bottom/right button and slider 4262 { 4263 if(scrollbar->orientation() == Qt::Horizontal) 4264 return QRect(sliderstart + sliderlen, 0, 4265 maxlen + buttonWidth - sliderstart - sliderlen, sbextent); 4266 else 4267 return QRect(0, sliderstart + sliderlen, 4268 sbextent, maxlen + buttonWidth - sliderstart - sliderlen); 4269 } 4270 4271 case SC_ScrollBarGroove: 4272 { 4273 if(scrollbar->orientation() == Qt::Horizontal) 4274 return QRect(buttonWidth, 0, 4275 scrollbar->width() - buttonWidth * 2, sbextent); 4276 else 4277 return QRect(0, buttonWidth, 4278 sbextent, scrollbar->height() - buttonWidth * 2); 4279 } 4280 4281 case SC_ScrollBarSlider: 4282 { 4283 if(scrollbar->orientation() == Qt::Horizontal) 4284 return QRect(sliderstart, 0, sliderlen, sbextent); 4285 else 4286 return QRect(0, sliderstart, sbextent, sliderlen); 4287 } 4288 } 4289 4290 break; 4291 } 4292 #endif // QT_NO_SCROLLBAR 4195 } 4196 else 4197 { 4198 sliderlen = maxlen; 4199 } 4200 4201 // calculate button width (for vertical scroll bars this is the height) 4202 // note: the "button" includes the lines at the extreme ends of the sb 4203 int buttonWidth; 4204 if(scrollbar->orientation() == Qt::Horizontal) 4205 buttonWidth = QMIN(scrollbar->width() / 2, 21); 4206 else 4207 buttonWidth = QMIN(scrollbar->height() / 2, 21); 4208 4209 switch(sc) 4210 { 4211 case SC_ScrollBarSubLine: // top/left button 4212 { 4213 if(scrollbar->orientation() == Qt::Horizontal) 4214 return QRect(0, 0, buttonWidth, sbextent); 4215 else 4216 return QRect(0, 0, sbextent, buttonWidth); 4217 } 4218 4219 case SC_ScrollBarAddLine: // bottom/right button 4220 { 4221 if(scrollbar->orientation() == Qt::Horizontal) 4222 return QRect(scrollbar->width() - buttonWidth, 0, 4223 buttonWidth, sbextent); 4224 else 4225 return QRect(0, scrollbar->height() - buttonWidth, 4226 sbextent, buttonWidth); 4227 } 4228 4229 case SC_ScrollBarSubPage: // between top/left button and slider 4230 { 4231 if(scrollbar->orientation() == Qt::Horizontal) 4232 return QRect(buttonWidth, 0, 4233 sliderstart - buttonWidth, sbextent); 4234 else 4235 return QRect(0, buttonWidth, 4236 sbextent, sliderstart - buttonWidth); 4237 } 4238 4239 case SC_ScrollBarAddPage: // between bottom/right button and slider 4240 { 4241 if(scrollbar->orientation() == Qt::Horizontal) 4242 return QRect(sliderstart + sliderlen, 0, 4243 maxlen + buttonWidth - sliderstart - sliderlen, sbextent); 4244 else 4245 return QRect(0, sliderstart + sliderlen, 4246 sbextent, maxlen + buttonWidth - sliderstart - sliderlen); 4247 } 4248 4249 case SC_ScrollBarGroove: 4250 { 4251 if(scrollbar->orientation() == Qt::Horizontal) 4252 return QRect(buttonWidth, 0, 4253 scrollbar->width() - buttonWidth * 2, sbextent); 4254 else 4255 return QRect(0, buttonWidth, 4256 sbextent, scrollbar->height() - buttonWidth * 2); 4257 } 4258 4259 case SC_ScrollBarSlider: 4260 { 4261 if(scrollbar->orientation() == Qt::Horizontal) 4262 return QRect(sliderstart, 0, sliderlen, sbextent); 4263 else 4264 return QRect(0, sliderstart, sbextent, sliderlen); 4265 } 4266 } 4267 4268 break; 4269 } 4270 #endif // QT_NO_SCROLLBAR 4293 4271 4294 4272 case CC_SpinWidget: … … 4475 4453 } 4476 4454 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 #endif 4455 #ifndef QT_NO_SLIDER 4456 case SR_SliderFocusRect: 4457 { 4458 rect = widget->rect(); 4459 break; 4460 } 4461 #endif // QT_NO_SLIDER 4462 4463 #ifndef QT_NO_PROGRESSBAR 4464 case SR_ProgressBarGroove: 4465 case SR_ProgressBarContents: 4466 { 4467 QFontMetrics fm((widget ? widget->fontMetrics() : 4468 QApplication::fontMetrics())); 4469 QProgressBar const* progressbar = (QProgressBar const*)widget; 4470 int textw = 0; 4471 if(progressbar->percentageVisible()) 4472 textw = fm.width("100%") + 6; 4473 4474 // only change for Warp4 compared to "common": the style default 4475 // is "centered" 4476 QRect wrect(widget->rect()); 4477 if(!progressbar->indicatorFollowsStyle() && 4478 !progressbar->centerIndicator()) 4479 rect.setCoords(wrect.left(), wrect.top(), 4480 wrect.right() - textw, wrect.bottom()); 4481 else 4482 rect = wrect; 4483 break; 4484 } 4485 4486 case SR_ProgressBarLabel: 4487 { 4488 QFontMetrics fm((widget ? widget->fontMetrics() : 4489 QApplication::fontMetrics())); 4490 QProgressBar const* progressbar = (QProgressBar const*)widget; 4491 int textw = 0; 4492 if(progressbar->percentageVisible()) 4493 textw = fm.width("100%") + 6; 4494 4495 // only change for Warp4 compared to "common": the style default 4496 // is "centered" 4497 QRect wrect(widget->rect()); 4498 if(!progressbar->indicatorFollowsStyle() && 4499 !progressbar->centerIndicator()) 4500 rect.setCoords(wrect.right() - textw, wrect.top(), 4501 wrect.right(), wrect.bottom()); 4502 else 4503 rect = wrect; 4504 break; 4505 } 4506 #endif // QT_NO_PROGRESSBAR 4529 4507 4530 4508 case SR_ToolBoxTabContents:
Note:
See TracChangeset
for help on using the changeset viewer.