diff options
Diffstat (limited to 'src/boost/tools/build/example/qt/qt3')
9 files changed, 300 insertions, 0 deletions
diff --git a/src/boost/tools/build/example/qt/qt3/hello/canvas.cpp b/src/boost/tools/build/example/qt/qt3/hello/canvas.cpp new file mode 100644 index 000000000..c6d23c9d4 --- /dev/null +++ b/src/boost/tools/build/example/qt/qt3/hello/canvas.cpp @@ -0,0 +1,73 @@ +// Copyright Vladimir Prus 2004. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt +// or copy at http://www.boost.org/LICENSE_1_0.txt) + +#include "canvas.h" + +#include <qlabel.h> +#include <qcanvas.h> +#include <qlayout.h> + +Canvas::Canvas(QWidget* parent) +: QWidget(parent) +{ + m_pen = QPen(QColor(255, 128, 128)); + m_brushes = new QBrush[2]; + m_brushes[0] = QBrush(QColor(255, 0, 0)); + m_brushes[1] = QBrush(QColor(0, 255, 0)); + m_current_brush = 0; + + m_canvas = new QCanvas(this); + m_canvas->resize(4*1600, 600); + + redraw(); + + QVBoxLayout* l = new QVBoxLayout(this); + + m_canvas_view = new QCanvasView(m_canvas, this); + l->addWidget(m_canvas_view); + m_canvas_view->resize(rect().size()); + m_canvas_view->show(); +} + +Canvas::~Canvas() +{ + delete m_brushes; +} + +void Canvas::redraw() +{ + QCanvasItemList l = m_canvas->allItems(); + for(QCanvasItemList::iterator i = l.begin(), + e = l.end(); i != e; ++i) + { + delete *i; + } + + unsigned count = 0; + for (unsigned x = 10; x < 4*1600; x += 20) + for (unsigned y = 10; y < 600; y += 20) { + QCanvasRectangle* r = new QCanvasRectangle(x, y, 10, 10, m_canvas); + r->setPen(m_pen); + r->setBrush(m_brushes[m_current_brush]); + r->show(); + ++count; + QCanvasText* t = new QCanvasText("D", m_canvas); + t->move(x, y); + t->show(); + ++count; + } + + (new QCanvasText(QString::number(count), m_canvas))->show(); + m_canvas->setAllChanged(); + +} + +void Canvas::change_color() +{ + m_current_brush = (m_current_brush + 1)%2; + redraw(); + m_canvas->update(); +} + diff --git a/src/boost/tools/build/example/qt/qt3/hello/canvas.h b/src/boost/tools/build/example/qt/qt3/hello/canvas.h new file mode 100644 index 000000000..f9f950267 --- /dev/null +++ b/src/boost/tools/build/example/qt/qt3/hello/canvas.h @@ -0,0 +1,35 @@ +// Copyright Vladimir Prus 2004. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt +// or copy at http://www.boost.org/LICENSE_1_0.txt) + + +#ifndef CANVAS_VP_2004_08_31 +#define CANVAS_VP_2004_08_31 + +#include <qmainwindow.h> +#include <qpen.h> +#include <qbrush.h> + +class Canvas : public QWidget +{ + Q_OBJECT +public: + Canvas(QWidget* parent); + + virtual ~Canvas(); + +public slots: + void change_color(); + +private: + void redraw(); + class QCanvas* m_canvas; + class QCanvasView* m_canvas_view; + class QPen m_pen; + class QBrush* m_brushes; + int m_current_brush; +}; + +#endif + diff --git a/src/boost/tools/build/example/qt/qt3/hello/jamroot.jam b/src/boost/tools/build/example/qt/qt3/hello/jamroot.jam new file mode 100644 index 000000000..03be582e5 --- /dev/null +++ b/src/boost/tools/build/example/qt/qt3/hello/jamroot.jam @@ -0,0 +1,13 @@ +# Copyright Vladimir Prus 2004. +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt +# or copy at http://www.boost.org/LICENSE_1_0.txt) + +using qt ; + +project + # built MT version, unless asked otherwise. + : default-build <threading>multi + ; + +exe canvas : main.cpp canvas.cpp canvas.h : <library>/qt//qt ;
\ No newline at end of file diff --git a/src/boost/tools/build/example/qt/qt3/hello/main.cpp b/src/boost/tools/build/example/qt/qt3/hello/main.cpp new file mode 100644 index 000000000..8f1ffc2fb --- /dev/null +++ b/src/boost/tools/build/example/qt/qt3/hello/main.cpp @@ -0,0 +1,36 @@ +// Copyright Vladimir Prus 2004. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt +// or copy at http://www.boost.org/LICENSE_1_0.txt) + +#include "canvas.h" +#include <qapplication.h> +#include <qvbox.h> +#include <qpushbutton.h> + +class Window : public QMainWindow +{ +public: + Window() + { + setCaption("QCanvas test"); + QVBox* vb = new QVBox(this); + setCentralWidget(vb); + + Canvas* c = new Canvas(vb); + QPushButton* b = new QPushButton("Change color", vb); + connect(b, SIGNAL(clicked()), c, SLOT(change_color())); + } +}; + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + Window *w = new Window(); + + app.setMainWidget(w); + w->show(); + + return app.exec(); +} + diff --git a/src/boost/tools/build/example/qt/qt3/moccable-cpp/jamroot.jam b/src/boost/tools/build/example/qt/qt3/moccable-cpp/jamroot.jam new file mode 100644 index 000000000..85778da20 --- /dev/null +++ b/src/boost/tools/build/example/qt/qt3/moccable-cpp/jamroot.jam @@ -0,0 +1,11 @@ + +using qt ; +import cast ; + +project + : default-build <threading>multi + ; + +exe main : main.cpp [ cast _ moccable-cpp : main.cpp ] + /qt//qt + ; diff --git a/src/boost/tools/build/example/qt/qt3/moccable-cpp/main.cpp b/src/boost/tools/build/example/qt/qt3/moccable-cpp/main.cpp new file mode 100644 index 000000000..ed36f7469 --- /dev/null +++ b/src/boost/tools/build/example/qt/qt3/moccable-cpp/main.cpp @@ -0,0 +1,41 @@ +// Copyright Vladimir Prus 2005. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt +// or copy at http://www.boost.org/LICENSE_1_0.txt) + + +#include <qwidget.h> +#include <qpushbutton.h> +#include <qapplication.h> + +#include <iostream> + +class My_widget : public QWidget +{ + Q_OBJECT +public: + My_widget() : QWidget() + { + QPushButton* b = new QPushButton("Push me", this); + + connect(b, SIGNAL(clicked()), this, SLOT(theSlot())); + } + +private slots: + void theSlot() + { + std::cout << "Clicked\n"; + } + +}; + +int main(int ac, char* av[]) +{ + QApplication app(ac, av); + My_widget mw; + mw.show(); + app.setMainWidget(&mw); + app.exec(); +} + +#include "main.moc" diff --git a/src/boost/tools/build/example/qt/qt3/uic/hello_world_widget.ui b/src/boost/tools/build/example/qt/qt3/uic/hello_world_widget.ui new file mode 100644 index 000000000..26cc73487 --- /dev/null +++ b/src/boost/tools/build/example/qt/qt3/uic/hello_world_widget.ui @@ -0,0 +1,58 @@ +<!DOCTYPE UI><UI version="3.0" stdsetdef="1"> +<class>HelloWorldWidget</class> +<comment> +<!-- + Copyright Felix E. Klee, 2003 + Distributed under the Boost Software License, Version 1.0. + (See accompanying file LICENSE_1_0.txt + or copy at http://www.boost.org/LICENSE_1_0.txt) +--> +</comment> +<widget class="QWidget"> + <property name="name"> + <cstring>HelloWorldWidget</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>124</width> + <height>63</height> + </rect> + </property> + <property name="caption"> + <string>Hello World!</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>11</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>TextLabel2</cstring> + </property> + <property name="text"> + <string>Hello World!</string> + </property> + <property name="alignment"> + <set>AlignCenter</set> + </property> + </widget> + <widget class="QPushButton"> + <property name="name"> + <cstring>OkButton</cstring> + </property> + <property name="text"> + <string>OK</string> + </property> + </widget> + </vbox> +</widget> +<layoutdefaults spacing="6" margin="11"/> +</UI> diff --git a/src/boost/tools/build/example/qt/qt3/uic/jamroot.jam b/src/boost/tools/build/example/qt/qt3/uic/jamroot.jam new file mode 100644 index 000000000..d0b806294 --- /dev/null +++ b/src/boost/tools/build/example/qt/qt3/uic/jamroot.jam @@ -0,0 +1,15 @@ +# Copyright Felix E. Klee, 2003 +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt +# or copy at http://www.boost.org/LICENSE_1_0.txt) + +# Tell that QT should be used. QTDIR will give installation +# prefix. +using qt ; + +project + : default-build <threading>multi + ; + +exe hello : main.cpp hello_world_widget.ui : <library>/qt//qt ; + diff --git a/src/boost/tools/build/example/qt/qt3/uic/main.cpp b/src/boost/tools/build/example/qt/qt3/uic/main.cpp new file mode 100644 index 000000000..f2a08b5fa --- /dev/null +++ b/src/boost/tools/build/example/qt/qt3/uic/main.cpp @@ -0,0 +1,18 @@ +// Copyright Felix E. Klee, 2003 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt +// or copy at http://www.boost.org/LICENSE_1_0.txt) + +#include "hello_world_widget.h" +#include <qapplication.h> + +#include <qpushbutton.h> + +int main(int argc, char **argv) { + QApplication a(argc, argv); + HelloWorldWidget w; + QObject::connect(static_cast<QObject*>(w.OkButton), SIGNAL(clicked()), &w, SLOT(close())); + a.setMainWidget(&w); + w.show(); + return a.exec(); +} |