Commit d29f44c3 authored by Christoffer Ackelman's avatar Christoffer Ackelman

QT: Fixed off-by-one error in text drawing function.

parent f8149f1d
......@@ -586,10 +586,6 @@ XttQt::XttQt(int argc, char* argv[], int* return_sts)
char title[120] = "Xtt ";
char nodename[80];
if (EVEN(*return_sts)) {
return;
}
setlocale(LC_TIME, "en_US");
setlocale(LC_NUMERIC, "POSIX");
......@@ -722,7 +718,7 @@ XttQt::XttQt(int argc, char* argv[], int* return_sts)
cmd_recall = new CoWowRecall();
value_recall = new CoWowRecall();
cmd_entry = new CoWowEntryQt(cmd_recall);
QObject::connect(cmd_entry, SIGNAL(editing_finished()), toplevel,
QObject::connect(cmd_entry, SIGNAL(returnPressed()), toplevel,
SLOT(valchanged_cmd_entry()));
statusbar->addWidget(msg_label);
......
......@@ -253,7 +253,7 @@ class CoWowQtObject : public QObject {
Q_OBJECT
public:
CoWowQtObject(QWidget* parent) : QObject(parent), parent_wid(parent)
CoWowQtObject(QWidget* parent) : QObject(), parent_wid(parent)
{
}
QWidget* parent_wid;
......
......@@ -56,8 +56,6 @@
#define DRAW_PRESS_PIX 9
#define roundi(x) ((x) >= 0 ? (int)((x) + 0.5) : (int)((x)-0.5))
typedef struct {
QWidget* w;
int x;
......@@ -882,10 +880,10 @@ int FlowDrawQt::rect_helper(FlowCtx* ctx, int painter_type, int size, int x,
QPainter* painter = get_painter(painter_type, size, nav);
if (fill) {
// debug_print("fillRect [%d, %d, %d, %d]\n", x, y, width, height);
// debug_print("fillRect [%d, %d, %d, %d] painter_type=%d, with color %s\n", x, y, width, height, painter_type, qPrintable(painter->brush().color().name()));
painter->fillRect(x, y, width, height, painter->brush());
} else {
// debug_print("drawRect [%d, %d, %d, %d]\n", x, y, width, height);
// debug_print("drawRect [%d, %d, %d, %d] pen %s brush %s\n", x, y, width, height, qPrintable(painter->pen().color().name()), qPrintable(painter->brush().color().name()));
painter->setBrush(Qt::NoBrush);
painter->drawRect(x, y, width, height);
}
......@@ -1239,21 +1237,13 @@ int FlowDrawQt::text_pango_helper(FlowCtx* ctx, int x, int y, char* text,
int height = rect.height();
if (erase_rect > 0) {
// debug_print("eraseRect [%d, %d, %d, %d], color=%s\n", x, roundi(y - 0.8 *
// height), rect.width(), roundi(height * (erase_rect / 10.0)),
// painter->background().color().name().toAscii().data());
painter->eraseRect(x, roundi(y - 0.8 * height), rect.width(),
roundi(height * (erase_rect / 10.0)));
// debug_print("eraseRect [%d,%d,%d,%d]\n", x, ROUND(y - 0.8 * height), rect.width() + 1, ROUND(height * (erase_rect / 10.0)));
painter->eraseRect(x, ROUND(y - 0.8 * height), rect.width() + 1, ROUND(height * (erase_rect / 10.0)));
}
if (erase_rect < 12) {
// debug_print("drawText %s at (%d, %d), painter_type=%d, brush=%s, pen=%s,
// background=%s\n", text, x, roundi(y - 0.8 * height), painter_type,
// painter->brush().color().name().toAscii().data(),
// painter->pen().color().name().toAscii().data(),
// background.name().toAscii().data());
painter->drawText(x, roundi(y - 0.8 * height), rect.width(), height,
Qt::TextDontClip, str);
// debug_print("drawText %s at [%d,%d,%d,%d]\n", text, x, ROUND(y - 0.8 * height), rect.width(), height);
painter->drawText(x, ROUND(y - 0.8 * height), rect.width(), height, Qt::TextDontClip, str, &rect);
}
delete painter;
......@@ -1550,8 +1540,7 @@ void FlowDrawQt::clear(FlowCtx* ctx)
QPainter* painter = new QPainter(window_canvas);
painter->setBackground(QBrush(background));
// debug_print("clear color=%s\n",
// painter->background().color().name().toAscii().data());
// debug_print("clear color=%s\n", painter->background().color().name().toAscii().data());
painter->eraseRect(window_canvas->rect());
delete painter;
......@@ -1566,8 +1555,7 @@ void FlowDrawQt::nav_clear(FlowCtx* ctx)
QPainter* painter = new QPainter(nav_window_canvas);
painter->setBackground(QBrush(background));
// debug_print("nav_clear color=%s\n",
// painter->background().color().name().toAscii().data());
// debug_print("nav_clear color=%s\n\n", painter->background().color().name().toAscii().data());
painter->eraseRect(nav_window_canvas->rect());
delete painter;
......@@ -1787,8 +1775,7 @@ void FlowDrawQt::clear_area(
QPainter* painter = new QPainter(window_canvas);
painter->setBackground(QBrush(background));
// debug_print("clear_area [%d, %d, %d, %d], color=%s\n", ll_x, ll_y, ur_x -
// ll_x, ur_y - ll_y, painter->background().color().name().toAscii().data());
// debug_print("clear_area [%d, %d, %d, %d], color=%s\n", ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, painter->background().color().name().toAscii().data());
painter->eraseRect(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y);
delete painter;
......
......@@ -953,9 +953,7 @@ int GlowDrawQt::rect_helper(GlowWind* wind, int painter_type, int size, int x,
}
if (fill) {
// debug_print("fillRect [%d, %d, %d, %d] painter_type=%d, with color %s\n",
// x, y, width, height, painter_type,
// qPrintable(painter->brush().color().name()));
// debug_print("fillRect [%d, %d, %d, %d] painter_type=%d, with color %s\n", x, y, width, height, painter_type, qPrintable(painter->brush().color().name()));
painter->fillRect(x, y, width, height, painter->brush());
} else {
// debug_print("drawRect [%d, %d, %d, %d]\n", x, y, width, height);
......@@ -1716,6 +1714,8 @@ void GlowDrawQt::copy_area(GlowWind* wind, int x, int y)
window_height = ctx->navw.window_height;
}
// debug_print("copy_area [%d, %d, %d, %d]\n", x, y, window_width, window_height);
QPainter* painterBuffer
= get_painter(w->buffer, this, glow_eDrawType_Line, 3);
if (x >= 0 && y >= 0) {
......@@ -1767,7 +1767,14 @@ void GlowDrawQt::clear_area(
}
DrawWindQt* w = (DrawWindQt*)wind->window;
QPainter(w->buffer).eraseRect(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y);
QPainter* painter = new QPainter(w->buffer);
painter->setBackground(QBrush(background));
// debug_print("clear_area [%d, %d, %d, %d], color=%s\n", ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, painter->background().color().name().toAscii().data());
painter->eraseRect(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y);
delete painter;
}
void GlowDrawQt::set_inputfocus(GlowWind* wind)
......
......@@ -75,9 +75,9 @@ XttMethodToolbarQt::~XttMethodToolbarQt()
delete object;
}
void XttMethodToolbarQtObject::activate_button(QAction* action)
void XttMethodToolbarQtObject::activate_button()
{
int idx = action->data().toInt();
int idx = ((QAction *) sender())->data().toInt();
int sts = 0;
int is_attr;
......
......@@ -80,7 +80,7 @@ public:
}
public slots:
void activate_button(QAction* action);
void activate_button();
void set_sensitive_cb();
private:
......
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