You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1587 lines
54 KiB
1587 lines
54 KiB
/****************************************************************************
|
|
**
|
|
** Copyright (C) 2012 Timothy Pearson. All rights reserved.
|
|
**
|
|
** This file is part of the TDE Qt4 style interface
|
|
**
|
|
** This file may be used under the terms of the GNU General
|
|
** Public License versions 2.0 or 3.0 as published by the Free
|
|
** Software Foundation and appearing in the files LICENSE.GPL2
|
|
** and LICENSE.GPL3 included in the packaging of this file.
|
|
**
|
|
** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
|
|
** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
|
|
** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted
|
|
** herein.
|
|
**
|
|
**********************************************************************/
|
|
|
|
#define TQT_NO_COMPAT_NAMES
|
|
#include <tqstyle.h>
|
|
#include <tqpixmap.h>
|
|
#include <tqpainter.h>
|
|
#include <tqapplication.h>
|
|
#include <tqprogressbar.h>
|
|
#include <tqtabbar.h>
|
|
#include <tqradiobutton.h>
|
|
#include <tqpopupmenu.h>
|
|
#include <tqmenudata.h>
|
|
#include <tqcombobox.h>
|
|
#include <tqiconset.h>
|
|
#undef Qt
|
|
|
|
#include <QtGui/QtGui>
|
|
#include <QtGui/QX11Info>
|
|
|
|
#include "simplestyle.h"
|
|
#include "tdeqt4painter.h"
|
|
|
|
#define INTEGRATE_WITH_TDE 1
|
|
|
|
#ifdef INTEGRATE_WITH_TDE
|
|
#undef Q_OBJECT
|
|
#define Q_OBJECT TQ_OBJECT
|
|
#include <kapplication.h>
|
|
#include <kcmdlineargs.h>
|
|
#include <kaboutdata.h>
|
|
#include <kicontheme.h>
|
|
#endif
|
|
|
|
#define DEBUG_WARNINGS 1
|
|
// #define DEBUG_SPEW 1
|
|
|
|
inline QColor convertTQt3ToQt4Color(TQColor tqt3color)
|
|
{
|
|
return QColor(tqt3color.red(), tqt3color.green(), tqt3color.blue());
|
|
}
|
|
|
|
inline TQColor convertQt4ToTQt3Color(QColor qt4color)
|
|
{
|
|
return TQColor(qt4color.red(), qt4color.green(), qt4color.blue());
|
|
}
|
|
|
|
inline QString convertTQt3ToQt4String(TQString tqt3string)
|
|
{
|
|
return QString::fromUtf8(tqt3string.utf8().data());
|
|
}
|
|
|
|
inline TQString convertQt4ToTQt3String(QString qt4string)
|
|
{
|
|
return TQString::fromUtf8(qt4string.toUtf8().data());
|
|
}
|
|
|
|
inline TQIconSet convertQt4ToTQt3IconSet(QIcon qt4icon)
|
|
{
|
|
int i=0;
|
|
int j=0;
|
|
QIcon::Mode qt4iconmode;
|
|
TQIconSet::Mode tqt3iconmode;
|
|
QIcon::State qt4iconstate;
|
|
TQIconSet::State tqt3iconstate;
|
|
|
|
TQIconSet tqt3iconset;
|
|
|
|
// Get the maximum icon size stored in the QIcon and generate a pixmap of that size
|
|
QSize qt4size = qt4icon.actualSize(QSize(32768,32768));
|
|
|
|
for (i=0;i<3;i++) {
|
|
for (j=0;j<2;j++) {
|
|
if (i==0) {
|
|
qt4iconmode = QIcon::Normal;
|
|
tqt3iconmode = TQIconSet::Normal;
|
|
}
|
|
if (i==1) {
|
|
qt4iconmode = QIcon::Disabled;
|
|
tqt3iconmode = TQIconSet::Disabled;
|
|
}
|
|
if (i==2) {
|
|
qt4iconmode = QIcon::Active;
|
|
tqt3iconmode = TQIconSet::Active;
|
|
}
|
|
if (j==0) {
|
|
qt4iconstate = QIcon::On;
|
|
tqt3iconstate = TQIconSet::On;
|
|
}
|
|
if (j==1) {
|
|
qt4iconstate = QIcon::Off;
|
|
tqt3iconstate = TQIconSet::Off;
|
|
}
|
|
QPixmap qt4iconpm = qt4icon.pixmap(qt4size, qt4iconmode, qt4iconstate);
|
|
TQPixmap tqtPM(qt4iconpm.width(), qt4iconpm.height(), qt4iconpm.depth());
|
|
QPixmap qtPM = QPixmap::fromX11Pixmap(tqtPM.handle(), QPixmap::ExplicitlyShared);
|
|
QPainter qt4painter(&qtPM);
|
|
qt4painter.drawPixmap(0, 0, qt4iconpm);
|
|
qt4painter.end();
|
|
|
|
tqt3iconset.setPixmap(tqtPM, TQIconSet::Automatic, tqt3iconmode, tqt3iconstate);
|
|
}
|
|
}
|
|
|
|
return tqt3iconset;
|
|
}
|
|
|
|
inline TQPixmap convertQt4ToTQt3Pixmap(QIcon qt4icon)
|
|
{
|
|
// Get the maximum icon size stored in the QIcon and generate a pixmap of that size
|
|
QSize qt4size = qt4icon.actualSize(QSize(32768,32768));
|
|
|
|
QPixmap qt4iconpm = qt4icon.pixmap(qt4size);
|
|
TQPixmap tqtPM(qt4iconpm.width(), qt4iconpm.height(), qt4iconpm.depth());
|
|
QPixmap qtPM = QPixmap::fromX11Pixmap(tqtPM.handle(), QPixmap::ExplicitlyShared);
|
|
QPainter qt4painter(&qtPM);
|
|
qt4painter.drawPixmap(0, 0, qt4iconpm);
|
|
qt4painter.end();
|
|
|
|
return tqtPM;
|
|
}
|
|
|
|
inline QRect convertTQt3ToQt4Rect(TQRect tqt3rect)
|
|
{
|
|
return QRect(tqt3rect.x(), tqt3rect.y(), tqt3rect.width(), tqt3rect.height());
|
|
}
|
|
|
|
inline QBrush convertTQt3ToQt4Brush(TQBrush tqt3brush)
|
|
{
|
|
QBrush qt4brush;
|
|
TQt::BrushStyle tqt3brushstyle = tqt3brush.style();
|
|
Qt::BrushStyle qt4brushstyle;
|
|
|
|
switch ( tqt3brushstyle ) {
|
|
case TQt::NoBrush:
|
|
qt4brushstyle = Qt::NoBrush;
|
|
break;
|
|
case TQt::SolidPattern:
|
|
qt4brushstyle = Qt::SolidPattern;
|
|
break;
|
|
case TQt::Dense1Pattern:
|
|
qt4brushstyle = Qt::Dense1Pattern;
|
|
break;
|
|
case TQt::Dense2Pattern:
|
|
qt4brushstyle = Qt::Dense2Pattern;
|
|
break;
|
|
case TQt::Dense3Pattern:
|
|
qt4brushstyle = Qt::Dense3Pattern;
|
|
break;
|
|
case TQt::Dense4Pattern:
|
|
qt4brushstyle = Qt::Dense4Pattern;
|
|
break;
|
|
case TQt::Dense5Pattern:
|
|
qt4brushstyle = Qt::Dense5Pattern;
|
|
break;
|
|
case TQt::Dense6Pattern:
|
|
qt4brushstyle = Qt::Dense6Pattern;
|
|
break;
|
|
case TQt::Dense7Pattern:
|
|
qt4brushstyle = Qt::Dense7Pattern;
|
|
break;
|
|
case TQt::HorPattern:
|
|
qt4brushstyle = Qt::HorPattern;
|
|
break;
|
|
case TQt::VerPattern:
|
|
qt4brushstyle = Qt::VerPattern;
|
|
break;
|
|
case TQt::CrossPattern:
|
|
qt4brushstyle = Qt::CrossPattern;
|
|
break;
|
|
case TQt::BDiagPattern:
|
|
qt4brushstyle = Qt::BDiagPattern;
|
|
break;
|
|
case TQt::FDiagPattern:
|
|
qt4brushstyle = Qt::FDiagPattern;
|
|
break;
|
|
case TQt::DiagCrossPattern:
|
|
qt4brushstyle = Qt::DiagCrossPattern;
|
|
break;
|
|
case TQt::CustomPattern:
|
|
qt4brushstyle = Qt::TexturePattern;
|
|
break;
|
|
default:
|
|
qt4brushstyle = Qt::NoBrush;
|
|
#if defined(QT_CHECK_RANGE)
|
|
tqWarning( "convertTQt3ToQt4Brush: Invalid brush style %d", tqt3brushstyle );
|
|
#endif
|
|
}
|
|
qt4brush.setStyle(qt4brushstyle);
|
|
TQColor qt3color = tqt3brush.color();
|
|
qt4brush.setColor(QColor(qt3color.red(), qt3color.green(), qt3color.blue(), 255));
|
|
if (qt4brushstyle == Qt::TexturePattern) {
|
|
TQPixmap tqtPM = *tqt3brush.pixmap();
|
|
QPixmap qtPM = QPixmap::fromX11Pixmap(tqtPM.handle(), QPixmap::ImplicitlyShared);
|
|
qt4brush.setTexture(qtPM);
|
|
}
|
|
|
|
return qt4brush;
|
|
}
|
|
|
|
inline TQBrush convertQt4ToTQt3Brush(QBrush qt4brush)
|
|
{
|
|
TQBrush tqt3brush;
|
|
Qt::BrushStyle qt4brushstyle = qt4brush.style();
|
|
TQt::BrushStyle tqt3brushstyle;
|
|
|
|
switch ( qt4brushstyle ) {
|
|
case Qt::NoBrush:
|
|
tqt3brushstyle = TQt::NoBrush;
|
|
break;
|
|
case Qt::SolidPattern:
|
|
tqt3brushstyle = TQt::SolidPattern;
|
|
break;
|
|
case Qt::Dense1Pattern:
|
|
tqt3brushstyle = TQt::Dense1Pattern;
|
|
break;
|
|
case Qt::Dense2Pattern:
|
|
tqt3brushstyle = TQt::Dense2Pattern;
|
|
break;
|
|
case Qt::Dense3Pattern:
|
|
tqt3brushstyle = TQt::Dense3Pattern;
|
|
break;
|
|
case Qt::Dense4Pattern:
|
|
tqt3brushstyle = TQt::Dense4Pattern;
|
|
break;
|
|
case Qt::Dense5Pattern:
|
|
tqt3brushstyle = TQt::Dense5Pattern;
|
|
break;
|
|
case Qt::Dense6Pattern:
|
|
tqt3brushstyle = TQt::Dense6Pattern;
|
|
break;
|
|
case Qt::Dense7Pattern:
|
|
tqt3brushstyle = TQt::Dense7Pattern;
|
|
break;
|
|
case Qt::HorPattern:
|
|
tqt3brushstyle = TQt::HorPattern;
|
|
break;
|
|
case Qt::VerPattern:
|
|
tqt3brushstyle = TQt::VerPattern;
|
|
break;
|
|
case Qt::CrossPattern:
|
|
tqt3brushstyle = TQt::CrossPattern;
|
|
break;
|
|
case Qt::BDiagPattern:
|
|
tqt3brushstyle = TQt::BDiagPattern;
|
|
break;
|
|
case Qt::FDiagPattern:
|
|
tqt3brushstyle = TQt::FDiagPattern;
|
|
break;
|
|
case Qt::DiagCrossPattern:
|
|
tqt3brushstyle = TQt::DiagCrossPattern;
|
|
break;
|
|
case Qt::TexturePattern:
|
|
tqt3brushstyle = TQt::CustomPattern;
|
|
break;
|
|
default:
|
|
tqt3brushstyle = TQt::NoBrush;
|
|
#if defined(QT_CHECK_RANGE)
|
|
tqWarning( "convertQt4ToTQt3Brush: Invalid brush style %d", tqt3brushstyle );
|
|
#endif
|
|
}
|
|
tqt3brush.setStyle(tqt3brushstyle);
|
|
QColor qt4color = qt4brush.color();
|
|
tqt3brush.setColor(TQColor(qt4color.red(), qt4color.green(), qt4color.blue()));
|
|
if (tqt3brushstyle == TQt::CustomPattern) {
|
|
QPixmap qt4texture = qt4brush.texture();
|
|
TQPixmap tqtPM(qt4texture.width(), qt4texture.height(), qt4texture.depth());
|
|
QPixmap qtPM = QPixmap::fromX11Pixmap(tqtPM.handle(), QPixmap::ExplicitlyShared);
|
|
QPainter qt4painter(&qtPM);
|
|
qt4painter.drawPixmap(0, 0, qt4texture);
|
|
qt4painter.end();
|
|
tqt3brush.setPixmap(tqtPM);
|
|
}
|
|
|
|
return tqt3brush;
|
|
}
|
|
|
|
inline QPalette convertTQt3ToQt4Palette(TQPalette tqt3palette)
|
|
{
|
|
int i;
|
|
QPalette qt4palette;
|
|
|
|
// Color groups
|
|
TQPalette::ColorGroup tqt3cgroup;
|
|
QPalette::ColorGroup qt4cgroup;
|
|
TQColor tqt3color;
|
|
for (i=0;i<3;i++) {
|
|
if (i == 0) {
|
|
tqt3cgroup = TQPalette::Disabled;
|
|
qt4cgroup = QPalette::Disabled;
|
|
}
|
|
if (i == 1) {
|
|
tqt3cgroup = TQPalette::Active;
|
|
qt4cgroup = QPalette::Active;
|
|
}
|
|
if (i == 2) {
|
|
tqt3cgroup = TQPalette::Inactive;
|
|
qt4cgroup = QPalette::Inactive;
|
|
}
|
|
|
|
// Brushes
|
|
qt4palette.setBrush(qt4cgroup, QPalette::Background, convertTQt3ToQt4Brush(tqt3palette.brush(tqt3cgroup, TQColorGroup::Background)));
|
|
qt4palette.setBrush(qt4cgroup, QPalette::Foreground, convertTQt3ToQt4Brush(tqt3palette.brush(tqt3cgroup, TQColorGroup::Foreground)));
|
|
qt4palette.setBrush(qt4cgroup, QPalette::Base, convertTQt3ToQt4Brush(tqt3palette.brush(tqt3cgroup, TQColorGroup::Base)));
|
|
qt4palette.setBrush(qt4cgroup, QPalette::Text, convertTQt3ToQt4Brush(tqt3palette.brush(tqt3cgroup, TQColorGroup::Text)));
|
|
qt4palette.setBrush(qt4cgroup, QPalette::Button, convertTQt3ToQt4Brush(tqt3palette.brush(tqt3cgroup, TQColorGroup::Button)));
|
|
qt4palette.setBrush(qt4cgroup, QPalette::ButtonText, convertTQt3ToQt4Brush(tqt3palette.brush(tqt3cgroup, TQColorGroup::ButtonText)));
|
|
qt4palette.setBrush(qt4cgroup, QPalette::Light, convertTQt3ToQt4Brush(tqt3palette.brush(tqt3cgroup, TQColorGroup::Light)));
|
|
qt4palette.setBrush(qt4cgroup, QPalette::Midlight, convertTQt3ToQt4Brush(tqt3palette.brush(tqt3cgroup, TQColorGroup::Midlight)));
|
|
qt4palette.setBrush(qt4cgroup, QPalette::Dark, convertTQt3ToQt4Brush(tqt3palette.brush(tqt3cgroup, TQColorGroup::Dark)));
|
|
qt4palette.setBrush(qt4cgroup, QPalette::Mid, convertTQt3ToQt4Brush(tqt3palette.brush(tqt3cgroup, TQColorGroup::Mid)));
|
|
qt4palette.setBrush(qt4cgroup, QPalette::Shadow, convertTQt3ToQt4Brush(tqt3palette.brush(tqt3cgroup, TQColorGroup::Shadow)));
|
|
qt4palette.setBrush(qt4cgroup, QPalette::Highlight, convertTQt3ToQt4Brush(tqt3palette.brush(tqt3cgroup, TQColorGroup::Highlight)));
|
|
qt4palette.setBrush(qt4cgroup, QPalette::HighlightedText, convertTQt3ToQt4Brush(tqt3palette.brush(tqt3cgroup, TQColorGroup::HighlightedText)));
|
|
qt4palette.setBrush(qt4cgroup, QPalette::BrightText, convertTQt3ToQt4Brush(tqt3palette.brush(tqt3cgroup, TQColorGroup::BrightText)));
|
|
qt4palette.setBrush(qt4cgroup, QPalette::Link, convertTQt3ToQt4Brush(tqt3palette.brush(tqt3cgroup, TQColorGroup::Link)));
|
|
qt4palette.setBrush(qt4cgroup, QPalette::LinkVisited, convertTQt3ToQt4Brush(tqt3palette.brush(tqt3cgroup, TQColorGroup::LinkVisited)));
|
|
|
|
// Colors
|
|
qt4palette.setColor(qt4cgroup, QPalette::Background, convertTQt3ToQt4Color(tqt3palette.color(tqt3cgroup, TQColorGroup::Background)));
|
|
qt4palette.setColor(qt4cgroup, QPalette::Foreground, convertTQt3ToQt4Color(tqt3palette.color(tqt3cgroup, TQColorGroup::Foreground)));
|
|
qt4palette.setColor(qt4cgroup, QPalette::Base, convertTQt3ToQt4Color(tqt3palette.color(tqt3cgroup, TQColorGroup::Base)));
|
|
qt4palette.setColor(qt4cgroup, QPalette::Text, convertTQt3ToQt4Color(tqt3palette.color(tqt3cgroup, TQColorGroup::Text)));
|
|
qt4palette.setColor(qt4cgroup, QPalette::Button, convertTQt3ToQt4Color(tqt3palette.color(tqt3cgroup, TQColorGroup::Button)));
|
|
qt4palette.setColor(qt4cgroup, QPalette::ButtonText, convertTQt3ToQt4Color(tqt3palette.color(tqt3cgroup, TQColorGroup::ButtonText)));
|
|
qt4palette.setColor(qt4cgroup, QPalette::Light, convertTQt3ToQt4Color(tqt3palette.color(tqt3cgroup, TQColorGroup::Light)));
|
|
qt4palette.setColor(qt4cgroup, QPalette::Midlight, convertTQt3ToQt4Color(tqt3palette.color(tqt3cgroup, TQColorGroup::Midlight)));
|
|
qt4palette.setColor(qt4cgroup, QPalette::Dark, convertTQt3ToQt4Color(tqt3palette.color(tqt3cgroup, TQColorGroup::Dark)));
|
|
qt4palette.setColor(qt4cgroup, QPalette::Mid, convertTQt3ToQt4Color(tqt3palette.color(tqt3cgroup, TQColorGroup::Mid)));
|
|
qt4palette.setColor(qt4cgroup, QPalette::Shadow, convertTQt3ToQt4Color(tqt3palette.color(tqt3cgroup, TQColorGroup::Shadow)));
|
|
qt4palette.setColor(qt4cgroup, QPalette::Highlight, convertTQt3ToQt4Color(tqt3palette.color(tqt3cgroup, TQColorGroup::Highlight)));
|
|
qt4palette.setColor(qt4cgroup, QPalette::HighlightedText, convertTQt3ToQt4Color(tqt3palette.color(tqt3cgroup, TQColorGroup::HighlightedText)));
|
|
qt4palette.setColor(qt4cgroup, QPalette::BrightText, convertTQt3ToQt4Color(tqt3palette.color(tqt3cgroup, TQColorGroup::BrightText)));
|
|
qt4palette.setColor(qt4cgroup, QPalette::Link, convertTQt3ToQt4Color(tqt3palette.color(tqt3cgroup, TQColorGroup::Link)));
|
|
qt4palette.setColor(qt4cgroup, QPalette::LinkVisited, convertTQt3ToQt4Color(tqt3palette.color(tqt3cgroup, TQColorGroup::LinkVisited)));
|
|
}
|
|
|
|
return qt4palette;
|
|
}
|
|
|
|
inline TQPalette convertQt4ToTQt3Palette(QPalette qt4palette)
|
|
{
|
|
int i;
|
|
TQPalette tqt3palette;
|
|
|
|
// Color groups
|
|
TQPalette::ColorGroup tqt3cgroup;
|
|
QPalette::ColorGroup qt4cgroup;
|
|
TQColor tqt3color;
|
|
for (i=0;i<3;i++) {
|
|
if (i == 0) {
|
|
tqt3cgroup = TQPalette::Disabled;
|
|
qt4cgroup = QPalette::Disabled;
|
|
}
|
|
if (i == 1) {
|
|
tqt3cgroup = TQPalette::Active;
|
|
qt4cgroup = QPalette::Active;
|
|
}
|
|
if (i == 2) {
|
|
tqt3cgroup = TQPalette::Inactive;
|
|
qt4cgroup = QPalette::Inactive;
|
|
}
|
|
|
|
// Brushes
|
|
tqt3palette.setBrush(tqt3cgroup, TQColorGroup::Background, convertQt4ToTQt3Brush(qt4palette.brush(qt4cgroup, QPalette::Background)));
|
|
tqt3palette.setBrush(tqt3cgroup, TQColorGroup::Foreground, convertQt4ToTQt3Brush(qt4palette.brush(qt4cgroup, QPalette::Foreground)));
|
|
tqt3palette.setBrush(tqt3cgroup, TQColorGroup::Base, convertQt4ToTQt3Brush(qt4palette.brush(qt4cgroup, QPalette::Base)));
|
|
tqt3palette.setBrush(tqt3cgroup, TQColorGroup::Text, convertQt4ToTQt3Brush(qt4palette.brush(qt4cgroup, QPalette::Text)));
|
|
tqt3palette.setBrush(tqt3cgroup, TQColorGroup::Button, convertQt4ToTQt3Brush(qt4palette.brush(qt4cgroup, QPalette::Button)));
|
|
tqt3palette.setBrush(tqt3cgroup, TQColorGroup::ButtonText, convertQt4ToTQt3Brush(qt4palette.brush(qt4cgroup, QPalette::ButtonText)));
|
|
tqt3palette.setBrush(tqt3cgroup, TQColorGroup::Light, convertQt4ToTQt3Brush(qt4palette.brush(qt4cgroup, QPalette::Light)));
|
|
tqt3palette.setBrush(tqt3cgroup, TQColorGroup::Midlight, convertQt4ToTQt3Brush(qt4palette.brush(qt4cgroup, QPalette::Midlight)));
|
|
tqt3palette.setBrush(tqt3cgroup, TQColorGroup::Dark, convertQt4ToTQt3Brush(qt4palette.brush(qt4cgroup, QPalette::Dark)));
|
|
tqt3palette.setBrush(tqt3cgroup, TQColorGroup::Mid, convertQt4ToTQt3Brush(qt4palette.brush(qt4cgroup, QPalette::Mid)));
|
|
tqt3palette.setBrush(tqt3cgroup, TQColorGroup::Shadow, convertQt4ToTQt3Brush(qt4palette.brush(qt4cgroup, QPalette::Shadow)));
|
|
tqt3palette.setBrush(tqt3cgroup, TQColorGroup::Highlight, convertQt4ToTQt3Brush(qt4palette.brush(qt4cgroup, QPalette::Highlight)));
|
|
tqt3palette.setBrush(tqt3cgroup, TQColorGroup::HighlightedText, convertQt4ToTQt3Brush(qt4palette.brush(qt4cgroup, QPalette::HighlightedText)));
|
|
tqt3palette.setBrush(tqt3cgroup, TQColorGroup::BrightText, convertQt4ToTQt3Brush(qt4palette.brush(qt4cgroup, QPalette::BrightText)));
|
|
tqt3palette.setBrush(tqt3cgroup, TQColorGroup::Link, convertQt4ToTQt3Brush(qt4palette.brush(qt4cgroup, QPalette::Link)));
|
|
tqt3palette.setBrush(tqt3cgroup, TQColorGroup::LinkVisited, convertQt4ToTQt3Brush(qt4palette.brush(qt4cgroup, QPalette::LinkVisited)));
|
|
|
|
// Colors
|
|
tqt3palette.setColor(tqt3cgroup, TQColorGroup::Background, convertQt4ToTQt3Color(qt4palette.color(qt4cgroup, QPalette::Background)));
|
|
tqt3palette.setColor(tqt3cgroup, TQColorGroup::Foreground, convertQt4ToTQt3Color(qt4palette.color(qt4cgroup, QPalette::Foreground)));
|
|
tqt3palette.setColor(tqt3cgroup, TQColorGroup::Base, convertQt4ToTQt3Color(qt4palette.color(qt4cgroup, QPalette::Base)));
|
|
tqt3palette.setColor(tqt3cgroup, TQColorGroup::Text, convertQt4ToTQt3Color(qt4palette.color(qt4cgroup, QPalette::Text)));
|
|
tqt3palette.setColor(tqt3cgroup, TQColorGroup::Button, convertQt4ToTQt3Color(qt4palette.color(qt4cgroup, QPalette::Button)));
|
|
tqt3palette.setColor(tqt3cgroup, TQColorGroup::ButtonText, convertQt4ToTQt3Color(qt4palette.color(qt4cgroup, QPalette::ButtonText)));
|
|
tqt3palette.setColor(tqt3cgroup, TQColorGroup::Light, convertQt4ToTQt3Color(qt4palette.color(qt4cgroup, QPalette::Light)));
|
|
tqt3palette.setColor(tqt3cgroup, TQColorGroup::Midlight, convertQt4ToTQt3Color(qt4palette.color(qt4cgroup, QPalette::Midlight)));
|
|
tqt3palette.setColor(tqt3cgroup, TQColorGroup::Dark, convertQt4ToTQt3Color(qt4palette.color(qt4cgroup, QPalette::Dark)));
|
|
tqt3palette.setColor(tqt3cgroup, TQColorGroup::Mid, convertQt4ToTQt3Color(qt4palette.color(qt4cgroup, QPalette::Mid)));
|
|
tqt3palette.setColor(tqt3cgroup, TQColorGroup::Shadow, convertQt4ToTQt3Color(qt4palette.color(qt4cgroup, QPalette::Shadow)));
|
|
tqt3palette.setColor(tqt3cgroup, TQColorGroup::Highlight, convertQt4ToTQt3Color(qt4palette.color(qt4cgroup, QPalette::Highlight)));
|
|
tqt3palette.setColor(tqt3cgroup, TQColorGroup::HighlightedText, convertQt4ToTQt3Color(qt4palette.color(qt4cgroup, QPalette::HighlightedText)));
|
|
tqt3palette.setColor(tqt3cgroup, TQColorGroup::BrightText, convertQt4ToTQt3Color(qt4palette.color(qt4cgroup, QPalette::BrightText)));
|
|
tqt3palette.setColor(tqt3cgroup, TQColorGroup::Link, convertQt4ToTQt3Color(qt4palette.color(qt4cgroup, QPalette::Link)));
|
|
tqt3palette.setColor(tqt3cgroup, TQColorGroup::LinkVisited, convertQt4ToTQt3Color(qt4palette.color(qt4cgroup, QPalette::LinkVisited)));
|
|
}
|
|
|
|
return tqt3palette;
|
|
}
|
|
|
|
inline TQStyle::SFlags convertQt4ToTQt3SFlags(QStyle::State qt4stateflags, TQt3WidgetType wt)
|
|
{
|
|
// Convert sflags
|
|
TQStyle::SFlags sflags = 0;
|
|
|
|
if (qt4stateflags & QStyle::State_Active) {
|
|
if (wt != TQT3WT_TQPopupMenu) {
|
|
sflags = sflags | TQStyle::Style_Active;
|
|
}
|
|
}
|
|
if (qt4stateflags & QStyle::State_AutoRaise) {
|
|
sflags = sflags | TQStyle::Style_AutoRaise;
|
|
}
|
|
// if (qt4stateflags & QStyle::State_Children) {
|
|
// sflags = sflags | TQStyle::;
|
|
// }
|
|
if (qt4stateflags & QStyle::State_DownArrow) {
|
|
sflags = sflags | TQStyle::Style_Down;
|
|
}
|
|
// if (qt4stateflags & QStyle::State_Editing) {
|
|
// sflags = sflags | TQStyle::;
|
|
// }
|
|
if (qt4stateflags & QStyle::State_Enabled) {
|
|
sflags = sflags | TQStyle::Style_Enabled;
|
|
}
|
|
// if (qt4stateflags & QStyle::State_HasEditFocus) {
|
|
// sflags = sflags | TQStyle::Style_HasFocus;
|
|
// }
|
|
if (qt4stateflags & QStyle::State_HasFocus) {
|
|
sflags = sflags | TQStyle::Style_HasFocus;
|
|
}
|
|
if (qt4stateflags & QStyle::State_Horizontal) {
|
|
sflags = sflags | TQStyle::Style_Horizontal;
|
|
}
|
|
// if (qt4stateflags & QStyle::State_KeyboardFocusChange) {
|
|
// sflags = sflags | TQStyle::;
|
|
// }
|
|
if (qt4stateflags & QStyle::State_MouseOver) {
|
|
sflags = sflags | TQStyle::Style_MouseOver;
|
|
}
|
|
if (qt4stateflags & QStyle::State_NoChange) {
|
|
sflags = sflags | TQStyle::Style_NoChange;
|
|
}
|
|
if (qt4stateflags & QStyle::State_Off) {
|
|
sflags = sflags | TQStyle::Style_Off;
|
|
}
|
|
if (qt4stateflags & QStyle::State_On) {
|
|
sflags = sflags | TQStyle::Style_On;
|
|
}
|
|
if (qt4stateflags & QStyle::State_Raised) {
|
|
sflags = sflags | TQStyle::Style_Raised;
|
|
}
|
|
// if (qt4stateflags & QStyle::State_ReadOnly) {
|
|
// sflags = sflags | TQStyle::;
|
|
// }
|
|
if (qt4stateflags & QStyle::State_Selected) {
|
|
if (wt == TQT3WT_TQPopupMenu) {
|
|
sflags = sflags | TQStyle::Style_Active;
|
|
}
|
|
sflags = sflags | TQStyle::Style_Selected;
|
|
}
|
|
// if (qt4stateflags & QStyle::State_Item) {
|
|
// sflags = sflags | TQStyle::;
|
|
// }
|
|
// if (qt4stateflags & QStyle::State_Open) {
|
|
// sflags = sflags | TQStyle::;
|
|
// }
|
|
// if (qt4stateflags & QStyle::State_Sibling) {
|
|
// sflags = sflags | TQStyle::;
|
|
// }
|
|
if (qt4stateflags & QStyle::State_Sunken) {
|
|
sflags = sflags | TQStyle::Style_Sunken;
|
|
}
|
|
if (qt4stateflags & QStyle::State_UpArrow) {
|
|
sflags = sflags | TQStyle::Style_Up;
|
|
}
|
|
// if (qt4stateflags & QStyle::State_Mini) {
|
|
// sflags = sflags | TQStyle::;
|
|
// }
|
|
// if (qt4stateflags & QStyle::State_Small) {
|
|
// sflags = sflags | TQStyle::;
|
|
// }
|
|
|
|
return sflags;
|
|
}
|
|
|
|
SimpleStyle::SimpleStyle()
|
|
{
|
|
#ifdef INTEGRATE_WITH_TDE
|
|
if (!tqApp) {
|
|
// Initialize KApplication required data structures
|
|
int argc = 1;
|
|
char** argv;
|
|
// Supply it with fake data to keep KApplication happy
|
|
argv = (char**) malloc(sizeof(char*));
|
|
argv[0] = (char*) malloc(sizeof(char) * 19);
|
|
strncpy(argv[0], "SimpleStyle", 19);
|
|
|
|
KAboutData aboutData("SimpleStyle", I18N_NOOP("SimpleStyle"), "v0.1",
|
|
"TDE Qt4 theme engine", KAboutData::License_GPL,
|
|
"(c) 2012, Timothy Pearson",
|
|
"message goes here", 0 /* TODO: Website */, "kb9vqf@pearsoncomputing.net");
|
|
KCmdLineArgs::init(argc, argv, &aboutData);
|
|
|
|
// Qt4 can be SO STUPID sometimes...why can't I get the X11 display directly from qApp?!?!??
|
|
QWidget myhackedwidget;
|
|
new KApplication(myhackedwidget.x11Info().display());
|
|
}
|
|
|
|
// Set the Qt4 icon set to the TDE icon set
|
|
QIcon::setThemeName(convertTQt3ToQt4String(KIconTheme::current()));
|
|
#else // INTEGRATE_WITH_TDE
|
|
if (!tqApp) {
|
|
// Qt4 can be SO STUPID sometimes...why can't I get the X11 display directly from qApp?!?!??
|
|
QWidget myhackedwidget;
|
|
new TQApplication(myhackedwidget.x11Info().display());
|
|
}
|
|
#endif // INTEGRATE_WITH_TDE
|
|
|
|
// Set the Qt4 palette to the TQt3 palette
|
|
qApp->setPalette(convertTQt3ToQt4Palette(tqApp->palette()));
|
|
|
|
// Create interface widgets
|
|
m_tqt3parent_widget = new TQWidget();
|
|
|
|
m_tqt3progressbar_widget = new TQProgressBar(m_tqt3parent_widget);
|
|
m_tqt3tabbar_widget = new TQTabBar(m_tqt3parent_widget);
|
|
m_tqt3radiobutton_widget = new TQRadioButton(m_tqt3parent_widget);
|
|
m_tqt3popupmenu_widget = new TQPopupMenu(m_tqt3parent_widget);
|
|
m_tqt3combobox_widget = new TQComboBox(m_tqt3parent_widget);
|
|
}
|
|
|
|
SimpleStyle::~SimpleStyle()
|
|
{
|
|
// delete tqApp;
|
|
|
|
// Delete interface widgets
|
|
// Widgets are deleted when their parent is deleted...these lines will cause a crash on exit
|
|
// delete m_tqt3progressbar_widget;
|
|
// delete m_tqt3tabbar_widget;
|
|
// delete m_tqt3radiobutton_widget;
|
|
// delete m_tqt3popupmenu_widget;
|
|
// delete m_tqt3combobox_widget;
|
|
|
|
// FIXME
|
|
// Verify I'm not leaking memory like a sieve when this is commented out!!!
|
|
// delete m_tqt3parent_widget;
|
|
}
|
|
|
|
void SimpleStyle::polish(QPalette &palette)
|
|
{
|
|
// FIXME
|
|
// Figure out some way to polish the Qt4 widgets with the Qt3 polish method
|
|
// This probably involves modifying Qt3 to specify a painter...
|
|
}
|
|
|
|
void SimpleStyle::polish(QWidget *widget)
|
|
{
|
|
// HACK
|
|
// Many TQt3 styles need to be notified when their widgets are moused over
|
|
// The only way we can really do that here is to force a repaint on mouse entry/mouse exit
|
|
// I figure if Qt4 programmers and users can put up with Qt4's overall poor raster graphics
|
|
// performance, they can also put up with this hack...
|
|
widget->setMouseTracking(true);
|
|
widget->installEventFilter(this);
|
|
}
|
|
|
|
void SimpleStyle::unpolish(QWidget *widget)
|
|
{
|
|
// HACK
|
|
// See SimpleStyle::polish
|
|
widget->setMouseTracking(false);
|
|
widget->removeEventFilter(this);
|
|
}
|
|
|
|
bool SimpleStyle::eventFilter(QObject *obj, QEvent *ev)
|
|
{
|
|
// HACK
|
|
// See SimpleStyle::polish
|
|
if (!obj->isWidgetType() ) {
|
|
return false;
|
|
}
|
|
|
|
QWidget* widget = static_cast<QWidget*>(obj);
|
|
|
|
if ((ev->type() == QEvent::FocusIn) || (ev->type() == QEvent::FocusOut)
|
|
|| (ev->type() == QEvent::Enter) || (ev->type() == QEvent::Leave) || (ev->type() == QEvent::Wheel)) {
|
|
widget->repaint();
|
|
}
|
|
else {
|
|
// if (dynamic_cast<QTabBar*>(obj)) {
|
|
if (ev->type() == QEvent::MouseMove) {
|
|
QTabBar *tabbar = dynamic_cast<QTabBar*>(obj);
|
|
QMouseEvent *me = dynamic_cast<QMouseEvent*>(ev);
|
|
if (tabbar && me) {
|
|
// FIXME
|
|
// Avoid unnecessary repaints (which otherwise would occour on every
|
|
// MouseMove event causing high cpu load).
|
|
// FIXME
|
|
// Tab highlighting won't work unless we keep the same tabbar object,
|
|
// and specifically tab objects, while the mouse is being moved within
|
|
// the tabbar...also the eventFilter method of the style needs to be called...
|
|
|
|
bool repaint = true;
|
|
|
|
// QTab *tab = tabbar->selectTab(me->pos() );
|
|
// if (hoverTab == tab)
|
|
// repaint = false;
|
|
// hoverTab = tab;
|
|
|
|
if (repaint)
|
|
tabbar->repaint();
|
|
}
|
|
}
|
|
// }
|
|
}
|
|
|
|
// Transparently pass the event on to any other handlers
|
|
return false;
|
|
}
|
|
|
|
int SimpleStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QWidget *w ) const
|
|
{
|
|
int retval = 0;
|
|
TQWidget* interfaceWidget = 0;
|
|
|
|
char retswitch = 0;
|
|
TQStyle::PixelMetric tqt3pixelmetric = TQStyle::PM_CustomBase;
|
|
switch (metric) {
|
|
case QStyle::PM_ButtonMargin:
|
|
tqt3pixelmetric = TQStyle::PM_ButtonMargin;
|
|
retswitch = 1;
|
|
break;
|
|
// case QStyle::PM_DockWidgetTitleBarButtonMargin:
|
|
// tqt3pixelmetric = TQStyle::;
|
|
// retswitch = 1;
|
|
// break;
|
|
case QStyle::PM_ButtonDefaultIndicator:
|
|
tqt3pixelmetric = TQStyle::PM_ButtonDefaultIndicator;
|
|
retswitch = 1;
|
|
break;
|
|
case QStyle::PM_MenuButtonIndicator:
|
|
tqt3pixelmetric = TQStyle::PM_MenuButtonIndicator;
|
|
retswitch = 1;
|
|
break;
|
|
case QStyle::PM_ButtonShiftHorizontal:
|
|
tqt3pixelmetric = TQStyle::PM_ButtonShiftHorizontal;
|
|
retswitch = 1;
|
|
break;
|
|
case QStyle::PM_ButtonShiftVertical:
|
|
tqt3pixelmetric = TQStyle::PM_ButtonShiftVertical;
|
|
retswitch = 1;
|
|
break;
|
|
case QStyle::PM_DefaultFrameWidth:
|
|
tqt3pixelmetric = TQStyle::PM_DefaultFrameWidth;
|
|
retswitch = 1;
|
|
break;
|
|
case QStyle::PM_SpinBoxFrameWidth:
|
|
tqt3pixelmetric = TQStyle::PM_SpinBoxFrameWidth;
|
|
retswitch = 1;
|
|
break;
|
|
// case QStyle::PM_ComboBoxFrameWidth:
|
|
// tqt3pixelmetric = TQStyle::PM_ComboBoxFrameWidth;
|
|
// retswitch = 1;
|
|
// break;
|
|
case QStyle::PM_MDIFrameWidth:
|
|
tqt3pixelmetric = TQStyle::PM_MDIFrameWidth;
|
|
retswitch = 1;
|
|
break;
|
|
// case QStyle::PM_MdiSubWindowFrameWidth:
|
|
// tqt3pixelmetric = TQStyle::PM_MdiSubWindowFrameWidth;
|
|
// retswitch = 1;
|
|
// break;
|
|
case QStyle::PM_MDIMinimizedWidth:
|
|
tqt3pixelmetric = TQStyle::PM_MDIMinimizedWidth;
|
|
retswitch = 1;
|
|
break;
|
|
// case QStyle::PM_MdiSubWindowMinimizedWidth:
|
|
// tqt3pixelmetric = TQStyle::PM_MdiSubWindowMinimizedWidth;
|
|
// retswitch = 1;
|
|
// break;
|
|
case QStyle::PM_LayoutLeftMargin:
|
|
retval = 0;
|
|
retswitch = 2;
|
|
break;
|
|
case QStyle::PM_LayoutTopMargin:
|
|
retval = 0;
|
|
retswitch = 2;
|
|
break;
|
|
case QStyle::PM_LayoutRightMargin:
|
|
retval = 0;
|
|
retswitch = 2;
|
|
break;
|
|
case QStyle::PM_LayoutBottomMargin:
|
|
retval = 0;
|
|
retswitch = 2;
|
|
break;
|
|
case QStyle::PM_LayoutHorizontalSpacing:
|
|
retval = 0;
|
|
retswitch = 2;
|
|
break;
|
|
case QStyle::PM_LayoutVerticalSpacing:
|
|
retval = 0;
|
|
retswitch = 2;
|
|
break;
|
|
case QStyle::PM_MaximumDragDistance:
|
|
tqt3pixelmetric = TQStyle::PM_MaximumDragDistance;
|
|
retswitch = 1;
|
|
break;
|
|
case QStyle::PM_ScrollBarExtent:
|
|
tqt3pixelmetric = TQStyle::PM_ScrollBarExtent;
|
|
retswitch = 1;
|
|
break;
|
|
case QStyle::PM_ScrollBarSliderMin:
|
|
tqt3pixelmetric = TQStyle::PM_ScrollBarSliderMin;
|
|
retswitch = 1;
|
|
break;
|
|
case QStyle::PM_SliderThickness:
|
|
tqt3pixelmetric = TQStyle::PM_SliderThickness;
|
|
retswitch = 1;
|
|
break;
|
|
case QStyle::PM_SliderControlThickness:
|
|
tqt3pixelmetric = TQStyle::PM_SliderControlThickness;
|
|
retswitch = 1;
|
|
break;
|
|
case QStyle::PM_SliderLength:
|
|
tqt3pixelmetric = TQStyle::PM_SliderLength;
|
|
retswitch = 1;
|
|
break;
|
|
case QStyle::PM_SliderTickmarkOffset:
|
|
tqt3pixelmetric = TQStyle::PM_SliderTickmarkOffset;
|
|
retswitch = 1;
|
|
break;
|
|
case QStyle::PM_SliderSpaceAvailable:
|
|
tqt3pixelmetric = TQStyle::PM_SliderSpaceAvailable;
|
|
retswitch = 1;
|
|
break;
|
|
case QStyle::PM_DockWidgetSeparatorExtent:
|
|
tqt3pixelmetric = TQStyle::PM_DockWindowSeparatorExtent;
|
|
retswitch = 1;
|
|
break;
|
|
case QStyle::PM_DockWidgetHandleExtent:
|
|
tqt3pixelmetric = TQStyle::PM_DockWindowHandleExtent;
|
|
retswitch = 1;
|
|
break;
|
|
case QStyle::PM_DockWidgetFrameWidth:
|
|
tqt3pixelmetric = TQStyle::PM_DockWindowFrameWidth;
|
|
retswitch = 1;
|
|
break;
|
|
// case QStyle::PM_DockWidgetTitleMargin:
|
|
// tqt3pixelmetric = TQStyle::PM_DockWindowTitleMargin;
|
|
// retswitch = 1;
|
|
// break;
|
|
case QStyle::PM_MenuBarPanelWidth:
|
|
tqt3pixelmetric = TQStyle::PM_MenuBarFrameWidth;
|
|
retswitch = 1;
|
|
break;
|
|
case QStyle::PM_MenuBarItemSpacing:
|
|
tqt3pixelmetric = TQStyle::PM_MenuBarItemSpacing;
|
|
retswitch = 1;
|
|
break;
|
|
// case QStyle::PM_MenuBarHMargin:
|
|
// tqt3pixelmetric = TQStyle::PM_MenuBarHMargin;
|
|
// retswitch = 1;
|
|
// break;
|
|
// case QStyle::PM_MenuBarVMargin:
|
|
// tqt3pixelmetric = TQStyle::PM_MenuBarVMargin;
|
|
// retswitch = 1;
|
|
// break;
|
|
// case QStyle::PM_ToolBarFrameWidth:
|
|
// tqt3pixelmetric = TQStyle::PM_ToolBarFrameWidth;
|
|
// retswitch = 1;
|
|
// break;
|
|
// case QStyle::PM_ToolBarHandleExtent:
|
|
// tqt3pixelmetric = TQStyle::PM_ToolBarHandleExtent;
|
|
// retswitch = 1;
|
|
// break;
|
|
// case QStyle::PM_ToolBarItemMargin:
|
|
// tqt3pixelmetric = TQStyle::PM_ToolBarItemMargin;
|
|
// retswitch = 1;
|
|
// break;
|
|
// case QStyle::PM_ToolBarItemSpacing:
|
|
// tqt3pixelmetric = TQStyle::PM_ToolBarItemSpacing;
|
|
// retswitch = 1;
|
|
// break;
|
|
// case QStyle::PM_ToolBarSeparatorExtent:
|
|
// tqt3pixelmetric = TQStyle::PM_ToolBarSeparatorExtent;
|
|
// retswitch = 1;
|
|
// break;
|
|
// case QStyle::PM_ToolBarExtensionExtent:
|
|
// tqt3pixelmetric = TQStyle::PM_ToolBarExtensionExtent;
|
|
// retswitch = 1;
|
|
// break;
|
|
case QStyle::PM_TabBarTabOverlap:
|
|
tqt3pixelmetric = TQStyle::PM_TabBarTabOverlap;
|
|
interfaceWidget = initializeInterfaceWidget(TQT3WT_TQTabBar, w);
|
|
retswitch = 1;
|
|
break;
|
|
case QStyle::PM_TabBarTabHSpace:
|
|
tqt3pixelmetric = TQStyle::PM_TabBarTabHSpace;
|
|
interfaceWidget = initializeInterfaceWidget(TQT3WT_TQTabBar, w);
|
|
retswitch = 1;
|
|
break;
|
|
case QStyle::PM_TabBarTabVSpace:
|
|
tqt3pixelmetric = TQStyle::PM_TabBarTabVSpace;
|
|
interfaceWidget = initializeInterfaceWidget(TQT3WT_TQTabBar, w);
|
|
retswitch = 1;
|
|
break;
|
|
case QStyle::PM_TabBarBaseHeight:
|
|
tqt3pixelmetric = TQStyle::PM_TabBarBaseHeight;
|
|
interfaceWidget = initializeInterfaceWidget(TQT3WT_TQTabBar, w);
|
|
retswitch = 1;
|
|
break;
|
|
case QStyle::PM_TabBarBaseOverlap:
|
|
tqt3pixelmetric = TQStyle::PM_TabBarBaseOverlap;
|
|
interfaceWidget = initializeInterfaceWidget(TQT3WT_TQTabBar, w);
|
|
retswitch = 1;
|
|
break;
|
|
case QStyle::PM_TabBarScrollButtonWidth:
|
|
tqt3pixelmetric = TQStyle::PM_TabBarScrollButtonWidth;
|
|
interfaceWidget = initializeInterfaceWidget(TQT3WT_TQTabBar, w);
|
|
retswitch = 1;
|
|
break;
|
|
case QStyle::PM_TabBarTabShiftHorizontal:
|
|
tqt3pixelmetric = TQStyle::PM_TabBarTabShiftHorizontal;
|
|
interfaceWidget = initializeInterfaceWidget(TQT3WT_TQTabBar, w);
|
|
retswitch = 1;
|
|
break;
|
|
case QStyle::PM_TabBarTabShiftVertical:
|
|
tqt3pixelmetric = TQStyle::PM_TabBarTabShiftVertical;
|
|
interfaceWidget = initializeInterfaceWidget(TQT3WT_TQTabBar, w);
|
|
retswitch = 1;
|
|
break;
|
|
case QStyle::PM_ProgressBarChunkWidth:
|
|
tqt3pixelmetric = TQStyle::PM_ProgressBarChunkWidth;
|
|
retswitch = 1;
|
|
break;
|
|
case QStyle::PM_SplitterWidth:
|
|
tqt3pixelmetric = TQStyle::PM_SplitterWidth;
|
|
retswitch = 1;
|
|
break;
|
|
case QStyle::PM_TitleBarHeight:
|
|
tqt3pixelmetric = TQStyle::PM_TitleBarHeight;
|
|
retswitch = 1;
|
|
break;
|
|
case QStyle::PM_IndicatorWidth:
|
|
tqt3pixelmetric = TQStyle::PM_IndicatorWidth;
|
|
retswitch = 1;
|
|
break;
|
|
case QStyle::PM_IndicatorHeight:
|
|
tqt3pixelmetric = TQStyle::PM_IndicatorHeight;
|
|
retswitch = 1;
|
|
break;
|
|
case QStyle::PM_ExclusiveIndicatorWidth:
|
|
tqt3pixelmetric = TQStyle::PM_ExclusiveIndicatorWidth;
|
|
retswitch = 1;
|
|
break;
|
|
case QStyle::PM_ExclusiveIndicatorHeight:
|
|
tqt3pixelmetric = TQStyle::PM_ExclusiveIndicatorHeight;
|
|
retswitch = 1;
|
|
break;
|
|
// case QStyle::PM_MenuPanelWidth:
|
|
// retval = 0;
|
|
// retswitch = 2;
|
|
// break;
|
|
case QStyle::PM_MenuHMargin:
|
|
retval = 0;
|
|
retswitch = 2;
|
|
break;
|
|
case QStyle::PM_MenuVMargin:
|
|
retval = 0;
|
|
retswitch = 2;
|
|
break;
|
|
// case QStyle::PM_MenuScrollerHeight:
|
|
// tqt3pixelmetric = TQStyle::PM_MenuScrollerHeight;
|
|
// retswitch = 1;
|
|
// break;
|
|
// case QStyle::PM_MenuTearoffHeight:
|
|
// tqt3pixelmetric = TQStyle::PM_MenuTearoffHeight;
|
|
// retswitch = 1;
|
|
// break;
|
|
// case QStyle::PM_MenuDesktopFrameWidth:
|
|
// tqt3pixelmetric = TQStyle::PM_MenuDesktopFrameWidth;
|
|
// retswitch = 1;
|
|
// break;
|
|
case QStyle::PM_CheckListButtonSize:
|
|
tqt3pixelmetric = TQStyle::PM_CheckListButtonSize;
|
|
retswitch = 1;
|
|
break;
|
|
case QStyle::PM_CheckListControllerSize:
|
|
tqt3pixelmetric = TQStyle::PM_CheckListControllerSize;
|
|
retswitch = 1;
|
|
break;
|
|
case QStyle::PM_HeaderMarkSize:
|
|
tqt3pixelmetric = TQStyle::PM_HeaderMarkSize;
|
|
retswitch = 1;
|
|
break;
|
|
case QStyle::PM_HeaderGripMargin:
|
|
tqt3pixelmetric = TQStyle::PM_HeaderGripMargin;
|
|
retswitch = 1;
|
|
break;
|
|
case QStyle::PM_HeaderMargin:
|
|
tqt3pixelmetric = TQStyle::PM_HeaderMargin;
|
|
retswitch = 1;
|
|
break;
|
|
// case QStyle::PM_SpinBoxSliderHeight:
|
|
// tqt3pixelmetric = TQStyle::PM_SpinBoxSliderHeight;
|
|
// retswitch = 1;
|
|
// break;
|
|
// case QStyle::PM_ToolBarIconSize:
|
|
// tqt3pixelmetric = TQStyle::PM_ToolBarIconSize;
|
|
// retswitch = 1;
|
|
// break;
|
|
// case QStyle::PM_SmallIconSize:
|
|
// tqt3pixelmetric = TQStyle::PM_SmallIconSize;
|
|
// retswitch = 1;
|
|
// break;
|
|
// case QStyle::PM_LargeIconSize:
|
|
// tqt3pixelmetric = TQStyle::PM_LargeIconSize;
|
|
// retswitch = 1;
|
|
// break;
|
|
// case QStyle::PM_FocusFrameHMargin:
|
|
// tqt3pixelmetric = TQStyle::PM_FocusFrameHMargin;
|
|
// retswitch = 1;
|
|
// break;
|
|
// case QStyle::PM_FocusFrameVMargin:
|
|
// tqt3pixelmetric = TQStyle::PM_FocusFrameVMargin;
|
|
// retswitch = 1;
|
|
// break;
|
|
// case QStyle::PM_IconViewIconSize:
|
|
// tqt3pixelmetric = TQStyle::PM_IconViewIconSize;
|
|
// retswitch = 1;
|
|
// break;
|
|
// case QStyle::PM_ListViewIconSize:
|
|
// tqt3pixelmetric = TQStyle::PM_ListViewIconSize;
|
|
// retswitch = 1;
|
|
// break;
|
|
// case QStyle::PM_ToolTipLabelFrameWidth:
|
|
// tqt3pixelmetric = TQStyle::PM_ToolTipLabelFrameWidth;
|
|
// retswitch = 1;
|
|
// break;
|
|
// case QStyle::PM_CheckBoxLabelSpacing:
|
|
// tqt3pixelmetric = TQStyle::PM_CheckBoxLabelSpacing;
|
|
// retswitch = 1;
|
|
// break;
|
|
// case QStyle::PM_RadioButtonLabelSpacing:
|
|
// tqt3pixelmetric = TQStyle::PM_RadioButtonLabelSpacing;
|
|
// retswitch = 1;
|
|
// break;
|
|
// case QStyle::PM_TabBarIconSize:
|
|
// tqt3pixelmetric = TQStyle::PM_TabBarIconSize;
|
|
// retswitch = 1;
|
|
// break;
|
|
// case QStyle::PM_SizeGripSize:
|
|
// tqt3pixelmetric = TQStyle::PM_SizeGripSize;
|
|
// retswitch = 1;
|
|
// break;
|
|
// case QStyle::PM_MessageBoxIconSize:
|
|
// tqt3pixelmetric = TQStyle::PM_MessageBoxIconSize;
|
|
// retswitch = 1;
|
|
// break;
|
|
// case QStyle::PM_ButtonIconSize:
|
|
// tqt3pixelmetric = TQStyle::PM_ButtonIconSize;
|
|
// retswitch = 1;
|
|
// break;
|
|
// case QStyle::PM_TextCursorWidth:
|
|
// tqt3pixelmetric = TQStyle::PM_TextCursorWidth;
|
|
// retswitch = 1;
|
|
// break;
|
|
// case QStyle::PM_TabBar_ScrollButtonOverlap:
|
|
// tqt3pixelmetric = TQStyle::PM_TabBar_ScrollButtonOverlap;
|
|
// retswitch = 1;
|
|
// break;
|
|
// case QStyle::PM_TabCloseIndicatorWidth:
|
|
// tqt3pixelmetric = TQStyle::PM_TabCloseIndicatorWidth;
|
|
// retswitch = 1;
|
|
// break;
|
|
// case QStyle::PM_TabCloseIndicatorHeight:
|
|
// tqt3pixelmetric = TQStyle::PM_TabCloseIndicatorHeight;
|
|
// retswitch = 1;
|
|
// break;
|
|
default:
|
|
#ifdef DEBUG_WARNINGS
|
|
printf("No metrics for Qt4 element %d\n\r", metric); fflush(stdout);
|
|
#endif
|
|
retval = 0;
|
|
}
|
|
|
|
if (retswitch == 1) {
|
|
retval = tqApp->style().pixelMetric(tqt3pixelmetric, interfaceWidget);
|
|
}
|
|
else {
|
|
// if (retswitch == 2) {
|
|
// // retval was already set
|
|
// }
|
|
// else {
|
|
// Tell Qt4 to get the information
|
|
retval = QCommonStyle::pixelMetric(metric, opt, w);
|
|
// }
|
|
}
|
|
|
|
return retval;
|
|
}
|
|
|
|
TQWidget* SimpleStyle::initializeInterfaceWidget(TQt3WidgetType wt, const QWidget* w) const
|
|
{
|
|
int i;
|
|
TQWidget* interfaceWidget = 0;
|
|
|
|
// Qt4 interface widget pointers
|
|
const QTabBar* qt4tabbar_widget = 0;
|
|
const QRadioButton* qt4radiobutton_widget = 0;
|
|
const QMenu* qt4menu_widget = 0;
|
|
const QProgressBar* qt4progressbar_widget = 0;
|
|
const QComboBox* qt4combobox_widget = 0;
|
|
|
|
TQTabBar::Shape tqt3tbshape = TQTabBar::RoundedAbove;
|
|
|
|
switch (wt) {
|
|
case TQT3WT_TQProgressBar:
|
|
interfaceWidget = m_tqt3progressbar_widget;
|
|
// Copy over all widget attributes
|
|
qt4progressbar_widget = static_cast<const QProgressBar*>(w);
|
|
m_tqt3progressbar_widget->setGeometry(0, 0, qt4progressbar_widget->width(), qt4progressbar_widget->height());
|
|
m_tqt3progressbar_widget->setProgress(qt4progressbar_widget->value()-qt4progressbar_widget->minimum(),qt4progressbar_widget->maximum()-qt4progressbar_widget->minimum());
|
|
if (qt4progressbar_widget->orientation() != Qt::Horizontal) {
|
|
// Qt3 cannot draw vertical progress bars
|
|
#ifdef DEBUG_WARNINGS
|
|
printf("No rules to draw vertical Qt4 progress bar\n\r"); fflush(stdout);
|
|
interfaceWidget = 0;
|
|
#endif
|
|
}
|
|
break;
|
|
case TQT3WT_TQTabBar:
|
|
interfaceWidget = m_tqt3tabbar_widget;
|
|
// Copy over all widget attributes
|
|
qt4tabbar_widget = static_cast<const QTabBar*>(w);
|
|
m_tqt3tabbar_widget->setGeometry(0, 0, qt4tabbar_widget->width(), qt4tabbar_widget->height());
|
|
// Clear out tabbar
|
|
for (i=0;i<m_tqt3tabbar_widget->count();i++) {
|
|
m_tqt3tabbar_widget->removeTab(m_tqt3tabbar_widget->tabAt(i));
|
|
}
|
|
// Copy over all tabs
|
|
for (i=0;i<qt4tabbar_widget->count();i++) {
|
|
if (qt4tabbar_widget->tabIcon(i).isNull()) {
|
|
TQTab* newTab = new TQTab(convertQt4ToTQt3String(qt4tabbar_widget->tabText(i)));
|
|
m_tqt3tabbar_widget->insertTab(newTab, i);
|
|
newTab->setIdentifier(i);
|
|
}
|
|
else {
|
|
TQTab* newTab = new TQTab(convertQt4ToTQt3IconSet(qt4tabbar_widget->tabIcon(i)), convertQt4ToTQt3String(qt4tabbar_widget->tabText(i)));
|
|
m_tqt3tabbar_widget->insertTab(newTab, i);
|
|
newTab->setIdentifier(i);
|
|
}
|
|
}
|
|
m_tqt3tabbar_widget->setCurrentTab(qt4tabbar_widget->currentIndex());
|
|
switch (qt4tabbar_widget->shape()) {
|
|
case QTabBar::RoundedNorth:
|
|
tqt3tbshape = TQTabBar::RoundedAbove;
|
|
break;
|
|
case QTabBar::RoundedSouth:
|
|
tqt3tbshape = TQTabBar::RoundedBelow;
|
|
break;
|
|
case QTabBar::TriangularNorth:
|
|
tqt3tbshape = TQTabBar::TriangularAbove;
|
|
break;
|
|
case QTabBar::TriangularSouth:
|
|
tqt3tbshape = TQTabBar::TriangularBelow;
|
|
break;
|
|
default:
|
|
// Qt3 cannot draw other tab shapes
|
|
#ifdef DEBUG_WARNINGS
|
|
printf("No rules to draw Qt4 tab shape %d\n\r", qt4tabbar_widget->shape()); fflush(stdout);
|
|
interfaceWidget = 0;
|
|
#endif
|
|
}
|
|
m_tqt3tabbar_widget->setShape(tqt3tbshape);
|
|
break;
|
|
case TQT3WT_TQRadioButton:
|
|
interfaceWidget = m_tqt3radiobutton_widget;
|
|
// Copy over all widget attributes
|
|
qt4radiobutton_widget = static_cast<const QRadioButton*>(w);
|
|
m_tqt3radiobutton_widget->setGeometry(0, 0, qt4radiobutton_widget->width(), qt4radiobutton_widget->height());
|
|
m_tqt3radiobutton_widget->setText(convertQt4ToTQt3String(qt4radiobutton_widget->text()));
|
|
m_tqt3radiobutton_widget->setDown(qt4radiobutton_widget->isDown());
|
|
break;
|
|
case TQT3WT_TQComboBox:
|
|
interfaceWidget = m_tqt3combobox_widget;
|
|
// Copy over all widget attributes
|
|
qt4combobox_widget = static_cast<const QComboBox*>(w);
|
|
m_tqt3combobox_widget->setGeometry(0, 0, qt4combobox_widget->width(), qt4combobox_widget->height());
|
|
// Clear out all combobox items
|
|
m_tqt3combobox_widget->clear();
|
|
|
|
for (i=0;i<qt4combobox_widget->count();i++) {
|
|
if (qt4combobox_widget->itemIcon(i).isNull()) {
|
|
m_tqt3combobox_widget->insertItem(convertQt4ToTQt3String(qt4combobox_widget->itemText(i)), i);
|
|
}
|
|
else {
|
|
m_tqt3combobox_widget->insertItem(convertQt4ToTQt3Pixmap(qt4combobox_widget->itemIcon(i)), convertQt4ToTQt3String(qt4combobox_widget->itemText(i)), i);
|
|
}
|
|
}
|
|
m_tqt3combobox_widget->setEditable(qt4combobox_widget->isEditable());
|
|
break;
|
|
case TQT3WT_TQPopupMenu:
|
|
interfaceWidget = m_tqt3popupmenu_widget;
|
|
// Copy over all widget attributes
|
|
qt4menu_widget = static_cast<const QMenu*>(w);
|
|
m_tqt3popupmenu_widget->setGeometry(0, 0, qt4menu_widget->width(), qt4menu_widget->height());
|
|
// Clear out menu
|
|
m_tqt3popupmenu_widget->clear();
|
|
m_tqt3popupmenu_widget->setCheckable(false);
|
|
// Copy over all menu items
|
|
QList<QAction*> qt4menuactions = qt4menu_widget->actions();
|
|
QAction* currentAction = 0;
|
|
for (i=0; i<qt4menuactions.size();++i) {
|
|
currentAction = qt4menuactions.at(i);
|
|
if (currentAction) {
|
|
if (currentAction->isSeparator()) {
|
|
m_tqt3popupmenu_widget->insertSeparator(i);
|
|
}
|
|
else {
|
|
if (currentAction->icon().isNull()) {
|
|
m_tqt3popupmenu_widget->insertItem(convertQt4ToTQt3String(currentAction->text()), i, i);
|
|
}
|
|
else {
|
|
m_tqt3popupmenu_widget->insertItem(convertQt4ToTQt3IconSet(currentAction->icon()), convertQt4ToTQt3String(currentAction->text()), i, i);
|
|
}
|
|
// FIXME
|
|
// Handle pixmaps, etc.
|
|
}
|
|
m_tqt3popupmenu_widget->setItemEnabled(i, currentAction->isEnabled());
|
|
m_tqt3popupmenu_widget->setItemChecked(i, currentAction->isChecked());
|
|
m_tqt3popupmenu_widget->setItemVisible(i, currentAction->isVisible());
|
|
if (currentAction->isCheckable()) {
|
|
m_tqt3popupmenu_widget->setCheckable(true);
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
|
|
return interfaceWidget;
|
|
}
|
|
|
|
QRect SimpleStyle::subElementRect(SubElement element, const QStyleOption *opt, const QWidget *w) const
|
|
{
|
|
TQStyle::SFlags sflags = 0;
|
|
|
|
bool can_override = true;
|
|
TQStyle::SubRect tqtSR;
|
|
|
|
TQWidget* interfaceWidget = 0;
|
|
QRect retRect;
|
|
|
|
switch (element) {
|
|
case SE_ComboBoxFocusRect:
|
|
tqtSR = TQStyle::SR_ComboBoxFocusRect;
|
|
interfaceWidget = initializeInterfaceWidget(TQT3WT_TQComboBox, w);
|
|
if (interfaceWidget == 0) {
|
|
can_override = false;
|
|
}
|
|
break;
|
|
default:
|
|
#ifdef DEBUG_WARNINGS
|
|
printf("No rules to obtain Qt4 subelement rect %d\n\r", element); fflush(stdout);
|
|
#endif
|
|
can_override = false;
|
|
}
|
|
|
|
if (can_override) {
|
|
// Instruct TQt3 to obtain the subelement rect information
|
|
retRect = convertTQt3ToQt4Rect(tqApp->style().subRect(tqtSR, interfaceWidget));
|
|
|
|
#ifdef DEBUG_WARNINGS
|
|
#ifdef DEBUG_SPEW
|
|
printf("Used Qt3 subelement rect %d to handle Qt4 subelement rect %d\n\r", tqtSR, control); fflush(stdout);
|
|
#endif
|
|
#endif
|
|
}
|
|
else {
|
|
// Tell Qt4 to obtain the subelement rect information
|
|
retRect = QCommonStyle::subElementRect(element, opt, w);
|
|
}
|
|
|
|
return retRect;
|
|
}
|
|
|
|
void SimpleStyle::drawComplexControl(ComplexControl control, const QStyleOptionComplex *opt, QPainter *p, const QWidget *w) const
|
|
{
|
|
TQStyle::SFlags sflags = 0;
|
|
|
|
bool can_override = true;
|
|
TQStyle::ComplexControl tqtCC;
|
|
TQStyle::SCFlags subControl = TQStyle::SC_All;
|
|
TQStyle::SCFlags subControlActive = TQStyle::SC_None;
|
|
|
|
TQWidget* interfaceWidget = 0;
|
|
TQStyleOption tqt3opt(TQStyleOption::Default);
|
|
|
|
// Determine the correct color group
|
|
sflags = convertQt4ToTQt3SFlags(opt->state, TQT3WT_NONE);
|
|
TQPalette tqt3palette = convertQt4ToTQt3Palette(opt->palette);
|
|
TQColorGroup tqt3colorgroup;
|
|
if (sflags & TQStyle::Style_Enabled) {
|
|
if (sflags & TQStyle::Style_Active) {
|
|
tqt3colorgroup = tqt3palette.active();
|
|
}
|
|
else {
|
|
tqt3colorgroup = tqt3palette.inactive();
|
|
}
|
|
}
|
|
else {
|
|
tqt3colorgroup = tqt3palette.disabled();
|
|
}
|
|
|
|
switch (control) {
|
|
case CC_ComboBox:
|
|
tqtCC = TQStyle::CC_ComboBox;
|
|
interfaceWidget = initializeInterfaceWidget(TQT3WT_TQComboBox, w);
|
|
if (interfaceWidget == 0) {
|
|
can_override = false;
|
|
}
|
|
break;
|
|
default:
|
|
#ifdef DEBUG_WARNINGS
|
|
printf("No rules to draw Qt4 complex control %d\n\r", control); fflush(stdout);
|
|
#endif
|
|
can_override = false;
|
|
}
|
|
|
|
if (can_override) {
|
|
// Construct a Qt3 paint device on the Qt4 painter
|
|
TDEQt4PaintDevice qt4pd(p);
|
|
|
|
TQPainter tqtPainter(&qt4pd);
|
|
|
|
// Instruct TQt3 to draw the complex control
|
|
tqApp->style().drawComplexControl(tqtCC, &tqtPainter, interfaceWidget, TQRect(opt->rect.x(), opt->rect.y(), opt->rect.width(), opt->rect.height()), tqt3colorgroup, sflags, subControl, subControlActive, tqt3opt);
|
|
|
|
tqtPainter.end();
|
|
|
|
#ifdef DEBUG_WARNINGS
|
|
#ifdef DEBUG_SPEW
|
|
printf("Used Qt3 complex control %d to draw Qt4 complex control %d\n\r", tqtCE, control); fflush(stdout);
|
|
#endif
|
|
#endif
|
|
}
|
|
else {
|
|
// Tell Qt4 to draw it
|
|
QCommonStyle::drawComplexControl(control, opt, p, w);
|
|
}
|
|
}
|
|
|
|
void SimpleStyle::drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w) const
|
|
{
|
|
int i;
|
|
TQStyle::SFlags sflags = 0;
|
|
|
|
bool can_override = true;
|
|
TQStyle::ControlElement tqtCE;
|
|
|
|
bool draw_second_element = false;
|
|
TQStyle::ControlElement tqtCE_element2;
|
|
|
|
bool draw_third_element = false;
|
|
TQStyle::ControlElement tqtCE_element3;
|
|
|
|
TQWidget* interfaceWidget = 0;
|
|
TQStyleOption tqt3opt(TQStyleOption::Default);
|
|
TQStyleOption tqt3opt_element2(TQStyleOption::Default);
|
|
TQStyleOption tqt3opt_element3(TQStyleOption::Default);
|
|
|
|
TQTab* drawingTab = 0;
|
|
int estimated_tab_index;
|
|
|
|
TQMenuItem* drawingItem = 0;
|
|
QAction* drawingAction = 0;
|
|
QList<QAction*> qt4menuactions;
|
|
int tqt3tabwidth = 0;
|
|
int tqt3iconwidth = 0;
|
|
|
|
TQRect tqt3elementrect(opt->rect.x(), opt->rect.y(), opt->rect.width(), opt->rect.height());
|
|
TQRect tqt3element2rect = tqt3elementrect;
|
|
TQRect tqt3element3rect = tqt3elementrect;
|
|
|
|
// Determine the correct color group
|
|
sflags = convertQt4ToTQt3SFlags(opt->state, TQT3WT_NONE);
|
|
TQPalette tqt3palette = convertQt4ToTQt3Palette(opt->palette);
|
|
TQColorGroup tqt3colorgroup;
|
|
if (sflags & TQStyle::Style_Enabled) {
|
|
if (sflags & TQStyle::Style_Active) {
|
|
tqt3colorgroup = tqt3palette.active();
|
|
}
|
|
else {
|
|
tqt3colorgroup = tqt3palette.inactive();
|
|
}
|
|
}
|
|
else {
|
|
tqt3colorgroup = tqt3palette.disabled();
|
|
}
|
|
|
|
switch (element) {
|
|
case QStyle::CE_ProgressBar:
|
|
// Unlike Qt3, QStyle::CE_ProgressBar draws the bar, the groove, and the label
|
|
tqtCE = TQStyle::CE_ProgressBarContents;
|
|
draw_second_element = true;
|
|
tqtCE_element2 = TQStyle::CE_ProgressBarGroove;
|
|
draw_third_element = true;
|
|
tqtCE_element3 = TQStyle::CE_ProgressBarLabel;
|
|
sflags = convertQt4ToTQt3SFlags(opt->state, TQT3WT_TQProgressBar);
|
|
interfaceWidget = initializeInterfaceWidget(TQT3WT_TQProgressBar, w);
|
|
if (interfaceWidget == 0) {
|
|
can_override = false;
|
|
}
|
|
break;
|
|
case QStyle::CE_ProgressBarContents:
|
|
tqtCE = TQStyle::CE_ProgressBarContents;
|
|
sflags = convertQt4ToTQt3SFlags(opt->state, TQT3WT_TQProgressBar);
|
|
interfaceWidget = initializeInterfaceWidget(TQT3WT_TQProgressBar, w);
|
|
if (interfaceWidget == 0) {
|
|
can_override = false;
|
|
}
|
|
break;
|
|
case QStyle::CE_TabBarTab:
|
|
// Unlike Qt3, QStyle::CE_TabBarTab draws both the tab and the label
|
|
tqtCE = TQStyle::CE_TabBarTab;
|
|
draw_second_element = true;
|
|
tqtCE_element2 = TQStyle::CE_TabBarLabel;
|
|
sflags = convertQt4ToTQt3SFlags(opt->state, TQT3WT_TQTabBar);
|
|
interfaceWidget = initializeInterfaceWidget(TQT3WT_TQTabBar, w);
|
|
if (interfaceWidget == 0) {
|
|
can_override = false;
|
|
}
|
|
else {
|
|
// Convert the QStyleOption to the proper TQStyleOption
|
|
// In other words, figure out which TQt3 tab is currently being drawn
|
|
// Qt4 makes this really, really hard...
|
|
// I have to guess based on the Qt4 position of the tab in the tab bar, which may or may not work 100% in all cases
|
|
drawingTab = 0;
|
|
estimated_tab_index = static_cast<const QTabBar*>(w)->tabAt(QPoint(opt->rect.x(), opt->rect.y()));
|
|
drawingTab = m_tqt3tabbar_widget->tabAt(estimated_tab_index);
|
|
|
|
if (drawingTab) {
|
|
tqt3opt = TQStyleOption(drawingTab);
|
|
tqt3opt_element2 = TQStyleOption(drawingTab);
|
|
}
|
|
|
|
// HACK
|
|
// Qt4 is BUSTED YET AGAIN
|
|
// Grrrrr....
|
|
// The PM_TabBarTabOverlap enum is present, BUT IS NOT IMPLEMENTED, in Qt4 (!??!?)
|
|
// Many TDE styles use overlapping tabs, and expect to draw outside their horizontal boundaries by PM_TabBarTabOverlap pixels
|
|
// At the very least we need to expand the drawing rect by that amount, even if the drawing gets clipped, otherwise
|
|
// those styles will show badly broken tabs with missing chunks and added lines.
|
|
tqt3tabwidth = tqApp->style().pixelMetric(TQStyle::PM_TabBarTabOverlap, interfaceWidget);
|
|
if (tqt3tabwidth > 0) {
|
|
tqt3elementrect = TQRect(tqt3elementrect.x()-tqt3tabwidth, tqt3elementrect.y(), tqt3elementrect.width()+(tqt3tabwidth*1), tqt3elementrect.height());
|
|
}
|
|
}
|
|
break;
|
|
#if 0
|
|
case CE_RadioButton:
|
|
// Unlike Qt3, QStyle::CE_RadioButton draws the button, the label, and the focus rectangle
|
|
tqtCE = TQStyle::CE_RadioButton;
|
|
draw_second_element = true;
|
|
tqtCE_element2 = TQStyle::CE_RadioButtonLabel;
|
|
sflags = convertQt4ToTQt3SFlags(opt->state, TQT3WT_TQRadioButton);
|
|
interfaceWidget = initializeInterfaceWidget(TQT3WT_TQRadioButton, w);
|
|
if (interfaceWidget == 0) {
|
|
can_override = false;
|
|
}
|
|
break;
|
|
#endif
|
|
case CE_MenuItem:
|
|
tqtCE = TQStyle::CE_PopupMenuItem;
|
|
sflags = convertQt4ToTQt3SFlags(opt->state, TQT3WT_TQPopupMenu);
|
|
interfaceWidget = initializeInterfaceWidget(TQT3WT_TQPopupMenu, w);
|
|
if (interfaceWidget == 0) {
|
|
can_override = false;
|
|
}
|
|
else {
|
|
// Convert the QStyleOption to the proper TQStyleOption
|
|
// In other words, figure out which TQt3 menu item is currently being drawn
|
|
// Qt4 makes this really, really hard...
|
|
// I have to guess based on the Qt4 position of the item in the menu, which may or may not work 100% in all cases
|
|
drawingItem = 0;
|
|
drawingAction = static_cast<const QMenu*>(w)->actionAt(QPoint(opt->rect.x(), opt->rect.y()));
|
|
qt4menuactions = static_cast<const QMenu*>(w)->actions();
|
|
for (i=0; i<qt4menuactions.size();++i) {
|
|
if (qt4menuactions.at(i) == drawingAction) {
|
|
drawingItem = m_tqt3popupmenu_widget->findItem(m_tqt3popupmenu_widget->idAt(i));
|
|
}
|
|
}
|
|
|
|
if (drawingItem) {
|
|
tqt3tabwidth = static_cast<const QStyleOptionMenuItem*>(opt)->tabWidth;
|
|
tqt3iconwidth = static_cast<const QStyleOptionMenuItem*>(opt)->maxIconWidth;
|
|
tqt3opt = TQStyleOption(drawingItem, tqt3iconwidth, tqt3tabwidth);
|
|
}
|
|
}
|
|
break;
|
|
case QStyle::CE_TabBarTabShape:
|
|
// Ignore request as Qt3 has no equivalent
|
|
can_override = false;
|
|
break;
|
|
default:
|
|
#ifdef DEBUG_WARNINGS
|
|
printf("No rules to draw Qt4 control %d\n\r", element); fflush(stdout);
|
|
#endif
|
|
can_override = false;
|
|
}
|
|
|
|
if (can_override) {
|
|
// Construct a Qt3 paint device on the Qt4 painter
|
|
TDEQt4PaintDevice qt4pd(p);
|
|
|
|
TQPainter tqtPainter(&qt4pd);
|
|
|
|
// Instruct TQt3 to draw the control
|
|
// FIXME
|
|
// Implement sflags and QStyleOption
|
|
tqApp->style().drawControl(tqtCE, &tqtPainter, interfaceWidget, tqt3elementrect, tqt3colorgroup, sflags, tqt3opt);
|
|
if (draw_second_element == true) {
|
|
tqApp->style().drawControl(tqtCE_element2, &tqtPainter, interfaceWidget, tqt3element2rect, tqt3colorgroup, sflags, tqt3opt_element2);
|
|
}
|
|
if (draw_third_element == true) {
|
|
tqApp->style().drawControl(tqtCE_element3, &tqtPainter, interfaceWidget, tqt3element3rect, tqt3colorgroup, sflags, tqt3opt_element3);
|
|
}
|
|
|
|
tqtPainter.end();
|
|
|
|
#ifdef DEBUG_WARNINGS
|
|
#ifdef DEBUG_SPEW
|
|
printf("Used Qt3 control %d to draw Qt4 control %d\n\r", tqtCE, element); fflush(stdout);
|
|
#endif
|
|
#endif
|
|
}
|
|
else {
|
|
// Tell Qt4 to draw it
|
|
QCommonStyle::drawControl(element, opt, p, w);
|
|
}
|
|
}
|
|
|
|
#define NO_QT3_EQUIVALENT can_override = false;
|
|
|
|
void SimpleStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w) const
|
|
{
|
|
// Construct a Qt3 paint device translator on the Qt4 painter
|
|
TDEQt4PaintDevice qt4pd(p);
|
|
|
|
// Open a painter on the paint device translator
|
|
TQPainter tqtPainter(&qt4pd);
|
|
|
|
bool can_override = true;
|
|
TQStyle::PrimitiveElement tqtPE;
|
|
TQStyleOption tqt3opt(TQStyleOption::Default);
|
|
|
|
// NOTE: Qt3 seems to combine PE_FrameMenu and PE_PanelMenu into PE_PanelPopup
|
|
|
|
switch (pe) {
|
|
case QStyle::PE_Frame:
|
|
tqtPE = TQStyle::PE_Panel;
|
|
tqt3opt = TQStyleOption(static_cast<const QStyleOptionFrame*>(opt)->lineWidth, static_cast<const QStyleOptionFrame*>(opt)->midLineWidth);
|
|
break;
|
|
case QStyle::PE_FrameMenu:
|
|
tqtPE = TQStyle::PE_PanelPopup;
|
|
tqt3opt = TQStyleOption(static_cast<const QStyleOptionFrame*>(opt)->lineWidth, static_cast<const QStyleOptionFrame*>(opt)->midLineWidth);
|
|
break;
|
|
case QStyle::PE_PanelButtonBevel:
|
|
tqtPE = TQStyle::PE_ButtonBevel;
|
|
break;
|
|
case QStyle::PE_FrameGroupBox:
|
|
tqtPE = TQStyle::PE_GroupBoxFrame;
|
|
tqt3opt = TQStyleOption(static_cast<const QStyleOptionFrame*>(opt)->lineWidth, static_cast<const QStyleOptionFrame*>(opt)->midLineWidth);
|
|
break;
|
|
case QStyle::PE_FrameFocusRect:
|
|
tqtPE = TQStyle::PE_FocusRect;
|
|
break;
|
|
case QStyle::PE_FrameButtonTool:
|
|
tqtPE = TQStyle::PE_ButtonTool;
|
|
break;
|
|
case QStyle::PE_FrameTabBarBase:
|
|
NO_QT3_EQUIVALENT
|
|
break;
|
|
case QStyle::PE_FrameTabWidget:
|
|
tqtPE = TQStyle::PE_PanelTabWidget;
|
|
break;
|
|
case QStyle::PE_PanelButtonCommand:
|
|
tqtPE = TQStyle::PE_ButtonCommand;
|
|
break;
|
|
case QStyle::PE_IndicatorProgressChunk:
|
|
tqtPE = TQStyle::PE_ProgressBarChunk;
|
|
break;
|
|
case QStyle::PE_IndicatorArrowDown:
|
|
tqtPE = TQStyle::PE_ArrowDown;
|
|
break;
|
|
case QStyle::PE_IndicatorArrowLeft:
|
|
tqtPE = TQStyle::PE_ArrowLeft;
|
|
break;
|
|
case QStyle::PE_IndicatorArrowRight:
|
|
tqtPE = TQStyle::PE_ArrowRight;
|
|
break;
|
|
case QStyle::PE_IndicatorArrowUp:
|
|
tqtPE = TQStyle::PE_ArrowUp;
|
|
break;
|
|
case QStyle::PE_IndicatorCheckBox:
|
|
tqtPE = TQStyle::PE_Indicator;
|
|
break;
|
|
case QStyle::PE_IndicatorRadioButton:
|
|
tqtPE = TQStyle::PE_ExclusiveIndicator;
|
|
break;
|
|
case QStyle::PE_PanelMenu:
|
|
tqtPE = TQStyle::PE_PanelPopup;
|
|
break;
|
|
case QStyle::PE_PanelButtonTool:
|
|
tqtPE = TQStyle::PE_ButtonTool;
|
|
break;
|
|
case QStyle::PE_IndicatorTabTear:
|
|
NO_QT3_EQUIVALENT
|
|
break;
|
|
default:
|
|
#ifdef DEBUG_WARNINGS
|
|
printf("No rules to draw Qt4 element %d\n\r", pe); fflush(stdout);
|
|
#endif
|
|
can_override = false;
|
|
}
|
|
|
|
// Convert the style flags
|
|
TQStyle::SFlags sflags = convertQt4ToTQt3SFlags(opt->state, TQT3WT_NONE);
|
|
|
|
// Determine the correct color group
|
|
TQPalette tqt3palette = convertQt4ToTQt3Palette(opt->palette);
|
|
TQColorGroup tqt3colorgroup;
|
|
if (sflags & TQStyle::Style_Enabled) {
|
|
if (sflags & TQStyle::Style_Active) {
|
|
tqt3colorgroup = tqt3palette.active();
|
|
}
|
|
else {
|
|
tqt3colorgroup = tqt3palette.inactive();
|
|
}
|
|
}
|
|
else {
|
|
tqt3colorgroup = tqt3palette.disabled();
|
|
}
|
|
|
|
|
|
if (can_override) {
|
|
// Construct a Qt3 paint device on the Qt4 painter
|
|
TDEQt4PaintDevice qt4pd(p);
|
|
|
|
TQPainter tqtPainter(&qt4pd);
|
|
|
|
// Instruct TQt3 to draw the primitive
|
|
tqApp->style().drawPrimitive(tqtPE, &tqtPainter, TQRect(opt->rect.x(), opt->rect.y(), opt->rect.width(), opt->rect.height()), tqt3colorgroup, sflags, tqt3opt);
|
|
tqtPainter.end();
|
|
|
|
#ifdef DEBUG_WARNINGS
|
|
#ifdef DEBUG_SPEW
|
|
printf("Used Qt3 element %d to draw Qt4 element %d\n\r", tqtPE, pe); fflush(stdout);
|
|
#endif
|
|
#endif
|
|
}
|
|
else {
|
|
// Tell Qt4 to draw it
|
|
QCommonStyle::drawPrimitive(pe, opt, p, w);
|
|
}
|
|
}
|