//#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
};
};
-class VGR : public QFrame {
+class VGR : public QMainWindow {
Q_OBJECT
public:
VGR(char*);
* Construct the DrawView with buttons.
*/
VGR::VGR(char *sockname)
- :QFrame()
+ :QMainWindow()
{
QPixmap mp;
struct sockaddr_un svr;
MakeColors();
setCaption("graphic resource");
- setBackgroundColor(white);
+// setBackgroundColor(white);
canvas = new QPixmap(640, 480);
canvas->fill(backgroundColor());
setMaximumSize(MAXWIDTH + 16, MAXHEIGHT + 16);
setUpdatesEnabled(FALSE);
-};
+}
VGR::~VGR()
{
*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 */
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();
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();
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();
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();
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();
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();
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();
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));
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();
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();
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.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));
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();
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));
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();
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();
{
QApplication app(argc, argv);
VGR gs(argv[1]);
- app.setMainWidget(&gs);
+// app.setMainWidget(&gs);
gs.show();
return app.exec();
}
#include <QtGui/QApplication>
-#include <QtGui/QFrame>
+#include <QtGui/QMainWindow>
#include <Qt3Support/q3multilineedit.h>
-#include <qmenubar.h>
-#include <qpopmenu.h>
-#include <qdialog.h>
-#include <qbttngrp.h>
+#include <QtGui/QMenuBar>
+// #include <qpopmenu.h>
+#include <QtGui/QDialog>
+#include <QtGui/QButtonGroup>
#include <QtGui/QLabel>
-#include <qlined.h>
-#include <qlistbox.h>
+#include <QtGui/QLineEdit>
+#include <Qt3Support/Q3ListBox>
#include <QtGui/QPushButton>
#include <QtGui/QRadioButton>
#include <QtCore/QList>
#include <QtCore/qfile.h>
-#include <qcombo.h>
-#include <qtooltip.h>
-#include <qfont.h>
-#include <qpixmap.h>
-#include <qmsgbox.h>
+#include <QtGui/qcombobox.h>
+#include <QtGui/QToolTip>
+#include <QtGui/QFont>
+#include <QtGui/QPixmap>
+#include <QtGui/QMessageBox>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
-#include <QtCore/qfile.h>
#include <QtCore/QTextStream>
-#include <qstring.h>
-#include <qfiledlg.h>
-#include <qfontmet.h>
-#include <qpainter.h>
-#include <qscrbar.h>
+#include <QtCore/qstring.h>
+#include <QtGui/QFileDialog>
+#include <QtGui/QFontMetrics>
+#include <QtGui/QPainter>
+#include <QtGui/QScrollBar>
#define TAG_TEXT 0
class HTMLAnalyzer {
public:
- QList<Tag> tags;
+ QList<Tag*> tags;
bool verbatim;
HTMLAnalyzer();
QTextStream fs(&f);
- while (!fs.eof()) {
+ while (!fs.atEnd()) {
poms = fs.readLine();
while (poms.length()>0) {
i = poms.find('<');
poms1 = poms1.simplifyWhiteSpace();
}
- sprintf(pomt->tag_text, " %s",
- poms1.data());
+ sprintf(pomt->tag_text, " %s", poms1.toStdString().c_str());
tags.append(pomt);
}
poms = poms.right(poms.length() - i);
if (!verbatim)
poms=poms.simplifyWhiteSpace();
- sprintf(pomt->tag_text, " %s", poms.data());
+ sprintf(pomt->tag_text, " %s", poms.toStdString().c_str());
tags.append(pomt);
break;
}
*t = t->simplifyWhiteSpace();
pom = new Tag;
- if ((t->data()[0] != 'A') && (t->data()[0] != 'a')) {
+ if ((t->toStdString().c_str()[0] != 'A') && (t->toStdString().c_str()[0] != 'a')) {
*t = t->upper();
- if (strcmp(t->data(), "B") ==0 ) {
+ if (strcmp(t->toStdString().c_str(), "B") ==0 ) {
pom->tag_type = TAG_BOLD_ON;
}
- else if (strcmp(t->data(), "/B") == 0) {
+ else if (strcmp(t->toStdString().c_str(), "/B") == 0) {
pom->tag_type = TAG_BOLD_OFF;
}
- else if (strcmp(t->data(), "I") == 0) {
+ else if (strcmp(t->toStdString().c_str(), "I") == 0) {
pom->tag_type = TAG_ITALIC_ON;
}
- else if (strcmp(t->data(), "/I") == 0) {
+ else if (strcmp(t->toStdString().c_str(), "/I") == 0) {
pom->tag_type = TAG_ITALIC_OFF;
}
- else if (strcmp(t->data(), "BR") == 0) {
+ else if (strcmp(t->toStdString().c_str(), "BR") == 0) {
pom->tag_type = TAG_BREAK;
}
- else if (strcmp(t->data(), "HR") == 0) {
+ else if (strcmp(t->toStdString().c_str(), "HR") == 0) {
pom->tag_type = TAG_LINE;
}
- else if (strcmp(t->data(), "/A") == 0) {
+ else if (strcmp(t->toStdString().c_str(), "/A") == 0) {
pom->tag_type = TAG_LINK_END;
}
- else if (strcmp(t->data(), "UL") == 0) {
+ else if (strcmp(t->toStdString().c_str(), "UL") == 0) {
pom->tag_type = TAG_LIST_ON;
}
- else if (strcmp(t->data(), "/UL") == 0) {
+ else if (strcmp(t->toStdString().c_str(), "/UL") == 0) {
pom->tag_type = TAG_LIST_OFF;
}
- else if (strcmp(t->data(), "LI") == 0) {
+ else if (strcmp(t->toStdString().c_str(), "LI") == 0) {
pom->tag_type = TAG_LIST_ITEM;
}
- else if (strcmp(t->data(), "PRE") == 0) {
+ else if (strcmp(t->toStdString().c_str(), "PRE") == 0) {
verbatim=TRUE;
}
- else if (strcmp(t->data(),"/PRE") == 0) {
+ else if (strcmp(t->toStdString().c_str(),"/PRE") == 0) {
verbatim=FALSE;
}
} else {
poms1 = t->right(t->length() - i - 1);
poms1 = poms1.simplifyWhiteSpace();
- if (strcmp(poms.data(),"HREF") == 0) {
+ if (poms == "HREF") {
pom->tag_type = TAG_LINK;
- strcpy(pom->tag_link,poms1.data());
+ strcpy(pom->tag_link,poms1.toStdString().c_str());
}
- else if (strcmp(poms.data(), "NAME") == 0) {
+ else if (poms == "NAME") {
pom->tag_type = TAG_ANCHOR;
- if (poms1.data()[0] == '"')
+ if (poms1[0] == '"')
poms1=poms1.right(poms1.length() - 1);
- if (poms1.data()[poms1.length() - 1] == '"')
+ if (poms1[poms1.length() - 1] == '"')
poms1=poms1.left(poms1.length() - 1);
- strcpy(pom->tag_label, poms1.data());
+ strcpy(pom->tag_label, poms1.toStdString().c_str());
}
}
}
while (pom != NULL) {
fprintf(stderr, "%s:%s,%s,%s\n", names[pom->tag_type],
pom->tag_text, pom->tag_link, pom->tag_label);
- pom=tags.next();
+ pom=tags.takeFirst();
}
}
while (pom!=NULL) {
if ((pom->tag_type == TAG_LINK) ||
(pom->tag_type == TAG_ANCHOR)) {
- pom1 = tags.next();
+ pom1 = tags.takeFirst();
strcpy(s, "");
while ((pom1 != NULL) &&
(pom1->tag_type != TAG_LINK_END)) {
if (pom1->tag_type == TAG_TEXT)
strcat(s,pom1->tag_text);
- tags.remove(pom1);
+ tags.removeOne(pom1);
pom1 = tags.current();
}
strcpy(pom->tag_text,s);
- tags.remove(pom1);
+ tags.removeOne(pom1);
pom = tags.current();
} else {
- pom = tags.next();
+ pom = tags.takeFirst();
}
}
}
(y >= pom->y) && (y <= pom->y + pom->h)) {
return pom;
}
- pom=tags.next();
+ pom=tags.takeFirst();
}
return NULL;
}
(strcmp(pom->tag_label, name) == 0)) {
return(pom);
}
- pom=tags.next();
+ pom=tags.takeFirst();
}
return pom;
}
/********************************/
-class QHTML: public QFrame {
+class QHTML: public QMainWindow {
Q_OBJECT
public:
QScrollBar *vscroll;
QHTML::QHTML(char *d)
{
- QPopupMenu *pp;
char s[255];
QFont f("Helvetica", 12, QFont::Bold);
strcpy(homedir, d);
actual_font = normal;
- bar = new QMenuBar(this);
- pp = new QPopupMenu;
- pp->insertItem("Index", this, SLOT(contents()));
- pp->insertItem("User Guide", this, SLOT(user_guide()));
- pp->insertItem("Language reference", this, SLOT(lang_guide()));
- pp->setFont(f);
- /*pp->setStyle(WindowsStyle);*/
- bar->insertItem("File", this, SLOT(load()));
- bar->insertItem("Contents", pp);
- bar->insertItem("Quit", app, SLOT(quit()));
- bar->setFont(f);
- setCaption("LOGLAN Help");
- setBackgroundColor(gray);
+
+ setWindowTitle("LOGLAN Help");
+
+ QMenu * contentsMenu = NULL;
+ menuBar()->addAction("File", this, SLOT(load()));
+ contentsMenu = menuBar()->addMenu("&Contents");
+ contentsMenu->addAction("Index", this, SLOT(contents()));
+ contentsMenu->addAction("User Guide", this, SLOT(user_guide()));
+ contentsMenu->addAction("Language reference", this, SLOT(lang_guide()));
+
+ menuBar()->addAction("Quit", app, SLOT(quit()));
+
analyzer = new HTMLAnalyzer;
map = new QPixmap(500, PIX_HEIGHT);
map->fill(backgroundColor());
oy = 0;
lstep = 10;
pstep = height() - bar->height();
- vscroll = new QScrollBar(0, PIX_HEIGHT, lstep, pstep, 0,
- QScrollBar::Vertical, this);
+ vscroll = new QScrollBar(0, PIX_HEIGHT, lstep, pstep, 0, QScrollBar::Vertical, this);
vscroll->setTracking(TRUE);
- vscroll->setGeometry(width() - 16, bar->height(), 16,
- height()-bar->height());
- connect(vscroll, SIGNAL(valueChanged(int)), this, SLOT(vscrolled(int)));
+ vscroll->setGeometry(width() - 16, bar->height(), 16, height()-bar->height());
+ connect(vscroll, SIGNAL(valueChanged(int)), this, SLOT(vscrolled(int)));
sprintf(s, "%s/index.html", homedir);
analyzer->LoadFile(s);
analyzer->PackLinks();
pom = analyzer->CheckTag(ev->x(), ev->y() + oy);
if (pom != NULL) {
poms.sprintf(pom->tag_link);
- if (poms.data()[0] == '"')
+ if (poms[0] == '"')
poms = poms.right(poms.length() - 1);
- if (poms.data()[poms.length() - 1] == '"')
+ if (poms[poms.length() - 1] == '"')
poms=poms.left(poms.length() - 1);
- if (poms.data()[0] == '#') {
+ if (poms[0] == '#') {
poms = poms.right(poms.length() - 1);
pom1 = analyzer->FindAnchor((char*)poms.ascii());
if (pom1 != NULL) {
vscroll->setValue(pom1->y);
}
} else {
- sprintf(ss, "%s/%s", homedir, poms.data());
+ sprintf(ss, "%s/%s", homedir, poms.toStdString().c_str());
analyzer->LoadFile(ss);
analyzer->PackLinks();
DrawList();
cy = cy + p.fontMetrics().height();
break;
}
- pom = analyzer->tags.next();
+ pom = analyzer->tags.takeFirst();
}
p.end();
repaint();
ps.sprintf(".");
QHTML cfg((char*)ps.ascii());
//app->setStyle(WindowsStyle);
- app->setMainWidget(&cfg);
+// app->setMainWidget(&cfg);
cfg.show();
return app->exec();
}