Merging BRANCH_MVC back into HEAD.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1770 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Angus Leeming 2001-03-15 13:37:04 +00:00
parent a3de819fa3
commit 9c36dd0f40
179 changed files with 6192 additions and 3011 deletions

View File

@ -1,3 +1,9 @@
2001-03-14 Angus Leeming <a.leeming@ic.ac.uk>
* Merging changes from BRANCH_MVC back into HEAD.
* configure.in: added controllers directory to frontends.
2001-03-08 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* INSTALL: remove mention of problem with gettext.

View File

@ -304,6 +304,7 @@ AC_OUTPUT([Makefile \
src/support/Makefile \
src/frontends/Makefile \
src/frontends/support/Makefile \
src/frontends/controllers/Makefile \
src/frontends/xforms/Makefile \
src/frontends/qt2/Makefile \
src/frontends/kde/Makefile \

View File

@ -1,3 +1,9 @@
2001-03-14 Angus Leeming <a.leeming@ic.ac.uk>
* Merging changes from BRANCH_MVC back into HEAD.
* Makefile.am: added controllers/libcontrollers.la to lyx_DEPENDENCIES
2001-03-14 Angus Leeming <a.leeming@ic.ac.uk>
* lyxfunc.C (Dispatch): removed redundant break statement.

View File

@ -11,6 +11,7 @@ lyx_DEPENDENCIES = mathed/libmathed.la insets/libinsets.la \
graphics/libgraphics.la \
frontends/libfrontends.la @FRONTEND_GUILIB@ \
frontends/libfrontends.la \
frontends/controllers/libcontrollers.la \
frontends/support/libfrontendsupport.la support/libsupport.la \
@INCLUDED_SIGC@
lyx_LDADD = $(lyx_DEPENDENCIES) @INTLLIBS@ $(LYX_LIBS) $(SIGC_LIBS) \

View File

@ -1,3 +1,21 @@
2001-03-14 Angus Leeming <a.leeming@ic.ac.uk>
* Merging changes from BRANCH_MVC back into HEAD.
* Makefile.am: added controllers to SUBDIRS.
removed ButtonPolicies.[Ch]. Now in controllers.
* DialogBase.h: commented out abstract method show().
* Dialogs.h: The dialogs are now stored as a
std::vector<boost::shared_ptr<DialogBase> >.
Removed using directives.
(d-tor) removed.
(add): new helper method. Makes code in c-tor a little tidier.
(destroySplash): Moved out of xforms implementation.
* ButtonPolicies.[Ch]: moved to controllers/ButtonPolicies.[Ch]
2001-03-09 John Levon <moz@compsoc.man.ac.uk>
* Dialogs.h: add showExternal signal

View File

@ -40,14 +40,14 @@ class DialogBase : public Object, public noncopyable
public:
/**@name Constructors and Deconstructors */
//@{
///
/// Virtual base destructor
virtual ~DialogBase() {}
//@}
/**@name Signal Targets */
//@{
///
virtual void show() = 0;
//virtual void show() = 0;
///
virtual void hide() = 0;
///

View File

@ -23,14 +23,18 @@
#include "LString.h"
#include <boost/utility.hpp>
#include <boost/smart_ptr.hpp>
class DialogBase;
#ifdef __GNUG__
#pragma interface
#endif
#include "DialogBase.h"
#include "support/LAssert.h"
// Maybe this should be a UIFunc modelled on LyXFunc
class LyXView;
class FormSplash;
class InsetGraphics;
class InsetBibKey;
class InsetBibtex;
@ -41,11 +45,6 @@ class InsetInfo;
class InsetTabular;
class InsetCommand;
#ifdef SIGC_CXX_NAMESPACES
using SigC::Signal0;
using SigC::Signal1;
#endif
/** Container of all dialogs and signals a LyXView needs or uses to access them
The list of dialog signals isn't comprehensive but should be a good guide
for any future additions. Remember don't go overboard -- think minimal.
@ -53,116 +52,129 @@ using SigC::Signal1;
class Dialogs : public noncopyable
{
public:
/**@name Constructors and Deconstructors */
///
typedef boost::shared_ptr<DialogBase> db_ptr;
/**@name Constructor */
//@{
///
Dialogs(LyXView *);
///
~Dialogs();
//@}
/** Redraw all visible popups because, for example, the GUI colours
have been re-mapped. */
static Signal0<void> redrawGUI;
static SigC::Signal0<void> redrawGUI;
/**@name Global Hide and Update Signals */
//@{
/// Hide all visible popups
Signal0<void> hideAll;
SigC::Signal0<void> hideAll;
/// Hide any dialogs that require a buffer for them to operate
Signal0<void> hideBufferDependent;
SigC::Signal0<void> hideBufferDependent;
/** Update visible, buffer-dependent dialogs
If the bool is true then a buffer change has occurred
else its still the same buffer.
*/
Signal1<void, bool> updateBufferDependent;
SigC::Signal1<void, bool> updateBufferDependent;
//@}
/**@name Dialog Access Signals.
Put into some sort of alphabetical order */
//@{
/// Do we really have to push this?
Signal1<void, std::vector<string> const &> SetDocumentClassChoice;
SigC::Signal1<void, std::vector<string> const &> SetDocumentClassChoice;
/// show the key and label of a bibliography entry
Signal1<void, InsetCommand *> showBibitem;
SigC::Signal1<void, InsetCommand *> showBibitem;
/// show the bibtex dialog
Signal1<void, InsetCommand *> showBibtex;
SigC::Signal1<void, InsetCommand *> showBibtex;
///
Signal0<void> showCharacter;
SigC::Signal0<void> showCharacter;
///
Signal1<void, InsetCommand *> showCitation;
SigC::Signal1<void, InsetCommand *> showCitation;
///
Signal1<void, string const &> createCitation;
SigC::Signal1<void, string const &> createCitation;
///
Signal0<void> showCopyright;
SigC::Signal0<void> showCopyright;
///
Signal0<void> showCredits;
SigC::Signal0<void> showCredits;
///
Signal1<void, InsetError *> showError;
SigC::Signal1<void, InsetError *> showError;
/// show the external inset dialog
Signal1<void, InsetExternal *> showExternal;
SigC::Signal1<void, InsetExternal *> showExternal;
///
Signal1<void, InsetGraphics *> showGraphics;
SigC::Signal1<void, InsetGraphics *> showGraphics;
/// show the details of a LyX file include inset
Signal1<void, InsetInclude *> showInclude;
SigC::Signal1<void, InsetInclude *> showInclude;
///
Signal1<void, InsetCommand *> showIndex;
SigC::Signal1<void, InsetCommand *> showIndex;
///
Signal1<void, string const &> createIndex;
SigC::Signal1<void, string const &> createIndex;
///
Signal1<void, InsetInfo *> showInfo;
SigC::Signal1<void, InsetInfo *> showInfo;
///
Signal0<void> showLayoutDocument;
SigC::Signal0<void> showLayoutDocument;
///
Signal0<void> showLayoutParagraph;
SigC::Signal0<void> showLayoutParagraph;
///
Signal0<void> showLayoutCharacter;
SigC::Signal0<void> showLayoutCharacter;
///
Signal0<void> setUserFreeFont;
SigC::Signal0<void> setUserFreeFont;
/// show the version control log
Signal0<void> showVCLogFile;
SigC::Signal0<void> showVCLogFile;
/// show the LaTeX log or build file
Signal0<void> showLogFile;
SigC::Signal0<void> showLogFile;
///
Signal0<void> showPreamble;
SigC::Signal0<void> showPreamble;
///
Signal0<void> showPreferences;
SigC::Signal0<void> showPreferences;
///
Signal0<void> showPrint;
SigC::Signal0<void> showPrint;
///
Signal1<void, InsetCommand *> showRef;
SigC::Signal1<void, InsetCommand *> showRef;
///
Signal1<void, string const &> createRef;
SigC::Signal1<void, string const &> createRef;
///
Signal0<void> showSearch;
SigC::Signal0<void> showSearch;
/// pop up the splash
Signal0<void> showSplash;
SigC::Signal0<void> showSplash;
/// destroy the splash dialog
void destroySplash();
///
Signal1<void, InsetTabular *> showTabular;
SigC::Signal1<void, InsetTabular *> showTabular;
///
Signal1<void, InsetTabular *> updateTabular;
SigC::Signal1<void, InsetTabular *> updateTabular;
///
Signal0<void> showTabularCreate;
SigC::Signal0<void> showTabularCreate;
///
Signal1<void, InsetCommand *> showTOC;
SigC::Signal1<void, InsetCommand *> showTOC;
///
Signal1<void, string const &> createTOC;
SigC::Signal1<void, string const &> createTOC;
///
Signal1<void, InsetCommand *> showUrl;
SigC::Signal1<void, InsetCommand *> showUrl;
///
Signal1<void, string const &> createUrl;
SigC::Signal1<void, string const &> createUrl;
///
Signal0<void> updateCharacter; // allow update as cursor moves
SigC::Signal0<void> updateCharacter; // allow update as cursor moves
//@}
private:
/// Add a dialog to the vector of dialogs.
void add(DialogBase *);
/// the dialogs being managed
std::vector<DialogBase *> dialogs_;
std::vector<db_ptr> dialogs_;
/// the splash dialog
FormSplash * splash_;
boost::scoped_ptr<DialogBase> splash_;
};
inline void Dialogs::add(DialogBase * ptr)
{
Assert(ptr);
dialogs_.push_back(db_ptr(ptr));
}
inline void Dialogs::destroySplash()
{
splash_.reset();
}
#endif

View File

@ -4,15 +4,13 @@ MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
# xforms has to be fixed here as we still need object files in this directory
# for the compilation of other frontends, so until that we have to let this
# here.
SUBDIRS = support xforms @FRONTEND@
SUBDIRS = support xforms controllers @FRONTEND@
ETAGS_ARGS = --lang=c++
BOOST_INCLUDES = -I$(top_srcdir)/boost
INCLUDES = ${FRONTEND_INCLUDES} -I${srcdir}/.. -I${srcdir}/xforms ${SIGC_CFLAGS} $(BOOST_INCLUDES)
LIBS =
noinst_LTLIBRARIES = libfrontends.la
libfrontends_la_SOURCES=\
ButtonPolicies.C \
ButtonPolicies.h \
Dialogs.h \
DialogBase.h \
FileDialog.h \

View File

@ -0,0 +1,6 @@
Makefile.in
Makefile
*.deps
*.lo
.libs
libcontrollers.la

View File

@ -0,0 +1,98 @@
// -*- C++ -*-
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 2000 The LyX Team.
*
* ======================================================
*
* \file ButtonController.C
* \author Allan Rae
*/
#ifdef __GNUG__
#pragma implementation
#endif
#include <config.h>
#include "ButtonController.h"
#include "support/LAssert.h"
ButtonControllerBase::ButtonControllerBase(string const & cancel,
string const & close)
: cancel_label(cancel), close_label(close)
{}
void ButtonControllerBase::ok()
{
input(ButtonPolicy::SMI_OKAY);
}
void ButtonControllerBase::input(ButtonPolicy::SMInput in)
{
if (ButtonPolicy::SMI_NOOP == in) return;
bp().input(in);
refresh();
}
void ButtonControllerBase::apply()
{
input(ButtonPolicy::SMI_APPLY);
}
void ButtonControllerBase::cancel()
{
input(ButtonPolicy::SMI_CANCEL);
}
void ButtonControllerBase::undoAll()
{
input(ButtonPolicy::SMI_UNDO_ALL);
}
void ButtonControllerBase::hide()
{
input(ButtonPolicy::SMI_HIDE);
}
void ButtonControllerBase::valid(bool v)
{
if (v) {
input(ButtonPolicy::SMI_VALID);
} else {
input(ButtonPolicy::SMI_INVALID);
}
}
void ButtonControllerBase::invalid()
{
input(ButtonPolicy::SMI_INVALID);
}
bool ButtonControllerBase::readOnly(bool ro)
{
if (ro) {
input(ButtonPolicy::SMI_READ_ONLY);
} else {
input(ButtonPolicy::SMI_READ_WRITE);
}
return ro;
}
void ButtonControllerBase::readWrite()
{
readOnly(false);
}

View File

@ -0,0 +1,105 @@
// -*- C++ -*-
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 2000 The LyX Team.
*
* ======================================================
*
* \file ButtonController.h
* \author Allan Rae
*/
#ifndef BUTTONCONTROLLER_H
#define BUTTONCONTROLLER_H
#ifdef __GNUG__
#pragma interface
#endif
#include "ButtonPolicies.h"
#include "LString.h"
#include "gettext.h"
/** Abstract base class for a ButtonController
* 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.
* Author: Allan Rae <rae@lyx.org>.
* This abstract base class stripped of xforms-specific code by
* Angus Leeming <a.leeming@ic.ac.uk>
*/
class ButtonControllerBase : public noncopyable
{
public:
/** Constructor.
The cancel/close label entries are _not_ managed within the class
thereby allowing you to reassign at will and to use static labels.
It also means if you really don't want to have the Cancel button
label be different when there is nothing changed in the dialog then
you can just assign "Cancel" to both labels. Or even reuse this
class for something completely different.
*/
ButtonControllerBase(string const & cancel, string const & close);
///
virtual ~ButtonControllerBase() {}
///
virtual void refresh() = 0;
///
virtual ButtonPolicy & bp() = 0;
///
virtual void input(ButtonPolicy::SMInput);
///
void ok();
///
void apply();
///
void cancel();
///
void undoAll();
///
void hide();
/// Passthrough function -- returns its input value
bool readOnly(bool = true);
///
void readWrite();
///
void valid(bool = true);
///
void invalid();
protected:
///
string cancel_label;
///
string close_label;
};
template <class BP, class GUIBC>
class ButtonController: public GUIBC
{
public:
///
ButtonController(string const & = _("Cancel"),
string const & = _("Close"));
///
virtual ButtonPolicy & bp() { return bp_; }
protected:
///
BP bp_;
};
template <class BP, class GUIBC>
ButtonController<BP, GUIBC>::ButtonController(string const & cancel,
string const & close)
: GUIBC(cancel, close)
{}
#endif // BUTTONCONTROLLER_H

View File

@ -0,0 +1,546 @@
// -*- C++ -*-
/* ButtonPolicies.C
* Provides a state machine implementation of the various button policies
* used by the dialogs.
* Author: Allan Rae <rae@lyx.org>
* 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
* ======================================================
*/
#include <config.h>
#include "ButtonPolicies.h"
#include "debug.h"
using std::endl;
/// Helper function
static inline
void nextState(ButtonPolicy::State & state,
ButtonPolicy::SMInput in,
ButtonPolicy::StateMachine const & s_m,
char const * function_name = "nextState")
{
if (ButtonPolicy::SMI_NOOP == in) return;
ButtonPolicy::State tmp = s_m[state][in];
if (ButtonPolicy::BOGUS != tmp) {
state = tmp;
} else {
lyxerr << function_name
<< ": No transition for input "
<< in
<< " from state "
<< state
<< endl;
}
}
/*-----------------------------PreferencesPolicy-----------------------------*/
PreferencesPolicy::PreferencesPolicy()
: state_(INITIAL),
outputs_(APPLIED + 1, ButtonPolicy::ALL_BUTTONS),
state_machine_(APPLIED + 1,
StateArray(int(SMI_TOTAL), ButtonPolicy::BOGUS))
{
// Build the state output map
outputs_[INITIAL] = CLOSE;
outputs_[VALID] = UNDO_ALL | OKAY | APPLY | CANCEL;
outputs_[INVALID] = UNDO_ALL | CANCEL;
outputs_[APPLIED] = OKAY | CLOSE;
// Build the state machine one state at a time
// NOTE: Since CANCEL and HIDE always go to INITIAL they are
// left out of the state machine and handled explicitly
// in input(). This won't necessarily be true for all
// policies though so I'll leave those two as distinct
// inputs rather than merge them. For example, a dialog
// that doesn't update it's input fields when reshown
// after being hidden needs a policy where CANCEL and
// HIDE are treated differently.
//
// State::INITIAL
state_machine_[INITIAL][SMI_READ_ONLY] = INITIAL;
state_machine_[INITIAL][SMI_READ_WRITE] = INITIAL;
state_machine_[INITIAL][SMI_VALID] = VALID;
state_machine_[INITIAL][SMI_INVALID] = INVALID;
// State::VALID
state_machine_[VALID][SMI_VALID] = VALID;
state_machine_[VALID][SMI_READ_ONLY] = VALID;
state_machine_[VALID][SMI_READ_WRITE] = VALID;
state_machine_[VALID][SMI_INVALID] = INVALID;
state_machine_[VALID][SMI_APPLY] = APPLIED;
state_machine_[VALID][SMI_OKAY] = INITIAL;
state_machine_[VALID][SMI_UNDO_ALL] = INITIAL;
// State::INVALID
state_machine_[INVALID][SMI_VALID] = VALID;
state_machine_[INVALID][SMI_INVALID] = INVALID;
state_machine_[INVALID][SMI_READ_ONLY] = INVALID;
state_machine_[INVALID][SMI_READ_WRITE] = INVALID;
state_machine_[INVALID][SMI_UNDO_ALL] = INITIAL;
// State::APPLIED
state_machine_[APPLIED][SMI_VALID] = VALID;
state_machine_[APPLIED][SMI_INVALID] = INVALID;
state_machine_[APPLIED][SMI_OKAY] = INITIAL;
state_machine_[APPLIED][SMI_READ_ONLY] = APPLIED;
state_machine_[APPLIED][SMI_READ_WRITE] = APPLIED;
}
void PreferencesPolicy::input(SMInput input)
{
//lyxerr << "PreferencesPolicy::input" << endl;
// CANCEL and HIDE always take us to INITIAL for all cases.
// Note that I didn't put that special case in the helper function
// because it doesn't belong there. Some other
// This is probably optimising for the wrong case since it occurs as the
// dialog will be hidden. It would have saved a little memory in the
// state machine if I could have gotten map working. ARRae 20000813
if (SMI_CANCEL == input
|| SMI_HIDE == input) {
state_ = INITIAL;
} else {
nextState(state_,
input,
state_machine_,
"PreferencesPolicy");
}
}
/*-------------------------------OkCancelPolicy------------------------------*/
OkCancelPolicy::OkCancelPolicy()
: state_(INITIAL),
outputs_(INVALID + 1, ButtonPolicy::ALL_BUTTONS),
state_machine_(INVALID + 1,
StateArray(int(SMI_TOTAL), ButtonPolicy::BOGUS))
{
// Build the state output map
outputs_[INITIAL] = CLOSE;
outputs_[VALID] = UNDO_ALL | OKAY | CANCEL;
outputs_[INVALID] = UNDO_ALL | CANCEL;
// Build the state machine one state at a time
// NOTE: Since CANCEL and HIDE always go to INITIAL they are
// left out of the state machine and handled explicitly
// in input()
//
// State::INITIAL
state_machine_[INITIAL][SMI_READ_ONLY] = INITIAL;
state_machine_[INITIAL][SMI_READ_WRITE] = INITIAL;
state_machine_[INITIAL][SMI_VALID] = VALID;
state_machine_[INITIAL][SMI_INVALID] = INVALID;
// State::VALID
state_machine_[VALID][SMI_VALID] = VALID;
state_machine_[VALID][SMI_READ_ONLY] = VALID;
state_machine_[VALID][SMI_READ_WRITE] = VALID;
state_machine_[VALID][SMI_INVALID] = INVALID;
state_machine_[VALID][SMI_OKAY] = INITIAL;
state_machine_[VALID][SMI_UNDO_ALL] = INITIAL;
// State::INVALID
state_machine_[INVALID][SMI_VALID] = VALID;
state_machine_[INVALID][SMI_INVALID] = INVALID;
state_machine_[INVALID][SMI_READ_ONLY] = INVALID;
state_machine_[INVALID][SMI_READ_WRITE] = INVALID;
state_machine_[INVALID][SMI_UNDO_ALL] = INITIAL;
}
void OkCancelPolicy::input(SMInput input)
{
//lyxerr << "OkCancelPolicy::input" << endl;
// CANCEL and HIDE always take us to INITIAL for all cases
if (SMI_CANCEL == input
|| SMI_HIDE == input) {
state_ = INITIAL;
} else {
nextState(state_, input, state_machine_, "OkCancelPolicy");
}
}
/*---------------------------OkCancelReadOnlyPolicy-------------------------*/
OkCancelReadOnlyPolicy::OkCancelReadOnlyPolicy()
: state_(INITIAL),
outputs_(RO_INVALID + 1, ButtonPolicy::ALL_BUTTONS),
state_machine_(RO_INVALID + 1,
StateArray(int(SMI_TOTAL), ButtonPolicy::BOGUS))
{
// Build the state output map
outputs_[INITIAL] = CLOSE;
outputs_[VALID] = UNDO_ALL | OKAY | CANCEL;
outputs_[INVALID] = UNDO_ALL | CANCEL;
outputs_[RO_INITIAL] = CLOSE;
outputs_[RO_VALID] = UNDO_ALL | CANCEL;
outputs_[RO_INVALID] = UNDO_ALL | CANCEL;
// Build the state machine one state at a time
// NOTE: Since CANCEL and HIDE always go to INITIAL they are
// left out of the state machine and handled explicitly
// in input()
//
// State::INITIAL
state_machine_[INITIAL][SMI_READ_WRITE] = INITIAL;
state_machine_[INITIAL][SMI_VALID] = VALID;
state_machine_[INITIAL][SMI_INVALID] = INVALID;
state_machine_[INITIAL][SMI_READ_ONLY] = RO_INITIAL;
// State::VALID
state_machine_[VALID][SMI_VALID] = VALID;
state_machine_[VALID][SMI_READ_WRITE] = VALID;
state_machine_[VALID][SMI_INVALID] = INVALID;
state_machine_[VALID][SMI_OKAY] = INITIAL;
state_machine_[VALID][SMI_UNDO_ALL] = INITIAL;
state_machine_[VALID][SMI_READ_ONLY] = RO_VALID;
// State::INVALID
state_machine_[INVALID][SMI_INVALID] = INVALID;
state_machine_[INVALID][SMI_READ_WRITE] = INVALID;
state_machine_[INVALID][SMI_VALID] = VALID;
state_machine_[INVALID][SMI_UNDO_ALL] = INITIAL;
state_machine_[INVALID][SMI_READ_ONLY] = RO_INVALID;
// State::RO_INITIAL
state_machine_[RO_INITIAL][SMI_READ_ONLY] = RO_INITIAL;
state_machine_[RO_INITIAL][SMI_VALID] = RO_VALID;
state_machine_[RO_INITIAL][SMI_INVALID] = RO_INVALID;
state_machine_[RO_INITIAL][SMI_READ_WRITE] = INITIAL;
// State::RO_VALID
state_machine_[RO_VALID][SMI_VALID] = RO_VALID;
state_machine_[RO_VALID][SMI_READ_ONLY] = RO_VALID;
state_machine_[RO_VALID][SMI_INVALID] = RO_INVALID;
state_machine_[RO_VALID][SMI_READ_WRITE] = VALID;
state_machine_[RO_VALID][SMI_UNDO_ALL] = RO_INITIAL;
// State::RO_INVALID
state_machine_[RO_INVALID][SMI_READ_ONLY] = RO_INVALID;
state_machine_[RO_INVALID][SMI_INVALID] = RO_INVALID;
state_machine_[RO_INVALID][SMI_VALID] = RO_VALID;
state_machine_[RO_INVALID][SMI_READ_WRITE] = INVALID;
state_machine_[RO_INVALID][SMI_UNDO_ALL] = RO_INITIAL;
}
void OkCancelReadOnlyPolicy::input(SMInput input)
{
//lyxerr << "OkCancelReadOnlyPolicy::input" << endl;
// CANCEL and HIDE always take us to INITIAL for all cases
if (SMI_CANCEL == input
|| SMI_HIDE == input) {
state_ = INITIAL;
} else {
nextState(state_,
input,
state_machine_,
"OkCancelReadOnlyPolicy");
}
}
/*--------------------------NoRepeatedApplyReadOnlyPolicy----------------------*/
NoRepeatedApplyReadOnlyPolicy::NoRepeatedApplyReadOnlyPolicy()
: state_(INITIAL),
outputs_(RO_INVALID + 1, ButtonPolicy::ALL_BUTTONS),
state_machine_(RO_INVALID + 1,
StateArray(int(SMI_TOTAL), ButtonPolicy::BOGUS))
{
// Build the state output map
outputs_[INITIAL] = CLOSE;
outputs_[VALID] = UNDO_ALL | OKAY | APPLY | CANCEL;
outputs_[INVALID] = UNDO_ALL | CANCEL;
outputs_[RO_INITIAL] = CLOSE;
outputs_[RO_VALID] = UNDO_ALL | CANCEL;
outputs_[RO_INVALID] = UNDO_ALL | CANCEL;
// Build the state machine one state at a time
// NOTE: Since CANCEL and HIDE always go to INITIAL they are
// left out of the state machine and handled explicitly
// in input()
//
// State::INITIAL
state_machine_[INITIAL][SMI_READ_WRITE] = INITIAL;
state_machine_[INITIAL][SMI_VALID] = VALID;
state_machine_[INITIAL][SMI_INVALID] = INVALID;
state_machine_[INITIAL][SMI_READ_ONLY] = RO_INITIAL;
// State::VALID
state_machine_[VALID][SMI_VALID] = VALID;
state_machine_[VALID][SMI_READ_WRITE] = VALID;
state_machine_[VALID][SMI_INVALID] = INVALID;
state_machine_[VALID][SMI_OKAY] = INITIAL;
state_machine_[VALID][SMI_APPLY] = INITIAL;
state_machine_[VALID][SMI_UNDO_ALL] = INITIAL;
state_machine_[VALID][SMI_READ_ONLY] = RO_VALID;
// State::INVALID
state_machine_[INVALID][SMI_INVALID] = INVALID;
state_machine_[INVALID][SMI_READ_WRITE] = INVALID;
state_machine_[INVALID][SMI_VALID] = VALID;
state_machine_[INVALID][SMI_UNDO_ALL] = INITIAL;
state_machine_[INVALID][SMI_READ_ONLY] = RO_INVALID;
// State::RO_INITIAL
state_machine_[RO_INITIAL][SMI_READ_ONLY] = RO_INITIAL;
state_machine_[RO_INITIAL][SMI_VALID] = RO_VALID;
state_machine_[RO_INITIAL][SMI_INVALID] = RO_INVALID;
state_machine_[RO_INITIAL][SMI_READ_WRITE] = INITIAL;
// State::RO_VALID
state_machine_[RO_VALID][SMI_VALID] = RO_VALID;
state_machine_[RO_VALID][SMI_READ_ONLY] = RO_VALID;
state_machine_[RO_VALID][SMI_INVALID] = RO_INVALID;
state_machine_[RO_VALID][SMI_READ_WRITE] = VALID;
state_machine_[RO_VALID][SMI_UNDO_ALL] = RO_INITIAL;
// State::RO_INVALID
state_machine_[RO_INVALID][SMI_INVALID] = RO_INVALID;
state_machine_[RO_INVALID][SMI_READ_ONLY] = RO_INVALID;
state_machine_[RO_INVALID][SMI_VALID] = RO_VALID;
state_machine_[RO_INVALID][SMI_READ_WRITE] = INVALID;
state_machine_[RO_INVALID][SMI_UNDO_ALL] = RO_INITIAL;
}
void NoRepeatedApplyReadOnlyPolicy::input(SMInput input)
{
//lyxerr << "NoReapeatedApplyReadOnlyPolicy::input" << endl;
// CANCEL and HIDE always take us to INITIAL for all cases
if (SMI_CANCEL == input
|| SMI_HIDE == input) {
state_ = INITIAL;
} else {
nextState(state_,
input,
state_machine_,
"NoRepeatedApplyReadOnlyPolicy");
}
}
/*--------------------------OkApplyCancelReadOnlyPolicy----------------------*/
OkApplyCancelReadOnlyPolicy::OkApplyCancelReadOnlyPolicy()
: state_(INITIAL),
outputs_(RO_APPLIED + 1, ButtonPolicy::ALL_BUTTONS),
state_machine_(RO_APPLIED + 1,
StateArray(int(SMI_TOTAL), ButtonPolicy::BOGUS))
{
// Build the state output map
outputs_[INITIAL] = CLOSE;
outputs_[VALID] = UNDO_ALL | OKAY | APPLY | CANCEL;
outputs_[INVALID] = UNDO_ALL | CANCEL;
outputs_[APPLIED] = OKAY | APPLY | CLOSE;
outputs_[RO_INITIAL] = CLOSE;
outputs_[RO_VALID] = UNDO_ALL | CANCEL;
outputs_[RO_INVALID] = UNDO_ALL | CANCEL;
outputs_[RO_APPLIED] = CLOSE;
// Build the state machine one state at a time
// NOTE: Since CANCEL and HIDE always go to INITIAL they are
// left out of the state machine and handled explicitly
// in input()
//
// State::INITIAL
state_machine_[INITIAL][SMI_READ_WRITE] = INITIAL;
state_machine_[INITIAL][SMI_VALID] = VALID;
state_machine_[INITIAL][SMI_INVALID] = INVALID;
state_machine_[INITIAL][SMI_READ_ONLY] = RO_INITIAL;
// State::VALID
state_machine_[VALID][SMI_VALID] = VALID;
state_machine_[VALID][SMI_READ_WRITE] = VALID;
state_machine_[VALID][SMI_INVALID] = INVALID;
state_machine_[VALID][SMI_OKAY] = INITIAL;
state_machine_[VALID][SMI_UNDO_ALL] = INITIAL;
state_machine_[VALID][SMI_APPLY] = APPLIED;
state_machine_[VALID][SMI_READ_ONLY] = RO_VALID;
// State::INVALID
state_machine_[INVALID][SMI_INVALID] = INVALID;
state_machine_[INVALID][SMI_READ_WRITE] = INVALID;
state_machine_[INVALID][SMI_VALID] = VALID;
state_machine_[INVALID][SMI_UNDO_ALL] = INITIAL;
state_machine_[INVALID][SMI_READ_ONLY] = RO_INVALID;
// State::APPLIED
state_machine_[APPLIED][SMI_APPLY] = APPLIED;
state_machine_[APPLIED][SMI_READ_WRITE] = APPLIED;
state_machine_[APPLIED][SMI_VALID] = VALID;
state_machine_[APPLIED][SMI_INVALID] = INVALID;
state_machine_[APPLIED][SMI_OKAY] = INITIAL;
state_machine_[APPLIED][SMI_READ_ONLY] = RO_APPLIED;
// State::RO_INITIAL
state_machine_[RO_INITIAL][SMI_READ_ONLY] = RO_INITIAL;
state_machine_[RO_INITIAL][SMI_VALID] = RO_VALID;
state_machine_[RO_INITIAL][SMI_INVALID] = RO_INVALID;
state_machine_[RO_INITIAL][SMI_READ_WRITE] = INITIAL;
// State::RO_VALID
state_machine_[RO_VALID][SMI_VALID] = RO_VALID;
state_machine_[RO_VALID][SMI_READ_ONLY] = RO_VALID;
state_machine_[RO_VALID][SMI_INVALID] = RO_INVALID;
state_machine_[RO_VALID][SMI_READ_WRITE] = VALID;
state_machine_[RO_VALID][SMI_UNDO_ALL] = RO_INITIAL;
// State::RO_INVALID
state_machine_[RO_INVALID][SMI_INVALID] = RO_INVALID;
state_machine_[RO_INVALID][SMI_READ_ONLY] = RO_INVALID;
state_machine_[RO_INVALID][SMI_VALID] = RO_VALID;
state_machine_[RO_INVALID][SMI_READ_WRITE] = INVALID;
state_machine_[RO_INVALID][SMI_UNDO_ALL] = RO_INITIAL;
// State::RO_APPLIED
state_machine_[RO_APPLIED][SMI_READ_ONLY] = RO_APPLIED;
state_machine_[RO_APPLIED][SMI_INVALID] = RO_INVALID;
state_machine_[RO_APPLIED][SMI_VALID] = RO_VALID;
state_machine_[RO_APPLIED][SMI_READ_WRITE] = APPLIED;
}
void OkApplyCancelReadOnlyPolicy::input(SMInput input)
{
//lyxerr << "OkApplyCancelReadOnlyPolicy::input" << endl;
// CANCEL and HIDE always take us to INITIAL for all cases
if (SMI_CANCEL == input
|| SMI_HIDE == input) {
state_ = INITIAL;
} else {
nextState(state_,
input,
state_machine_,
"OkApplyCancelReadOnlyPolicy");
}
}
/*--------------------------OkApplyCancelPolicy----------------------*/
OkApplyCancelPolicy::OkApplyCancelPolicy()
: state_(INITIAL),
outputs_(APPLIED + 1, ButtonPolicy::ALL_BUTTONS),
state_machine_(APPLIED + 1,
StateArray(int(SMI_TOTAL), ButtonPolicy::BOGUS))
{
// Build the state output map
outputs_[INITIAL] = CLOSE;
outputs_[VALID] = UNDO_ALL | OKAY | APPLY | CANCEL;
outputs_[INVALID] = UNDO_ALL | CANCEL;
outputs_[APPLIED] = OKAY | APPLY | CLOSE;
// Build the state machine one state at a time
// NOTE: Since CANCEL and HIDE always go to INITIAL they are
// left out of the state machine and handled explicitly
// in input()
//
// State::INITIAL
state_machine_[INITIAL][SMI_READ_ONLY] = INITIAL;
state_machine_[INITIAL][SMI_READ_WRITE] = INITIAL;
state_machine_[INITIAL][SMI_VALID] = VALID;
state_machine_[INITIAL][SMI_INVALID] = INVALID;
// State::VALID
state_machine_[VALID][SMI_VALID] = VALID;
state_machine_[VALID][SMI_READ_ONLY] = VALID;
state_machine_[VALID][SMI_READ_WRITE] = VALID;
state_machine_[VALID][SMI_INVALID] = INVALID;
state_machine_[VALID][SMI_OKAY] = INITIAL;
state_machine_[VALID][SMI_UNDO_ALL] = INITIAL;
state_machine_[VALID][SMI_APPLY] = APPLIED;
// State::INVALID
state_machine_[INVALID][SMI_INVALID] = INVALID;
state_machine_[INVALID][SMI_READ_ONLY] = INVALID;
state_machine_[INVALID][SMI_READ_WRITE] = INVALID;
state_machine_[INVALID][SMI_VALID] = VALID;
state_machine_[INVALID][SMI_UNDO_ALL] = INITIAL;
// State::APPLIED
state_machine_[APPLIED][SMI_APPLY] = APPLIED;
state_machine_[APPLIED][SMI_READ_ONLY] = APPLIED;
state_machine_[APPLIED][SMI_READ_WRITE] = APPLIED;
state_machine_[APPLIED][SMI_VALID] = VALID;
state_machine_[APPLIED][SMI_INVALID] = INVALID;
state_machine_[APPLIED][SMI_OKAY] = INITIAL;
}
void OkApplyCancelPolicy::input(SMInput input)
{
//lyxerr << "OkApplyCancelPolicy::input" << endl;
// CANCEL and HIDE always take us to INITIAL for all cases
if (SMI_CANCEL == input
|| SMI_HIDE == input) {
state_ = INITIAL;
} else {
nextState(state_,
input,
state_machine_,
"OkApplyCancelPolicy");
}
}
/*--------------------------NoRepeatedApplyPolicy----------------------*/
NoRepeatedApplyPolicy::NoRepeatedApplyPolicy()
: state_(INITIAL),
outputs_(INVALID + 1, ButtonPolicy::ALL_BUTTONS),
state_machine_(INVALID + 1,
StateArray(int(SMI_TOTAL), ButtonPolicy::BOGUS))
{
// Build the state output map
outputs_[INITIAL] = CLOSE;
outputs_[VALID] = UNDO_ALL | OKAY | APPLY | CANCEL;
outputs_[INVALID] = UNDO_ALL | CANCEL;
// Build the state machine one state at a time
// NOTE: Since CANCEL and HIDE always go to INITIAL they are
// left out of the state machine and handled explicitly
// in input()
//
// State::INITIAL
state_machine_[INITIAL][SMI_READ_ONLY] = INITIAL;
state_machine_[INITIAL][SMI_READ_WRITE] = INITIAL;
state_machine_[INITIAL][SMI_VALID] = VALID;
state_machine_[INITIAL][SMI_INVALID] = INVALID;
// State::VALID
state_machine_[VALID][SMI_VALID] = VALID;
state_machine_[VALID][SMI_READ_ONLY] = VALID;
state_machine_[VALID][SMI_READ_WRITE] = VALID;
state_machine_[VALID][SMI_INVALID] = INVALID;
state_machine_[VALID][SMI_OKAY] = INITIAL;
state_machine_[VALID][SMI_APPLY] = INITIAL;
state_machine_[VALID][SMI_UNDO_ALL] = INITIAL;
// State::INVALID
state_machine_[INVALID][SMI_INVALID] = INVALID;
state_machine_[INVALID][SMI_READ_ONLY] = INVALID;
state_machine_[INVALID][SMI_READ_WRITE] = INVALID;
state_machine_[INVALID][SMI_VALID] = VALID;
state_machine_[INVALID][SMI_UNDO_ALL] = INITIAL;
}
void NoRepeatedApplyPolicy::input(SMInput input)
{
//lyxerr << "NoRepeatedApplyPolicy::input" << endl;
// CANCEL and HIDE always take us to INITIAL for all cases
if (SMI_CANCEL == input
|| SMI_HIDE == input) {
state_ = INITIAL;
} else {
nextState(state_,
input,
state_machine_,
"NoRepeatedApplyPolicy");
}
}

View File

@ -0,0 +1,473 @@
// -*- C++ -*-
/* ButtonPolicies.h
* Provides a state machine implementation of the various button policies
* used by the dialogs.
* Author: Allan Rae <rae@lyx.org>
* 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
* ======================================================
*/
#ifndef BUTTONPOLICIES_H
#define BUTTONPOLICIES_H
#include <vector>
#include <boost/utility.hpp>
#include "support/LOstream.h"
/** An abstract base class for button policies.
A state machine implementation of the various button policies used by the
dialogs. Only the policy is implemented here. Separate ButtonController
classes are needed for each GUI implementation.
Policy | ReadOnly | Apply Button | Repeated Apply
========================================================================
OkCancel | N | N | -
OkCancelReadOnly | Y | N | -
OkApplyCancel | N | Y | Y
OkApplyCancelReadOnly | Y | Y | Y
NoRepeatedApply | N | Y | N
NoRepeatedApplyReadOnly | Y | Y | N
Preferences | N | Y | No (Ok-Close)
Ignorant | N/A | N/A | N/A
========================================================================
Policy
The name of the policy
ReadOnly
Does the policy treat read-only docs differently to read-write docs?
This usually means that when an SMI_READ_ONLY input arrives then
all the buttons are disabled except Cancel/Close. The state
machine tracks the inputs (valid/invalid) and has states for all
combinations. When an SMI_READ_WRITE input arrives the appropriate
machine state is entered (just as if the document had always been
read-write).
NOTE: If a dialog doesn't care about the read-only status of a document
(and uses an appropriate policy) it can never get into a read-only state
so isReadOnly() can only ever return false even though the document may
be read-only.
Repeated Apply
Simply means that it is alright to use the Apply button multiple times
without requiring a change of the dialog contents. If no repeating is
allowed the Ok+Apply buttons are deactivated. The Preferences dialog
has its own special version of repeated apply handling because its Ok
button is actually a Save button -- its always reasonable to Save the
preferences if the dialog has changed since the last save.
The IgnorantPolicy is a special case that allows anything.
*/
class ButtonPolicy : public noncopyable {
public:
///
virtual ~ButtonPolicy() {}
/** The various possible state names.
Not all state-machines have this many states. However, we need
to define them all here so we can share the code.
*/
enum State {
///
INITIAL = 0,
///
VALID,
///
INVALID,
///
APPLIED,
///
RO_INITIAL,
///
RO_VALID,
///
RO_INVALID,
///
RO_APPLIED,
///
BOGUS = 55
};
/// The various button types.
enum Button {
///
CLOSE = 0, // Not a real button, but effectively !CANCEL
///
OKAY = 1,
///
APPLY = 2,
///
CANCEL = 4,
///
UNDO_ALL = 8
};
///
static const Button ALL_BUTTONS =
Button(OKAY | APPLY | CANCEL | UNDO_ALL);
/** State machine inputs.
All the policies so far have both CANCEL and HIDE always going to
INITIAL. This won't necessarily be true for all [future] policies
though so I'll leave those two as distinct inputs rather than merge
them. For example, a dialog that doesn't update it's input fields
when reshown after being hidden needs a policy where CANCEL and
HIDE are treated differently.
*/
enum SMInput {
///
SMI_VALID = 0,
///
SMI_INVALID,
///
SMI_OKAY,
///
SMI_APPLY,
///
SMI_CANCEL,
///
SMI_UNDO_ALL,
///
SMI_HIDE,
///
SMI_READ_ONLY,
///
SMI_READ_WRITE,
///
SMI_NOOP,
///
SMI_TOTAL // not a real input
};
/// Trigger a transition with this input.
virtual void input(SMInput) = 0;
/// Activation status of a button
virtual bool buttonStatus(Button) const = 0;
/// Are we in a read-only state?
virtual bool isReadOnly() const = 0;
/// Transition map of the state machine.
typedef std::vector<State> StateArray;
///
typedef std::vector<StateArray> StateMachine;
/// The state outputs are the status of the buttons.
typedef std::vector<int> StateOutputs;
};
inline
std::ostream & operator<<(std::ostream & os, ButtonPolicy::State st)
{
os << int(st);
return os;
}
inline
std::ostream & operator<<(std::ostream & os, ButtonPolicy::SMInput smi)
{
os << int(smi);
return os;
}
//--------------------- Actual Policy Classes -----------------------------
/** Ok and Cancel buttons for dialogs with read-only operation.
Note: This scheme supports the relabelling of Cancel to Close and
vice versa.
This is based on the value of the bool state of the Button::CANCEL.
true == Cancel, false == Close
*/
class OkCancelPolicy : public ButtonPolicy {
public:
///
OkCancelPolicy();
///
//virtual ~OkCancelPolicy() {}
/// Trigger a transition with this input.
virtual void input(SMInput);
/** Activation status of a button.
We assume that we haven't gotten into an undefined state.
This is reasonable since we can only reach states defined
in the state machine and they should all have been defined in
the outputs_ variable. Perhaps we can do something at compile
time to check that all the states have corresponding outputs.
*/
virtual bool buttonStatus(Button button) const {
return button & outputs_[state_];
}
/// Are we in a read-only state?
virtual bool isReadOnly() const {
return false;
}
private:
/// Current state.
State state_;
/// Which buttons are active for a given state.
StateOutputs outputs_;
///
StateMachine state_machine_;
};
/** Ok and Cancel buttons for dialogs where read-only operation is blocked.
The state machine design for this policy allows changes to occur within
the dialog while a file is read-only -- the okay button is disabled until
a read-write input is given. When the file is made read-write the dialog
will then be in the correct state (as if the file had always been
read-write).
Note: This scheme supports the relabelling of Cancel to Close
and vice versa.
This is based on the value of the bool state of the Button::CANCEL.
true == Cancel, false == Close
*/
class OkCancelReadOnlyPolicy : public ButtonPolicy {
public:
///
OkCancelReadOnlyPolicy();
///
//virtual ~OkCancelReadOnlyPolicy() {}
/// Trigger a transition with this input.
virtual void input(SMInput);
/// Activation status of a button.
virtual bool buttonStatus(Button button) const {
return button & outputs_[state_];
}
/// Are we in a read-only state?
virtual bool isReadOnly() const {
return RO_INITIAL == state_
|| RO_VALID == state_
|| RO_INVALID == state_
|| RO_APPLIED == state_;
}
private:
/// Current state.
State state_;
/// Which buttons are active for a given state.
StateOutputs outputs_;
///
StateMachine state_machine_;
};
/** Ok, Apply and Cancel buttons for dialogs where read-only operation
is blocked.
Repeated Apply are not allowed. Likewise, Ok cannot follow Apply without
some valid input. That is, the dialog contents must change between
each Apply or Apply and Ok.
The state machine design for this policy allows changes to occur within
the dialog while a file is read-only -- the Ok+Apply buttons are disabled
until a read-write input is given. When the file is made read-write the
dialog will then be in the correct state (as if the file had always been
read-write).
Note: This scheme supports the relabelling of Cancel to Close
and vice versa.
This is based on the value of the bool state of the Button::CANCEL.
true == Cancel, false == Close
*/
class NoRepeatedApplyReadOnlyPolicy : public ButtonPolicy
{
public:
///
NoRepeatedApplyReadOnlyPolicy();
///
//virtual ~NoRepeatedApplyReadOnlyPolicy() {}
/// Trigger a transition with this input.
virtual void input(SMInput);
/// Activation status of a button.
virtual bool buttonStatus(Button button) const {
return button & outputs_[state_];
}
/// Are we in a read-only state?
virtual bool isReadOnly() const {
return RO_INITIAL == state_
|| RO_VALID == state_
|| RO_INVALID == state_
|| RO_APPLIED == state_;
}
private:
/// Current state.
State state_;
/// Which buttons are active for a given state.
StateOutputs outputs_;
///
StateMachine state_machine_;
};
/** Ok, Apply and Cancel buttons for dialogs where read-only
operation is blocked.
Repeated Apply is allowed. Likewise, Ok can follow Apply.
The state machine design for this policy allows changes to occur within
the dialog while a file is read-only -- the Ok+Apply buttons are disabled
until a read-write input is given. When the file is made read-write the
dialog will then be in the correct state (as if the file had always been
read-write).
Note: This scheme supports the relabelling of Cancel to Close
and vice versa.
This is based on the value of the bool state of the Button::CANCEL.
true == Cancel, false == Close
*/
class OkApplyCancelReadOnlyPolicy : public ButtonPolicy {
public:
///
OkApplyCancelReadOnlyPolicy();
///
//virtual ~OkApplyCancelReadOnlyPolicy() {}
/// Trigger a transition with this input.
virtual void input(SMInput);
/// Activation status of a button.
virtual bool buttonStatus(Button button) const {
return button & outputs_[state_];
}
/// Are we in a read-only state?
virtual bool isReadOnly() const {
return RO_INITIAL == state_
|| RO_VALID == state_
|| RO_INVALID == state_
|| RO_APPLIED == state_;
}
private:
/// Current state.
State state_;
/// Which buttons are active for a given state.
StateOutputs outputs_;
///
StateMachine state_machine_;
};
/** Ok, Apply and Cancel buttons for dialogs where repeated Apply is allowed.
Note: This scheme supports the relabelling of Cancel to Close
and vice versa.
This is based on the value of the bool state of the Button::CANCEL.
true == Cancel, false == Close
*/
class OkApplyCancelPolicy : public ButtonPolicy {
public:
///
OkApplyCancelPolicy();
///
//virtual ~OkApplyCancelPolicy() {}
/// Trigger a transition with this input.
virtual void input(SMInput);
/// Activation status of a button.
virtual bool buttonStatus(Button button) const {
return button & outputs_[state_];
}
/// Are we in a read-only state?
virtual bool isReadOnly() const {
return false;
}
private:
/// Current state.
State state_;
/// Which buttons are active for a given state.
StateOutputs outputs_;
///
StateMachine state_machine_;
};
/** Ok, Apply and Cancel buttons for dialogs with no repeated Apply.
Note: This scheme supports the relabelling of Cancel to Close
and vice versa.
This is based on the value of the bool state of the Button::CANCEL.
true == Cancel, false == Close
*/
class NoRepeatedApplyPolicy : public ButtonPolicy {
public:
///
NoRepeatedApplyPolicy();
///
//virtual ~NoRepeatedApplyPolicy() {}
/// Trigger a transition with this input.
virtual void input(SMInput);
/// Activation status of a button.
virtual bool buttonStatus(Button button) const {
return button & outputs_[state_];
}
/// Are we in a read-only state?
virtual bool isReadOnly() const {
return false;
}
private:
/// Current state.
State state_;
/// Which buttons are active for a given state.
StateOutputs outputs_;
///
StateMachine state_machine_;
};
/** Defines the policy used by the Preferences dialog.
Four buttons: Ok (Save), Apply, Cancel/Close, Restore.
Note: This scheme supports the relabelling of Cancel to Close
and vice versa.
This is based on the value of the bool state of the Button::CANCEL.
true == Cancel, false == Close
*/
class PreferencesPolicy : public ButtonPolicy {
public:
///
PreferencesPolicy();
///
//virtual ~PreferencesPolicy() {}
/// Trigger a transition with this input.
virtual void input(SMInput);
/// Activation status of a button.
virtual bool buttonStatus(Button button) const {
return button & outputs_[state_];
}
/// Are we in a read-only state?
virtual bool isReadOnly() const {
return false;
}
private:
/// Current state.
State state_;
/// Which buttons are active for a given state.
StateOutputs outputs_;
///
StateMachine state_machine_;
};
/** Defines the policy used by dialogs that are forced to support a button
controller when they either don't have a use for one or are not ready to
use one. This may be useful when testing a new button policy but wishing
to minimise problems to users by supplying an anything-goes policy via a
preprocessor directive.
*/
class IgnorantPolicy : public ButtonPolicy {
public:
//virtual ~IgnorantPolicy() {}
/// Trigger a transition with this input.
virtual void input(SMInput) {}
/// Activation status of a button.
virtual bool buttonStatus(Button) const {
return true;
}
/// Are we in a read-only state?
virtual bool isReadOnly() const {
return false;
}
};
#endif

View File

@ -0,0 +1,112 @@
2001-03-14 Angus Leeming <a.leeming@ic.ac.uk>
* Merging changes from BRANCH_MVC back into HEAD.
2001-03-12 Angus Leeming <a.leeming@ic.ac.uk>
* Makefile.am: add ControlBibitem.[Ch].
* ControlBibitem.[Ch]: new files that together define the Controller
for a Bibitem popup.
* ControlCommand.h (c-tor): give kb_action a default value of
LFUN_NOACTION.
* ControlCommand.C (apply): do nothing if kb_action is LFUN_NOACTION.
* ControlCitation.[Ch]: moved search functions out of class.
(bibkeysInfo): new method. Returns const reference to private data.
(searchKeys): added case-sensitive switch. Used only by simpleSearch
for now.
2001-03-09 Angus Leeming <a.leeming@ic.ac.uk>
* ControlCitation.[Ch]: added Search functions to the class,
(shamelessly lifted from Marco's gnome code). I think that these would
be better as helper functions outside the class, but this is a first
stab at it.
2001-03-07 Angus Leeming <a.leeming@ic.ac.uk>
* ControlCitation.[Ch]: (getBibkeyList): removed from class
ControlCitation.
(getBibkeys, getBibkeyInfo): added to class ControlCitation.
(getStringFromVector, getVectorFromString, parseBibTeX): new helper
funcs. parseBibTeX() is lifted staraight out of Marco's gnome
implementation of FormCitation.
2001-03-05 Angus Leeming <a.leeming@ic.ac.uk>
* ButtonPolicies.h: add SMI_NOOP to enum.
* ButtonPolicies.C (nextState): add if-statement for SMI_NOOP.
* ButtonController.C (input): add "optimising" if-statement. Actually,
things don't work correctly without it...
2001-03-02 John Levon <moz@compsoc.man.ac.uk>
* ViewBase.h: remove #pragma directive
* ControlConnection.[Ch] (ControlConnectBI c-tor): add explicit c-tor
to make g++ happy.
2001-03-02 Angus Leeming <a.leeming@ic.ac.uk>
* ButtonPolicies.[Ch]: moved from ../ButtonPolicies.[Ch]
* Makefile.am: added ButtonPolicies.[Ch]
* ButtonController.[Ch]: ButtonController is split into
ButtonControllerBase and a template ButtonController class. The base
class no longer stores a pointer to a ButtonPolicy, but instead
accesses the actual instantiation of the policy through a pure virtual
method bp(). This method and the ButtonPolicy itself are instantiated
in the templatised ButtonController class. This class is derived from
the GUI-specific GUIBC class, meaning that the frontends know
nothing about the actual policy decided upon by the controllers.
* ControlBase.[Ch]: No longer store the View or the ButtonController.
Instead the actual instantiations are accessed through pure virtual
methods view() and bc(). The daughter classes are responsible for the
actual View and ButtonController.
* ControlCitation.h: the templatised class GUICitation instantiates
the methods view() and bc(). It also stores the instances of the
View and ButtonController.
2001-02-23 Angus Leeming <a.leeming@ic.ac.uk>
* ButtonControllerBase.[Ch]: renamed as ButtonController.[Ch]. Class
also changed to ButtonController.
* ControlBase.[Ch]:
* ControlConnections.[Ch]:
* ControlCommand.[Ch]:
* ControlCitation.[Ch]:
* ViewBase.h: Changes associated with this.
2001-01-15 Angus Leeming <a.leeming@ic.ac.uk>
* ButtonControllerBase.[Ch]: new files. Split Allan's original
xforms/ButtonController class into a GUI-I class (here) and an
xforms-specific derived class, to be found in xforms/xformsBC.[Ch].
* ControlBase.[Ch]: new files. ControlBase is an abstract base class
from which all Dialog Controllers should be derived. the Controllers
are GUI-independent, but are designed to control the behaviour of
GUI-specific implementaions of each dialog.
* ControlConnections.[Ch]: new files. Classes controlling the
connections of buffer-independent, buffer-dependent and Inset dialogs
with the LyX kernel.
* ControlCommand.[Ch]: new files. A controller for all dialogs for the
InsetCommand subset of insets.
* ControlCitation.[Ch]: new files. The test specialisation! A
controller for the Citation dialog.
* ViewBase.h: new file. ViewBase is an abstract base class from which
GUI-specific dialogs should be derived. The functionality that the GUIs
must now implement is much reduced.

View File

@ -0,0 +1,59 @@
// -*- C++ -*-
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 2000 The LyX Team.
*
* ======================================================
*
* \file ControlBase.C
* \author Angus Leeming <a.leeming@ic.ac.uk>
*/
#ifdef __GNUG__
#pragma implementation
#endif
#include <config.h>
#include "buffer.h"
#include "ButtonController.h"
#include "ControlBase.h"
#include "LyXView.h"
#include "support/LAssert.h"
void ControlBase::ApplyButton()
{
apply();
bc().apply();
}
void ControlBase::OKButton()
{
apply();
hide();
bc().ok();
}
void ControlBase::CancelButton()
{
hide();
bc().cancel();
}
void ControlBase::RestoreButton()
{
update();
bc().undoAll();
}
bool ControlBase::isReadonly() const
{
return lv_.buffer()->isReadonly();
}

View File

@ -0,0 +1,83 @@
// -*- C++ -*-
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 2000 The LyX Team.
*
* ======================================================
*
* \file ControlBase.h
* \author Angus Leeming <a.leeming@ic.ac.uk>
*
* The Controller connects the GUI-dependent popup to any appropriate
* signals and dispatches any changes to the kernel.
* It has no knowledge of the actual instantiation of the
* GUI-dependent View and ButtonController, which should therefore
* be created elsewhere.
* Once created, the Controller will take care of their initialisation,
* management and, ultimately, destruction.
*/
#ifndef CONTROLBASE_H
#define CONTROLBASE_H
#ifdef __GNUG__
#pragma interface
#endif
#include "DialogBase.h" // This can go eventually
class ButtonControllerBase;
class Dialogs;
class LyXView;
class ViewBase;
/** Abstract base class for Controllers with a ButtonController.
*/
class ControlBase : public DialogBase
{
public: // methods
///
ControlBase(LyXView & lv) : lv_(lv) {}
///
virtual ~ControlBase() {};
/// These functions are called when the controlling buttons are pressed.
///
void ApplyButton();
///
void OKButton();
///
void CancelButton();
///
void RestoreButton();
/// The View may need to know if the buffer is read-only.
bool isReadonly() const;
/** Allow the view to access the ButtonController. This method must be
instantiated in a daughter class that creates the actual instance
of the ButtonController. */
virtual ButtonControllerBase & bc() = 0;
protected:
/// Get changed parameters and Dispatch them to the kernel.
virtual void apply() = 0;
/// Disconnect signals and hide View.
virtual void hide() = 0;
/// Update dialog before showing it.
virtual void update() = 0;
/** Allow the Controller to access the View. This method must be
instantiated in a daughter class that creates the actual instance
of the View. */
virtual ViewBase & view() = 0;
/// Get at the kernel Dispatch methods we need to apply() parameters.
LyXView & lv_;
};
#endif // CONTROLBASE_H

View File

@ -0,0 +1,53 @@
// -*- C++ -*-
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 2000 The LyX Team.
*
* ======================================================
*
* \file ControlBibitem.C
* \author Angus Leeming <a.leeming@ic.ac.uk>
*/
#include <algorithm>
#ifdef __GNUG__
#pragma implementation
#endif
#include <config.h>
#include "ControlBibitem.h"
#include "Dialogs.h"
#include "LyXView.h"
#include "BufferView.h"
ControlBibitem::ControlBibitem(LyXView & lv, Dialogs & d)
: ControlCommand(lv, d)
{
d_.showBibitem.connect(slot(this, &ControlBibitem::showInset));
}
void ControlBibitem::apply()
{
view().apply();
if (inset_ && params() != inset_->params()) {
// FIXME:
// confirm, is this only necessary for FormBibTeX ???
if (params().getContents() != inset_->params().getContents())
lv_.view()->ChangeCitationsIfUnique(
inset_->params().getContents(),
params().getContents());
inset_->setParams(params());
lv_.view()->updateInset(inset_, true);
// We need to do a redraw because the maximum
// InsetBibKey width could have changed
lv_.view()->redraw();
lv_.view()->fitCursor(lv_.view()->getLyXText());
}
}

View File

@ -0,0 +1,65 @@
// -*- C++ -*-
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 2000 The LyX Team.
*
* ======================================================
*
* \file ControlBibitem.h
* \author Angus Leeming <a.leeming@ic.ac.uk>
*/
#ifndef CONTROLBIBITEM_H
#define CONTROLBIBITEM_H
#ifdef __GNUG__
#pragma interface
#endif
#include "ControlCommand.h"
#include "ButtonController.h"
#include "ViewBase.h"
/** A controller for Bibitem dialogs.
*/
class ControlBibitem : public ControlCommand
{
public:
///
ControlBibitem(LyXView &, Dialogs &);
protected:
/// Get changed parameters and Dispatch them to the kernel.
virtual void apply();
};
/** This class instantiates and makes available the GUI-specific
ButtonController and View.
*/
template <class GUIview, class GUIbc>
class GUIBibitem : public ControlBibitem {
public:
///
GUIBibitem(LyXView &, Dialogs &);
///
virtual ButtonControllerBase & bc() { return bc_; }
///
virtual ViewBase & view() { return view_; }
private:
///
ButtonController<OkCancelReadOnlyPolicy, GUIbc> bc_;
///
GUIview view_;
};
template <class GUIview, class GUIbc>
GUIBibitem<GUIview, GUIbc>::GUIBibitem(LyXView & lv, Dialogs & d)
: ControlBibitem(lv, d),
view_(*this)
{}
#endif // CONTROLBIBITEM_H

View File

@ -0,0 +1,362 @@
// -*- C++ -*-
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 2000 The LyX Team.
*
* ======================================================
*
* \file ControlCitation.C
* \author Angus Leeming <a.leeming@ic.ac.uk>
*/
#include <algorithm>
#ifdef __GNUG__
#pragma implementation
#endif
#include <config.h>
#include "ControlCitation.h"
#include "buffer.h"
#include "ButtonController.h"
#include "Dialogs.h"
#include "LyXView.h"
#include "ViewBase.h"
#include "support/lstrings.h"
#include "support/LRegex.h"
using std::find;
using std::min;
using std::pair;
using std::vector;
using std::sort;
ControlCitation::ControlCitation(LyXView & lv, Dialogs & d)
: ControlCommand(lv, d, LFUN_CITATION_INSERT)
{
// These are permanent connections so we won't bother
// storing a copy because we won't be disconnecting.
d_.showCitation.connect(slot(this, &ControlCitation::showInset));
d_.createCitation.connect(slot(this, &ControlCitation::createInset));
}
void ControlCitation::hide()
{
bibkeysInfo_.clear();
ControlCommand::hide();
}
// A functor for use with std::sort, leading to case insensitive sorting
struct compareNoCase: public std::binary_function<string, string, bool>
{
bool operator()(string const & s1, string const & s2) const {
return compare_no_case(s1, s2) < 0;
}
};
vector<string> const ControlCitation::getBibkeys()
{
vector<string> bibkeys;
bibkeysInfo_.clear();
vector<pair<string,string> > blist = lv_.buffer()->getBibkeyList();
for (vector<pair<string,string> >::size_type i=0; i<blist.size(); ++i) {
bibkeys.push_back(blist[i].first);
bibkeysInfo_.insert(InfoMapValue(blist[i].first,
blist[i].second));
}
sort(bibkeys.begin(), bibkeys.end(), compareNoCase());
return bibkeys;
}
string const ControlCitation::getBibkeyInfo(string const & key)
{
string result;
if (bibkeysInfo_.empty()) getBibkeys();
InfoMap::const_iterator it = bibkeysInfo_.find(key);
if (it != bibkeysInfo_.end()) {
// Search for all possible "required" keys
string author = parseBibTeX((*it).second, "author");
if (author.empty())
author = parseBibTeX((*it).second, "editor");
string year = parseBibTeX((*it).second, "year");
string title = parseBibTeX((*it).second, "title");
string booktitle = parseBibTeX((*it).second, "booktitle");
string chapter = parseBibTeX((*it).second, "chapter");
string pages = parseBibTeX((*it).second, "pages");
string media = parseBibTeX((*it).second, "journal");
if (media.empty())
media = parseBibTeX((*it).second, "publisher");
if (media.empty())
media = parseBibTeX((*it).second, "school");
if (media.empty())
media = parseBibTeX((*it).second, "institution");
result = author;
if (!year.empty())
result += ", " + year;
if (!title.empty())
result += ", " + title;
if (!booktitle.empty())
result += ", in " + booktitle;
if (!chapter.empty())
result += ", Ch. " + chapter;
if (!media.empty())
result += ", " + media;
if (!pages.empty())
result += ", pp. " + pages;
}
return result;
}
vector<string>::const_iterator
searchKeys(ControlCitation const & controller,
vector<string> const & keys,
string const & expr,
vector<string>::const_iterator start,
ControlCitation::Search type,
ControlCitation::Direction dir,
bool caseSensitive)
{
// Preliminary checks
if(start < keys.begin() || start >= keys.end())
return keys.end();
string search_expr = frontStrip(strip(expr));
if (search_expr.empty())
return start;
if (type == ControlCitation::SIMPLE)
return simpleSearch(controller, keys, search_expr, start, dir,
caseSensitive);
return regexSearch(controller, keys, search_expr, start, dir);
}
vector<string>::const_iterator
simpleSearch(ControlCitation const & controller,
vector<string> const & keys,
string const & expr,
vector<string>::const_iterator start,
ControlCitation::Direction dir,
bool caseSensitive)
{
vector<string> searchwords = getVectorFromString(expr, ' ');
// Loop over all keys from start...
for (vector<string>::const_iterator it = start;
// End condition is direction-dependent.
(dir == ControlCitation::FORWARD) ?
(it<keys.end()) : (it>=keys.begin());
// increment is direction-dependent.
(dir == ControlCitation::FORWARD) ?
(++it) : (--it)) {
string data = (*it);
ControlCitation::InfoMap::const_iterator info =
controller.bibkeysInfo().find(*it);
if (info != controller.bibkeysInfo().end())
data += " " + info->second;
if (!caseSensitive)
data = lowercase(data);
bool found = true;
// Loop over all search words...
if (caseSensitive) {
for (vector<string>::const_iterator sit=
searchwords.begin();
sit<searchwords.end(); ++sit) {
if (data.find(*sit) == string::npos) {
found = false;
break;
}
}
} else {
for (vector<string>::const_iterator sit=
searchwords.begin();
sit<searchwords.end(); ++sit) {
if (data.find(lowercase(*sit)) ==
string::npos) {
found = false;
break;
}
}
}
if (found) return it;
}
return keys.end();
}
vector<string>::const_iterator
regexSearch(ControlCitation const & controller,
vector<string> const & keys,
string const & expr,
vector<string>::const_iterator start,
ControlCitation::Direction dir)
{
LRegex reg(expr);
for (vector<string>::const_iterator it = start;
// End condition is direction-dependent.
(dir == ControlCitation::FORWARD) ?
(it<keys.end()) : (it>=keys.begin());
// increment is direction-dependent.
(dir == ControlCitation::FORWARD) ?
(++it) : (--it)) {
string data = (*it);
ControlCitation::InfoMap::const_iterator info =
controller.bibkeysInfo().find(*it);
if (info != controller.bibkeysInfo().end())
data += " " + info->second;
if (reg.exec(data).size() > 0)
return it;
}
return keys.end();
}
string const getStringFromVector(vector<string> const & vec, char delim)
{
string str;
for (vector<string>::size_type i=0; i<vec.size(); ++i) {
if (i > 0) str += tostr(delim) + " ";
str += vec[i];
}
return str;
}
vector<string> const getVectorFromString(string const & str, char delim)
{
vector<string> vec;
string keys(str);
string tmp;
keys = frontStrip(split(keys, tmp, delim));
while (!tmp.empty()) {
vec.push_back(tmp);
keys = frontStrip(split(keys, tmp, delim));
}
return vec;
}
string const parseBibTeX(string data, string const & findkey)
{
string keyvalue;
for (string::iterator it=data.begin(); it<data.end(); ++it) {
if ((*it) == '\n' || (*it) == '\t')
(*it)= ' ';
}
data = frontStrip(data);
while (!data.empty() && data[0] != '=' &&
(data.find(' ') != string::npos || data.find('=') != string::npos)) {
string::size_type keypos = min(data.find(' '), data.find('='));
string key = lowercase(data.substr(0, keypos));
data = data.substr(keypos, data.length()-1);
data = frontStrip(strip(data));
if (data.length() > 1 && data[0]=='=') {
data = frontStrip(data.substr(1, data.length()-1));
if (!data.empty()) {
keypos = 1;
string value;
char enclosing;
if (data[0]=='{') {
enclosing = '}';
} else if (data[0]=='"') {
enclosing = '"';
} else {
keypos=0;
enclosing=' ';
}
if (keypos &&
data.find(enclosing)!=string::npos &&
data.length()>1) {
string tmp = data.substr(keypos,
data.length()-1);
while (tmp.find('{') != string::npos &&
tmp.find('}') != string::npos &&
tmp.find('{') < tmp.find('}') &&
tmp.find('{') < tmp.find(enclosing)) {
keypos += tmp.find('{')+1;
tmp = data.substr(keypos,
data.length()-1);
keypos += tmp.find('}')+1;
tmp = data.substr(keypos,
data.length()-1);
}
if (tmp.find(enclosing)==string::npos)
return keyvalue;
else {
keypos += tmp.find(enclosing);
tmp = data.substr(keypos,
data.length()-1);
}
value = data.substr(1, keypos-1);
if (keypos+1<data.length()-1)
data = frontStrip(data.substr(keypos+1, data.length()-1));
else
data = "";
} else if (!keypos &&
(data.find(' ') ||
data.find(','))) {
keypos = data.length()-1;
if (data.find(' ') != string::npos)
keypos = data.find(' ');
if (data.find(',') != string::npos &&
keypos > data.find(','))
keypos = data.find(',');
value = data.substr(0, keypos);
if (keypos+1<data.length()-1)
data = frontStrip(data.substr(keypos+1, data.length()-1));
else
data = "";
}
else
return keyvalue;
if (findkey == key) {
keyvalue = value;
return keyvalue;
}
data = frontStrip(frontStrip(data,','));
}
}
else return keyvalue;
}
return keyvalue;
}

View File

@ -0,0 +1,146 @@
// -*- C++ -*-
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 2000 The LyX Team.
*
* ======================================================
*
* \file ControlCitation.h
* \author Angus Leeming <a.leeming@ic.ac.uk>
*/
#ifndef CONTROLCITATION_H
#define CONTROLCITATION_H
#ifdef __GNUG__
#pragma interface
#endif
#include "ControlCommand.h"
#include "ButtonController.h"
#include "ViewBase.h"
/** A controller for Citation dialogs. All citation-specific functionality
should go in here.
*/
class ControlCitation : public ControlCommand
{
public:
///
typedef std::map<string, string> InfoMap;
///
typedef std::map<string, string>::value_type InfoMapValue;
///
enum Search {
///
SIMPLE,
///
REGEX
};
///
enum Direction {
///
FORWARD,
///
BACKWARD
};
///
ControlCitation(LyXView &, Dialogs &);
/// A vector of bibliography keys
std::vector<string> const getBibkeys();
/// Returns a reference to the map of stored keys
InfoMap const & bibkeysInfo() const { return bibkeysInfo_; }
/** Returns the BibTeX data associated with a given key.
Empty if no info exists. */
string const getBibkeyInfo(string const &);
private:
/// Clean up, then hide dialog.
virtual void hide();
/// The info associated with each key
InfoMap bibkeysInfo_;
};
/** This class instantiates and makes available the GUI-specific
ButtonController and View.
*/
template <class GUIview, class GUIbc>
class GUICitation : public ControlCitation {
public:
///
GUICitation(LyXView &, Dialogs &);
///
virtual ButtonControllerBase & bc() { return bc_; }
///
virtual ViewBase & view() { return view_; }
private:
///
ButtonController<NoRepeatedApplyReadOnlyPolicy, GUIbc> bc_;
///
GUIview view_;
};
template <class GUIview, class GUIbc>
GUICitation<GUIview, GUIbc>::GUICitation(LyXView & lv, Dialogs & d)
: ControlCitation(lv, d),
view_(*this)
{}
/** Helper functions, of possible use to all frontends
*/
/** Multiple citation keys are stored in InsetCommandParams::contents as a
comma-separated string. These two functions convert to/from a vector. */
string const getStringFromVector(std::vector<string> const &, char delim=',');
///
std::vector<string> const getVectorFromString(string const &, char delim=',');
/** Search a BibTeX info field for the given key and return the
associated field. */
string const parseBibTeX(string data, string const & findkey);
/** Returns an iterator to the first key that meets the search criterion,
or end() if unsuccessful.
User supplies :
the controller with the map of bibkeys info,
the vector of keys to be searched,
the search criterion,
an iterator defining the starting point of the search,
an enum defining a Simple or Regex search,
an enum defining the search direction.
*/
std::vector<string>::const_iterator
searchKeys(ControlCitation const & controller,
std::vector<string> const & keys_to_search,
string const & search_expression,
std::vector<string>::const_iterator start,
ControlCitation::Search,
ControlCitation::Direction,
bool caseSensitive=false);
/// Do the dirty work for the search. Should use through the function above
std::vector<string>::const_iterator
simpleSearch(ControlCitation const & controller,
std::vector<string> const & keys_to_search,
string const & search_expression,
std::vector<string>::const_iterator start,
ControlCitation::Direction,
bool caseSensitive=false);
/// Should use through the function above
std::vector<string>::const_iterator
regexSearch(ControlCitation const & controller,
std::vector<string> const & keys_to_search,
string const & search_expression,
std::vector<string>::const_iterator start,
ControlCitation::Direction);
#endif // CONTROLCITATION_H

View File

@ -0,0 +1,113 @@
// -*- C++ -*-
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 2000 The LyX Team.
*
* ======================================================
*
* \file ControlCommand.C
* \author Angus Leeming <a.leeming@ic.ac.uk>
*/
#ifdef __GNUG__
#pragma implementation
#endif
#include <config.h>
#include "ControlCommand.h"
#include "BufferView.h"
#include "ButtonController.h"
#include "Dialogs.h"
#include "lyxfunc.h"
#include "LyXView.h"
#include "support/LAssert.h"
#include "ViewBase.h"
ControlCommand::ControlCommand(LyXView & lv, Dialogs & d, kb_action ac)
: ControlConnectInset<InsetCommand>(lv, d),
params_(0), action_(ac)
{}
void ControlCommand::showInset(InsetCommand * inset)
{
if (inset == 0) return; // maybe we should Assert this?
connectInset(inset);
show(inset->params());
}
void ControlCommand::createInset(string const & arg)
{
connectInset();
if ( !arg.empty() )
bc().valid(); // so that the user can press Ok
InsetCommandParams params;
params.setFromString(arg);
show(params);
}
void ControlCommand::update()
{
if (params_) delete params_;
if (inset_)
params_ = new InsetCommandParams(inset_->params());
else
params_ = new InsetCommandParams;
bc().readOnly(isReadonly());
view().update();
}
void ControlCommand::show(InsetCommandParams const & params)
{
if (params_) delete params_;
params_ = new InsetCommandParams(params);
bc().readOnly(isReadonly());
view().show();
}
void ControlCommand::hide()
{
if (params_) {
delete params_;
params_ = 0;
}
disconnect();
view().hide();
}
InsetCommandParams & ControlCommand::params() const
{
Assert(params_);
return *params_;
}
void ControlCommand::apply()
{
view().apply();
if (inset_) {
// Only update if contents have changed
if (params() != inset_->params()) {
inset_->setParams(params());
lv_.view()->updateInset(inset_, true);
}
} else if (action_ != LFUN_NOACTION){
lv_.getLyXFunc()->Dispatch(action_, params().getAsString());
}
}

View File

@ -0,0 +1,74 @@
// -*- C++ -*-
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 2000 The LyX Team.
*
* ======================================================
*
* \file ControlCommand.h
* \author Angus Leeming <a.leeming@ic.ac.uk>
*
* Defines a Controller class for dialogs that create or modify
* an inset derived from InsetCommand.
* Also defines the abstract base class from which the GUI-dependent Views
* of this dialog should be derived.
*/
#ifndef CONTROLCOMMAND_H
#define CONTROLCOMMAND_H
#ifdef __GNUG__
#pragma interface
#endif
#include "ControlConnections.h"
#include "insets/insetcommand.h"
#include "commandtags.h" // kb_action
class Dialogs;
class LyXView;
/** The Inset dialog controller. Connects/disconnects signals, launches
GUI-dependent View and returns the output from this View to the kernel.
*/
class ControlCommand : public ControlConnectInset<InsetCommand>
{
public:
///
ControlCommand(LyXView &, Dialogs &, kb_action=LFUN_NOACTION);
/// Allow the View access to the local copy.
InsetCommandParams & params() const;
protected:
/// Slots connected in the daughter classes c-tor.
/// Slot launching dialog to (possibly) create a new inset.
void createInset(string const &);
/// Slot launching dialog to an existing inset.
void showInset(InsetCommand *);
/// Connect signals and launch View.
void show(InsetCommandParams const &);
/// Instantiation of private ControlBase virtual methods.
/// Get changed parameters and Dispatch them to the kernel.
virtual void apply();
/// Disconnect signals and hide View.
virtual void hide();
/// Update dialog before showing it.
virtual void update();
private:
/** A local copy of the inset's params.
Memory is allocated only whilst the dialog is visible.
*/
InsetCommandParams * params_;
/// Controls what is done in LyXFunc::Dispatch()
kb_action const action_;
};
#endif // CONTROLCOMMAND_H

View File

@ -0,0 +1,86 @@
// -*- C++ -*-
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 2000 The LyX Team.
*
* ======================================================
*
* \file ControlConnections.C
* \author Angus Leeming <a.leeming@ic.ac.uk>
*/
#ifdef __GNUG__
#pragma implementation
#endif
#include <config.h>
#include "ControlConnections.h"
#include "Dialogs.h"
#include "ViewBase.h"
#include "insets/lyxinset.h"
#ifdef SIGC_CXX_NAMESPACES
using SigC::slot;
#endif
ControlConnectBase::ControlConnectBase(LyXView & lv, Dialogs & d)
: ControlBase(lv),
d_(d), h_(0), r_(0)
{}
void ControlConnectBase::connect()
{
r_ = Dialogs::redrawGUI.
connect(slot(this, &ControlConnectBase::redraw));
}
void ControlConnectBase::disconnect()
{
h_.disconnect();
r_.disconnect();
}
void ControlConnectBase::redraw()
{
view().redraw();
}
ControlConnectBI::ControlConnectBI(LyXView & lv, Dialogs & d)
: ControlConnectBase(lv, d)
{}
void ControlConnectBI::connect()
{
h_ = d_.hideAll.connect(slot(this, &ControlConnectBI::hide));
ControlConnectBase::connect();
}
ControlConnectBD::ControlConnectBD(LyXView & lv, Dialogs & d)
: ControlConnectBase(lv, d),
u_(0)
{}
void ControlConnectBD::connect()
{
u_ = d_.updateBufferDependent.
connect(slot(this, &ControlConnectBD::updateSlot));
h_ = d_.hideBufferDependent.
connect(slot(this, &ControlConnectBD::hide));
ControlConnectBase::connect();
}
void ControlConnectBD::disconnect()
{
u_.disconnect();
ControlConnectBase::disconnect();
}

View File

@ -0,0 +1,180 @@
// -*- C++ -*-
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 2000 The LyX Team.
*
* ======================================================
*
* \file ControlConnections.h
* \author Angus Leeming <a.leeming@ic.ac.uk>
*/
#ifndef CONTROLCONNECTIONS_H
#define CONTROLCONNECTIONS_H
#ifdef __GNUG__
#pragma interface
#endif
#include "ControlBase.h"
/** Base class to control connection/disconnection of signals with the LyX
kernel. It is meant to be used solely as the parent class to
ControlConnectBI and ControlConnectBD.
*/
class ControlConnectBase : public ControlBase
{
public:
///
ControlConnectBase(LyXView &, Dialogs &);
protected:
/// Connect signals
virtual void connect();
/// Disconnect signals
virtual void disconnect();
/** Redraw the dialog (on receipt of a Signal indicating, for example,
its colors have been re-mapped).
*/
void redraw();
/// Contains the signals we have to connect to.
Dialogs & d_;
/// Hide connection.
Connection h_;
/// Redraw connection.
Connection r_;
};
/** Base class to control connection/disconnection of signals with the LyX
kernel for Buffer Independent dialogs.
Such dialogs do not require an update Connection although they may use
an update() function which is also supported by the Restore button.
*/
class ControlConnectBI : public ControlConnectBase
{
public:
///
ControlConnectBI(LyXView &, Dialogs &);
protected:
/// Connect signals
virtual void connect();
};
/** Base class to control connection/disconnection of signals with the LyX
kernel for Buffer Dependent dialogs.
*/
class ControlConnectBD : public ControlConnectBase
{
public:
///
ControlConnectBD(LyXView &, Dialogs &);
protected:
/** Slot connected to update signal.
Bool indicates if a buffer switch took place.
Default behaviour is to ignore this and simply update().
*/
virtual void updateSlot(bool) { update(); }
/// Connect signals
virtual void connect();
/// Disconnect signals
virtual void disconnect();
private:
/// Update connection.
Connection u_;
};
/** Base class to control connection/disconnection of signals with the LyX
kernel for Inset dialogs.
*/
class Inset;
template <class Inset>
class ControlConnectInset : public ControlConnectBD
{
public:
///
ControlConnectInset(LyXView &, Dialogs &);
protected:
/// Slot connected to update signal.
virtual void updateSlot(bool);
/// Connect signals
void connectInset(Inset * = 0);
/// Disconnect signals
virtual void disconnect();
///
void disconnectInset();
protected:
/// pointer to the inset passed through connectInset
Inset * inset_;
private:
/// inset::hide connection.
Connection ih_;
};
template <class Inset>
ControlConnectInset<Inset>::ControlConnectInset(LyXView & lv, Dialogs & d)
: ControlConnectBD(lv, d),
ih_(0), inset_(0)
{}
template <class Inset>
void ControlConnectInset<Inset>::updateSlot(bool switched)
{
if (switched)
hide();
else
update();
}
template <class Inset>
void ControlConnectInset<Inset>::disconnect()
{
inset_ = 0;
ih_.disconnect();
ControlConnectBD::disconnect();
}
template <class Inset>
void ControlConnectInset<Inset>::connectInset(Inset * inset)
{
// If connected to another inset, disconnect from it.
if (inset_) {
ih_.disconnect();
inset_ = 0;
}
if (inset) {
inset_ = inset;
ih_ = inset->hideDialog.connect(
slot(this, &ControlConnectInset::hide));
}
connect();
}
template <class Inset>
void ControlConnectInset<Inset>::disconnectInset()
{
ih_.disconnect();
}
#endif // CONTROLCONNECTIONS_H

View File

@ -0,0 +1,41 @@
AUTOMAKE_OPTIONS = foreign 1.4
DISTCLEANFILES= *.orig *.rej *~ *.bak core
MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
noinst_LTLIBRARIES = libcontrollers.la
BOOST_INCLUDES = -I$(top_srcdir)/boost
INCLUDES = -I${top_srcdir}/src/ \
-I${top_srcdir}/src/frontends/ \
${SIGC_CFLAGS} $(BOOST_INCLUDES)
LIBS =
SUBDIRS =
ETAGS_ARGS = --lang=c++
libcontrollers_la_SOURCES=\
ButtonController.C \
ButtonController.h \
ButtonPolicies.C \
ButtonPolicies.h \
ControlBase.C \
ControlBase.h \
ControlBibitem.C \
ControlBibitem.h \
ControlCitation.C \
ControlCitation.h \
ControlCommand.C \
ControlCommand.h \
ControlConnections.C \
ControlConnections.h \
ViewBase.h
# just copied from old lyx repository
dist-hook:
for subdir in $(LYXDATADIRS) ; do \
test -d $(distdir)/$$subdir \
|| mkdir $(distdir)/$$subdir \
|| exit 1; \
chmod 777 $(distdir)/$$subdir; \
list=`(cd $(srcdir)/$$subdir && ls -1 | grep -v CVS)`; \
echo $$list ; \
for fil in $$list ; do \
cp -p $(srcdir)/$$subdir/$$fil $(distdir)/$$subdir ; \
done ; \
done

View File

@ -0,0 +1,17 @@
This directory provides the controllers that act as an interface between the
LyX kernel and the GUI-specific implementations of each popup. It also
provides abstract base classes from which GUI-specific implemetations of the
ButtonController and each separate popup should be derived (see
ButtonControlBase.[Ch] and ViewBase.h respectively).
The Controller connects the GUI-specific popup to any appropriate signals and
dispatches any changes in the data to the kernel. It has no knowledge of the
actual instantiation of the GUI-dependent View and ButtonController, which
should therefore be created elsewhere. Once created, the Controller will take
care of their initialisation, management and, ultimately, destruction.
This leaves the GUI-specific popup (and its author!) to worry only about the
data that it has been created to input/modify.
This concept has been instatiated for the Citation dialog only at the moment.
See xforms-new/FormCitation.[Ch] for an xforms-specific View of the dialog.

View File

@ -0,0 +1,71 @@
// -*- C++ -*-
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 2000 The LyX Team.
*
* ======================================================
*
* Author: Angus Leeming <a.leeming@ic.ac.uk>
*/
#ifndef VIEWBASE_H
#define VIEWBASE_H
#include <boost/utility.hpp>
#include "ControlBase.h"
class ViewBase {
public:
///
ViewBase(ControlBase & c) : controller_(c) {}
///
virtual ~ViewBase() {}
/// Apply changes to LyX data from dialog.
virtual void apply() = 0;
/// Hide the dialog.
virtual void hide() = 0;
/// Redraw the dialog (e.g. if the colors have been remapped).
virtual void redraw() {}
/// Create the dialog if necessary, update it and display it.
virtual void show() = 0;
/// Update dialog before/whilst showing it.
virtual void update() = 0;
/** These shortcuts allow (e.g. xform's) global callback functions
access to the buttons without making the whole controller_ public.
*/
///
void ApplyButton() { controller_.ApplyButton(); }
///
void OKButton() { controller_.OKButton(); }
///
void CancelButton() { controller_.CancelButton(); }
///
void RestoreButton() { controller_.RestoreButton(); }
protected:
/// The view is, after all, controlled!
ControlBase & controller_;
};
/** A generic class to cast the ButtonController controller_.bc_ to it's
daughter class. */
template <class GUIbc>
class ViewBC : public ViewBase {
public:
///
ViewBC(ControlBase & c) : ViewBase(c) {}
///
GUIbc & bc() const
{
return static_cast<GUIbc &>(controller_.bc());
// return dynamic_cast<GUIbc &>(controller_.bc());
}
};
#endif // VIEWBASE_H

View File

@ -1,3 +1,48 @@
2001-03-14 Angus Leeming <a.leeming@ic.ac.uk>
* Merging changes from BRANCH_MVC back into HEAD.
2001-03-12 Angus Leeming <a.leeming@ic.ac.uk>
* Dialogs.C (c-tor): Changes associated with storing a vector of
boost::shared_ptrs.
2001-03-08 Angus Leeming <a.leeming@ic.ac.uk>
* Makefile.am: added ../xforms/FormCredits.lo and
../xforms/form_credits.lo
* Dialogs.C: added FormCredits and removed ShowCredits.
2001-03-07 Angus Leeming <a.leeming@ic.ac.uk>
* FormCitation.[Ch]: cull large chunks of code, making more use of
ControlCitation and associated helper funcs. Also use boost::scoped_ptr
for dialog_.
2001-03-05 Angus Leeming <a.leeming@ic.ac.uk>
* FormCitation.[Ch]: use ButtonController::input() rather than
ButtonController::valid() to check state of input. The buttons are
now controlled correctly.
2001-03-02 Angus Leeming <a.leeming@ic.ac.uk>
* kdeBC.[Ch]: Changes associated with the changes to
controllers/ButtonController.[Ch]. Ie, the class is now derived from
ButtonControllerBase and the ButtonPolicy is accessed through a method
bp() rather than the instance bp_.
2001-02-23 Angus Leeming <a.leeming@ic.ac.uk>
* kdeBC.[Ch]: new files. A ButtonController for KDE.
* FormCitation.[Ch]:
* citationdlg.[Ch]: A KDE-specific implementation of the
Citation dialog, controlled by the GUI-I ControlCitation.
* Dialogs.C: Use the controlled Citation dialog.
2001-03-15 Angus Leeming <a.leeming@ic.ac.uk>
* FormParagraph.C: changes associated with Lars' creation of a

View File

@ -11,10 +11,17 @@
#include FORMS_H_LOCATION
#include "Dialogs.h"
#include "ControlBibitem.h"
#include "ControlCitation.h"
#include "kdeBC.h"
#include "FormBibitem.h"
#include "FormBibtex.h"
#include "FormCitation.h"
#include "citationdlg.h"
#include "FormCopyright.h"
#include "FormCredits.h"
#include "FormDocument.h"
#include "FormError.h"
#include "FormGraphics.h"
@ -22,6 +29,7 @@
#include "FormIndex.h"
#include "FormLog.h"
#include "FormParagraph.h"
#include "FormPreamble.h"
#include "FormPreferences.h"
#include "FormPrint.h"
#include "FormRef.h"
@ -36,9 +44,6 @@
#pragma implementation
#endif
// temporary till ported
extern void ShowCredits();
/* We don't implement this, but it's needed whilst we
* still rely on xforms
*/
@ -46,42 +51,34 @@ Signal0<void> Dialogs::redrawGUI;
Dialogs::Dialogs(LyXView * lv)
{
/*
dialogs_.push_back(new FormBibitem(lv, this));
dialogs_.push_back(new FormBibtex(lv, this));
dialogs_.push_back(new FormCitation(lv, this));
dialogs_.push_back(new FormCopyright(lv, this));
dialogs_.push_back(new FormDocument(lv, this));
dialogs_.push_back(new FormError(lv, this));
dialogs_.push_back(new FormGraphics(lv, this));
dialogs_.push_back(new FormInclude(lv, this));
dialogs_.push_back(new FormIndex(lv, this));
dialogs_.push_back(new FormLog(lv, this));
dialogs_.push_back(new FormParagraph(lv, this));
dialogs_.push_back(new FormPreferences(lv, this));
dialogs_.push_back(new FormPrint(lv, this));
dialogs_.push_back(new FormRef(lv, this));
dialogs_.push_back(new FormSplash(lv, this));
dialogs_.push_back(new FormTabular(lv, this));
dialogs_.push_back(new FormTabularCreate(lv, this));
dialogs_.push_back(new FormToc(lv, this));
dialogs_.push_back(new FormUrl(lv, this));
dialogs_.push_back(new FormVCLog(lv, this));
splash_.reset(new FormSplash(lv, this));
showCredits.connect(slot(ShowCredits));
add(new GUIBibitem<FormBibitem, xformsBC>(*lv, *this));
add(new GUICitation<FormCitation, xformsBC>(*lv, *this));
add(new FormBibtex(lv, this));
add(new FormCharacter(lv, this));
add(new FormCopyright(lv, this));
add(new FormCredits(lv, this));
add(new FormDocument(lv, this));
add(new FormError(lv, this));
add(new FormGraphics(lv, this));
add(new FormInclude(lv, this));
add(new FormIndex(lv, this));
add(new FormLog(lv, this));
add(new FormParagraph(lv, this));
add(new FormPreamble(lv, this));
add(new FormPreferences(lv, this));
add(new FormPrint(lv, this));
add(new FormRef(lv, this));
add(new FormSearch(lv, this));
add(new FormTabular(lv, this));
add(new FormTabularCreate(lv, this));
add(new FormToc(lv, this));
add(new FormUrl(lv, this));
add(new FormVCLog(lv, this));
// reduce the number of connections needed in
// dialogs by a simple connection here.
hideAll.connect(hideBufferDependent.slot());
*/
}
Dialogs::~Dialogs()
{
for (vector<DialogBase *>::iterator iter = dialogs_.begin();
iter != dialogs_.end();
++iter) {
delete *iter;
}
}

View File

@ -10,63 +10,114 @@
#include <algorithm>
#include "Dialogs.h"
#include "ControlCitation.h"
#include "FormCitation.h"
#include "gettext.h"
#include "buffer.h"
#include "LyXView.h"
#include "lyxfunc.h"
#include "citationdlg.h"
#include "gettext.h"
#include "kdeBC.h"
#include "support/lstrings.h"
using std::vector;
using std::pair;
using std::find;
FormCitation::FormCitation(LyXView *v, Dialogs *d)
: dialog_(0), lv_(v), d_(d), inset_(0), h_(0), u_(0), ih_(0),
keys(0), chosenkeys(0)
{
d->showCitation.connect(slot(this, &FormCitation::showCitation));
d->createCitation.connect(slot(this, &FormCitation::createCitation));
}
FormCitation::FormCitation(ControlCitation & c)
: ViewBC<kdeBC>(c),
keys(0), chosenkeys(0)
{}
FormCitation::~FormCitation()
ControlCitation & FormCitation::controller() const
{
delete dialog_;
}
void FormCitation::showCitation(InsetCommand * const inset)
{
// FIXME: when could inset be 0 here ?
if (inset==0)
return;
inset_ = inset;
readonly = lv_->buffer()->isReadonly();
ih_ = inset_->hideDialog.connect(slot(this,&FormCitation::hide));
params = inset->params();
show();
return static_cast<ControlCitation &>(controller_);
//return dynamic_cast<ControlCitation &>(controller_);
}
void FormCitation::createCitation(string const & arg)
void FormCitation::show()
{
// we could already be showing stuff, clear it out
if (inset_)
close();
if (!dialog_.get())
build();
readonly = lv_->buffer()->isReadonly();
params.setFromString(arg);
show();
update();
dialog_->raise();
dialog_->setActiveWindow();
dialog_->show();
}
void FormCitation::apply()
{
controller().params().setCmdName("cite");
controller().params().setContents(getStringFromVector(chosenkeys));
controller().params().setOptions(dialog_->after->text());
}
void FormCitation::hide()
{
chosenkeys.clear();
selectedKey.erase();
selectedChosenKey.erase();
if (dialog_.get() && dialog_->isVisible())
dialog_->hide();
}
void FormCitation::build()
{
dialog_.reset(new CitationDialog(this, 0, "Citation", false));
// Manage the ok, apply, restore and cancel/close buttons
bc().setOK(dialog_->buttonOk);
//bc().setApply(dialog_->buttonApply);
bc().setCancel(dialog_->buttonCancel);
//bc().setUndoAll(dialog_->buttonRestore);
bc().refresh();
bc().addReadOnly(dialog_->add);
bc().addReadOnly(dialog_->remove);
bc().addReadOnly(dialog_->up);
bc().addReadOnly(dialog_->down);
//bc().addReadOnly(dialog_->style);
//bc().addReadOnly(dialog_->labelbefore);
bc().addReadOnly(dialog_->labelafter);
}
void FormCitation::update()
{
keys = controller().getBibkeys();
updateAvailableList();
selectedKey.erase();
chosenkeys = getVectorFromString(controller().params().getContents());
updateChosenList();
selectedChosenKey.erase();
dialog_->entry->setText("");
dialog_->after->setText(controller().params().getOptions().c_str());
updateButtons();
if (controller().isReadonly()) {
dialog_->keys->setFocusPolicy(QWidget::NoFocus);
dialog_->chosen->setFocusPolicy(QWidget::NoFocus);
dialog_->after->setFocusPolicy(QWidget::NoFocus);
} else {
dialog_->keys->setFocusPolicy(QWidget::StrongFocus);
dialog_->chosen->setFocusPolicy(QWidget::StrongFocus);
dialog_->after->setFocusPolicy(QWidget::StrongFocus);
}
}
void FormCitation::updateButtons()
{
if (readonly) {
// Can go once ButtonController is working?
if (controller().isReadonly()) {
dialog_->add->setEnabled(false);
dialog_->remove->setEnabled(false);
dialog_->up->setEnabled(false);
@ -88,138 +139,30 @@ void FormCitation::updateButtons()
void FormCitation::updateChosenList()
{
dialog_->chosen->setAutoUpdate(false);
dialog_->chosen->clear();
for (vector< string >::const_iterator iter = chosenkeys.begin();
iter != chosenkeys.end(); ++iter) {
dialog_->chosen->insertItem(iter->c_str());
}
dialog_->chosen->setAutoUpdate(true);
dialog_->chosen->update();
updateList(dialog_->chosen, chosenkeys);
}
void FormCitation::updateAvailableList()
{
dialog_->keys->setAutoUpdate(false);
dialog_->keys->clear();
updateList(dialog_->keys, keys);
}
for (vector< pair<string,string> >::const_iterator iter = keys.begin();
void FormCitation::updateList(QListBox * lb, vector<string> const & keys)
{
lb->setAutoUpdate(false);
lb->clear();
for (vector<string>::const_iterator iter = keys.begin();
iter != keys.end(); ++iter) {
dialog_->keys->insertItem(iter->first.c_str());
lb->insertItem(iter->c_str());
}
dialog_->keys->setAutoUpdate(true);
dialog_->keys->update();
lb->setAutoUpdate(true);
lb->update();
}
// we can safely ignore the parameter because we can always update
void FormCitation::update(bool)
{
keys.clear();
vector < pair<string,string> > const ckeys = lv_->buffer()->getBibkeyList();
for (vector< pair<string,string> >::const_iterator iter = ckeys.begin();
iter != ckeys.end(); ++iter) {
keys.push_back(*iter);
}
updateAvailableList();
selectedKey.erase();
chosenkeys.clear();
string tmp, paramkeys(params.getContents());
paramkeys = frontStrip(split(paramkeys, tmp, ','));
while (!tmp.empty()) {
chosenkeys.push_back(tmp);
paramkeys = frontStrip(split(paramkeys, tmp, ','));
}
updateChosenList();
selectedChosenKey.erase();
dialog_->entry->setText("");
dialog_->after->setText(params.getOptions().c_str());
updateButtons();
if (readonly) {
dialog_->keys->setFocusPolicy(QWidget::NoFocus);
dialog_->chosen->setFocusPolicy(QWidget::NoFocus);
dialog_->after->setFocusPolicy(QWidget::NoFocus);
dialog_->buttonOk->setEnabled(false);
dialog_->buttonCancel->setText(_("&Close"));
} else {
dialog_->keys->setFocusPolicy(QWidget::StrongFocus);
dialog_->chosen->setFocusPolicy(QWidget::StrongFocus);
dialog_->after->setFocusPolicy(QWidget::StrongFocus);
dialog_->buttonOk->setEnabled(true);
dialog_->buttonCancel->setText(_("&Cancel"));
}
}
void FormCitation::apply()
{
if (readonly)
return;
string contents;
for (vector< string >::const_iterator iter = chosenkeys.begin();
iter != chosenkeys.end(); ++iter) {
if (iter != chosenkeys.begin())
contents += ", ";
contents += *iter;
}
params.setContents(contents);
params.setOptions(dialog_->after->text());
if (inset_ != 0) {
if (params != inset_->params()) {
inset_->setParams(params);
lv_->view()->updateInset(inset_, true);
}
} else
lv_->getLyXFunc()->Dispatch(LFUN_CITATION_INSERT, params.getAsString().c_str());
}
void FormCitation::show()
{
if (!dialog_)
dialog_ = new CitationDialog(this, 0, _("LyX: Citation Reference"), false);
if (!dialog_->isVisible()) {
h_ = d_->hideBufferDependent.connect(slot(this, &FormCitation::hide));
u_ = d_->updateBufferDependent.connect(slot(this, &FormCitation::update));
}
dialog_->raise();
dialog_->setActiveWindow();
update();
dialog_->show();
}
void FormCitation::close()
{
h_.disconnect();
u_.disconnect();
ih_.disconnect();
inset_ = 0;
}
void FormCitation::hide()
{
dialog_->hide();
close();
}
void FormCitation::selectChosen()
{
for (unsigned int i=0; i < dialog_->chosen->count(); ++i) {
@ -231,15 +174,15 @@ void FormCitation::selectChosen()
}
}
void FormCitation::add()
ButtonPolicy::SMInput FormCitation::add()
{
if (selectedKey.empty())
return;
return ButtonPolicy::SMI_NOOP;
for (vector< pair<string,string> >::const_iterator iter = keys.begin();
for (vector<string>::const_iterator iter = keys.begin();
iter != keys.end(); ++iter) {
if (iter->first == selectedKey) {
chosenkeys.push_back(iter->first);
if (*iter == selectedKey) {
chosenkeys.push_back(*iter);
break;
}
}
@ -247,12 +190,13 @@ void FormCitation::add()
selectedChosenKey.erase();
updateChosenList();
updateButtons();
return ButtonPolicy::SMI_VALID;
}
void FormCitation::remove()
ButtonPolicy::SMInput FormCitation::remove()
{
if (selectedChosenKey.empty())
return;
return ButtonPolicy::SMI_NOOP;
for (vector< string >::iterator iter = chosenkeys.begin();
iter != chosenkeys.end(); ++iter) {
@ -264,12 +208,13 @@ void FormCitation::remove()
selectedChosenKey.erase();
updateChosenList();
updateButtons();
return ButtonPolicy::SMI_VALID;
}
void FormCitation::up()
ButtonPolicy::SMInput FormCitation::up()
{
if (selectedChosenKey.empty())
return;
return ButtonPolicy::SMI_NOOP;
// Qt will select the first one on redo, so we need this
string tmp = selectedChosenKey;
@ -285,18 +230,19 @@ void FormCitation::up()
}
}
if (iter==chosenkeys.end())
return;
return ButtonPolicy::SMI_NOOP;
updateChosenList();
selectedChosenKey=tmp;
selectChosen();
return ButtonPolicy::SMI_VALID;
}
void FormCitation::down()
ButtonPolicy::SMInput FormCitation::down()
{
if (selectedChosenKey.empty())
return;
return ButtonPolicy::SMI_NOOP;
// Qt will select the first one on redo, so we need this
string tmp = selectedChosenKey;
@ -312,74 +258,67 @@ void FormCitation::down()
}
}
if (iter == chosenkeys.end())
return;
return ButtonPolicy::SMI_NOOP;
updateChosenList();
selectedChosenKey=tmp;
selectChosen();
return ButtonPolicy::SMI_VALID;
}
void FormCitation::select_key(char const * key)
ButtonPolicy::SMInput FormCitation::select_key(char const * key)
{
if (readonly)
return;
if (controller().isReadonly())
return ButtonPolicy::SMI_INVALID;
vector<string>::const_iterator iter =
find(chosenkeys.begin(), chosenkeys.end(), key);
if (iter != chosenkeys.end())
return;
return ButtonPolicy::SMI_NOOP;
selectedKey.erase();
selectedKey = key;
add();
return ButtonPolicy::SMI_VALID;
}
void FormCitation::highlight_key(char const * key)
{
if (readonly)
return;
selectedKey.erase();
selectedKey = key;
for (unsigned int i=0; i < keys.size(); i++) {
if (keys[i].first == key) {
dialog_->entry->setText(keys[i].second.c_str());
dialog_->chosen->clearFocus();
dialog_->chosen->clearSelection();
selectedChosenKey.erase();
break;
}
}
updateButtons();
highlight(key, dialog_->chosen, selectedKey, selectedChosenKey);
}
void FormCitation::highlight_chosen(char const * key)
{
selectedChosenKey.erase();
selectedChosenKey = key;
highlight(key, dialog_->keys, selectedChosenKey, selectedKey);
}
void FormCitation::highlight(char const * key, QListBox * lb,
string & selected1, string & selected2)
{
selected1.erase();
selected1 = key;
unsigned int i;
for (i=0; i < keys.size(); i++) {
if (keys[i].first == key) {
if (keys[i].second.compare(dialog_->entry->text()))
dialog_->entry->setText(keys[i].second.c_str());
dialog_->keys->clearFocus();
dialog_->keys->clearSelection();
selectedKey.erase();
for (i=0; i < keys.size(); ++i) {
if (keys[i] == key) {
string const tmp = controller().getBibkeyInfo(key);
dialog_->entry->setText(tmp.c_str());
lb->clearFocus();
lb->clearSelection();
selected2.erase();
break;
}
}
if (i == keys.size())
dialog_->entry->setText(_("Key not found in references."));
dialog_->entry->setText(_("Key not found."));
updateButtons();
}

View File

@ -9,55 +9,56 @@
#ifndef FORMCITATION_H
#define FORMCITATION_H
#include "DialogBase.h"
#include "support/lstrings.h"
#include "boost/utility.hpp"
#include "insets/insetcommand.h"
#include <vector>
#include <boost/smart_ptr.hpp>
class Dialogs;
class LyXView;
#ifdef __GNUG__
#pragma interface
#endif
#include "ViewBase.h"
#include "ButtonPolicies.h"
class kdeBC;
class QListBox;
class ControlCitation;
class CitationDialog;
class FormCitation : public DialogBase {
class FormCitation : public ViewBC<kdeBC> {
public:
FormCitation(LyXView *, Dialogs *);
FormCitation(ControlCitation &);
~FormCitation();
/// Functions accessible to the Controller.
/// Set the Params variable for the Controller.
virtual void apply();
/// Set the Params variable for the Controller.
virtual void build();
/// Hide the dialog.
virtual void hide();
/// Update dialog before/whilst showing it.
virtual void update();
/// Create the dialog if necessary, update it and display it.
void show();
/// Apply changes
void apply();
/// close the connections
void close();
/// add a key
void add();
ButtonPolicy::SMInput add();
/// remove a key
void remove();
ButtonPolicy::SMInput remove();
/// move a key up
void up();
ButtonPolicy::SMInput up();
/// move a key down
void down();
ButtonPolicy::SMInput down();
/// a key has been highlighted
void highlight_key(char const * key);
/// a chosen key has been highlighted
void highlight_chosen(char const * key);
/// a key has been double-clicked
void select_key(char const * key);
ButtonPolicy::SMInput select_key(char const * key);
private:
/// Create the dialog if necessary, update it and display it.
void show();
/// Hide the dialog.
void hide();
/// Update the dialog.
void update(bool switched = false);
/// create a Citation inset
void createCitation(string const &);
/// edit a Citation inset
void showCitation(InsetCommand * const);
/// The parent controller
ControlCitation & controller() const;
/// update add,remove,up,down
void updateButtons();
/// update the available keys list
@ -66,33 +67,16 @@ private:
void updateChosenList();
/// select the currently chosen key
void selectChosen();
/// does the dirty work for highlight_key(), highlight_chosen()
void highlight(char const *, QListBox *, string &, string &);
/// does the dirty work for updateAvailableList(), updateChosenList()
void updateList(QListBox *, std::vector<string> const &);
/// Real GUI implementation.
CitationDialog * dialog_;
/// the LyXView we belong to
LyXView * lv_;
/** Which Dialogs do we belong to?
Used so we can get at the signals we have to connect to.
*/
Dialogs * d_;
/// pointer to the inset if any
InsetCommand * inset_;
/// insets params
InsetCommandParams params;
/// is the inset we are reading from a readonly buffer ?
bool readonly;
/// Hide connection.
Connection h_;
/// Update connection.
Connection u_;
/// Inset hide connection.
Connection ih_;
boost::scoped_ptr<CitationDialog> dialog_;
/// available citation keys
std::vector<std::pair<string, string> > keys;
std::vector<string> keys;
/// chosen citation keys
std::vector<string> chosenkeys;

View File

@ -3,7 +3,9 @@ MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
noinst_LTLIBRARIES = libkde.la
BOOST_INCLUDES = -I$(top_srcdir)/boost
SUBDIRS = dlg moc
INCLUDES = -I${top_srcdir}/src/ -I${top_srcdir}/src/frontends/ \
INCLUDES = -I${top_srcdir}/src/ \
-I${top_srcdir}/src/frontends/ \
-I${top_srcdir}/src/frontends/controllers \
${SIGC_CFLAGS} ${FRONTEND_INCLUDES} $(BOOST_INCLUDES) \
-I${top_srcdir}/src/frontends/xforms
@ -15,11 +17,13 @@ libkde_la_OBJADD = \
moc/libkdemoc.la \
dlg/libkdedlg.la \
dlg/moc/libkdedlgmoc.la \
../xforms/FormBase.lo \
../xforms/FormBaseDeprecated.lo \
../xforms/FormBibitem.lo \
../xforms/form_bibitem.lo \
../xforms/FormBibtex.lo \
../xforms/form_bibtex.lo \
../xforms/FormCredits.lo \
../xforms/form_credits.lo \
../xforms/FormError.lo \
../xforms/form_error.lo \
../xforms/FormGraphics.lo \
@ -35,9 +39,9 @@ libkde_la_OBJADD = \
../xforms/form_splash.lo \
../xforms/FormTabular.lo \
../xforms/form_tabular.lo \
../xforms/ButtonController.lo \
../xforms/xformsBC.lo \
../xforms/Color.lo \
../xforms/xform_helpers.lo \
../xforms/xforms_helpers.lo \
../xforms/input_validators.lo \
../xforms/RadioButtonGroup.lo \
../xforms/Toolbar_pimpl.lo \
@ -55,6 +59,8 @@ libkde_la_SOURCES = \
QtLyXView.h \
Timeout_pimpl.C \
Timeout_pimpl.h \
kdeBC.C \
kdeBC.h \
FormCitation.C \
FormCitation.h \
FormCopyright.C \

View File

@ -171,6 +171,6 @@ CitationDialog::~CitationDialog()
void CitationDialog::closeEvent(QCloseEvent * e)
{
form_->close();
form_->CancelButton();
e->accept();
}

View File

@ -14,6 +14,7 @@
// to connect apply() and hide()
#include "FormCitation.h"
#include "kdeBC.h"
#include <qdialog.h>
#include <qlistbox.h>
@ -68,34 +69,31 @@ private:
private slots:
void apply_adaptor(void) {
form_->apply();
form_->close();
hide();
form_->OKButton();
}
void close_adaptor(void) {
form_->close();
hide();
form_->CancelButton();
}
void add_adaptor(void) {
form_->add();
form_->bc().valid(form_->add());
}
void up_adaptor(void) {
form_->up();
form_->bc().valid(form_->up());
}
void down_adaptor(void) {
form_->down();
form_->bc().valid(form_->down());
}
void remove_adaptor(void) {
form_->remove();
form_->bc().valid(form_->remove());
}
void select_key_adaptor(const char * key) {
form_->select_key(key);
form_->bc().valid(form_->select_key(key));
}
void highlight_key_adaptor(const char * key) {

View File

@ -442,7 +442,7 @@ bool DocDialog::updateParams(BufferParams & params)
tmpskip = VSpace(length);
break;
}
if (!(tmpskip == params.getDefSkip())) {
redo = true;
params.setDefSkip(tmpskip);

55
src/frontends/kde/kdeBC.C Normal file
View File

@ -0,0 +1,55 @@
#include <config.h>
#ifdef __GNUG__
#pragma implementation
#endif
#include "kdeBC.h"
#include <qpushbutton.h>
kdeBC::kdeBC(string const & cancel, string const & close)
: ButtonControllerBase(cancel, close),
okay_(0), apply_(0), cancel_(0), undo_all_(0), read_only_()
{}
void kdeBC::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<QWidget *>::iterator iter = read_only_.begin();
iter != read_only_.end(); ++iter) {
(*iter)->setEnabled(enable);
}
}
}

77
src/frontends/kde/kdeBC.h Normal file
View File

@ -0,0 +1,77 @@
// -*- C++ -*-
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2000 The LyX Team.
*
* ======================================================
*
* Author: Angus Leeming <a.leeming@ic.ac.uk>
*/
#ifndef KDEBC_H
#define KDEBC_H
#include "ButtonController.h"
#include <list>
#ifdef __GNUG__
#pragma interface
#endif
class QWidget;
class QPushButton;
class kdeBC : public ButtonControllerBase
{
public:
///
kdeBC(string const & cancel, string const & close);
/* Initialise Button Functions */
/// Call refresh() when finished setting the buttons.
void setOK(QPushButton * obj) {
okay_ = obj;
}
///
void setApply(QPushButton * obj) {
apply_ = obj;
}
///
void setCancel(QPushButton * obj) {
cancel_ = obj;
}
///
void setUndoAll(QPushButton * obj) {
undo_all_ = obj;
}
///
void addReadOnly(QWidget * 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:
///
QPushButton * okay_;
///
QPushButton * apply_;
///
QPushButton * cancel_;
///
QPushButton * undo_all_;
/// List of items to be deactivated when in one of the read-only states
std::list<QWidget *> read_only_;
};
#endif // KDEBC_H

View File

@ -2,8 +2,12 @@ AUTOMAKE_OPTIONS = foreign 1.4
MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
noinst_LTLIBRARIES = libkdemoc.la
BOOST_INCLUDES = -I$(top_srcdir)/boost
INCLUDES = -I${top_srcdir}/src/ -I${top_srcdir}/src/frontends/ \
${SIGC_CFLAGS} ${FRONTEND_INCLUDES} ${BOOST_INCLUDES}
INCLUDES = -I${top_srcdir}/src/ \
-I${top_srcdir}/src/frontends/ \
-I${top_srcdir}/src/frontends/controllers \
${SIGC_CFLAGS} \
${FRONTEND_INCLUDES} \
$(BOOST_INCLUDES)
libkdemoc_la_SOURCES = FileDialog_private_moc.C \
citationdlg_moc.C \

View File

@ -1,182 +0,0 @@
#include <config.h>
#include <algorithm>
#include FORMS_H_LOCATION
#ifdef __GNUG__
#pragma implementation
#endif
#include "ButtonController.h"
#include "support/LAssert.h"
#include "gettext.h" // _()
//#include "debug.h"
using std::find;
using std::vector;
ButtonController::ButtonController(ButtonPolicy * bp,
char const * cancel, char const * close)
: bp_(bp), okay_(0), apply_(0), cancel_(0), undo_all_(0),
read_only_(), dont_trigger_change_(),
cancel_label(cancel), close_label(close)
{
Assert(bp);
}
void ButtonController::refresh()
{
if (okay_) {
if (bp_->buttonStatus(ButtonPolicy::OKAY)) {
fl_activate_object(okay_);
fl_set_object_lcol(okay_, FL_BLACK);
} else {
fl_deactivate_object(okay_);
fl_set_object_lcol(okay_, FL_INACTIVE);
}
}
if (apply_) {
if (bp_->buttonStatus(ButtonPolicy::APPLY)) {
fl_activate_object(apply_);
fl_set_object_lcol(apply_, FL_BLACK);
} else {
fl_deactivate_object(apply_);
fl_set_object_lcol(apply_, FL_INACTIVE);
}
}
if (undo_all_) {
if (bp_->buttonStatus(ButtonPolicy::UNDO_ALL)) {
fl_activate_object(undo_all_);
fl_set_object_lcol(undo_all_, FL_BLACK);
} else {
fl_deactivate_object(undo_all_);
fl_set_object_lcol(undo_all_,
FL_INACTIVE);
}
}
if (cancel_) {
if (bp_->buttonStatus(ButtonPolicy::CANCEL)) {
fl_set_object_label(cancel_,
_(cancel_label));
} else {
fl_set_object_label(cancel_,
_(close_label));
}
}
if (!read_only_.empty()) {
if (bp_->isReadOnly()) {
std::list<FL_OBJECT *>::iterator
end = read_only_.end();
for (std::list<FL_OBJECT *>::iterator
iter = read_only_.begin();
iter != end;
++iter) {
fl_deactivate_object(*iter);
fl_set_object_lcol(*iter,
FL_INACTIVE);
}
} else {
std::list<FL_OBJECT *>::iterator
end = read_only_.end();
for (std::list<FL_OBJECT *>::iterator
iter = read_only_.begin();
iter != end;
++iter) {
fl_activate_object(*iter);
fl_set_object_lcol(*iter,
FL_BLACK);
}
}
}
}
void ButtonController::input(ButtonPolicy::SMInput in)
{
//lyxerr << "ButtonController::input: bp_[" << bp_ << "]" << endl;
bp_->input(in);
refresh();
}
void ButtonController::ok()
{
input(ButtonPolicy::SMI_OKAY);
}
void ButtonController::apply()
{
input(ButtonPolicy::SMI_APPLY);
}
void ButtonController::cancel()
{
input(ButtonPolicy::SMI_CANCEL);
}
void ButtonController::undoAll()
{
input(ButtonPolicy::SMI_UNDO_ALL);
}
void ButtonController::hide()
{
input(ButtonPolicy::SMI_HIDE);
}
bool ButtonController::readOnly(bool ro)
{
if (ro) {
input(ButtonPolicy::SMI_READ_ONLY);
} else {
input(ButtonPolicy::SMI_READ_WRITE);
}
return ro;
}
void ButtonController::readWrite()
{
readOnly(false);
}
bool ButtonController::valid(bool v, FL_OBJECT * obj)
{
if (obj && !dont_trigger_change_.empty()) {
vector<FL_OBJECT *>::const_iterator cit =
find(dont_trigger_change_.begin(),
dont_trigger_change_.end(),
obj);
// Only trigger a change if the obj is not in the list
if (cit == dont_trigger_change_.end()) {
if (v) {
input(ButtonPolicy::SMI_VALID);
} else {
input(ButtonPolicy::SMI_INVALID);
}
}
} else {
if (v) {
input(ButtonPolicy::SMI_VALID);
} else {
input(ButtonPolicy::SMI_INVALID);
}
}
return v;
}
void ButtonController::invalid()
{
valid(false);
}

View File

@ -1,146 +0,0 @@
// -*- C++ -*-
/* ButtonController.h
* 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.
* Author: Allan Rae <rae@lyx.org>
* 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
* ======================================================
*/
#ifndef BUTTONCONTROLLER_H
#define BUTTONCONTROLLER_H
#include "ButtonPolicies.h"
#include <list>
#ifdef __GNUG__
#pragma interface
#endif
/** 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.
@author Allan Rae <rae@lyx.org>
20001001 Switch from template implementation to taking Policy parameter.
Allows FormBase to provide a ButtonController for any dialog.
*/
class ButtonController : public noncopyable
{
public:
/** Constructor.
The cancel/close label entries are _not_ managed within the class
thereby allowing you to reassign at will and to use static labels.
It also means if you really don't want to have the Cancel button
label be different when there is nothing changed in the dialog then
you can just assign "Cancel" to both labels. Or even reuse this
class for something completely different.
*/
ButtonController(ButtonPolicy * bp,
char const * cancel, char const * close);
// Somebody else owns the FL_OBJECTs we just manipulate them.
// so? (Lgb)
//~ButtonController() {}
/* Initialise Button Functions */
/// Call refresh() when finished setting the buttons.
void setOK(FL_OBJECT * obj) {
okay_ = obj;
}
///
void setApply(FL_OBJECT * obj) {
apply_ = obj;
}
///
void setCancel(FL_OBJECT * obj) {
cancel_ = obj;
}
///
void setUndoAll(FL_OBJECT * obj) {
undo_all_ = obj;
}
///
void setCancelTrueLabel(char const * c) {
cancel_label = c;
}
///
void setCancelFalseLabel(char const * c) {
close_label = c;
}
///
void addReadOnly(FL_OBJECT * obj) {
read_only_.push_front(obj);
}
///
void eraseReadOnly() {
read_only_.erase(read_only_.begin(), read_only_.end());
}
///
void addDontTriggerChange(FL_OBJECT * obj) {
dont_trigger_change_.push_back(obj);
}
///
void eraseDontTriggerChange() {
dont_trigger_change_.clear();
}
/* Action Functions */
/// force a refresh of the buttons
void refresh();
///
void input(ButtonPolicy::SMInput in);
///
void ok();
///
void apply();
///
void cancel();
///
void undoAll();
///
void hide();
/// Passthrough function -- returns its input value
bool readOnly(bool ro = true);
///
void readWrite();
/// Passthrough function -- returns its input value
bool valid(bool v = true, FL_OBJECT * obj = 0);
///
void invalid();
private:
///
ButtonPolicy * bp_;
///
FL_OBJECT * okay_;
///
FL_OBJECT * apply_;
///
FL_OBJECT * cancel_;
///
FL_OBJECT * undo_all_;
/// List of items to be deactivated when in one of the read-only states
std::list<FL_OBJECT *> read_only_;
/// container of items that do not trigger a change in activation status
std::vector<FL_OBJECT *> dont_trigger_change_;
///
char const * cancel_label;
///
char const * close_label;
};
#endif

View File

@ -1,10 +1,121 @@
2001-03-14 Angus Leeming <a.leeming@ic.ac.uk>
* Merging changes from BRANCH_MVC back into HEAD.
2001-03-12 Angus Leeming <a.leeming@ic.ac.uk>
* Dialogs.C (c-tor): Changes associated with storing a vector of
boost::shared_ptrs.
Use MVC Bibitem popup.
* FormBase.h: add a new template class FormBase2, derived from FormBase
to make life creating MVC popups even easier ;-)
* FormBibitem.[Ch]:
* forms/form_bibitem.fd: moved over to the MVC way of doing things.
Proof that a simple popup should be easy to implement!
* FormCitation.[Ch]: now derived from FormBase2.
* FormToc.C: added using std::vector directive.
2001-03-09 Dekel Tsur <dekelts@tau.ac.il>
* FormSearch.C: Add missing #pragma
2001-03-09 Angus Leeming <a.leeming@ic.ac.uk>
* FormCitation.C:
* forms/form_citation.fd: added the ability to Search, both Simply and
for Regular Expressions. Use the Search code in the controller() to do
the actual searching.
2001-03-08 Angus Leeming <a.leeming@ic.ac.uk>
* Makefile.am: added FormCredits.[Ch] and form_credits.[Ch]
* forms/makefile: added form_credits.fd
* Dialogs.C: added FormCredits and removed ShowCredits.
* FormCredits.[Ch]:
* forms/form_credits.fd:
* forms/form_search.fd: ported to the MVC way.
2001-03-07 Angus Leeming <a.leeming@ic.ac.uk>
* xforms_helpers.h (formatted): now has default arguments for size and
style.
* FormCitation.[Ch]: moved code out of this class and into
ControlCitation and associated helper funcs.
2001-03-05 Angus Leeming <a.leeming@ic.ac.uk>
* FormBase.[Ch]: (InputCB): use ButtonController::input() rather than
ButtonController::valid() to check state of input. The buttons are
now controlled correctly.
* Form*.[Ch]: use boost::scoped_ptr for the remaining few classes.
2001-03-05 Lars Gullik Bjønnes <larsbj@lyx.org>
* Form*.[Ch]: use boost::scoped_ptr for dialog_ et al.
* FormBase.[Ch]: rename title as title_.
2001-03-02 John Levon <moz@compsoc.man.ac.uk>
* FormBase.C (c-tor): initialise variables in correct order.
* FormCitation.C: add #include <algorithm>
2001-03-02 Angus Leeming <a.leeming@ic.ac.uk>
* xformsBC.[Ch]: Changes associated with the changes to
controllers/ButtonController.[Ch]. Ie, the class is now derived from
ButtonControllerBase and the ButtonPolicy is accessed through a method
bp() rather than the instance bp_.
* FormBaseDeprecated.[Ch]: no longer store a ButtonController, but
rather use a pure virtual method bc() to access the controller
instantiated by the daughter classes.
* F*.[Ch]: changes associated with the above.
2001-02-27 Angus Leeming <a.leeming@ic.ac.uk>
* FormBase.[Ch]: renamed as FormBaseDeprecated.[Ch]
* ViewXforms.[Ch]: renamed as FormBase.[Ch]
2001-02-23 Angus Leeming <a.leeming@ic.ac.uk>
* ButtonController.[Ch]: deleted. The class is split into two
(with identical functionality), the code being found in
../controllers/ButtonController.[Ch] and xformsBC.[Ch]
* xformsBC.[Ch]: new files. Xforms specific part of Allan's original
ButtonController class.
* FormBase.[Ch]: changes associated with the above split.
* ViewXforms.[Ch]: Base class for xforms dialogs derived from ViewBase
(../controllers/ViewBase.h). Ie, for Dialogs with GUI-I controllers
controlling all interaction to/from the LyX kernel.
* FormCitation.[Ch]:
* forms/form_citation.fd: An xforms-specific implementation of the
Citation dialog, controlled by the GUI-I ControlCitation.
* Dialogs.C: Use the controlled Citation dialog.
2001-03-09 Angus Leeming <a.leeming@ic.ac.uk>
* forms/fdfix.sh:
* forms/form_filedialog.C.patch: I hate having to make these patches,
but on reflection I think it's probably better than hacking fdfix.sh.
22001-03-13 John Levon <moz@compsoc.man.ac.uk>
2001-03-13 John Levon <moz@compsoc.man.ac.uk>
* FormGraphics.C: remove unnecessary hack

View File

@ -10,14 +10,16 @@
*======================================================*/
#include <config.h>
#include <algorithm> // max
#include <cmath> // floor
#include FORMS_H_LOCATION
#ifdef __GNUG_
#pragma implementation
#endif
#include <algorithm> // max
#include <cmath> // floor
#include "Color.h"
using std::max;

View File

@ -10,8 +10,18 @@
*/
#include <config.h>
#include FORMS_H_LOCATION
#ifdef __GNUG__
#pragma implementation
#endif
#include "Dialogs.h"
#include "ControlBibitem.h"
#include "ControlCitation.h"
#include "xformsBC.h"
#include "FormBibitem.h"
#include "FormBibtex.h"
#include "FormCitation.h"
@ -38,70 +48,46 @@
#include "FormUrl.h"
#include "FormVCLog.h"
#ifdef __GNUG__
#pragma implementation
#endif
using std::endl;
// Signal enabling all visible popups to be redrawn if so desired.
// E.g., when the GUI colours have been remapped.
Signal0<void> Dialogs::redrawGUI;
Dialogs::Dialogs(LyXView * lv)
{
splash_ = new FormSplash(lv, this);
dialogs_.push_back(new FormBibitem(lv, this));
dialogs_.push_back(new FormBibtex(lv, this));
dialogs_.push_back(new FormCharacter(lv, this));
dialogs_.push_back(new FormCitation(lv, this));
dialogs_.push_back(new FormCopyright(lv, this));
dialogs_.push_back(new FormCredits(lv, this));
dialogs_.push_back(new FormDocument(lv, this));
dialogs_.push_back(new FormError(lv, this));
dialogs_.push_back(new FormExternal(lv, this));
dialogs_.push_back(new FormGraphics(lv, this));
dialogs_.push_back(new FormInclude(lv, this));
dialogs_.push_back(new FormIndex(lv, this));
dialogs_.push_back(new FormLog(lv, this));
dialogs_.push_back(new FormParagraph(lv, this));
dialogs_.push_back(new FormPreamble(lv, this));
dialogs_.push_back(new FormPreferences(lv, this));
dialogs_.push_back(new FormPrint(lv, this));
dialogs_.push_back(new FormRef(lv, this));
dialogs_.push_back(new FormSearch(lv, this));
dialogs_.push_back(new FormTabular(lv, this));
dialogs_.push_back(new FormTabularCreate(lv, this));
dialogs_.push_back(new FormToc(lv, this));
dialogs_.push_back(new FormUrl(lv, this));
dialogs_.push_back(new FormVCLog(lv, this));
splash_.reset(new FormSplash(lv, this));
add(new GUICitation<FormCitation, xformsBC>(*lv, *this));
add(new GUIBibitem<FormBibitem, xformsBC>(*lv, *this));
add(new FormBibtex(lv, this));
add(new FormCharacter(lv, this));
add(new FormCopyright(lv, this));
add(new FormCredits(lv, this));
add(new FormDocument(lv, this));
add(new FormError(lv, this));
add(new FormExternal(lv, this));
add(new FormGraphics(lv, this));
add(new FormInclude(lv, this));
add(new FormIndex(lv, this));
add(new FormLog(lv, this));
add(new FormParagraph(lv, this));
add(new FormPreamble(lv, this));
add(new FormPreferences(lv, this));
add(new FormPrint(lv, this));
add(new FormRef(lv, this));
add(new FormSearch(lv, this));
add(new FormSplash(lv, this));
add(new FormTabular(lv, this));
add(new FormTabularCreate(lv, this));
add(new FormToc(lv, this));
add(new FormUrl(lv, this));
add(new FormVCLog(lv, this));
// reduce the number of connections needed in
// dialogs by a simple connection here.
hideAll.connect(hideBufferDependent.slot());
}
Dialogs::~Dialogs()
{
for (vector<DialogBase *>::iterator iter = dialogs_.begin();
iter != dialogs_.end();
++iter) {
delete *iter;
}
delete splash_;
}
void Dialogs::destroySplash()
{
delete splash_;
splash_ = 0;
}
/*****************************************************************************
Q. WHY does Dialogs::Dialogs pass `this' to dialog constructors?

View File

@ -11,57 +11,21 @@
#include <config.h>
#include FORMS_H_LOCATION
#ifdef __GNUG__
#pragma implementation
#endif
#include "Dialogs.h"
#include "FormBase.h"
#include "LyXView.h"
#include "xformsBC.h"
#include "support/LAssert.h"
//#include "debug.h"
extern "C" int C_FormBaseWMHideCB(FL_FORM * ob, void * d)
{
return FormBase::WMHideCB(ob, d);
}
extern "C" void C_FormBaseApplyCB(FL_OBJECT * ob, long d)
{
FormBase::ApplyCB(ob, d);
}
extern "C" void C_FormBaseOKCB(FL_OBJECT * ob, long d)
{
FormBase::OKCB(ob, d);
}
extern "C" void C_FormBaseCancelCB(FL_OBJECT * ob, long d)
{
FormBase::CancelCB(ob, d);
}
extern "C" void C_FormBaseInputCB(FL_OBJECT * ob, long d)
{
FormBase::InputCB(ob, d);
}
extern "C" void C_FormBaseRestoreCB(FL_OBJECT * ob, long d)
{
FormBase::RestoreCB(ob, d);
}
extern "C" int C_FormBaseWMHideCB(FL_FORM * form, void *);
FormBase::FormBase(LyXView * lv, Dialogs * d, string const & t,
ButtonPolicy * bp, char const * close, char const * cancel)
: lv_(lv), bc_(bp, cancel, close), d_(d), h_(0), r_(0), title(t),
bp_(bp), minw_(0), minh_(0)
{
Assert(lv && d && bp);
}
FormBase::~FormBase()
{
delete bp_;
}
FormBase::FormBase(ControlBase & c, string const & t)
: ViewBC<xformsBC>(c), minw_(0), minh_(0), title_(t)
{}
void FormBase::redraw()
@ -71,20 +35,6 @@ void FormBase::redraw()
}
void FormBase::connect()
{
fl_set_form_minsize(form(), minw_, minh_);
r_ = Dialogs::redrawGUI.connect(slot(this, &FormBase::redraw));
}
void FormBase::disconnect()
{
h_.disconnect();
r_.disconnect();
}
void FormBase::show()
{
if (!form()) {
@ -110,122 +60,72 @@ void FormBase::show()
XMapWindow(fl_get_display(), form()->window);
} else {
// calls to fl_set_form_minsize/maxsize apply only to the next
// fl_show_form(), so connect() comes first.
connect();
// fl_show_form(), so this comes first.
fl_set_form_minsize(form(), minw_, minh_);
fl_show_form(form(),
FL_PLACE_MOUSE | FL_FREE_SIZE, 0,
title.c_str());
title_.c_str());
}
}
void FormBase::hide()
{
if (form() && form()->visible) {
// some dialogs might do things to the form first
// such as the nested tabfolder problem in Preferences
disconnect();
if (form() && form()->visible)
fl_hide_form(form());
}
}
int FormBase::WMHideCB(FL_FORM * form, void *)
{
Assert(form);
// Ensure that the signals (u and h) are disconnected even if the
// window manager is used to close the dialog.
FormBase * pre = static_cast<FormBase*>(form->u_vdata);
Assert(pre);
pre->hide();
pre->bc_.hide();
return FL_CANCEL;
}
void FormBase::ApplyCB(FL_OBJECT * ob, long)
{
Assert(ob && ob->form);
FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);
Assert(pre);
pre->apply();
pre->bc_.apply();
}
void FormBase::OKCB(FL_OBJECT * ob, long)
{
Assert(ob && ob->form);
FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);
Assert(pre);
pre->ok();
pre->bc_.ok();
}
void FormBase::CancelCB(FL_OBJECT * ob, long)
{
Assert(ob && ob->form);
FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);
Assert(pre);
pre->cancel();
pre->bc_.cancel();
}
void FormBase::InputCB(FL_OBJECT * ob, long data)
{
Assert(ob && ob->form);
FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);
Assert(ob);
pre->bc_.valid(pre->input(ob, data), ob);
bc().input(input(ob, data));
}
void FormBase::RestoreCB(FL_OBJECT * ob, long)
static FormBase * GetForm(FL_OBJECT * ob)
{
Assert(ob && ob->form);
FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);
Assert(ob);
pre->bc_.undoAll();
pre->restore();
Assert(ob && ob->form && ob->form->u_vdata);
FormBase * pre = static_cast<FormBase *>(ob->form->u_vdata);
return pre;
}
FormBaseBI::FormBaseBI(LyXView * lv, Dialogs * d, string const & t,
ButtonPolicy * bp,
char const * close, char const * cancel)
: FormBase(lv, d, t, bp, close, cancel)
{}
void FormBaseBI::connect()
extern "C" int C_FormBaseWMHideCB(FL_FORM * form, void *)
{
h_ = d_->hideAll.connect(slot(this, &FormBaseBI::hide));
FormBase::connect();
// 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;
}
FormBaseBD::FormBaseBD(LyXView * lv, Dialogs * d, string const & t,
ButtonPolicy * bp,
char const * close, char const * cancel)
: FormBase(lv, d, t, bp, close, cancel),
u_(0)
{}
void FormBaseBD::connect()
extern "C" void C_FormBaseApplyCB(FL_OBJECT * ob, long)
{
u_ = d_->updateBufferDependent.
connect(slot(this, &FormBaseBD::updateSlot));
h_ = d_->hideBufferDependent.
connect(slot(this, &FormBaseBD::hide));
FormBase::connect();
GetForm(ob)->ApplyButton();
}
void FormBaseBD::disconnect()
extern "C" void C_FormBaseOKCB(FL_OBJECT * ob, long)
{
u_.disconnect();
FormBase::disconnect();
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

@ -7,160 +7,105 @@
* Copyright 2000 The LyX Team.
*
* ======================================================
*
* Author: Angus Leeming <a.leeming@ic.ac.uk>
*/
#ifndef FORMBASE_H
#define FORMBASE_H
#include "DialogBase.h"
#include "LString.h"
#include FORMS_H_LOCATION
#include "ButtonController.h"
#include "gettext.h"
#include <sigc++/signal_system.h>
class Buffer;
class Dialogs;
class LyXView;
#include <boost/smart_ptr.hpp>
#ifdef __GNUG__
#pragma interface
#endif
#include FORMS_H_LOCATION // Can't forward-declare FL_FORM
#include "ViewBase.h"
#include "LString.h"
#include "ButtonPolicies.h"
class xformsBC;
/** This class is an XForms GUI base class.
It is meant to be used solely as the parent class to FormBaseBI
and FormBaseBD.
@author Angus Leeming
*/
class FormBase : public DialogBase {
class FormBase : public ViewBC<xformsBC>
{
public:
/// Callback functions
static int WMHideCB(FL_FORM *, void *);
///
static void ApplyCB(FL_OBJECT *, long);
FormBase(ControlBase &, string const &);
///
static void OKCB(FL_OBJECT *, long);
///
static void CancelCB(FL_OBJECT *, long);
///
static void InputCB(FL_OBJECT *, long);
///
static void RestoreCB(FL_OBJECT *, long);
virtual ~FormBase() {}
protected: // methods
///
FormBase(LyXView *, Dialogs *, string const &,
ButtonPolicy *, char const *, char const *);
///
virtual ~FormBase();
/// input callback function
void InputCB(FL_OBJECT *, long);
/** Redraw the form (on receipt of a Signal indicating, for example,
that the xforms colors have been re-mapped).
Must be virtual because dialogs with tabbed folders will need to
redraw the form for each tab.
*/
virtual void redraw();
/// Create the dialog if necessary, update it and display it.
virtual void show();
/// Hide the dialog.
virtual void hide();
/// Update the dialog.
virtual void update() {}
/// Connect signals. Also perform any necessary initialisation.
virtual void connect();
/// Disconnect signals. Also perform any necessary housekeeping.
virtual void disconnect();
protected:
/// Build the dialog
virtual void build() = 0;
/** Filter the inputs on callback from xforms
Return true if inputs are valid.
*/
virtual bool input( FL_OBJECT *, long) {
return true;
}
/// Apply from dialog (modify or create inset)
virtual void apply() {}
/// OK from dialog
virtual void ok() {
apply();
hide();
}
/// Cancel from dialog
virtual void cancel() {
hide();
}
/// Restore from dialog
virtual void restore() {
update();
}
/// Pointer to the actual instantiation of the xforms form
virtual FL_FORM * form() const = 0;
/// Hide the dialog.
void hide();
/// Create the dialog if necessary, update it and display it.
void show();
/** 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_;
/// Useable even in derived-class's const functions.
mutable ButtonController bc_;
/// Used so we can get at the signals we have to connect to.
Dialogs * d_;
/// Hide connection.
Connection h_;
/// Redraw connection.
Connection r_;
/// dialog title, displayed by WM.
string title;
private:
///
ButtonPolicy * bp_;
public:
/// Pointer to the actual instantiation of xform's form
virtual FL_FORM * form() const = 0;
/** Filter the inputs on callback from xforms
Return true if inputs are valid. */
virtual ButtonPolicy::SMInput input(FL_OBJECT *, long) = 0;
/** Redraw the form (on receipt of a Signal indicating, for example,
that the xform colors have been re-mapped). */
virtual void redraw();
protected:
/// Overcome a dumb xforms sizing bug
mutable int minw_;
///
mutable int minh_;
private:
/// dialog title, displayed by WM.
string title_;
};
/** This class is an XForms GUI base class for Buffer Independent dialogs.
Such dialogs do not require an update Connection although they may use
an update() function which is also supported by restore().
*/
class FormBaseBI : public FormBase {
template <class Controller, class Dialog>
class FormBase2: public FormBase
{
protected:
/// Constructor
FormBaseBI(LyXView *, Dialogs *, string const &,
ButtonPolicy * bp,
char const * close = N_("Close"),
char const * cancel = N_("Cancel"));
/// Connect signals
virtual void connect();
///
FormBase2(ControlBase &, string const &);
/// The parent controller
Controller & controller() const;
/// Pointer to the actual instantiation of xform's form
virtual FL_FORM * form() const;
/// Real GUI implementation.
boost::scoped_ptr<Dialog> dialog_;
};
/** This class is an XForms GUI base class for Buffer Dependent dialogs
*/
class FormBaseBD : public FormBase {
protected:
/// Constructor
FormBaseBD(LyXView *, Dialogs *, string const &,
ButtonPolicy * bp,
char const * close = N_("Close"),
char const * cancel = N_("Cancel"));
/// Connect signals
virtual void connect();
/// Disconnect signals
virtual void disconnect();
/// bool indicates if a buffer switch took place
virtual void updateSlot(bool) { update(); }
/// Update connection.
Connection u_;
};
template <class Controller, class Dialog>
FormBase2<Controller, Dialog>::FormBase2(ControlBase & c, string const & t)
: FormBase(c, t)
{}
#endif
template <class Controller, class Dialog>
Controller & FormBase2<Controller, Dialog>::controller() const
{
return static_cast<Controller &>(controller_);
//return dynamic_cast<Controller &>(controller_);
}
template <class Controller, class Dialog>
FL_FORM * FormBase2<Controller, Dialog>::form() const
{
if (dialog_.get()) return dialog_->form;
return 0;
}
#endif // FORMBASE_H

View File

@ -0,0 +1,219 @@
// -*- C++ -*-
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 2000 The LyX Team.
*
* ======================================================
*/
#include <config.h>
#include FORMS_H_LOCATION
#ifdef __GNUG__
#pragma implementation
#endif
#include "Dialogs.h"
#include "FormBaseDeprecated.h"
#include "LyXView.h"
#include "support/LAssert.h"
#include "xformsBC.h"
//#include "debug.h"
extern "C" int C_FormBaseDeprecatedWMHideCB(FL_FORM * ob, void * d)
{
return FormBaseDeprecated::WMHideCB(ob, d);
}
extern "C" void C_FormBaseDeprecatedApplyCB(FL_OBJECT * ob, long d)
{
FormBaseDeprecated::ApplyCB(ob, d);
}
extern "C" void C_FormBaseDeprecatedOKCB(FL_OBJECT * ob, long d)
{
FormBaseDeprecated::OKCB(ob, d);
}
extern "C" void C_FormBaseDeprecatedCancelCB(FL_OBJECT * ob, long d)
{
FormBaseDeprecated::CancelCB(ob, d);
}
extern "C" void C_FormBaseDeprecatedInputCB(FL_OBJECT * ob, long d)
{
FormBaseDeprecated::InputCB(ob, d);
}
extern "C" void C_FormBaseDeprecatedRestoreCB(FL_OBJECT * ob, long d)
{
FormBaseDeprecated::RestoreCB(ob, d);
}
FormBaseDeprecated::FormBaseDeprecated(LyXView * lv, Dialogs * d,
string const & t)
: lv_(lv), d_(d), h_(0), r_(0), title(t), minw_(0), minh_(0)
{
Assert(lv && d);
}
void FormBaseDeprecated::redraw()
{
if (form() && form()->visible)
fl_redraw_form(form());
}
void FormBaseDeprecated::connect()
{
fl_set_form_minsize(form(), minw_, minh_);
r_ = Dialogs::redrawGUI.connect(slot(this,&FormBaseDeprecated::redraw));
}
void FormBaseDeprecated::disconnect()
{
h_.disconnect();
r_.disconnect();
}
void FormBaseDeprecated::show()
{
if (!form()) {
build();
fl_set_form_atclose(form(),
C_FormBaseDeprecatedWMHideCB, 0);
}
fl_freeze_form(form());
update(); // make sure its up-to-date
fl_unfreeze_form(form());
if (form()->visible) {
fl_raise_form(form());
} else {
// calls to fl_set_form_minsize/maxsize apply only to the next
// fl_show_form(), so connect() comes first.
connect();
fl_show_form(form(),
FL_PLACE_MOUSE | FL_FREE_SIZE,
FL_TRANSIENT,
title.c_str());
}
}
void FormBaseDeprecated::hide()
{
if (form() && form()->visible) {
// some dialogs might do things to the form first
// such as the nested tabfolder problem in Preferences
disconnect();
fl_hide_form(form());
}
}
int FormBaseDeprecated::WMHideCB(FL_FORM * form, void *)
{
Assert(form);
// Ensure that the signals (u and h) are disconnected even if the
// window manager is used to close the dialog.
FormBaseDeprecated * pre =
static_cast<FormBaseDeprecated*>(form->u_vdata);
Assert(pre);
pre->hide();
pre->bc().hide();
return FL_CANCEL;
}
void FormBaseDeprecated::ApplyCB(FL_OBJECT * ob, long)
{
Assert(ob && ob->form);
FormBaseDeprecated * pre =
static_cast<FormBaseDeprecated*>(ob->form->u_vdata);
Assert(pre);
pre->apply();
pre->bc().apply();
}
void FormBaseDeprecated::OKCB(FL_OBJECT * ob, long)
{
Assert(ob && ob->form);
FormBaseDeprecated * pre =
static_cast<FormBaseDeprecated*>(ob->form->u_vdata);
Assert(pre);
pre->ok();
pre->bc().ok();
}
void FormBaseDeprecated::CancelCB(FL_OBJECT * ob, long)
{
Assert(ob && ob->form);
FormBaseDeprecated * pre =
static_cast<FormBaseDeprecated*>(ob->form->u_vdata);
Assert(pre);
pre->cancel();
pre->bc().cancel();
}
void FormBaseDeprecated::InputCB(FL_OBJECT * ob, long data)
{
Assert(ob && ob->form);
FormBaseDeprecated * pre =
static_cast<FormBaseDeprecated*>(ob->form->u_vdata);
Assert(ob);
pre->bc().valid(pre->input(ob, data));
}
void FormBaseDeprecated::RestoreCB(FL_OBJECT * ob, long)
{
Assert(ob && ob->form);
FormBaseDeprecated * pre =
static_cast<FormBaseDeprecated*>(ob->form->u_vdata);
Assert(ob);
pre->bc().undoAll();
pre->restore();
}
FormBaseBI::FormBaseBI(LyXView * lv, Dialogs * d, string const & t)
: FormBaseDeprecated(lv, d, t)
{}
void FormBaseBI::connect()
{
h_ = d_->hideAll.connect(slot(this, &FormBaseBI::hide));
FormBaseDeprecated::connect();
}
FormBaseBD::FormBaseBD(LyXView * lv, Dialogs * d, string const & t)
: FormBaseDeprecated(lv, d, t),
u_(0)
{}
void FormBaseBD::connect()
{
u_ = d_->updateBufferDependent.
connect(slot(this, &FormBaseBD::updateSlot));
h_ = d_->hideBufferDependent.
connect(slot(this, &FormBaseBD::hide));
FormBaseDeprecated::connect();
}
void FormBaseBD::disconnect()
{
u_.disconnect();
FormBaseDeprecated::disconnect();
}

View File

@ -0,0 +1,158 @@
// -*- C++ -*-
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 2000 The LyX Team.
*
* ======================================================
*/
#ifndef FORMBASEDEPRECATED_H
#define FORMBASEDEPRECATED_H
#include "DialogBase.h"
#include "LString.h"
#include FORMS_H_LOCATION
#include <sigc++/signal_system.h>
class Buffer;
class Dialogs;
class LyXView;
class xformsBC;
#ifdef __GNUG__
#pragma interface
#endif
/** This class is an XForms GUI base class.
It is meant to be used solely as the parent class to FormBaseBI
and FormBaseBD.
It has now been superceeded by the Controller/View split.
See FormBase.[Ch] for the way to go!
@author Angus Leeming
*/
class FormBaseDeprecated : public DialogBase {
public:
/// Callback functions
static int WMHideCB(FL_FORM *, void *);
///
static void ApplyCB(FL_OBJECT *, long);
///
static void OKCB(FL_OBJECT *, long);
///
static void CancelCB(FL_OBJECT *, long);
///
static void InputCB(FL_OBJECT *, long);
///
static void RestoreCB(FL_OBJECT *, long);
protected: // methods
///
FormBaseDeprecated(LyXView *, Dialogs *, string const &);
///
virtual ~FormBaseDeprecated() {}
/// Pointer to the actual instantiation of the ButtonController.
virtual xformsBC & bc() = 0;
/** Redraw the form (on receipt of a Signal indicating, for example,
that the xform colors have been re-mapped).
Must be virtual because dialogs with tabbed folders will need to
redraw the form for each tab.
*/
virtual void redraw();
/// Create the dialog if necessary, update it and display it.
virtual void show();
/// Hide the dialog.
virtual void hide();
/// Update the dialog.
virtual void update() {}
/// Connect signals. Also perform any necessary initialisation.
virtual void connect();
/// Disconnect signals. Also perform any necessary housekeeping.
virtual void disconnect();
/// Build the dialog
virtual void build() = 0;
/** Filter the inputs on callback from xforms
Return true if inputs are valid.
*/
virtual bool input( FL_OBJECT *, long) {
return true;
}
/// Apply from dialog (modify or create inset)
virtual void apply() {}
/// OK from dialog
virtual void ok() {
apply();
hide();
}
/// Cancel from dialog
virtual void cancel() {
hide();
}
/// Restore from dialog
virtual void restore() {
update();
}
/// Pointer to the actual instantiation of xform's form
virtual FL_FORM * form() const = 0;
/** 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_;
/// Used so we can get at the signals we have to connect to.
Dialogs * d_;
/// Hide connection.
Connection h_;
/// Redraw connection.
Connection r_;
/// dialog title, displayed by WM.
string title;
public:
/// Overcome a dumb xforms sizing bug
mutable int minw_;
///
mutable int minh_;
};
/** This class is an XForms GUI base class for Buffer Independent dialogs.
Such dialogs do not require an update Connection although they may use
an update() function which is also supported by restore().
*/
class FormBaseBI : public FormBaseDeprecated {
protected:
/// Constructor
FormBaseBI(LyXView *, Dialogs *, string const &);
/// Connect signals
virtual void connect();
};
/** This class is an XForms GUI base class for Buffer Dependent dialogs
*/
class FormBaseBD : public FormBaseDeprecated {
protected:
/// Constructor
FormBaseBD(LyXView *, Dialogs *, string const &);
/// Connect signals
virtual void connect();
/// Disconnect signals
virtual void disconnect();
/// bool indicates if a buffer switch took place
virtual void updateSlot(bool) { update(); }
/// Update connection.
Connection u_;
};
#endif // FORMBASEDEPRECATED_H

View File

@ -7,120 +7,65 @@
* \author John Levon
*/
#include <config.h>
#include FORMS_H_LOCATION
#ifdef __GNUG__
#pragma implementation
#endif
#include "Dialogs.h"
#include <config.h>
#include "ControlBibitem.h"
#include "FormBibitem.h"
#include "LyXView.h"
#include "buffer.h"
#include "form_bibitem.h"
#include "lyxfunc.h"
#include "debug.h"
#include "gettext.h"
#include "xformsBC.h"
#include "support/lstrings.h" // compare
using std::endl;
FormBibitem::FormBibitem(ControlBibitem & c)
: FormBase2<ControlBibitem, FD_form_bibitem>(c, _("Bibliography Entry"))
{}
FormBibitem::FormBibitem(LyXView * lv, Dialogs * d)
: FormCommand(lv, d, _("Bibliography Entry"), new OkCancelReadOnlyPolicy),
dialog_(0)
{
d->showBibitem.connect(slot(this, &FormBibitem::showInset));
}
FormBibitem::~FormBibitem()
{
delete dialog_;
}
FL_FORM * FormBibitem::form() const
{
if (dialog_)
return dialog_->form;
return 0;
}
void FormBibitem::connect()
{
fl_set_form_maxsize(form(), 2 * minw_, minh_);
FormCommand::connect();
}
void FormBibitem::build()
{
dialog_ = build_bibitem();
dialog_.reset(build_bibitem());
// Workaround dumb xforms sizing bug
minw_ = form()->w;
minh_ = form()->h;
fl_set_input_return(dialog_->key, FL_RETURN_CHANGED);
fl_set_input_return(dialog_->key, FL_RETURN_CHANGED);
fl_set_input_return(dialog_->label, FL_RETURN_CHANGED);
// Manage the ok, apply, restore and cancel/close buttons
bc_.setOK(dialog_->button_ok);
bc_.setCancel(dialog_->button_cancel);
bc_.refresh();
bc().setOK(dialog_->button_ok);
bc().setCancel(dialog_->button_cancel);
bc().refresh();
bc_.addReadOnly(dialog_->key);
bc_.addReadOnly(dialog_->label);
bc().addReadOnly(dialog_->key);
bc().addReadOnly(dialog_->label);
}
bool FormBibitem::input(FL_OBJECT *, long)
ButtonPolicy::SMInput FormBibitem::input(FL_OBJECT *, long)
{
// minimal validation
if (!compare(fl_get_input(dialog_->key), ""))
return false;
return ButtonPolicy::SMI_NOOP;
return true;
return ButtonPolicy::SMI_VALID;
}
void FormBibitem::update()
{
fl_set_input(dialog_->key, params.getContents().c_str());
fl_set_input(dialog_->label, params.getOptions().c_str());
// Surely, this should reset the buttons to their original state?
// It doesn't. Instead "Restore" becomes a "Close"
//bc_.refresh();
bc_.readOnly(lv_->buffer()->isReadonly());
fl_set_input(dialog_->key,
controller().params().getContents().c_str());
fl_set_input(dialog_->label,
controller().params().getOptions().c_str());
}
void FormBibitem::apply()
{
if (lv_->buffer()->isReadonly())
return;
params.setContents(fl_get_input(dialog_->key));
params.setOptions(fl_get_input(dialog_->label));
if (inset_ != 0) {
// Only update if contents have changed
if (params != inset_->params()) {
// FIXME: confirm, is this only necessary for FormBibTeX ???
if (params.getContents() != inset_->params().getContents())
lv_->view()->ChangeCitationsIfUnique(
inset_->params().getContents(), params.getContents());
inset_->setParams(params);
lv_->view()->updateInset(inset_, true);
// We need to do a redraw because the maximum
// InsetBibKey width could have changed
lv_->view()->redraw();
lv_->view()->fitCursor(lv_->view()->getLyXText());
}
} else
lyxerr[Debug::GUI] << "Editing non-existent bibitem !" << endl;
controller().params().setContents(fl_get_input(dialog_->key));
controller().params().setOptions(fl_get_input(dialog_->label));
}

View File

@ -1,3 +1,4 @@
// -*- C++ -*-
/**
* \file FormBibitem.h
* Copyright 2001 the LyX Team
@ -14,35 +15,35 @@
#pragma interface
#endif
#include "FormInset.h"
struct FD_form_bibitem;
#include "FormBase.h"
/**
* For bibliography entry editing
*/
class FormBibitem : public FormCommand {
#include "form_bibitem.h"
class ControlBibitem;
class FormBibitem : public FormBase2<ControlBibitem, FD_form_bibitem> {
public:
///
FormBibitem(LyXView *, Dialogs *);
///
~FormBibitem();
private:
/// Connect signals etc. Set form's max size.
virtual void connect();
/// Build the dialog
virtual void build();
/// Update dialog before showing it
virtual void update();
/// input handler
virtual bool input(FL_OBJECT *,long);
/// Apply from dialog (modify or create inset)
FormBibitem(ControlBibitem &);
// Functions accessible to the Controller.
/// Set the Params variable for the Controller.
virtual void apply();
/// Pointer to the actual instantiation of the xforms form
virtual FL_FORM * form() const;
///
/// Build the dialog.
virtual void build();
/// Update dialog before/whilst showing it.
virtual void update();
private:
/// Filter the inputs on callback from xforms
virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
/// Type definition from the fdesign produced header file.
FD_form_bibitem * build_bibitem();
/// Real GUI implementation.
FD_form_bibitem * dialog_;
};
#endif // FORMBIBITEM_H

View File

@ -27,22 +27,15 @@
using std::endl;
FormBibtex::FormBibtex(LyXView * lv, Dialogs * d)
: FormCommand(lv, d, _("BibTeX Database"), new OkCancelReadOnlyPolicy),
dialog_(0)
: FormCommand(lv, d, _("BibTeX Database"))
{
d->showBibtex.connect(slot(this, &FormBibtex::showInset));
}
FormBibtex::~FormBibtex()
{
delete dialog_;
}
FL_FORM * FormBibtex::form() const
{
if (dialog_)
if (dialog_.get())
return dialog_->form;
return 0;
}
@ -57,7 +50,7 @@ void FormBibtex::connect()
void FormBibtex::build()
{
dialog_ = build_bibtex();
dialog_.reset(build_bibtex());
// Workaround dumb xforms sizing bug
minw_ = form()->w;
@ -67,12 +60,12 @@ void FormBibtex::build()
fl_set_input_return(dialog_->style, FL_RETURN_CHANGED);
// Manage the ok, apply, restore and cancel/close buttons
bc_.setOK(dialog_->button_ok);
bc_.setCancel(dialog_->button_cancel);
bc_.refresh();
bc().setOK(dialog_->button_ok);
bc().setCancel(dialog_->button_cancel);
bc().refresh();
bc_.addReadOnly(dialog_->database);
bc_.addReadOnly(dialog_->style);
bc().addReadOnly(dialog_->database);
bc().addReadOnly(dialog_->style);
}
@ -92,8 +85,8 @@ void FormBibtex::update()
fl_set_input(dialog_->style, params.getOptions().c_str());
// Surely, this should reset the buttons to their original state?
// It doesn't. Instead "Restore" becomes a "Close"
//bc_.refresh();
bc_.readOnly(lv_->buffer()->isReadonly());
//bc().refresh();
bc().readOnly(lv_->buffer()->isReadonly());
}

View File

@ -1,3 +1,4 @@
// -*- C++ -*-
/**
* \file FormBibtex.h
* Copyright 2001 the LyX Team
@ -10,11 +11,15 @@
#ifndef FORMBIBTEX_H
#define FORMBIBTEX_H
#include <boost/smart_ptr.hpp>
#include "FormInset.h"
#include "xformsBC.h"
#ifdef __GNUG__
#pragma interface
#endif
#include "FormInset.h"
struct FD_form_bibtex;
/**
@ -24,9 +29,9 @@ class FormBibtex : public FormCommand {
public:
///
FormBibtex(LyXView *, Dialogs *);
///
~FormBibtex();
private:
/// Pointer to the actual instantiation of the ButtonController.
virtual xformsBC & bc();
/// Connect signals etc. Set form's max size.
virtual void connect();
/// Build the dialog
@ -42,7 +47,15 @@ private:
///
FD_form_bibtex * build_bibtex();
/// Real GUI implementation.
FD_form_bibtex * dialog_;
boost::scoped_ptr<FD_form_bibtex> dialog_;
/// The ButtonController
ButtonController<OkCancelReadOnlyPolicy, xformsBC> bc_;
};
inline
xformsBC & FormBibtex::bc()
{
return bc_;
}
#endif // FORMBIBTEX_H

View File

@ -24,39 +24,34 @@ using SigC::slot;
#endif
FormBrowser::FormBrowser(LyXView * lv, Dialogs * d, const string & name)
: FormBaseBD(lv, d, name, new OkCancelPolicy),
dialog_(0)
{
}
: FormBaseBD(lv, d, name)
{}
FormBrowser::~FormBrowser()
{
delete dialog_;
}
void FormBrowser::build()
{
dialog_ = build_browser();
dialog_.reset(build_browser());
// Workaround dumb xforms sizing bug
minw_ = form()->w;
minh_ = form()->h;
// Manage the close button
bc_.setCancel(dialog_->button_close);
bc_.refresh();
bc().setCancel(dialog_->button_close);
bc().refresh();
}
FL_FORM * FormBrowser::form() const
{
if (dialog_)
if (dialog_.get())
return dialog_->form;
return 0;
}
void FormBrowser::update()
{
}
{}
bool FormBrowser::input(FL_OBJECT *, long)
{

View File

@ -9,7 +9,10 @@
#ifndef FORMBROWSER_H
#define FORMBROWSER_H
#include "FormBase.h"
#include <boost/smart_ptr.hpp>
#include "FormBaseDeprecated.h"
#include "xformsBC.h"
#ifdef __GNUG__
#pragma interface
@ -25,16 +28,16 @@ struct FD_form_browser;
*/
class FormBrowser : public FormBaseBD {
public:
///
FormBrowser(LyXView *, Dialogs *, const string &);
~FormBrowser();
protected:
/// Update the dialog.
virtual void update();
/// Real GUI implementation.
FD_form_browser * dialog_;
boost::scoped_ptr<FD_form_browser> dialog_;
/// Pointer to the actual instantiation of the ButtonController.
virtual xformsBC & bc();
private:
/// Pointer to the actual instantiation of the xforms form
virtual FL_FORM * form() const;
@ -45,6 +48,14 @@ private:
/// generated build function
FD_form_browser * build_browser();
/// The ButtonController
ButtonController<OkCancelPolicy, xformsBC> bc_;
};
inline
xformsBC & FormBrowser::bc()
{
return bc_;
}
#endif

View File

@ -8,12 +8,12 @@
#include <config.h>
#include FORMS_H_LOCATION
#ifdef __GNUG_
#pragma implementation
#endif
#include FORMS_H_LOCATION
#include "FormCharacter.h"
#include "form_character.h"
#include "bufferview_funcs.h"
@ -31,9 +31,7 @@ using Liason::setMinibuffer;
FormCharacter::FormCharacter(LyXView * lv, Dialogs * d)
: FormBaseBD(lv, d, _("Character Layout"),
new NoRepeatedApplyReadOnlyPolicy),
dialog_(0), combo_language2_(0)
: FormBaseBD(lv, d, _("Character Layout"))
{
// let the popup be shown
// This is a permanent connection so we won't bother
@ -44,17 +42,9 @@ FormCharacter::FormCharacter(LyXView * lv, Dialogs * d)
}
FormCharacter::~FormCharacter()
{
// This must be done before the deletion of the dialog.
delete combo_language2_;
delete dialog_;
}
FL_FORM * FormCharacter::form() const
{
if (dialog_)
if (dialog_.get())
return dialog_->form;
return 0;
}
@ -62,15 +52,15 @@ FL_FORM * FormCharacter::form() const
void FormCharacter::build()
{
dialog_ = build_character();
dialog_.reset(build_character());
// Workaround dumb xforms sizing bug
minw_ = form()->w;
minh_ = form()->h;
// Manage the ok, apply and cancel/close buttons
bc_.setApply(dialog_->button_apply);
bc_.setCancel(dialog_->button_close);
bc_.refresh();
bc_.addReadOnly (dialog_->check_toggle_all);
bc().setApply(dialog_->button_apply);
bc().setCancel(dialog_->button_close);
bc().refresh();
bc().addReadOnly (dialog_->check_toggle_all);
fl_addto_choice(dialog_->choice_family,
_(" No change %l| Roman | Sans Serif | Typewriter %l| Reset "));
@ -94,7 +84,7 @@ void FormCharacter::build()
// insert default language box manually
fl_addto_form(dialog_->form);
FL_OBJECT * ob = dialog_->choice_language;
combo_language2_ = new Combox(FL_COMBOX_DROPLIST);
combo_language2_.reset(new Combox(FL_COMBOX_DROPLIST));
combo_language2_->add(ob->x, ob->y, ob->w, ob->h, 250);
combo_language2_->shortcut("#L", 1);
fl_end_form();
@ -111,7 +101,7 @@ void FormCharacter::build()
void FormCharacter::apply()
{
if (!lv_->view()->available() || !dialog_)
if (!lv_->view()->available() || !dialog_.get())
return;
LyXFont font(LyXFont::ALL_IGNORE);
@ -213,8 +203,8 @@ void FormCharacter::apply()
void FormCharacter::update()
{
if (!dialog_)
if (!dialog_.get())
return;
bc_.readOnly(lv_->buffer()->isReadonly());
bc().readOnly(lv_->buffer()->isReadonly());
}

View File

@ -10,13 +10,15 @@
#ifndef FORM_CHARACTER_H
#define FORM_CHARACTER_H
#include "FormBase.h"
#include <boost/smart_ptr.hpp>
#include "FormBaseDeprecated.h"
#include "xformsBC.h"
#ifdef __GNUG_
#pragma interface
#endif
class LyXView;
class Dialogs;
class Combox;
@ -29,31 +31,42 @@ struct FD_form_character;
*/
class FormCharacter : public FormBaseBD {
public:
///
FormCharacter(LyXView *, Dialogs *);
///
~FormCharacter();
///
FormCharacter(LyXView *, Dialogs *);
private:
/// Build the popup
virtual void build();
/// Apply from popup
virtual void apply();
/// Update the popup.
virtual void update();
/// Pointer to the actual instantiation of the xforms form
virtual FL_FORM * form() const;
/// Pointer to the actual instantiation of the ButtonController.
virtual xformsBC & bc();
FD_form_character * build_character();
/// Real GUI implementation.
FD_form_character * dialog_;
/// Build the popup
virtual void build();
Combox * combo_language2_;
/// Apply from popup
virtual void apply();
/// Update the popup.
virtual void update();
/// Pointer to the actual instantiation of the xform's form
virtual FL_FORM * form() const;
///
FD_form_character * build_character();
/// Real GUI implementation.
boost::scoped_ptr<FD_form_character> dialog_;
///
boost::scoped_ptr<Combox> combo_language2_;
/// The ButtonController
ButtonController<NoRepeatedApplyReadOnlyPolicy, xformsBC> bc_;
};
inline
xformsBC & FormCharacter::bc()
{
return bc_;
}
#endif

View File

@ -9,22 +9,20 @@
* ======================================================
*/
#include <config.h>
#include <algorithm>
#ifdef __GNUG__
#pragma implementation
#endif
#include "Dialogs.h"
#include <config.h>
#include "ControlCitation.h"
#include "FormCitation.h"
#include "LyXView.h"
#include "buffer.h"
#include "form_citation.h"
#include "lyxfunc.h"
#include "support/filetools.h"
#include "gettext.h"
#include "support/lstrings.h"
#include "xforms_helpers.h"
#include "xformsBC.h"
using std::find;
using std::max;
@ -33,52 +31,33 @@ using std::pair;
using std::sort;
using std::vector;
FormCitation::FormCitation(ControlCitation & c)
: FormBase2<ControlCitation, FD_form_citation>(c, _("Citation"))
{}
FormCitation::FormCitation(LyXView * lv, Dialogs * d)
: FormCommand(lv, d, _("Citation"), new NoRepeatedApplyReadOnlyPolicy),
dialog_(0)
void FormCitation::apply()
{
// let the dialog be shown
// These are permanent connections so we won't bother
// storing a copy because we won't be disconnecting.
d->showCitation.connect(slot(this, &FormCitation::showInset));
d->createCitation.connect(slot(this, &FormCitation::createInset));
controller().params().setCmdName("cite");
controller().params().setContents(getStringFromVector(citekeys));
string const after = fl_get_input(dialog_->input_after);
controller().params().setOptions(after);
}
FormCitation::~FormCitation()
{
delete dialog_;
}
FL_FORM * FormCitation::form() const
{
if (dialog_) return dialog_->form;
return 0;
}
void FormCitation::connect()
{
//fl_set_form_maxsize(dialog_->form, 3*minw_, minh_);
FormCommand::connect();
}
void FormCitation::disconnect()
void FormCitation::hide()
{
citekeys.clear();
bibkeys.clear();
bibkeysInfo.clear();
FormCommand::disconnect();
FormBase::hide();
}
void FormCitation::build()
{
dialog_ = build_citation();
dialog_.reset(build_citation());
// Workaround dumb xforms sizing bug
minw_ = form()->w;
@ -87,51 +66,229 @@ void FormCitation::build()
fl_set_input_return(dialog_->input_after, FL_RETURN_CHANGED);
fl_set_input_return(dialog_->input_before, FL_RETURN_CHANGED);
fl_set_button(dialog_->button_search_type, 0);
fl_set_object_label(dialog_->button_search_type, _("Simple"));
// Manage the ok, apply, restore and cancel/close buttons
bc_.setOK(dialog_->button_ok);
bc_.setApply(dialog_->button_apply);
bc_.setCancel(dialog_->button_cancel);
bc_.setUndoAll(dialog_->button_restore);
bc_.refresh();
bc().setOK(dialog_->button_ok);
bc().setApply(dialog_->button_apply);
bc().setCancel(dialog_->button_cancel);
bc().setUndoAll(dialog_->button_restore);
bc().refresh();
bc_.addReadOnly(dialog_->button_add);
bc_.addReadOnly(dialog_->button_del);
bc_.addReadOnly(dialog_->button_up);
bc_.addReadOnly(dialog_->button_down);
bc_.addReadOnly(dialog_->input_before);
bc_.addReadOnly(dialog_->input_after);
bc().addReadOnly(dialog_->button_add);
bc().addReadOnly(dialog_->button_del);
bc().addReadOnly(dialog_->button_up);
bc().addReadOnly(dialog_->button_down);
bc().addReadOnly(dialog_->choice_style);
bc().addReadOnly(dialog_->input_before);
bc().addReadOnly(dialog_->input_after);
}
bc_.addDontTriggerChange(dialog_->browser_cite);
bc_.addDontTriggerChange(dialog_->browser_bib);
ButtonPolicy::SMInput FormCitation::input(FL_OBJECT * ob, long)
{
ButtonPolicy::SMInput activate = ButtonPolicy::SMI_NOOP;
if (ob == dialog_->browser_bib) {
fl_deselect_browser(dialog_->browser_cite);
unsigned int const sel = fl_get_browser(dialog_->browser_bib);
if (sel < 1 || sel > bibkeys.size())
return ButtonPolicy::SMI_NOOP;
// Put into browser_info the additional info associated with
// the selected browser_bib key
fl_clear_browser(dialog_->browser_info);
string const tmp = formatted( controller().
getBibkeyInfo(bibkeys[sel-1]),
dialog_->browser_info->w-10 );
fl_add_browser_line(dialog_->browser_info, tmp.c_str());
// Highlight the selected browser_bib key in browser_cite if
// present
vector<string>::const_iterator cit =
find(citekeys.begin(), citekeys.end(), bibkeys[sel-1]);
if (cit != citekeys.end()) {
int const n = int(cit - citekeys.begin());
fl_select_browser_line(dialog_->browser_cite, n+1);
fl_set_browser_topline(dialog_->browser_cite, n+1);
}
if (!controller().isReadonly()) {
if (cit != citekeys.end()) {
setBibButtons(OFF);
setCiteButtons(ON);
} else {
setBibButtons(ON);
setCiteButtons(OFF);
}
}
} else if (ob == dialog_->browser_cite) {
unsigned int const sel = fl_get_browser(dialog_->browser_cite);
if (sel < 1 || sel > citekeys.size())
return ButtonPolicy::SMI_NOOP;
if (!controller().isReadonly()) {
setBibButtons(OFF);
setCiteButtons(ON);
}
// Highlight the selected browser_cite key in browser_bib
vector<string>::const_iterator cit =
find(bibkeys.begin(), bibkeys.end(), citekeys[sel-1]);
if (cit != bibkeys.end()) {
int const n = int(cit - bibkeys.begin());
fl_select_browser_line(dialog_->browser_bib, n+1);
fl_set_browser_topline(dialog_->browser_bib, n+1);
// Put into browser_info the additional info associated
// with the selected browser_cite key
fl_clear_browser(dialog_->browser_info);
string const tmp =
formatted( controller().
getBibkeyInfo(bibkeys[n]),
dialog_->browser_info->w-10 );
fl_add_browser_line(dialog_->browser_info, tmp.c_str());
}
} else if (ob == dialog_->button_add) {
unsigned int const sel = fl_get_browser(dialog_->browser_bib);
if (sel < 1 || sel > bibkeys.size())
return ButtonPolicy::SMI_NOOP;
// Add the selected browser_bib key to browser_cite
fl_addto_browser(dialog_->browser_cite,
bibkeys[sel-1].c_str());
citekeys.push_back(bibkeys[sel-1]);
int const n = int(citekeys.size());
fl_select_browser_line(dialog_->browser_cite, n);
setBibButtons(OFF);
setCiteButtons(ON);
activate = ButtonPolicy::SMI_VALID;
} else if (ob == dialog_->button_del) {
unsigned int const sel = fl_get_browser(dialog_->browser_cite);
if (sel < 1 || sel > citekeys.size())
return ButtonPolicy::SMI_NOOP;
// Remove the selected key from browser_cite
fl_delete_browser_line(dialog_->browser_cite, sel) ;
citekeys.erase(citekeys.begin() + sel-1);
setBibButtons(ON);
setCiteButtons(OFF);
activate = ButtonPolicy::SMI_VALID;
} else if (ob == dialog_->button_up) {
unsigned int const sel = fl_get_browser(dialog_->browser_cite);
if (sel < 2 || sel > citekeys.size())
return ButtonPolicy::SMI_NOOP;
// Move the selected key up one line
vector<string>::iterator it = citekeys.begin() + sel-1;
string const tmp = *it;
fl_delete_browser_line(dialog_->browser_cite, sel);
citekeys.erase(it);
fl_insert_browser_line(dialog_->browser_cite, sel-1, tmp.c_str());
fl_select_browser_line(dialog_->browser_cite, sel-1);
citekeys.insert(it-1, tmp);
setCiteButtons(ON);
activate = ButtonPolicy::SMI_VALID;
} else if (ob == dialog_->button_down) {
unsigned int const sel = fl_get_browser(dialog_->browser_cite);
if (sel < 1 || sel > citekeys.size()-1)
return ButtonPolicy::SMI_NOOP;
// Move the selected key down one line
vector<string>::iterator it = citekeys.begin() + sel-1;
string const tmp = *it;
fl_delete_browser_line(dialog_->browser_cite, sel);
citekeys.erase(it);
fl_insert_browser_line(dialog_->browser_cite, sel+1, tmp.c_str());
fl_select_browser_line(dialog_->browser_cite, sel+1);
citekeys.insert(it+1, tmp);
setCiteButtons(ON);
activate = ButtonPolicy::SMI_VALID;
} else if (ob == dialog_->button_search_type) {
if (fl_get_button(dialog_->button_search_type))
fl_set_object_label(dialog_->button_search_type,
_("Regex"));
else
fl_set_object_label(dialog_->button_search_type,
_("Simple"));
return ButtonPolicy::SMI_NOOP;
} else if (ob == dialog_->button_previous ||
ob == dialog_->button_next) {
string const str = fl_get_input(dialog_->input_search);
ControlCitation::Direction const dir =
(ob == dialog_->button_previous) ?
ControlCitation::BACKWARD : ControlCitation::FORWARD;
ControlCitation::Search const type =
fl_get_button(dialog_->button_search_type) ?
ControlCitation::REGEX : ControlCitation::SIMPLE;
vector<string>::const_iterator start = bibkeys.begin();
unsigned int const sel = fl_get_browser(dialog_->browser_bib);
if (sel >= 1 && sel <= bibkeys.size())
start += sel-1;
// Find the NEXT instance...
if (dir == ControlCitation::FORWARD)
start += 1;
else
start -= 1;
vector<string>::const_iterator const cit =
searchKeys(controller(), bibkeys, str, start,
type, dir);
if (cit == bibkeys.end())
return ButtonPolicy::SMI_NOOP;
int const found = int(cit - bibkeys.begin()) + 1;
if (found == sel)
return ButtonPolicy::SMI_NOOP;
// Update the display
int const top = max(found-5, 1);
fl_set_browser_topline(dialog_->browser_bib, top);
fl_select_browser_line(dialog_->browser_bib, found);
input(dialog_->browser_bib, 0);
} else if (ob == dialog_->choice_style ||
ob == dialog_->input_before ||
ob == dialog_->input_after) {
activate = ButtonPolicy::SMI_VALID;
}
return activate;
}
void FormCitation::update()
{
bc_.readOnly(lv_->buffer()->isReadonly());
bibkeys.clear();
bibkeysInfo.clear();
vector<pair<string,string> > blist =
lv_->buffer()->getBibkeyList();
sort(blist.begin(), blist.end());
for (unsigned int i = 0; i < blist.size(); ++i) {
bibkeys.push_back(blist[i].first);
bibkeysInfo.push_back(blist[i].second);
}
blist.clear();
// Make the list of all available bibliography keys
bibkeys = controller().getBibkeys();
updateBrowser(dialog_->browser_bib, bibkeys);
// Ditto for the keys cited in this inset
citekeys.clear();
string tmp, keys(params.getContents());
keys = frontStrip(split(keys, tmp, ','));
while (!tmp.empty()) {
citekeys.push_back(tmp);
keys = frontStrip(split(keys, tmp, ','));
}
citekeys = getVectorFromString(controller().params().getContents());
updateBrowser(dialog_->browser_cite, citekeys);
// No keys have been selected yet, so...
@ -139,26 +296,27 @@ void FormCitation::update()
setBibButtons(OFF);
setCiteButtons(OFF);
int noKeys = static_cast<int>(max(bibkeys.size(), citekeys.size()));
int noKeys = int(max(bibkeys.size(), citekeys.size()));
// Place bounds, so that 4 <= noKeys <= 10
noKeys = max(4, min(10, noKeys));
// Re-size the form to accommodate the new browser size
int size = 20 * noKeys;
bool bibPresent = (bibkeys.size() > 0);
int const size = 20 * noKeys;
bool const bibPresent = (bibkeys.size() > 0);
setSize(size, bibPresent);
fl_set_input(dialog_->input_after, params.getOptions().c_str());
fl_set_input(dialog_->input_after,
controller().params().getOptions().c_str());
}
void FormCitation::updateBrowser(FL_OBJECT * browser,
vector<string> const & keys) const
vector<string> const & keys) const
{
fl_clear_browser(browser);
for (unsigned int i = 0; i < keys.size(); ++i)
for (vector<string>::size_type i = 0; i < keys.size(); ++i)
fl_add_browser_line(browser, keys[i].c_str());
}
@ -173,7 +331,6 @@ void FormCitation::setCiteButtons(State status) const
{
int const sel = fl_get_browser(dialog_->browser_cite);
int const maxline = fl_get_browser_maxline(dialog_->browser_cite);
bool const activate = (status == ON);
bool const activate_up = (activate && sel != 1);
bool const activate_down = (activate && sel != maxline);
@ -194,7 +351,8 @@ void FormCitation::setSize(int hbrsr, bool bibPresent) const
// so they are not changed by dynamic resizing
static int const dh1 = 30; // top of form to top of cite/bib brsrs;
// bottom of cite/bib brsrs to top of info;
// bottom of info to top next element;
// bottom of info to top search frame;
// bottom of search frame to top next elemnt;
// bottom of style to top input_before;
// bottom of text to top ok/cancel buttons.
static int const dh2 = 10; // bottom of input_before to top input_after;
@ -203,11 +361,12 @@ void FormCitation::setSize(int hbrsr, bool bibPresent) const
int const wbrsr = dialog_->browser_cite->w;
static int const hinfo = dialog_->browser_info->h;
static int const hframe = dialog_->frame_search->h;
static int const hstyle = dialog_->choice_style->h;
static int const htext = dialog_->input_after->h;
static int const hok = dialog_->button_ok->h;
int hform = dh1 + hbrsr + dh1;
int hform = dh1 + hbrsr + dh1 + hframe + dh1;
if (bibPresent) hform += hinfo + dh1;
if (natbib) hform += hstyle + dh1 + htext + dh2;
hform += htext + dh1 + hok + dh2;
@ -247,6 +406,30 @@ void FormCitation::setSize(int hbrsr, bool bibPresent) const
} else
fl_hide_object(dialog_->browser_info);
x = dialog_->frame_search->x;
// ??? The frame height seems to be reduced. Use geometry to enforce it.
fl_set_object_geometry(dialog_->frame_search, x, y,
dialog_->frame_search->w, hframe);
//fl_set_object_position(dialog_->frame_search, x, y);
x = dialog_->input_search->x;
y += 15;
fl_set_object_position(dialog_->input_search, x, y);
x = dialog_->button_previous->x;
y += dialog_->input_search->h + 5;
fl_set_object_position(dialog_->button_previous, x, y);
x = dialog_->button_next->x;
y += dialog_->button_previous->h + 5;
fl_set_object_position(dialog_->button_next, x, y);
x = dialog_->button_search_type->x;
y = dialog_->button_previous->y;
fl_set_object_position(dialog_->button_search_type, x, y);
y = dialog_->frame_search->y + hframe + dh1;
if (natbib) {
x = dialog_->choice_style->x;
fl_set_object_position(dialog_->choice_style, x, y);
@ -266,168 +449,11 @@ void FormCitation::setSize(int hbrsr, bool bibPresent) const
y += htext + dh1;
x = dialog_->button_restore->x;
fl_set_object_position(dialog_->button_restore, x, y);
fl_set_object_position(dialog_->button_restore, x, y);
x = dialog_->button_ok->x;
fl_set_object_position(dialog_->button_ok, x, y);
fl_set_object_position(dialog_->button_ok, x, y);
x = dialog_->button_apply->x;
fl_set_object_position(dialog_->button_apply, x, y);
fl_set_object_position(dialog_->button_apply, x, y);
x = dialog_->button_cancel->x;
fl_set_object_position(dialog_->button_cancel, x, y);
}
bool FormCitation::input(FL_OBJECT * ob, long)
{
bool activate = false;
if (ob == dialog_->browser_bib) {
fl_deselect_browser(dialog_->browser_cite);
unsigned int sel = fl_get_browser(dialog_->browser_bib);
if (sel < 1 || sel > bibkeys.size()) return false;
// Put into browser_info the additional info associated with
// the selected browser_bib key
fl_clear_browser(dialog_->browser_info);
fl_add_browser_line(dialog_->browser_info,
bibkeysInfo[sel - 1].c_str());
// Highlight the selected browser_bib key in browser_cite if present
vector<string>::iterator it =
find(citekeys.begin(), citekeys.end(), bibkeys[sel-1]);
if (it != citekeys.end()) {
int n = static_cast<int>(it - citekeys.begin());
fl_select_browser_line(dialog_->browser_cite, n+1);
fl_set_browser_topline(dialog_->browser_cite, n+1);
}
if (!lv_->buffer()->isReadonly()) {
if (it != citekeys.end()) {
setBibButtons(OFF);
setCiteButtons(ON);
} else {
setBibButtons(ON);
setCiteButtons(OFF);
}
}
} else if (ob == dialog_->browser_cite) {
unsigned int sel = fl_get_browser(dialog_->browser_cite);
if (sel < 1 || sel > citekeys.size()) return false;
if (!lv_->buffer()->isReadonly()) {
setBibButtons(OFF);
setCiteButtons(ON);
}
// Highlight the selected browser_cite key in browser_bib
vector<string>::iterator it =
find(bibkeys.begin(), bibkeys.end(), citekeys[sel-1]);
if (it != bibkeys.end()) {
int n = static_cast<int>(it - bibkeys.begin());
fl_select_browser_line(dialog_->browser_bib, n+1);
fl_set_browser_topline(dialog_->browser_bib, n+1);
// Put into browser_info the additional info associated with
// the selected browser_cite key
fl_clear_browser(dialog_->browser_info);
fl_add_browser_line(dialog_->browser_info,
bibkeysInfo[n].c_str());
}
} else if (ob == dialog_->button_add) {
unsigned int sel = fl_get_browser(dialog_->browser_bib);
if (sel < 1 || sel > bibkeys.size()) return false;
// Add the selected browser_bib key to browser_cite
fl_addto_browser(dialog_->browser_cite,
bibkeys[sel-1].c_str());
citekeys.push_back(bibkeys[sel-1]);
int n = static_cast<int>(citekeys.size());
fl_select_browser_line(dialog_->browser_cite, n);
setBibButtons(OFF);
setCiteButtons(ON);
activate = true;
} else if (ob == dialog_->button_del) {
unsigned int sel = fl_get_browser(dialog_->browser_cite);
if (sel < 1 || sel > citekeys.size()) return false;
// Remove the selected key from browser_cite
fl_delete_browser_line(dialog_->browser_cite, sel) ;
citekeys.erase(citekeys.begin() + sel-1);
setBibButtons(ON);
setCiteButtons(OFF);
activate = true;
} else if (ob == dialog_->button_up) {
unsigned int sel = fl_get_browser(dialog_->browser_cite);
if (sel < 2 || sel > citekeys.size()) return false;
// Move the selected key up one line
vector<string>::iterator it = citekeys.begin() + sel-1;
string tmp = *it;
fl_delete_browser_line(dialog_->browser_cite, sel);
citekeys.erase(it);
fl_insert_browser_line(dialog_->browser_cite, sel-1, tmp.c_str());
fl_select_browser_line(dialog_->browser_cite, sel-1);
citekeys.insert(it-1, tmp);
setCiteButtons(ON);
activate = true;
} else if (ob == dialog_->button_down) {
unsigned int sel = fl_get_browser(dialog_->browser_cite);
if (sel < 1 || sel > citekeys.size()-1) return false;
// Move the selected key down one line
vector<string>::iterator it = citekeys.begin() + sel-1;
string tmp = *it;
fl_delete_browser_line(dialog_->browser_cite, sel);
citekeys.erase(it);
fl_insert_browser_line(dialog_->browser_cite, sel+1, tmp.c_str());
fl_select_browser_line(dialog_->browser_cite, sel+1);
citekeys.insert(it+1, tmp);
setCiteButtons(ON);
activate = true;
} else if (ob == dialog_->choice_style ||
ob == dialog_->input_before ||
ob == dialog_->input_after) {
activate = true;
}
return activate;
}
void FormCitation::apply()
{
if (lv_->buffer()->isReadonly()) return;
string contents;
for (unsigned int i = 0; i < citekeys.size(); ++i) {
if (i > 0) contents += ",";
contents += citekeys[i];
}
params.setContents(contents);
params.setOptions(fl_get_input(dialog_->input_after));
if (inset_ != 0) {
// Only update if contents have changed
if (params != inset_->params()) {
inset_->setParams(params);
lv_->view()->updateInset(inset_, true);
}
} else {
lv_->getLyXFunc()->Dispatch(LFUN_CITATION_INSERT,
params.getAsString());
}
}

View File

@ -7,6 +7,8 @@
* Copyright 2000 The LyX Team.
*
* ======================================================
*
* Author: Angus Leeming <a.leeming@ic.ac.uk>
*/
#ifndef FORMCITATION_H
@ -16,39 +18,43 @@
#pragma interface
#endif
#include "FormInset.h"
struct FD_form_citation;
#include "FormBase.h"
/** This class provides an XForms implementation of the FormCitation Dialog.
/** This class provides an XForms implementation of the Citation Dialog.
*/
class FormCitation : public FormCommand {
#include "form_citation.h"
class ControlCitation;
class FormCitation : public FormBase2<ControlCitation, FD_form_citation> {
public:
///
FormCitation(LyXView *, Dialogs *);
///
~FormCitation();
FormCitation(ControlCitation &);
// Functions accessible to the Controller.
/// Set the Params variable for the Controller.
virtual void apply();
/// Build the dialog.
virtual void build();
/// Hide the dialog.
virtual void hide();
/// Update dialog before/whilst showing it.
virtual void update();
private:
///
enum State {
///
ON,
///
OFF
};
/// Connect signals etc. Set form's max size.
virtual void connect();
/// Disconnect signals. Also perform any necessary housekeeping.
virtual void disconnect();
/// Build the dialog
virtual void build();
/// Filter the inputs
virtual bool input(FL_OBJECT *, long);
/// Update dialog before showing it
virtual void update();
/// Apply from dialog (modify or create inset)
virtual void apply();
/// Pointer to the actual instantiation of the xforms form
virtual FL_FORM * form() const;
/// Filter the inputs on callback from xforms
virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
/// Type definition from the fdesign produced header file.
FD_form_citation * build_citation();
///
void updateBrowser(FL_OBJECT *, std::vector<string> const &) const;
@ -58,17 +64,11 @@ private:
void setCiteButtons(State) const;
///
void setSize(int, bool) const;
/// Type definition from the fdesign produced header file.
FD_form_citation * build_citation();
/// Real GUI implementation.
FD_form_citation * dialog_;
///
std::vector<string> citekeys;
///
std::vector<string> bibkeys;
///
std::vector<string> bibkeysInfo;
};
#endif
#endif // FORMCITATION_H

View File

@ -17,8 +17,7 @@
#include "xforms_helpers.h"
FormCopyright::FormCopyright( LyXView * lv, Dialogs * d )
: FormBaseBI(lv, d, _("Copyright and Warranty"), new OkCancelPolicy),
dialog_(0)
: FormBaseBI(lv, d, _("Copyright and Warranty"))
{
// let the dialog be shown
// This is a permanent connection so we won't bother
@ -27,22 +26,16 @@ FormCopyright::FormCopyright( LyXView * lv, Dialogs * d )
}
FormCopyright::~FormCopyright()
{
delete dialog_;
}
FL_FORM * FormCopyright::form() const
{
if (dialog_ ) return dialog_->form;
if (dialog_.get()) return dialog_->form;
return 0;
}
void FormCopyright::build()
{
dialog_ = build_copyright();
dialog_.reset(build_copyright());
// Workaround dumb xforms sizing bug
minw_ = form()->w;
@ -64,6 +57,6 @@ void FormCopyright::build()
fl_set_object_label(dialog_->text_disclaimer, str.c_str());
// Manage the cancel/close button
bc_.setCancel(dialog_->button_cancel);
bc_.refresh();
bc().setCancel(dialog_->button_cancel);
bc().refresh();
}

View File

@ -17,12 +17,15 @@
#ifndef FORMCOPYRIGHT_H
#define FORMCOPYRIGHT_H
#include "FormBase.h"
#include <boost/smart_ptr.hpp>
#ifdef __GNUG__
#pragma interface
#endif
#include "FormBaseDeprecated.h"
#include "xformsBC.h"
struct FD_form_copyright;
/** This class provides an XForms implementation of the FormCopyright Dialog.
@ -31,10 +34,9 @@ class FormCopyright : public FormBaseBI {
public:
/// #FormCopyright x(LyXFunc ..., Dialogs ...);#
FormCopyright(LyXView *, Dialogs *);
///
~FormCopyright();
private:
/// Pointer to the actual instantiation of the ButtonController.
virtual xformsBC & bc();
/// Build the dialog
virtual void build();
/// Pointer to the actual instantiation of the xforms form
@ -43,8 +45,16 @@ private:
FD_form_copyright * build_copyright();
/// Real GUI implementation.
FD_form_copyright * dialog_;
boost::scoped_ptr<FD_form_copyright> dialog_;
/// The ButtonController
ButtonController<OkCancelPolicy, xformsBC> bc_;
};
inline
xformsBC & FormCopyright::bc()
{
return bc_;
}
#endif

View File

@ -22,7 +22,7 @@
#include "support/filetools.h"
FormCredits::FormCredits( LyXView * lv, Dialogs * d )
: FormBaseBI(lv, d, _("Credits"), new OkCancelPolicy), dialog_(0)
: FormBaseBI(lv, d, _("Credits"))
{
// let the dialog be shown
// This is a permanent connection so we won't bother
@ -31,16 +31,10 @@ FormCredits::FormCredits( LyXView * lv, Dialogs * d )
}
FormCredits::~FormCredits()
{
delete dialog_;
}
FL_FORM * FormCredits::form() const
{
if (dialog_ )
return dialog_->form;
if (dialog_.get())
return dialog_->form;
return 0;
}
@ -49,7 +43,7 @@ extern string system_lyxdir;
void FormCredits::build()
{
dialog_ = build_credits();
dialog_.reset(build_credits());
// Workaround dumb xforms sizing bug
minw_ = form()->w;

View File

@ -9,12 +9,15 @@
#ifndef FORMCREDITS_H
#define FORMCREDITS_H
#include "FormBase.h"
#include <boost/smart_ptr.hpp>
#ifdef __GNUG__
#pragma interface
#endif
#include "FormBaseDeprecated.h"
#include "xformsBC.h"
struct FD_form_credits;
/** This class provides an XForms implementation of the FormCredits Dialog.
@ -23,10 +26,10 @@ class FormCredits : public FormBaseBI {
public:
/// #FormCopyright x(LyXFunc ..., Dialogs ...);#
FormCredits(LyXView *, Dialogs *);
///
~FormCredits();
private:
/// Pointer to the actual instantiation of the ButtonController.
virtual xformsBC & bc();
/// Build the dialog
virtual void build();
/// Pointer to the actual instantiation of the xforms form
@ -35,8 +38,16 @@ private:
FD_form_credits * build_credits();
/// Real GUI implementation.
FD_form_credits * dialog_;
boost::scoped_ptr<FD_form_credits> dialog_;
/// The ButtonController
ButtonController<OkCancelPolicy, xformsBC> bc_;
};
inline
xformsBC & FormCredits::bc()
{
return bc_;
}
#endif

View File

@ -11,13 +11,14 @@
#include <config.h>
#include FORMS_H_LOCATION
#include XPM_H_LOCATION
#ifdef __GNUG_
#pragma implementation
#endif
#include "lyx_gui_misc.h"
#include FORMS_H_LOCATION
#include XPM_H_LOCATION
#include "FormDocument.h"
#include "form_document.h"
@ -46,11 +47,7 @@ using Liason::setMinibuffer;
#define USE_CLASS_COMBO 1
FormDocument::FormDocument(LyXView * lv, Dialogs * d)
: FormBaseBD(lv, d, _("Document Layout"),
new NoRepeatedApplyReadOnlyPolicy),
dialog_(0), paper_(0), class_(0), language_(0), options_(0),
bullets_(0), current_bullet_panel(0), current_bullet_depth(0),
fbullet(0), combo_language(0), combo_doc_class(0)
: FormBaseBD(lv, d, _("Document Layout")), fbullet(0)
{
// let the popup be shown
// This is a permanent connection so we won't bother
@ -59,21 +56,6 @@ FormDocument::FormDocument(LyXView * lv, Dialogs * d)
}
FormDocument::~FormDocument()
{
#ifdef USE_CLASS_COMBO
delete combo_doc_class;
#endif
delete class_;
delete paper_;
delete combo_language;
delete language_;
delete options_;
delete bullets_;
delete dialog_;
}
void FormDocument::redraw()
{
if( form() && form()->visible )
@ -89,7 +71,7 @@ void FormDocument::redraw()
FL_FORM * FormDocument::form() const
{
if (dialog_) return dialog_->form;
if (dialog_.get()) return dialog_->form;
return 0;
}
@ -99,21 +81,21 @@ void FormDocument::build()
int n;
// the tabbed folder
dialog_ = build_tabbed_document();
dialog_.reset(build_tabbed_document());
// Manage the restore, ok, apply, restore and cancel/close buttons
bc_.setOK(dialog_->button_ok);
bc_.setApply(dialog_->button_apply);
bc_.setCancel(dialog_->button_cancel);
bc_.setUndoAll(dialog_->button_restore);
bc_.refresh();
bc().setOK(dialog_->button_ok);
bc().setApply(dialog_->button_apply);
bc().setCancel(dialog_->button_cancel);
bc().setUndoAll(dialog_->button_restore);
bc().refresh();
// Workaround dumb xforms sizing bug
minw_ = form()->w;
minh_ = form()->h;
// the document paper form
paper_ = build_doc_paper();
paper_.reset(build_doc_paper());
fl_addto_choice(paper_->choice_papersize2,
_(" Default | Custom | USletter | USlegal "
"| USexecutive | A3 | A4 | A5 | B3 | B4 | B5 "));
@ -132,24 +114,24 @@ void FormDocument::build()
fl_set_input_return(paper_->input_head_sep, FL_RETURN_CHANGED);
fl_set_input_return(paper_->input_foot_skip, FL_RETURN_CHANGED);
bc_.addReadOnly (paper_->choice_paperpackage);
bc_.addReadOnly (paper_->greoup_radio_orientation);
bc_.addReadOnly (paper_->radio_portrait);
bc_.addReadOnly (paper_->radio_landscape);
bc_.addReadOnly (paper_->choice_papersize2);
bc_.addReadOnly (paper_->push_use_geometry);
bc_.addReadOnly (paper_->input_custom_width);
bc_.addReadOnly (paper_->input_custom_height);
bc_.addReadOnly (paper_->input_top_margin);
bc_.addReadOnly (paper_->input_bottom_margin);
bc_.addReadOnly (paper_->input_left_margin);
bc_.addReadOnly (paper_->input_right_margin);
bc_.addReadOnly (paper_->input_head_height);
bc_.addReadOnly (paper_->input_head_sep);
bc_.addReadOnly (paper_->input_foot_skip);
bc().addReadOnly (paper_->choice_paperpackage);
bc().addReadOnly (paper_->greoup_radio_orientation);
bc().addReadOnly (paper_->radio_portrait);
bc().addReadOnly (paper_->radio_landscape);
bc().addReadOnly (paper_->choice_papersize2);
bc().addReadOnly (paper_->push_use_geometry);
bc().addReadOnly (paper_->input_custom_width);
bc().addReadOnly (paper_->input_custom_height);
bc().addReadOnly (paper_->input_top_margin);
bc().addReadOnly (paper_->input_bottom_margin);
bc().addReadOnly (paper_->input_left_margin);
bc().addReadOnly (paper_->input_right_margin);
bc().addReadOnly (paper_->input_head_height);
bc().addReadOnly (paper_->input_head_sep);
bc().addReadOnly (paper_->input_foot_skip);
// the document class form
class_ = build_doc_class();
class_.reset(build_doc_class());
FL_OBJECT * obj;
#ifdef USE_CLASS_COMBO
@ -157,7 +139,7 @@ void FormDocument::build()
obj = class_->choice_doc_class;
fl_deactivate_object(obj);
fl_addto_form(class_->form);
combo_doc_class = new Combox(FL_COMBOX_DROPLIST);
combo_doc_class.reset(new Combox(FL_COMBOX_DROPLIST));
combo_doc_class->add(obj->x, obj->y, obj->w, obj->h, 400,
dialog_->tabbed_folder);
combo_doc_class->shortcut("#C",1);
@ -190,26 +172,26 @@ void FormDocument::build()
fl_set_input_return(class_->input_doc_skip, FL_RETURN_CHANGED);
fl_set_input_return(class_->input_doc_spacing, FL_RETURN_CHANGED);
bc_.addReadOnly (class_->radio_doc_indent);
bc_.addReadOnly (class_->radio_doc_skip);
bc().addReadOnly (class_->radio_doc_indent);
bc().addReadOnly (class_->radio_doc_skip);
#ifndef USE_CLASS_COMBO
bc_.addReadOnly (class_->choice_doc_class);
bc().addReadOnly (class_->choice_doc_class);
#endif
bc_.addReadOnly (class_->choice_doc_pagestyle);
bc_.addReadOnly (class_->choice_doc_fonts);
bc_.addReadOnly (class_->choice_doc_fontsize);
bc_.addReadOnly (class_->radio_doc_sides_one);
bc_.addReadOnly (class_->radio_doc_sides_two);
bc_.addReadOnly (class_->radio_doc_columns_one);
bc_.addReadOnly (class_->radio_doc_columns_two);
bc_.addReadOnly (class_->input_doc_extra);
bc_.addReadOnly (class_->input_doc_skip);
bc_.addReadOnly (class_->choice_doc_skip);
bc_.addReadOnly (class_->choice_doc_spacing);
bc_.addReadOnly (class_->input_doc_spacing);
bc().addReadOnly (class_->choice_doc_pagestyle);
bc().addReadOnly (class_->choice_doc_fonts);
bc().addReadOnly (class_->choice_doc_fontsize);
bc().addReadOnly (class_->radio_doc_sides_one);
bc().addReadOnly (class_->radio_doc_sides_two);
bc().addReadOnly (class_->radio_doc_columns_one);
bc().addReadOnly (class_->radio_doc_columns_two);
bc().addReadOnly (class_->input_doc_extra);
bc().addReadOnly (class_->input_doc_skip);
bc().addReadOnly (class_->choice_doc_skip);
bc().addReadOnly (class_->choice_doc_spacing);
bc().addReadOnly (class_->input_doc_spacing);
// the document language form
language_ = build_doc_language();
language_.reset(build_doc_language());
fl_addto_choice(language_->choice_inputenc,
"default|auto|latin1|latin2|latin5"
"|koi8-r|koi8-u|cp866|cp1251|iso88595");
@ -218,7 +200,7 @@ void FormDocument::build()
obj = language_->choice_language;
fl_deactivate_object(obj);
fl_addto_form(language_->form);
combo_language = new Combox(FL_COMBOX_DROPLIST);
combo_language.reset(new Combox(FL_COMBOX_DROPLIST));
combo_language->add(obj->x, obj->y, obj->w, obj->h, 400,
dialog_->tabbed_folder);
combo_language->shortcut("#L",1);
@ -234,10 +216,10 @@ void FormDocument::build()
_(" ``text'' | ''text'' | ,,text`` | ,,text'' |"
" «text» | »text« "));
bc_.addReadOnly (language_->choice_inputenc);
bc().addReadOnly (language_->choice_inputenc);
// the document options form
options_ = build_doc_options();
options_.reset(build_doc_options());
fl_set_input_return(options_->input_float_placement, FL_RETURN_CHANGED);
fl_set_counter_bounds(options_->slider_secnumdepth,-2,5);
fl_set_counter_bounds(options_->slider_tocdepth,-1,5);
@ -249,14 +231,14 @@ void FormDocument::build()
fl_addto_choice(options_->choice_postscript_driver, tex_graphics[n]);
}
bc_.addReadOnly (options_->slider_secnumdepth);
bc_.addReadOnly (options_->slider_tocdepth);
bc_.addReadOnly (options_->check_use_amsmath);
bc_.addReadOnly (options_->input_float_placement);
bc_.addReadOnly (options_->choice_postscript_driver);
bc().addReadOnly (options_->slider_secnumdepth);
bc().addReadOnly (options_->slider_tocdepth);
bc().addReadOnly (options_->check_use_amsmath);
bc().addReadOnly (options_->input_float_placement);
bc().addReadOnly (options_->choice_postscript_driver);
// the document bullets form
bullets_ = build_doc_bullet();
bullets_.reset(build_doc_bullet());
fl_addto_choice(bullets_->choice_bullet_size,
_(" default | tiny | script | footnote | small |"
" normal | large | Large | LARGE | huge | Huge"));
@ -264,9 +246,9 @@ void FormDocument::build()
fl_set_input_return(bullets_->input_bullet_latex, FL_RETURN_CHANGED);
fl_set_input_maxchars(bullets_->input_bullet_latex, 80);
bc_.addReadOnly (bullets_->bmtable_bullet_panel);
bc_.addReadOnly (bullets_->choice_bullet_size);
bc_.addReadOnly (bullets_->input_bullet_latex);
bc().addReadOnly (bullets_->bmtable_bullet_panel);
bc().addReadOnly (bullets_->choice_bullet_size);
bc().addReadOnly (bullets_->input_bullet_latex);
fl_addto_tabfolder(dialog_->tabbed_folder,_("Document"),
class_->form);
@ -290,7 +272,7 @@ void FormDocument::build()
void FormDocument::apply()
{
if (!lv_->view()->available() || !dialog_)
if (!lv_->view()->available() || !dialog_.get())
return;
bool redo = class_apply();
@ -321,7 +303,7 @@ void FormDocument::cancel()
void FormDocument::update()
{
if (!dialog_)
if (!dialog_.get())
return;
checkReadOnly();
@ -389,9 +371,9 @@ bool FormDocument::input( FL_OBJECT * ob, long data )
void FormDocument::ComboInputCB(int, void * v, Combox * combox)
{
FormDocument * pre = static_cast<FormDocument*>(v);
if (combox == pre->combo_doc_class)
if (combox == pre->combo_doc_class.get())
pre->CheckChoiceClass(0, 0);
pre->bc_.valid(pre->CheckDocumentInput(0,0));
pre->bc().valid(pre->CheckDocumentInput(0,0));
}
@ -637,7 +619,7 @@ void FormDocument::bullets_apply()
void FormDocument::class_update(BufferParams const & params)
{
if (!class_)
if (!class_.get())
return;
LyXTextClass const & tclass = textclasslist.TextClass(params.textclass);
@ -732,7 +714,7 @@ void FormDocument::class_update(BufferParams const & params)
void FormDocument::language_update(BufferParams const & params)
{
if (!language_)
if (!language_.get())
return;
combo_language->select_text(params.language->lang());
@ -749,7 +731,7 @@ void FormDocument::language_update(BufferParams const & params)
void FormDocument::options_update(BufferParams const & params)
{
if (!options_)
if (!options_.get())
return;
fl_set_choice_text(options_->choice_postscript_driver,
@ -767,7 +749,7 @@ void FormDocument::options_update(BufferParams const & params)
void FormDocument::paper_update(BufferParams const & params)
{
if (!paper_)
if (!paper_.get())
return;
fl_set_choice(paper_->choice_papersize2, params.papersize2 + 1);
@ -794,7 +776,7 @@ void FormDocument::paper_update(BufferParams const & params)
void FormDocument::bullets_update(BufferParams const & params)
{
if (!bullets_ || ((XpmVersion<4) || (XpmVersion==4 && XpmRevision<7)))
if (!bullets_.get() || ((XpmVersion<4) || (XpmVersion==4 && XpmRevision<7)))
return;
bool const isLinuxDoc = lv_->buffer()->isLinuxDoc();
@ -812,7 +794,7 @@ void FormDocument::bullets_update(BufferParams const & params)
void FormDocument::checkReadOnly()
{
if (bc_.readOnly(lv_->buffer()->isReadonly())) {
if (bc().readOnly(lv_->buffer()->isReadonly())) {
combo_doc_class->deactivate();
combo_language->deactivate();
fl_set_object_label(dialog_->text_warning,
@ -1114,7 +1096,7 @@ void FormDocument::CheckChoiceClass(FL_OBJECT * ob, long)
void FormDocument::UpdateLayoutDocument(BufferParams const & params)
{
if (!dialog_)
if (!dialog_.get())
return;
checkReadOnly();

View File

@ -13,8 +13,10 @@
#ifndef FORM_DOCUMENT_H
#define FORM_DOCUMENT_H
#include "FormBase.h"
#include <vector>
#include <boost/smart_ptr.hpp>
#include "FormBaseDeprecated.h"
#include "xformsBC.h"
#ifdef __GNUG_
#pragma interface
@ -41,10 +43,7 @@ public:
/// #FormDocument x(Communicator ..., Popups ...);#
FormDocument(LyXView *, Dialogs *);
///
~FormDocument();
///
static void ComboInputCB(int, void *, Combox *);
private:
///
enum State {
@ -79,6 +78,8 @@ private:
///
BULLETBMTABLE
};
/// Pointer to the actual instantiation of the ButtonController.
virtual xformsBC & bc();
/** Redraw the form (on receipt of a Signal indicating, for example,
that the xforms colours have been re-mapped). */
virtual void redraw();
@ -153,17 +154,17 @@ private:
FD_form_doc_bullet * build_doc_bullet();
/// Real GUI implementation.
FD_form_tabbed_document * dialog_;
boost::scoped_ptr<FD_form_tabbed_document> dialog_;
///
FD_form_doc_paper * paper_;
boost::scoped_ptr<FD_form_doc_paper> paper_;
///
FD_form_doc_class * class_;
boost::scoped_ptr<FD_form_doc_class> class_;
///
FD_form_doc_language * language_;
boost::scoped_ptr<FD_form_doc_language> language_;
///
FD_form_doc_options * options_;
boost::scoped_ptr<FD_form_doc_options> options_;
///
FD_form_doc_bullet * bullets_;
boost::scoped_ptr<FD_form_doc_bullet> bullets_;
///
int ActCell;
///
@ -175,9 +176,18 @@ private:
///
FL_OBJECT * fbullet;
///
Combox * combo_language;
boost::scoped_ptr<Combox> combo_language;
///
Combox * combo_doc_class;
boost::scoped_ptr<Combox> combo_doc_class;
/// The ButtonController
ButtonController<NoRepeatedApplyReadOnlyPolicy, xformsBC> bc_;
};
inline
xformsBC & FormDocument::bc()
{
return bc_;
}
#endif

View File

@ -23,8 +23,8 @@
FormError::FormError(LyXView * lv, Dialogs * d)
: FormInset( lv, d, _("LaTeX Error"), new OkCancelPolicy),
dialog_(0), inset_(0)
: FormInset( lv, d, _("LaTeX Error")),
inset_(0)
{
Assert(lv && d);
// let the dialog be shown
@ -34,15 +34,9 @@ FormError::FormError(LyXView * lv, Dialogs * d)
}
FormError::~FormError()
{
delete dialog_;
}
FL_FORM * FormError::form() const
{
if (dialog_) return dialog_->form;
if (dialog_.get()) return dialog_->form;
return 0;
}
@ -78,13 +72,13 @@ void FormError::update()
void FormError::build()
{
dialog_ = build_error();
dialog_.reset(build_error());
// Workaround dumb xforms sizing bug
minw_ = form()->w;
minh_ = form()->h;
// Manage the cancel/close button
bc_.setCancel(dialog_->button_cancel);
bc_.refresh();
bc().setCancel(dialog_->button_cancel);
bc().refresh();
}

View File

@ -12,12 +12,14 @@
#ifndef FORMERROR_H
#define FORMERROR_H
#include <boost/smart_ptr.hpp>
#include "FormInset.h"
#include "xformsBC.h"
#ifdef __GNUG__
#pragma interface
#endif
#include "FormInset.h"
class InsetError;
struct FD_form_error;
@ -27,9 +29,9 @@ class FormError : public FormInset {
public:
/// Constructor
FormError(LyXView *, Dialogs *);
///
~FormError();
private:
/// Pointer to the actual instantiation of the ButtonController.
virtual xformsBC & bc();
/// Disconnect signals. Also perform any necessary housekeeping.
virtual void disconnect();
@ -45,11 +47,19 @@ private:
FD_form_error * build_error();
/// Real GUI implementation.
FD_form_error * dialog_;
boost::scoped_ptr<FD_form_error> dialog_;
/// pointer to the inset passed through showInset
InsetError * inset_;
/// the error message
string message_;
/// The ButtonController
ButtonController<OkCancelPolicy, xformsBC> bc_;
};
inline
xformsBC & FormError::bc()
{
return bc_;
}
#endif

View File

@ -24,6 +24,7 @@
#include "LyXView.h"
#include "buffer.h"
#include "FormExternal.h"
#include "form_external.h"
#include "frontends/FileDialog.h"
#include "LString.h"
#include "support/filetools.h"
@ -33,19 +34,13 @@ using std::make_pair;
using std::endl;
FormExternal::FormExternal(LyXView * lv, Dialogs * d)
: FormBaseBD(lv, d, _("Edit external file"), new OkCancelReadOnlyPolicy),
inset_(0), ih_(0), dialog_(0)
: FormBaseBD(lv, d, _("Edit external file")),
inset_(0), ih_(0)
{
d->showExternal.connect(slot(this, &FormExternal::showInset));
}
FormExternal::~FormExternal()
{
delete dialog_;
}
extern "C" void ExternalTemplateCB(FL_OBJECT * ob, long data)
{
FormExternal::templateCB(ob, data);
@ -78,7 +73,7 @@ extern "C" void ExternalUpdateCB(FL_OBJECT * ob, long data)
FL_FORM * FormExternal::form() const
{
if (dialog_)
if (dialog_.get())
return dialog_->form;
return 0;
}
@ -90,7 +85,7 @@ void FormExternal::connect()
connect(slot(this, &FormExternal::updateSlot));
h_ = d_->hideBufferDependent.
connect(slot(this, &FormExternal::hide));
FormBase::connect();
FormBaseDeprecated::connect();
}
@ -129,7 +124,7 @@ void FormExternal::showInset(InsetExternal * inset)
void FormExternal::build()
{
dialog_ = build_external();
dialog_.reset(build_external());
fl_addto_choice(dialog_->choice_template,
getTemplatesComboString().c_str());

View File

@ -10,22 +10,24 @@
#ifndef FORMEXTERNAL_H
#define FORMEXTERNAL_H
#include "FormBase.h"
#include "insets/insetexternal.h"
#include "form_external.h"
#include <boost/smart_ptr.hpp>
#ifdef __GNUG__
#pragma interface
#endif
#include "FormBaseDeprecated.h"
#include "insets/insetexternal.h"
#include "xformsBC.h"
struct FD_form_external;
/// The class for editing External insets via a dialog
class FormExternal : public FormBaseBD {
public:
///
FormExternal(LyXView *, Dialogs *);
~FormExternal();
/// Connect signals. Also perform any necessary initialisation.
virtual void connect();
@ -92,8 +94,21 @@ private:
/// build the dialog
FD_form_external * build_external();
/// Pointer to the actual instantiation of the ButtonController.
virtual xformsBC & bc();
/// the dialog implementation
FD_form_external * dialog_;
boost::scoped_ptr<FD_form_external> dialog_;
/// The ButtonController
ButtonController<OkCancelReadOnlyPolicy, xformsBC> bc_;
};
inline
xformsBC & FormExternal::bc()
{
return bc_;
}
#endif // FORMEXTERNAL_H

View File

@ -10,15 +10,15 @@
#ifndef FORMFILEDIALOG_H
#define FORMFILEDIALOG_H
#include <vector>
#include <sigc++/signal_system.h>
#ifdef __GNUG__
#pragma interface
#endif
#include <config.h>
#include <vector>
#include <sigc++/signal_system.h>
#include "LString.h"
#include FORMS_H_LOCATION
#include "form_filedialog.h"

View File

@ -33,8 +33,8 @@ using std::endl;
using std::make_pair;
FormGraphics::FormGraphics(LyXView * lv, Dialogs * d)
: FormInset(lv, d, _("Graphics"), new NoRepeatedApplyReadOnlyPolicy),
dialog_(0), inset_(0),
: FormInset(lv, d, _("Graphics")),
inset_(0),
// The buttons c-tor values are the number of buttons we use
// This is only to reduce memory waste.
widthButtons(5), heightButtons(4), displayButtons(4),
@ -53,20 +53,12 @@ FormGraphics::~FormGraphics()
widthButtons.reset();
heightButtons.reset();
displayButtons.reset();
// Free the form.
// delete dialog_;
}
void FormGraphics::build()
{
dialog_ = build_graphics();
Assert(dialog_ != 0);
if (!dialog_) {
lyxerr << "ERROR: Failed to create the Graphics Inset dialog." << endl;
return ;
}
dialog_.reset(build_graphics());
// Workaround dumb xforms sizing bug
minw_ = form()->w;
@ -136,29 +128,30 @@ void FormGraphics::build()
InsetGraphicsParams::NONE);
// Manage the ok, apply, restore and cancel/close buttons
bc_.setOK(dialog_->button_ok);
bc_.setApply(dialog_->button_apply);
bc_.setCancel(dialog_->button_cancel);
bc_.setUndoAll(dialog_->button_restore);
bc_.refresh();
bc().setOK(dialog_->button_ok);
bc().setApply(dialog_->button_apply);
bc().setCancel(dialog_->button_cancel);
bc().setUndoAll(dialog_->button_restore);
bc().refresh();
bc_.addReadOnly(dialog_->input_filename);
bc_.addReadOnly(dialog_->button_browse);
bc_.addReadOnly(dialog_->input_width);
bc_.addReadOnly(dialog_->input_height);
bc_.addReadOnly(dialog_->radio_button_group_width);
bc_.addReadOnly(dialog_->radio_button_group_height);
bc_.addReadOnly(dialog_->radio_button_group_display);
bc_.addReadOnly(dialog_->input_rotate_angle);
bc_.addReadOnly(dialog_->check_inline);
bc_.addReadOnly(dialog_->input_subcaption);
bc_.addReadOnly(dialog_->check_subcaption);
bc().addReadOnly(dialog_->input_filename);
bc().addReadOnly(dialog_->button_browse);
bc().addReadOnly(dialog_->input_width);
bc().addReadOnly(dialog_->input_height);
bc().addReadOnly(dialog_->radio_button_group_width);
bc().addReadOnly(dialog_->radio_button_group_height);
bc().addReadOnly(dialog_->radio_button_group_display);
bc().addReadOnly(dialog_->input_rotate_angle);
bc().addReadOnly(dialog_->check_inline);
bc().addReadOnly(dialog_->input_subcaption);
bc().addReadOnly(dialog_->check_subcaption);
}
FL_FORM * FormGraphics::form() const
{
if (dialog_ ) return dialog_->form;
if (dialog_.get())
return dialog_->form;
return 0;
}
@ -266,7 +259,7 @@ void FormGraphics::update()
igp.inlineFigure);
// update the dialog's read only / read-write status
bc_.readOnly(lv_->buffer()->isReadonly());
bc().readOnly(lv_->buffer()->isReadonly());
// Now make sure that the buttons are set correctly.
input(0, 0);

View File

@ -16,15 +16,18 @@
#ifndef FORMGRAPHICS_H
#define FORMGRAPHICS_H
#include "LString.h"
#include "RadioButtonGroup.h"
#include "ButtonPolicies.h"
#include "FormInset.h"
#include <boost/smart_ptr.hpp>
#ifdef __GNUG__
#pragma interface
#endif
#include "LString.h"
#include "RadioButtonGroup.h"
#include "ButtonPolicies.h"
#include "FormInset.h"
#include "xformsBC.h"
// Forward declarations for classes we use only as pointers.
class InsetGraphics;
@ -72,6 +75,8 @@ private:
ADVANCEDINPUT
};
/// Pointer to the actual instantiation of the ButtonController.
virtual xformsBC & bc();
/// Build the dialog
virtual void build();
/// Filter the inputs
@ -97,7 +102,7 @@ private:
FD_form_graphics * build_graphics();
/// Real GUI implementation.
FD_form_graphics * dialog_;
boost::scoped_ptr<FD_form_graphics> dialog_;
/** Which Inset do we belong to?
Used to set and update data to/from the inset.
*/
@ -110,6 +115,14 @@ private:
RadioButtonGroup displayButtons;
/// Last used figure path
string last_image_path;
/// The ButtonController
ButtonController<NoRepeatedApplyReadOnlyPolicy, xformsBC> bc_;
};
inline
xformsBC & FormGraphics::bc()
{
return bc_;
}
#endif

View File

@ -32,22 +32,16 @@ using std::make_pair;
using std::pair;
FormInclude::FormInclude(LyXView * lv, Dialogs * d)
: FormBaseBD(lv, d, _("Include file"), new OkCancelPolicy),
dialog_(0), ih_(0), inset_(0)
: FormBaseBD(lv, d, _("Include file")),
ih_(0), inset_(0)
{
d->showInclude.connect(slot(this, &FormInclude::showInclude));
}
FormInclude::~FormInclude()
{
delete dialog_;
}
FL_FORM * FormInclude::form() const
{
if (dialog_)
if (dialog_.get())
return dialog_->form;
return 0;
}
@ -59,7 +53,7 @@ void FormInclude::connect()
connect(slot(this, &FormInclude::updateSlot));
h_ = d_->hideBufferDependent.
connect(slot(this, &FormInclude::hide));
FormBase::connect();
FormBaseDeprecated::connect();
}
@ -82,7 +76,7 @@ void FormInclude::updateSlot(bool switched)
void FormInclude::build()
{
dialog_ = build_include();
dialog_.reset(build_include());
// Workaround dumb xforms sizing bug
minw_ = form()->w;
@ -116,7 +110,7 @@ void FormInclude::showInclude(InsetInclude * inset)
void FormInclude::update()
{
bc_.readOnly(lv_->buffer()->isReadonly());
bc().readOnly(lv_->buffer()->isReadonly());
if (!inset_) {
fl_set_input(dialog_->input_filename, "");

View File

@ -1,3 +1,4 @@
// -*- C++ -*-
/**
* \file FormInclude.h
* Copyright 2001 the LyX Team
@ -9,15 +10,16 @@
#ifndef FORMINCLUDE_H
#define FORMINCLUDE_H
#include <boost/smart_ptr.hpp>
#ifdef __GNUG__
#pragma interface
#endif
#include "FormBase.h"
#include "FormBaseDeprecated.h"
#include "xformsBC.h"
#include "insets/insetinclude.h"
class InsetInclude;
struct FD_form_include;
/** This class provides an XForms implementation of the FormInclude Dialog.
@ -26,21 +28,21 @@ class FormInclude : public FormBaseBD {
public:
///
FormInclude(LyXView *, Dialogs *);
///
~FormInclude();
private:
///
enum State {
/// the browse button
BROWSE=0,
BROWSE = 0,
/// the load file button
LOAD=5,
LOAD = 5,
/// the verbatim radio choice
VERBATIM=10,
VERBATIM = 10,
/// the input and include radio choices
INPUTINCLUDE=11
INPUTINCLUDE = 11
};
/// Pointer to the actual instantiation of the ButtonController.
virtual xformsBC & bc();
/// Slot launching dialog to an existing inset
void showInclude(InsetInclude *);
@ -67,8 +69,10 @@ private:
FD_form_include * build_include();
/// Real GUI implementation.
FD_form_include * dialog_;
boost::scoped_ptr<FD_form_include> dialog_;
/// The ButtonController
ButtonController<OkCancelReadOnlyPolicy, xformsBC> bc_;
/// inset::hide connection.
Connection ih_;
@ -78,4 +82,10 @@ private:
InsetInclude::InsetIncludeParams params;
};
inline
xformsBC & FormInclude::bc()
{
return bc_;
}
#endif

View File

@ -26,8 +26,7 @@
#include "lyxfunc.h"
FormIndex::FormIndex(LyXView * lv, Dialogs * d)
: FormCommand(lv, d, _("Index"), new NoRepeatedApplyPolicy),
dialog_(0)
: FormCommand(lv, d, _("Index"))
{
// let the dialog be shown
// These are permanent connections so we won't bother
@ -37,15 +36,9 @@ FormIndex::FormIndex(LyXView * lv, Dialogs * d)
}
FormIndex::~FormIndex()
{
delete dialog_;
}
FL_FORM * FormIndex::form() const
{
if (dialog_) return dialog_->form;
if (dialog_.get()) return dialog_->form;
return 0;
}
@ -59,7 +52,7 @@ void FormIndex::connect()
void FormIndex::build()
{
dialog_ = build_index();
dialog_.reset(build_index());
// Workaround dumb xforms sizing bug
minw_ = form()->w;
@ -68,13 +61,13 @@ void FormIndex::build()
fl_set_input_return(dialog_->input_key, FL_RETURN_CHANGED);
// Manage the ok, apply, restore and cancel/close buttons
bc_.setOK(dialog_->button_ok);
bc_.setApply(dialog_->button_apply);
bc_.setCancel(dialog_->button_cancel);
bc_.setUndoAll(dialog_->button_restore);
bc_.refresh();
bc().setOK(dialog_->button_ok);
bc().setApply(dialog_->button_apply);
bc().setCancel(dialog_->button_cancel);
bc().setUndoAll(dialog_->button_restore);
bc().refresh();
bc_.addReadOnly(dialog_->input_key);
bc().addReadOnly(dialog_->input_key);
}
@ -83,8 +76,8 @@ void FormIndex::update()
fl_set_input(dialog_->input_key, params.getContents().c_str());
// Surely, this should reset the buttons to their original state?
// It doesn't. Instead "Restore" becomes a "Close"
//bc_.refresh();
bc_.readOnly(lv_->buffer()->isReadonly());
//bc().refresh();
bc().readOnly(lv_->buffer()->isReadonly());
}

View File

@ -12,11 +12,14 @@
#ifndef FORMINDEX_H
#define FORMINDEX_H
#include <boost/smart_ptr.hpp>
#include "FormInset.h"
#include "xformsBC.h"
#ifdef __GNUG__
#pragma interface
#endif
#include "FormInset.h"
struct FD_form_index;
/** This class provides an XForms implementation of the FormIndex Dialog.
@ -25,9 +28,9 @@ class FormIndex : public FormCommand {
public:
///
FormIndex(LyXView *, Dialogs *);
///
~FormIndex();
private:
/// Pointer to the actual instantiation of the ButtonController.
virtual xformsBC & bc();
/// Connect signals etc. Set form's max size.
virtual void connect();
/// Build the dialog
@ -41,7 +44,15 @@ private:
///
FD_form_index * build_index();
/// Real GUI implementation.
FD_form_index * dialog_;
boost::scoped_ptr<FD_form_index> dialog_;
/// The ButtonController
ButtonController<NoRepeatedApplyReadOnlyPolicy, xformsBC> bc_;
};
inline
xformsBC & FormIndex::bc()
{
return bc_;
}
#endif

View File

@ -21,11 +21,10 @@
#include "Dialogs.h"
#include "LyXView.h"
#include "FormInset.h"
#include "xformsBC.h"
FormInset::FormInset(LyXView * lv, Dialogs * d, string const & t,
ButtonPolicy * bp,
char const * close, char const * cancel)
: FormBaseBD(lv, d, t, bp, close, cancel), ih_(0)
FormInset::FormInset(LyXView * lv, Dialogs * d, string const & t)
: FormBaseBD(lv, d, t), ih_(0)
{}
@ -35,7 +34,7 @@ void FormInset::connect()
connect(slot(this, &FormInset::updateSlot));
h_ = d_->hideBufferDependent.
connect(slot(this, &FormInset::hide));
FormBase::connect();
FormBaseDeprecated::connect();
}
@ -55,10 +54,8 @@ void FormInset::updateSlot(bool switched)
}
FormCommand::FormCommand(LyXView * lv, Dialogs * d, string const & t,
ButtonPolicy * bp,
char const * close, char const * cancel)
: FormInset(lv, d, t, bp, close, cancel),
FormCommand::FormCommand(LyXView * lv, Dialogs * d, string const & t)
: FormInset(lv, d, t),
inset_(0)
{}
@ -95,6 +92,6 @@ void FormCommand::createInset(string const & arg)
params.setFromString(arg);
if ( !arg.empty() )
bc_.valid(); // so that the user can press Ok
bc().valid(); // so that the user can press Ok
show();
}

View File

@ -12,7 +12,7 @@
#ifndef FORMCOMMAND_H
#define FORMCOMMAND_H
#include "FormBase.h"
#include "FormBaseDeprecated.h"
#include "insets/insetcommand.h"
#ifdef __GNUG__
@ -25,10 +25,7 @@
class FormInset : public FormBaseBD {
protected:
/// Constructor
FormInset(LyXView *, Dialogs *, string const &,
ButtonPolicy * bp,
char const * close = N_("Close"),
char const * cancel = N_("Cancel"));
FormInset(LyXView *, Dialogs *, string const &);
/// Connect signals. Also perform any necessary initialisation.
virtual void connect();
@ -49,10 +46,7 @@ protected:
class FormCommand : public FormInset {
protected:
/// Constructor
FormCommand(LyXView *, Dialogs *, string const &,
ButtonPolicy *,
char const * close = N_("Close"),
char const * cancel = N_("Cancel"));
FormCommand(LyXView *, Dialogs *, string const &);
/// Disconnect signals. Also perform any necessary housekeeping.
virtual void disconnect();

View File

@ -32,13 +32,10 @@ FormLog::FormLog(LyXView * lv, Dialogs * d)
d->showLogFile.connect(slot(this, &FormLog::show));
}
FormLog::~FormLog()
{
}
void FormLog::update()
{
if (!dialog_ || !lv_->view()->available())
if (!dialog_.get() || !lv_->view()->available())
return;
std::pair<Buffer::LogType, string> const logfile

View File

@ -9,7 +9,7 @@
#ifndef FORMLOG_H
#define FORMLOG_H
#include "FormBase.h"
#include "FormBaseDeprecated.h"
#include "FormBrowser.h"
#ifdef __GNUG__
@ -25,9 +25,8 @@ class Dialogs;
*/
class FormLog : public FormBrowser {
public:
///
FormLog(LyXView *, Dialogs *);
~FormLog();
private:
/// Update the dialog.
virtual void update();

View File

@ -31,9 +31,7 @@ using Liason::setMinibuffer;
#endif
FormParagraph::FormParagraph(LyXView * lv, Dialogs * d)
: FormBaseBD(lv, d, _("Paragraph Layout"),
new NoRepeatedApplyReadOnlyPolicy),
dialog_(0), general_(0), extra_(0)
: FormBaseBD(lv, d, _("Paragraph Layout"))
{
// let the popup be shown
// This is a permanent connection so we won't bother
@ -42,14 +40,6 @@ FormParagraph::FormParagraph(LyXView * lv, Dialogs * d)
}
FormParagraph::~FormParagraph()
{
delete general_;
delete extra_;
delete dialog_;
}
void FormParagraph::redraw()
{
if( form() && form()->visible )
@ -65,7 +55,7 @@ void FormParagraph::redraw()
FL_FORM * FormParagraph::form() const
{
if (dialog_) return dialog_->form;
if (dialog_.get()) return dialog_->form;
return 0;
}
@ -73,7 +63,7 @@ FL_FORM * FormParagraph::form() const
void FormParagraph::build()
{
// the tabbed folder
dialog_ = build_tabbed_paragraph();
dialog_.reset(build_tabbed_paragraph());
// Workaround dumb xforms sizing bug
minw_ = form()->w;
@ -87,7 +77,7 @@ void FormParagraph::build()
bc_.refresh();
// the general paragraph data form
general_ = build_paragraph_general();
general_.reset(build_paragraph_general());
fl_addto_choice(general_->choice_space_above,
_(" None | Defskip | Smallskip "
@ -118,7 +108,7 @@ void FormParagraph::build()
bc_.addReadOnly (general_->input_labelwidth);
// the document class form
extra_ = build_paragraph_extra();
extra_.reset(build_paragraph_extra());
fl_set_input_return(extra_->input_pextra_width, FL_RETURN_CHANGED);
fl_set_input_return(extra_->input_pextra_widthp, FL_RETURN_CHANGED);
@ -137,7 +127,7 @@ void FormParagraph::build()
void FormParagraph::apply()
{
if (!lv_->view()->available() || !dialog_)
if (!lv_->view()->available() || !dialog_.get())
return;
general_apply();
@ -152,7 +142,7 @@ void FormParagraph::apply()
void FormParagraph::update()
{
if (!dialog_)
if (!dialog_.get())
return;
general_update();
@ -296,7 +286,7 @@ void FormParagraph::extra_apply()
void FormParagraph::general_update()
{
if (!general_)
if (!general_.get())
return;
Buffer * buf = lv_->view()->buffer();
@ -468,7 +458,7 @@ void FormParagraph::general_update()
void FormParagraph::extra_update()
{
if (!lv_->view()->available() || !extra_)
if (!lv_->view()->available() || !extra_.get())
return;
LyXParagraph * par = lv_->view()->text->cursor.par();

View File

@ -13,13 +13,14 @@
#ifndef FORM_PARAGRAPH_H
#define FORM_PARAGRAPH_H
#include "FormBase.h"
#include <boost/smart_ptr.hpp>
#include "FormBaseDeprecated.h"
#include "xformsBC.h"
#ifdef __GNUG_
#pragma interface
#endif
struct FD_form_tabbed_paragraph;
struct FD_form_paragraph_general;
struct FD_form_paragraph_extra;
@ -31,10 +32,9 @@ class FormParagraph : public FormBaseBD {
public:
///
FormParagraph(LyXView *, Dialogs *);
///
~FormParagraph();
private:
/// Pointer to the actual instantiation of the ButtonController.
virtual xformsBC & bc();
/** Redraw the form (on receipt of a Signal indicating, for example,
that the xforms colours have been re-mapped). */
virtual void redraw();
@ -67,11 +67,19 @@ private:
FD_form_paragraph_extra * build_paragraph_extra();
/// Real GUI implementation.
FD_form_tabbed_paragraph * dialog_;
boost::scoped_ptr<FD_form_tabbed_paragraph> dialog_;
///
FD_form_paragraph_general * general_;
boost::scoped_ptr<FD_form_paragraph_general> general_;
///
FD_form_paragraph_extra * extra_;
boost::scoped_ptr<FD_form_paragraph_extra> extra_;
/// The ButtonController
ButtonController<NoRepeatedApplyReadOnlyPolicy, xformsBC> bc_;
};
inline
xformsBC & FormParagraph::bc()
{
return bc_;
}
#endif

View File

@ -10,6 +10,10 @@
#include FORMS_H_LOCATION
#ifdef __GNUG__
#pragma implementation
#endif
#include "form_preamble.h"
#include "FormPreamble.h"
#include "Dialogs.h"
@ -24,8 +28,7 @@ using Liason::setMinibuffer;
#endif
FormPreamble::FormPreamble(LyXView * lv, Dialogs * d)
: FormBaseBD(lv, d, _("LaTeX preamble"), new NoRepeatedApplyReadOnlyPolicy),
dialog_(0)
: FormBaseBD(lv, d, _("LaTeX preamble"))
{
// let the popup be shown
// This is a permanent connection so we won't bother
@ -34,37 +37,33 @@ FormPreamble::FormPreamble(LyXView * lv, Dialogs * d)
}
FormPreamble::~FormPreamble()
{
delete dialog_;
}
FL_FORM * FormPreamble::form() const
{
if (dialog_) return dialog_->form;
if (dialog_.get()) return dialog_->form;
return 0;
}
void FormPreamble::build()
{
dialog_ = build_preamble();
dialog_.reset(build_preamble());
// Workaround dumb xforms sizing bug
minw_ = form()->w;
minh_ = form()->h;
fl_set_input_return(dialog_->input_preamble, FL_RETURN_CHANGED);
// Manage the ok, apply and cancel/close buttons
bc_.setOK(dialog_->button_ok);
bc_.setApply(dialog_->button_apply);
bc_.setCancel(dialog_->button_cancel);
bc_.addReadOnly(dialog_->input_preamble);
bc_.refresh();
bc().setOK(dialog_->button_ok);
bc().setApply(dialog_->button_apply);
bc().setCancel(dialog_->button_cancel);
bc().addReadOnly(dialog_->input_preamble);
bc().refresh();
}
void FormPreamble::apply()
{
if (!lv_->view()->available() || !dialog_)
if (!lv_->view()->available() || !dialog_.get())
return;
// is this needed?:
@ -78,7 +77,7 @@ void FormPreamble::apply()
void FormPreamble::update()
{
if (!dialog_)
if (!dialog_.get())
return;
fl_set_input(dialog_->input_preamble,lv_->buffer()->params.preamble.c_str());
@ -89,7 +88,7 @@ void FormPreamble::update()
setEnabled(dialog_->button_apply, enable);
// need this?
// bc_.readOnly(lv_->buffer()->isReadonly());
// bc().readOnly(lv_->buffer()->isReadonly());
}

View File

@ -1,3 +1,4 @@
// -*- C++ -*-
/**
* \file FormPreamble.h
* Copyright 2001 The LyX Team.
@ -9,7 +10,13 @@
#ifndef FORMPREAMBLE_H
#define FORMPREAMBLE_H
#include "FormBase.h"
#include <boost/smart_ptr.hpp>
#include "FormBaseDeprecated.h"
#include "xformsBC.h"
#ifdef __GNUG__
#pragma interface
#endif
struct FD_form_preamble;
@ -17,33 +24,37 @@ struct FD_form_preamble;
*/
class FormPreamble : public FormBaseBD {
public:
///
FormPreamble(LyXView *, Dialogs *);
///
~FormPreamble();
///
FormPreamble(LyXView *, Dialogs *);
private:
/** Redraw the form (on receipt of a Signal indicating, for example,
* that the xforms colours have been re-mapped).
*/
/// Pointer to the actual instantiation of the ButtonController.
virtual xformsBC & bc();
/// Filter the inputs
// virtual bool input(FL_OBJECT *, long);
/// Filter the inputs
// virtual bool input(FL_OBJECT *, long);
/// Build the popup
virtual void build();
/// Apply from popup
virtual void apply();
/// Update the popup.
virtual void update();
///
virtual FL_FORM * form() const;
/// Build the popup
virtual void build();
/// Apply from popup
virtual void apply();
/// Update the popup.
virtual void update();
///
virtual FL_FORM * form() const;
/// Typedefinitions from the fdesign produced Header file
FD_form_preamble * build_preamble();
/// Typedefinitions from the fdesign produced Header file
FD_form_preamble * build_preamble();
/// Real GUI implementation.
FD_form_preamble * dialog_;
/// Real GUI implementation.
boost::scoped_ptr<FD_form_preamble> dialog_;
/// The ButtonController
ButtonController<NoRepeatedApplyReadOnlyPolicy, xformsBC> bc_;
};
inline
xformsBC & FormPreamble::bc()
{
return bc_;
}
#endif

View File

@ -62,10 +62,7 @@ static Formats local_formats;
static Converters local_converters;
FormPreferences::FormPreferences(LyXView * lv, Dialogs * d)
: FormBaseBI(lv, d, _("Preferences"), new PreferencesPolicy),
dialog_(0),
converters_tab_(0), inputs_tab_(0), look_n_feel_tab_(0),
outputs_tab_(0), lang_opts_tab_(0),
: FormBaseBI(lv, d, _("Preferences")),
warningPosted(false),
colors_(*this), converters_(*this), inputs_misc_(*this),
formats_(*this), interface_(*this), language_(*this),
@ -79,18 +76,6 @@ FormPreferences::FormPreferences(LyXView * lv, Dialogs * d)
}
FormPreferences::~FormPreferences()
{
delete converters_tab_;
delete inputs_tab_;
delete look_n_feel_tab_;
delete outputs_tab_;
delete lang_opts_tab_;
delete dialog_;
}
void FormPreferences::connect()
{
fl_set_form_maxsize( dialog_->form, minw_, minh_ );
@ -143,14 +128,14 @@ void FormPreferences::redraw()
FL_FORM * FormPreferences::form() const
{
if (dialog_) return dialog_->form;
if (dialog_.get()) return dialog_->form;
return 0;
}
void FormPreferences::ok()
{
FormBase::ok();
FormBaseDeprecated::ok();
if (colors_.modifiedXformsPrefs) {
string const filename =
@ -171,31 +156,31 @@ void FormPreferences::hide()
&& outer_form->visible) {
fl_hide_form(outer_form);
}
FormBase::hide();
FormBaseDeprecated::hide();
}
void FormPreferences::build()
{
dialog_ = build_preferences();
dialog_.reset(build_preferences());
// Manage the restore, save, apply and cancel/close buttons
bc_.setOK(dialog_->button_ok);
bc_.setApply(dialog_->button_apply);
bc_.setCancel(dialog_->button_cancel);
bc_.setUndoAll(dialog_->button_restore);
bc_.refresh();
bc().setOK(dialog_->button_ok);
bc().setApply(dialog_->button_apply);
bc().setCancel(dialog_->button_cancel);
bc().setUndoAll(dialog_->button_restore);
bc().refresh();
// Workaround dumb xforms sizing bug
minw_ = form()->w;
minh_ = form()->h;
// build the tab folders
converters_tab_ = build_outer_tab();
look_n_feel_tab_ = build_outer_tab();
inputs_tab_ = build_outer_tab();
outputs_tab_ = build_outer_tab();
lang_opts_tab_ = build_outer_tab();
converters_tab_.reset(build_outer_tab());
look_n_feel_tab_.reset(build_outer_tab());
inputs_tab_.reset(build_outer_tab());
outputs_tab_.reset(build_outer_tab());
lang_opts_tab_.reset(build_outer_tab());
// build actual tabfolder contents
// these will become nested tabfolders
@ -339,8 +324,7 @@ void FormPreferences::feedback(FL_OBJECT * ob)
str = spellchecker_.feedback(ob);
}
str = formatted(_(str), dialog_->text_warning->w-10,
FL_SMALL_SIZE, FL_NORMAL_STYLE);
str = formatted(_(str), dialog_->text_warning->w-10, FL_SMALL_SIZE);
fl_set_object_label(dialog_->text_warning, str.c_str());
fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
@ -379,7 +363,7 @@ bool FormPreferences::input(FL_OBJECT * ob, long)
void FormPreferences::update()
{
if (!dialog_) return;
if (!dialog_.get()) return;
// read lyxrc entries
colors_.update();
@ -397,9 +381,14 @@ void FormPreferences::update()
}
FormPreferences::Colors::~Colors()
FormPreferences::Colors::Colors(FormPreferences & p)
: parent_(p)
{}
FD_form_colors const * FormPreferences::Colors::dialog()
{
delete dialog_;
return dialog_.get();
}
@ -478,7 +467,7 @@ void FormPreferences::Colors::apply()
void FormPreferences::Colors::build()
{
dialog_ = parent_.build_colors();
dialog_.reset(parent_.build_colors());
fl_set_object_color(dialog_->button_color,
GUI_COLOR_CHOICE, GUI_COLOR_CHOICE);
@ -944,9 +933,14 @@ string const FormPreferences::Colors::X11hexname(RGBColor const & col) const
}
FormPreferences::Converters::~Converters()
FormPreferences::Converters::Converters(FormPreferences & p)
: parent_(p)
{}
FD_form_converters const * FormPreferences::Converters::dialog()
{
delete dialog_;
return dialog_.get();
}
@ -960,7 +954,7 @@ void FormPreferences::Converters::apply() const
void FormPreferences::Converters::build()
{
dialog_ = parent_.build_converters();
dialog_.reset(parent_.build_converters());
fl_set_input_return(dialog_->input_converter, FL_RETURN_CHANGED);
fl_set_input_return(dialog_->input_flags, FL_RETURN_CHANGED);
@ -1201,9 +1195,14 @@ void FormPreferences::Converters::UpdateChoices() const
}
FormPreferences::Formats::~Formats()
FormPreferences::Formats::Formats( FormPreferences & p )
: parent_(p)
{}
FD_form_formats const * FormPreferences::Formats::dialog()
{
delete dialog_;
return dialog_.get();
}
@ -1215,7 +1214,7 @@ void FormPreferences::Formats::apply() const
void FormPreferences::Formats::build()
{
dialog_ = parent_.build_formats();
dialog_.reset(parent_.build_formats());
fl_set_input_return(dialog_->input_format, FL_RETURN_CHANGED);
fl_set_input_return(dialog_->input_viewer, FL_RETURN_CHANGED);
@ -1421,9 +1420,14 @@ bool FormPreferences::Formats::Input()
}
FormPreferences::InputsMisc::~InputsMisc()
FormPreferences::InputsMisc::InputsMisc( FormPreferences & p )
: parent_(p)
{}
FD_form_inputs_misc const * FormPreferences::InputsMisc::dialog()
{
delete dialog_;
return dialog_.get();
}
@ -1436,7 +1440,7 @@ void FormPreferences::InputsMisc::apply() const
void FormPreferences::InputsMisc::build()
{
dialog_ = parent_.build_inputs_misc();
dialog_.reset(parent_.build_inputs_misc());
fl_set_input_return(dialog_->input_date_format, FL_RETURN_CHANGED);
@ -1464,9 +1468,14 @@ void FormPreferences::InputsMisc::update()
}
FormPreferences::Interface::~Interface()
FormPreferences::Interface::Interface( FormPreferences & p )
: parent_(p)
{}
FD_form_interface const * FormPreferences::Interface::dialog()
{
delete dialog_;
return dialog_.get();
}
@ -1486,7 +1495,7 @@ void FormPreferences::Interface::apply() const
void FormPreferences::Interface::build()
{
dialog_ = parent_.build_interface();
dialog_.reset(parent_.build_interface());
fl_set_input_return(dialog_->input_popup_font, FL_RETURN_CHANGED);
fl_set_input_return(dialog_->input_menu_font, FL_RETURN_CHANGED);
@ -1576,10 +1585,14 @@ void FormPreferences::Interface::update()
}
FormPreferences::Language::~Language()
FormPreferences::Language::Language( FormPreferences & p )
: parent_(p)
{}
FD_form_language const * FormPreferences::Language::dialog()
{
delete combo_default_lang;
delete dialog_;
return dialog_.get();
}
@ -1628,7 +1641,7 @@ void FormPreferences::Language::apply()
void FormPreferences::Language::build()
{
dialog_ = parent_.build_language();
dialog_.reset(parent_.build_language());
fl_set_input_return(dialog_->input_package, FL_RETURN_CHANGED);
fl_set_input_return(dialog_->input_command_begin, FL_RETURN_CHANGED);
@ -1640,7 +1653,7 @@ void FormPreferences::Language::build()
FL_OBJECT * obj = dialog_->choice_default_lang;
fl_deactivate_object(dialog_->choice_default_lang);
combo_default_lang = new Combox(FL_COMBOX_DROPLIST);
combo_default_lang.reset(new Combox(FL_COMBOX_DROPLIST));
combo_default_lang->add(obj->x, obj->y, obj->w, obj->h, 400,
parent_.lang_opts_tab_->tabfolder_outer,
parent_.dialog_->tabfolder_prefs);
@ -1688,7 +1701,7 @@ FormPreferences::Language::feedback(FL_OBJECT const * const ob) const
{
string str;
if (reinterpret_cast<Combox const *>(ob) == combo_default_lang)
if (reinterpret_cast<Combox const *>(ob) == combo_default_lang.get())
str = lyxrc.getDescription(LyXRC::RC_DEFAULT_LANGUAGE);
else if (ob == dialog_->check_use_kbmap)
str = lyxrc.getDescription(LyXRC::RC_KBMAP);
@ -1800,13 +1813,18 @@ void FormPreferences::Language::ComboCB(int, void * v, Combox * combox)
FormPreferences * pre = static_cast<FormPreferences*>(v);
// This is safe, as nothing is done to the pointer, other than
// to use its address in a block-if statement.
pre->bc_.valid(pre->input(reinterpret_cast<FL_OBJECT *>(combox), 0));
pre->bc().valid(pre->input(reinterpret_cast<FL_OBJECT *>(combox), 0));
}
FormPreferences::LnFmisc::~LnFmisc()
FormPreferences::LnFmisc::LnFmisc( FormPreferences & p )
: parent_(p)
{}
FD_form_lnf_misc const * FormPreferences::LnFmisc::dialog()
{
delete dialog_;
return dialog_.get();
}
@ -1830,7 +1848,7 @@ void FormPreferences::LnFmisc::apply() const
void FormPreferences::LnFmisc::build()
{
dialog_ = parent_.build_lnf_misc();
dialog_.reset(parent_.build_lnf_misc());
fl_set_counter_step(dialog_->counter_autosave, 1, 10);
fl_set_counter_step(dialog_->counter_wm_jump, 1, 10);
@ -1891,9 +1909,14 @@ void FormPreferences::LnFmisc::update()
}
FormPreferences::OutputsMisc::~OutputsMisc()
FormPreferences::OutputsMisc::OutputsMisc( FormPreferences & p )
: parent_(p)
{}
FD_form_outputs_misc const * FormPreferences::OutputsMisc::dialog()
{
delete dialog_;
return dialog_.get();
}
@ -1914,7 +1937,7 @@ void FormPreferences::OutputsMisc::apply() const
void FormPreferences::OutputsMisc::build()
{
dialog_ = parent_.build_outputs_misc();
dialog_.reset(parent_.build_outputs_misc());
fl_set_counter_step(dialog_->counter_line_len, 1, 10);
@ -1970,9 +1993,14 @@ void FormPreferences::OutputsMisc::update()
}
FormPreferences::Paths::~Paths()
FormPreferences::Paths::Paths( FormPreferences & p )
: parent_(p)
{}
FD_form_paths const * FormPreferences::Paths::dialog()
{
delete dialog_;
return dialog_.get();
}
@ -2013,7 +2041,7 @@ void FormPreferences::Paths::apply()
void FormPreferences::Paths::build()
{
dialog_ = parent_.build_paths();
dialog_.reset(parent_.build_paths());
fl_set_input_return(dialog_->input_default_path, FL_RETURN_CHANGED);
fl_set_input_return(dialog_->input_template_path, FL_RETURN_CHANGED);
@ -2228,9 +2256,14 @@ void FormPreferences::Paths::update()
}
FormPreferences::Printer::~Printer()
FormPreferences::Printer::Printer(FormPreferences & p)
: parent_(p)
{}
FD_form_printer const * FormPreferences::Printer::dialog()
{
delete dialog_;
return dialog_.get();
}
@ -2310,7 +2343,7 @@ FormPreferences::Printer::feedback(FL_OBJECT const * const ob) const
void FormPreferences::Printer::build()
{
dialog_ = parent_.build_printer();
dialog_.reset(parent_.build_printer());
fl_set_input_return(dialog_->input_command, FL_RETURN_CHANGED);
fl_set_input_return(dialog_->input_page_range, FL_RETURN_CHANGED);
@ -2393,9 +2426,14 @@ void FormPreferences::Printer::update()
}
FormPreferences::ScreenFonts::~ScreenFonts()
FormPreferences::ScreenFonts::ScreenFonts( FormPreferences & p )
: parent_(p)
{}
FD_form_screen_fonts const * FormPreferences::ScreenFonts::dialog()
{
delete dialog_;
return dialog_.get();
}
@ -2517,7 +2555,7 @@ void FormPreferences::ScreenFonts::apply() const
void FormPreferences::ScreenFonts::build()
{
dialog_ = parent_.build_screen_fonts();
dialog_.reset(parent_.build_screen_fonts());
fl_set_counter_step(dialog_->counter_zoom, 1, 10);
fl_set_counter_step(dialog_->counter_dpi, 1, 10);
@ -2695,9 +2733,15 @@ void FormPreferences::ScreenFonts::update()
}
FormPreferences::SpellChecker::~SpellChecker()
FormPreferences::SpellChecker::SpellChecker( FormPreferences & p )
: parent_(p)
{}
FD_form_spellchecker const * FormPreferences::SpellChecker::dialog()
{
delete dialog_;
return dialog_.get();
}
@ -2761,7 +2805,7 @@ void FormPreferences::SpellChecker::apply()
void FormPreferences::SpellChecker::build()
{
dialog_ = parent_.build_spellchecker();
dialog_.reset(parent_.build_spellchecker());
fl_addto_choice(dialog_->choice_spell_command,
_(" none | ispell | aspell "));
@ -2912,8 +2956,7 @@ void FormPreferences::printWarning(string const & warning)
warningPosted = true;
string str = _("WARNING!") + string(" ") + warning;
str = formatted(str, dialog_->text_warning->w-10,
FL_SMALL_SIZE, FL_NORMAL_STYLE);
str = formatted(str, dialog_->text_warning->w-10, FL_SMALL_SIZE);
fl_set_object_label(dialog_->text_warning, str.c_str());
fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);

View File

@ -17,14 +17,17 @@
#ifndef FORMPREFERENCES_H
#define FORMPREFERENCES_H
#include <utility> // pair
#include <boost/smart_ptr.hpp>
#ifdef __GNUG_
#pragma interface
#endif
#include <utility> // pair
#include "FormBase.h"
#include "FormBaseDeprecated.h"
#include "Color.h" // NamedColor
#include "xforms_helpers.h" // XformsColor
#include "xforms_helpers.h" // XformColor
#include "xformsBC.h"
class Combox;
class Dialogs;
@ -54,12 +57,12 @@ public:
/// #FormPreferences x(LyXFunc ..., Dialogs ...);#
FormPreferences(LyXView *, Dialogs *);
///
~FormPreferences();
///
static int FeedbackCB(FL_OBJECT *, int,
FL_Coord, FL_Coord, int, void *);
private:
/// Pointer to the actual instantiation of the ButtonController.
virtual xformsBC & bc();
/// Connect signals etc. Set form's max size.
virtual void connect();
/// Disconnect signals. Also perform any necessary housekeeping.
@ -128,17 +131,17 @@ private:
FD_form_spellchecker * build_spellchecker();
/// Real GUI implementation.
FD_form_preferences * dialog_;
boost::scoped_ptr<FD_form_preferences> dialog_;
/// Converters tabfolder
FD_form_outer_tab * converters_tab_;
boost::scoped_ptr<FD_form_outer_tab> converters_tab_;
/// reLyX and other import/input stuff
FD_form_outer_tab * inputs_tab_;
boost::scoped_ptr<FD_form_outer_tab> inputs_tab_;
/// HCI configuration
FD_form_outer_tab * look_n_feel_tab_;
boost::scoped_ptr<FD_form_outer_tab> look_n_feel_tab_;
/// Outputs tabfolder
FD_form_outer_tab * outputs_tab_;
boost::scoped_ptr<FD_form_outer_tab> outputs_tab_;
/// Spellchecker, language stuff, etc
FD_form_outer_tab * lang_opts_tab_;
boost::scoped_ptr<FD_form_outer_tab> lang_opts_tab_;
/** Flag whether a warning has been posted to the text window.
If so, don't redraw the window when the mouse leaves an object. */
@ -156,11 +159,9 @@ private:
GUI_COLOR_CURSOR = FL_FREE_COL3
};
///
Colors( FormPreferences & p ) : parent_(p), dialog_(0) {}
Colors( FormPreferences & p );
///
~Colors();
///
FD_form_colors const * dialog() { return dialog_; }
FD_form_colors const * dialog();
///
void apply(); // not const as modifies modifiedXformsPrefs.
///
@ -196,7 +197,7 @@ private:
///
FormPreferences & parent_;
///
FD_form_colors * dialog_;
boost::scoped_ptr<FD_form_colors> dialog_;
/// A vector of LyX LColor GUI name and associated RGB color.
std::vector<NamedColor> lyxColorDB;
@ -210,11 +211,9 @@ private:
class Converters {
public:
///
Converters( FormPreferences & p ) : parent_(p), dialog_(0) {}
Converters( FormPreferences & p );
///
~Converters();
///
FD_form_converters const * dialog() { return dialog_; }
FD_form_converters const * dialog();
///
void apply() const;
///
@ -247,7 +246,7 @@ private:
///
FormPreferences & parent_;
///
FD_form_converters * dialog_;
boost::scoped_ptr<FD_form_converters> dialog_;
};
///
friend class Converters;
@ -256,11 +255,9 @@ private:
class Formats {
public:
///
Formats( FormPreferences & p ) : parent_(p), dialog_(0) {}
Formats( FormPreferences & p );
///
~Formats();
///
FD_form_formats const * dialog() { return dialog_; }
FD_form_formats const * dialog();
///
void apply() const;
///
@ -287,7 +284,7 @@ private:
///
FormPreferences & parent_;
///
FD_form_formats * dialog_;
boost::scoped_ptr<FD_form_formats> dialog_;
};
///
friend class Formats;
@ -296,11 +293,9 @@ private:
class InputsMisc {
public:
///
InputsMisc( FormPreferences & p ) : parent_(p), dialog_(0) {}
InputsMisc( FormPreferences & p );
///
~InputsMisc();
///
FD_form_inputs_misc const * dialog() { return dialog_; }
FD_form_inputs_misc const * dialog();
///
void apply() const;
///
@ -314,7 +309,7 @@ private:
///
FormPreferences & parent_;
///
FD_form_inputs_misc * dialog_;
boost::scoped_ptr<FD_form_inputs_misc> dialog_;
};
///
friend class InputsMisc;
@ -323,11 +318,9 @@ private:
class Interface {
public:
///
Interface( FormPreferences & p ) : parent_(p), dialog_(0) {}
Interface( FormPreferences & p );
///
~Interface();
///
FD_form_interface const * dialog() { return dialog_; }
FD_form_interface const * dialog();
///
void apply() const;
///
@ -343,7 +336,7 @@ private:
///
FormPreferences & parent_;
///
FD_form_interface * dialog_;
boost::scoped_ptr<FD_form_interface> dialog_;
};
///
friend class Interface;
@ -352,12 +345,9 @@ private:
class Language {
public:
///
Language( FormPreferences & p )
: parent_(p), dialog_(0), combo_default_lang(0) {}
Language( FormPreferences & p );
///
~Language();
///
FD_form_language const * dialog() { return dialog_; }
FD_form_language const * dialog();
///
void apply(); // not const because calls update()
///
@ -375,9 +365,9 @@ private:
///
FormPreferences & parent_;
///
FD_form_language * dialog_;
boost::scoped_ptr<FD_form_language> dialog_;
///
Combox * combo_default_lang;
boost::scoped_ptr<Combox> combo_default_lang;
};
///
friend class Language;
@ -386,11 +376,9 @@ private:
class LnFmisc {
public:
///
LnFmisc( FormPreferences & p ) : parent_(p), dialog_(0) {}
LnFmisc( FormPreferences & p );
///
~LnFmisc();
///
FD_form_lnf_misc const * dialog() { return dialog_; }
FD_form_lnf_misc const * dialog();
///
void apply() const;
///
@ -404,7 +392,7 @@ private:
///
FormPreferences & parent_;
///
FD_form_lnf_misc * dialog_;
boost::scoped_ptr<FD_form_lnf_misc> dialog_;
};
///
friend class LnFmisc;
@ -413,11 +401,9 @@ private:
class OutputsMisc {
public:
///
OutputsMisc( FormPreferences & p ) : parent_(p), dialog_(0) {}
OutputsMisc( FormPreferences & p );
///
~OutputsMisc();
///
FD_form_outputs_misc const * dialog() { return dialog_; }
FD_form_outputs_misc const * dialog();
///
void apply() const;
///
@ -431,7 +417,7 @@ private:
///
FormPreferences & parent_;
///
FD_form_outputs_misc * dialog_;
boost::scoped_ptr<FD_form_outputs_misc> dialog_;
};
///
friend class OutputsMisc;
@ -440,11 +426,9 @@ private:
class Paths {
public:
///
Paths( FormPreferences & p ) : parent_(p), dialog_(0) {}
Paths( FormPreferences & p );
///
~Paths();
///
FD_form_paths const * dialog() { return dialog_; }
FD_form_paths const * dialog();
///
void apply();
///
@ -460,7 +444,7 @@ private:
///
FormPreferences & parent_;
///
FD_form_paths * dialog_;
boost::scoped_ptr<FD_form_paths> dialog_;
};
///
friend class Paths;
@ -469,11 +453,9 @@ private:
class Printer {
public:
///
Printer( FormPreferences & p ) : parent_(p), dialog_(0) {}
Printer( FormPreferences & p );
///
~Printer();
///
FD_form_printer const * dialog() { return dialog_; }
FD_form_printer const * dialog();
///
void apply() const;
///
@ -487,7 +469,7 @@ private:
///
FormPreferences & parent_;
///
FD_form_printer * dialog_;
boost::scoped_ptr<FD_form_printer> dialog_;
};
///
friend class Printer;
@ -496,11 +478,9 @@ private:
class ScreenFonts {
public:
///
ScreenFonts( FormPreferences & p ) : parent_(p), dialog_(0) {}
ScreenFonts( FormPreferences & p );
///
~ScreenFonts();
///
FD_form_screen_fonts const * dialog() { return dialog_; }
FD_form_screen_fonts const * dialog();
///
void apply() const;
///
@ -516,7 +496,7 @@ private:
///
FormPreferences & parent_;
///
FD_form_screen_fonts * dialog_;
boost::scoped_ptr<FD_form_screen_fonts> dialog_;
};
///
friend class ScreenFonts;
@ -525,11 +505,9 @@ private:
class SpellChecker {
public:
///
SpellChecker( FormPreferences & p ) : parent_(p), dialog_(0) {}
SpellChecker( FormPreferences & p );
///
~SpellChecker();
///
FD_form_spellchecker const * dialog() { return dialog_; }
FD_form_spellchecker const * dialog();
///
void apply(); // not const because calls update()!
///
@ -545,7 +523,7 @@ private:
///
FormPreferences & parent_;
///
FD_form_spellchecker * dialog_;
boost::scoped_ptr<FD_form_spellchecker> dialog_;
};
///
friend class SpellChecker;
@ -595,7 +573,15 @@ private:
///
RGBColor col;
};
/// The ButtonController
ButtonController<PreferencesPolicy, xformsBC> bc_;
};
inline
xformsBC & FormPreferences::bc()
{
return bc_;
}
#endif

View File

@ -36,8 +36,8 @@ using Liason::getPrinterParams;
using std::make_pair;
FormPrint::FormPrint(LyXView * lv, Dialogs * d)
: FormBaseBD(lv, d, _("Print"), new OkApplyCancelPolicy),
dialog_(0), target_(2), order_(2), which_(3)
: FormBaseBD(lv, d, _("Print")),
target_(2), order_(2), which_(3)
{
// let the dialog be shown
// This is a permanent connection so we won't bother
@ -46,25 +46,19 @@ FormPrint::FormPrint(LyXView * lv, Dialogs * d)
}
FormPrint::~FormPrint()
{
delete dialog_;
}
void FormPrint::build()
{
dialog_ = build_print();
dialog_.reset(build_print());
// Workaround dumb xforms sizing bug
minw_ = form()->w;
minh_ = form()->h;
// Manage the ok, apply and cancel/close buttons
bc_.setOK(dialog_->button_ok);
bc_.setApply(dialog_->button_apply);
bc_.setCancel(dialog_->button_cancel);
bc_.refresh();
bc().setOK(dialog_->button_ok);
bc().setApply(dialog_->button_apply);
bc().setCancel(dialog_->button_cancel);
bc().refresh();
// allow controlling of input and ok/apply (de)activation
fl_set_input_return(dialog_->input_printer,
@ -115,7 +109,8 @@ void FormPrint::build()
FL_FORM * FormPrint::form() const
{
if (dialog_) return dialog_->form;
if (dialog_.get())
return dialog_->form;
return 0;
}
@ -162,7 +157,7 @@ void FormPrint::apply()
void FormPrint::update()
{
if (dialog_
if (dialog_.get()
&& lv_->view()->available()) {
PrinterParams pp(getPrinterParams(lv_->buffer()));
@ -196,7 +191,7 @@ void FormPrint::update()
fl_set_input(dialog_->input_count,
tostr(pp.count_copies).c_str());
bc_.valid(true);
bc().valid(true);
}
}

View File

@ -17,13 +17,16 @@
#ifndef FORMPRINT_H
#define FORMPRINT_H
#include "FormBase.h"
#include "RadioButtonGroup.h"
#include <boost/smart_ptr.hpp>
#ifdef __GNUG__
#pragma interface
#endif
#include "FormBaseDeprecated.h"
#include "RadioButtonGroup.h"
#include "xformsBC.h"
class LyXView;
class Dialogs;
struct FD_form_print;
@ -35,10 +38,10 @@ class FormPrint : public FormBaseBD {
public:
/// #FormPrint x(LyXView ..., Dialogs ...);#
FormPrint(LyXView *, Dialogs *);
///
~FormPrint();
private:
/// Pointer to the actual instantiation of the ButtonController.
virtual xformsBC & bc();
/// Update the dialog.
virtual void update();
/// Apply from dialog
@ -56,13 +59,21 @@ private:
FD_form_print * build_print();
/// Real GUI implementation.
FD_form_print * dialog_;
boost::scoped_ptr<FD_form_print> dialog_;
/// print target
RadioButtonGroup target_;
/// page order
RadioButtonGroup order_;
/// which pages
RadioButtonGroup which_;
/// The ButtonController
ButtonController<OkApplyCancelPolicy, xformsBC> bc_;
};
inline
xformsBC & FormPrint::bc()
{
return bc_;
}
#endif

View File

@ -35,8 +35,8 @@ using std::vector;
bool saved_position;
FormRef::FormRef(LyXView * lv, Dialogs * d)
: FormCommand(lv, d, _("Reference"), new NoRepeatedApplyPolicy),
at_ref(false), dialog_(0)
: FormCommand(lv, d, _("Reference")),
at_ref(false)
{
// let the dialog be shown
// These are permanent connections so we won't bother
@ -46,15 +46,10 @@ FormRef::FormRef(LyXView * lv, Dialogs * d)
}
FormRef::~FormRef()
{
delete dialog_;
}
FL_FORM * FormRef::form() const
{
if (dialog_) return dialog_->form;
if (dialog_.get())
return dialog_->form;
return 0;
}
@ -68,7 +63,7 @@ void FormRef::disconnect()
void FormRef::build()
{
dialog_ = build_ref();
dialog_.reset(build_ref());
for (int i = 0; !InsetRef::types[i].latex_name.empty(); ++i)
fl_addto_choice(dialog_->type,
@ -82,15 +77,15 @@ void FormRef::build()
fl_deactivate_object(dialog_->ref);
// Manage the ok and cancel/close buttons
bc_.setOK(dialog_->button_ok);
bc_.setApply(dialog_->button_apply);
bc_.setCancel(dialog_->button_cancel);
bc_.setUndoAll(dialog_->button_restore);
bc_.refresh();
bc().setOK(dialog_->button_ok);
bc().setApply(dialog_->button_apply);
bc().setCancel(dialog_->button_cancel);
bc().setUndoAll(dialog_->button_restore);
bc().refresh();
#warning I had to uncomment this so the buttons could be disabled in update() (dekel)
//bc_.addReadOnly(dialog_->type);
//bc_.addReadOnly(dialog_->name);
//bc().addReadOnly(dialog_->type);
//bc().addReadOnly(dialog_->name);
}
@ -121,7 +116,7 @@ void FormRef::update()
refs = lv_->buffer()->getLabelList();
updateBrowser(refs);
bc_.readOnly(lv_->buffer()->isReadonly());
bc().readOnly(lv_->buffer()->isReadonly());
}

View File

@ -12,11 +12,15 @@
#ifndef FORMREF_H
#define FORMREF_H
#include <boost/smart_ptr.hpp>
#ifdef __GNUG__
#pragma interface
#endif
#include "FormInset.h"
#include "xformsBC.h"
struct FD_form_ref;
/** This class provides an XForms implementation of the FormRef Dialog.
@ -25,10 +29,9 @@ class FormRef : public FormCommand {
public:
///
FormRef(LyXView *, Dialogs *);
///
~FormRef();
///
private:
/// Pointer to the actual instantiation of the ButtonController.
virtual xformsBC & bc();
/// Disconnect signals. Also perform any necessary housekeeping.
virtual void disconnect();
@ -54,7 +57,15 @@ private:
std::vector<string> refs;
/// Real GUI implementation.
FD_form_ref * dialog_;
boost::scoped_ptr<FD_form_ref> dialog_;
/// The ButtonController
ButtonController<NoRepeatedApplyPolicy, xformsBC> bc_;
};
inline
xformsBC & FormRef::bc()
{
return bc_;
}
#endif

View File

@ -8,6 +8,10 @@
#include <config.h>
#ifdef __GNUG__
#pragma implementation
#endif
#include "FormSearch.h"
#include "form_search.h"
#include "gettext.h"
@ -25,8 +29,7 @@ using Liason::setMinibuffer;
FormSearch::FormSearch(LyXView * lv, Dialogs * d)
: FormBaseBD(lv, d, _("LyX: Find and Replace"), new NoRepeatedApplyReadOnlyPolicy),
dialog_(0)
: FormBaseBD(lv, d, _("LyX: Find and Replace"))
{
// let the popup be shown
// This is a permanent connection so we won't bother
@ -38,22 +41,16 @@ FormSearch::FormSearch(LyXView * lv, Dialogs * d)
}
FormSearch::~FormSearch()
{
delete dialog_;
}
FL_FORM * FormSearch::form() const
{
if (dialog_)
return dialog_->form;
if (dialog_.get())
return dialog_->form;
return 0;
}
void FormSearch::build()
{
dialog_ = build_search();
dialog_.reset(build_search());
// Workaround dumb xforms sizing bug
minw_ = form()->w;
minh_ = form()->h;
@ -68,7 +65,7 @@ void FormSearch::build()
void FormSearch::update()
{
if (!dialog_)
if (!dialog_.get())
return;
bc_.readOnly(lv_->buffer()->isReadonly());

View File

@ -9,7 +9,14 @@
#ifndef FORMSEARCH_H
#define FORMSEARCH_H
#include "FormBase.h"
#include <boost/smart_ptr.hpp>
#ifdef __GNUG__
#pragma interface
#endif
#include "FormBaseDeprecated.h"
#include "xformsBC.h"
struct FD_form_search;
class LyXView;
@ -19,40 +26,45 @@ class Dialogs;
*/
class FormSearch : public FormBaseBD {
public:
///
FormSearch(LyXView *, Dialogs *);
///
~FormSearch();
///
FormSearch(LyXView *, Dialogs *);
private:
/** Redraw the form (on receipt of a Signal indicating, for example,
* that the xform colours have been re-mapped).
*/
/// Pointer to the actual instantiation of the ButtonController.
virtual xformsBC & bc();
/// Filter the inputs
virtual bool input(FL_OBJECT *, long);
/// Filter the inputs
virtual bool input(FL_OBJECT *, long);
/// Build the popup
virtual void build();
/// Build the popup
virtual void build();
/// Update the popup
virtual void update();
/// Update the popup
virtual void update();
/// Searches occurance of string
/// if argument=true forward search otherwise backward search
void Find(bool const = true);
/// if argument=false replace once otherwise replace all
/// Replaces occurance of string
void Replace(bool const = false);
/// Searches occurance of string
/// if argument=true forward search otherwise backward search
void Find(bool const = true);
/// if argument=false replace once otherwise replace all
/// Replaces occurance of string
void Replace(bool const = false);
///
virtual FL_FORM * form() const;
///
virtual FL_FORM * form() const;
/// Typedefinitions from the fdesign produced Header file
FD_form_search * build_search();
/// Typedefinitions from the fdesign produced Header file
FD_form_search * build_search();
/// Real GUI implementation.
FD_form_search * dialog_;
/// Real GUI implementation.
boost::scoped_ptr<FD_form_search> dialog_;
/// The ButtonController
ButtonController<NoRepeatedApplyReadOnlyPolicy, xformsBC> bc_;
};
inline
xformsBC & FormSearch::bc()
{
return bc_;
}
#endif

View File

@ -38,25 +38,21 @@ extern "C" void C_FormSplashCB(FL_OBJECT * ob, long)
FormSplash * form = static_cast<FormSplash*>(ob->form->u_vdata);
form->hide();
}
FormSplash::FormSplash(LyXView *, Dialogs * d)
: dialog_(0), d_(d)
: d_(d)
{
c_ = d->showSplash.connect(slot(this, &FormSplash::show));
}
FormSplash::~FormSplash()
{
c_.disconnect();
delete dialog_;
}
void FormSplash::show()
{
if (!dialog_) {
if (!lyxrc.show_banner)
return;
if (!dialog_.get()) {
build();
fl_set_form_atclose(dialog_->form, C_FormSplashCloseCB, 0);
}
@ -78,21 +74,20 @@ void FormSplash::show()
void FormSplash::hide()
{
c_.disconnect();
if (dialog_->form && dialog_->form->visible)
fl_hide_form(dialog_->form);
d_->destroySplash();
}
void FormSplash::build()
{
if (!lyxrc.show_banner)
return;
string banner_file = LibFileSearch("images", "banner", "xpm");
if (banner_file.empty())
return;
dialog_ = build_splash();
dialog_.reset(build_splash());
// Workaround dumb xforms sizing bug
fl_set_form_minsize(dialog_->form, dialog_->form->w, dialog_->form->h);

View File

@ -10,10 +10,15 @@
#ifndef FORMSPLASH_H
#define FORMSPLASH_H
#include <boost/smart_ptr.hpp>
#ifdef __GNUG__
#pragma interface
#endif
#include "FormBaseDeprecated.h"
#include "xformsBC.h"
#include "DialogBase.h"
struct FD_form_splash;
@ -24,10 +29,9 @@ class LyXView;
*/
class FormSplash : public DialogBase {
public:
///
FormSplash(LyXView *, Dialogs *);
~FormSplash();
/// hide (and destroy) the dialog
void hide();
@ -40,7 +44,7 @@ private:
FD_form_splash * build_splash();
/// Real GUI implementation.
FD_form_splash * dialog_;
boost::scoped_ptr<FD_form_splash> dialog_;
/// our container
Dialogs * d_;
/// the show connection

View File

@ -14,6 +14,10 @@
#include <config.h>
#ifdef __GNUG__
#pragma implementation
#endif
#include "FormTabular.h"
#include "form_tabular.h"
#include "LyXView.h"
@ -24,9 +28,7 @@
FormTabular::FormTabular(LyXView * lv, Dialogs * d)
: FormInset(lv, d, _("Tabular Layout"), new OkCancelReadOnlyPolicy),
dialog_(0), tabular_options_(0), column_options_(0),
cell_options_(0), longtable_options_(0),
: FormInset(lv, d, _("Tabular Layout")),
inset_(0), actCell_(-1)
{
// let the dialog be shown
@ -37,16 +39,6 @@ FormTabular::FormTabular(LyXView * lv, Dialogs * d)
}
FormTabular::~FormTabular()
{
delete dialog_;
delete tabular_options_;
delete column_options_;
delete cell_options_;
delete longtable_options_;
}
void FormTabular::redraw()
{
if(form() && form()->visible)
@ -62,7 +54,8 @@ void FormTabular::redraw()
FL_FORM * FormTabular::form() const
{
if (dialog_) return dialog_->form;
if (dialog_.get())
return dialog_->form;
return 0;
}
@ -106,11 +99,11 @@ void FormTabular::updateInset(InsetTabular * inset)
void FormTabular::build()
{
dialog_ = build_tabular();
tabular_options_ = build_tabular_options();
column_options_ = build_column_options();
cell_options_ = build_cell_options();
longtable_options_ = build_longtable_options();
dialog_.reset(build_tabular());
tabular_options_.reset(build_tabular_options());
column_options_.reset(build_column_options());
cell_options_.reset(build_cell_options());
longtable_options_.reset(build_longtable_options());
// Workaround dumb xforms sizing bug
minw_ = form()->w;

View File

@ -15,7 +15,14 @@
#ifndef FORMTABULAR_H
#define FORMTABULAR_H
#include <boost/smart_ptr.hpp>
#ifdef __GNUG__
#pragma interface
#endif
#include "FormInset.h"
#include "xformsBC.h"
class InsetTabular;
struct FD_form_tabular;
@ -31,10 +38,10 @@ class FormTabular : public FormInset {
public:
/// #FormTabular x(LyXFunc ..., Dialogs ...);#
FormTabular(LyXView *, Dialogs *);
///
~FormTabular();
private:
/// Pointer to the actual instantiation of the ButtonController.
virtual xformsBC & bc();
/** Redraw the form (on receipt of a Signal indicating, for example,
that the xforms colours have been re-mapped). */
virtual void redraw();
@ -66,20 +73,28 @@ private:
FD_form_longtable_options * build_longtable_options();
/// Real GUI implementation.
FD_form_tabular * dialog_;
boost::scoped_ptr<FD_form_tabular> dialog_;
///
FD_form_tabular_options * tabular_options_;
boost::scoped_ptr<FD_form_tabular_options> tabular_options_;
///
FD_form_column_options * column_options_;
boost::scoped_ptr<FD_form_column_options> column_options_;
///
FD_form_cell_options * cell_options_;
boost::scoped_ptr<FD_form_cell_options> cell_options_;
///
FD_form_longtable_options * longtable_options_;
boost::scoped_ptr<FD_form_longtable_options> longtable_options_;
/// pointer to the inset passed through showInset
InsetTabular * inset_;
///
int actCell_;
/// The ButtonController
ButtonController<OkCancelReadOnlyPolicy, xformsBC> bc_;
};
inline
xformsBC & FormTabular::bc()
{
return bc_;
}
#endif

View File

@ -28,9 +28,7 @@
#include "support/lstrings.h"
FormTabularCreate::FormTabularCreate(LyXView * lv, Dialogs * d)
: FormBaseBD(lv, d, _("Insert Tabular"),
new OkApplyCancelReadOnlyPolicy),
dialog_(0)
: FormBaseBD(lv, d, _("Insert Tabular"))
{
// let the dialog be shown
// This is a permanent connection so we won't bother
@ -39,29 +37,24 @@ FormTabularCreate::FormTabularCreate(LyXView * lv, Dialogs * d)
}
FormTabularCreate::~FormTabularCreate()
{
delete dialog_;
}
FL_FORM * FormTabularCreate::form() const
{
if (dialog_) return dialog_->form;
if (dialog_.get())
return dialog_->form;
return 0;
}
void FormTabularCreate::connect()
{
bc_.valid(true);
bc().valid(true);
FormBaseBD::connect();
}
void FormTabularCreate::build()
{
dialog_ = build_tabular_create();
dialog_.reset(build_tabular_create());
// Workaround dumb xforms sizing bug
minw_ = form()->w;
@ -75,10 +68,10 @@ void FormTabularCreate::build()
fl_set_slider_precision(dialog_->slider_columns, 0);
// Manage the ok, apply and cancel/close buttons
bc_.setOK(dialog_->button_ok);
bc_.setApply(dialog_->button_apply);
bc_.setCancel(dialog_->button_cancel);
bc_.refresh();
bc().setOK(dialog_->button_ok);
bc().setApply(dialog_->button_apply);
bc().setCancel(dialog_->button_cancel);
bc().refresh();
}
@ -94,5 +87,5 @@ void FormTabularCreate::apply()
void FormTabularCreate::update()
{
bc_.readOnly(lv_->buffer()->isReadonly());
bc().readOnly(lv_->buffer()->isReadonly());
}

View File

@ -15,12 +15,15 @@
#ifndef FORMTABULARCREATE_H
#define FORMTABULARCREATE_H
#include "FormBase.h"
#include <boost/smart_ptr.hpp>
#ifdef __GNUG__
#pragma interface
#endif
#include "FormBaseDeprecated.h"
#include "xformsBC.h"
class LyXView;
class Dialogs;
struct FD_form_tabular_create;
@ -32,10 +35,10 @@ class FormTabularCreate : public FormBaseBD {
public:
/// #FormTabularCreate x(LyXView ..., Dialogs ...);#
FormTabularCreate(LyXView *, Dialogs *);
///
~FormTabularCreate();
private:
/// Pointer to the actual instantiation of the ButtonController.
virtual xformsBC & bc();
/// Connect signals etc.
virtual void connect();
@ -52,7 +55,15 @@ private:
FD_form_tabular_create * build_tabular_create();
/// Real GUI implementation.
FD_form_tabular_create * dialog_;
boost::scoped_ptr<FD_form_tabular_create> dialog_;
/// The ButtonController
ButtonController<OkApplyCancelReadOnlyPolicy, xformsBC> bc_;
};
inline
xformsBC & FormTabularCreate::bc()
{
return bc_;
}
#endif

View File

@ -27,12 +27,14 @@
#include "lyxfunc.h"
#include "support/lstrings.h"
using std::vector;
// The current code uses the apply() for handling the Update button and the
// type-of-table selection and cancel() for the close button. This is a little
// confusing to the button controller so I've made an IgnorantPolicy to cover
// this situation since the dialog doesn't care about buttons. ARRae 20001013
FormToc::FormToc(LyXView * lv, Dialogs * d)
: FormCommand(lv, d, _("Table of Contents"), new OkCancelPolicy),
: FormCommand(lv, d, _("Table of Contents")),
dialog_(0)
{
// let the dialog be shown
@ -43,15 +45,10 @@ FormToc::FormToc(LyXView * lv, Dialogs * d)
}
FormToc::~FormToc()
{
delete dialog_;
}
FL_FORM * FormToc::form() const
{
if (dialog_ ) return dialog_->form;
if (dialog_.get())
return dialog_->form;
return 0;
}
@ -65,7 +62,7 @@ void FormToc::disconnect()
void FormToc::build()
{
dialog_ = build_toc();
dialog_.reset(build_toc());
#if 0
fl_addto_choice(dialog_->choice_toc_type,
@ -85,8 +82,8 @@ void FormToc::build()
minh_ = form()->h;
// Manage the cancel/close button
bc_.setCancel(dialog_->button_cancel);
bc_.refresh();
bc().setCancel(dialog_->button_cancel);
bc().refresh();
}

View File

@ -12,12 +12,16 @@
#ifndef FORMTOC_H
#define FORMTOC_H
#include <boost/smart_ptr.hpp>
#ifdef __GNUG__
#pragma interface
#endif
#include "FormInset.h"
#include "buffer.h"
#include "xformsBC.h"
struct FD_form_toc;
/** This class provides an XForms implementation of the FormToc Dialog.
@ -26,9 +30,9 @@ class FormToc : public FormCommand {
public:
///
FormToc(LyXView *, Dialogs *);
///
~FormToc();
private:
/// Pointer to the actual instantiation of the ButtonController.
virtual xformsBC & bc();
/// Disconnect signals. Also perform any necessary housekeeping.
virtual void disconnect();
@ -47,10 +51,18 @@ private:
///
FD_form_toc * build_toc();
/// Real GUI implementation.
FD_form_toc * dialog_;
///
Buffer::SingleList toclist;
/// Real GUI implementation.
boost::scoped_ptr<FD_form_toc> dialog_;
/// The ButtonController
ButtonController<OkCancelPolicy, xformsBC> bc_;
};
inline
xformsBC & FormToc::bc()
{
return bc_;
}
#endif

View File

@ -17,7 +17,6 @@
#pragma implementation
#endif
#include "Dialogs.h"
#include "FormUrl.h"
#include "LyXView.h"
@ -26,8 +25,7 @@
#include "lyxfunc.h"
FormUrl::FormUrl(LyXView * lv, Dialogs * d)
: FormCommand(lv, d, _("Url"), new NoRepeatedApplyReadOnlyPolicy),
dialog_(0)
: FormCommand(lv, d, _("Url"))
{
// let the dialog be shown
// These are permanent connections so we won't bother
@ -37,15 +35,9 @@ FormUrl::FormUrl(LyXView * lv, Dialogs * d)
}
FormUrl::~FormUrl()
{
delete dialog_;
}
FL_FORM * FormUrl::form() const
{
if (dialog_) return dialog_->form;
if (dialog_.get()) return dialog_->form;
return 0;
}
@ -59,7 +51,7 @@ void FormUrl::connect()
void FormUrl::build()
{
dialog_ = build_url();
dialog_.reset(build_url());
// Workaround dumb xforms sizing bug
minw_ = form()->w;
@ -69,15 +61,15 @@ void FormUrl::build()
fl_set_input_return(dialog_->url, FL_RETURN_CHANGED);
// Manage the ok, apply, restore and cancel/close buttons
bc_.setOK(dialog_->button_ok);
bc_.setApply(dialog_->button_apply);
bc_.setCancel(dialog_->button_cancel);
bc_.setUndoAll(dialog_->button_restore);
bc_.refresh();
bc().setOK(dialog_->button_ok);
bc().setApply(dialog_->button_apply);
bc().setCancel(dialog_->button_cancel);
bc().setUndoAll(dialog_->button_restore);
bc().refresh();
bc_.addReadOnly(dialog_->name);
bc_.addReadOnly(dialog_->url);
bc_.addReadOnly(dialog_->radio_html);
bc().addReadOnly(dialog_->name);
bc().addReadOnly(dialog_->url);
bc().addReadOnly(dialog_->radio_html);
}
@ -91,7 +83,7 @@ void FormUrl::update()
else
fl_set_button(dialog_->radio_html, 1);
bc_.readOnly(lv_->buffer()->isReadonly());
bc().readOnly(lv_->buffer()->isReadonly());
}

View File

@ -12,11 +12,15 @@
#ifndef FORMURL_H
#define FORMURL_H
#include <boost/smart_ptr.hpp>
#ifdef __GNUG__
#pragma interface
#endif
#include "FormInset.h"
#include "xformsBC.h"
struct FD_form_url;
/** This class provides an XForms implementation of the FormUrl Dialog.
@ -25,9 +29,9 @@ class FormUrl : public FormCommand {
public:
///
FormUrl(LyXView *, Dialogs *);
///
~FormUrl();
private:
/// Pointer to the actual instantiation of the ButtonController.
virtual xformsBC & bc();
/// Connect signals etc. Set form's max size.
virtual void connect();
/// Build the dialog
@ -41,7 +45,15 @@ private:
///
FD_form_url * build_url();
/// Real GUI implementation.
FD_form_url * dialog_;
boost::scoped_ptr<FD_form_url> dialog_;
/// The ButtonController
ButtonController<NoRepeatedApplyReadOnlyPolicy, xformsBC> bc_;
};
inline
xformsBC & FormUrl::bc()
{
return bc_;
}
#endif

Some files were not shown because too many files have changed in this diff Show More