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

Fixed printing in QT

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