- public:
- QPixmap *map;
- int number;
-
- VGRMap(int n,QPixmap *m) { number=n; map = m; };
-};
-
-
-
-
-class VGR : public QFrame
-{
- Q_OBJECT
-public:
-
- VGR(char*);
- ~VGR();
-
-
- int resp_sock;
- int fcol,bcol,gfcol,gbcol;
- int curx,cury;
- int tx,ty;
- QQueue<int> CharBuffer;
-
- bool string_wait, char_wait, line_wait, mouse_wait, inkey_wait, was_line;
- QColor *lcolors[256];
- QFont *prv_font, *italic_font, *bold_font, *normal_font;
-
- void MakeColors();
-
- void SetForeground(int);
- void SetBackground(int);
- void ClearAll();
- void ClearArea(int,int,int,int);
-
- void Line(int,int,int,int);
- void Ellipse(int x,int y,int a, int b,int alfa, int beta, int fill);
- void Rect(int x1, int y1, int x2, int y2,int col, int fill);
- void Point(int x, int y);
- void TextXY(int x, int y, char *s);
- void CharXY(int x, int y, char a);
- void IntXY(int x, int y, int val);
-
- void WriteText(char *s);
- void WriteChar(char a);
- void WriteLine();
- void PutChar(char a); /* Write Char w/o changing position */
- void DelChar();
-
- void Outstring(int x, int y, char *s, int b, int f);
- void writeintxy(int x, int y, int val,int c);
- void CurPos();
-
-
- int Getmap(int w, int h);
- void Putmap(int map);
-
- void MagicGraph(G_MESSAGE*);
- bool GetInput(int);
-
-public slots:
- void vscrolled(int);
- void hscrolled(int);
- void CloseMe();
- void RequestMessage();
-
-protected:
- virtual void resizeEvent( QResizeEvent * );
- virtual void closeEvent(QCloseEvent *);
- virtual void keyPressEvent(QKeyEvent *);
- virtual void mousePressEvent(QMouseEvent *);
- virtual void paintEvent(QPaintEvent *);
- virtual void focusInEvent(QFocusEvent *);
-private:
- QPixmap *canvas;
- QScrollBar *hscroll,*vscroll;
- QPushButton *close_btn;
- int ox,oy,lstep,pstep,gx,gy;
- QList<VGRMap> maps;
- int firstfreemap;
- bool Closed, MustRepaint,GraphRead;
- QSocketNotifier *request;
- char internal_buffer[256];
- int strcnt;
-
-
-};
-
-
-
-void VGR::MakeColors()
-{
- lcolors[0] = new QColor(0, 0, 0 ); /* black */
- lcolors[1] = new QColor(0, 0, 139); /* blue dark */
- lcolors[2] = new QColor(0, 100, 0 ); /* green dark */
- lcolors[3] = new QColor(0, 197, 205 ); /* turquoise dark */
- lcolors[4] = new QColor(205,0 , 0 ); /* red dark */
- lcolors[5] = new QColor(238, 130,238); /* violet */
- lcolors[6] = new QColor(139,35,35 ); /* brown */
- lcolors[7] = new QColor(190,190,190 ); /* grey light */
- lcolors[8] = new QColor(97, 97, 97 ); /* grey dark */
- lcolors[9] = new QColor(0, 0, 255 ); /* blue */
- lcolors[10] = new QColor(0, 255, 0 ); /* green */
- lcolors[11] = new QColor(0, 229,238 ); /* turquoise */
- lcolors[12] = new QColor(255, 0, 0 ); /* red light */
- lcolors[13] = new QColor(255, 110,180 ); /* rose */
- lcolors[14] = new QColor(255,255, 0 ); /* yellow */
- lcolors[15] = new QColor(255, 255, 255 ); /* white */
+ char *sockname = argv[1];
+
+ fprintf(stderr, "loggraph: inited with sockname = %s\n", sockname);
+
+ QPixmap mp;
+ struct sockaddr_un svr;
+ int len, i, optval, on;
+
+ normal_font = new QFont("lucidatypewriter", 10, QFont::Normal);
+ normal_font->setFixedPitch(TRUE);
+ bold_font = new QFont("lucidatypewriter", 10, QFont::Bold);
+ bold_font->setFixedPitch(TRUE);
+ italic_font = new QFont("lucidatypewriter", 10, QFont::Normal,TRUE);
+ italic_font->setFixedPitch(TRUE);
+
+ prv_font = normal_font;
+
+ MakeColors();
+ setCaption("graphic resource");
+// setBackgroundColor(white);
+ canvas = new QPixmap(640, 480);
+ canvas->fill(backgroundColor());
+
+ ox = oy = 0;
+ curx = cury = 0;
+ tx = ty = 0;
+ gx = gy = 0;
+
+// maps.setAutoDelete(TRUE);
+ firstfreemap = 1;
+ Closed = FALSE;
+ GraphRead = FALSE;
+ lstep = 10;
+ pstep = 250;
+ hscroll = new QScrollBar(0, MAXWIDTH, lstep, pstep, 0, Qt::Orientation::Horizontal, this);
+ vscroll = new QScrollBar(0, MAXHEIGHT, lstep, pstep, 0, Qt::Orientation::Vertical, this);
+ hscroll->setTracking(TRUE);
+ vscroll->setTracking(TRUE);
+ resize(640, 300);
+
+ hscroll->setGeometry(0, height() - 16, width() - 16, 16);
+ vscroll->setGeometry(width() - 16, 0, 16, height() - 16);
+
+ connect(hscroll, SIGNAL(valueChanged(int)), this, SLOT(hscrolled(int)));
+ connect(vscroll, SIGNAL(valueChanged(int)), this, SLOT(vscrolled(int)));
+
+ close_btn = new QPushButton(this, "close");
+
+ if (mp.load("pics/close.bmp"))
+ close_btn->setPixmap(mp);
+ else
+ close_btn->setText("C");
+
+ close_btn->setGeometry(width()-16,height()-16,16,16);
+ close_btn->setEnabled(FALSE);
+ connect(close_btn, SIGNAL(clicked()), this, SLOT(CloseMe()));
+
+
+ gfcol = fcol = 0;
+ gbcol = bcol = 15;
+ resp_sock = socket(AF_UNIX, SOCK_STREAM, 0);
+ bzero(&svr, sizeof(svr));
+ svr.sun_family = AF_UNIX;
+ strcpy(svr.sun_path, sockname);
+ len = strlen(svr.sun_path) + sizeof(svr.sun_family);
+ i = ::connect(resp_sock, (struct sockaddr*)&svr, len);
+ if (i == 0)
+ fcntl(resp_sock, F_SETFL, O_NONBLOCK |
+ fcntl(resp_sock , F_GETFL, 0));
+ on = 1;
+ setsockopt(resp_sock, IPPROTO_TCP, TCP_NODELAY, (char*)&on, sizeof(on));
+ request = new QSocketNotifier(resp_sock, QSocketNotifier::Read);
+ connect(request, SIGNAL(activated(int)), this, SLOT(RequestMessage()));
+ optval=TCP_BUFFER_SIZE;
+ /*
+ setsockopt(resp_sock,SOL_SOCKET,SO_SNDBUF,&optval,sizeof(optval));
+ setsockopt(resp_sock,SOL_SOCKET,SO_RCVBUF,&optval,sizeof(optval));
+ */
+
+ inkey_wait = string_wait = FALSE;
+ char_wait = line_wait = mouse_wait = FALSE;
+ was_line = FALSE;
+ CharBuffer.clear();
+// CharBuffer.setAutoDelete(TRUE);
+
+ setFocusPolicy(Qt::StrongFocus);
+ hscroll->setRange(0, MAXWIDTH - width() + 20);
+ vscroll->setRange(0, MAXHEIGHT - height() + 20);
+ hscroll->setSteps((int)(hscroll->width() / hscroll->maxValue()),
+ (int)((hscroll->width() / hscroll->maxValue()) * 4));
+ vscroll->setSteps((int)(vscroll->height() / vscroll->maxValue()),
+ (int)((vscroll->height() / vscroll->maxValue()) * 4));
+
+ setMaximumSize(MAXWIDTH + 16, MAXHEIGHT + 16);
+ setUpdatesEnabled(FALSE);