summaryrefslogtreecommitdiffstats
path: root/tdehtml/java/kjavaappletwidget.cpp
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-01-26 13:17:21 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-01-26 13:17:21 -0600
commitdfe289850f068f19ba4a83ab4e7e22a7e09c13c9 (patch)
treec297348a55df66c571de4525646e0b9762427353 /tdehtml/java/kjavaappletwidget.cpp
parentb7658a0d5eca24a9d37c6e04f88298ef02389db0 (diff)
downloadtdelibs-dfe289850f068f19ba4a83ab4e7e22a7e09c13c9.tar.gz
tdelibs-dfe289850f068f19ba4a83ab4e7e22a7e09c13c9.zip
Rename a number of libraries and executables to avoid conflicts with KDE4
Diffstat (limited to 'tdehtml/java/kjavaappletwidget.cpp')
-rw-r--r--tdehtml/java/kjavaappletwidget.cpp140
1 files changed, 140 insertions, 0 deletions
diff --git a/tdehtml/java/kjavaappletwidget.cpp b/tdehtml/java/kjavaappletwidget.cpp
new file mode 100644
index 000000000..c096261cd
--- /dev/null
+++ b/tdehtml/java/kjavaappletwidget.cpp
@@ -0,0 +1,140 @@
+/* This file is part of the KDE project
+ *
+ * Copyright (C) 2000 Richard Moore <rich@kde.org>
+ * 2000 Wynn Wilkes <wynnw@caldera.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "kjavaappletwidget.h"
+#include "kjavaappletserver.h"
+
+#include <twin.h>
+#include <kdebug.h>
+#include <klocale.h>
+
+#include <tqlabel.h>
+
+
+// For future expansion
+class KJavaAppletWidgetPrivate
+{
+friend class KJavaAppletWidget;
+private:
+ TQLabel* tmplabel;
+};
+
+int KJavaAppletWidget::appletCount = 0;
+
+KJavaAppletWidget::KJavaAppletWidget( TQWidget* parent, const char* name )
+ : QXEmbed ( parent, name)
+{
+ setProtocol(QXEmbed::XPLAIN);
+
+ m_applet = new KJavaApplet( this );
+ d = new KJavaAppletWidgetPrivate;
+ m_kwm = new KWinModule( TQT_TQOBJECT(this) );
+
+ d->tmplabel = new TQLabel( this );
+ d->tmplabel->setText( KJavaAppletServer::getAppletLabel() );
+ d->tmplabel->setAlignment( Qt::AlignCenter | TQt::WordBreak );
+ d->tmplabel->setFrameStyle( TQFrame::StyledPanel | TQFrame::Sunken );
+ d->tmplabel->show();
+
+ m_swallowTitle.sprintf( "KJAS Applet - Ticket number %u", appletCount++ );
+ m_applet->setWindowName( m_swallowTitle );
+}
+
+KJavaAppletWidget::~KJavaAppletWidget()
+{
+ delete m_applet;
+ delete d;
+}
+
+void KJavaAppletWidget::showApplet()
+{
+ connect( m_kwm, TQT_SIGNAL( windowAdded( WId ) ),
+ this, TQT_SLOT( setWindow( WId ) ) );
+
+ m_kwm->doNotManage( m_swallowTitle );
+
+ //Now we send applet info to the applet server
+ if ( !m_applet->isCreated() )
+ m_applet->create();
+}
+
+void KJavaAppletWidget::setWindow( WId w )
+{
+ //make sure that this window has the right name, if so, embed it...
+ KWin::WindowInfo w_info = KWin::windowInfo( w );
+ if ( m_swallowTitle == w_info.name() ||
+ m_swallowTitle == w_info.visibleName() )
+ {
+ kdDebug(6100) << "swallowing our window: " << m_swallowTitle
+ << ", window id = " << w << endl;
+ delete d->tmplabel;
+ d->tmplabel = 0;
+
+ // disconnect from KWM events
+ disconnect( m_kwm, TQT_SIGNAL( windowAdded( WId ) ),
+ this, TQT_SLOT( setWindow( WId ) ) );
+
+
+ embed( w );
+ setFocus();
+ }
+}
+
+TQSize KJavaAppletWidget::sizeHint() const
+{
+ kdDebug(6100) << "KJavaAppletWidget::sizeHint()" << endl;
+ TQSize rval = QXEmbed::sizeHint();
+
+ if( rval.width() == 0 || rval.height() == 0 )
+ {
+ if( width() != 0 && height() != 0 )
+ {
+ rval = TQSize( width(), height() );
+ }
+ }
+
+ kdDebug(6100) << "returning: (" << rval.width() << ", " << rval.height() << ")" << endl;
+
+ return rval;
+}
+
+void KJavaAppletWidget::resize( int w, int h )
+{
+ if( d->tmplabel )
+ {
+ d->tmplabel->resize( w, h );
+ m_applet->setSize( TQSize( w, h ) );
+ }
+
+ QXEmbed::resize( w, h );
+}
+
+void KJavaAppletWidget::showEvent (TQShowEvent * e) {
+ QXEmbed::showEvent(e);
+ if (!applet()->isCreated() && !applet()->appletClass().isEmpty()) {
+ // delayed showApplet
+ if (applet()->size().width() <= 0)
+ applet()->setSize (sizeHint());
+ showApplet();
+ }
+}
+
+#include "kjavaappletwidget.moc"