Juergen's wrap dialog for Qt

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5366 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
John Levon 2002-10-07 16:41:10 +00:00
parent 717fce48c5
commit c8f0a3516c
10 changed files with 656 additions and 9 deletions

View 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:

View 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)
{}

View File

@ -276,7 +276,7 @@ void Dialogs::showVCLogFile()
}
void Dialogs::showWrap(InsetWrap * i)
void Dialogs::showWrap(InsetWrap * iw)
{
// FIXME
}
pimpl_->wrap.controller().showInset(iw);
}

View File

@ -117,6 +117,8 @@
#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

View 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

106
src/frontends/qt2/QWrap.C Normal file
View File

@ -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);
}

43
src/frontends/qt2/QWrap.h Normal file
View File

@ -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

View File

@ -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();
}

View File

@ -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

View File

@ -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>