Commit 5dcb0632 authored by Christoffer Ackelman's avatar Christoffer Ackelman

Fixed printing in QT

parent 279b1f38
......@@ -129,7 +129,8 @@ void WbBckWQt::print()
pwr_tStatus sts;
CoWowQt::CreateBrowPrintDialogQt(name, bckwnav->brow->ctx,
flow_eOrientation_Portrait, 1.0, this, &sts);
flow_eOrientation_Portrait, 1.0,
toplevel, &sts);
}
void WbBckWQtWidget::focusInEvent(QFocusEvent *event)
......
......@@ -136,7 +136,8 @@ void WbExpWQt::print()
pwr_tStatus sts;
CoWowQt::CreateBrowPrintDialogQt(name, expwnav->brow->ctx,
flow_eOrientation_Portrait, 1.0, this, &sts);
flow_eOrientation_Portrait, 1.0, toplevel,
&sts);
}
void WbExpWQtWidget::focusInEvent(QFocusEvent *event)
......
......@@ -97,8 +97,8 @@ void WFoeQtWidget::activate_printdialog()
{
pwr_tStatus sts;
CoWowQt::CreateFlowPrintDialogQt("PlcEditor", foe->gre->flow_ctx,
flow_eOrientation_Landscape, 1.0, this,
&sts);
flow_eOrientation_Landscape, 1.0,
this, &sts);
}
void WFoeQtWidget::activate_createobject()
......
......@@ -194,7 +194,7 @@ void WAttQt::print(const char *title)
CoWowQt::CreateBrowPrintDialogQt(title, wattnav->brow->ctx,
flow_eOrientation_Portrait, 1.0,
(void *) this, &sts);
toplevel, &sts);
}
void WAttQt::change_value_close()
......
......@@ -99,7 +99,7 @@ void WCrrQt::print()
CoWowQt::CreateBrowPrintDialogQt(title, xcrrnav->brow->ctx,
flow_eOrientation_Portrait, 1.0,
(void *) this, &sts);
toplevel, &sts);
}
void WCrrQtWidget::closeEvent(QCloseEvent *event)
......
......@@ -102,7 +102,7 @@ void CoLogWQt::print()
CoWowQt::CreateBrowPrintDialogQt(name, logwnav->brow->ctx,
flow_eOrientation_Portrait, 1.0,
(void *) this, &sts);
toplevel, &sts);
}
void CoLogWQtWidget::focusInEvent(QFocusEvent *event)
......
......@@ -147,7 +147,7 @@ void MsgWindowQt::print()
CoWowQt::CreateBrowPrintDialogQt(title, msgnav->brow->ctx,
flow_eOrientation_Landscape, 1.4,
(void *) this, &sts);
toplevel, &sts);
}
void MsgWindowQtWidget::focusInEvent(QFocusEvent *event)
......
......@@ -174,7 +174,7 @@ void CoXHelpQt::print()
CoWowQt::CreateBrowPrintDialogQt(title, xhelpnav->brow->ctx,
flow_eOrientation_Portrait, 0.7,
(void *) this, &sts);
toplevel, &sts);
}
void CoXHelpQtWidget::closeEvent(QCloseEvent *event)
......
......@@ -57,6 +57,7 @@ FlowPrintDrawQt::FlowPrintDrawQt(void *context, const char *t, int p,
print_margin_x = 10;
print_margin_y = 10;
}
print_margin_x = print_margin_y = 0;
*sts = 1;
}
......@@ -77,6 +78,7 @@ int FlowPrintDrawQt::print_page(double ll_x, double ll_y, double ur_x,
print_margin_y = 10;
}
}
print_margin_x = print_margin_y = 0;
if (ur_x - ll_x > ur_y - ll_y) {
ctx->print_zoom_factor = 730 / (ur_x - ll_x);
......@@ -104,7 +106,6 @@ int FlowPrintDrawQt::print_page(double ll_x, double ll_y, double ur_x,
sprintf(page_str, "Page %d", page + 1);
painter->drawText(print_margin_x + width - 90, print_margin_y - height,
fl(page_str));
painter->drawText(print_margin_x, print_margin_y - height, fl(title));
}
......@@ -134,6 +135,7 @@ int FlowPrintDrawQt::rect(double x, double y, double width, double height,
pen.setWidth(0.5 * idx);
painter->setPen(pen);
painter->setBrush(Qt::NoBrush);
painter->drawRect(print_margin_x + x - page_x, print_margin_y + y - page_y,
width, height);
......@@ -143,27 +145,22 @@ int FlowPrintDrawQt::rect(double x, double y, double width, double height,
int FlowPrintDrawQt::filled_rect(double x, double y, double width,
double height, flow_eDrawType type, double idx)
{
QBrush brush = painter->brush();
switch (type) {
case flow_eDrawType_LineRed:
brush.setColor(QColor::fromRgbF(1, 0, 0));
painter->setBrush(QBrush(QColor::fromRgbF(1, 0, 0)));
break;
case flow_eDrawType_Green:
brush.setColor(QColor::fromRgbF(0, 1, 0));
painter->setBrush(QBrush(QColor::fromRgbF(0, 1, 0)));
break;
case flow_eDrawType_Yellow:
brush.setColor(QColor::fromRgbF(1, 1, 0));
painter->setBrush(QBrush(QColor::fromRgbF(1, 1, 0)));
break;
case flow_eDrawType_DarkGray:
brush.setColor(QColor::fromRgbF(0.3, 0.3, 0.3));
painter->setBrush(QBrush(QColor::fromRgbF(0.3, 0.3, 0.3)));
break;
default:
brush.setColor(QColor::fromRgbF(0, 0, 0));
painter->setBrush(QBrush(QColor::fromRgbF(0, 0, 0)));
}
painter->setBrush(brush);
painter->fillRect(print_margin_x + x - page_x, print_margin_y + y - page_y,
width, height, painter->brush());
QPen pen = QPen(QColor::fromRgbF(0, 0, 0));
pen.setWidth(0.5 * idx);
......@@ -251,16 +248,17 @@ int FlowPrintDrawQt::line(double x1, double y1, double x2, double y2,
int FlowPrintDrawQt::text(double x, double y, char *text, int len,
flow_eDrawType type, double size, int line)
{
char font[40];
QFont font;
switch (type) {
case flow_eDrawType_TextHelvetica:
sprintf(font, "Lucida Sans %3.1f", 1.0 * size);
font = QFont(fl("Lucida Sans"), -1);
break;
case flow_eDrawType_TextHelveticaBold:
sprintf(font, "Lucida Sans Bold %3.1f", 1.0 * size);
font = QFont(fl("Lucida Sans"), -1, QFont::Bold);
break;
default:;
}
font.setPointSizeF(size);
char *s;
for (s = text; *s; s++) {
......@@ -272,14 +270,11 @@ int FlowPrintDrawQt::text(double x, double y, char *text, int len,
if (s - text > 0) {
QString textutf8 = QString::fromLatin1(text, s - text);
painter->setFont(fl(font));
QBrush target = painter->brush();
target.setColor(QColor::fromRgbF(0, 0, 0));
painter->setBrush(target);
painter->setFont(font);
painter->setBrush(QBrush(QColor::fromRgbF(0, 0, 0)));
painter->drawText(print_margin_x + x - page_x,
print_margin_y + y - page_y - 0.8 / 1024 * size * 1093 +
0.4 / 1024 * size * 1093 * line, textutf8);
print_margin_y + y - page_y, textutf8);
}
return 1;
......@@ -318,12 +313,15 @@ int FlowPrintDrawQt::arrow(double x1, double y1, double x2, double y2,
switch (type) {
case flow_eDrawType_LineRed:
painter->setPen(QColor::fromRgbF(1, 0, 0));
painter->setBrush(QBrush(QColor::fromRgbF(1, 0, 0)));
break;
case flow_eDrawType_LineGray:
painter->setPen(QColor::fromRgbF(0.7, 0.7, 0.7));
painter->setBrush(QBrush(QColor::fromRgbF(0.7, 0.7, 0.7)));
break;
default:
painter->setPen(QColor::fromRgbF(0, 0, 0));
painter->setBrush(QBrush(QColor::fromRgbF(0, 0, 0)));
break;
}
......
......@@ -117,7 +117,7 @@ void EvListQt::print(const char *title)
}
CoWowQt::CreateBrowPrintDialogQt(print_title, brow->ctx,
flow_eOrientation_Landscape, 1.0, 0, &sts);
flow_eOrientation_Landscape, 1.0, form_widget, &sts);
if (sts == WOW__PRINTDIALOGDISABLED) {
pwr_tFileName filename;
pwr_tCmd cmd;
......
......@@ -302,7 +302,7 @@ void XAttQt::print()
CoWowQt::CreateBrowPrintDialogQt(title, xattnav->brow->ctx,
flow_eOrientation_Portrait, 1.0,
(void *) this, &sts);
toplevel, &sts);
}
void XAttQtWidget::closeEvent(QCloseEvent *event)
......
......@@ -97,7 +97,7 @@ void XCrrQt::print()
CoWowQt::CreateBrowPrintDialogQt(title, xcrrnav->brow->ctx,
flow_eOrientation_Portrait, 1.0,
(void *) this, &sts);
toplevel, &sts);
}
void XCrrQtWidget::closeEvent(QCloseEvent *event)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment