author | sandman <sandman> | 2002-11-22 21:57:47 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-11-22 21:57:47 (UTC) |
commit | a71b9d79a05ab2b6bc891afe4df4d5fdcf641550 (patch) (side-by-side diff) | |
tree | 12852a47649207eb46b6bd6f7d41ab2fc2156259 | |
parent | 0f9ce3f60b6fbd350f79485ee8fc5fe37be692e1 (diff) | |
download | opie-a71b9d79a05ab2b6bc891afe4df4d5fdcf641550.zip opie-a71b9d79a05ab2b6bc891afe4df4d5fdcf641550.tar.gz opie-a71b9d79a05ab2b6bc891afe4df4d5fdcf641550.tar.bz2 |
Added some code for backward compatibility .. this enabled tkc apps with
custom window decoration to work on Opie (the X and OK button have a 1
pixel offset though, but I can't do anything about it)
-rw-r--r-- | library/qpedecoration_qws.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/library/qpedecoration_qws.cpp b/library/qpedecoration_qws.cpp index 9cbe92b..6221f5b 100644 --- a/library/qpedecoration_qws.cpp +++ b/library/qpedecoration_qws.cpp @@ -411,192 +411,197 @@ void WindowDecorationInterface::drawArea( Area a, QPainter *p, const WindowData r.width()-metric(OKWidth,wd)-metric(CloseWidth,wd), th, QPainter::AlignVCenter, wd->caption); break; } } void WindowDecorationInterface::drawButton( Button b, QPainter *p, const WindowData *wd, int x, int y, int, int, QWSButton::State state ) const { QImage *img = 0; switch ( b ) { case OK: img = okImage(metric(TitleHeight,wd)); break; case Close: img = closeImage(metric(TitleHeight,wd)); break; case Help: img = helpImage(metric(TitleHeight,wd)); break; case Maximize: img = maximizeImage(metric(TitleHeight,wd)); break; } if ( img ) { if ((state & QWSButton::MouseOver) && (state & QWSButton::Clicked)) p->drawImage(x+2, y+2, *img); else p->drawImage(x+1, y+1, *img); } } QRegion WindowDecorationInterface::mask( const WindowData *wd ) const { int th = metric(TitleHeight,wd); QRect rect( wd->rect ); QRect r(rect.left() - metric(LeftBorder,wd), rect.top() - th - metric(TopBorder,wd), rect.width() + metric(LeftBorder,wd) + metric(RightBorder,wd), rect.height() + th + metric(TopBorder,wd) + metric(BottomBorder,wd)); return QRegion(r) - rect; } class DefaultWindowDecoration : public WindowDecorationInterface { public: DefaultWindowDecoration() : ref(0) {} QString name() const { return "Default"; } QPixmap icon() const { return QPixmap(); } QRESULT queryInterface( const QUuid &uuid, QUnknownInterface **iface ) { *iface = 0; if ( uuid == IID_QUnknown ) *iface = this; else if ( uuid == IID_WindowDecoration ) *iface = this; if ( *iface ) (*iface)->addRef(); return QS_OK; } Q_REFCOUNT private: ulong ref; }; static WindowDecorationInterface *wdiface = 0; static QLibrary *wdlib = 0; //=========================================================================== QPEDecoration::QPEDecoration() : QWSDefaultDecoration() { if ( wdlib ) { wdiface->release(); wdlib->unload(); delete wdlib; wdlib = 0; } else { delete wdiface; } wdiface = new DefaultWindowDecoration; helpFile = QString(qApp->argv()[0]) + ".html"; QStringList helpPath = Global::helpPath(); helpExists = FALSE; for (QStringList::ConstIterator it=helpPath.begin(); it!=helpPath.end() && !helpExists; ++it) { helpExists = QFile::exists( *it + "/" + helpFile ); qDebug ( "Checking %s/%s for help: %d", (*it).latin1(), helpFile.latin1(),helpExists); } qpeManager = new QPEManager( this ); + + // for backward compatibility: + imageOk = *okImage ( 15 ); + imageClose = *closeImage ( 15 ); + imageHelp = *helpImage ( 15 ); } QPEDecoration::QPEDecoration( const QString &plugin ) : QWSDefaultDecoration() { if ( wdlib ) { wdiface->release(); wdlib->unload(); delete wdlib; wdlib = 0; } else { delete wdiface; } WindowDecorationInterface *iface = 0; QString path = QPEApplication::qpeDir() + "/plugins/decorations"; QLibrary *lib = new QLibrary( path + "/" + plugin ); if ( lib->queryInterface( IID_WindowDecoration, (QUnknownInterface**)&iface ) == QS_OK && iface ) { wdiface = iface; wdlib = lib; } else { delete lib; wdiface = new DefaultWindowDecoration; } helpFile = QString(qApp->argv()[0]) + ".html"; QStringList helpPath = Global::helpPath(); helpExists = FALSE; for (QStringList::ConstIterator it=helpPath.begin(); it!=helpPath.end() && !helpExists; ++it) { helpExists = QFile::exists( *it + "/" + helpFile ); qDebug ( "Checking %s/%s for help: %d", (*it).latin1(), helpFile.latin1(),helpExists); } qpeManager = new QPEManager( this ); } QPEDecoration::~QPEDecoration() { delete qpeManager; } const char **QPEDecoration::menuPixmap() { return (const char **)0; } const char **QPEDecoration::closePixmap() { return (const char **)qpe_close_xpm; } const char **QPEDecoration::minimizePixmap() { return (const char **)qpe_accept_xpm; } const char **QPEDecoration::maximizePixmap() { return (const char **)0; } const char **QPEDecoration::normalizePixmap() { return (const char **)0; } int QPEDecoration::getTitleHeight( const QWidget *w ) { WindowDecorationInterface::WindowData wd; windowData( w, wd ); return wdiface->metric(WindowDecorationInterface::TitleHeight,&wd); } /* If rect is empty, no frame is added. (a hack, really) */ QRegion QPEDecoration::region(const QWidget *widget, const QRect &rect, QWSDecoration::Region type) { qpeManager->updateActive(); WindowDecorationInterface::WindowData wd; windowData( widget, wd ); wd.rect = rect; int titleHeight = wdiface->metric(WindowDecorationInterface::TitleHeight,&wd); int okWidth = wdiface->metric(WindowDecorationInterface::OKWidth,&wd); int closeWidth = wdiface->metric(WindowDecorationInterface::CloseWidth,&wd); int helpWidth = wdiface->metric(WindowDecorationInterface::HelpWidth,&wd); int grab = wdiface->metric(WindowDecorationInterface::CornerGrabSize,&wd); QRegion region; switch ((int)type) { case Menu: break; case Maximize: if ( !widget->inherits( "QDialog" ) && qApp->desktop()->width() > 350 ) { int maximizeWidth = wdiface->metric(WindowDecorationInterface::MaximizeWidth,&wd); int left = rect.right() - maximizeWidth - closeWidth; |