From ead11eb6b5fae67d0e19e44aa953e225db219d41 Mon Sep 17 00:00:00 2001 From: John Levon Date: Wed, 29 Aug 2001 02:08:04 +0000 Subject: [PATCH] add minipage dialog git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2610 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt2/ChangeLog | 11 + src/frontends/qt2/Dialogs.C | 27 +- src/frontends/qt2/Makefile.am | 5 +- src/frontends/qt2/Makefile.dialogs | 7 + src/frontends/qt2/QMinipage.C | 101 +++++ src/frontends/qt2/QMinipage.h | 41 ++ src/frontends/qt2/QMinipageDialog.C | 48 +++ src/frontends/qt2/QMinipageDialog.h | 34 ++ src/frontends/qt2/lengthcombo.C | 98 +++++ src/frontends/qt2/lengthcombo.h | 41 ++ src/frontends/qt2/moc/Makefile.am | 1 + src/frontends/qt2/ui/QMinipageDialog.ui | 543 ++++++++++++++++++++++++ 12 files changed, 943 insertions(+), 14 deletions(-) create mode 100644 src/frontends/qt2/QMinipage.C create mode 100644 src/frontends/qt2/QMinipage.h create mode 100644 src/frontends/qt2/QMinipageDialog.C create mode 100644 src/frontends/qt2/QMinipageDialog.h create mode 100644 src/frontends/qt2/lengthcombo.C create mode 100644 src/frontends/qt2/lengthcombo.h create mode 100644 src/frontends/qt2/ui/QMinipageDialog.ui diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index f642b5258b..87985af0ae 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,14 @@ +2001-08-29 John Levon + + * QMinipage.[Ch]: + * QMinipageDialog.[Ch]: + * ui/QMinipageDialog.ui: + * lengthcombo.[Ch]: + * Makefile.am: + * moc/Makefile.am: + * Makefile.dialogs: + * Dialogs.C: add minipage and prototype length combo widget + 2001-08-29 John Levon * QLog.[Ch]: diff --git a/src/frontends/qt2/Dialogs.C b/src/frontends/qt2/Dialogs.C index 6ad64d6215..f22d3db81e 100644 --- a/src/frontends/qt2/Dialogs.C +++ b/src/frontends/qt2/Dialogs.C @@ -21,15 +21,16 @@ #include "QERTDialog.h" #include "QExternalDialog.h" #include "QGraphicsDialog.h" -#include "QIncludeDialog.h" +#include "QIncludeDialog.h" #include "QIndexDialog.h" #include "QLogDialog.h" +#include "QMinipageDialog.h" #include "QRefDialog.h" #include "QTabularCreateDialog.h" #include "QThesaurusDialog.h" #include "QURLDialog.h" #include "QVCLogDialog.h" - + #include "QAbout.h" #include "QBibitem.h" #include "QBibtex.h" @@ -42,6 +43,7 @@ #include "QInclude.h" #include "QIndex.h" #include "QLog.h" +#include "QMinipage.h" #include "QParagraph.h" #include "QPrint.h" #include "QRef.h" @@ -52,7 +54,7 @@ #include "QURL.h" #include "QVCLog.h" -#include "QtLyXView.h" +#include "QtLyXView.h" #include "Dialogs.h" #include "BufferView.h" #include "buffer.h" @@ -71,18 +73,18 @@ #include "controllers/ControlInclude.h" #include "controllers/ControlIndex.h" #include "controllers/ControlLog.h" +#include "controllers/ControlMinipage.h" #include "controllers/ControlRef.h" #include "controllers/ControlSplash.h" #include "controllers/ControlTabularCreate.h" #include "controllers/ControlThesaurus.h" -#include "controllers/ControlUrl.h" +#include "controllers/ControlUrl.h" #include "controllers/ControlVCLog.h" #if 0 #include "controllers/ControlButtons.h" #include "controllers/ControlCitation.h" #include "controllers/ControlFloat.h" #include "controllers/ControlLabel.h" -#include "controllers/ControlMinipage.h" #include "controllers/ControlPreamble.h" #include "controllers/ControlPrint.h" #include "controllers/ControlRef.h" @@ -92,7 +94,7 @@ #endif #include "GUI.h" - + // this makes no real sense for Qt2 SigC::Signal0 Dialogs::redrawGUI; @@ -107,16 +109,17 @@ Dialogs::Dialogs(LyXView * lv) add(new GUIBibitem(*lv, *this)); add(new GUIBibtex(*lv, *this)); add(new GUICharacter(*lv, *this)); - add(new GUIError(*lv, *this)); - add(new GUIERT(*lv, *this)); - add(new GUIExternal(*lv, *this)); + add(new GUIError(*lv, *this)); + add(new GUIERT(*lv, *this)); + add(new GUIExternal(*lv, *this)); add(new GUIGraphics(*lv, *this)); - add(new GUIInclude(*lv, *this)); + add(new GUIInclude(*lv, *this)); add(new GUIIndex(*lv, *this)); - add(new GUILog(*lv, *this)); + add(new GUILog(*lv, *this)); + add(new GUIMinipage(*lv, *this)); add(new GUIRef(*lv, *this)); add(new GUITabularCreate(*lv, *this)); - add(new GUIThesaurus(*lv, *this)); + add(new GUIThesaurus(*lv, *this)); add(new GUIUrl(*lv, *this)); add(new GUIVCLog(*lv, *this)); diff --git a/src/frontends/qt2/Makefile.am b/src/frontends/qt2/Makefile.am index f661d496cb..1598ee106b 100644 --- a/src/frontends/qt2/Makefile.am +++ b/src/frontends/qt2/Makefile.am @@ -27,7 +27,6 @@ libqt2_la_OBJADD = \ ../xforms/FormDocument.lo \ ../xforms/FormIndex.lo \ ../xforms/FormInset.lo \ - ../xforms/FormMinipage.lo \ ../xforms/FormPreamble.lo \ ../xforms/FormPreferences.lo \ ../xforms/FormRef.lo \ @@ -77,4 +76,6 @@ libqt2_la_SOURCES = \ Qt2BC.C \ Qt2BC.h \ emptytable.C \ - emptytable.h + emptytable.h \ + lengthcombo.C \ + lengthcombo.h diff --git a/src/frontends/qt2/Makefile.dialogs b/src/frontends/qt2/Makefile.dialogs index 65ec673613..733deae42d 100644 --- a/src/frontends/qt2/Makefile.dialogs +++ b/src/frontends/qt2/Makefile.dialogs @@ -14,6 +14,7 @@ DIALOGS = \ QInclude \ QIndex \ QLog \ + QMinipage \ QParagraph \ QPrint \ QRef \ @@ -52,6 +53,8 @@ DIALOGSOURCES = \ QIndex.C QIndexDialog.C \ QLog.h QLogDialog.h \ QLog.C QLogDialog.C \ + QMinipage.h QMinipageDialog.h \ + QMinipage.C QMinipageDialog.C \ QParagraph.h QParagraphDialog.h \ QParagraph.C QParagraphDialog.C \ QPrint.h QPrintDialog.h \ @@ -87,6 +90,7 @@ MOCDIALOGS = \ QIncludeDialog_moc.C \ QIndexDialog_moc.C \ QLogDialog_moc.C \ + QMinipageDialog_moc.C \ QParagraphDialog_moc.C \ QPrintDialog_moc.C \ QRefDialog_moc.C \ @@ -125,6 +129,8 @@ UIDIALOGS = \ QIndexDialogBase.C \ QLogDialogBase.h \ QLogDialogBase.C \ + QMinipageDialogBase.h \ + QMinipageDialogBase.C \ QParagraphDialogBase.h \ QParagraphDialogBase.C \ QPrintDialogBase.h \ @@ -158,6 +164,7 @@ UIMOCDIALOGS = \ QIncludeDialogBase_moc.C \ QIndexDialogBase_moc.C \ QLogDialogBase_moc.C \ + QMinipageDialogBase_moc.C \ QParagraphDialogBase_moc.C \ QPrintDialogBase_moc.C \ QRefDialogBase_moc.C \ diff --git a/src/frontends/qt2/QMinipage.C b/src/frontends/qt2/QMinipage.C new file mode 100644 index 0000000000..fabb86d826 --- /dev/null +++ b/src/frontends/qt2/QMinipage.C @@ -0,0 +1,101 @@ +/** + * \file QMinipage.C + * Copyright 2001 the LyX Team + * Read the file COPYING + * + * \author John Levon + */ + +#include + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include +#include +#include +#include "lengthcombo.h" + +#include "QMinipageDialog.h" +#include "QMinipage.h" +#include "Qt2BC.h" +#include "gettext.h" +#include "support/lstrings.h" + +#include "QtLyXView.h" +#include "ControlMinipage.h" + +typedef Qt2CB > base_class; + +QMinipage::QMinipage(ControlMinipage & c) + : base_class(c, _("Minipage")) +{ +} + + +void QMinipage::build_dialog() +{ + dialog_.reset(new QMinipageDialog(this)); + + bc().setRestore(dialog_->restorePB); + bc().setOK(dialog_->okPB); + bc().setApply(dialog_->applyPB); + bc().setCancel(dialog_->closePB); + + bc().addReadOnly(dialog_->widthED); + bc().addReadOnly(dialog_->unitsLC); + bc().addReadOnly(dialog_->topRB); + bc().addReadOnly(dialog_->bottomRB); + bc().addReadOnly(dialog_->middleRB); +} + + +void QMinipage::apply() +{ + double value = strToDbl(dialog_->widthED->text().latin1()); + LyXLength::UNIT unit = dialog_->unitsLC->currentLengthItem(); + if (string(dialog_->widthED->text().latin1()).empty()) + unit = LyXLength::UNIT_NONE; + + LyXLength len(value, unit); + + controller().params().width = len.asString(); + + if (dialog_->topRB->isChecked()) + controller().params().pos = InsetMinipage::top; + else if (dialog_->middleRB->isChecked()) + controller().params().pos = InsetMinipage::center; + else + controller().params().pos = InsetMinipage::bottom; +} + + +namespace { + string const numtostr(double val) { + string a(tostr(val)); + if (a == "0") + a = ""; + return a; + } +} // namespace anon + + +void QMinipage::update_contents() +{ + LyXLength len(controller().params().width.c_str()); + dialog_->widthED->setText(numtostr(len.value()).c_str()); + dialog_->unitsLC->setCurrentItem(len.unit()); + + QRadioButton * button = dialog_->topRB; + + switch (controller().params().pos) { + case InsetMinipage::center: + button = dialog_->middleRB; + break; + case InsetMinipage::bottom: + button = dialog_->bottomRB; + break; + } + button->setChecked(true); +} diff --git a/src/frontends/qt2/QMinipage.h b/src/frontends/qt2/QMinipage.h new file mode 100644 index 0000000000..f53691ecf8 --- /dev/null +++ b/src/frontends/qt2/QMinipage.h @@ -0,0 +1,41 @@ +// -*- C++ -*- +/** + * \file QMinipage.h + * Copyright 2001 the LyX Team + * Read the file COPYING + * + * \author John Levon + */ + +#ifndef QMINIPAGE_H +#define QMINIPAGE_H + +#ifdef __GNUG__ +#pragma interface +#endif + +#include "Qt2Base.h" + +class ControlMinipage; +class QMinipageDialog; + +/// +class QMinipage + : public Qt2CB > +{ +public: + /// + friend class QMinipageDialog; + /// + QMinipage(ControlMinipage &); + +private: + /// Apply changes + virtual void apply(); + /// update + virtual void update_contents(); + /// build the dialog + virtual void build_dialog(); +}; + +#endif // QMINIPAGE_H diff --git a/src/frontends/qt2/QMinipageDialog.C b/src/frontends/qt2/QMinipageDialog.C new file mode 100644 index 0000000000..b3b4661821 --- /dev/null +++ b/src/frontends/qt2/QMinipageDialog.C @@ -0,0 +1,48 @@ +/** + * \file QMinipageDialog.C + * Copyright 2001 the LyX Team + * Read the file COPYING + * + * \author John Levon + */ + +#include +#include + +#include +#include +#include "lengthcombo.h" + +#include "QMinipageDialog.h" +#include "Dialogs.h" +#include "QMinipage.h" + +#include "QtLyXView.h" +#include "ControlMinipage.h" + +QMinipageDialog::QMinipageDialog(QMinipage * form) + : QMinipageDialogBase(0, 0, false, 0), + form_(form) +{ + connect(restorePB, SIGNAL(clicked()), + form, SLOT(slotRestore())); + connect(okPB, SIGNAL(clicked()), + form, SLOT(slotOK())); + connect(applyPB, SIGNAL(clicked()), + form, SLOT(slotApply())); + connect(closePB, SIGNAL(clicked()), + form, SLOT(slotClose())); +} + + +void QMinipageDialog::closeEvent(QCloseEvent * e) +{ + form_->slotWMHide(); + e->accept(); +} + + +void QMinipageDialog::change_adaptor() +{ + form_->changed(); +} diff --git a/src/frontends/qt2/QMinipageDialog.h b/src/frontends/qt2/QMinipageDialog.h new file mode 100644 index 0000000000..553b30f046 --- /dev/null +++ b/src/frontends/qt2/QMinipageDialog.h @@ -0,0 +1,34 @@ +/** + * \file QMinipageDialog.h + * Copyright 2001 the LyX Team + * Read the file COPYING + * + * \author John Levon + */ + +#ifndef QMINIPAGEDIALOG_H +#define QMINIPAGEDIALOG_H + +#include + +#include "ui/QMinipageDialogBase.h" + +class QMinipage; + +class QMinipageDialog : public QMinipageDialogBase +{ Q_OBJECT + +public: + QMinipageDialog(QMinipage * form); + +protected slots: + virtual void change_adaptor(); + +protected: + virtual void closeEvent(QCloseEvent * e); + +private: + QMinipage * form_; +}; + +#endif // QMINIPAGEDIALOG_H diff --git a/src/frontends/qt2/lengthcombo.C b/src/frontends/qt2/lengthcombo.C new file mode 100644 index 0000000000..7b300eb952 --- /dev/null +++ b/src/frontends/qt2/lengthcombo.C @@ -0,0 +1,98 @@ +/** + * \file lengthcombo.C + * Copyright 2001 the LyX Team + * Read the file COPYING + * + * \author John Levon + */ + +#include +#include "gettext.h" + +#include "lengthcombo.h" + +#include + +LengthCombo::LengthCombo(QWidget * parent, char * name) + : QComboBox(parent, name) +{ + insertItem(_("Centimetres")); + insertItem(_("Inches")); + insertItem(_("Points")); + insertItem(_("Millimetres")); + insertItem(_("Picas")); + insertItem(_("ex units")); + insertItem(_("em units")); + insertItem(_("Scaled points")); + insertItem(_("Big/PS points")); + insertItem(_("Didot points")); + insertItem(_("Cicero points")); + insertItem(_("Mathematical units")); + insertItem(_("Percent of page")); + insertItem(_("Percent of column")); + insertItem(_("Percent of line width")); + + connect(this, SIGNAL(activated(int)), + this, SLOT(has_activated(int))); + + QWhatsThis::add(this, _("FIXME - describe the units.")); +} + + +LyXLength::UNIT LengthCombo::currentLengthItem() const +{ + LyXLength::UNIT unit; + int i = currentItem(); + switch (i) { + default: + case 0: unit = LyXLength::CM; break; + case 1: unit = LyXLength::IN; break; + case 2: unit = LyXLength::PT; break; + case 3: unit = LyXLength::MM; break; + case 4: unit = LyXLength::PC; break; + case 5: unit = LyXLength::EX; break; + case 6: unit = LyXLength::EM; break; + case 7: unit = LyXLength::SP; break; + case 8: unit = LyXLength::BP; break; + case 9: unit = LyXLength::DD; break; + case 10: unit = LyXLength::CC; break; + case 11: unit = LyXLength::MU; break; + case 12: unit = LyXLength::PP; break; + case 13: unit = LyXLength::PW; break; + case 14: unit = LyXLength::PL; break; + // FIXME: LyXLength::PE ? + }; + return unit; +} + + +void LengthCombo::has_activated(int) +{ + emit selectionChanged(currentLengthItem()); +} + + +void LengthCombo::setCurrentItem(LyXLength::UNIT unit) +{ + int i; + switch (unit) { + default: + case LyXLength::CM: i = 0; break; + case LyXLength::IN: i = 1; break; + case LyXLength::PT: i = 2; break; + case LyXLength::MM: i = 3; break; + case LyXLength::PC: i = 4; break; + case LyXLength::EX: i = 5; break; + case LyXLength::EM: i = 6; break; + case LyXLength::SP: i = 7; break; + case LyXLength::BP: i = 8; break; + case LyXLength::DD: i = 9; break; + case LyXLength::CC: i = 10; break; + case LyXLength::MU: i = 11; break; + case LyXLength::PP: i = 12; break; + case LyXLength::PW: i = 13; break; + case LyXLength::PL: i = 14; break; + // FIXME: LyXLength::PE ? + } + QComboBox::setCurrentItem(i); +} diff --git a/src/frontends/qt2/lengthcombo.h b/src/frontends/qt2/lengthcombo.h new file mode 100644 index 0000000000..93ab0fed6e --- /dev/null +++ b/src/frontends/qt2/lengthcombo.h @@ -0,0 +1,41 @@ +/** + * \file lengthcombo.h + * Copyright 2001 the LyX Team + * Read the file COPYING + * + * \author John Levon + */ + +#ifndef LENGTHCOMBO_H +#define LENGTHCOMBO_H + +#include + +#include + +#include "vspace.h" + +/** + * A combo box for selecting LyXLength::UNIT types. + */ +class LengthCombo : public QComboBox { + Q_OBJECT +public: + LengthCombo(QWidget * parent, char * name); + + /// set the current item + virtual void setCurrentItem(LyXLength::UNIT unit); + + /// get the current item + LyXLength::UNIT currentLengthItem() const; + +protected slots: + virtual void has_activated(int index); + +signals: + /// the current selection has changed + void selectionChanged(LyXLength::UNIT unit); + +}; + +#endif diff --git a/src/frontends/qt2/moc/Makefile.am b/src/frontends/qt2/moc/Makefile.am index 2147fdcd69..9370ae57f3 100644 --- a/src/frontends/qt2/moc/Makefile.am +++ b/src/frontends/qt2/moc/Makefile.am @@ -14,6 +14,7 @@ include ../Makefile.dialogs libqt2moc_la_SOURCES := FileDialog_private_moc.C \ emptytable_moc.C \ + lengthcombo_moc.C \ Qt2Base_moc.C \ $(MOCDIALOGS) diff --git a/src/frontends/qt2/ui/QMinipageDialog.ui b/src/frontends/qt2/ui/QMinipageDialog.ui new file mode 100644 index 0000000000..576ff6b128 --- /dev/null +++ b/src/frontends/qt2/ui/QMinipageDialog.ui @@ -0,0 +1,543 @@ + +QMinipageDialogBase +config.h +gettext.h +vspace.h + + QDialog + + name + QMinipageDialogBase + + + geometry + + 0 + 0 + 412 + 328 + + + + caption + Minipage settings + + + + margin + 11 + + + spacing + 6 + + + QLayoutWidget + + name + Layout6 + + + + margin + 0 + + + spacing + 6 + + + QButtonGroup + + name + alignmentBG + + + frameShape + Box + + + frameShadow + Sunken + + + title + &Vertical alignment + + + toolTip + Alignment of minipage + + + + margin + 11 + + + spacing + 6 + + + + name + Spacer1 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + QRadioButton + + name + topRB + + + text + &Top + + + toolTip + FIXME + + + + + name + Spacer2 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + QRadioButton + + name + middleRB + + + text + &Middle + + + toolTip + FIXME + + + + + name + Spacer3_2 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + QRadioButton + + name + bottomRB + + + text + &Bottom + + + toolTip + FIXME + + + + + name + Spacer4 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + + + QLayoutWidget + + name + Layout5 + + + + margin + 0 + + + spacing + 6 + + + QLayoutWidget + + name + Layout4 + + + + margin + 0 + + + spacing + 6 + + + QLabel + + name + widthLA + + + text + &Width + + + buddy + widthED + + + + + name + Spacer5 + + + orientation + Horizontal + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + + + QLayoutWidget + + name + Layout3 + + + + margin + 0 + + + spacing + 6 + + + QLineEdit + + name + widthED + + + toolTip + Width value + + + + LengthCombo + + name + unitsLC + + + sizePolicy + + 5 + 1 + + + + minimumSize + + 40 + 20 + + + + focusPolicy + StrongFocus + + + toolTip + Units of width value + + + + + + + name + Spacer6 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + + + + + QLayoutWidget + + name + Layout2 + + + + margin + 0 + + + spacing + 6 + + + QPushButton + + name + restorePB + + + text + &Restore + + + default + true + + + toolTip + + + + + + name + Spacer3 + + + orientation + Horizontal + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + QPushButton + + name + okPB + + + text + &OK + + + default + true + + + toolTip + + + + + QPushButton + + name + applyPB + + + text + &Apply + + + default + true + + + toolTip + + + + + QPushButton + + name + closePB + + + text + &Close + + + + + + + + + LengthCombo +
lengthcombo.h
+ + -1 + -1 + + 0 + + 5 + 5 + + image0 + selectionChanged(LyXLength::UNIT) +
+
+ + + image0 + 789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758 + + + + + applyPB + clicked() + QMinipageDialogBase + updateClicked() + + + topRB + toggled(bool) + QMinipageDialogBase + change_adaptor() + + + middleRB + toggled(bool) + QMinipageDialogBase + change_adaptor() + + + bottomRB + clicked() + QMinipageDialogBase + change_adaptor() + + + widthED + textChanged(const QString&) + QMinipageDialogBase + change_adaptor() + + + unitsLC + selectionChanged(LyXLength::UNIT) + QMinipageDialogBase + change_adaptor() + + change_adaptor() + updateClicked() + + + topRB + middleRB + bottomRB + widthED + unitsLC + restorePB + okPB + applyPB + closePB + +
-- 2.39.2