Small changes in loggraph porting to Qt4
[vlp.git] / src / graph / loggraph.cpp
index 461669fe881fe64a388048a75a1662efb451d9c4..752828490a8dd60600c9d321e0058e8a35b40bdb 100644 (file)
@@ -7,20 +7,21 @@
 
 //#include <qwindow.h>
 */
-#include <qpainter.h>
-#include <qprinter.h>
-#include <qpushbt.h>
-#include <qradiobt.h>
-#include <qbttngrp.h>
-#include <qapp.h>
+#include <QtGui/QPainter>
+#include <QtGui/QPrinter>
+#include <QtGui/QPushButton>
+#include <QtGui/QRadioButton>
+#include <QtGui/QButtonGroup>
+#include <QtGui/QApplication>
+#include <QtGui/QMainWindow>
 #include <math.h>
-#include <qpixmap.h>
-#include <qscrbar.h>
-#include <qcolor.h>
+#include <QtGui/QPixmap>
+#include <QtGui/QScrollBar>
+#include <QtGui/QColor>
 #include <stdio.h>
-#include <qfont.h>
-#include <qfontmet.h>
-#include <qlist.h>
+#include <QtGui/QFont>
+#include <QtGui/QFontMetrics>
+#include <QtCore/QList>
 #include <fcntl.h>
 #include <sys/stat.h>
 #include <netinet/in.h>
 #include "comm.h"
 #include "socu.h"
 #include <unistd.h>
-#include <qsocknot.h>
-#include <qobject.h>
+#include <QtCore/QSocketNotifier>
+#include <QtCore/QObject>
 #include <errno.h>
-#include <qqueue.h>
-#include <qmsgbox.h>
-#include <qmenubar.h>
-#include <qpopmenu.h>
-#include <qkeycode.h>
+#include <QtCore/QQueue>
+#include <QtGui/QMessageBox>
+#include <QtGui/QMenuBar>
+// #include <qpopmenu.h>
+#include <QtCore/qnamespace.h>
 
 #define MAXWIDTH       640
 #define MAXHEIGHT      480
@@ -55,7 +56,7 @@ public:
        };
 };
 
-class VGR : public QFrame {
+class VGR : public QMainWindow {
        Q_OBJECT
 public:
        VGR(char*);
@@ -187,7 +188,7 @@ void VGR::MakeColors()
  * Construct the DrawView with buttons.
  */
 VGR::VGR(char *sockname)
-       :QFrame()
+       :QMainWindow()
 {
        QPixmap mp;
        struct sockaddr_un svr;
@@ -204,7 +205,7 @@ VGR::VGR(char *sockname)
 
        MakeColors();
        setCaption("graphic resource");
-       setBackgroundColor(white);
+//     setBackgroundColor(white);
        canvas = new QPixmap(640, 480);
        canvas->fill(backgroundColor());
 
@@ -280,7 +281,7 @@ VGR::VGR(char *sockname)
 
        setMaximumSize(MAXWIDTH + 16, MAXHEIGHT + 16);
        setUpdatesEnabled(FALSE);
-};
+}
 
 VGR::~VGR()
 {
@@ -426,61 +427,61 @@ void VGR::keyPressEvent(QKeyEvent *ev)
        *pom=ev->ascii();
        if (*pom==0) {
                switch(ev->key()) {
-               case Key_F1:
+               case Qt::Key_F1:
                        *pom = -10;
                        break;
-               case Key_F2:
+               case Qt::Key_F2:
                        *pom = -11;
                        break;
-               case Key_F3:
+               case Qt::Key_F3:
                        *pom = -12;
                        break;
-               case Key_F4:
+               case Qt::Key_F4:
                        *pom = -13;
                        break;
-               case Key_F5:
+               case Qt::Key_F5:
                        *pom = -14;
                        break;
-               case Key_F6:
+               case Qt::Key_F6:
                        *pom = -15;
                        break;
-               case Key_F7:
+               case Qt::Key_F7:
                        *pom = -16;
                        break;
-               case Key_F8:
+               case Qt::Key_F8:
                        *pom = -17;
                        break;
-               case Key_F9:
+               case Qt::Key_F9:
                        *pom = -18;
                        break;
-               case Key_F10:
+               case Qt::Key_F10:
                        *pom = -19;
                        break;
-               case Key_Insert:
+               case Qt::Key_Insert:
                        *pom = -20;
                        break;
-               case Key_Home:
+               case Qt::Key_Home:
                        *pom = -21;
                        break;
-               case Key_End:
+               case Qt::Key_End:
                        *pom = -22;
                        break;
-               case Key_PageUp:
+               case Qt::Key_PageUp:
                        *pom = -23;
                        break;
-               case Key_PageDown:
+               case Qt::Key_PageDown:
                        *pom = -24;
                        break;
-               case Key_Left:
+               case Qt::Key_Left:
                        *pom = -25;
                        break;
-               case Key_Right:
+               case Qt::Key_Right:
                        *pom = -26;
                        break;
-               case Key_Up:
+               case Qt::Key_Up:
                        *pom = -27;
                        break;
-               case Key_Down:
+               case Qt::Key_Down:
                        *pom = -28;
                        break;
                }/* switch */
@@ -660,7 +661,7 @@ void VGR::TextXY(int x, int y, char *s)
        p.begin(canvas);
        p.setPen(*lcolors[fcol]);
        p.setBackgroundColor(*lcolors[bcol]);
-       p.setBackgroundMode(OpaqueMode);
+       p.setBackgroundMode(Qt::OpaqueMode);
        p.setFont(*prv_font);
        p.drawText(x, y + fm.height(), s, strlen(s));
        p.end();
@@ -669,7 +670,7 @@ void VGR::TextXY(int x, int y, char *s)
        p.begin(this);
        p.setPen(*lcolors[fcol]);
        p.setBackgroundColor(*lcolors[bcol]);
-       p.setBackgroundMode(OpaqueMode);
+       p.setBackgroundMode(Qt::OpaqueMode);
        p.setFont(*prv_font);
        p.drawText(x - ox, y - oy + fm.height(), s, strlen(s));
        p.end();
@@ -687,7 +688,7 @@ void VGR::CharXY(int x, int y, char a)
        p.begin(canvas);
        p.setPen(*lcolors[fcol]);
        p.setBackgroundColor(*lcolors[bcol]);
-       p.setBackgroundMode(OpaqueMode);
+       p.setBackgroundMode(Qt::OpaqueMode);
        p.setFont(*prv_font);
        p.drawText(x , y + fm.height(), s, strlen(s));
        p.end();
@@ -695,7 +696,7 @@ void VGR::CharXY(int x, int y, char a)
        p.begin(this);
        p.setPen(*lcolors[fcol]);
        p.setBackgroundColor(*lcolors[bcol]);
-       p.setBackgroundMode(OpaqueMode);
+       p.setBackgroundMode(Qt::OpaqueMode);
        p.setFont(*prv_font);
        p.drawText(x - ox, y - oy + fm.height(), s, strlen(s));
        p.end();
@@ -712,7 +713,7 @@ void VGR::IntXY(int x, int y, int val)
        p.begin(canvas);
        p.setPen(*lcolors[fcol]);
        p.setBackgroundColor(*lcolors[bcol]);
-       p.setBackgroundMode(OpaqueMode);
+       p.setBackgroundMode(Qt::OpaqueMode);
        p.setFont(*prv_font);
        p.drawText(x, y + fm.height(), s, strlen(s));
        p.end();
@@ -720,7 +721,7 @@ void VGR::IntXY(int x, int y, int val)
        p.begin(this);
        p.setPen(*lcolors[fcol]);
        p.setBackgroundColor(*lcolors[bcol]);
-       p.setBackgroundMode(OpaqueMode);
+       p.setBackgroundMode(Qt::OpaqueMode);
        p.setFont(*prv_font);
        p.drawText(x - ox, y - oy + fm.height(), s, strlen(s));
        p.end();
@@ -734,7 +735,7 @@ void VGR::WriteText(char *s)
        p.begin(canvas);
        p.setPen(*lcolors[fcol]);
        p.setBackgroundColor(*lcolors[bcol]);
-       p.setBackgroundMode(OpaqueMode);
+       p.setBackgroundMode(Qt::OpaqueMode);
        p.setFont(*prv_font);
        p.drawText(tx * fm.maxWidth(), (ty + 1) * fm.height(), s, strlen(s));
        p.end();
@@ -742,7 +743,7 @@ void VGR::WriteText(char *s)
        p.begin(this);
        p.setPen(*lcolors[fcol]);
        p.setBackgroundColor(*lcolors[bcol]);
-       p.setBackgroundMode(OpaqueMode);
+       p.setBackgroundMode(Qt::OpaqueMode);
        p.setFont(*prv_font);
        p.drawText(tx * fm.maxWidth() - ox, (ty + 1) * fm.height() - oy, s,
                                                                strlen(s));
@@ -771,7 +772,7 @@ void VGR::WriteChar(char a)
                p.begin(canvas);
                p.setPen(*lcolors[gfcol]);
                p.setBackgroundColor(*lcolors[gbcol]);
-               p.setBackgroundMode(OpaqueMode);
+               p.setBackgroundMode(Qt::OpaqueMode);
                p.setFont(*prv_font);
                p.drawText(gx, gy + fm.height(), s, strlen(s));
                p.end();
@@ -779,7 +780,7 @@ void VGR::WriteChar(char a)
                p.begin(this);
                p.setPen(*lcolors[gfcol]);
                p.setBackgroundColor(*lcolors[gbcol]);
-               p.setBackgroundMode(OpaqueMode);
+               p.setBackgroundMode(Qt::OpaqueMode);
                p.setFont(*prv_font);
                p.drawText(gx - ox, gy - oy + fm.height(), s, strlen(s));
                p.end();
@@ -796,7 +797,7 @@ void VGR::WriteChar(char a)
                p.begin(canvas);
                p.setPen(*lcolors[fcol]);
                p.setBackgroundColor(*lcolors[bcol]);
-               p.setBackgroundMode(OpaqueMode);
+               p.setBackgroundMode(Qt::OpaqueMode);
                p.setFont(*prv_font);
                p.drawText(tx * fm.maxWidth(), (ty + 1) * fm.height(), s, 
                                                                strlen(s));
@@ -805,7 +806,7 @@ void VGR::WriteChar(char a)
                p.begin(this);
                p.setPen(*lcolors[fcol]);
                p.setBackgroundColor(*lcolors[bcol]);
-               p.setBackgroundMode(OpaqueMode);
+               p.setBackgroundMode(Qt::OpaqueMode);
                p.setFont(*prv_font);
                p.drawText(tx * fm.maxWidth() - ox, (ty + 1) * fm.height() - oy,
                                                                s, strlen(s));
@@ -876,7 +877,7 @@ void VGR::PutChar(char a)
        p.begin(canvas);
        p.setPen(*lcolors[fcol]);
        p.setBackgroundColor(*lcolors[bcol]);
-       p.setBackgroundMode(OpaqueMode);
+       p.setBackgroundMode(Qt::OpaqueMode);
        p.setFont(*prv_font);
        p.drawText(tx * fm.maxWidth(), (ty + 1) * fm.height(), s, strlen(s));
        p.end();
@@ -884,7 +885,7 @@ void VGR::PutChar(char a)
        p.begin(this);
        p.setPen(*lcolors[fcol]);
        p.setBackgroundColor(*lcolors[bcol]);
-       p.setBackgroundMode(OpaqueMode);
+       p.setBackgroundMode(Qt::OpaqueMode);
        p.setFont(*prv_font);
        p.drawText(tx * fm.maxWidth() - ox, (ty + 1) * fm.height() - oy, s,
                                                                strlen(s));
@@ -978,7 +979,7 @@ void VGR::Outstring(int x, int y, char *s, int b, int f)
        p.begin(canvas);
        p.setPen(*lcolors[f]);
        p.setBackgroundColor(*lcolors[b]);
-       p.setBackgroundMode(OpaqueMode);
+       p.setBackgroundMode(Qt::OpaqueMode);
        p.setFont(*prv_font);
        p.drawText(x, y + fm.height(), s, strlen(s));
        p.end();
@@ -987,7 +988,7 @@ void VGR::Outstring(int x, int y, char *s, int b, int f)
        p.setPen(*lcolors[f]);
        p.setFont(*prv_font);
        p.setBackgroundColor(*lcolors[b]);
-       p.setBackgroundMode(OpaqueMode);
+       p.setBackgroundMode(Qt::OpaqueMode);
        p.drawText(x - ox, y - oy + fm.height(), s, strlen(s));
        p.end();
 
@@ -1311,7 +1312,7 @@ int main(int argc, char **argv)
 {
        QApplication app(argc, argv);
        VGR gs(argv[1]);
-       app.setMainWidget(&gs);
+//     app.setMainWidget(&gs);
        gs.show();
        return app.exec();
 }