3 // Qt Example Application: drawdemo
5 // Demonstrates the painter and the printer.
26 #include <netinet/in.h>
44 #define REQUEST_NAME "gr.req"
52 VGRMap(int n, QPixmap *m) {
58 class VGR : public QFrame {
73 QQueue<int> CharBuffer;
89 void SetForeground(int);
90 void SetBackground(int);
92 void ClearArea(int, int, int, int);
94 void Line(int, int, int, int);
95 void Ellipse(int x, int y, int a, int b, int alfa, int beta, int fill);
96 void Rect(int x1, int y1, int x2, int y2, int col, int fill);
97 void Point(int x, int y);
98 void TextXY(int x, int y, char *s);
99 void CharXY(int x, int y, char a);
100 void IntXY(int x, int y, int val);
102 void WriteText(char *s);
103 void WriteChar(char a);
106 /* Write Char w/o changing position */
107 void PutChar(char a);
110 void Outstring(int x, int y, char *s, int b, int f);
111 void writeintxy(int x, int y, int val, int c);
114 int Getmap(int w, int h);
115 void Putmap(int map);
117 void MagicGraph(G_MESSAGE*);
124 void RequestMessage();
127 virtual void resizeEvent(QResizeEvent *);
128 virtual void closeEvent(QCloseEvent *);
129 virtual void keyPressEvent(QKeyEvent *);
130 virtual void mousePressEvent(QMouseEvent *);
131 virtual void paintEvent(QPaintEvent *);
132 virtual void focusInEvent(QFocusEvent *);
138 QPushButton *close_btn;
139 int ox,oy,lstep,pstep,gx,gy;
145 QSocketNotifier *request;
146 char internal_buffer[256];
150 void VGR::MakeColors()
153 lcolors[0] = new QColor(0, 0, 0);
155 lcolors[1] = new QColor(0, 0, 139);
157 lcolors[2] = new QColor(0, 100, 0);
159 lcolors[3] = new QColor(0, 197, 205);
161 lcolors[4] = new QColor(205, 0, 0);
163 lcolors[5] = new QColor(238, 130, 238);
165 lcolors[6] = new QColor(139,35, 35);
167 lcolors[7] = new QColor(190, 190, 190);
169 lcolors[8] = new QColor(97, 97, 97);
171 lcolors[9] = new QColor(0, 0, 255);
173 lcolors[10] = new QColor(0, 255, 0);
175 lcolors[11] = new QColor(0, 229, 238);
177 lcolors[12] = new QColor(255, 0, 0);
179 lcolors[13] = new QColor(255, 110, 180);
181 lcolors[14] = new QColor(255, 255, 0);
183 lcolors[15] = new QColor(255, 255, 255);
187 * Construct the DrawView with buttons.
189 VGR::VGR(char *sockname)
193 struct sockaddr_un svr;
194 int len, i, optval, on;
196 normal_font = new QFont("lucidatypewriter", 10, QFont::Normal);
197 normal_font->setFixedPitch(TRUE);
198 bold_font = new QFont("lucidatypewriter", 10, QFont::Bold);
199 bold_font->setFixedPitch(TRUE);
200 italic_font = new QFont("lucidatypewriter", 10, QFont::Normal,TRUE);
201 italic_font->setFixedPitch(TRUE);
203 prv_font = normal_font;
206 setCaption("graphic resource");
207 setBackgroundColor(white);
208 canvas = new QPixmap(640, 480);
209 canvas->fill(backgroundColor());
216 maps.setAutoDelete(TRUE);
222 hscroll = new QScrollBar(0, MAXWIDTH, lstep, pstep, 0, QScrollBar::Horizontal, this);
223 vscroll = new QScrollBar(0, MAXHEIGHT, lstep, pstep, 0, QScrollBar::Vertical, this);
224 hscroll->setTracking(TRUE);
225 vscroll->setTracking(TRUE);
228 hscroll->setGeometry(0, height() - 16, width() - 16, 16);
229 vscroll->setGeometry(width() - 16, 0, 16, height() - 16);
231 connect(hscroll, SIGNAL(valueChanged(int)), this, SLOT(hscrolled(int)));
232 connect(vscroll, SIGNAL(valueChanged(int)), this, SLOT(vscrolled(int)));
234 close_btn = new QPushButton(this, "close");
236 if (mp.load("pics/close.bmp"))
237 close_btn->setPixmap(mp);
239 close_btn->setText("C");
241 close_btn->setGeometry(width()-16,height()-16,16,16);
242 close_btn->setEnabled(FALSE);
243 connect(close_btn, SIGNAL(clicked()), this, SLOT(CloseMe()));
248 resp_sock = socket(AF_UNIX, SOCK_STREAM, 0);
249 bzero(&svr, sizeof(svr));
250 svr.sun_family = AF_UNIX;
251 strcpy(svr.sun_path, sockname);
252 len = strlen(svr.sun_path) + sizeof(svr.sun_family);
253 i = ::connect(resp_sock, (struct sockaddr*)&svr, len);
255 fcntl(resp_sock, F_SETFL, O_NONBLOCK |
256 fcntl(resp_sock , F_GETFL, 0));
258 setsockopt(resp_sock, IPPROTO_TCP, TCP_NODELAY, (char*)&on, sizeof(on));
259 request = new QSocketNotifier(resp_sock, QSocketNotifier::Read);
260 connect(request, SIGNAL(activated(int)), this, SLOT(RequestMessage()));
261 optval=TCP_BUFFER_SIZE;
263 setsockopt(resp_sock,SOL_SOCKET,SO_SNDBUF,&optval,sizeof(optval));
264 setsockopt(resp_sock,SOL_SOCKET,SO_RCVBUF,&optval,sizeof(optval));
267 inkey_wait = string_wait = FALSE;
268 char_wait = line_wait = mouse_wait = FALSE;
271 CharBuffer.setAutoDelete(TRUE);
273 setFocusPolicy(QWidget::StrongFocus);
274 hscroll->setRange(0, MAXWIDTH - width() + 20);
275 vscroll->setRange(0, MAXHEIGHT - height() + 20);
276 hscroll->setSteps((int)(hscroll->width() / hscroll->maxValue()),
277 (int)((hscroll->width() / hscroll->maxValue()) * 4));
278 vscroll->setSteps((int)(vscroll->height() / vscroll->maxValue()),
279 (int)((vscroll->height() / vscroll->maxValue()) * 4));
281 setMaximumSize(MAXWIDTH + 16, MAXHEIGHT + 16);
282 setUpdatesEnabled(FALSE);
291 void VGR::paintEvent(QPaintEvent *p)
293 /*if (isUpdatesEnabled()) {*/
294 bitBlt(this, 0, 0, canvas, ox, oy, width() - 16, height() - 16);
299 void VGR::focusInEvent(QFocusEvent *)
301 setUpdatesEnabled(TRUE);
303 setUpdatesEnabled(FALSE);
307 void VGR::resizeEvent( QResizeEvent *ev )
309 hscroll->setGeometry(0, height() - 16, width() - 16, 16);
310 vscroll->setGeometry(width() - 16, 0, 16, height() - 16);
311 close_btn->setGeometry(width() - 16, height() - 16, 16, 16);
312 hscroll->setRange(0, MAXWIDTH - width() + 20);
313 vscroll->setRange(0, MAXHEIGHT - height() + 20);
314 pstep = height() - 32;
315 hscroll->setSteps(lstep, pstep);
316 vscroll->setSteps(lstep, pstep);
319 void VGR::closeEvent(QCloseEvent *ev)
322 QFrame::closeEvent(ev);
325 void VGR::mousePressEvent(QMouseEvent *ev)
330 msg.msg_type = MSG_GRAPH;
331 msg.param.pword[0] = GRAPH_MGETPRESS_RESPONSE;
332 msg.param.pword[2] = ev->pos().x() - ox;
333 msg.param.pword[3] = ev->pos().y() - oy;
334 switch(ev->button()) {
336 msg.param.pword[7] = 1;
339 msg.param.pword[7] = 3;
342 msg.param.pword[7] = 2;
345 msg.param.pword[7] = 0;
348 write(resp_sock, &msg, sizeof(G_MESSAGE));
352 QFrame::mousePressEvent(ev);
356 bool VGR::GetInput(int t)
360 if (!CharBuffer.isEmpty()) {
363 msg.msg_type = MSG_GRAPH;
364 msg.param.pword[0] = GRAPH_INKEY_RESPONSE;
365 msg.param.pword[3] = *(CharBuffer.dequeue());
366 write(resp_sock,&msg,sizeof(G_MESSAGE));
374 msg.msg_type = MSG_GRAPH;
375 msg.param.pword[0] = GRAPH_MAGIC_RESPONSE;
376 msg.param.pword[1] = 0;
378 (char)(*(CharBuffer.dequeue()));
379 WriteChar(msg.param.pchar);
382 msg.msg_type = MSG_GRAPH;
383 msg.param.pword[0] = GRAPH_READCHAR_RESPONSE;
385 (char)(*(CharBuffer.dequeue()));
388 write(resp_sock,&msg,sizeof(G_MESSAGE));
393 while ( ((!CharBuffer.isEmpty()) &&
394 (!(*(CharBuffer.dequeue()) = 13))));
396 if (!CharBuffer.isEmpty()) {
397 msg.msg_type = MSG_GRAPH;
398 msg.param.pword[0] = GRAPH_READLN_RESPONSE;
399 write(resp_sock, &msg, sizeof(G_MESSAGE));
408 if (CharBuffer.isEmpty() && (t == 2)) {
409 msg.msg_type = MSG_GRAPH;
410 msg.param.pword[0] = GRAPH_INKEY_RESPONSE;
411 msg.param.pword[3] = 0;
412 write(resp_sock, &msg, sizeof(G_MESSAGE));
420 void VGR::keyPressEvent(QKeyEvent *ev)
488 if ((!string_wait) && (!inkey_wait) && (!char_wait) && (!line_wait))
489 CharBuffer.enqueue(pom);
493 msg.msg_type = MSG_GRAPH;
494 msg.param.pword[0] = GRAPH_INKEY_RESPONSE;
495 msg.param.pword[3] = *pom;
496 write(resp_sock, &msg, sizeof(G_MESSAGE));
502 msg.msg_type = MSG_GRAPH;
503 msg.param.pword[0] = GRAPH_MAGIC_RESPONSE;
504 msg.param.pword[1] = 0;
505 WriteChar((char)ev->ascii());
508 msg.msg_type = MSG_GRAPH;
509 msg.param.pword[0] = GRAPH_READCHAR_RESPONSE;
511 msg.param.pchar = (char)ev->ascii();
512 write(resp_sock, &msg, sizeof(G_MESSAGE));
516 if ((line_wait) && (ev->ascii() == 13)) {
517 msg.msg_type = MSG_GRAPH;
518 msg.param.pword[0] = GRAPH_READLN_RESPONSE;
519 write(resp_sock, &msg, sizeof(G_MESSAGE));
524 if (ev->ascii() == 13) {
525 internal_buffer[strcnt] = '\0';
529 msg.msg_type = MSG_GRAPH;
530 msg.param.pword[0] = GRAPH_MAGIC_RESPONSE;
531 msg.param.pword[1] = 0;
533 msg.msg_type = MSG_GRAPH;
534 msg.param.pword[0] = GRAPH_READSTR_RESPONSE;
536 strcpy(msg.param.pstr, internal_buffer);
537 write(resp_sock, &msg, sizeof(G_MESSAGE));
542 else if (ev->ascii() == 8) {
548 internal_buffer[strcnt] = (char)ev->ascii();
551 WriteChar((char)ev->ascii());
565 void VGR::hscrolled(int val)
568 setUpdatesEnabled(TRUE);
570 setUpdatesEnabled(FALSE);
573 void VGR::vscrolled(int val)
576 setUpdatesEnabled(TRUE);
578 setUpdatesEnabled(FALSE);
582 /****************************************/
584 void VGR::SetForeground(int col)
589 void VGR::SetBackground(int col)
594 void VGR::Line(int x1, int y1, int x2, int y2)
598 p.setPen(*lcolors[fcol]);
599 p.drawLine(x1, y1, x2, y2);
603 p.setPen(*lcolors[fcol]);
604 p.drawLine(x1 - ox, y1 - oy, x2 - ox, y2 - oy);
608 void VGR::Ellipse(int x, int y, int a, int b, int alfa, int beta, int fill)
613 p.setPen(*lcolors[fcol]);
614 p.setBrush(*lcolors[fcol]);
616 p.drawPie(x, y, a, b, alfa * 16, (beta - alfa) * 16);
618 p.drawArc(x, y, a, b, alfa * 16, (beta - alfa) * 16);
623 p.setPen(*lcolors[fcol]);
624 p.setBrush(*lcolors[fcol]);
626 p.drawPie(x - ox, y - oy, a, b, alfa * 16, (beta - alfa) * 16);
628 p.drawArc(x - ox, y - oy, a, b, alfa * 16, (beta - alfa) * 16);
633 void VGR::Rect(int x1, int y1, int x2, int y2,int col, int fill)
636 QBrush b(*lcolors[col]);
638 p.setPen(*lcolors[col]);
640 p.fillRect(x1 , y1 , x2 - x1, y2 - y1, b);
642 p.drawRect(x1,y1,x2-x1,y2-y1);
647 p.setPen(*lcolors[col]);
649 p.fillRect(x1 - ox, y1 - oy, x2 - x1, y2 - y1, b);
651 p.drawRect(x1 - ox, y1 - oy, x2 - x1, y2 - y1);
655 void VGR::TextXY(int x, int y, char *s)
658 QFontMetrics fm(*prv_font);
661 p.setPen(*lcolors[fcol]);
662 p.setBackgroundColor(*lcolors[bcol]);
663 p.setBackgroundMode(OpaqueMode);
664 p.setFont(*prv_font);
665 p.drawText(x, y + fm.height(), s, strlen(s));
670 p.setPen(*lcolors[fcol]);
671 p.setBackgroundColor(*lcolors[bcol]);
672 p.setBackgroundMode(OpaqueMode);
673 p.setFont(*prv_font);
674 p.drawText(x - ox, y - oy + fm.height(), s, strlen(s));
679 void VGR::CharXY(int x, int y, char a)
683 QFontMetrics fm(*prv_font);
688 p.setPen(*lcolors[fcol]);
689 p.setBackgroundColor(*lcolors[bcol]);
690 p.setBackgroundMode(OpaqueMode);
691 p.setFont(*prv_font);
692 p.drawText(x , y + fm.height(), s, strlen(s));
696 p.setPen(*lcolors[fcol]);
697 p.setBackgroundColor(*lcolors[bcol]);
698 p.setBackgroundMode(OpaqueMode);
699 p.setFont(*prv_font);
700 p.drawText(x - ox, y - oy + fm.height(), s, strlen(s));
705 void VGR::IntXY(int x, int y, int val)
709 QFontMetrics fm(*prv_font);
711 sprintf(s, "%d", val);
713 p.setPen(*lcolors[fcol]);
714 p.setBackgroundColor(*lcolors[bcol]);
715 p.setBackgroundMode(OpaqueMode);
716 p.setFont(*prv_font);
717 p.drawText(x, y + fm.height(), s, strlen(s));
721 p.setPen(*lcolors[fcol]);
722 p.setBackgroundColor(*lcolors[bcol]);
723 p.setBackgroundMode(OpaqueMode);
724 p.setFont(*prv_font);
725 p.drawText(x - ox, y - oy + fm.height(), s, strlen(s));
729 void VGR::WriteText(char *s)
732 QFontMetrics fm(*prv_font);
735 p.setPen(*lcolors[fcol]);
736 p.setBackgroundColor(*lcolors[bcol]);
737 p.setBackgroundMode(OpaqueMode);
738 p.setFont(*prv_font);
739 p.drawText(tx * fm.maxWidth(), (ty + 1) * fm.height(), s, strlen(s));
743 p.setPen(*lcolors[fcol]);
744 p.setBackgroundColor(*lcolors[bcol]);
745 p.setBackgroundMode(OpaqueMode);
746 p.setFont(*prv_font);
747 p.drawText(tx * fm.maxWidth() - ox, (ty + 1) * fm.height() - oy, s,
752 if (tx > TEXT_COLS) {
756 if (ty > TEXT_LINES) {
761 void VGR::WriteChar(char a)
764 QFontMetrics fm(*prv_font);
772 p.setPen(*lcolors[gfcol]);
773 p.setBackgroundColor(*lcolors[gbcol]);
774 p.setBackgroundMode(OpaqueMode);
775 p.setFont(*prv_font);
776 p.drawText(gx, gy + fm.height(), s, strlen(s));
780 p.setPen(*lcolors[gfcol]);
781 p.setBackgroundColor(*lcolors[gbcol]);
782 p.setBackgroundMode(OpaqueMode);
783 p.setFont(*prv_font);
784 p.drawText(gx - ox, gy - oy + fm.height(), s, strlen(s));
787 gx = gx + strlen(s) * fm.maxWidth();
789 gy = gy + fm.height();
792 if (gy > MAXHEIGHT) {
797 p.setPen(*lcolors[fcol]);
798 p.setBackgroundColor(*lcolors[bcol]);
799 p.setBackgroundMode(OpaqueMode);
800 p.setFont(*prv_font);
801 p.drawText(tx * fm.maxWidth(), (ty + 1) * fm.height(), s,
806 p.setPen(*lcolors[fcol]);
807 p.setBackgroundColor(*lcolors[bcol]);
808 p.setBackgroundMode(OpaqueMode);
809 p.setFont(*prv_font);
810 p.drawText(tx * fm.maxWidth() - ox, (ty + 1) * fm.height() - oy,
815 if (tx > TEXT_COLS) {
819 if (ty > TEXT_LINES) {
828 QFontMetrics fm(*prv_font);
832 p.setPen(*lcolors[fcol]);
833 p.fillRect(gx - fm.maxWidth(), gy, fm.maxWidth(),
834 fm.height() + fm.descent() + 1, *lcolors[bcol]);
838 p.setPen(*lcolors[fcol]);
840 p.fillRect(gx - ox - fm.maxWidth(), gy - oy, fm.maxWidth(),
841 fm.height() + fm.descent() + 1, *lcolors[bcol]);
843 gx = gx - fm.maxWidth();
847 p.setPen(*lcolors[fcol]);
848 p.fillRect((tx - 1) * fm.maxWidth(), (ty) * fm.height(),
850 (ty + 1) * fm.height() + fm.descent() + 1,
855 p.setPen(*lcolors[fcol]);
856 p.fillRect((tx - 1) * fm.maxWidth() - ox, (ty) * fm.height() - oy,
858 (ty + 1) * fm.height() + fm.descent() + 1,
868 void VGR::PutChar(char a)
871 QFontMetrics fm(*prv_font);
877 p.setPen(*lcolors[fcol]);
878 p.setBackgroundColor(*lcolors[bcol]);
879 p.setBackgroundMode(OpaqueMode);
880 p.setFont(*prv_font);
881 p.drawText(tx * fm.maxWidth(), (ty + 1) * fm.height(), s, strlen(s));
885 p.setPen(*lcolors[fcol]);
886 p.setBackgroundColor(*lcolors[bcol]);
887 p.setBackgroundMode(OpaqueMode);
888 p.setFont(*prv_font);
889 p.drawText(tx * fm.maxWidth() - ox, (ty + 1) * fm.height() - oy, s,
894 void VGR::WriteLine()
898 if (ty > TEXT_LINES) {
904 void VGR::Point(int x, int y)
909 p.setPen(*lcolors[fcol]);
914 p.setPen(*lcolors[fcol]);
915 p.drawPoint(x - ox, y - oy);
919 void VGR::ClearArea(int x, int y, int w, int h)
923 p.eraseRect(x, y, w, h);
927 p.eraseRect(x - ox, y - oy, w, h);
934 QBrush b(QColor(white));
938 canvas->fill(backgroundColor());
941 p.fillRect(0, 0, width() - 16, height() - 16, backgroundColor());
945 int VGR::Getmap(int w, int h)
949 m = new QPixmap(w, h);
950 bitBlt(m, 0, 0, canvas, curx, cury, w, h);
951 maps.append(new VGRMap(firstfreemap, m));
953 return(firstfreemap - 1);
957 void VGR::Putmap(int map)
962 if (m->number == map) {
963 bitBlt(canvas, curx, cury, m->map, 0, 0,
964 m->map->width(), m->map->height());
965 bitBlt(this, curx - ox, cury - oy, m->map, 0, 0,
966 m->map->width(), m->map->height());
973 void VGR::Outstring(int x, int y, char *s, int b, int f)
976 QFontMetrics fm(*prv_font);
979 p.setPen(*lcolors[f]);
980 p.setBackgroundColor(*lcolors[b]);
981 p.setBackgroundMode(OpaqueMode);
982 p.setFont(*prv_font);
983 p.drawText(x, y + fm.height(), s, strlen(s));
987 p.setPen(*lcolors[f]);
988 p.setFont(*prv_font);
989 p.setBackgroundColor(*lcolors[b]);
990 p.setBackgroundMode(OpaqueMode);
991 p.drawText(x - ox, y - oy + fm.height(), s, strlen(s));
996 void VGR::writeintxy(int x, int y, int val,int c)
1000 QFontMetrics fm(*prv_font);
1002 sprintf(s, "%d", val);
1004 p.setPen(*lcolors[c]);
1005 p.setFont(*prv_font);
1006 p.drawText(x, y, s, strlen(s));
1010 p.setPen(*lcolors[c]);
1011 p.setFont(*prv_font);
1012 p.drawText(x - ox, y - oy + fm.height(), s, strlen(s));
1020 msg.msg_type = MSG_GRAPH;
1021 msg.param.pword[0] = GRAPH_CURPOS_RESPONSE;
1022 msg.param.pword[3] = curx;
1023 msg.param.pword[4] = cury;
1024 write(resp_sock, &msg, sizeof(G_MESSAGE));
1028 void VGR::RequestMessage()
1033 bzero(&m, sizeof(G_MESSAGE));
1034 stat = read(resp_sock, &m, sizeof(G_MESSAGE));
1036 if (m.msg_type == MSG_GRAPH) {
1037 switch(m.param.pword[0]) {
1039 close_btn->setEnabled(TRUE);
1043 case GRAPH_SET_TITLE:
1044 setCaption(m.param.pstr);
1047 if (strcmp(m.param.pstr,"\n") == 0)
1050 WriteText(m.param.pstr);
1054 TextXY(m.param.pword[3], m.param.pword[4],
1057 case GRAPH_READCHAR:
1063 strcpy(internal_buffer, "");
1070 m.msg_type = MSG_GRAPH;
1071 m.param.pword[0] = GRAPH_READLN_RESPONSE;
1072 write(resp_sock, &m, sizeof(G_MESSAGE));
1074 } else if (!GetInput(1))
1078 WriteChar(m.param.pchar);
1081 Line(curx,cury, m.param.pword[3],
1085 Ellipse(m.param.pword[3], m.param.pword[4],
1086 m.param.pword[5], m.param.pword[6],
1087 m.param.pword[7], m.param.pword[8],
1091 Rect(m.param.pword[3], m.param.pword[4],
1092 m.param.pword[5], m.param.pword[6],
1093 m.param.pword[7], m.param.pword[8]);
1095 case GRAPH_FOREGROUND:
1096 SetForeground(m.param.pword[3]);
1098 case GRAPH_BACKGROUND:
1099 SetBackground(m.param.pword[3]);
1102 Point(m.param.pword[3], m.param.pword[4]);
1115 case GRAPH_OUTSTRING:
1116 Outstring(m.param.pword[2], m.param.pword[3],
1117 m.param.pstr, m.param.pword[4],
1120 case GRAPH_WRITEINTXY:
1121 writeintxy(m.param.pword[2], m.param.pword[3],
1122 m.param.pword[4], m.param.pword[5]);
1125 bzero(&mm, sizeof(G_MESSAGE));
1126 mm.msg_type = MSG_GRAPH;
1127 mm.param.pword[0] = GRAPH_GETMAP_RESPONSE;
1128 mm.param.pword[2] = Getmap(m.param.pword[2] - curx, m.param.pword[3] - cury);
1129 mm.param.pword[3] = m.param.pword[2] - curx;
1130 mm.param.pword[4] = m.param.pword[3] - cury;
1131 write(resp_sock, &mm, sizeof(G_MESSAGE));
1134 Putmap(m.param.pword[2]);
1137 curx = m.param.pword[2];
1138 cury = m.param.pword[3];
1140 case GRAPH_MGETPRESS:
1147 if (m.param.pword[1] != 0)
1148 CharXY(curx, cury, (char)m.param.pword[1]);
1150 CharXY(curx, cury, ' ');
1160 void VGR::MagicGraph(G_MESSAGE *msg)
1167 switch(msg->param.pword[1]) {
1170 tx = msg->param.pword[2];
1171 ty = msg->param.pword[3];
1175 fcol = msg->param.pword[2];
1179 bcol = msg->param.pword[2];
1182 prv_font = bold_font;
1185 prv_font = italic_font;
1188 prv_font = normal_font;
1193 /* Draw array_of char (x,y,fcol,bcol) */
1197 fcol = msg->param.pword[4];
1198 bcol = msg->param.pword[5];
1199 TextXY(msg->param.pword[2], msg->param.pword[3], msg->param.pstr);
1203 /* Draw int (x,y,int,fcol,bcol) */
1207 fcol = msg->param.pword[5];
1208 bcol = msg->param.pword[6];
1209 IntXY(msg->param.pword[2], msg->param.pword[3], msg->param.pword[4]);
1213 /* Draw char (x,y,char,fcol,bcol) */
1217 fcol = msg->param.pword[5];
1218 bcol = msg->param.pword[6];
1219 CharXY(msg->param.pword[2], msg->param.pword[3],
1220 (char)(msg->param.pword[4]));
1224 /* Draw real (x,y,int,frac,fcol,bcol) */
1228 fcol = msg->param.pword[6];
1229 bcol = msg->param.pword[7];
1230 sprintf(ss, "%d.%d", msg->param.pword[4], msg->param.pword[5]);
1231 TextXY(msg->param.pword[2], msg->param.pword[3], ss);
1235 /* ReadText (x,y,fcol,bcol) */
1239 gfcol = msg->param.pword[4];
1240 gbcol = msg->param.pword[5];
1241 strcpy(internal_buffer, "");
1244 gx = msg->param.pword[2];
1245 gy = msg->param.pword[3];
1251 gfcol = msg->param.pword[4];
1252 gbcol = msg->param.pword[5];
1253 strcpy(internal_buffer, "");
1256 gx = msg->param.pword[2];
1257 gy = msg->param.pword[3];
1261 /* Put image from file (x,y,fname) */
1263 if (p.load(msg->param.pstr)) {
1264 bitBlt(canvas, msg->param.pword[2],
1265 msg->param.pword[3], &p,
1266 0, 0, p.width(), p.height());
1267 bitBlt(this, msg->param.pword[2] - ox,
1268 msg->param.pword[3] - oy, &p,
1269 0, 0, p.width(), p.height());
1274 pmap = maps.first();
1275 while (pmap != NULL) {
1276 if (msg->param.pword[2] == pmap->number) {
1283 /* Line (x1,y1,x2,y2,col) */
1286 fcol = msg->param.pword[6];
1287 Line(msg->param.pword[2], msg->param.pword[3],
1288 msg->param.pword[4], msg->param.pword[5]);
1291 /* Rectangle(x1,y1,x2,y2,fcol,icol) */
1293 Rect(msg->param.pword[2], msg->param.pword[3],
1294 msg->param.pword[4], msg->param.pword[5],
1295 msg->param.pword[7], 1);
1296 Rect(msg->param.pword[2], msg->param.pword[3],
1297 msg->param.pword[4],msg->param.pword[5],
1298 msg->param.pword[6], 0);
1300 /* ClearArea(x1,y1,w,h) */
1302 ClearArea(msg->param.pword[2],msg->param.pword[3],
1303 msg->param.pword[4], msg->param.pword[5]);
1308 #include "loggraph.moc"
1310 int main(int argc, char **argv)
1312 QApplication app(argc, argv);
1314 app.setMainWidget(&gs);