2001-02-14 19:43:56 +00:00
|
|
|
/**
|
2001-08-19 13:25:15 +00:00
|
|
|
* \file QParagraph.C
|
2002-09-24 13:57:09 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2001-02-14 19:43:56 +00:00
|
|
|
*
|
2002-10-19 10:32:57 +00:00
|
|
|
* \author Edwin Leuven
|
2002-09-24 13:57:09 +00:00
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2001-02-14 19:43:56 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2001-08-19 13:25:15 +00:00
|
|
|
#include "QParagraph.h"
|
2002-07-17 15:51:23 +00:00
|
|
|
#include "QParagraphDialog.h"
|
|
|
|
#include "Qt2BC.h"
|
2002-12-17 20:37:13 +00:00
|
|
|
#include "qt_helpers.h"
|
2002-07-17 15:51:23 +00:00
|
|
|
|
2004-05-20 09:36:28 +00:00
|
|
|
#include "ParagraphParameters.h"
|
2003-09-06 20:32:37 +00:00
|
|
|
#include "Spacing.h"
|
2004-05-20 09:36:28 +00:00
|
|
|
|
|
|
|
#include "controllers/ControlParagraph.h"
|
|
|
|
#include "controllers/helper_funcs.h"
|
|
|
|
|
|
|
|
#include <qbuttongroup.h>
|
|
|
|
#include <qcheckbox.h>
|
2002-07-17 15:51:23 +00:00
|
|
|
#include <qcombobox.h>
|
|
|
|
#include <qlineedit.h>
|
|
|
|
#include <qpushbutton.h>
|
|
|
|
|
2003-06-30 23:56:22 +00:00
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
using std::string;
|
2003-09-08 00:33:41 +00:00
|
|
|
|
2004-05-19 15:11:37 +00:00
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
2003-09-08 00:33:41 +00:00
|
|
|
|
2003-03-13 13:56:25 +00:00
|
|
|
typedef QController<ControlParagraph, QView<QParagraphDialog> > base_class;
|
2002-07-28 22:50:13 +00:00
|
|
|
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2003-03-13 13:56:25 +00:00
|
|
|
QParagraph::QParagraph(Dialog & parent)
|
2003-05-22 15:42:50 +00:00
|
|
|
: base_class(parent, _("LyX: Paragraph Settings"))
|
2002-07-17 15:51:23 +00:00
|
|
|
{}
|
|
|
|
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2002-07-17 15:51:23 +00:00
|
|
|
void QParagraph::build_dialog()
|
2001-02-14 19:43:56 +00:00
|
|
|
{
|
2003-12-01 07:54:02 +00:00
|
|
|
// the dialog
|
2002-07-17 15:51:23 +00:00
|
|
|
dialog_.reset(new QParagraphDialog(this));
|
|
|
|
|
|
|
|
// Manage the ok, apply, restore and cancel/close buttons
|
2003-03-10 03:13:28 +00:00
|
|
|
bcview().setOK(dialog_->okPB);
|
|
|
|
bcview().setApply(dialog_->applyPB);
|
|
|
|
bcview().setCancel(dialog_->closePB);
|
|
|
|
bcview().setRestore(dialog_->restorePB);
|
2001-02-14 19:43:56 +00:00
|
|
|
}
|
|
|
|
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2001-08-19 13:25:15 +00:00
|
|
|
void QParagraph::apply()
|
2001-02-14 19:43:56 +00:00
|
|
|
{
|
2002-10-20 01:48:28 +00:00
|
|
|
ParagraphParameters & params = controller().params();
|
|
|
|
|
|
|
|
// alignment
|
2002-07-17 15:51:23 +00:00
|
|
|
LyXAlignment align;
|
|
|
|
switch (dialog_->align->currentItem()) {
|
|
|
|
case 0:
|
|
|
|
align = LYX_ALIGN_BLOCK;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
align = LYX_ALIGN_LEFT;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
align = LYX_ALIGN_RIGHT;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
align = LYX_ALIGN_CENTER;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
align = LYX_ALIGN_BLOCK;
|
|
|
|
}
|
2002-10-20 01:48:28 +00:00
|
|
|
params.align(align);
|
2002-07-28 22:50:13 +00:00
|
|
|
|
2002-10-20 01:48:28 +00:00
|
|
|
// get spacing
|
2002-07-17 15:51:23 +00:00
|
|
|
Spacing::Space linespacing = Spacing::Default;
|
|
|
|
string other;
|
|
|
|
switch (dialog_->linespacing->currentItem()) {
|
|
|
|
case 0:
|
|
|
|
linespacing = Spacing::Default;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
linespacing = Spacing::Single;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
linespacing = Spacing::Onehalf;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
linespacing = Spacing::Double;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
linespacing = Spacing::Other;
|
2002-12-17 20:37:13 +00:00
|
|
|
other = fromqstr(dialog_->linespacingValue->text());
|
2002-07-17 15:51:23 +00:00
|
|
|
break;
|
|
|
|
}
|
2001-02-14 19:43:56 +00:00
|
|
|
|
2002-07-17 15:51:23 +00:00
|
|
|
Spacing const spacing(linespacing, other);
|
2002-10-20 01:48:28 +00:00
|
|
|
params.spacing(spacing);
|
|
|
|
|
|
|
|
// label width
|
2002-12-17 20:37:13 +00:00
|
|
|
params.labelWidthString(fromqstr(dialog_->labelWidth->text()));
|
2002-10-20 01:48:28 +00:00
|
|
|
// indendation
|
2003-03-28 19:45:53 +00:00
|
|
|
params.noindent(!dialog_->indentCB->isChecked());
|
2002-07-17 15:51:23 +00:00
|
|
|
}
|
2001-02-14 19:43:56 +00:00
|
|
|
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2002-07-17 15:51:23 +00:00
|
|
|
void QParagraph::update_contents()
|
|
|
|
{
|
2002-10-20 01:48:28 +00:00
|
|
|
ParagraphParameters const & params = controller().params();
|
|
|
|
|
|
|
|
// label width
|
|
|
|
string const & labelwidth = params.labelWidthString();
|
2002-12-17 20:37:13 +00:00
|
|
|
// _() is correct here (this is stupid though !)
|
2003-03-28 19:45:53 +00:00
|
|
|
if (labelwidth != _("Senseless with this layout!")) {
|
|
|
|
dialog_->labelwidthGB->setEnabled(true);
|
|
|
|
dialog_->labelWidth->setText(toqstr(labelwidth));
|
|
|
|
} else {
|
|
|
|
dialog_->labelwidthGB->setEnabled(false);
|
|
|
|
dialog_->labelWidth->setText("");
|
|
|
|
}
|
2002-07-17 15:51:23 +00:00
|
|
|
|
2002-10-20 01:48:28 +00:00
|
|
|
// alignment
|
2002-07-17 15:51:23 +00:00
|
|
|
int i;
|
2002-10-20 01:48:28 +00:00
|
|
|
switch (params.align()) {
|
2002-07-17 15:51:23 +00:00
|
|
|
case LYX_ALIGN_LEFT:
|
|
|
|
i = 1;
|
|
|
|
break;
|
|
|
|
case LYX_ALIGN_RIGHT:
|
|
|
|
i = 2;
|
|
|
|
break;
|
|
|
|
case LYX_ALIGN_CENTER:
|
|
|
|
i = 3;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
i = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
dialog_->align->setCurrentItem(i);
|
2002-07-28 22:50:13 +00:00
|
|
|
|
2002-07-17 15:51:23 +00:00
|
|
|
|
|
|
|
//LyXAlignment alignpos = controller().alignPossible();
|
|
|
|
|
2003-03-28 19:45:53 +00:00
|
|
|
dialog_->indentCB->setChecked(!params.noindent());
|
2002-07-17 15:51:23 +00:00
|
|
|
|
2002-10-20 01:48:28 +00:00
|
|
|
// linespacing
|
2002-07-17 15:51:23 +00:00
|
|
|
int linespacing;
|
2002-10-20 01:48:28 +00:00
|
|
|
Spacing const & space = params.spacing();
|
2002-07-17 15:51:23 +00:00
|
|
|
switch (space.getSpace()) {
|
|
|
|
case Spacing::Single:
|
|
|
|
linespacing = 1;
|
|
|
|
break;
|
|
|
|
case Spacing::Onehalf:
|
|
|
|
linespacing = 2;
|
|
|
|
break;
|
|
|
|
case Spacing::Double:
|
|
|
|
linespacing = 3;
|
|
|
|
break;
|
|
|
|
case Spacing::Other:
|
|
|
|
linespacing = 4;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
linespacing = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
dialog_->linespacing->setCurrentItem(linespacing);
|
|
|
|
if (space.getSpace() == Spacing::Other) {
|
2005-01-06 13:48:13 +00:00
|
|
|
dialog_->linespacingValue->setText(toqstr(space.getValueAsString()));
|
2002-07-17 15:51:23 +00:00
|
|
|
dialog_->linespacingValue->setEnabled(true);
|
|
|
|
} else {
|
|
|
|
dialog_->linespacingValue->setText("");
|
|
|
|
dialog_->linespacingValue->setEnabled(false);
|
|
|
|
}
|
2001-02-14 19:43:56 +00:00
|
|
|
}
|
2004-05-19 15:11:37 +00:00
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|