John Levon wrote:
> you should be able to dig the setEnabled stuff out of the attached

Thanks, I implemented it (slightly modified: borders are now always greyed out 
if setEnabled(false), because this is a better visual hint).
I have also managed to fix the setborder update problem (a repaint() call was 
needed) and added the readonly stuff.
So, qtabular can be considered FINISHED :-)

Regards,
Jürgen
Index: src/frontends/qt2/ChangeLog
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/frontends/qt2/ChangeLog,v
retrieving revision 1.325
diff -u -r1.325 ChangeLog
--- src/frontends/qt2/ChangeLog	2002/11/28 01:21:52	1.325
+++ src/frontends/qt2/ChangeLog	2002/11/28 10:09:57
@@ -1,3 +1,10 @@
+2002-11-28  Juergen Spitzmueller  <[EMAIL PROTECTED]>
+
+	* qsetborder.[Ch]: implement John's setEnabled bool
+
+	* QTabular.C:
+	* QTabularDialog.C: remaining fixes.
+
 2002-11-28  John Levon  <[EMAIL PROTECTED]>

 	* QDocument.C: fix line spacing
Index: src/frontends/qt2/QTabular.C
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/frontends/qt2/QTabular.C,v
retrieving revision 1.7
diff -u -r1.7 QTabular.C
--- src/frontends/qt2/QTabular.C	2002/11/27 23:58:37	1.7
+++ src/frontends/qt2/QTabular.C	2002/11/28 10:09:58
@@ -46,7 +46,37 @@

 	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 @@
 	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();
 }
 
 
Index: src/frontends/qt2/QTabularDialog.C
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/frontends/qt2/QTabularDialog.C,v
retrieving revision 1.5
diff -u -r1.5 QTabularDialog.C
--- src/frontends/qt2/QTabularDialog.C	2002/11/27 23:58:37	1.5
+++ src/frontends/qt2/QTabularDialog.C	2002/11/28 10:09:59
@@ -84,7 +84,6 @@
 	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 @@
 	form_->controller().set(LyXTabular::UNSET_ALL_LINES);
 	form_->update_borders();
 	form_->changed();
-	//FIXME: qsetborder widget not updated
 }
  
 
Index: src/frontends/qt2/qsetborder.C
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/frontends/qt2/qsetborder.C,v
retrieving revision 1.4
diff -u -r1.4 qsetborder.C
--- src/frontends/qt2/qsetborder.C	2002/11/27 20:23:53	1.4
+++ src/frontends/qt2/qsetborder.C	2002/11/28 10:09:59
@@ -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 @@
 {
 	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::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::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 @@
 
 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;
 }
Index: src/frontends/qt2/qsetborder.h
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/frontends/qt2/qsetborder.h,v
retrieving revision 1.4
diff -u -r1.4 qsetborder.h
--- src/frontends/qt2/qsetborder.h	2002/11/27 20:23:53	1.4
+++ src/frontends/qt2/qsetborder.h	2002/11/28 10:09:59
@@ -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 <qwidget.h>
 #include <qpixmap.h>
+#include <qcolor.h>
 
 class QMouseEvent;
 class QResizeEvent;
@@ -37,6 +39,10 @@
 	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 @@
 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;

Reply via email to