summaryrefslogtreecommitdiffstats
path: root/tdemdi/test
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 /tdemdi/test
parentb7658a0d5eca24a9d37c6e04f88298ef02389db0 (diff)
downloadtdelibs-dfe289850f068f19ba4a83ab4e7e22a7e09c13c9.tar.gz
tdelibs-dfe289850f068f19ba4a83ab4e7e22a7e09c13c9.zip
Rename a number of libraries and executables to avoid conflicts with KDE4
Diffstat (limited to 'tdemdi/test')
-rw-r--r--tdemdi/test/Makefile.am10
-rw-r--r--tdemdi/test/README16
-rw-r--r--tdemdi/test/hello.cpp104
-rw-r--r--tdemdi/test/hello.h38
-rw-r--r--tdemdi/test/main.cpp103
-rw-r--r--tdemdi/test/mainwidget.cpp147
-rw-r--r--tdemdi/test/mainwidget.h71
7 files changed, 489 insertions, 0 deletions
diff --git a/tdemdi/test/Makefile.am b/tdemdi/test/Makefile.am
new file mode 100644
index 000000000..4a5b21458
--- /dev/null
+++ b/tdemdi/test/Makefile.am
@@ -0,0 +1,10 @@
+check_PROGRAMS = kfourchildren
+METASOURCES = AUTO
+
+INCLUDES = -I$(top_srcdir)/tdemdi -I.. $(all_includes)
+
+kfourchildren_SOURCES = hello.cpp main.cpp mainwidget.cpp
+kfourchildren_LDFLAGS = -no-undefined $(all_libraries)
+kfourchildren_LDADD = $(top_builddir)/tdemdi/libtdemdi.la \
+ $(top_builddir)/tdeutils/libtdeutils.la
+
diff --git a/tdemdi/test/README b/tdemdi/test/README
new file mode 100644
index 000000000..cf3902083
--- /dev/null
+++ b/tdemdi/test/README
@@ -0,0 +1,16 @@
+This example shows the use of KMdi.
+Either you inherit your views from KMdiChildView or you wrap your common widgets by KMdiChildViews.
+Your main widget must inherit from KMdiMainFrm.
+
+
+
+Call
+ qmake kFourChildren -o Makefile
+ make
+to build the example app.
+Likely you must set the environment variable TDEDIR (to e.g. /opt/trinity).
+
+
+
+Find more details on:
+ http://www.geocities.com/gigafalk/qextmdi.htm
diff --git a/tdemdi/test/hello.cpp b/tdemdi/test/hello.cpp
new file mode 100644
index 000000000..d92233ea6
--- /dev/null
+++ b/tdemdi/test/hello.cpp
@@ -0,0 +1,104 @@
+/****************************************************************************
+** $Id$
+**
+** Copyright (C) 1992-1999 Troll Tech AS. All rights reserved.
+**
+** This file is part of an example program for Qt. This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+
+#include "hello.h"
+#include <tqpushbutton.h>
+#include <tqtimer.h>
+#include <tqpainter.h>
+#include <tqpixmap.h>
+
+/*
+ Constructs a Hello widget. Starts a 40 ms animation timer.
+*/
+
+Hello::Hello( const char *title, const char *text, TQWidget *parentWidget )
+ : KMdiChildView(title, parentWidget), t(text), b(0)
+{
+ TQTimer *timer = new TQTimer(this);
+ TQObject::connect( timer, TQT_SIGNAL(timeout()), TQT_SLOT(animate()) );
+ timer->start( 40 );
+
+ resize( 260, 130 );
+}
+
+
+/*
+ This private slot is called each time the timer fires.
+*/
+
+void Hello::animate()
+{
+ b = (b + 1) & 15;
+ repaint( false );
+}
+
+
+/*
+ Handles mouse button release events for the Hello widget.
+
+ We emit the clicked() signal when the mouse is released inside
+ the widget.
+*/
+
+void Hello::mouseReleaseEvent( TQMouseEvent *e )
+{
+ if ( rect().contains( e->pos() ) )
+ emit clicked();
+}
+
+
+/*
+ Handles paint events for the Hello widget.
+
+ Flicker-free update. The text is first drawn in the pixmap and the
+ pixmap is then blt'ed to the screen.
+*/
+
+void Hello::paintEvent( TQPaintEvent * )
+{
+ static int sin_tbl[16] = {
+ 0, 38, 71, 92, 100, 92, 71, 38, 0, -38, -71, -92, -100, -92, -71, -38};
+
+ if ( t.isEmpty() )
+ return;
+
+ // 1: Compute some sizes, positions etc.
+ TQFontMetrics fm = fontMetrics();
+ int w = fm.width(t) + 20;
+ int h = fm.height() * 2;
+ int pmx = width()/2 - w/2;
+ int pmy = height()/2 - h/2;
+
+ // 2: Create the pixmap and fill it with the widget's background
+ TQPixmap pm( w, h );
+ pm.fill( this, pmx, pmy );
+
+ // 3: Paint the pixmap. Cool wave effect
+ TQPainter p;
+ int x = 10;
+ int y = h/2 + fm.descent();
+ int i = 0;
+ p.begin( &pm );
+ p.setFont( font() );
+ while ( !t[i].isNull() ) {
+ int i16 = (b+i) & 15;
+ p.setPen( TQColor((15-i16)*16,255,255,TQColor::Hsv) );
+ p.drawText( x, y-sin_tbl[i16]*h/800, t.mid(i,1), 1 );
+ x += fm.width( t[i] );
+ i++;
+ }
+ p.end();
+
+ // 4: Copy the pixmap to the Hello widget
+ bitBlt( this, pmx, pmy, &pm );
+}
+
+#include "hello.moc"
+
diff --git a/tdemdi/test/hello.h b/tdemdi/test/hello.h
new file mode 100644
index 000000000..b6ce589a0
--- /dev/null
+++ b/tdemdi/test/hello.h
@@ -0,0 +1,38 @@
+/****************************************************************************
+** $Id$
+**
+** Copyright (C) 1992-1999 Troll Tech AS. All rights reserved.
+**
+** This file is part of an example program for Qt. This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+
+#ifndef HELLO_H
+#define HELLO_H
+
+#include <tqstring.h>
+#include <tdemdichildview.h>
+
+class TQWidget;
+class TQMouseEvent;
+class TQPaintEvent;
+
+class Hello : public KMdiChildView
+{
+ Q_OBJECT
+public:
+ Hello( const char *title, const char *text, TQWidget* parentWidget = 0 );
+signals:
+ void clicked();
+protected:
+ void mouseReleaseEvent( TQMouseEvent * );
+ void paintEvent( TQPaintEvent * );
+private slots:
+ void animate();
+private:
+ TQString t;
+ int b;
+};
+
+#endif
diff --git a/tdemdi/test/main.cpp b/tdemdi/test/main.cpp
new file mode 100644
index 000000000..4f14a410c
--- /dev/null
+++ b/tdemdi/test/main.cpp
@@ -0,0 +1,103 @@
+//----------------------------------------------------------------------------
+// filename : main.cpp
+//----------------------------------------------------------------------------
+// Project : Qt MDI extension
+//
+// begin : 07/1999 by Szymon Stefanek as part of kvirc
+// (an IRC application)
+// changes : 09/1999 by Falk Brettschneider to create an
+// stand-alone Qt extension set of
+// classes and a Qt-based library
+// 02/2000 by Massimo Morin (mmorin@schedsys.com)
+//
+// copyright : (C) 1999-2000 by Szymon Stefanek (stefanek@tin.it)
+// and
+// Falk Brettschneider
+// email : falkbr@tdevelop.org (Falk Brettschneider)
+//----------------------------------------------------------------------------
+//
+//----------------------------------------------------------------------------
+//
+// This program 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.
+//
+//----------------------------------------------------------------------------
+
+#ifndef NO_KDE
+# include <kapplication.h>
+ TDEApplication* theApp;
+#else
+# include <tqapplication.h>
+ TQApplication* theApp;
+#endif
+
+//#include <iostream.h>
+#include "mainwidget.h"
+#include "hello.h"
+
+#define SHOW(v) cout << #v << " -> " << v << endl;
+
+int main( int argc, char **argv )
+{
+#ifndef NO_KDE
+ TDEApplication a(argc,argv,"KFourChildren");
+#else
+ TQApplication a(argc,argv);
+#endif
+ theApp = &a;
+
+ RestartWidget* restartWidget = new RestartWidget;
+ MainWidget* mainWdg = new MainWidget(restartWidget->dockConfig,restartWidget->mdimode);
+ restartWidget->setWindow(mainWdg);
+
+ Hello* h1 = new Hello( "Hello1", "Click the right mouse button on the mainframe!", mainWdg);
+ h1->setTabCaption("Tab changed");
+ h1->setBackgroundColor( Qt::white );
+ mainWdg->addWindow( h1);
+// SHOW(h1->caption());
+// SHOW(h1->tabCaption());
+
+ TQWidget* w = new TQWidget(mainWdg);
+ KMdiChildView* h2 = mainWdg->createWrapper(w, "I'm a common but wrapped QWidget!", "Hello2");
+ mainWdg->addWindow( h2 );
+// SHOW(h2->caption());
+// SHOW(h2->tabCaption());
+
+ Hello* h3 = new Hello( "Hello3", "Dock me using the taskbar button context menu!", 0);
+ h3->setBackgroundColor( Qt::white );
+ h3->setFont( TQFont("times",20,TQFont::Bold) );
+ mainWdg->addWindow( h3, KMdi::Detach ); // undock this!
+ h3->setGeometry( 20, 20, 400, 100);
+
+ Hello* h4 = new Hello( "Hello4", "Hello world!", mainWdg);
+ h4->setMDICaption("Hello4 both changed");
+ h4->setFont( TQFont("times",32,TQFont::Bold) );
+ mainWdg->addWindow( h4);
+// SHOW(h4->caption());
+// SHOW(h4->tabCaption());
+
+ Hello* h5 = new Hello( "Hello5", "I'm not a MDI widget :-(");
+ h5->setGeometry(40, 40, 400, 100);
+ h5->setFont( TQFont("times",20,TQFont::Bold) );
+ h5->setCaption("MDI Test Application");
+ h5->show();
+
+#if 0
+ KMdiIterator<KMdiChildView*> *it = mainWdg->createIterator();
+ for ( it->first(); !it->isDone(); it->next()) {
+ //cout << "--> " << it->currentItem()->caption() << endl;
+
+ }
+ //delete it;
+#endif
+
+ mainWdg->resize(500,500);
+ a.setMainWidget( restartWidget );
+ restartWidget->show();
+ mainWdg->show();
+
+ mainWdg->cascadeWindows();
+ return a.exec();
+}
diff --git a/tdemdi/test/mainwidget.cpp b/tdemdi/test/mainwidget.cpp
new file mode 100644
index 000000000..fd166ee95
--- /dev/null
+++ b/tdemdi/test/mainwidget.cpp
@@ -0,0 +1,147 @@
+/***************************************************************************
+ mainwidget.cpp - description
+ -------------------
+ begin : Mon Nov 8 1999
+ copyright : (C) 1999 by Falk Brettschneider
+ email : falkbr@tdevelop.org
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include <tqlayout.h>
+#include <tqmenubar.h>
+#include <tqtoolbar.h>
+#include <tqmultilineedit.h>
+#include <tqlistview.h>
+#include <tqfile.h>
+#include <tdemdimainfrm.h>
+#include <tdemditoolviewaccessor.h>
+
+#include "mainwidget.h"
+
+MainWidget::MainWidget(TQDomElement& dockConfig,KMdi::MdiMode mode)
+: KMdiMainFrm(0L, "theMDIMainFrm",mode)
+ ,m_dockConfig(dockConfig)
+{
+ setIDEAlModeStyle(1); // KDEV3
+
+ dockManager->setReadDockConfigMode(KDockManager::RestoreAllDockwidgets);
+ initMenu();
+
+ if (m_dockConfig.hasChildNodes()) {
+ readDockConfig(m_dockConfig);
+ }
+
+ TQMultiLineEdit* mle = new TQMultiLineEdit(0L,"theMultiLineEditWidget");
+ mle->setText("This is a TQMultiLineEdit widget.");
+ addToolWindow( mle, KDockWidget::DockBottom, m_pMdi, 70);
+
+ TQMultiLineEdit* mle2 = new TQMultiLineEdit(0L,"theMultiLineEditWidget2");
+ addToolWindow( mle2, KDockWidget::DockCenter, mle, 70);
+
+ TQMultiLineEdit* mle3 = new TQMultiLineEdit(0L,"theMultiLineEditWidget3");
+ addToolWindow( mle3, KDockWidget::DockCenter, mle, 70);
+
+ TQMultiLineEdit* mle4 = new TQMultiLineEdit(0L,"theMultiLineEditWidget4");
+ addToolWindow( mle4, KDockWidget::DockCenter, mle, 70);
+
+ KMdiToolViewAccessor *tva=createToolWindow();
+ tva->setWidgetToWrap(new TQMultiLineEdit(tva->wrapperWidget(),"theMultiLineEditWidget5"));
+ tva->placeAndShow(KDockWidget::DockCenter,mle,70);
+
+ TQListView* lv = new TQListView(0L,"theListViewWidget");
+#include "../res/filenew.xpm"
+ lv->setIcon(filenew);
+ lv->addColumn("Test", 50);
+ lv->addColumn("KMDI", 70);
+ new TQListViewItem(lv,TQString("test"),TQString("test"));
+ addToolWindow( lv, KDockWidget::DockLeft, m_pMdi, 35, "1");
+
+ TQListView* lv2 = new TQListView(0L,"theListViewWidget2");
+ lv2->setIcon(filenew);
+ lv2->addColumn("Test2", 50);
+ lv2->addColumn("KMDI2", 70);
+ new TQListViewItem(lv,TQString("test2"),TQString("test2"));
+ addToolWindow( lv2, KDockWidget::DockCenter, lv, 35, "2");
+
+ TQListView* lv3 = new TQListView(0L,"theListViewWidget3");
+ lv3->setIcon(filenew);
+ lv3->addColumn("Test3", 50);
+ lv3->addColumn("KMDI3", 70);
+ new TQListViewItem(lv,TQString("test3"),TQString("test3"));
+ addToolWindow( lv3, KDockWidget::DockCenter, lv, 35, "3");
+
+ dockManager->finishReadDockConfig();
+
+ setMenuForSDIModeSysButtons( menuBar());
+}
+
+MainWidget::~MainWidget()
+{
+ writeDockConfig(m_dockConfig);
+ TQDomDocument doc = m_dockConfig.ownerDocument();
+ TQString s = doc.toString();
+ TQFile f("/tmp/dc.txt");
+ f.open(IO_ReadWrite);
+ f.tqwriteBlock(s.latin1(), s.length());
+ f.close();
+}
+
+void MainWidget::initMenu()
+{
+ menuBar()->insertItem("&Window", windowMenu());
+ menuBar()->insertItem("&Docking", dockHideShowMenu());
+}
+
+/** additionally fit the system menu button position to the menu position */
+void MainWidget::resizeEvent( TQResizeEvent *pRSE)
+{
+ KMdiMainFrm::resizeEvent( pRSE);
+ setSysButtonsAtMenuPosition();
+}
+
+RestartWidget::RestartWidget():KMainWindow()
+{
+ mdimode=KMdi::ChildframeMode;
+ TQVBoxLayout* bl = new TQVBoxLayout(this);
+ TQLabel* l = new TQLabel("This is for the testing of\nKMdiMainFrm::read/writeDockConfig().\n", this);
+ TQCheckBox* b1 = new TQCheckBox("KMdiMainFrm close/restart", this);
+ b1->toggle();
+ TQObject::connect(b1, TQT_SIGNAL(stateChanged(int)), this, TQT_SLOT(onStateChanged(int)));
+ bl->add(l);
+ bl->add(b1);
+ bl->setMargin(10);
+ bl->activate();
+ show();
+
+ dockConfig = domDoc.createElement("dockConfig");
+ domDoc.appendChild(dockConfig);
+}
+
+void RestartWidget::onStateChanged(int on)
+{
+ if (on) {
+ m_w = new MainWidget(dockConfig,mdimode);
+ m_w->resize(500,500);
+ m_w->show();
+ }
+ else {
+ mdimode=m_w->mdiMode();
+ m_w->close();
+ delete m_w;
+ }
+
+}
+
+void RestartWidget::setWindow(MainWidget *w) {
+ m_w=w;
+}
+
+#include "mainwidget.moc"
diff --git a/tdemdi/test/mainwidget.h b/tdemdi/test/mainwidget.h
new file mode 100644
index 000000000..74ec7a654
--- /dev/null
+++ b/tdemdi/test/mainwidget.h
@@ -0,0 +1,71 @@
+/***************************************************************************
+ mainwidget.h - description
+ -------------------
+ begin : Mon Nov 8 1999
+ copyright : (C) 1999 by Falk Brettschneider
+ email : falkbr@tdevelop.org
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef MAINWIDGET_H
+#define MAINWIDGET_H
+
+#include <tqcheckbox.h>
+#include <tqlayout.h>
+#include <tqlabel.h>
+#include <tqdom.h>
+#include <tdemdimainfrm.h>
+
+/**
+ *@author Falk Brettschneider
+ */
+class MainWidget : public KMdiMainFrm
+{
+ Q_OBJECT
+public:
+ MainWidget(TQDomElement& dockConfig,KMdi::MdiMode mode);
+ virtual ~MainWidget();
+ void initMenu();
+
+protected: // Protected methods
+ virtual void resizeEvent( TQResizeEvent *pRSE);
+private:
+ TQDomElement m_dockConfig;
+};
+
+
+
+/**
+ *@author Falk Brettschneider
+ * This allows me to test KMdiMainFrm::read/writeDockConfig by
+ * closing and restarting the MainWidget via checkbox click.
+ */
+class RestartWidget : public KMainWindow
+{
+ Q_OBJECT
+// methods
+public:
+ RestartWidget();
+ void setWindow(MainWidget *w);
+
+private slots:
+ void onStateChanged(int on);
+
+// attributes
+public:
+ TQDomDocument domDoc;
+ TQDomElement dockConfig;
+ KMdi::MdiMode mdimode;
+private:
+ MainWidget *m_w;
+};
+
+#endif