]> git.lyx.org Git - features.git/commitdiff
Juergen's wrap dialog for Qt
authorJohn Levon <levon@movementarian.org>
Mon, 7 Oct 2002 16:41:10 +0000 (16:41 +0000)
committerJohn Levon <levon@movementarian.org>
Mon, 7 Oct 2002 16:41:10 +0000 (16:41 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5366 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt2/ChangeLog
src/frontends/qt2/Dialogs.C
src/frontends/qt2/Dialogs2.C
src/frontends/qt2/Dialogs_impl.h
src/frontends/qt2/Makefile.dialogs
src/frontends/qt2/QWrap.C [new file with mode: 0644]
src/frontends/qt2/QWrap.h [new file with mode: 0644]
src/frontends/qt2/QWrapDialog.C [new file with mode: 0644]
src/frontends/qt2/QWrapDialog.h [new file with mode: 0644]
src/frontends/qt2/ui/QWrapDialog.ui [new file with mode: 0644]

index b509b1bb3e395c1c23f2e2d8656c72aadda6d184..0ca4a5e65455932dd07ac52a49f92fb3cc0ada7a 100644 (file)
@@ -1,3 +1,13 @@
+2002-09-28  Juergen Spitzmueller  <j.spitzmueller@gmx.de>
+
+       * ui/QWrapDialog.ui:
+       * QWrapDialog.[Ch]:
+       * QWrap.[Ch]:
+       * Makefile.dialogs:
+       * Dialogs.C:
+       * Dialogs2.C:
+       * Dialogs_impl.h: Implement Wrap figure dialog
 2002-09-25  Angus Leeming  <leeming@lyx.org>
 
        * Dialogs2.C:
index 6d7962e9f4c3147560cfa33f052a0ffccec50365..467b04938bfc03424cc31aa05d94ff55a4ff8573 100644 (file)
@@ -74,5 +74,6 @@ Dialogs::Impl::Impl(LyXView & lv, Dialogs & d)
 
          toc(lv, d),
          url(lv, d),
-         vclogfile(lv, d)
+         vclogfile(lv, d),
+         wrap(lv, d)
 {}
index d803ee634ab7f76c0e8f121a4d341c7dc2b05012..e0f8cb7f47e463e530f72885a95bc78543754543 100644 (file)
@@ -276,7 +276,7 @@ void Dialogs::showVCLogFile()
 }
 
 
-void Dialogs::showWrap(InsetWrap * i)
+void Dialogs::showWrap(InsetWrap * iw)
 {
-       // FIXME 
-} 
+       pimpl_->wrap.controller().showInset(iw);
+}
index 9d3446e35213fa945c152b85ad112cfb51c19f1b..ba61490317f66c6adc72039dd3c7d89ddc1a6ebf 100644 (file)
 #include "QURLDialog.h"
 #include "QVCLog.h"
 #include "QVCLogDialog.h"
+#include "QWrap.h"
+#include "QWrapDialog.h"
 
 #include "Qt2BC.h"
 
@@ -205,6 +207,9 @@ UrlDialog;
 typedef GUI<ControlVCLog, QVCLog, OkCancelPolicy, Qt2BC>
 VCLogFileDialog;
 
+typedef GUI<ControlWrap, QWrap, NoRepeatedApplyReadOnlyPolicy, Qt2BC>
+WrapDialog;
+
 
 struct Dialogs::Impl {
        Impl(LyXView & lv, Dialogs & d);
@@ -240,6 +245,7 @@ struct Dialogs::Impl {
        TocDialog           toc;
        UrlDialog           url;
        VCLogFileDialog     vclogfile;
+       WrapDialog          wrap;
 };
 
 #endif // DIALOGS_IMPL_H
index c20e3db1d74922213e7d29f7c93970fbc6fe7b49..722256ab25edb64b066ba7e49b4cb1a780898ef2 100644 (file)
@@ -29,7 +29,8 @@ DIALOGS = \
        QThesaurus \
        QToc \
        QURL \
-       QVCLog
+       QVCLog \
+       QWrap
  
 DIALOGSOURCES = \
        QAbout.h QAboutDialog.h \
@@ -88,7 +89,9 @@ DIALOGSOURCES = \
        QURL.h QURLDialog.h \
        QURL.C QURLDialog.C \
        QVCLog.h QVCLogDialog.h \
-       QVCLog.C QVCLogDialog.C
+       QVCLog.C QVCLogDialog.C \
+       QWrap.h QWrapDialog.h \
+       QWrap.C QWrapDialog.C
  
 MOCDIALOGS = \
        QAboutDialog_moc.C \
@@ -119,7 +122,8 @@ MOCDIALOGS = \
        QThesaurusDialog_moc.C \
        QTocDialog_moc.C \
        QURLDialog_moc.C \
-       QVCLogDialog_moc.C
+       QVCLogDialog_moc.C \
+       QWrapDialog_moc.C
  
 UIDIALOGS = \
        QAboutDialogBase.h \
@@ -181,7 +185,9 @@ UIDIALOGS = \
        QURLDialogBase.h \
        QURLDialogBase.C \
        QVCLogDialogBase.h \
-       QVCLogDialogBase.C
+       QVCLogDialogBase.C \
+       QWrapDialogBase.h \
+       QWrapDialogBase.C
  
 UIMOCDIALOGS = \
        QAboutDialogBase_moc.C \
@@ -213,4 +219,5 @@ UIMOCDIALOGS = \
        QThesaurusDialogBase_moc.C \
        QTocDialogBase_moc.C \
        QURLDialogBase_moc.C \
-       QVCLogDialogBase_moc.C
+       QVCLogDialogBase_moc.C \
+       QWrapDialogBase_moc.C
diff --git a/src/frontends/qt2/QWrap.C b/src/frontends/qt2/QWrap.C
new file mode 100644 (file)
index 0000000..4588962
--- /dev/null
@@ -0,0 +1,106 @@
+/**
+ * \file QWrap.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Juergen Spitzmueller
+ *
+ * Full author contact details are available in file CREDITS
+ */
+
+#include <config.h>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "debug.h"
+#include "gettext.h"
+#include "support/lstrings.h"
+#include "LyXView.h"
+#include "ControlWrap.h"
+
+#include "QWrap.h"
+#include "QWrapDialog.h"
+#include "Qt2BC.h"
+#include "lengthcombo.h"
+#include <qpushbutton.h>
+#include <qcombobox.h>
+#include <qlineedit.h>
+
+typedef Qt2CB<ControlWrap, Qt2DB<QWrapDialog> > base_class;
+
+QWrap::QWrap()
+       : base_class(_("Wrap Options"))
+{
+}
+
+
+void QWrap::build_dialog()
+{
+       dialog_.reset(new QWrapDialog(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_->valignCO);
+}
+
+
+void QWrap::apply()
+{
+       double const value = strToDbl(dialog_->widthED->text().latin1());
+       LyXLength::UNIT unit = dialog_->unitsLC->currentLengthItem();
+       if (string(dialog_->widthED->text().latin1()).empty())
+               unit = LyXLength::UNIT_NONE;
+
+       controller().params().pageWidth = LyXLength(value, unit);
+
+       switch (dialog_->valignCO->currentItem()) {
+       case 0:
+               controller().params().placement.erase();
+               break;
+       case 1:
+               controller().params().placement = "l";
+               break;
+       case 2:
+               controller().params().placement = "r";
+               break;
+       case 3:
+               controller().params().placement = "p";
+               break;
+       }
+}
+
+
+namespace {
+       string const numtostr(double val) {
+               string a(tostr(val));
+               if (a == "0")
+                       a = "";
+               return a;
+       }
+} // namespace anon
+
+
+void QWrap::update_contents()
+{
+       LyXLength len(controller().params().pageWidth);
+       dialog_->widthED->setText(numtostr(len.value()).c_str());
+       dialog_->unitsLC->setCurrentItem(len.unit());
+
+       int item = 0;
+       if (controller().params().placement == "l")
+               item = 1;
+       else if (controller().params().placement == "r")
+               item = 2;
+       else if (controller().params().placement == "p")
+               item = 3;
+
+       dialog_->valignCO->setCurrentItem(item);
+}
diff --git a/src/frontends/qt2/QWrap.h b/src/frontends/qt2/QWrap.h
new file mode 100644 (file)
index 0000000..3fc085d
--- /dev/null
@@ -0,0 +1,43 @@
+// -*- C++ -*-
+/**
+ * \file QWrap.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Juergen Spitzmueller
+ *
+ * Full author contact details are available in file CREDITS
+ */
+
+#ifndef QWRAP_H
+#define QWRAP_H
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include "Qt2Base.h"
+
+class ControlWrap;
+class QWrapDialog;
+
+
+class QWrap
+       : public Qt2CB<ControlWrap, Qt2DB<QWrapDialog> >
+{
+public:
+
+       friend class QWrapDialog;
+
+       QWrap();
+
+private:
+       /// Apply changes
+       virtual void apply();
+       /// update
+       virtual void update_contents();
+       /// build the dialog
+       virtual void build_dialog();
+};
+
+#endif // QWRAP_H
diff --git a/src/frontends/qt2/QWrapDialog.C b/src/frontends/qt2/QWrapDialog.C
new file mode 100644 (file)
index 0000000..ea0bef8
--- /dev/null
@@ -0,0 +1,53 @@
+/**
+ * \file QWrapDialog.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Juergen Spitzmueller
+ *
+ * Full author contact details are available in file CREDITS
+ */
+
+#include <config.h>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include <vector>
+
+#include "ControlWrap.h"
+
+#include "QWrap.h"
+#include "QWrapDialog.h"
+
+#include <qpushbutton.h>
+#include <qtextview.h>
+#include "lengthcombo.h"
+
+QWrapDialog::QWrapDialog(QWrap * form)
+       : QWrapDialogBase(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 QWrapDialog::closeEvent(QCloseEvent * e)
+{
+       form_->slotWMHide();
+       e->accept();
+}
+
+
+void QWrapDialog::change_adaptor()
+{
+       form_->changed();
+}
diff --git a/src/frontends/qt2/QWrapDialog.h b/src/frontends/qt2/QWrapDialog.h
new file mode 100644 (file)
index 0000000..def8301
--- /dev/null
@@ -0,0 +1,39 @@
+// -*- C++ -*-
+/**
+ * \file QWrapDialog.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Juergen Spitzmueller
+ *
+ * Full author contact details are available in file CREDITS
+ */
+
+#ifndef QWRAPDIALOG_H
+#define QWRAPDIALOG_H
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include "ui/QWrapDialogBase.h"
+
+class QWrap;
+
+class QWrapDialog : public QWrapDialogBase
+{ Q_OBJECT
+
+public:
+       QWrapDialog(QWrap * form);
+
+protected slots:
+       virtual void change_adaptor();
+
+protected:
+       virtual void closeEvent(QCloseEvent * e);
+
+private:
+       QWrap * form_;
+};
+
+#endif // QWRAPDIALOG_H
diff --git a/src/frontends/qt2/ui/QWrapDialog.ui b/src/frontends/qt2/ui/QWrapDialog.ui
new file mode 100644 (file)
index 0000000..7b1ee9a
--- /dev/null
@@ -0,0 +1,382 @@
+<!DOCTYPE UI><UI>
+<class>QWrapDialogBase</class>
+<include location="global">config.h</include>
+<include location="local">gettext.h</include>
+<include location="local">vspace.h</include>
+<widget>
+    <class>QDialog</class>
+    <property stdset="1">
+        <name>name</name>
+        <cstring>QWrapDialogBase</cstring>
+    </property>
+    <property stdset="1">
+        <name>geometry</name>
+        <rect>
+            <x>0</x>
+            <y>0</y>
+            <width>369</width>
+            <height>111</height>
+        </rect>
+    </property>
+    <property stdset="1">
+        <name>caption</name>
+        <string>Wrap Options</string>
+    </property>
+    <property stdset="1">
+        <name>sizeGripEnabled</name>
+        <bool>true</bool>
+    </property>
+    <property>
+        <name>layoutMargin</name>
+    </property>
+    <property>
+        <name>layoutSpacing</name>
+    </property>
+    <vbox>
+        <property stdset="1">
+            <name>margin</name>
+            <number>11</number>
+        </property>
+        <property stdset="1">
+            <name>spacing</name>
+            <number>6</number>
+        </property>
+        <widget>
+            <class>QLayoutWidget</class>
+            <property stdset="1">
+                <name>name</name>
+                <cstring>Layout3</cstring>
+            </property>
+            <grid>
+                <property stdset="1">
+                    <name>margin</name>
+                    <number>0</number>
+                </property>
+                <property stdset="1">
+                    <name>spacing</name>
+                    <number>6</number>
+                </property>
+                <widget row="0"  column="0" >
+                    <class>QLabel</class>
+                    <property stdset="1">
+                        <name>name</name>
+                        <cstring>widthLA</cstring>
+                    </property>
+                    <property stdset="1">
+                        <name>frameShape</name>
+                        <enum>MShape</enum>
+                    </property>
+                    <property stdset="1">
+                        <name>frameShadow</name>
+                        <enum>MShadow</enum>
+                    </property>
+                    <property stdset="1">
+                        <name>text</name>
+                        <string>&amp;Width:</string>
+                    </property>
+                    <property>
+                        <name>buddy</name>
+                        <cstring>widthED</cstring>
+                    </property>
+                </widget>
+                <widget row="1"  column="2" >
+                    <class>QComboBox</class>
+                    <item>
+                        <property>
+                            <name>text</name>
+                            <string>Default (outer)</string>
+                        </property>
+                    </item>
+                    <item>
+                        <property>
+                            <name>text</name>
+                            <string>Left</string>
+                        </property>
+                    </item>
+                    <item>
+                        <property>
+                            <name>text</name>
+                            <string>Right</string>
+                        </property>
+                    </item>
+                    <item>
+                        <property>
+                            <name>text</name>
+                            <string>Outer</string>
+                        </property>
+                    </item>
+                    <property stdset="1">
+                        <name>name</name>
+                        <cstring>valignCO</cstring>
+                    </property>
+                    <property>
+                        <name>toolTip</name>
+                        <string>Vertical alignment</string>
+                    </property>
+                </widget>
+                <widget row="0"  column="2" >
+                    <class>QLabel</class>
+                    <property stdset="1">
+                        <name>name</name>
+                        <cstring>valignLA</cstring>
+                    </property>
+                    <property stdset="1">
+                        <name>text</name>
+                        <string>&amp;Placement:</string>
+                    </property>
+                    <property>
+                        <name>buddy</name>
+                        <cstring>valignCO</cstring>
+                    </property>
+                </widget>
+                <widget row="1"  column="1" >
+                    <class>LengthCombo</class>
+                    <property stdset="1">
+                        <name>name</name>
+                        <cstring>unitsLC</cstring>
+                    </property>
+                    <property stdset="1">
+                        <name>sizePolicy</name>
+                        <sizepolicy>
+                            <hsizetype>3</hsizetype>
+                            <vsizetype>0</vsizetype>
+                        </sizepolicy>
+                    </property>
+                    <property stdset="1">
+                        <name>minimumSize</name>
+                        <size>
+                            <width>40</width>
+                            <height>22</height>
+                        </size>
+                    </property>
+                    <property stdset="1">
+                        <name>focusPolicy</name>
+                        <enum>StrongFocus</enum>
+                    </property>
+                    <property>
+                        <name>toolTip</name>
+                        <string>Units of width value</string>
+                    </property>
+                </widget>
+                <widget row="1"  column="0" >
+                    <class>QLineEdit</class>
+                    <property stdset="1">
+                        <name>name</name>
+                        <cstring>widthED</cstring>
+                    </property>
+                    <property stdset="1">
+                        <name>sizePolicy</name>
+                        <sizepolicy>
+                            <hsizetype>1</hsizetype>
+                            <vsizetype>0</vsizetype>
+                        </sizepolicy>
+                    </property>
+                    <property>
+                        <name>toolTip</name>
+                        <string>Width value</string>
+                    </property>
+                </widget>
+                <widget row="0"  column="1" >
+                    <class>QLabel</class>
+                    <property stdset="1">
+                        <name>name</name>
+                        <cstring>unitsLA</cstring>
+                    </property>
+                    <property stdset="1">
+                        <name>text</name>
+                        <string>&amp;Units:</string>
+                    </property>
+                    <property>
+                        <name>buddy</name>
+                        <cstring>unitsLC</cstring>
+                    </property>
+                </widget>
+            </grid>
+        </widget>
+        <spacer>
+            <property>
+                <name>name</name>
+                <cstring>Spacer1_2</cstring>
+            </property>
+            <property stdset="1">
+                <name>orientation</name>
+                <enum>Vertical</enum>
+            </property>
+            <property stdset="1">
+                <name>sizeType</name>
+                <enum>Expanding</enum>
+            </property>
+            <property>
+                <name>sizeHint</name>
+                <size>
+                    <width>20</width>
+                    <height>20</height>
+                </size>
+            </property>
+        </spacer>
+        <widget>
+            <class>QLayoutWidget</class>
+            <property stdset="1">
+                <name>name</name>
+                <cstring>Layout17</cstring>
+            </property>
+            <hbox>
+                <property stdset="1">
+                    <name>margin</name>
+                    <number>0</number>
+                </property>
+                <property stdset="1">
+                    <name>spacing</name>
+                    <number>6</number>
+                </property>
+                <widget>
+                    <class>QPushButton</class>
+                    <property stdset="1">
+                        <name>name</name>
+                        <cstring>restorePB</cstring>
+                    </property>
+                    <property stdset="1">
+                        <name>text</name>
+                        <string>&amp;Restore</string>
+                    </property>
+                    <property stdset="1">
+                        <name>default</name>
+                        <bool>false</bool>
+                    </property>
+                    <property>
+                        <name>toolTip</name>
+                        <string></string>
+                    </property>
+                </widget>
+                <spacer>
+                    <property>
+                        <name>name</name>
+                        <cstring>Spacer1</cstring>
+                    </property>
+                    <property stdset="1">
+                        <name>orientation</name>
+                        <enum>Horizontal</enum>
+                    </property>
+                    <property stdset="1">
+                        <name>sizeType</name>
+                        <enum>Expanding</enum>
+                    </property>
+                    <property>
+                        <name>sizeHint</name>
+                        <size>
+                            <width>20</width>
+                            <height>20</height>
+                        </size>
+                    </property>
+                </spacer>
+                <widget>
+                    <class>QPushButton</class>
+                    <property stdset="1">
+                        <name>name</name>
+                        <cstring>okPB</cstring>
+                    </property>
+                    <property stdset="1">
+                        <name>text</name>
+                        <string>&amp;OK</string>
+                    </property>
+                    <property stdset="1">
+                        <name>default</name>
+                        <bool>false</bool>
+                    </property>
+                    <property>
+                        <name>toolTip</name>
+                        <string></string>
+                    </property>
+                </widget>
+                <widget>
+                    <class>QPushButton</class>
+                    <property stdset="1">
+                        <name>name</name>
+                        <cstring>applyPB</cstring>
+                    </property>
+                    <property stdset="1">
+                        <name>text</name>
+                        <string>&amp;Apply</string>
+                    </property>
+                    <property stdset="1">
+                        <name>default</name>
+                        <bool>false</bool>
+                    </property>
+                    <property>
+                        <name>toolTip</name>
+                        <string></string>
+                    </property>
+                </widget>
+                <widget>
+                    <class>QPushButton</class>
+                    <property stdset="1">
+                        <name>name</name>
+                        <cstring>closePB</cstring>
+                    </property>
+                    <property stdset="1">
+                        <name>text</name>
+                        <string>&amp;Close</string>
+                    </property>
+                    <property stdset="1">
+                        <name>default</name>
+                        <bool>true</bool>
+                    </property>
+                </widget>
+            </hbox>
+        </widget>
+    </vbox>
+</widget>
+<customwidgets>
+    <customwidget>
+        <class>LengthCombo</class>
+        <header location="local">lengthcombo.h</header>
+        <sizehint>
+            <width>-1</width>
+            <height>-1</height>
+        </sizehint>
+        <container>0</container>
+        <sizepolicy>
+            <hordata>5</hordata>
+            <verdata>5</verdata>
+        </sizepolicy>
+        <pixmap>image0</pixmap>
+        <signal>selectionChanged(LyXLength::UNIT)</signal>
+    </customwidget>
+</customwidgets>
+<images>
+    <image>
+        <name>image0</name>
+        <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data>
+    </image>
+</images>
+<connections>
+    <connection>
+        <sender>widthED</sender>
+        <signal>textChanged(const QString&amp;)</signal>
+        <receiver>QWrapDialogBase</receiver>
+        <slot>change_adaptor()</slot>
+    </connection>
+    <connection>
+        <sender>unitsLC</sender>
+        <signal>selectionChanged(LyXLength::UNIT)</signal>
+        <receiver>QWrapDialogBase</receiver>
+        <slot>change_adaptor()</slot>
+    </connection>
+    <connection>
+        <sender>valignCO</sender>
+        <signal>highlighted(const QString&amp;)</signal>
+        <receiver>QWrapDialogBase</receiver>
+        <slot>change_adaptor()</slot>
+    </connection>
+    <slot access="public">change_adaptor()</slot>
+</connections>
+<tabstops>
+    <tabstop>widthED</tabstop>
+    <tabstop>unitsLC</tabstop>
+    <tabstop>valignCO</tabstop>
+    <tabstop>restorePB</tabstop>
+    <tabstop>applyPB</tabstop>
+    <tabstop>okPB</tabstop>
+    <tabstop>closePB</tabstop>
+</tabstops>
+</UI>