mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-10 20:04:46 +00:00
Reorganised, cleaned-up and improved documentation of controllers.
Implemented controller-view split for Copyright and Credits popups. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1803 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
540ecf3e20
commit
8a4455d459
@ -1,5 +1,7 @@
|
||||
// -*- C++ -*-
|
||||
/* This file is part of
|
||||
/*
|
||||
* \file ButtonController.h
|
||||
*
|
||||
* This file is part of
|
||||
* ======================================================
|
||||
*
|
||||
* LyX, The Document Processor
|
||||
@ -8,8 +10,7 @@
|
||||
*
|
||||
* ======================================================
|
||||
*
|
||||
* \file ButtonController.h
|
||||
* \author Allan Rae
|
||||
* \author Allan Rae, rae@lyx.org
|
||||
*/
|
||||
|
||||
#ifndef BUTTONCONTROLLER_H
|
||||
|
@ -1,8 +1,10 @@
|
||||
// -*- C++ -*-
|
||||
/* ButtonPolicies.h
|
||||
/*
|
||||
* \file ButtonPolicies.h
|
||||
* \author Allan Rae, rae@lyx.org
|
||||
*
|
||||
* 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
|
||||
* ======================================================
|
||||
*
|
||||
|
@ -1,3 +1,50 @@
|
||||
2001-03-22 Angus Leeming <a.leeming@ic.ac.uk>
|
||||
|
||||
* lots of header files: improved explanatory notes.
|
||||
|
||||
* ControlBase.[Ch]: removed LyXView & lv_ and methods using it.
|
||||
ControlBase is now a class that only controls the interaction of the
|
||||
View with the ButtonController.
|
||||
|
||||
* ControlConnections.[Ch]: added LyXView & lv_ and associated methods
|
||||
to ControlConnectBase. The class controls the connection/disconnection
|
||||
of signals from the LyX kernel and makes available the kernel (through
|
||||
lv_) to daughter controller classes.
|
||||
Moved out class ControlConnectInset to a new file ControlDialogs.h.
|
||||
|
||||
* ControlDialogs.h: new file. Contains the definition of two template
|
||||
controller classes, ControlDialog and ControlInset (was
|
||||
ControlConnectInset). ControlInset is a parent class for controllers
|
||||
of inset-popups. ControlDialogs is the rather uninspired name for
|
||||
the base class of all non-inset popups. (Eg, Document and Paragraph.)
|
||||
ControlDialogs is reaching a state of maturity as several popups now use
|
||||
it and its functionality becomes clear. ControlInset is still in a state
|
||||
of flux. It is likely that functionality will be moved out of
|
||||
ControlCommands and into it.
|
||||
|
||||
* GUI.h: new file. Moved all the template GUIXXX classes out of the
|
||||
individual Controller header files and into one place. These classes
|
||||
serve only as convenient wrappers to simplify code in the respective
|
||||
frontends' Dialogs::c-tor. Now all derived from a templatised parent.
|
||||
|
||||
* ControlCharacter.[Ch] (show, update, hide):
|
||||
* ControlLog.[Ch] (show, update, hide):
|
||||
* ControlVCLog.[Ch] (show, update, hide): moved back into
|
||||
the ControlDialogs base class.
|
||||
(setParams, clearParams): new methods containing controller-specific
|
||||
code to set/reset the parameters manipulated by the view.
|
||||
|
||||
* ControlCommand.[Ch] (clearParams): a new virtual method, by default
|
||||
empty.
|
||||
(hide): calls clearParams.
|
||||
|
||||
* ControlCitation.[Ch] (hide): renamed as clearParams, a method called
|
||||
by ControlCommand::hide().
|
||||
|
||||
* ControlCopyright.[Ch]:
|
||||
* ControlCredits.[Ch]: new files; controllers for the copyright and
|
||||
credits popups, respectively.
|
||||
|
||||
2001-03-21 Lars Gullik Bjønnes <larsbj@trylle.birdstep.com>
|
||||
|
||||
* ControlCharacter.C: fix typo
|
||||
|
@ -18,11 +18,8 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "buffer.h"
|
||||
#include "ButtonController.h"
|
||||
#include "ControlBase.h"
|
||||
#include "LyXView.h"
|
||||
#include "support/LAssert.h"
|
||||
|
||||
void ControlBase::ApplyButton()
|
||||
{
|
||||
@ -51,9 +48,3 @@ void ControlBase::RestoreButton()
|
||||
update();
|
||||
bc().undoAll();
|
||||
}
|
||||
|
||||
|
||||
bool ControlBase::isReadonly() const
|
||||
{
|
||||
return lv_.buffer()->isReadonly();
|
||||
}
|
||||
|
@ -1,4 +1,3 @@
|
||||
// -*- C++ -*-
|
||||
/* This file is part of
|
||||
* ======================================================
|
||||
*
|
||||
@ -11,11 +10,17 @@
|
||||
* \file ControlBase.h
|
||||
* \author Angus Leeming <a.leeming@ic.ac.uk>
|
||||
*
|
||||
* The Controller connects the GUI-dependent popup to any appropriate
|
||||
* ControlBase serves only to control the activation of the Ok, Apply, Cancel
|
||||
* and Restore buttons on the View popup.
|
||||
*
|
||||
* More generally, the class is part of a hierarchy of controller classes
|
||||
* that together connect 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
|
||||
*
|
||||
* These controllers have 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.
|
||||
*/
|
||||
@ -30,8 +35,6 @@
|
||||
#include "DialogBase.h" // This can go eventually
|
||||
#include "ButtonController.h"
|
||||
|
||||
class Dialogs;
|
||||
class LyXView;
|
||||
class ViewBase;
|
||||
|
||||
/** Abstract base class for Controllers with a ButtonController.
|
||||
@ -40,7 +43,7 @@ class ControlBase : public DialogBase
|
||||
{
|
||||
public: // methods
|
||||
///
|
||||
ControlBase(LyXView & lv) : lv_(lv) {}
|
||||
ControlBase() {}
|
||||
///
|
||||
virtual ~ControlBase() {};
|
||||
|
||||
@ -54,9 +57,6 @@ public: // methods
|
||||
///
|
||||
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. */
|
||||
@ -74,9 +74,6 @@ protected:
|
||||
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_;
|
||||
};
|
||||
|
||||
#include "ViewBase.h"
|
||||
|
@ -35,30 +35,4 @@ protected:
|
||||
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
|
||||
|
@ -35,30 +35,4 @@ protected:
|
||||
virtual void apply();
|
||||
};
|
||||
|
||||
/** This class instantiates and makes available the GUI-specific
|
||||
ButtonController and View.
|
||||
*/
|
||||
template <class GUIview, class GUIbc>
|
||||
class GUIBibtex : public ControlBibtex {
|
||||
public:
|
||||
///
|
||||
GUIBibtex(LyXView &, Dialogs &);
|
||||
///
|
||||
virtual ButtonControllerBase & bc() { return bc_; }
|
||||
///
|
||||
virtual ViewBase & view() { return view_; }
|
||||
|
||||
private:
|
||||
///
|
||||
ButtonController<OkCancelReadOnlyPolicy, GUIbc> bc_;
|
||||
///
|
||||
GUIview view_;
|
||||
};
|
||||
|
||||
template <class GUIview, class GUIbc>
|
||||
GUIBibtex<GUIview, GUIbc>::GUIBibtex(LyXView & lv, Dialogs & d)
|
||||
: ControlBibtex(lv, d),
|
||||
view_(*this)
|
||||
{}
|
||||
|
||||
#endif // CONTROLBIBTEX_H
|
||||
|
@ -28,46 +28,27 @@ using SigC::slot;
|
||||
using std::vector;
|
||||
|
||||
ControlCharacter::ControlCharacter(LyXView & lv, Dialogs & d)
|
||||
: ControlConnectBD(lv, d), font_(0), toggleall_(false)
|
||||
: ControlDialog<ControlConnectBD>(lv, d),
|
||||
font_(0), toggleall_(false)
|
||||
{
|
||||
d.showLayoutCharacter.connect(slot(this, &ControlCharacter::show));
|
||||
d.setUserFreeFont.connect(slot(this, &ControlCharacter::apply));
|
||||
}
|
||||
|
||||
|
||||
void ControlCharacter::show()
|
||||
void ControlCharacter::setParams()
|
||||
{
|
||||
if (!lv_.view()->available()) return;
|
||||
|
||||
if (font_) delete font_;
|
||||
font_ = new LyXFont(LyXFont::ALL_IGNORE);
|
||||
|
||||
bc().readOnly(isReadonly());
|
||||
view().show();
|
||||
}
|
||||
|
||||
|
||||
void ControlCharacter::update()
|
||||
{
|
||||
if (!lv_.view()->available()) return;
|
||||
|
||||
if (font_) delete font_;
|
||||
font_ = new LyXFont(LyXFont::ALL_IGNORE);
|
||||
|
||||
bc().readOnly(isReadonly());
|
||||
view().update();
|
||||
}
|
||||
|
||||
|
||||
void ControlCharacter::hide()
|
||||
void ControlCharacter::clearParams()
|
||||
{
|
||||
if (font_) {
|
||||
delete font_;
|
||||
font_ = 0;
|
||||
}
|
||||
|
||||
disconnect();
|
||||
view().hide();
|
||||
}
|
||||
|
||||
|
||||
|
@ -13,13 +13,13 @@
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include "ControlConnections.h"
|
||||
#include "ControlDialogs.h"
|
||||
#include "lyxfont.h"
|
||||
#include "LColor.h"
|
||||
|
||||
/** A controller for Character dialogs.
|
||||
*/
|
||||
class ControlCharacter : public ControlConnectBD
|
||||
class ControlCharacter : public ControlDialog<ControlConnectBD>
|
||||
{
|
||||
public:
|
||||
///
|
||||
@ -74,12 +74,10 @@ public:
|
||||
protected:
|
||||
/// Get changed parameters and Dispatch them to the kernel.
|
||||
virtual void apply();
|
||||
/// Show the dialog.
|
||||
virtual void show();
|
||||
/// Update the dialog.
|
||||
virtual void update();
|
||||
/// Hide the dialog.
|
||||
virtual void hide();
|
||||
/// set the params before show or update.
|
||||
virtual void setParams();
|
||||
/// clean-up on hide.
|
||||
virtual void clearParams();
|
||||
|
||||
private:
|
||||
LyXFont * font_;
|
||||
@ -101,30 +99,4 @@ std::vector<ControlCharacter::ColorPair> const getColorData();
|
||||
///
|
||||
std::vector<string> const getLanguageData();
|
||||
|
||||
/** This class instantiates and makes available the GUI-specific
|
||||
ButtonController and View.
|
||||
*/
|
||||
template <class GUIview, class GUIbc>
|
||||
class GUICharacter : public ControlCharacter {
|
||||
public:
|
||||
///
|
||||
GUICharacter(LyXView &, Dialogs &);
|
||||
///
|
||||
virtual ButtonControllerBase & bc() { return bc_; }
|
||||
///
|
||||
virtual ViewBase & view() { return view_; }
|
||||
|
||||
private:
|
||||
///
|
||||
ButtonController<NoRepeatedApplyReadOnlyPolicy, GUIbc> bc_;
|
||||
///
|
||||
GUIview view_;
|
||||
};
|
||||
|
||||
template <class GUIview, class GUIbc>
|
||||
GUICharacter<GUIview, GUIbc>::GUICharacter(LyXView & lv, Dialogs & d)
|
||||
: ControlCharacter(lv, d),
|
||||
view_(*this)
|
||||
{}
|
||||
|
||||
#endif // CONTROLCHARACTER_H
|
||||
|
@ -45,10 +45,9 @@ ControlCitation::ControlCitation(LyXView & lv, Dialogs & d)
|
||||
}
|
||||
|
||||
|
||||
void ControlCitation::hide()
|
||||
void ControlCitation::clearParams()
|
||||
{
|
||||
bibkeysInfo_.clear();
|
||||
ControlCommand::hide();
|
||||
}
|
||||
|
||||
|
||||
|
@ -56,38 +56,11 @@ public:
|
||||
string const getBibkeyInfo(string const &);
|
||||
private:
|
||||
/// Clean up, then hide dialog.
|
||||
virtual void hide();
|
||||
virtual void clearParams();
|
||||
/// 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
|
||||
*/
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include "support/LAssert.h"
|
||||
|
||||
ControlCommand::ControlCommand(LyXView & lv, Dialogs & d, kb_action ac)
|
||||
: ControlConnectInset<InsetCommand>(lv, d),
|
||||
: ControlInset<InsetCommand>(lv, d),
|
||||
params_(0), action_(ac)
|
||||
{}
|
||||
|
||||
@ -84,6 +84,8 @@ void ControlCommand::hide()
|
||||
params_ = 0;
|
||||
}
|
||||
|
||||
clearParams();
|
||||
|
||||
disconnect();
|
||||
view().hide();
|
||||
}
|
||||
|
@ -11,10 +11,13 @@
|
||||
* \file ControlCommand.h
|
||||
* \author Angus Leeming <a.leeming@ic.ac.uk>
|
||||
*
|
||||
* Defines a Controller class for dialogs that create or modify
|
||||
* ControlCommand is 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.
|
||||
*
|
||||
* The class is likely to be changed as other Inset controllers are created
|
||||
* and it becomes clear just what functionality can be moved back into
|
||||
* ControlInset.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CONTROLCOMMAND_H
|
||||
@ -24,14 +27,14 @@
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include "ControlConnections.h"
|
||||
#include "ControlDialogs.h"
|
||||
#include "insets/insetcommand.h"
|
||||
#include "commandtags.h" // kb_action
|
||||
|
||||
/** 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>
|
||||
class ControlCommand : public ControlInset<InsetCommand>
|
||||
{
|
||||
public:
|
||||
///
|
||||
@ -58,6 +61,10 @@ protected:
|
||||
/// Update dialog before showing it.
|
||||
virtual void update();
|
||||
|
||||
/// clean-up on hide.
|
||||
virtual void clearParams() {}
|
||||
|
||||
|
||||
private:
|
||||
/** A local copy of the inset's params.
|
||||
Memory is allocated only whilst the dialog is visible.
|
||||
|
@ -20,13 +20,13 @@
|
||||
|
||||
#include "ControlConnections.h"
|
||||
#include "Dialogs.h"
|
||||
#include "insets/lyxinset.h"
|
||||
#include "LyXView.h"
|
||||
#include "buffer.h"
|
||||
|
||||
using SigC::slot;
|
||||
|
||||
ControlConnectBase::ControlConnectBase(LyXView & lv, Dialogs & d)
|
||||
: ControlBase(lv),
|
||||
d_(d), h_(0), r_(0)
|
||||
: lv_(lv), d_(d), h_(0), r_(0)
|
||||
{}
|
||||
|
||||
|
||||
@ -49,6 +49,15 @@ void ControlConnectBase::redraw()
|
||||
}
|
||||
|
||||
|
||||
bool ControlConnectBase::isReadonly() const
|
||||
{
|
||||
if (!lv_.buffer())
|
||||
return true;
|
||||
|
||||
return lv_.buffer()->isReadonly();
|
||||
}
|
||||
|
||||
|
||||
ControlConnectBI::ControlConnectBI(LyXView & lv, Dialogs & d)
|
||||
: ControlConnectBase(lv, d)
|
||||
{}
|
||||
|
@ -1,4 +1,3 @@
|
||||
// -*- C++ -*-
|
||||
/* This file is part of
|
||||
* ======================================================
|
||||
*
|
||||
@ -10,6 +9,22 @@
|
||||
*
|
||||
* \file ControlConnections.h
|
||||
* \author Angus Leeming <a.leeming@ic.ac.uk>
|
||||
*
|
||||
* ControlConnections.h contains the definition of three controller classes,
|
||||
* ControlConnectBase, ControlConnectBI and ControlConnectBD.
|
||||
*
|
||||
* Together they control the connection/disconnection of signals with the LyX
|
||||
* kernel. Controllers of individual popups interacting with the kernel through
|
||||
* signals/slots will all be derived from ControlConnectBI or ControlConnectBD.
|
||||
*
|
||||
* A popup is classed as "Buffer Dependent" if its contents change with the
|
||||
* buffer (document). An example would be the Citation popup. Such a popup
|
||||
* would be derived, therefore, from ControlConnectBD.
|
||||
*
|
||||
* Conversely, a popup is "Buffer Independent" if its contents do not change
|
||||
* when the buffer changes. An example would be the Copyright popup. Such a
|
||||
* popup, is therefore derived from ControlConnectBI.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CONTROLCONNECTIONS_H
|
||||
@ -21,6 +36,9 @@
|
||||
|
||||
#include "ControlBase.h"
|
||||
|
||||
class Dialogs;
|
||||
class LyXView;
|
||||
|
||||
/** 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.
|
||||
@ -30,8 +48,13 @@ class ControlConnectBase : public ControlBase
|
||||
public:
|
||||
///
|
||||
ControlConnectBase(LyXView &, Dialogs &);
|
||||
/// The View may need to know if the buffer is read-only.
|
||||
bool isReadonly() const;
|
||||
|
||||
protected:
|
||||
/// True if the dialog depends on the buffer, else false.
|
||||
virtual bool isBufferDependent() const = 0;
|
||||
|
||||
/// Connect signals
|
||||
virtual void connect();
|
||||
/// Disconnect signals
|
||||
@ -42,6 +65,8 @@ protected:
|
||||
*/
|
||||
void redraw();
|
||||
|
||||
/// Get at the kernel Dispatch methods we need to apply() parameters.
|
||||
LyXView & lv_;
|
||||
/// Contains the signals we have to connect to.
|
||||
Dialogs & d_;
|
||||
/// Hide connection.
|
||||
@ -64,6 +89,8 @@ public:
|
||||
ControlConnectBI(LyXView &, Dialogs &);
|
||||
|
||||
protected:
|
||||
///
|
||||
virtual bool isBufferDependent() const { return false; }
|
||||
/// Connect signals
|
||||
virtual void connect();
|
||||
};
|
||||
@ -79,6 +106,8 @@ public:
|
||||
ControlConnectBD(LyXView &, Dialogs &);
|
||||
|
||||
protected:
|
||||
///
|
||||
virtual bool isBufferDependent() const { return true; }
|
||||
/** Slot connected to update signal.
|
||||
Bool indicates if a buffer switch took place.
|
||||
Default behaviour is to ignore this and simply update().
|
||||
@ -94,87 +123,4 @@ private:
|
||||
SigC::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.
|
||||
SigC::Connection ih_;
|
||||
};
|
||||
|
||||
|
||||
template <class Inset>
|
||||
ControlConnectInset<Inset>::ControlConnectInset(LyXView & lv, Dialogs & d)
|
||||
: ControlConnectBD(lv, d),
|
||||
inset_(0), ih_(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(
|
||||
SigC::slot(this, &ControlConnectInset::hide));
|
||||
}
|
||||
connect();
|
||||
}
|
||||
|
||||
|
||||
template <class Inset>
|
||||
void ControlConnectInset<Inset>::disconnectInset()
|
||||
{
|
||||
ih_.disconnect();
|
||||
}
|
||||
|
||||
|
||||
#endif // CONTROLCONNECTIONS_H
|
||||
|
43
src/frontends/controllers/ControlCopyright.C
Normal file
43
src/frontends/controllers/ControlCopyright.C
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* \file ControlCopyright.C
|
||||
* Copyright 2000-2001 The LyX Team.
|
||||
* See the file COPYING.
|
||||
*
|
||||
* \author Allan Rae
|
||||
* \author Angus Leeming, a.leeming@.ac.uk
|
||||
*/
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation
|
||||
#endif
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "ControlCopyright.h"
|
||||
#include "Dialogs.h"
|
||||
#include "LyXView.h"
|
||||
#include "BufferView.h"
|
||||
|
||||
using SigC::slot;
|
||||
|
||||
ControlCopyright::ControlCopyright(LyXView & lv, Dialogs & d)
|
||||
: ControlDialog<ControlConnectBI>(lv, d)
|
||||
{
|
||||
d_.showCopyright.connect(slot(this, &ControlCopyright::show));
|
||||
}
|
||||
|
||||
|
||||
string const ControlCopyright::getCopyright() const
|
||||
{
|
||||
return _("LyX is Copyright (C) 1995 by Matthias Ettrich,\n1995-2001 LyX Team");
|
||||
}
|
||||
|
||||
string const ControlCopyright::getLicence() const
|
||||
{
|
||||
return _("This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.");
|
||||
}
|
||||
|
||||
string const ControlCopyright::getDisclaimer() const
|
||||
{
|
||||
return _("LyX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\nSee the GNU General Public License for more details.\nYou should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.");
|
||||
}
|
64
src/frontends/controllers/ControlCopyright.h
Normal file
64
src/frontends/controllers/ControlCopyright.h
Normal file
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* \file ControlCopyright.C
|
||||
* Copyright 2000-2001 The LyX Team.
|
||||
* See the file COPYING.
|
||||
*
|
||||
* \author Allan Rae
|
||||
* \author Angus Leeming, a.leeming@.ac.uk
|
||||
*/
|
||||
|
||||
#ifndef CONTROLCOPYRIGHT_H
|
||||
#define CONTROLCOPYRIGHT_H
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include "ControlDialogs.h"
|
||||
|
||||
/** A controller for Copyright dialogs.
|
||||
*/
|
||||
class ControlCopyright : public ControlDialog<ControlConnectBI> {
|
||||
public:
|
||||
///
|
||||
ControlCopyright(LyXView &, Dialogs &);
|
||||
|
||||
///
|
||||
string const getCopyright() const;
|
||||
///
|
||||
string const getLicence() const;
|
||||
///
|
||||
string const getDisclaimer() const;
|
||||
|
||||
private:
|
||||
/// not needed.
|
||||
virtual void apply() {}
|
||||
};
|
||||
|
||||
/** This class instantiates and makes available the GUI-specific
|
||||
ButtonController and View.
|
||||
*/
|
||||
template <class GUIview, class GUIbc>
|
||||
class GUICopyright : public ControlCopyright {
|
||||
public:
|
||||
///
|
||||
GUICopyright(LyXView &, Dialogs &);
|
||||
///
|
||||
virtual ButtonControllerBase & bc() { return bc_; }
|
||||
///
|
||||
virtual ViewBase & view() { return view_; }
|
||||
|
||||
private:
|
||||
///
|
||||
ButtonController<OkCancelPolicy, GUIbc> bc_;
|
||||
///
|
||||
GUIview view_;
|
||||
};
|
||||
|
||||
template <class GUIview, class GUIbc>
|
||||
GUICopyright<GUIview, GUIbc>::GUICopyright(LyXView & lv, Dialogs & d)
|
||||
: ControlCopyright(lv, d),
|
||||
view_(*this)
|
||||
{}
|
||||
#endif // CONTROLCOPYRIGHT_H
|
||||
|
72
src/frontends/controllers/ControlCredits.C
Normal file
72
src/frontends/controllers/ControlCredits.C
Normal file
@ -0,0 +1,72 @@
|
||||
/**
|
||||
* \file ControlCredits.C
|
||||
* Copyright 2001 The LyX Team.
|
||||
* See the file COPYING.
|
||||
*
|
||||
* \author Edwin Leuven, leuven@fee.uva.nl
|
||||
* \author Angus Leeming, a.leeming@.ac.uk
|
||||
*/
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation
|
||||
#endif
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "ControlCredits.h"
|
||||
#include "Dialogs.h"
|
||||
#include "LyXView.h"
|
||||
#include "BufferView.h"
|
||||
#include "gettext.h"
|
||||
#include "support/filetools.h" // FileSearch
|
||||
|
||||
using SigC::slot;
|
||||
using std::getline;
|
||||
using std::ifstream;
|
||||
using std::ios_base;
|
||||
using std::vector;
|
||||
|
||||
ControlCredits::ControlCredits(LyXView & lv, Dialogs & d)
|
||||
: ControlDialog<ControlConnectBI>(lv, d)
|
||||
{
|
||||
d_.showCredits.connect(slot(this, &ControlCredits::show));
|
||||
}
|
||||
|
||||
|
||||
// needed for the browser
|
||||
extern string system_lyxdir;
|
||||
|
||||
vector<string> const ControlCredits::getCredits() const
|
||||
{
|
||||
vector<string> data;
|
||||
|
||||
string const name = FileSearch(system_lyxdir, "CREDITS");
|
||||
|
||||
bool found = (!name.empty());
|
||||
|
||||
if (found) {
|
||||
ifstream in(name.c_str());
|
||||
found = (in.get());
|
||||
|
||||
if (found) {
|
||||
in.seekg(0, ios_base::beg); // rewind to the beginning
|
||||
|
||||
for(;;) {
|
||||
string line;
|
||||
getline(in, line);
|
||||
if (!in.good()) break;
|
||||
data.push_back(line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
data.push_back(_("ERROR: LyX wasn't able to read CREDITS file"));
|
||||
data.push_back(_("Please install correctly to estimate the great"));
|
||||
data.push_back(_("amount of work other people have done for the LyX project."));
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
37
src/frontends/controllers/ControlCredits.h
Normal file
37
src/frontends/controllers/ControlCredits.h
Normal file
@ -0,0 +1,37 @@
|
||||
/**
|
||||
* \file ControlCredits.h
|
||||
* Copyright 2001 The LyX Team.
|
||||
* See the file COPYING.
|
||||
*
|
||||
* \author Edwin Leuven, leuven@fee.uva.nl
|
||||
* \author Angus Leeming <a.leeming@ic.ac.uk>
|
||||
*/
|
||||
|
||||
#ifndef CONTROLCREDITS_H
|
||||
#define CONTROLCREDITS_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include "ControlDialogs.h"
|
||||
|
||||
/** A controller for the Credits dialogs.
|
||||
*/
|
||||
class ControlCredits : public ControlDialog<ControlConnectBI> {
|
||||
public:
|
||||
///
|
||||
ControlCredits(LyXView &, Dialogs &);
|
||||
|
||||
///
|
||||
std::vector<string> const getCredits() const;
|
||||
|
||||
private:
|
||||
/// not needed.
|
||||
virtual void apply() {}
|
||||
};
|
||||
|
||||
#endif // CONTROLCREDITS_H
|
||||
|
193
src/frontends/controllers/ControlDialogs.h
Normal file
193
src/frontends/controllers/ControlDialogs.h
Normal file
@ -0,0 +1,193 @@
|
||||
/* This file is part of
|
||||
* ======================================================
|
||||
*
|
||||
* LyX, The Document Processor
|
||||
*
|
||||
* Copyright 2001 The LyX Team.
|
||||
*
|
||||
* ======================================================
|
||||
*
|
||||
* \file ControlDialogs.h
|
||||
* \author Angus Leeming <a.leeming@ic.ac.uk>
|
||||
*
|
||||
* ControlDialogs.h contains the definition of two template controller classes,
|
||||
* ControlDialog and ControlInset, rather clumsy names for classes that
|
||||
* control the showing, updating and hiding of popups.
|
||||
*
|
||||
* ControlInset is to be used as a parent class for popups that display and
|
||||
* can perhaps modify the contents of an individual inset. An example being the
|
||||
* ubiquitous Citation popup.
|
||||
*
|
||||
* ControlDialog is to be used as a parent class for popups that are not
|
||||
* Inset-popups. (An ugly description I know, but I hope the meaning is clear!
|
||||
* Can anyone do any better?) Examples would be the Document and Paragraph
|
||||
* popups.
|
||||
*
|
||||
* At the moment, ControlDialog is reaching a state of maturity as several
|
||||
* controllers are now derived from it and its required functionality
|
||||
* becaomes clear.
|
||||
*
|
||||
* ControlInset is still in a state of flux as currently only InsetCommand-type
|
||||
* insets have a controller.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CONTROLCONNECTIONS2_H
|
||||
#define CONTROLCONNECTIONS2_H
|
||||
|
||||
#include "ControlConnections.h"
|
||||
#include "LyXView.h"
|
||||
|
||||
/** Base class to control connection/disconnection of signals with the LyX
|
||||
kernel for dialogs NOT used with insets.
|
||||
The Base class will be either ControlConnectBI or ControlConnectBD.
|
||||
*/
|
||||
template <class Base>
|
||||
class ControlDialog : public Base
|
||||
{
|
||||
public:
|
||||
///
|
||||
ControlDialog(LyXView &, Dialogs &);
|
||||
|
||||
protected:
|
||||
/// Show the dialog.
|
||||
virtual void show();
|
||||
/// Hide the dialog.
|
||||
virtual void hide();
|
||||
/// Update the dialog.
|
||||
virtual void update();
|
||||
|
||||
/// set the params before show or update
|
||||
virtual void setParams() {}
|
||||
/// clean-up on hide.
|
||||
virtual void clearParams() {}
|
||||
};
|
||||
|
||||
|
||||
/** Base class to control connection/disconnection of signals with the LyX
|
||||
kernel for Inset dialogs.
|
||||
*/
|
||||
class Inset;
|
||||
|
||||
template <class Inset>
|
||||
class ControlInset : public ControlConnectBD
|
||||
{
|
||||
public:
|
||||
///
|
||||
ControlInset(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.
|
||||
SigC::Connection ih_;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
template <class Base>
|
||||
ControlDialog<Base>::ControlDialog(LyXView & lv, Dialogs & d)
|
||||
: Base(lv, d)
|
||||
{}
|
||||
|
||||
|
||||
template <class Base>
|
||||
void ControlDialog<Base>::show()
|
||||
{
|
||||
if (isBufferDependent() && !lv_.view()->available())
|
||||
return;
|
||||
|
||||
setParams();
|
||||
|
||||
bc().readOnly(isReadonly());
|
||||
view().show();
|
||||
}
|
||||
|
||||
template <class Base>
|
||||
void ControlDialog<Base>::update()
|
||||
{
|
||||
if (isBufferDependent() && !lv_.view()->available())
|
||||
return;
|
||||
|
||||
setParams();
|
||||
|
||||
bc().readOnly(isReadonly());
|
||||
view().update();
|
||||
}
|
||||
|
||||
template <class Base>
|
||||
void ControlDialog<Base>::hide()
|
||||
{
|
||||
clearParams();
|
||||
|
||||
disconnect();
|
||||
view().hide();
|
||||
}
|
||||
|
||||
|
||||
template <class Inset>
|
||||
ControlInset<Inset>::ControlInset(LyXView & lv, Dialogs & d)
|
||||
: ControlConnectBD(lv, d),
|
||||
inset_(0), ih_(0)
|
||||
{}
|
||||
|
||||
|
||||
template <class Inset>
|
||||
void ControlInset<Inset>::updateSlot(bool switched)
|
||||
{
|
||||
if (switched)
|
||||
hide();
|
||||
else
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
template <class Inset>
|
||||
void ControlInset<Inset>::disconnect()
|
||||
{
|
||||
inset_ = 0;
|
||||
ih_.disconnect();
|
||||
ControlConnectBD::disconnect();
|
||||
}
|
||||
|
||||
|
||||
template <class Inset>
|
||||
void ControlInset<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(
|
||||
SigC::slot(this, &ControlInset::hide));
|
||||
}
|
||||
connect();
|
||||
}
|
||||
|
||||
|
||||
template <class Inset>
|
||||
void ControlInset<Inset>::disconnectInset()
|
||||
{
|
||||
ih_.disconnect();
|
||||
}
|
||||
|
||||
|
||||
#endif // CONTROLCONNECTIONS2_H
|
@ -22,43 +22,22 @@
|
||||
#include "Dialogs.h"
|
||||
#include "lyxrc.h"
|
||||
|
||||
using std::make_pair;
|
||||
using SigC::slot;
|
||||
|
||||
ControlLog::ControlLog(LyXView & lv, Dialogs & d)
|
||||
: ControlConnectBD(lv, d)
|
||||
: ControlDialog<ControlConnectBD>(lv, d)
|
||||
{
|
||||
d_.showLogFile.connect(slot(this, &ControlLog::show));
|
||||
}
|
||||
|
||||
|
||||
void ControlLog::show()
|
||||
void ControlLog::setParams()
|
||||
{
|
||||
if (!lv_.view()->available())
|
||||
return;
|
||||
|
||||
logfile_ = lv_.view()->buffer()->getLogName();
|
||||
|
||||
bc().readOnly(isReadonly());
|
||||
view().show();
|
||||
}
|
||||
|
||||
|
||||
void ControlLog::update()
|
||||
{
|
||||
if (!lv_.view()->available())
|
||||
return;
|
||||
|
||||
logfile_ = lv_.view()->buffer()->getLogName();
|
||||
|
||||
bc().readOnly(isReadonly());
|
||||
view().update();
|
||||
}
|
||||
|
||||
|
||||
void ControlLog::hide()
|
||||
void ControlLog::clearParams()
|
||||
{
|
||||
logfile_.second.erase();
|
||||
disconnect();
|
||||
view().hide();
|
||||
}
|
||||
|
@ -22,13 +22,13 @@
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include "ControlConnections.h"
|
||||
#include "ControlDialogs.h"
|
||||
#include "buffer.h" // Buffer::LogType
|
||||
|
||||
/**
|
||||
* A controller for a read-only text browser.
|
||||
*/
|
||||
class ControlLog : public ControlConnectBD {
|
||||
class ControlLog : public ControlDialog<ControlConnectBD> {
|
||||
public:
|
||||
///
|
||||
ControlLog(LyXView &, Dialogs &);
|
||||
@ -39,42 +39,13 @@ public:
|
||||
protected:
|
||||
///
|
||||
virtual void apply() {}
|
||||
/// Show the dialog.
|
||||
virtual void show();
|
||||
/// Update the dialog.
|
||||
virtual void update();
|
||||
/// Hide the dialog.
|
||||
virtual void hide();
|
||||
/// set the params before show or update
|
||||
virtual void setParams();
|
||||
/// clean-up on hide.
|
||||
virtual void clearParams();
|
||||
|
||||
private:
|
||||
std::pair<Buffer::LogType, string> logfile_;
|
||||
};
|
||||
|
||||
|
||||
/** A class to instantiate and make available the GUI-specific
|
||||
ButtonController and View.
|
||||
*/
|
||||
template <class GUIview, class GUIbc>
|
||||
class GUILog : public ControlLog {
|
||||
public:
|
||||
///
|
||||
GUILog(LyXView &, Dialogs &);
|
||||
///
|
||||
virtual ButtonControllerBase & bc() { return bc_; }
|
||||
///
|
||||
virtual ViewBase & view() { return view_; }
|
||||
|
||||
private:
|
||||
///
|
||||
ButtonController<OkCancelPolicy, GUIbc> bc_;
|
||||
///
|
||||
GUIview view_;
|
||||
};
|
||||
|
||||
template <class GUIview, class GUIbc>
|
||||
GUILog<GUIview, GUIbc>::GUILog(LyXView & lv, Dialogs & d)
|
||||
: ControlLog(lv, d),
|
||||
view_(*this)
|
||||
{}
|
||||
|
||||
#endif // CONTROLLOG_H
|
||||
|
@ -26,41 +26,19 @@
|
||||
using SigC::slot;
|
||||
|
||||
ControlVCLog::ControlVCLog(LyXView & lv, Dialogs & d)
|
||||
: ControlConnectBD(lv, d)
|
||||
: ControlDialog<ControlConnectBD>(lv, d)
|
||||
{
|
||||
d_.showVCLogFile.connect(slot(this, &ControlVCLog::show));
|
||||
}
|
||||
|
||||
|
||||
void ControlVCLog::show()
|
||||
void ControlVCLog::setParams()
|
||||
{
|
||||
if (!lv_.view()->available())
|
||||
return;
|
||||
|
||||
logfile_ = lv_.view()->buffer()->lyxvc.getLogFile();
|
||||
|
||||
bc().readOnly(isReadonly());
|
||||
view().show();
|
||||
}
|
||||
|
||||
|
||||
void ControlVCLog::update()
|
||||
{
|
||||
if (!lv_.view()->available())
|
||||
return;
|
||||
|
||||
logfile_ = lv_.view()->buffer()->lyxvc.getLogFile();
|
||||
|
||||
bc().readOnly(isReadonly());
|
||||
view().update();
|
||||
|
||||
lyx::unlink(logfile_);
|
||||
}
|
||||
|
||||
|
||||
void ControlVCLog::hide()
|
||||
void ControlVCLog::clearParams()
|
||||
{
|
||||
logfile_.erase();
|
||||
disconnect();
|
||||
view().hide();
|
||||
}
|
||||
|
@ -22,12 +22,12 @@
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include "ControlConnections.h"
|
||||
#include "ControlDialogs.h"
|
||||
|
||||
/**
|
||||
* A controller for the Version Control log viewer.
|
||||
*/
|
||||
class ControlVCLog : public ControlConnectBD {
|
||||
class ControlVCLog : public ControlDialog<ControlConnectBD> {
|
||||
public:
|
||||
///
|
||||
ControlVCLog(LyXView &, Dialogs &);
|
||||
@ -37,42 +37,13 @@ public:
|
||||
protected:
|
||||
///
|
||||
virtual void apply() {}
|
||||
/// Show the dialog.
|
||||
virtual void show();
|
||||
/// Update the dialog.
|
||||
virtual void update();
|
||||
/// Hide the dialog.
|
||||
virtual void hide();
|
||||
/// set the params before show or update
|
||||
virtual void setParams();
|
||||
/// clean-up on hide.
|
||||
virtual void clearParams();
|
||||
|
||||
private:
|
||||
string logfile_;
|
||||
};
|
||||
|
||||
|
||||
/** A class to instantiate and make available the GUI-specific
|
||||
ButtonController and View.
|
||||
*/
|
||||
template <class GUIview, class GUIbc>
|
||||
class GUIVCLog : public ControlVCLog {
|
||||
public:
|
||||
///
|
||||
GUIVCLog(LyXView &, Dialogs &);
|
||||
///
|
||||
virtual ButtonControllerBase & bc() { return bc_; }
|
||||
///
|
||||
virtual ViewBase & view() { return view_; }
|
||||
|
||||
private:
|
||||
///
|
||||
ButtonController<OkCancelPolicy, GUIbc> bc_;
|
||||
///
|
||||
GUIview view_;
|
||||
};
|
||||
|
||||
template <class GUIview, class GUIbc>
|
||||
GUIVCLog<GUIview, GUIbc>::GUIVCLog(LyXView & lv, Dialogs & d)
|
||||
: ControlVCLog(lv, d),
|
||||
view_(*this)
|
||||
{}
|
||||
|
||||
#endif // CONTROLVCLOG_H
|
||||
|
139
src/frontends/controllers/GUI.h
Normal file
139
src/frontends/controllers/GUI.h
Normal file
@ -0,0 +1,139 @@
|
||||
/**
|
||||
* \file GUI.h
|
||||
* Copyright 2001 The LyX Team.
|
||||
* See the file COPYING.
|
||||
*
|
||||
* \author Angus Leeming <a.leeming@ic.ac.uk>
|
||||
*/
|
||||
|
||||
#ifndef GUI_H
|
||||
#define GUI_H
|
||||
|
||||
/** This class instantiates and makes available the GUI-specific
|
||||
ButtonController and View.
|
||||
*/
|
||||
template <class Controller, class GUIview, class Policy, class GUIbc>
|
||||
class GUI : public Controller {
|
||||
public:
|
||||
///
|
||||
GUI(LyXView & lv, Dialogs & d) : Controller(lv, d), view_(*this) {}
|
||||
///
|
||||
virtual ButtonControllerBase & bc() { return bc_; }
|
||||
///
|
||||
virtual ViewBase & view() { return view_; }
|
||||
|
||||
private:
|
||||
///
|
||||
ButtonController<Policy, GUIbc> bc_;
|
||||
///
|
||||
GUIview view_;
|
||||
};
|
||||
|
||||
/// Forward declaration of ButtonPolicies
|
||||
class OkCancelPolicy;
|
||||
class OkCancelReadOnlyPolicy;
|
||||
class NoRepeatedApplyReadOnlyPolicy;
|
||||
|
||||
|
||||
/** Specialization for Bibitem dialog
|
||||
*/
|
||||
class ControlBibitem;
|
||||
|
||||
template <class GUIview, class GUIbc>
|
||||
class GUIBibitem :
|
||||
public GUI<ControlBibitem, GUIview, OkCancelReadOnlyPolicy, GUIbc> {
|
||||
public:
|
||||
///
|
||||
GUIBibitem(LyXView & lv, Dialogs & d)
|
||||
: GUI<ControlBibitem, GUIview, OkCancelReadOnlyPolicy, GUIbc>(lv, d) {}
|
||||
};
|
||||
|
||||
|
||||
/** Specialization for Bibtex dialog
|
||||
*/
|
||||
class ControlBibtex;
|
||||
|
||||
template <class GUIview, class GUIbc>
|
||||
class GUIBibtex :
|
||||
public GUI<ControlBibtex, GUIview, OkCancelReadOnlyPolicy, GUIbc> {
|
||||
public:
|
||||
///
|
||||
GUIBibtex(LyXView & lv, Dialogs & d)
|
||||
: GUI<ControlBibtex, GUIview, OkCancelReadOnlyPolicy, GUIbc>(lv, d) {}
|
||||
};
|
||||
|
||||
|
||||
/** Specialization for Character dialog
|
||||
*/
|
||||
class ControlCharacter;
|
||||
|
||||
template <class GUIview, class GUIbc>
|
||||
class GUICharacter : public GUI<ControlCharacter, GUIview,
|
||||
NoRepeatedApplyReadOnlyPolicy, GUIbc>
|
||||
{
|
||||
public:
|
||||
///
|
||||
GUICharacter(LyXView & lv, Dialogs & d)
|
||||
: GUI<ControlCharacter, GUIview,
|
||||
NoRepeatedApplyReadOnlyPolicy, GUIbc>(lv, d) {}
|
||||
};
|
||||
|
||||
|
||||
/** Specialization for Citation dialog
|
||||
*/
|
||||
class ControlCitation;
|
||||
|
||||
template <class GUIview, class GUIbc>
|
||||
class GUICitation : public GUI<ControlCitation, GUIview,
|
||||
NoRepeatedApplyReadOnlyPolicy, GUIbc>
|
||||
{
|
||||
public:
|
||||
///
|
||||
GUICitation(LyXView & lv, Dialogs & d)
|
||||
: GUI<ControlCitation, GUIview,
|
||||
NoRepeatedApplyReadOnlyPolicy, GUIbc>(lv, d) {}
|
||||
};
|
||||
|
||||
|
||||
/** Specialization for Credits dialog
|
||||
*/
|
||||
class ControlCredits;
|
||||
|
||||
template <class GUIview, class GUIbc>
|
||||
class GUICredits :
|
||||
public GUI<ControlCredits, GUIview, OkCancelPolicy, GUIbc> {
|
||||
public:
|
||||
///
|
||||
GUICredits(LyXView & lv, Dialogs & d)
|
||||
: GUI<ControlCredits, GUIview, OkCancelPolicy, GUIbc>(lv, d) {}
|
||||
};
|
||||
|
||||
|
||||
/** Specialization for Log dialog
|
||||
*/
|
||||
class ControlLog;
|
||||
|
||||
template <class GUIview, class GUIbc>
|
||||
class GUILog :
|
||||
public GUI<ControlLog, GUIview, OkCancelPolicy, GUIbc> {
|
||||
public:
|
||||
///
|
||||
GUILog(LyXView & lv, Dialogs & d)
|
||||
: GUI<ControlLog, GUIview, OkCancelPolicy, GUIbc>(lv, d) {}
|
||||
};
|
||||
|
||||
|
||||
/** Specialization for VCLog dialog
|
||||
*/
|
||||
class ControlVCLog;
|
||||
|
||||
template <class GUIview, class GUIbc>
|
||||
class GUIVCLog :
|
||||
public GUI<ControlVCLog, GUIview, OkCancelPolicy, GUIbc> {
|
||||
public:
|
||||
///
|
||||
GUIVCLog(LyXView & lv, Dialogs & d)
|
||||
: GUI<ControlVCLog, GUIview, OkCancelPolicy, GUIbc>(lv, d) {}
|
||||
};
|
||||
|
||||
#endif // GUI_H
|
@ -28,10 +28,15 @@ libcontrollers_la_SOURCES=\
|
||||
ControlCommand.h \
|
||||
ControlConnections.C \
|
||||
ControlConnections.h \
|
||||
ControlCopyright.C \
|
||||
ControlCredits.h \
|
||||
ControlCredits.C \
|
||||
ControlCopyright.h \
|
||||
ControlLog.C \
|
||||
ControlLog.h \
|
||||
ControlVCLog.C \
|
||||
ControlVCLog.h \
|
||||
GUI.h \
|
||||
ViewBase.h \
|
||||
helper_funcs.C \
|
||||
helper_funcs.h
|
||||
|
@ -1,3 +1,17 @@
|
||||
2001-03-22 Angus Leeming <a.leeming@ic.ac.uk>
|
||||
|
||||
* FormCopyright.[Ch]:
|
||||
* forms/form_copyright.fd: implemented controller-view split.
|
||||
|
||||
* FormCredits.[Ch]:
|
||||
* forms/form_credits.fd: implemented controller-view split.
|
||||
|
||||
* Dialogs.C: associated changes.
|
||||
|
||||
* xforms_helpers.C (formatted): improved the function so that it now
|
||||
repects '\n' characters in the input string. Ie, the user can now
|
||||
specify line breaks explicitly.
|
||||
|
||||
2001-03-21 Angus Leeming <a.leeming@ic.ac.uk>
|
||||
|
||||
* FormCharacter.[Ch]:
|
||||
@ -35,13 +49,6 @@
|
||||
|
||||
* Dialogs.C: associated changes.
|
||||
|
||||
2001-03-19 Angus Leeming <a.leeming@ic.ac.uk>
|
||||
|
||||
* FormBibtex.[Ch]:
|
||||
* forms/form_bibtex.fd: implemented controller-view split.
|
||||
|
||||
* Dialogs.C: associated changes.
|
||||
|
||||
2001-03-19 Angus Leeming <a.leeming@ic.ac.uk>
|
||||
|
||||
* FormBaseDeprecated.[Ch]: rename title as title_.
|
||||
|
@ -4,7 +4,7 @@
|
||||
* LyX, The Document Processor
|
||||
*
|
||||
* Copyright 1995 Matthias Ettrich
|
||||
* Copyright 1995-2000 The LyX Team.
|
||||
* Copyright 1995-2001 The LyX Team.
|
||||
*
|
||||
* ======================================================
|
||||
*/
|
||||
@ -23,25 +23,31 @@
|
||||
#include "ControlBibtex.h"
|
||||
#include "ControlCharacter.h"
|
||||
#include "ControlCitation.h"
|
||||
#include "ControlCopyright.h"
|
||||
#include "ControlCredits.h"
|
||||
#include "ControlLog.h"
|
||||
#include "ControlVCLog.h"
|
||||
|
||||
#include "combox.h" // needed for clean destructtion of boost::scoped ptr
|
||||
#include "GUI.h"
|
||||
|
||||
#include "combox.h" // needed for clean destruction of boost::scoped_ptr
|
||||
#include "form_bibitem.h"
|
||||
#include "form_bibtex.h"
|
||||
#include "form_browser.h"
|
||||
#include "form_character.h"
|
||||
#include "form_citation.h"
|
||||
#include "form_copyright.h"
|
||||
#include "form_credits.h"
|
||||
|
||||
#include "FormBibitem.h"
|
||||
#include "FormBibtex.h"
|
||||
#include "FormCharacter.h"
|
||||
#include "FormCitation.h"
|
||||
#include "FormCopyright.h"
|
||||
#include "FormCredits.h"
|
||||
#include "FormLog.h"
|
||||
#include "FormVCLog.h"
|
||||
|
||||
#include "FormCopyright.h"
|
||||
#include "FormCredits.h"
|
||||
#include "FormDocument.h"
|
||||
#include "FormError.h"
|
||||
#include "FormExternal.h"
|
||||
@ -74,11 +80,11 @@ Dialogs::Dialogs(LyXView * lv)
|
||||
add(new GUIBibtex<FormBibtex, xformsBC>(*lv, *this));
|
||||
add(new GUICharacter<FormCharacter, xformsBC>(*lv, *this));
|
||||
add(new GUICitation<FormCitation, xformsBC>(*lv, *this));
|
||||
add(new GUICopyright<FormCopyright, xformsBC>(*lv, *this));
|
||||
add(new GUICredits<FormCredits, xformsBC>(*lv, *this));
|
||||
add(new GUILog<FormLog, xformsBC>(*lv, *this));
|
||||
add(new GUIVCLog<FormVCLog, xformsBC>(*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));
|
||||
|
@ -81,12 +81,13 @@ void FormCharacter::build()
|
||||
fl_addto_choice(dialog_->choice_color, choice.c_str());
|
||||
|
||||
// xforms appears to need this to prevent a crash...
|
||||
// fl_addto_choice(dialog_->choice_language,
|
||||
// _(" English %l| German | French "));
|
||||
fl_addto_choice(dialog_->choice_language, "prevent crash");
|
||||
|
||||
// insert default language box manually
|
||||
fl_addto_form(dialog_->form);
|
||||
FL_OBJECT * ob = dialog_->choice_language;
|
||||
fl_deactivate_object(dialog_->choice_language);
|
||||
|
||||
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);
|
||||
|
@ -1,4 +1,3 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file FormCharacter.h
|
||||
* Copyright 2001 The LyX Team.
|
||||
|
@ -1,57 +1,48 @@
|
||||
/* FormCopyright.C
|
||||
* FormCopyright Interface Class Implementation
|
||||
/*
|
||||
* \file FormCopyright.C
|
||||
* Copyright 2000-2001 The LyX Team.
|
||||
* See the file COPYING.
|
||||
*
|
||||
* \author Allan Rae
|
||||
* \author Angus Leeming, a.leeming@.ac.uk
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include FORMS_H_LOCATION
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation
|
||||
#endif
|
||||
|
||||
#include "Dialogs.h"
|
||||
#include "LyXView.h"
|
||||
#include "form_copyright.h"
|
||||
#include <config.h>
|
||||
|
||||
#include "xformsBC.h"
|
||||
#include "ControlCopyright.h"
|
||||
#include "FormCopyright.h"
|
||||
#include "form_copyright.h"
|
||||
#include "xforms_helpers.h"
|
||||
|
||||
using SigC::slot;
|
||||
typedef FormCB<ControlCopyright, FormDB<FD_form_copyright> > base_class;
|
||||
|
||||
FormCopyright::FormCopyright( LyXView * lv, Dialogs * d )
|
||||
: FormBaseBI(lv, d, _("Copyright and Warranty"))
|
||||
{
|
||||
// let the dialog be shown
|
||||
// This is a permanent connection so we won't bother
|
||||
// storing a copy because we won't be disconnecting.
|
||||
d->showCopyright.connect(slot(this, &FormCopyright::show));
|
||||
}
|
||||
|
||||
|
||||
FL_FORM * FormCopyright::form() const
|
||||
{
|
||||
if (dialog_.get()) return dialog_->form;
|
||||
return 0;
|
||||
}
|
||||
FormCopyright::FormCopyright(ControlCopyright & c)
|
||||
: base_class(c, _("Copyright and Warranty"))
|
||||
{}
|
||||
|
||||
|
||||
void FormCopyright::build()
|
||||
{
|
||||
dialog_.reset(build_copyright());
|
||||
|
||||
string str = _("LyX is Copyright (C) 1995 by Matthias Ettrich, 1995-2001 LyX Team");
|
||||
str = formatted(str, dialog_->text_copyright->w-10,
|
||||
FL_NORMAL_SIZE, FL_NORMAL_STYLE);
|
||||
string str = formatted(controller().getCopyright(),
|
||||
dialog_->text_copyright->w-10);
|
||||
|
||||
fl_set_object_label(dialog_->text_copyright, str.c_str());
|
||||
|
||||
str = _("This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.");
|
||||
str = formatted(str, dialog_->text_licence->w-10,
|
||||
FL_NORMAL_SIZE, FL_NORMAL_STYLE);
|
||||
str = formatted(controller().getLicence(),
|
||||
dialog_->text_licence->w-10);
|
||||
|
||||
fl_set_object_label(dialog_->text_licence, str.c_str());
|
||||
|
||||
str = _("LyX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.");
|
||||
str = formatted(str, dialog_->text_disclaimer->w-10,
|
||||
FL_NORMAL_SIZE, FL_NORMAL_STYLE);
|
||||
str = formatted(controller().getDisclaimer(),
|
||||
dialog_->text_disclaimer->w-10);
|
||||
|
||||
fl_set_object_label(dialog_->text_disclaimer, str.c_str());
|
||||
|
||||
// Manage the cancel/close button
|
||||
|
@ -1,59 +1,51 @@
|
||||
// -*- C++ -*-
|
||||
/* FormCopyright.h
|
||||
* FormCopyright Interface Class
|
||||
/**
|
||||
* \file FormCopyright.h
|
||||
* This file is part of
|
||||
* ======================================================
|
||||
*
|
||||
* LyX, The Document Processor
|
||||
*
|
||||
* Copyright 1995 Matthias Ettrich
|
||||
* Copyright 1995-2000 The LyX Team.
|
||||
* Copyright 1995-2001 The LyX Team.
|
||||
*
|
||||
* This file Copyright 2000
|
||||
* This file Copyright 2000-2001
|
||||
* Allan Rae
|
||||
* ======================================================
|
||||
*
|
||||
* \author Allan Rae
|
||||
* \author Angus Leeming, a.leeming@.ac.uk
|
||||
*/
|
||||
|
||||
#ifndef FORMCOPYRIGHT_H
|
||||
#define FORMCOPYRIGHT_H
|
||||
|
||||
#include <boost/smart_ptr.hpp>
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include "FormBaseDeprecated.h"
|
||||
#include "FormBase.h"
|
||||
|
||||
class ControlCopyright;
|
||||
struct FD_form_copyright;
|
||||
|
||||
/** This class provides an XForms implementation of the FormCopyright Dialog.
|
||||
*/
|
||||
class FormCopyright : public FormBaseBI {
|
||||
class FormCopyright
|
||||
: public FormCB<ControlCopyright, FormDB<FD_form_copyright> > {
|
||||
public:
|
||||
/// #FormCopyright x(LyXFunc ..., Dialogs ...);#
|
||||
FormCopyright(LyXView *, Dialogs *);
|
||||
///
|
||||
FormCopyright(ControlCopyright &);
|
||||
|
||||
private:
|
||||
/// Pointer to the actual instantiation of the ButtonController.
|
||||
virtual xformsBC & bc();
|
||||
/// not needed.
|
||||
virtual void apply() {}
|
||||
/// not needed.
|
||||
virtual void update() {}
|
||||
/// Build the dialog
|
||||
virtual void build();
|
||||
/// Pointer to the actual instantiation of the xforms form
|
||||
virtual FL_FORM * form() const;
|
||||
|
||||
/// Fdesign generated method
|
||||
FD_form_copyright * build_copyright();
|
||||
|
||||
/// Real GUI implementation.
|
||||
boost::scoped_ptr<FD_form_copyright> dialog_;
|
||||
/// The ButtonController
|
||||
ButtonController<OkCancelPolicy, xformsBC> bc_;
|
||||
};
|
||||
|
||||
|
||||
inline
|
||||
xformsBC & FormCopyright::bc()
|
||||
{
|
||||
return bc_;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // FORMCOPYRIGHT_H
|
||||
|
@ -4,69 +4,43 @@
|
||||
* See the file COPYING.
|
||||
*
|
||||
* \author Edwin Leuven, leuven@fee.uva.nl
|
||||
* \author Angus Leeming, a.leeming@.ac.uk
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include FORMS_H_LOCATION
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation
|
||||
#endif
|
||||
|
||||
#include "Dialogs.h"
|
||||
#include "LyXView.h"
|
||||
#include "form_credits.h"
|
||||
#include <config.h>
|
||||
|
||||
#include "xformsBC.h"
|
||||
#include "ControlCredits.h"
|
||||
#include "FormCredits.h"
|
||||
#include "form_credits.h"
|
||||
#include "xforms_helpers.h"
|
||||
#include "support/filetools.h"
|
||||
|
||||
using SigC::slot;
|
||||
using std::vector;
|
||||
|
||||
FormCredits::FormCredits( LyXView * lv, Dialogs * d )
|
||||
: FormBaseBI(lv, d, _("Credits"))
|
||||
{
|
||||
// let the dialog be shown
|
||||
// This is a permanent connection so we won't bother
|
||||
// storing a copy because we won't be disconnecting.
|
||||
d->showCredits.connect(slot(this, &FormCredits::show));
|
||||
}
|
||||
typedef FormCB<ControlCredits, FormDB<FD_form_credits> > base_class;
|
||||
|
||||
FormCredits::FormCredits(ControlCredits & c)
|
||||
: base_class(c, _("Credits"))
|
||||
{}
|
||||
|
||||
FL_FORM * FormCredits::form() const
|
||||
{
|
||||
if (dialog_.get())
|
||||
return dialog_->form;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// needed for the browser
|
||||
extern string system_lyxdir;
|
||||
|
||||
void FormCredits::build()
|
||||
{
|
||||
dialog_.reset(build_credits());
|
||||
dialog_.reset(build_credits());
|
||||
|
||||
// Manage the cancel/close button
|
||||
bc_.setCancel(dialog_->button_cancel);
|
||||
bc_.refresh();
|
||||
|
||||
/* read the credits into the browser */
|
||||
|
||||
/* try file LYX_DIR/CREDITS */
|
||||
string real_file = AddName (system_lyxdir, "CREDITS");
|
||||
|
||||
if (!fl_load_browser(dialog_->browser_credits,
|
||||
real_file.c_str())) {
|
||||
fl_add_browser_line(dialog_->browser_credits,
|
||||
_("ERROR: LyX wasn't able to read"
|
||||
" CREDITS file"));
|
||||
fl_add_browser_line(dialog_->browser_credits, "");
|
||||
fl_add_browser_line(dialog_->browser_credits,
|
||||
_("Please install correctly to estimate"
|
||||
" the great"));
|
||||
fl_add_browser_line(dialog_->browser_credits,
|
||||
_("amount of work other people have done"
|
||||
" for the LyX project."));
|
||||
}
|
||||
// Manage the cancel/close button
|
||||
bc().setCancel(dialog_->button_cancel);
|
||||
bc().refresh();
|
||||
|
||||
vector<string> data = controller().getCredits();
|
||||
|
||||
/* read the credits into the browser */
|
||||
for (vector<string>::const_iterator it = data.begin();
|
||||
it < data.end(); ++it) {
|
||||
fl_add_browser_line(dialog_->browser_credits, it->c_str());
|
||||
}
|
||||
}
|
||||
|
@ -4,49 +4,39 @@
|
||||
* See the file COPYING.
|
||||
*
|
||||
* \author Edwin Leuven, leuven@fee.uva.nl
|
||||
* \author Angus Leeming, a.leeming@.ac.uk
|
||||
*/
|
||||
|
||||
#ifndef FORMCREDITS_H
|
||||
#define FORMCREDITS_H
|
||||
|
||||
#include <boost/smart_ptr.hpp>
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include "FormBaseDeprecated.h"
|
||||
#include "FormBase.h"
|
||||
|
||||
class ControlCredits;
|
||||
struct FD_form_credits;
|
||||
|
||||
/** This class provides an XForms implementation of the FormCredits Dialog.
|
||||
*/
|
||||
class FormCredits : public FormBaseBI {
|
||||
class FormCredits : public FormCB<ControlCredits, FormDB<FD_form_credits> > {
|
||||
public:
|
||||
/// #FormCopyright x(LyXFunc ..., Dialogs ...);#
|
||||
FormCredits(LyXView *, Dialogs *);
|
||||
///
|
||||
FormCredits(ControlCredits &);
|
||||
|
||||
private:
|
||||
/// Pointer to the actual instantiation of the ButtonController.
|
||||
virtual xformsBC & bc();
|
||||
/// not needed.
|
||||
virtual void apply() {}
|
||||
/// not needed.
|
||||
virtual void update() {}
|
||||
/// Build the dialog
|
||||
virtual void build();
|
||||
/// Pointer to the actual instantiation of the xforms form
|
||||
virtual FL_FORM * form() const;
|
||||
|
||||
/// Fdesign generated method
|
||||
FD_form_credits * build_credits();
|
||||
|
||||
/// Real GUI implementation.
|
||||
boost::scoped_ptr<FD_form_credits> dialog_;
|
||||
/// The ButtonController
|
||||
ButtonController<OkCancelPolicy, xformsBC> bc_;
|
||||
};
|
||||
|
||||
|
||||
inline
|
||||
xformsBC & FormCredits::bc()
|
||||
{
|
||||
return bc_;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -45,7 +45,7 @@ FD_form_copyright * FormCopyright::build_copyright()
|
||||
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
|
||||
fl_set_object_gravity(obj, FL_South, FL_South);
|
||||
fl_set_object_resize(obj, FL_RESIZE_NONE);
|
||||
fl_set_object_callback(obj, C_FormBaseDeprecatedCancelCB, 0);
|
||||
fl_set_object_callback(obj, C_FormBaseCancelCB, 0);
|
||||
fl_end_form();
|
||||
|
||||
fdui->form->fdui = fdui;
|
||||
|
@ -5,7 +5,7 @@
|
||||
#define FD_form_copyright_h_
|
||||
|
||||
/** Callbacks, globals and object handlers **/
|
||||
extern "C" void C_FormBaseDeprecatedCancelCB(FL_OBJECT *, long);
|
||||
extern "C" void C_FormBaseCancelCB(FL_OBJECT *, long);
|
||||
|
||||
|
||||
/**** Forms and Objects ****/
|
||||
|
@ -29,7 +29,7 @@ FD_form_credits * FormCredits::build_credits()
|
||||
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
|
||||
fl_set_object_gravity(obj, FL_South, FL_South);
|
||||
fl_set_object_resize(obj, FL_RESIZE_NONE);
|
||||
fl_set_object_callback(obj, C_FormBaseDeprecatedCancelCB, 0);
|
||||
fl_set_object_callback(obj, C_FormBaseCancelCB, 0);
|
||||
obj = fl_add_text(FL_NORMAL_TEXT, 10, 40, 480, 30, _("Matthias"));
|
||||
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
|
||||
fl_set_object_lalign(obj, FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
|
||||
|
@ -5,7 +5,7 @@
|
||||
#define FD_form_credits_h_
|
||||
|
||||
/** Callbacks, globals and object handlers **/
|
||||
extern "C" void C_FormBaseDeprecatedCancelCB(FL_OBJECT *, long);
|
||||
extern "C" void C_FormBaseCancelCB(FL_OBJECT *, long);
|
||||
|
||||
|
||||
/**** Forms and Objects ****/
|
||||
|
@ -99,7 +99,7 @@ shortcut:
|
||||
resize: FL_RESIZE_NONE
|
||||
gravity: FL_South FL_South
|
||||
name: button_cancel
|
||||
callback: C_FormBaseDeprecatedCancelCB
|
||||
callback: C_FormBaseCancelCB
|
||||
argument: 0
|
||||
|
||||
==============================
|
||||
|
@ -45,7 +45,7 @@ shortcut: ^M
|
||||
resize: FL_RESIZE_NONE
|
||||
gravity: FL_South FL_South
|
||||
name: button_cancel
|
||||
callback: C_FormBaseDeprecatedCancelCB
|
||||
callback: C_FormBaseCancelCB
|
||||
argument: 0
|
||||
|
||||
--------------------
|
||||
|
@ -51,34 +51,50 @@ string formatted(string const & sin, int w, int size, int style)
|
||||
if ((*sit) == ' ' || (*sit) == '\n') {
|
||||
sentence.push_back(word);
|
||||
word.erase();
|
||||
if ((*sit) == '\n') word += '\n';
|
||||
|
||||
} else {
|
||||
word += (*sit);
|
||||
}
|
||||
}
|
||||
|
||||
// Flush remaining contents of word
|
||||
if (!word.empty() ) sentence.push_back(word);
|
||||
|
||||
string line, l1;
|
||||
string line, line_plus_word;
|
||||
for (vector<string>::const_iterator vit = sentence.begin();
|
||||
vit != sentence.end(); ++vit) {
|
||||
if (!l1.empty() ) l1 += ' ';
|
||||
l1 += (*vit);
|
||||
int length = fl_get_string_width(style, size, l1.c_str(),
|
||||
int(l1.length()));
|
||||
if (length >= w) {
|
||||
if (!sout.empty() ) sout += '\n';
|
||||
sout += line;
|
||||
l1 = (*vit);
|
||||
string word = *vit;
|
||||
|
||||
char c = word[0];
|
||||
if (c == '\n') {
|
||||
sout += line + '\n';
|
||||
word = word.substr(1);
|
||||
line_plus_word.erase();
|
||||
line.erase();
|
||||
}
|
||||
|
||||
line = l1;
|
||||
if (!line_plus_word.empty() ) line_plus_word += ' ';
|
||||
line_plus_word += word;
|
||||
|
||||
int length = fl_get_string_width(style, size,
|
||||
line_plus_word.c_str(),
|
||||
int(line_plus_word.length()));
|
||||
if (length >= w) {
|
||||
sout += line + '\n';
|
||||
line_plus_word = word;
|
||||
}
|
||||
|
||||
line = line_plus_word;
|
||||
}
|
||||
// Flush remaining contents of line
|
||||
if (!line.empty()) {
|
||||
if (!sout.empty() ) sout += '\n';
|
||||
sout += line;
|
||||
}
|
||||
|
||||
|
||||
if (sout[sout.length()-1] == '\n')
|
||||
sout.erase(sout.length()-1);
|
||||
|
||||
return sout;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user