First attempt at converting copyright dialog to MVC architecture

Changed copyright dialog to new naming scheme


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1821 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Kalle Dalheimer 2001-03-23 22:07:56 +00:00
parent e65f49dd51
commit ab7778e295
15 changed files with 553 additions and 261 deletions

View File

@ -17,10 +17,13 @@
#include "Dialogs.h"
#include "FormCopyrightDialogImpl.h"
#undef emit
#include "FormCharacter.h"
#include "FormCitation.h"
#include "FormCredits.h"
//#include "FormCopyright.h"
#include "FormCopyright.h"
//#include "FormDocument.h"
#include "FormError.h"
#include "FormGraphics.h"
@ -36,6 +39,11 @@
//#include "FormToc.h"
//#include "FormUrl.h"
#include "BufferView.h"
#include "controllers/ControlCopyright.h"
#include "qt2BC.h"
// Signal enabling all visible popups to be redrawn if so desired.
// E.g., when the GUI colours have been remapped.
@ -45,6 +53,14 @@ SigC::Signal0<void> Dialogs::redrawGUI;
Dialogs::Dialogs(LyXView * lv)
{
splash_.reset( new FormSplash(lv, this) );
// dialogs that have been converted to new scheme
add( new GUICopyright<FormCopyright, qt2BC>( *lv, *this ) );
// ------------------------------------------
// dialogs that are still old-style
add( new FormCharacter(lv, this));
add( new FormCitation(lv, this));
// add(new FormCopyright(lv, this));

View File

@ -0,0 +1,121 @@
// -*- C++ -*-
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 2000 The LyX Team.
*
* ======================================================
*
* \author Angus Leeming <a.leeming@ic.ac.uk>
*/
#include <config.h>
#ifdef __GNUG__
#pragma implementation
#endif
#include <qdialog.h>
#undef emit
#include "Dialogs.h"
#include "FormBase.h"
#include "qt2BC.h"
#include "support/LAssert.h"
FormBase::FormBase(ControlBase & c, string const & t)
: ViewBC<qt2BC>(c), title_(t)
{}
void FormBase::show()
{
if (!form()) {
build();
}
update(); // make sure its up-to-date
if (form()->isVisible()) {
form()->raise();
} else {
form()->setCaption( title_.c_str() );
form()->show();
}
}
void FormBase::hide()
{
if (form() && form()->isVisible() )
form()->hide();
}
// void FormBase::InputCB(FL_OBJECT * ob, long data)
// {
// bc().input(input(ob, data));
// }
// ButtonPolicy::SMInput FormBase::input(FL_OBJECT *, long)
// {
// return ButtonPolicy::SMI_VALID;
// }
namespace {
// FormBase * GetForm(QWidget * ob)
// {
// Assert(ob && ob->form && ob->form->u_vdata);
// FormBase * pre = static_cast<FormBase *>(ob->form->u_vdata);
// return pre;
// }
} // namespace anon
// extern "C" int C_FormBaseWMHideCB(FL_FORM * form, void *)
// {
// // Close the dialog cleanly, even if the WM is used to do so.
// Assert(form && form->u_vdata);
// FormBase * pre = static_cast<FormBase *>(form->u_vdata);
// pre->CancelButton();
// return FL_CANCEL;
// }
// extern "C" void C_FormBaseApplyCB(FL_OBJECT * ob, long)
// {
// GetForm(ob)->ApplyButton();
// }
// extern "C" void C_FormBaseOKCB(FL_OBJECT * ob, long)
// {
// GetForm(ob)->OKButton();
// }
// extern "C" void C_FormBaseCancelCB(FL_OBJECT * ob, long)
// {
// FormBase * form = GetForm(ob);
// form->CancelButton();
// }
// extern "C" void C_FormBaseRestoreCB(FL_OBJECT * ob, long)
// {
// GetForm(ob)->RestoreButton();
// }
// extern "C" void C_FormBaseInputCB(FL_OBJECT * ob, long d)
// {
// GetForm(ob)->InputCB(ob, d);
// }

View File

@ -0,0 +1,113 @@
// -*- C++ -*-
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 2000 The LyX Team.
*
* ======================================================
*
* \author Angus Leeming <a.leeming@ic.ac.uk>
*/
#ifndef FORMBASE_H
#define FORMBASE_H
#include <boost/smart_ptr.hpp>
class QDialog;
#ifdef __GNUG__
#pragma interface
#endif
#include "ViewBase.h"
#include "LString.h"
#include "ButtonPolicies.h"
class qt2BC;
/** This class is an Qt2 GUI base class.
*/
class FormBase : public ViewBC<qt2BC>
{
public:
///
FormBase(ControlBase &, string const &);
///
virtual ~FormBase() {}
protected:
/// Build the dialog
virtual void build() = 0;
/// Hide the dialog.
void hide();
/// Create the dialog if necessary, update it and display it.
void show();
private:
/// Pointer to the actual instantiation of xform's form
virtual QDialog* form() const = 0;
// /** Filter the inputs on callback from xforms
// Return true if inputs are valid. */
// virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
private:
/// dialog title, displayed by WM.
string title_;
};
template <class Dialog>
class FormDB: public FormBase
{
protected:
///
FormDB(ControlBase &, string const &);
/// Pointer to the actual instantiation of the Qt dialog
virtual QDialog* form() const;
/// Real GUI implementation.
boost::scoped_ptr<Dialog> dialog_;
};
template <class Dialog>
FormDB<Dialog>::FormDB(ControlBase & c, string const & t)
: FormBase(c, t)
{}
template <class Dialog>
QDialog* FormDB<Dialog>::form() const
{
return dialog_.get();
}
template <class Controller, class Base>
class FormCB: public Base
{
protected:
///
FormCB(ControlBase &, string const &);
/// The parent controller
Controller & controller() const;
};
template <class Controller, class Base>
FormCB<Controller, Base>::FormCB(ControlBase & c, string const & t)
: Base(c, t)
{}
template <class Controller, class Base>
Controller & FormCB<Controller, Base>::controller() const
{
return static_cast<Controller &>(controller_);
//return dynamic_cast<Controller &>(controller_);
}
#endif // FORMBASE_H

View File

@ -2,8 +2,8 @@
formcopyright.cpp - description
-------------------
begin : Thu Feb 3 2000
copyright : (C) 2000 by Jürgen Vigna
email : jug@sad.it
copyright : (C) 2000 by Jürgen Vigna, 2001 by Kalle Dalheimer
email : kalle@klaralvdalens-datakonsult.se
***************************************************************************/
/***************************************************************************
@ -17,37 +17,36 @@
#include <config.h>
#include "Dialogs.h"
#include "FormCopyrightDialogImpl.h"
#include <qlabel.h>
#include <qpushbutton.h>
#undef emit
#include "qt2BC.h"
#include "ControlCopyright.h"
#include "FormCopyright.h"
#include "FormCopyrightDialog.h"
#include "gettext.h"
FormCopyright::FormCopyright(LyXView *v, Dialogs *d)
: dialog_(0), lv_(v), d_(d), h_(0)
typedef FormCB<ControlCopyright, FormDB<FormCopyrightDialogImpl> > base_class;
FormCopyright::FormCopyright( ControlCopyright& c ) :
base_class( c, _( "Copyright and Warranty" ) )
{
// let the dialog be shown
// This is a permanent connection so we won't bother
// storing a copy because we won't be disconnecting.
d->showCopyright.connect(slot(this, &FormCopyright::show));
}
FormCopyright::~FormCopyright()
void FormCopyright::build()
{
delete dialog_;
// PENDING(kalle) Parent???
dialog_.reset( new FormCopyrightDialogImpl() );
dialog_->copyrightLA->setText( controller().getCopyright().c_str() );
dialog_->licenseLA->setText( controller().getLicence().c_str() );
dialog_->disclaimerLA->setText( controller().getDisclaimer().c_str() );
// Manage the cancel/close button
bc().setCancel(dialog_->okPB);
bc().refresh();
}
void FormCopyright::show()
{
if (!dialog_)
dialog_ = new FormCopyrightDialog(0, _("Copyright and Warranty"),
false);
if (!dialog_->isVisible())
h_ = d_->hideAll.connect(slot(this, &FormCopyright::hide));
dialog_->show();
}
void FormCopyright::hide()
{
dialog_->hide();
h_.disconnect();
}

View File

@ -2,8 +2,8 @@
formcopyright.h - description
-------------------
begin : Thu Feb 3 2000
copyright : (C) 2000 by Jürgen Vigna
email : jug@sad.it
copyright : (C) 2000 by Jürgen Vigna, 2001 by Kalle Dalheimer
email : kalle@klaralvdalens-datakonsult.se
***************************************************************************/
/***************************************************************************
@ -18,40 +18,30 @@
#ifndef FORMCOPYRIGHT_H
#define FORMCOPYRIGHT_H
#include "DialogBase.h"
#include "FormBase.h"
#include "boost/utility.hpp"
class Dialogs;
class LyXView;
class FormCopyrightDialog;
class FormCopyrightDialogImpl;
class ControlCopyright;
/**
@author Jürgen Vigna
@author Kalle Dalheimer
*/
class FormCopyright : public DialogBase {
class FormCopyright
: public FormCB<ControlCopyright, FormDB<FormCopyrightDialogImpl> >
{
public:
FormCopyright(LyXView *, Dialogs *);
~FormCopyright();
FormCopyright( ControlCopyright& );
private:
/// Create the dialog if necessary, update it and display it.
void show();
/// Hide the dialog.
void hide();
/// Real GUI implementation.
FormCopyrightDialog * dialog_;
/** Which LyXFunc do we use?
We could modify Dialogs to have a visible LyXFunc* instead and
save a couple of bytes per dialog.
*/
LyXView * lv_;
/** Which Dialogs do we belong to?
Used so we can get at the signals we have to connect to.
*/
Dialogs * d_;
/// Hide connection.
Connection h_;
/// not needed
virtual void apply() {}
/// not needed
virtual void update() {}
// build the dialog
virtual void build();
};
#endif

View File

@ -1,22 +0,0 @@
#include "FormCopyrightDialog.h"
/*
* Constructs a FormCopyrightDialog which is a child of 'parent', with the
* name 'name' and widget flags set to 'f'
*
* The dialog will by default be modeless, unless you set 'modal' to
* TRUE to construct a modal dialog.
*/
FormCopyrightDialog::FormCopyrightDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
: FormCopyrightDialogBase( parent, name, modal, fl )
{
}
/*
* Destroys the object and frees any allocated resources
*/
FormCopyrightDialog::~FormCopyrightDialog()
{
// no need to delete child widgets, Qt does it all for us
}

View File

@ -1,15 +0,0 @@
#ifndef FORMCOPYRIGHTDIALOG_H
#define FORMCOPYRIGHTDIALOG_H
#include "FormCopyrightDialogBase.h"
class FormCopyrightDialog : public FormCopyrightDialogBase
{
Q_OBJECT
public:
FormCopyrightDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
~FormCopyrightDialog();
};
#endif // FORMCOPYRIGHTDIALOG_H

View File

@ -1,17 +1,17 @@
<!DOCTYPE UI><UI>
<class>FormCopyrightDialogBase</class>
<class>FormCopyrightDialog</class>
<widget>
<class>QDialog</class>
<property stdset="1">
<name>name</name>
<cstring>FormCopyrightDialogBase</cstring>
<cstring>FormCopyrightDialog</cstring>
</property>
<property stdset="1">
<name>geometry</name>
<rect>
<x>0</x>
<y>0</y>
<width>472</width>
<width>468</width>
<height>454</height>
</rect>
</property>
@ -32,12 +32,7 @@
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>TextLabel5</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>KLyX is Copyright (C) 1995 by Matthias Ettrich,
1995-2001 by LyX Team</string>
<cstring>copyrightLA</cstring>
</property>
<property stdset="1">
<name>frameShape</name>
@ -51,6 +46,11 @@
<name>margin</name>
<number>6</number>
</property>
<property stdset="1">
<name>text</name>
<string>KLyX is Copyright (C) 1995 by Matthias Ettrich,
1995-2001 by LyX Team</string>
</property>
<property stdset="1">
<name>alignment</name>
<set>AlignCenter</set>
@ -63,11 +63,14 @@
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>TextLabel5_2</cstring>
<cstring>licenseLA</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.</string>
<name>sizePolicy</name>
<sizepolicy>
<hsizetype>1</hsizetype>
<vsizetype>1</vsizetype>
</sizepolicy>
</property>
<property stdset="1">
<name>frameShape</name>
@ -82,15 +85,12 @@
<number>6</number>
</property>
<property stdset="1">
<name>alignment</name>
<set>WordBreak|AlignCenter</set>
<name>text</name>
<string>This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.</string>
</property>
<property stdset="1">
<name>sizePolicy</name>
<sizepolicy>
<hsizetype>1</hsizetype>
<vsizetype>1</vsizetype>
</sizepolicy>
<name>alignment</name>
<set>WordBreak|AlignCenter</set>
</property>
<property>
<name>hAlign</name>
@ -103,20 +103,21 @@
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>TextLabel5_2_2</cstring>
<cstring>disclaimerLA</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>KLyX is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY,
without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General
Public License for more details.
You should have received a copy of the GNU
General Public License along with this program;
if not, write to thee Free Software Foundation, Inc.,
675 Mass Ave, Cambridge, MA 02139, USA.</string>
<name>sizePolicy</name>
<sizepolicy>
<hsizetype>5</hsizetype>
<vsizetype>5</vsizetype>
</sizepolicy>
</property>
<property stdset="1">
<name>minimumSize</name>
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property stdset="1">
<name>frameShape</name>
@ -130,24 +131,23 @@ if not, write to thee Free Software Foundation, Inc.,
<name>margin</name>
<number>6</number>
</property>
<property stdset="1">
<name>text</name>
<string>KLyX is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY,
without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General
Public License for more details.
You should have received a copy of the GNU
General Public License along with this program;
if not, write to the Free Software Foundation, Inc.,
675 Mass Ave, Cambridge, MA 02139, USA.</string>
</property>
<property stdset="1">
<name>alignment</name>
<set>WordBreak|AlignCenter</set>
</property>
<property stdset="1">
<name>sizePolicy</name>
<sizepolicy>
<hsizetype>1</hsizetype>
<vsizetype>1</vsizetype>
</sizepolicy>
</property>
<property stdset="1">
<name>minimumSize</name>
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property>
<name>hAlign</name>
</property>
@ -161,10 +161,6 @@ if not, write to thee Free Software Foundation, Inc.,
<name>name</name>
<cstring>okPB</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>&amp;OK</string>
</property>
<property stdset="1">
<name>sizePolicy</name>
<sizepolicy>
@ -172,6 +168,10 @@ if not, write to thee Free Software Foundation, Inc.,
<vsizetype>0</vsizetype>
</sizepolicy>
</property>
<property stdset="1">
<name>text</name>
<string>&amp;OK</string>
</property>
<property stdset="1">
<name>default</name>
<bool>true</bool>
@ -183,7 +183,7 @@ if not, write to thee Free Software Foundation, Inc.,
<connection>
<sender>okPB</sender>
<signal>clicked()</signal>
<receiver>FormCopyrightDialogBase</receiver>
<receiver>FormCopyrightDialog</receiver>
<slot>reject()</slot>
</connection>
</connections>

View File

@ -1,80 +0,0 @@
/****************************************************************************
** Form implementation generated from reading ui file 'FormCopyrightDialogBase.ui'
**
** Created: Wed Feb 7 18:46:40 2001
** by: The User Interface Compiler (uic)
**
** WARNING! All changes made in this file will be lost!
****************************************************************************/
#include "FormCopyrightDialogBase.h"
#include <qlabel.h>
#include <qpushbutton.h>
#include <qlayout.h>
#include <qvariant.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
/*
* Constructs a FormCopyrightDialogBase which is a child of 'parent', with the
* name 'name' and widget flags set to 'f'
*
* The dialog will by default be modeless, unless you set 'modal' to
* TRUE to construct a modal dialog.
*/
FormCopyrightDialogBase::FormCopyrightDialogBase( QWidget* parent, const char* name, bool modal, WFlags fl )
: QDialog( parent, name, modal, fl )
{
if ( !name )
setName( "FormCopyrightDialogBase" );
resize( 472, 454 );
setCaption( tr( "Form1" ) );
FormCopyrightDialogBaseLayout = new QVBoxLayout( this );
FormCopyrightDialogBaseLayout->setSpacing( 6 );
FormCopyrightDialogBaseLayout->setMargin( 11 );
TextLabel5 = new QLabel( this, "TextLabel5" );
TextLabel5->setText( tr( "LyX is Copyright (C) 1995 by Matthias Ettrich,\n1995-2001 LyX Team" ) );
TextLabel5->setFrameShape( QLabel::Box );
TextLabel5->setFrameShadow( QLabel::Sunken );
TextLabel5->setMargin( 6 );
TextLabel5->setAlignment( int( QLabel::AlignCenter ) );
FormCopyrightDialogBaseLayout->addWidget( TextLabel5 );
TextLabel5_2 = new QLabel( this, "TextLabel5_2" );
TextLabel5_2->setText( tr( "This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version." ) );
TextLabel5_2->setFrameShape( QLabel::Box );
TextLabel5_2->setFrameShadow( QLabel::Sunken );
TextLabel5_2->setMargin( 6 );
TextLabel5_2->setAlignment( int( QLabel::WordBreak | QLabel::AlignCenter ) );
TextLabel5_2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, TextLabel5_2->sizePolicy().hasHeightForWidth() ) );
FormCopyrightDialogBaseLayout->addWidget( TextLabel5_2 );
TextLabel5_2_2 = new QLabel( this, "TextLabel5_2_2" );
TextLabel5_2_2->setText( tr( "LyX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA." ) );
TextLabel5_2_2->setFrameShape( QLabel::Box );
TextLabel5_2_2->setFrameShadow( QLabel::Sunken );
TextLabel5_2_2->setMargin( 6 );
TextLabel5_2_2->setAlignment( int( QLabel::WordBreak | QLabel::AlignCenter ) );
TextLabel5_2_2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, TextLabel5_2_2->sizePolicy().hasHeightForWidth() ) );
TextLabel5_2_2->setMinimumSize( QSize( 0, 0 ) );
FormCopyrightDialogBaseLayout->addWidget( TextLabel5_2_2 );
okPB = new QPushButton( this, "okPB" );
okPB->setText( tr( "&OK" ) );
okPB->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, okPB->sizePolicy().hasHeightForWidth() ) );
okPB->setDefault( TRUE );
FormCopyrightDialogBaseLayout->addWidget( okPB );
// signals and slots connections
connect( okPB, SIGNAL( clicked() ), this, SLOT( reject() ) );
}
/*
* Destroys the object and frees any allocated resources
*/
FormCopyrightDialogBase::~FormCopyrightDialogBase()
{
// no need to delete child widgets, Qt does it all for us
}

View File

@ -1,37 +0,0 @@
/****************************************************************************
** Form interface generated from reading ui file 'FormCopyrightDialogBase.ui'
**
** Created: Wed Jan 24 12:18:18 2001
** by: The User Interface Compiler (uic)
**
** WARNING! All changes made in this file will be lost!
****************************************************************************/
#ifndef FORMCOPYRIGHTDIALOGBASE_H
#define FORMCOPYRIGHTDIALOGBASE_H
#include <qvariant.h>
#include <qdialog.h>
class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class QLabel;
class QPushButton;
class FormCopyrightDialogBase : public QDialog
{
Q_OBJECT
public:
FormCopyrightDialogBase( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
~FormCopyrightDialogBase();
QLabel* TextLabel5;
QLabel* TextLabel5_2;
QLabel* TextLabel5_2_2;
QPushButton* okPB;
protected:
QVBoxLayout* FormCopyrightDialogBaseLayout;
};
#endif // FORMCOPYRIGHTDIALOGBASE_H

View File

@ -0,0 +1,22 @@
#include "FormCopyrightDialogImpl.h"
/*
* Constructs a FormCopyrightDialogImpl which is a child of 'parent', with the
* name 'name' and widget flags set to 'f'
*
* The dialog will by default be modeless, unless you set 'modal' to
* TRUE to construct a modal dialog.
*/
FormCopyrightDialogImpl::FormCopyrightDialogImpl( QWidget* parent, const char* name, bool modal, WFlags fl )
: FormCopyrightDialog( parent, name, modal, fl )
{
}
/*
* Destroys the object and frees any allocated resources
*/
FormCopyrightDialogImpl::~FormCopyrightDialogImpl()
{
// no need to delete child widgets, Qt does it all for us
}

View File

@ -0,0 +1,15 @@
#ifndef FORMCOPYRIGHTDIALOGIMPL_H
#define FORMCOPYRIGHTDIALOGIMPL_H
#include "FormCopyrightDialog.h"
class FormCopyrightDialogImpl : public FormCopyrightDialog
{
Q_OBJECT
public:
FormCopyrightDialogImpl( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
~FormCopyrightDialogImpl();
};
#endif // FORMCOPYRIGHTDIALOGIMPL_H

View File

@ -33,12 +33,10 @@ libqt2_la_OBJADD = \
../controllers/ButtonController.lo \
../xforms/combox.lo \
../xforms/Color.lo \
../xforms/FormBase.lo \
../xforms/FormBaseDeprecated.lo \
../xforms/FormBibitem.lo \
../xforms/FormBibtex.lo \
../xforms/FormBrowser.lo \
../xforms/FormCopyright.lo \
../xforms/FormDocument.lo \
../xforms/FormError.lo \
../xforms/FormExternal.lo \
@ -99,12 +97,20 @@ libqt2_la_SOURCES = \
chardlgimpl.h \
FileDialog.C \
FileDialog_private.C \
FormBase.C \
FormBase.h \
FormCitation.C \
FormCitation.h \
FormCitationDialog.C \
FormCitationDialog.h \
FormCitationDialogImpl.C \
FormCitationDialogImpl.h \
FormCopyright.C \
FormCopyright.h \
FormCopyrightDialog.C \
FormCopyrightDialog.h \
FormCopyrightDialogImpl.C \
FormCopyrightDialogImpl.h \
FormParagraph.C \
FormParagraph.h \
paragraphdlg.C \
@ -134,7 +140,9 @@ libqt2_la_SOURCES = \
tabularcreatedlg.C \
tabularcreatedlg.h \
tabularcreatedlgimpl.C \
tabularcreatedlgimpl.h
tabularcreatedlgimpl.h \
qt2BC.C \
qt2BC.h
# just copied from old lyx repository
dist-hook:
@ -160,6 +168,16 @@ moc_FormCitationDialog.C: FormCitationDialog.h
moc_FormCitationDialogImpl.C: FormCitationDialogImpl.h
$(MOC) -o $@ $<
FormCopyright.C: FormCopyrightDialogImpl.h
FormCopyrightDialog.h: FormCopyrightDialog.ui
$(UIC) -o $@ $<
FormCopyrightDialog.C: FormCopyrightDialog.ui
$(UIC) -impl FormCopyrightDialog.h -o $@ $<
moc_FormCopyrightDialog.C: FormCopyrightDialog.h
$(MOC) -o $@ $<
moc_FormCopyrightDialogImpl.C: FormCopyrightDialogImpl.h
$(MOC) -o $@ $<
FormParagraph.C: paragraphdlg.h
paragraphdlg.h: paragraphdlg.ui
$(UIC) -o $@ $<

65
src/frontends/qt2/qt2BC.C Normal file
View File

@ -0,0 +1,65 @@
/**
* \file xformsBC.C
* Copyright 2001 the LyX Team
* Read the file COPYING
*
* \author Allan Rae <rae@lyx.org>
* \author Angus Leeming <a.leeming@ic.ac.uk>
*/
#include <config.h>
#ifdef __GNUG__
#pragma implementation
#endif
#include "qt2BC.h"
#include <qbutton.h>
qt2BC::qt2BC(string const & cancel, string const & close)
: ButtonControllerBase(cancel, close),
okay_(0), apply_(0), cancel_(0), undo_all_(0), read_only_()
{}
void qt2BC::refresh()
{
if (okay_) {
if (bp().buttonStatus(ButtonPolicy::OKAY)) {
okay_->setEnabled( true );
} else {
okay_->setEnabled( false );
}
}
if (apply_) {
if (bp().buttonStatus(ButtonPolicy::APPLY)) {
apply_->setEnabled( true );
} else {
apply_->setEnabled( false );
}
}
if (undo_all_) {
if (bp().buttonStatus(ButtonPolicy::UNDO_ALL)) {
undo_all_->setEnabled( true );
} else {
undo_all_->setEnabled( false );
}
}
if (cancel_) {
if (bp().buttonStatus(ButtonPolicy::CANCEL)) {
cancel_->setText( cancel_label.c_str() );
} else {
cancel_->setText( close_label.c_str() );
}
}
if (!read_only_.empty()) {
bool enable = true;
if (bp().isReadOnly()) enable = false;
for (std::list<QButton *>::iterator iter = read_only_.begin();
iter != read_only_.end(); ++iter) {
(*iter)->setEnabled( enable );
}
}
}

87
src/frontends/qt2/qt2BC.h Normal file
View File

@ -0,0 +1,87 @@
// -*- C++ -*-
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2000 The LyX Team.
*
* This file Copyright 2000
* Allan Rae
* ======================================================
*
* Author: Allan Rae <rae@lyx.org>
* Non-xforms-specific code stripped-out and placed in a base class by
* Angus Leeming <a.leeming@ic.ac.uk>
*/
#ifndef QT2BC_H
#define QT2BC_H
#include <list>
#ifdef __GNUG__
#pragma interface
#endif
class QButton;
#include "ButtonController.h"
/** General purpose button controller for up to four buttons.
Controls the activation of the OK, Apply and Cancel buttons.
Actually supports 4 buttons in all and it's up to the user to decide on
the activation policy and which buttons correspond to which output of the
state machine.
*/
class qt2BC : public ButtonControllerBase
{
public:
///
qt2BC(string const &, string const &);
/* Initialise Button Functions */
/// Call refresh() when finished setting the buttons.
void setOK(QButton * obj) {
okay_ = obj;
}
///
void setApply(QButton * obj) {
apply_ = obj;
}
///
void setCancel(QButton * obj) {
cancel_ = obj;
}
///
void setUndoAll(QButton * obj) {
undo_all_ = obj;
}
///
void addReadOnly(QButton * obj) {
read_only_.push_front(obj);
}
///
void eraseReadOnly() {
read_only_.erase(read_only_.begin(), read_only_.end());
}
/* Action Functions */
/// force a refresh of the buttons
virtual void refresh();
private:
///
QButton * okay_;
///
QButton * apply_;
///
QButton * cancel_;
///
QButton * undo_all_;
/// List of items to be deactivated when in one of the read-only states
std::list<QButton *> read_only_;
};
#endif // XFORMSBC_H