2 #include <QtGui/QPainter>
3 #include <QtGui/QPrinter>
4 #include <QtGui/QPushButton>
5 #include <QtGui/QRadioButton>
6 #include <QtGui/QButtonGroup>
7 #include <QtGui/QApplication>
8 #include <QtGui/QMainWindow>
10 #include <QtGui/QPixmap>
11 #include <QtGui/QScrollBar>
12 #include <QtGui/QColor>
14 #include <QtGui/QFont>
15 #include <QtGui/QFontMetrics>
16 #include <QtCore/QList>
19 #include <netinet/in.h>
24 #include <QtCore/QSocketNotifier>
25 #include <QtCore/QObject>
27 #include <QtCore/QQueue>
28 #include <QtGui/QMessageBox>
29 #include <QtGui/QMenuBar>
30 // #include <qpopmenu.h>
31 #include <QtCore/qnamespace.h>
37 #define REQUEST_NAME "gr.req"
45 VGRMap(int n, QPixmap *m) {
51 class VGR : public QMainWindow {
66 QQueue<int> CharBuffer;
82 void SetForeground(int);
83 void SetBackground(int);
85 void ClearArea(int, int, int, int);
87 void Line(int, int, int, int);
88 void Ellipse(int x, int y, int a, int b, int alfa, int beta, int fill);
89 void Rect(int x1, int y1, int x2, int y2, int col, int fill);
90 void Point(int x, int y);
91 void TextXY(int x, int y, char *s);
92 void CharXY(int x, int y, char a);
93 void IntXY(int x, int y, int val);
95 void WriteText(char *s);
96 void WriteChar(char a);
99 /* Write Char w/o changing position */
100 void PutChar(char a);
103 void Outstring(int x, int y, char *s, int b, int f);
104 void writeintxy(int x, int y, int val, int c);
107 int Getmap(int w, int h);
108 void Putmap(int map);
110 void MagicGraph(G_MESSAGE*);
117 void RequestMessage();
120 virtual void resizeEvent(QResizeEvent *);
121 virtual void closeEvent(QCloseEvent *);
122 virtual void keyPressEvent(QKeyEvent *);
123 virtual void mousePressEvent(QMouseEvent *);
124 virtual void paintEvent(QPaintEvent *);
125 virtual void focusInEvent(QFocusEvent *);
131 QPushButton *close_btn;
132 int ox,oy,lstep,pstep,gx,gy;
138 QSocketNotifier *request;
139 char internal_buffer[256];
143 void VGR::MakeColors()
146 lcolors[0] = new QColor(0, 0, 0);
148 lcolors[1] = new QColor(0, 0, 139);
150 lcolors[2] = new QColor(0, 100, 0);
152 lcolors[3] = new QColor(0, 197, 205);
154 lcolors[4] = new QColor(205, 0, 0);
156 lcolors[5] = new QColor(238, 130, 238);
158 lcolors[6] = new QColor(139,35, 35);
160 lcolors[7] = new QColor(190, 190, 190);
162 lcolors[8] = new QColor(97, 97, 97);
164 lcolors[9] = new QColor(0, 0, 255);
166 lcolors[10] = new QColor(0, 255, 0);
168 lcolors[11] = new QColor(0, 229, 238);
170 lcolors[12] = new QColor(255, 0, 0);
172 lcolors[13] = new QColor(255, 110, 180);
174 lcolors[14] = new QColor(255, 255, 0);
176 lcolors[15] = new QColor(255, 255, 255);
180 * Construct the DrawView with buttons.
182 VGR::VGR(char *sockname)
186 struct sockaddr_un svr;
187 int len, i, optval, on;
189 normal_font = new QFont("lucidatypewriter", 10, QFont::Normal);
190 normal_font->setFixedPitch(TRUE);
191 bold_font = new QFont("lucidatypewriter", 10, QFont::Bold);
192 bold_font->setFixedPitch(TRUE);
193 italic_font = new QFont("lucidatypewriter", 10, QFont::Normal,TRUE);
194 italic_font->setFixedPitch(TRUE);
196 prv_font = normal_font;
199 setCaption("graphic resource");
200 // setBackgroundColor(white);
201 canvas = new QPixmap(640, 480);
202 canvas->fill(backgroundColor());
209 maps.setAutoDelete(TRUE);
215 hscroll = new QScrollBar(0, MAXWIDTH, lstep, pstep, 0, QScrollBar::Horizontal, this);
216 vscroll = new QScrollBar(0, MAXHEIGHT, lstep, pstep, 0, QScrollBar::Vertical, this);
217 hscroll->setTracking(TRUE);
218 vscroll->setTracking(TRUE);
221 hscroll->setGeometry(0, height() - 16, width() - 16, 16);
222 vscroll->setGeometry(width() - 16, 0, 16, height() - 16);
224 connect(hscroll, SIGNAL(valueChanged(int)), this, SLOT(hscrolled(int)));
225 connect(vscroll, SIGNAL(valueChanged(int)), this, SLOT(vscrolled(int)));
227 close_btn = new QPushButton(this, "close");
229 if (mp.load("pics/close.bmp"))
230 close_btn->setPixmap(mp);
232 close_btn->setText("C");
234 close_btn->setGeometry(width()-16,height()-16,16,16);
235 close_btn->setEnabled(FALSE);
236 connect(close_btn, SIGNAL(clicked()), this, SLOT(CloseMe()));
241 resp_sock = socket(AF_UNIX, SOCK_STREAM, 0);
242 bzero(&svr, sizeof(svr));
243 svr.sun_family = AF_UNIX;
244 strcpy(svr.sun_path, sockname);
245 len = strlen(svr.sun_path) + sizeof(svr.sun_family);
246 i = ::connect(resp_sock, (struct sockaddr*)&svr, len);
248 fcntl(resp_sock, F_SETFL, O_NONBLOCK |
249 fcntl(resp_sock , F_GETFL, 0));
251 setsockopt(resp_sock, IPPROTO_TCP, TCP_NODELAY, (char*)&on, sizeof(on));
252 request = new QSocketNotifier(resp_sock, QSocketNotifier::Read);
253 connect(request, SIGNAL(activated(int)), this, SLOT(RequestMessage()));
254 optval=TCP_BUFFER_SIZE;
256 setsockopt(resp_sock,SOL_SOCKET,SO_SNDBUF,&optval,sizeof(optval));
257 setsockopt(resp_sock,SOL_SOCKET,SO_RCVBUF,&optval,sizeof(optval));
260 inkey_wait = string_wait = FALSE;
261 char_wait = line_wait = mouse_wait = FALSE;
264 CharBuffer.setAutoDelete(TRUE);
266 setFocusPolicy(QWidget::StrongFocus);
267 hscroll->setRange(0, MAXWIDTH - width() + 20);
268 vscroll->setRange(0, MAXHEIGHT - height() + 20);
269 hscroll->setSteps((int)(hscroll->width() / hscroll->maxValue()),
270 (int)((hscroll->width() / hscroll->maxValue()) * 4));
271 vscroll->setSteps((int)(vscroll->height() / vscroll->maxValue()),
272 (int)((vscroll->height() / vscroll->maxValue()) * 4));
274 setMaximumSize(MAXWIDTH + 16, MAXHEIGHT + 16);
275 setUpdatesEnabled(FALSE);
284 void VGR::paintEvent(QPaintEvent *p)
286 /*if (isUpdatesEnabled()) {*/
287 bitBlt(this, 0, 0, canvas, ox, oy, width() - 16, height() - 16);
292 void VGR::focusInEvent(QFocusEvent *)
294 setUpdatesEnabled(TRUE);
296 setUpdatesEnabled(FALSE);
300 void VGR::resizeEvent( QResizeEvent *ev )
302 hscroll->setGeometry(0, height() - 16, width() - 16, 16);
303 vscroll->setGeometry(width() - 16, 0, 16, height() - 16);
304 close_btn->setGeometry(width() - 16, height() - 16, 16, 16);
305 hscroll->setRange(0, MAXWIDTH - width() + 20);
306 vscroll->setRange(0, MAXHEIGHT - height() + 20);
307 pstep = height() - 32;
308 hscroll->setSteps(lstep, pstep);
309 vscroll->setSteps(lstep, pstep);
312 void VGR::closeEvent(QCloseEvent *ev)
315 QFrame::closeEvent(ev);
318 void VGR::mousePressEvent(QMouseEvent *ev)
323 msg.msg_type = MSG_GRAPH;
324 msg.param.pword[0] = GRAPH_MGETPRESS_RESPONSE;
325 msg.param.pword[2] = ev->pos().x() - ox;
326 msg.param.pword[3] = ev->pos().y() - oy;
327 switch(ev->button()) {
329 msg.param.pword[7] = 1;
332 msg.param.pword[7] = 3;
335 msg.param.pword[7] = 2;
338 msg.param.pword[7] = 0;
341 write(resp_sock, &msg, sizeof(G_MESSAGE));
345 QFrame::mousePressEvent(ev);
349 bool VGR::GetInput(int t)
353 if (!CharBuffer.isEmpty()) {
356 msg.msg_type = MSG_GRAPH;
357 msg.param.pword[0] = GRAPH_INKEY_RESPONSE;
358 msg.param.pword[3] = *(CharBuffer.dequeue());
359 write(resp_sock,&msg,sizeof(G_MESSAGE));
367 msg.msg_type = MSG_GRAPH;
368 msg.param.pword[0] = GRAPH_MAGIC_RESPONSE;
369 msg.param.pword[1] = 0;
371 (char)(*(CharBuffer.dequeue()));
372 WriteChar(msg.param.pchar);
375 msg.msg_type = MSG_GRAPH;
376 msg.param.pword[0] = GRAPH_READCHAR_RESPONSE;
378 (char)(*(CharBuffer.dequeue()));
381 write(resp_sock,&msg,sizeof(G_MESSAGE));
386 while ( ((!CharBuffer.isEmpty()) &&
387 (!(*(CharBuffer.dequeue()) = 13))));
389 if (!CharBuffer.isEmpty()) {
390 msg.msg_type = MSG_GRAPH;
391 msg.param.pword[0] = GRAPH_READLN_RESPONSE;
392 write(resp_sock, &msg, sizeof(G_MESSAGE));
401 if (CharBuffer.isEmpty() && (t == 2)) {
402 msg.msg_type = MSG_GRAPH;
403 msg.param.pword[0] = GRAPH_INKEY_RESPONSE;
404 msg.param.pword[3] = 0;
405 write(resp_sock, &msg, sizeof(G_MESSAGE));
413 void VGR::keyPressEvent(QKeyEvent *ev)
464 case Qt::Key_PageDown:
481 if ((!string_wait) && (!inkey_wait) && (!char_wait) && (!line_wait))
482 CharBuffer.enqueue(pom);
486 msg.msg_type = MSG_GRAPH;
487 msg.param.pword[0] = GRAPH_INKEY_RESPONSE;
488 msg.param.pword[3] = *pom;
489 write(resp_sock, &msg, sizeof(G_MESSAGE));
495 msg.msg_type = MSG_GRAPH;
496 msg.param.pword[0] = GRAPH_MAGIC_RESPONSE;
497 msg.param.pword[1] = 0;
498 WriteChar((char)ev->ascii());
501 msg.msg_type = MSG_GRAPH;
502 msg.param.pword[0] = GRAPH_READCHAR_RESPONSE;
504 msg.param.pchar = (char)ev->ascii();
505 write(resp_sock, &msg, sizeof(G_MESSAGE));
509 if ((line_wait) && (ev->ascii() == 13)) {
510 msg.msg_type = MSG_GRAPH;
511 msg.param.pword[0] = GRAPH_READLN_RESPONSE;
512 write(resp_sock, &msg, sizeof(G_MESSAGE));
517 if (ev->ascii() == 13) {
518 internal_buffer[strcnt] = '\0';
522 msg.msg_type = MSG_GRAPH;
523 msg.param.pword[0] = GRAPH_MAGIC_RESPONSE;
524 msg.param.pword[1] = 0;
526 msg.msg_type = MSG_GRAPH;
527 msg.param.pword[0] = GRAPH_READSTR_RESPONSE;
529 strcpy(msg.param.pstr, internal_buffer);
530 write(resp_sock, &msg, sizeof(G_MESSAGE));
535 else if (ev->ascii() == 8) {
541 internal_buffer[strcnt] = (char)ev->ascii();
544 WriteChar((char)ev->ascii());
558 void VGR::hscrolled(int val)
561 setUpdatesEnabled(TRUE);
563 setUpdatesEnabled(FALSE);
566 void VGR::vscrolled(int val)
569 setUpdatesEnabled(TRUE);
571 setUpdatesEnabled(FALSE);
575 /****************************************/
577 void VGR::SetForeground(int col)
582 void VGR::SetBackground(int col)
587 void VGR::Line(int x1, int y1, int x2, int y2)
591 p.setPen(*lcolors[fcol]);
592 p.drawLine(x1, y1, x2, y2);
596 p.setPen(*lcolors[fcol]);
597 p.drawLine(x1 - ox, y1 - oy, x2 - ox, y2 - oy);
601 void VGR::Ellipse(int x, int y, int a, int b, int alfa, int beta, int fill)
606 p.setPen(*lcolors[fcol]);
607 p.setBrush(*lcolors[fcol]);
609 p.drawPie(x, y, a, b, alfa * 16, (beta - alfa) * 16);
611 p.drawArc(x, y, a, b, alfa * 16, (beta - alfa) * 16);
616 p.setPen(*lcolors[fcol]);
617 p.setBrush(*lcolors[fcol]);
619 p.drawPie(x - ox, y - oy, a, b, alfa * 16, (beta - alfa) * 16);
621 p.drawArc(x - ox, y - oy, a, b, alfa * 16, (beta - alfa) * 16);
626 void VGR::Rect(int x1, int y1, int x2, int y2,int col, int fill)
629 QBrush b(*lcolors[col]);
631 p.setPen(*lcolors[col]);
633 p.fillRect(x1 , y1 , x2 - x1, y2 - y1, b);
635 p.drawRect(x1,y1,x2-x1,y2-y1);
640 p.setPen(*lcolors[col]);
642 p.fillRect(x1 - ox, y1 - oy, x2 - x1, y2 - y1, b);
644 p.drawRect(x1 - ox, y1 - oy, x2 - x1, y2 - y1);
648 void VGR::TextXY(int x, int y, char *s)
651 QFontMetrics fm(*prv_font);
654 p.setPen(*lcolors[fcol]);
655 p.setBackgroundColor(*lcolors[bcol]);
656 p.setBackgroundMode(Qt::OpaqueMode);
657 p.setFont(*prv_font);
658 p.drawText(x, y + fm.height(), s, strlen(s));
663 p.setPen(*lcolors[fcol]);
664 p.setBackgroundColor(*lcolors[bcol]);
665 p.setBackgroundMode(Qt::OpaqueMode);
666 p.setFont(*prv_font);
667 p.drawText(x - ox, y - oy + fm.height(), s, strlen(s));
672 void VGR::CharXY(int x, int y, char a)
676 QFontMetrics fm(*prv_font);
681 p.setPen(*lcolors[fcol]);
682 p.setBackgroundColor(*lcolors[bcol]);
683 p.setBackgroundMode(Qt::OpaqueMode);
684 p.setFont(*prv_font);
685 p.drawText(x , y + fm.height(), s, strlen(s));
689 p.setPen(*lcolors[fcol]);
690 p.setBackgroundColor(*lcolors[bcol]);
691 p.setBackgroundMode(Qt::OpaqueMode);
692 p.setFont(*prv_font);
693 p.drawText(x - ox, y - oy + fm.height(), s, strlen(s));
698 void VGR::IntXY(int x, int y, int val)
702 QFontMetrics fm(*prv_font);
704 sprintf(s, "%d", val);
706 p.setPen(*lcolors[fcol]);
707 p.setBackgroundColor(*lcolors[bcol]);
708 p.setBackgroundMode(Qt::OpaqueMode);
709 p.setFont(*prv_font);
710 p.drawText(x, y + fm.height(), s, strlen(s));
714 p.setPen(*lcolors[fcol]);
715 p.setBackgroundColor(*lcolors[bcol]);
716 p.setBackgroundMode(Qt::OpaqueMode);
717 p.setFont(*prv_font);
718 p.drawText(x - ox, y - oy + fm.height(), s, strlen(s));
722 void VGR::WriteText(char *s)
725 QFontMetrics fm(*prv_font);
728 p.setPen(*lcolors[fcol]);
729 p.setBackgroundColor(*lcolors[bcol]);
730 p.setBackgroundMode(Qt::OpaqueMode);
731 p.setFont(*prv_font);
732 p.drawText(tx * fm.maxWidth(), (ty + 1) * fm.height(), s, strlen(s));
736 p.setPen(*lcolors[fcol]);
737 p.setBackgroundColor(*lcolors[bcol]);
738 p.setBackgroundMode(Qt::OpaqueMode);
739 p.setFont(*prv_font);
740 p.drawText(tx * fm.maxWidth() - ox, (ty + 1) * fm.height() - oy, s,
745 if (tx > TEXT_COLS) {
749 if (ty > TEXT_LINES) {
754 void VGR::WriteChar(char a)
757 QFontMetrics fm(*prv_font);
765 p.setPen(*lcolors[gfcol]);
766 p.setBackgroundColor(*lcolors[gbcol]);
767 p.setBackgroundMode(Qt::OpaqueMode);
768 p.setFont(*prv_font);
769 p.drawText(gx, gy + fm.height(), s, strlen(s));
773 p.setPen(*lcolors[gfcol]);
774 p.setBackgroundColor(*lcolors[gbcol]);
775 p.setBackgroundMode(Qt::OpaqueMode);
776 p.setFont(*prv_font);
777 p.drawText(gx - ox, gy - oy + fm.height(), s, strlen(s));
780 gx = gx + strlen(s) * fm.maxWidth();
782 gy = gy + fm.height();
785 if (gy > MAXHEIGHT) {
790 p.setPen(*lcolors[fcol]);
791 p.setBackgroundColor(*lcolors[bcol]);
792 p.setBackgroundMode(Qt::OpaqueMode);
793 p.setFont(*prv_font);
794 p.drawText(tx * fm.maxWidth(), (ty + 1) * fm.height(), s,
799 p.setPen(*lcolors[fcol]);
800 p.setBackgroundColor(*lcolors[bcol]);
801 p.setBackgroundMode(Qt::OpaqueMode);
802 p.setFont(*prv_font);
803 p.drawText(tx * fm.maxWidth() - ox, (ty + 1) * fm.height() - oy,
808 if (tx > TEXT_COLS) {
812 if (ty > TEXT_LINES) {
821 QFontMetrics fm(*prv_font);
825 p.setPen(*lcolors[fcol]);
826 p.fillRect(gx - fm.maxWidth(), gy, fm.maxWidth(),
827 fm.height() + fm.descent() + 1, *lcolors[bcol]);
831 p.setPen(*lcolors[fcol]);
833 p.fillRect(gx - ox - fm.maxWidth(), gy - oy, fm.maxWidth(),
834 fm.height() + fm.descent() + 1, *lcolors[bcol]);
836 gx = gx - fm.maxWidth();
840 p.setPen(*lcolors[fcol]);
841 p.fillRect((tx - 1) * fm.maxWidth(), (ty) * fm.height(),
843 (ty + 1) * fm.height() + fm.descent() + 1,
848 p.setPen(*lcolors[fcol]);
849 p.fillRect((tx - 1) * fm.maxWidth() - ox, (ty) * fm.height() - oy,
851 (ty + 1) * fm.height() + fm.descent() + 1,
861 void VGR::PutChar(char a)
864 QFontMetrics fm(*prv_font);
870 p.setPen(*lcolors[fcol]);
871 p.setBackgroundColor(*lcolors[bcol]);
872 p.setBackgroundMode(Qt::OpaqueMode);
873 p.setFont(*prv_font);
874 p.drawText(tx * fm.maxWidth(), (ty + 1) * fm.height(), s, strlen(s));
878 p.setPen(*lcolors[fcol]);
879 p.setBackgroundColor(*lcolors[bcol]);
880 p.setBackgroundMode(Qt::OpaqueMode);
881 p.setFont(*prv_font);
882 p.drawText(tx * fm.maxWidth() - ox, (ty + 1) * fm.height() - oy, s,
887 void VGR::WriteLine()
891 if (ty > TEXT_LINES) {
897 void VGR::Point(int x, int y)
902 p.setPen(*lcolors[fcol]);
907 p.setPen(*lcolors[fcol]);
908 p.drawPoint(x - ox, y - oy);
912 void VGR::ClearArea(int x, int y, int w, int h)
916 p.eraseRect(x, y, w, h);
920 p.eraseRect(x - ox, y - oy, w, h);
927 QBrush b(QColor(white));
931 canvas->fill(backgroundColor());
934 p.fillRect(0, 0, width() - 16, height() - 16, backgroundColor());
938 int VGR::Getmap(int w, int h)
942 m = new QPixmap(w, h);
943 bitBlt(m, 0, 0, canvas, curx, cury, w, h);
944 maps.append(new VGRMap(firstfreemap, m));
946 return(firstfreemap - 1);
950 void VGR::Putmap(int map)
955 if (m->number == map) {
956 bitBlt(canvas, curx, cury, m->map, 0, 0,
957 m->map->width(), m->map->height());
958 bitBlt(this, curx - ox, cury - oy, m->map, 0, 0,
959 m->map->width(), m->map->height());
966 void VGR::Outstring(int x, int y, char *s, int b, int f)
969 QFontMetrics fm(*prv_font);
972 p.setPen(*lcolors[f]);
973 p.setBackgroundColor(*lcolors[b]);
974 p.setBackgroundMode(Qt::OpaqueMode);
975 p.setFont(*prv_font);
976 p.drawText(x, y + fm.height(), s, strlen(s));
980 p.setPen(*lcolors[f]);
981 p.setFont(*prv_font);
982 p.setBackgroundColor(*lcolors[b]);
983 p.setBackgroundMode(Qt::OpaqueMode);
984 p.drawText(x - ox, y - oy + fm.height(), s, strlen(s));
989 void VGR::writeintxy(int x, int y, int val,int c)
993 QFontMetrics fm(*prv_font);
995 sprintf(s, "%d", val);
997 p.setPen(*lcolors[c]);
998 p.setFont(*prv_font);
999 p.drawText(x, y, s, strlen(s));
1003 p.setPen(*lcolors[c]);
1004 p.setFont(*prv_font);
1005 p.drawText(x - ox, y - oy + fm.height(), s, strlen(s));
1013 msg.msg_type = MSG_GRAPH;
1014 msg.param.pword[0] = GRAPH_CURPOS_RESPONSE;
1015 msg.param.pword[3] = curx;
1016 msg.param.pword[4] = cury;
1017 write(resp_sock, &msg, sizeof(G_MESSAGE));
1021 void VGR::RequestMessage()
1026 bzero(&m, sizeof(G_MESSAGE));
1027 stat = read(resp_sock, &m, sizeof(G_MESSAGE));
1029 if (m.msg_type == MSG_GRAPH) {
1030 switch(m.param.pword[0]) {
1032 close_btn->setEnabled(TRUE);
1036 case GRAPH_SET_TITLE:
1037 setCaption(m.param.pstr);
1040 if (strcmp(m.param.pstr,"\n") == 0)
1043 WriteText(m.param.pstr);
1053 case GRAPH_READCHAR:
1059 strcpy(internal_buffer, "");
1066 m.msg_type = MSG_GRAPH;
1067 m.param.pword[0] = GRAPH_READLN_RESPONSE;
1068 write(resp_sock, &m, sizeof(G_MESSAGE));
1070 } else if (!GetInput(1))
1074 WriteChar(m.param.pchar);
1104 case GRAPH_FOREGROUND:
1105 SetForeground(m.param.pword[3]);
1107 case GRAPH_BACKGROUND:
1108 SetBackground(m.param.pword[3]);
1111 Point(m.param.pword[3], m.param.pword[4]);
1124 case GRAPH_OUTSTRING:
1133 case GRAPH_WRITEINTXY:
1134 writeintxy(m.param.pword[2], m.param.pword[3],
1135 m.param.pword[4], m.param.pword[5]);
1138 bzero(&mm, sizeof(G_MESSAGE));
1139 mm.msg_type = MSG_GRAPH;
1140 mm.param.pword[0] = GRAPH_GETMAP_RESPONSE;
1141 mm.param.pword[2] = Getmap(m.param.pword[2] - curx, m.param.pword[3] - cury);
1142 mm.param.pword[3] = m.param.pword[2] - curx;
1143 mm.param.pword[4] = m.param.pword[3] - cury;
1144 write(resp_sock, &mm, sizeof(G_MESSAGE));
1147 Putmap(m.param.pword[2]);
1150 curx = m.param.pword[2];
1151 cury = m.param.pword[3];
1153 case GRAPH_MGETPRESS:
1160 if (m.param.pword[1] != 0)
1161 CharXY(curx, cury, (char)m.param.pword[1]);
1163 CharXY(curx, cury, ' ');
1173 void VGR::MagicGraph(G_MESSAGE *msg)
1180 switch(msg->param.pword[1]) {
1183 tx = msg->param.pword[2];
1184 ty = msg->param.pword[3];
1188 fcol = msg->param.pword[2];
1192 bcol = msg->param.pword[2];
1195 prv_font = bold_font;
1198 prv_font = italic_font;
1201 prv_font = normal_font;
1206 /* Draw array_of char (x,y,fcol,bcol) */
1210 fcol = msg->param.pword[4];
1211 bcol = msg->param.pword[5];
1213 msg->param.pword[2],
1214 msg->param.pword[3],
1220 /* Draw int (x,y,int,fcol,bcol) */
1224 fcol = msg->param.pword[5];
1225 bcol = msg->param.pword[6];
1227 msg->param.pword[2],
1228 msg->param.pword[3],
1234 /* Draw char (x,y,char,fcol,bcol) */
1238 fcol = msg->param.pword[5];
1239 bcol = msg->param.pword[6];
1240 CharXY(msg->param.pword[2], msg->param.pword[3],
1241 (char)(msg->param.pword[4]));
1245 /* Draw real (x,y,int,frac,fcol,bcol) */
1249 fcol = msg->param.pword[6];
1250 bcol = msg->param.pword[7];
1251 sprintf(ss, "%d.%d", msg->param.pword[4], msg->param.pword[5]);
1252 TextXY(msg->param.pword[2], msg->param.pword[3], ss);
1256 /* ReadText (x,y,fcol,bcol) */
1260 gfcol = msg->param.pword[4];
1261 gbcol = msg->param.pword[5];
1262 strcpy(internal_buffer, "");
1265 gx = msg->param.pword[2];
1266 gy = msg->param.pword[3];
1272 gfcol = msg->param.pword[4];
1273 gbcol = msg->param.pword[5];
1274 strcpy(internal_buffer, "");
1277 gx = msg->param.pword[2];
1278 gy = msg->param.pword[3];
1282 /* Put image from file (x,y,fname) */
1284 if (p.load(msg->param.pstr)) {
1285 bitBlt(canvas, msg->param.pword[2],
1286 msg->param.pword[3], &p,
1287 0, 0, p.width(), p.height());
1288 bitBlt(this, msg->param.pword[2] - ox,
1289 msg->param.pword[3] - oy, &p,
1290 0, 0, p.width(), p.height());
1295 pmap = maps.first();
1296 while (pmap != NULL) {
1297 if (msg->param.pword[2] == pmap->number) {
1304 /* Line (x1,y1,x2,y2,col) */
1307 fcol = msg->param.pword[6];
1309 msg->param.pword[2], msg->param.pword[3],
1310 msg->param.pword[4], msg->param.pword[5]
1314 /* Rectangle(x1,y1,x2,y2,fcol,icol) */
1317 msg->param.pword[2], msg->param.pword[3],
1318 msg->param.pword[4], msg->param.pword[5],
1319 msg->param.pword[7],
1322 Rect(msg->param.pword[2], msg->param.pword[3],
1323 msg->param.pword[4],msg->param.pword[5],
1324 msg->param.pword[6], 0);
1326 /* ClearArea(x1,y1,w,h) */
1328 ClearArea(msg->param.pword[2],msg->param.pword[3],
1329 msg->param.pword[4], msg->param.pword[5]);
1334 #include "loggraph.moc"
1336 int main(int argc, char **argv)
1338 QApplication app(argc, argv);