From d9076c62ed0cab20ca1b70d720fddc4c905ffac5 Mon Sep 17 00:00:00 2001 From: John Levon Date: Thu, 28 Nov 2002 18:07:39 +0000 Subject: [PATCH] Juergen's tabular patch. Yay ! git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5745 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt2/ChangeLog | 7 +++ src/frontends/qt2/QTabular.C | 59 ++++++++++++++++-- src/frontends/qt2/QTabularDialog.C | 2 - src/frontends/qt2/qsetborder.C | 99 ++++++++++++++++++++++-------- src/frontends/qt2/qsetborder.h | 22 +++++-- 5 files changed, 152 insertions(+), 37 deletions(-) diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index 1fa2e960b2..bf4cb4270f 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,10 @@ +2002-11-28 Juergen Spitzmueller + + * qsetborder.[Ch]: implement John's setEnabled bool + + * QTabular.C: + * QTabularDialog.C: remaining fixes. + 2002-11-28 John Levon * QSpellcheckerDialog.C: fix Escape + restarting spellcheck diff --git a/src/frontends/qt2/QTabular.C b/src/frontends/qt2/QTabular.C index 41a2633fb7..b4b7cd498f 100644 --- a/src/frontends/qt2/QTabular.C +++ b/src/frontends/qt2/QTabular.C @@ -46,7 +46,37 @@ void QTabular::build_dialog() bc().setCancel(dialog_->closePB); - // FIXME: add widgets to read only + bc().addReadOnly(dialog_->multicolumnCB); + bc().addReadOnly(dialog_->rotateCellCB); + bc().addReadOnly(dialog_->rotateTabularCB); + bc().addReadOnly(dialog_->specialAlignmentED); + bc().addReadOnly(dialog_->widthED); + bc().addReadOnly(dialog_->widthUnit); + bc().addReadOnly(dialog_->hAlignCB); + bc().addReadOnly(dialog_->vAlignCB); + bc().addReadOnly(dialog_->columnAddPB); + bc().addReadOnly(dialog_->columnDeletePB); + bc().addReadOnly(dialog_->rowAddPB); + bc().addReadOnly(dialog_->rowDeletePB); + bc().addReadOnly(dialog_->borderSetPB); + bc().addReadOnly(dialog_->borderUnsetPB); + bc().addReadOnly(dialog_->borders); + bc().addReadOnly(dialog_->longTabularCB); + bc().addReadOnly(dialog_->headerStatusCB); + bc().addReadOnly(dialog_->headerBorderAboveCB); + bc().addReadOnly(dialog_->headerBorderBelowCB); + bc().addReadOnly(dialog_->firstheaderStatusCB); + bc().addReadOnly(dialog_->firstheaderBorderAboveCB); + bc().addReadOnly(dialog_->firstheaderBorderBelowCB); + bc().addReadOnly(dialog_->firstheaderNoContentsCB); + bc().addReadOnly(dialog_->footerStatusCB); + bc().addReadOnly(dialog_->footerBorderAboveCB); + bc().addReadOnly(dialog_->footerBorderBelowCB); + bc().addReadOnly(dialog_->lastfooterStatusCB); + bc().addReadOnly(dialog_->lastfooterBorderAboveCB); + bc().addReadOnly(dialog_->lastfooterBorderBelowCB); + bc().addReadOnly(dialog_->lastfooterNoContentsCB); + bc().addReadOnly(dialog_->newpageCB); } @@ -62,17 +92,38 @@ void QTabular::update_borders() int cell(controller().inset()->getActCell()); if (!controller().isMulticolumnCell()) { + dialog_->borders->setLeftEnabled(true); + dialog_->borders->setRightEnabled(true); dialog_->borders->setTop(tabular->TopLine(cell, true)); dialog_->borders->setBottom(tabular->BottomLine(cell, true)); dialog_->borders->setLeft(tabular->LeftLine(cell, true)); dialog_->borders->setRight(tabular->RightLine(cell, true)); + // repaint the setborder widget + dialog_->borders->repaint(); return; } - + dialog_->borders->setTop(tabular->TopLine(cell)); dialog_->borders->setBottom(tabular->BottomLine(cell)); - dialog_->borders->setLeft(tabular->LeftLine(cell)); - dialog_->borders->setRight(tabular->RightLine(cell)); + // pay attention to left/right lines: they are only allowed + // to set if we are in first/last cell of row or if the left/right + // cell is also a multicolumn. + if (tabular->IsFirstCellInRow(cell) || tabular->IsMultiColumn(cell - 1)) { + dialog_->borders->setLeftEnabled(true); + dialog_->borders->setLeft(tabular->LeftLine(cell)); + } else { + dialog_->borders->setLeft(false); + dialog_->borders->setLeftEnabled(false); + } + if (tabular->IsLastCellInRow(cell) || tabular->IsMultiColumn(cell + 1)) { + dialog_->borders->setRightEnabled(true); + dialog_->borders->setRight(tabular->RightLine(cell)); + } else { + dialog_->borders->setRight(false); + dialog_->borders->setRightEnabled(false); + } + // repaint the setborder widget + dialog_->borders->repaint(); } diff --git a/src/frontends/qt2/QTabularDialog.C b/src/frontends/qt2/QTabularDialog.C index 27832cf715..b8ec8aad15 100644 --- a/src/frontends/qt2/QTabularDialog.C +++ b/src/frontends/qt2/QTabularDialog.C @@ -84,7 +84,6 @@ void QTabularDialog::borderSet_clicked() form_->controller().set(LyXTabular::SET_ALL_LINES); form_->update_borders(); form_->changed(); - //FIXME: qsetborder widget not updated } void QTabularDialog::borderUnset_clicked() @@ -92,7 +91,6 @@ void QTabularDialog::borderUnset_clicked() form_->controller().set(LyXTabular::UNSET_ALL_LINES); form_->update_borders(); form_->changed(); - //FIXME: qsetborder widget not updated } diff --git a/src/frontends/qt2/qsetborder.C b/src/frontends/qt2/qsetborder.C index b734ad1e30..07ca58f164 100644 --- a/src/frontends/qt2/qsetborder.C +++ b/src/frontends/qt2/qsetborder.C @@ -4,6 +4,7 @@ * Licence details can be found in the file COPYING. * * \author Edwin Leuven + * \author John Levon * * Full author contact details are available in file CREDITS */ @@ -15,9 +16,7 @@ QSetBorder::QSetBorder(QWidget * parent, char const * name, WFlags fl) - : QWidget(parent, name, fl), - left_(true), right_(true), top_(true), bottom_(true), - buffer(75, 75) + : QWidget(parent, name, fl), buffer(75, 75) { /* length of corner line */ l = buffer.width() / 10; @@ -70,19 +69,27 @@ void QSetBorder::mousePressEvent(QMouseEvent * e) { if (e->y() > e->x()) { if (e->y() < height() - e->x()) { - setLeft(!left_); - emit leftSet(left_); + if (left_.enabled) { + setLeft(!left_.set); + emit leftSet(left_.set); + } } else { - setBottom(!bottom_); - emit bottomSet(bottom_); + if (bottom_.enabled) { + setBottom(!bottom_.set); + emit bottomSet(bottom_.set); + } } } else { if (e->y() < height() - e->x()) { - setTop(!top_); - emit topSet(top_); + if (top_.enabled) { + setTop(!top_.set); + emit topSet(top_.set); + } } else { - setRight(!right_); - emit rightSet(right_); + if (right_.enabled) { + setRight(!right_.set); + emit rightSet(right_.set); + } } } update(); @@ -90,13 +97,13 @@ void QSetBorder::mousePressEvent(QMouseEvent * e) } -void QSetBorder::drawLine(bool draw, int x, int y, int x2, int y2) +void QSetBorder::drawLine(QColor const & col, int x, int y, int x2, int y2) { QPainter paint; paint.begin(&buffer); QPen p = paint.pen(); p.setWidth(2); - p.setColor(draw ? Qt::black : Qt::white); + p.setColor(col); paint.setPen(p); paint.drawLine(x, y, x2, y2); paint.end(); @@ -105,52 +112,92 @@ void QSetBorder::drawLine(bool draw, int x, int y, int x2, int y2) void QSetBorder::drawLeft(bool draw) { - drawLine(draw, m + l, m + l + 2, m + l, h - m - l - 1); + QColor col(draw ? Qt::black : Qt::white); + if (!left_.enabled) + col = QColor("grey"); + drawLine(col, m + l, m + l + 2, m + l, h - m - l - 1); } void QSetBorder::drawRight(bool draw) { - drawLine(draw, h - m - l + 1, m + l + 2, h - m - l + 1, h - m - l - 1); + QColor col(draw ? Qt::black : Qt::white); + if (!right_.enabled) + col = QColor("grey"); + drawLine(col, h - m - l + 1, m + l + 2, h - m - l + 1, h - m - l - 1); } void QSetBorder::drawTop(bool draw) { - drawLine(draw, m + l + 2, m + l, w - m - l - 1, m + l); + QColor col(draw ? Qt::black : Qt::white); + if (!top_.enabled) + col = QColor("grey"); + drawLine(col, m + l + 2, m + l, w - m - l - 1, m + l); } void QSetBorder::drawBottom(bool draw) { - drawLine(draw, m + l + 2, w - m - l + 1, w - m - l - 1, w - m - l + 1); + QColor col(draw ? Qt::black : Qt::white); + if (!bottom_.enabled) + col = QColor("grey"); + drawLine(col, m + l + 2, w - m - l + 1, w - m - l - 1, w - m - l + 1); } - + +void QSetBorder::setLeftEnabled(bool border) +{ + left_.enabled = border; + drawLeft(border); +} + + +void QSetBorder::setRightEnabled(bool border) +{ + right_.enabled = border; + drawRight(border); +} + + +void QSetBorder::setTopEnabled(bool border) +{ + top_.enabled = border; + drawTop(border); +} + + +void QSetBorder::setBottomEnabled(bool border) +{ + bottom_.enabled = border; + drawBottom(border); +} + + void QSetBorder::setLeft(bool border) { - left_ = border; + left_.set = border; drawLeft(border); } void QSetBorder::setRight(bool border) { - right_ = border; + right_.set = border; drawRight(border); } void QSetBorder::setTop(bool border) { - top_ = border; + top_.set = border; drawTop(border); } void QSetBorder::setBottom(bool border) { - bottom_ = border; + bottom_.set = border; drawBottom(border); } @@ -166,23 +213,23 @@ void QSetBorder::setAll(bool border) bool QSetBorder::getLeft() { - return left_; + return left_.set; } bool QSetBorder::getRight() { - return right_; + return right_.set; } bool QSetBorder::getTop() { - return top_; + return top_.set; } bool QSetBorder::getBottom() { - return bottom_; + return bottom_.set; } diff --git a/src/frontends/qt2/qsetborder.h b/src/frontends/qt2/qsetborder.h index 52dfbf86d6..259c0e2670 100644 --- a/src/frontends/qt2/qsetborder.h +++ b/src/frontends/qt2/qsetborder.h @@ -5,6 +5,7 @@ * Licence details can be found in the file COPYING. * * \author Edwin Leuven + * \author John Levon * * Full author contact details are available in file CREDITS */ @@ -13,6 +14,7 @@ #include #include +#include class QMouseEvent; class QResizeEvent; @@ -37,6 +39,10 @@ signals: void clicked(); public slots: + void setLeftEnabled(bool); + void setRightEnabled(bool); + void setTopEnabled(bool); + void setBottomEnabled(bool); void setLeft(bool); void setRight(bool); void setTop(bool); @@ -50,17 +56,23 @@ protected: private: void init(); - void drawLine(bool set, int x, int y, int x2, int y2); + void drawLine(QColor const & col, int x, int y, int x2, int y2); void drawLeft(bool); void drawRight(bool); void drawTop(bool); void drawBottom(bool); - bool left_; - bool right_; - bool top_; - bool bottom_; + struct Border { + Border() : set(true), enabled(true) {} + bool set; + bool enabled; + }; + + Border left_; + Border right_; + Border top_; + Border bottom_; int m; int l; -- 2.39.2