some fixes

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5736 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
John Levon 2002-11-27 20:23:53 +00:00
parent 85e88d3824
commit 80d98d4d86
5 changed files with 155 additions and 171 deletions

View File

@ -1,7 +1,15 @@
2002-11-27 John Levon <levon@movementarian.org>
* qsetborder.h:
* qsetborder.C: cleanup
* QTabular.C:
* QTabularDialog.C: cleanups, fixes
2002-11-27 Juergen Spitzmueller <j.spitzmueller@gmx.de>
* ui/TabularDialog.ui
* QTabular.[Ch]
* ui/TabularDialog.ui:
* QTabular.[Ch]:
* QTabularDialog.[Ch]: implement most functions
* qsetborder.[Ch]: fixes

View File

@ -45,6 +45,8 @@ void QTabular::build_dialog()
dialog_.reset(new QTabularDialog(this));
bc().setCancel(dialog_->closePB);
// FIXME: add widgets to read only
}
@ -59,32 +61,18 @@ void QTabular::update_borders()
LyXTabular * tabular(controller().tabular());
int cell(controller().inset()->getActCell());
if (controller().isMulticolumnCell()) {
dialog_->borders->setTop(tabular->TopLine(cell)?1:0);
dialog_->borders->setBottom(tabular->BottomLine(cell)?1:0);
// 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->setLeft(tabular->LeftLine(cell)?1:0);
// FIXME: setEnabled(cell_options_->check_border_left, true);
} else {
dialog_->borders->setLeft(false);
// FIXME: setEnabled(cell_options_->check_border_left, false);
}
if (tabular->IsLastCellInRow(cell) || tabular->IsMultiColumn(cell+1)) {
dialog_->borders->setRight(tabular->RightLine(cell)?1:0);
// FIXME: setEnabled(cell_options_->check_border_right, true);
} else {
dialog_->borders->setRight(false);
// FIXME: setEnabled(cell_options_->check_border_right, false);
}
} else {
if (!controller().isMulticolumnCell()) {
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));
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));
}
@ -93,8 +81,8 @@ void QTabular::update_contents()
LyXTabular * tabular(controller().tabular());
int cell(controller().inset()->getActCell());
int row(tabular->row_of_cell(cell));
int col(tabular->column_of_cell(cell));
int const row(tabular->row_of_cell(cell));
int const col(tabular->column_of_cell(cell));
dialog_->tabularRowED->setText(tostr(row + 1).c_str());
dialog_->tabularColumnED->setText(tostr(col + 1).c_str());
@ -126,7 +114,7 @@ void QTabular::update_contents()
bool const isReadonly = bc().bp().isReadOnly();
dialog_->specialAlignmentED->setEnabled(!isReadonly);
LyXLength::UNIT default_unit = controller().metric() ? LyXLength::CM : LyXLength::CM;
LyXLength::UNIT default_unit = controller().metric() ? LyXLength::CM : LyXLength::IN;
if (!pwidth.zero()) {
dialog_->widthED->setText(tostr(pwidth.value()).c_str());
dialog_->widthUnit->setCurrentItem(pwidth.unit());
@ -138,7 +126,7 @@ void QTabular::update_contents()
dialog_->widthUnit->setEnabled(!isReadonly);
int align = 0;
switch(tabular->GetAlignment(cell)) {
switch (tabular->GetAlignment(cell)) {
case LYX_ALIGN_LEFT:
align = 1;
break;
@ -155,7 +143,7 @@ void QTabular::update_contents()
dialog_->hAlignCB->setCurrentItem(align);
int valign = 0;
switch(tabular->GetVAlignment(cell)) {
switch (tabular->GetVAlignment(cell)) {
case LyXTabular::LYX_VALIGN_TOP:
valign = 0;
break;
@ -176,76 +164,7 @@ void QTabular::update_contents()
dialog_->hAlignCB->setEnabled(true);
dialog_->vAlignCB->setEnabled(!pwidth.zero());
if (tabular->IsLongTabular()) {
LyXTabular::ltType ltt;
bool use_empty;
bool row_set = tabular->GetRowOfLTHead(row, ltt);
dialog_->headerStatusCB->setChecked(row_set);
if (ltt.set) {
dialog_->headerBorderAboveCB->setChecked(ltt.topDL);
dialog_->headerBorderBelowCB->setChecked(ltt.bottomDL);
use_empty = true;
} else {
dialog_->headerBorderAboveCB->setChecked(false);
dialog_->headerBorderBelowCB->setChecked(false);
dialog_->headerBorderAboveCB->setEnabled(false);
dialog_->headerBorderBelowCB->setEnabled(false);
dialog_->firstheaderNoContentsCB->setChecked(false);
dialog_->firstheaderNoContentsCB->setEnabled(false);
use_empty = false;
}
//
row_set = tabular->GetRowOfLTFirstHead(row, ltt);
dialog_->firstheaderStatusCB->setChecked(row_set);
if (ltt.set && (!ltt.empty || !use_empty)) {
dialog_->firstheaderBorderAboveCB->setChecked(ltt.topDL);
dialog_->firstheaderBorderBelowCB->setChecked(ltt.bottomDL);
} else {
dialog_->firstheaderBorderAboveCB->setEnabled(false);
dialog_->firstheaderBorderBelowCB->setEnabled(false);
dialog_->firstheaderBorderAboveCB->setChecked(false);
dialog_->firstheaderBorderBelowCB->setChecked(false);
if (use_empty) {
dialog_->firstheaderNoContentsCB->setChecked(ltt.empty);
if (ltt.empty)
dialog_->firstheaderStatusCB->setEnabled(false);
}
}
//
row_set = tabular->GetRowOfLTFoot(row, ltt);
dialog_->footerStatusCB->setChecked(row_set);
if (ltt.set) {
dialog_->footerBorderAboveCB->setChecked(ltt.topDL);
dialog_->footerBorderBelowCB->setChecked(ltt.bottomDL);
use_empty = true;
} else {
dialog_->footerBorderAboveCB->setChecked(false);
dialog_->footerBorderBelowCB->setChecked(false);
dialog_->footerBorderAboveCB->setEnabled(false);
dialog_->footerBorderBelowCB->setEnabled(false);
dialog_->lastfooterNoContentsCB->setChecked(false);
dialog_->lastfooterNoContentsCB->setEnabled(false);
use_empty = false;
}
//
row_set = tabular->GetRowOfLTLastFoot(row, ltt);
dialog_->lastfooterStatusCB->setChecked(row_set);
if (ltt.set && (!ltt.empty || !use_empty)) {
dialog_->lastfooterBorderAboveCB->setChecked(ltt.topDL);
dialog_->lastfooterBorderBelowCB->setChecked(ltt.bottomDL);
} else {
dialog_->lastfooterBorderAboveCB->setEnabled(false);
dialog_->lastfooterBorderBelowCB->setEnabled(false);
dialog_->lastfooterBorderAboveCB->setChecked(false);
dialog_->lastfooterBorderBelowCB->setChecked(false);
if (use_empty) {
dialog_->lastfooterNoContentsCB->setChecked(ltt.empty);
if (ltt.empty)
dialog_->lastfooterStatusCB->setEnabled(false);
}
}
dialog_->newpageCB->setChecked(tabular->GetLTNewPage(row));
} else {
if (!tabular->IsLongTabular()) {
dialog_->headerStatusCB->setChecked(false);
dialog_->headerBorderAboveCB->setChecked(false);
dialog_->headerBorderBelowCB->setChecked(false);
@ -261,9 +180,80 @@ void QTabular::update_contents()
dialog_->lastfooterBorderBelowCB->setChecked(false);
dialog_->lastfooterNoContentsCB->setChecked(false);
dialog_->newpageCB->setChecked(false);
return;
}
LyXTabular::ltType ltt;
bool use_empty;
bool row_set = tabular->GetRowOfLTHead(row, ltt);
dialog_->headerStatusCB->setChecked(row_set);
if (ltt.set) {
dialog_->headerBorderAboveCB->setChecked(ltt.topDL);
dialog_->headerBorderBelowCB->setChecked(ltt.bottomDL);
use_empty = true;
} else {
dialog_->headerBorderAboveCB->setChecked(false);
dialog_->headerBorderBelowCB->setChecked(false);
dialog_->headerBorderAboveCB->setEnabled(false);
dialog_->headerBorderBelowCB->setEnabled(false);
dialog_->firstheaderNoContentsCB->setChecked(false);
dialog_->firstheaderNoContentsCB->setEnabled(false);
use_empty = false;
}
row_set = tabular->GetRowOfLTFirstHead(row, ltt);
dialog_->firstheaderStatusCB->setChecked(row_set);
if (ltt.set && (!ltt.empty || !use_empty)) {
dialog_->firstheaderBorderAboveCB->setChecked(ltt.topDL);
dialog_->firstheaderBorderBelowCB->setChecked(ltt.bottomDL);
} else {
dialog_->firstheaderBorderAboveCB->setEnabled(false);
dialog_->firstheaderBorderBelowCB->setEnabled(false);
dialog_->firstheaderBorderAboveCB->setChecked(false);
dialog_->firstheaderBorderBelowCB->setChecked(false);
if (use_empty) {
dialog_->firstheaderNoContentsCB->setChecked(ltt.empty);
if (ltt.empty)
dialog_->firstheaderStatusCB->setEnabled(false);
}
}
row_set = tabular->GetRowOfLTFoot(row, ltt);
dialog_->footerStatusCB->setChecked(row_set);
if (ltt.set) {
dialog_->footerBorderAboveCB->setChecked(ltt.topDL);
dialog_->footerBorderBelowCB->setChecked(ltt.bottomDL);
use_empty = true;
} else {
dialog_->footerBorderAboveCB->setChecked(false);
dialog_->footerBorderBelowCB->setChecked(false);
dialog_->footerBorderAboveCB->setEnabled(false);
dialog_->footerBorderBelowCB->setEnabled(false);
dialog_->lastfooterNoContentsCB->setChecked(false);
dialog_->lastfooterNoContentsCB->setEnabled(false);
use_empty = false;
}
row_set = tabular->GetRowOfLTLastFoot(row, ltt);
dialog_->lastfooterStatusCB->setChecked(row_set);
if (ltt.set && (!ltt.empty || !use_empty)) {
dialog_->lastfooterBorderAboveCB->setChecked(ltt.topDL);
dialog_->lastfooterBorderBelowCB->setChecked(ltt.bottomDL);
} else {
dialog_->lastfooterBorderAboveCB->setEnabled(false);
dialog_->lastfooterBorderBelowCB->setEnabled(false);
dialog_->lastfooterBorderAboveCB->setChecked(false);
dialog_->lastfooterBorderBelowCB->setChecked(false);
if (use_empty) {
dialog_->lastfooterNoContentsCB->setChecked(ltt.empty);
if (ltt.empty)
dialog_->lastfooterStatusCB->setEnabled(false);
}
}
dialog_->newpageCB->setChecked(tabular->GetLTNewPage(row));
}
void QTabular::closeGUI()
{
// ugly hack to auto-apply the stuff that hasn't been
@ -282,6 +272,7 @@ void QTabular::closeGUI()
str2 = "";
else
str2 = llen.asString();
if (str1 != str2) {
if (controller().isMulticolumnCell())
controller().set(LyXTabular::SET_MPWIDTH, str1);
@ -295,6 +286,7 @@ void QTabular::closeGUI()
str2 = tabular->GetAlignSpecial(cell, LyXTabular::SET_SPECIAL_MULTI);
else
str2 = tabular->GetAlignSpecial(cell, LyXTabular::SET_SPECIAL_COLUMN);
if (str1 != str2) {
if (controller().isMulticolumnCell())
controller().set(LyXTabular::SET_SPECIAL_MULTI, str1);
@ -302,30 +294,3 @@ void QTabular::closeGUI()
controller().set(LyXTabular::SET_SPECIAL_COLUMN, str1);
}
}
#if 0
// the unported rest...
// not shure if and where this is needed (JSpitzm)
ButtonPolicy::SMInput FormTabular::input(FL_OBJECT * ob, long)
{
InsetTabular * inset(controller().inset());
LyXTabular * tabular(controller().tabular());
int cell = inset->getActCell();
FIXME: Where to place?
if (actCell_ != cell) {
update();
postWarning(_("Wrong Cursor position, updated window"));
return ButtonPolicy::SMI_VALID;
}
FIXME: Necessary in QT?
// No point in processing directives that you can't do anything with
// anyhow, so exit now if the buffer is read-only.
if (bc().bp().isReadOnly()) {
update();
return ButtonPolicy::SMI_VALID;
}
}
#endif

View File

@ -78,6 +78,7 @@ void QTabularDialog::rowDelete_clicked()
form_->controller().set(LyXTabular::DELETE_ROW);
}
void QTabularDialog::borderSet_clicked()
{
form_->controller().set(LyXTabular::SET_ALL_LINES);
@ -91,6 +92,7 @@ void QTabularDialog::borderUnset_clicked()
form_->update_borders();
form_->changed();
}
void QTabularDialog::leftBorder_changed()
{
@ -101,6 +103,7 @@ void QTabularDialog::leftBorder_changed()
form_->changed();
}
void QTabularDialog::rightBorder_changed()
{
if (form_->controller().isMulticolumnCell())
@ -110,6 +113,7 @@ void QTabularDialog::rightBorder_changed()
form_->changed();
}
void QTabularDialog::topBorder_changed()
{
if (form_->controller().isMulticolumnCell())
@ -119,6 +123,7 @@ void QTabularDialog::topBorder_changed()
form_->changed();
}
void QTabularDialog::bottomBorder_changed()
{
if (form_->controller().isMulticolumnCell())
@ -128,6 +133,7 @@ void QTabularDialog::bottomBorder_changed()
form_->changed();
}
void QTabularDialog::specialAlignment_changed()
{
string special = specialAlignmentED->text().latin1();
@ -137,6 +143,7 @@ void QTabularDialog::specialAlignment_changed()
form_->controller().set(LyXTabular::SET_SPECIAL_COLUMN, special);
}
void QTabularDialog::width_changed()
{
string const width =
@ -148,15 +155,17 @@ void QTabularDialog::width_changed()
form_->controller().set(LyXTabular::SET_PWIDTH, width);
}
void QTabularDialog::multicolumn_clicked()
{
form_->controller().set(LyXTabular::MULTICOLUMN);
form_->changed();
}
void QTabularDialog::rotateTabular_checked(int state)
{
switch(state) {
switch (state) {
case 0:
form_->controller().set(LyXTabular::UNSET_ROTATE_TABULAR);
break;
@ -169,9 +178,10 @@ void QTabularDialog::rotateTabular_checked(int state)
}
}
void QTabularDialog::rotateCell_checked(int state)
{
switch(state) {
switch (state) {
case 0:
form_->controller().set(LyXTabular::UNSET_ROTATE_CELL);
break;
@ -184,12 +194,13 @@ void QTabularDialog::rotateCell_checked(int state)
}
}
void QTabularDialog::hAlign_changed(int align)
{
LyXTabular::Feature num;
LyXTabular::Feature multi_num;
LyXTabular::Feature num = LyXTabular::ALIGN_BLOCK;
LyXTabular::Feature multi_num = LyXTabular::M_ALIGN_LEFT;
switch(align) {
switch (align) {
case 0:
{
num = LyXTabular::ALIGN_BLOCK;
@ -221,12 +232,13 @@ void QTabularDialog::hAlign_changed(int align)
form_->controller().set(num);
}
void QTabularDialog::vAlign_changed(int align)
{
LyXTabular::Feature num;
LyXTabular::Feature multi_num;
LyXTabular::Feature num = LyXTabular::ALIGN_BLOCK;
LyXTabular::Feature multi_num = LyXTabular::M_ALIGN_LEFT;
switch(align) {
switch (align) {
case 0:
{
num = LyXTabular::VALIGN_TOP;
@ -252,9 +264,10 @@ void QTabularDialog::vAlign_changed(int align)
form_->controller().set(num);
}
void QTabularDialog::longTabular_changed(int state)
{
switch(state) {
switch (state) {
case 0:
form_->controller().set(LyXTabular::UNSET_LONGTABULAR);
break;
@ -268,12 +281,14 @@ void QTabularDialog::longTabular_changed(int state)
form_->changed();
}
void QTabularDialog::ltNewpage_clicked()
{
form_->controller().set(LyXTabular::SET_LTNEWPAGE);
form_->changed();
}
void QTabularDialog::ltHeaderStatus_clicked()
{
bool enable(headerStatusCB->isChecked());
@ -438,4 +453,3 @@ void QTabularDialog::ltLastFooterEmpty_clicked()
lastfooterBorderBelowCB->setEnabled(!enable);
form_->changed();
}

View File

@ -16,7 +16,8 @@
QSetBorder::QSetBorder(QWidget * parent, char const * name, WFlags fl)
: QWidget(parent, name, fl),
left_(false), right_(false), top_(false), bottom_(false), buffer(75,75)
left_(true), right_(true), top_(true), bottom_(true),
buffer(75, 75)
{
/* length of corner line */
l = buffer.width() / 10;
@ -47,6 +48,8 @@ void QSetBorder::init()
paint.begin(&buffer);
paint.setPen(Qt::black);
// FIXME: wow, readable !! :)
paint.drawLine(m + l , m, m + l, m + l);
paint.drawLine(w - (m + l), m, w - (m + l), m + l);
@ -67,22 +70,18 @@ void QSetBorder::mousePressEvent(QMouseEvent * e)
{
if (e->y() > e->x()) {
if (e->y() < height() - e->x()) {
drawLeft(!left_);
left_ = !left_;
setLeft(!left_);
emit leftSet(left_);
} else {
drawBottom(!bottom_);
bottom_ = !bottom_;
setBottom(!bottom_);
emit bottomSet(bottom_);
}
} else {
if (e->y() < height() - e->x()) {
drawTop(!top_);
top_ = !top_;
setTop(!top_);
emit topSet(top_);
} else {
drawRight(!right_);
right_ = !right_;
setRight(!right_);
emit rightSet(right_);
}
}
@ -91,7 +90,7 @@ void QSetBorder::mousePressEvent(QMouseEvent * e)
}
void QSetBorder::drawLeft(bool draw)
void QSetBorder::drawLine(bool draw, int x, int y, int x2, int y2)
{
QPainter paint;
paint.begin(&buffer);
@ -99,64 +98,55 @@ void QSetBorder::drawLeft(bool draw)
p.setWidth(2);
p.setColor(draw ? Qt::black : Qt::white);
paint.setPen(p);
paint.drawLine(m + l, m + l + 2, m + l, h - m - l - 1);
paint.drawLine(x, y, x2, y2);
paint.end();
}
void QSetBorder::drawLeft(bool draw)
{
drawLine(draw, m + l, m + l + 2, m + l, h - m - l - 1);
}
void QSetBorder::drawRight(bool draw)
{
QPainter paint;
paint.begin(&buffer);
QPen p = paint.pen();
p.setWidth(2);
p.setColor(draw ? Qt::black : Qt::white);
paint.setPen(p);
paint.drawLine(h - m - l + 1, m + l + 2, h - m - l + 1, h - m - l - 1);
paint.end();
drawLine(draw, h - m - l + 1, m + l + 2, h - m - l + 1, h - m - l - 1);
}
void QSetBorder::drawTop(bool draw)
{
QPainter paint;
paint.begin(&buffer);
QPen p = paint.pen();
p.setWidth(2);
p.setColor(draw ? Qt::black : Qt::white);
paint.setPen(p);
paint.drawLine(m + l + 2, m + l, w - m - l - 1, m + l);
paint.end();
drawLine(draw, m + l + 2, m + l, w - m - l - 1, m + l);
}
void QSetBorder::drawBottom(bool draw)
{
QPainter paint;
paint.begin(&buffer);
QPen p = paint.pen();
p.setWidth(2);
p.setColor(draw ? Qt::black : Qt::white);
paint.setPen(p);
paint.drawLine(m + l + 2, w - m - l + 1, w - m - l - 1, w - m - l + 1);
paint.end();
drawLine(draw, m + l + 2, w - m - l + 1, w - m - l - 1, w - m - l + 1);
}
void QSetBorder::setLeft(bool border)
{
left_ = border;
drawLeft(border);
}
void QSetBorder::setRight(bool border)
{
right_ = border;
drawRight(border);
}
void QSetBorder::setTop(bool border)
{
top_ = border;
drawTop(border);
}
void QSetBorder::setBottom(bool border)
{
@ -164,6 +154,7 @@ void QSetBorder::setBottom(bool border)
drawBottom(border);
}
void QSetBorder::setAll(bool border)
{
setLeft(border);
@ -172,21 +163,25 @@ void QSetBorder::setAll(bool border)
setBottom(border);
}
bool QSetBorder::getLeft()
{
return left_;
}
bool QSetBorder::getRight()
{
return right_;
}
bool QSetBorder::getTop()
{
return top_;
}
bool QSetBorder::getBottom()
{
return bottom_;

View File

@ -50,6 +50,8 @@ protected:
private:
void init();
void drawLine(bool set, int x, int y, int x2, int y2);
void drawLeft(bool);
void drawRight(bool);
void drawTop(bool);
@ -64,7 +66,7 @@ private:
int l;
int w;
int h;
QPixmap buffer;
};