Yesterday's character dialog patch

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6472 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Angus Leeming 2003-03-12 22:17:50 +00:00
parent 47432f0259
commit 4a842aeb20
38 changed files with 390 additions and 193 deletions

View File

@ -1,3 +1,9 @@
2003-03-12 Angus Leeming <leeming@lyx.org>
* images/font-free.xpm: renamed as font-free-apply.xpm.
* ui/default.ui: s/font-free/font-free-apply/
2003-03-12 Dekel Tsur <dekelts@tau.ac.il> 2003-03-12 Dekel Tsur <dekelts@tau.ac.il>
* lyx2lyx/lyx2lyx (main): Print error messages to stderr. * lyx2lyx/lyx2lyx (main): Print error messages to stderr.

View File

@ -219,8 +219,8 @@ Menuset
End End
Menu "insert_special" Menu "insert_special"
Item "Superscript|S" "command-sequence math-mode ; math-superscript ; font-free; " Item "Superscript|S" "command-sequence math-mode ; math-superscript ; font-free-apply; "
Item "Subscript|u" "command-sequence math-mode ; math-subscript ; font-free; " Item "Subscript|u" "command-sequence math-mode ; math-subscript ; font-free-apply; "
Item "HFill|H" "hfill-insert" Item "HFill|H" "hfill-insert"
Item "Hyphenation Point|P" "hyphenation-point-insert" Item "Hyphenation Point|P" "hyphenation-point-insert"
Item "Ligature Break|k" "ligature-break-insert" Item "Ligature Break|k" "ligature-break-insert"
@ -423,7 +423,7 @@ Toolbar
Separator Separator
Icon "font-emph" Icon "font-emph"
Icon "font-noun" Icon "font-noun"
Icon "font-free" Icon "font-free-apply"
Separator Separator
Icon "ert-insert" Icon "ert-insert"
Icon "math-mode" Icon "math-mode"

View File

@ -997,18 +997,6 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev_in)
switchKeyMap(); switchKeyMap();
break; break;
case LFUN_DEPTH_MIN:
changeDepth(bv_, bv_->getLyXText(), -1);
break;
case LFUN_DEPTH_PLUS:
changeDepth(bv_, bv_->getLyXText(), 1);
break;
case LFUN_FREE:
owner_->getDialogs().setUserFreeFont();
break;
case LFUN_FILE_INSERT: case LFUN_FILE_INSERT:
MenuInsertLyXFile(ev.argument); MenuInsertLyXFile(ev.argument);
break; break;

View File

@ -1,3 +1,20 @@
2003-03-12 Angus Leeming <leeming@lyx.org>
* BufferView_pimpl.C (dispatch): remove LFUNs from switch as they
duplicate those in LyXFunc::dispatch.
* commandtags.h:
* LyXAction.C:
* ToolbarDefaults.C:
rename LFUN_FREE as LFUN_FONTFREE_APPLY.
Add LFUN_FONTFREE_UPDATE.
* lyxfunc.C (dispatch): code for LFUN_FREEFONT_APPLY,
LFUN_FREEFONT_UPDATE, LFUN_LAYOUT_CHARACTER.
* bufferview_func.[Ch]: several new functions to facilliate
transfer of data to and from the character dialog.
2003-03-12 John Levon <levon@movementarian.org> 2003-03-12 John Levon <levon@movementarian.org>
* buffer.C: * buffer.C:

View File

@ -191,8 +191,9 @@ void LyXAction::init()
{ LFUN_DEFAULT, "font-default", N_("Default font style"), { LFUN_DEFAULT, "font-default", N_("Default font style"),
Noop }, Noop },
{ LFUN_EMPH, "font-emph", N_("Toggle emphasize"), Noop }, { LFUN_EMPH, "font-emph", N_("Toggle emphasize"), Noop },
{ LFUN_FREE, "font-free", N_("Toggle user defined style"), { LFUN_FREEFONT_APPLY, "font-free-apply",
Noop }, N_("Toggle user defined style"), Noop },
{ LFUN_FREEFONT_UPDATE, "font-free-update", "", Noop },
{ LFUN_NOUN, "font-noun", N_("Toggle noun style"), Noop }, { LFUN_NOUN, "font-noun", N_("Toggle noun style"), Noop },
{ LFUN_ROMAN, "font-roman", N_("Toggle roman font style"), { LFUN_ROMAN, "font-roman", N_("Toggle roman font style"),
Noop }, Noop },

View File

@ -73,7 +73,7 @@ void ToolbarDefaults::init()
add(LFUN_EMPH); add(LFUN_EMPH);
add(LFUN_NOUN); add(LFUN_NOUN);
add(LFUN_FREE); add(LFUN_FREEFONT_APPLY);
add(SEPARATOR); add(SEPARATOR);
add(LFUN_INSET_FOOTNOTE); add(LFUN_INSET_FOOTNOTE);

View File

@ -1,12 +1,15 @@
/* This file is part of /**
* ====================================================== * \file bufferview_funcs.C
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
* *
* LyX, The Document Processor * \author Lars Gullik Bjønnes
* \author Jean-Marc Lasgouttes
* \author John Levon
* \author Angus Leeming
* *
* Copyright 1995 Matthias Ettrich * Full author contact details are available in file CREDITS
* Copyright 1995-2001 The LyX Team. */
*
* ====================================================== */
#include <config.h> #include <config.h>
@ -14,6 +17,7 @@
#include "BufferView.h" #include "BufferView.h"
#include "paragraph.h" #include "paragraph.h"
#include "lyxfont.h" #include "lyxfont.h"
#include "lyxlex.h"
#include "lyxtext.h" #include "lyxtext.h"
#include "buffer.h" #include "buffer.h"
#include "lyx_cb.h" #include "lyx_cb.h"
@ -27,11 +31,157 @@
#include "frontends/Alert.h" #include "frontends/Alert.h"
#include "support/lstrings.h" #include "support/lstrings.h"
#include "Lsstream.h"
#include "insets/updatableinset.h" #include "insets/updatableinset.h"
#include "BoostFormat.h" #include "BoostFormat.h"
namespace {
LyXFont freefont(LyXFont::ALL_IGNORE);
bool toggleall(false);
}
// Set data using font and toggle
// If successful, returns true
bool font2string(LyXFont const & font, bool toggle, string & data)
{
string lang = "ignore";
if (font.language())
lang = font.language()->lang();
ostringstream os;
os << "family " << font.family() << '\n'
<< "series " << font.series() << '\n'
<< "shape " << font.shape() << '\n'
<< "size " << font.size() << '\n'
<< "emph " << font.emph() << '\n'
<< "underbar " << font.underbar() << '\n'
<< "noun " << font.noun() << '\n'
<< "number " << font.number() << '\n'
<< "color " << font.color() << '\n'
<< "language " << lang << '\n'
<< "toggleall " << tostr(toggle);
data = os.str();
return true;
}
// Set font and toggle using data
// If successful, returns true
bool string2font(string const & data, LyXFont & font, bool & toggle)
{
istringstream is(data);
LyXLex lex(0,0);
lex.setStream(is);
int Int = 0;
bool Bool = false;
string String;
int nset = 0;
while (lex.isOK()) {
lex.next();
string const token = lex.getString();
if (token == "family" ||
token == "series" ||
token == "shape" ||
token == "size" ||
token == "emph" ||
token == "underbar" ||
token == "noun" ||
token == "number" ||
token == "color") {
lex.next();
Int = lex.getInteger();
} else if (token == "language") {
lex.next();
String = lex.getString();
} else if (token == "toggleall") {
lex.next();
Bool = lex.getBool();
} else {
// Unrecognised token
break;
}
if (!lex.isOK())
break;
++nset;
if (token == "family") {
font.setFamily(static_cast<LyXFont::FONT_FAMILY>(Int));
} else if (token == "series") {
font.setSeries(static_cast<LyXFont::FONT_SERIES>(Int));
} else if (token == "shape") {
font.setShape(static_cast<LyXFont::FONT_SHAPE>(Int));
} else if (token == "size") {
font.setSize(static_cast<LyXFont::FONT_SIZE>(Int));
} else if (token == "emph") {
font.setEmph(static_cast<LyXFont::FONT_MISC_STATE>(Int));
} else if (token == "underbar") {
font.setUnderbar(static_cast<LyXFont::FONT_MISC_STATE>(Int));
} else if (token == "noun") {
font.setNoun(static_cast<LyXFont::FONT_MISC_STATE>(Int));
} else if (token == "number") {
font.setNumber(static_cast<LyXFont::FONT_MISC_STATE>(Int));
} else if (token == "color") {
font.setColor(static_cast<LColor::color>(Int));
} else if (token == "language") {
if (String == "ignore")
font.setLanguage(ignore_language);
else
font.setLanguage(languages.getLanguage(String));
} else if (token == "toggleall") {
toggle = Bool;
}
}
return (nset > 0);
}
string const freefont2string()
{
string data;
if (font2string(freefont, toggleall, data))
return data;
return string();
}
void update_and_apply_freefont(BufferView * bv, string const & data)
{
LyXFont font;
bool toggle;
if (string2font(data, font, toggle)) {
freefont = font;
toggleall = toggle;
apply_freefont(bv);
}
}
void apply_freefont(BufferView * bv)
{
toggleAndShow(bv, freefont, toggleall);
bv->owner()->view_state_changed();
bv->buffer()->markDirty();
bv->owner()->message(_("Character set"));
}
void emph(BufferView * bv) void emph(BufferView * bv)
{ {
LyXFont font(LyXFont::ALL_IGNORE); LyXFont font(LyXFont::ALL_IGNORE);
@ -77,7 +227,7 @@ void lang(BufferView * bv, string const & l)
// Change environment depth. // Change environment depth.
// if decInc >= 0, increment depth // if decInc >= 0, increment depth
// if decInc < 0, decrement depth // if decInc < 0, decrement depth
void changeDepth(BufferView * bv, LyXText * text, int decInc) void changeDepth(BufferView * bv, LyXText * text, int decInc)
{ {
if (!bv->available() || !text) if (!bv->available() || !text)

View File

@ -1,13 +1,15 @@
// -*- C++ -*- // -*- C++ -*-
/* This file is part of /**
* ====================================================== * \file bufferview_funcs.h
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
* *
* LyX, The Document Processor * \author Lars Gullik Bjønnes
* \author Jean-Marc Lasgouttes
* \author Angus Leeming
* *
* Copyright 1995 Matthias Ettrich * Full author contact details are available in file CREDITS
* Copyright 1995-2001 The LyX Team. */
*
* ====================================================== */
#ifndef BUFFERVIEW_FUNCS_H #ifndef BUFFERVIEW_FUNCS_H
#define BUFFERVIEW_FUNCS_H #define BUFFERVIEW_FUNCS_H
@ -18,6 +20,27 @@ class BufferView;
class LyXFont; class LyXFont;
class LyXText; class LyXText;
/** Set \param data using \param font and \param toggle.
* If successful, returns true.
*/
bool font2string(LyXFont const & font, bool toggle, string & data);
/** Set \param font and \param toggle using \param data.
* If successful, returns true.
*/
bool string2font(string const & data, LyXFont & font, bool & toggle);
/** Returns the current freefont, encoded as a string to be passed to the
* frontends.
*/
string const freefont2string();
/** Set the freefont using the contents of \param data dispatched from
* the frontends and apply it at the current cursor location.
*/
void update_and_apply_freefont(BufferView * bv, string const & data);
/** Apply the contents of freefont at the current cursor location.
*/
void apply_freefont(BufferView * bv);
/// ///
extern void emph(BufferView *); extern void emph(BufferView *);
/// ///

View File

@ -46,7 +46,8 @@ enum kb_action {
LFUN_HYPHENATION, LFUN_HYPHENATION,
LFUN_LIGATURE_BREAK, LFUN_LIGATURE_BREAK,
LFUN_HFILL, LFUN_HFILL,
LFUN_FREE, // 30 LFUN_FREEFONT_APPLY,
LFUN_FREEFONT_UPDATE,
#if 0 #if 0
LFUN_FOOTMELT, // schedule for deletion LFUN_FOOTMELT, // schedule for deletion
LFUN_MARGINMELT, // schedule for deletion LFUN_MARGINMELT, // schedule for deletion

View File

@ -1,3 +1,12 @@
2003-03-12 Angus Leeming <leeming@lyx.org>
* Dialogs.[Ch] (hide): rejig as a static method. Hide the signal
away.
(show): add a string arg.
* Dialogs.h: remove showCharacter and setUserFreeFont.
* guiapi.[Ch]: remove gui_ShowCharacter and gui_SetUserFreeFont.
2003-03-10 Angus Leeming <leeming@lyx.org> 2003-03-10 Angus Leeming <leeming@lyx.org>
* Dialogs.h (hide): make it a static method that returns a * Dialogs.h (hide): make it a static method that returns a

View File

@ -13,6 +13,7 @@
#include "Dialogs.h" #include "Dialogs.h"
#include "controllers/Dialog.h" #include "controllers/Dialog.h"
#include <boost/signals/signal2.hpp>
#include <boost/bind.hpp> #include <boost/bind.hpp>
@ -43,11 +44,16 @@ boost::signal0<void> & Dialogs::redrawGUI()
} }
boost::signal2<void, string const &, InsetBase*> & Dialogs::hide() namespace {
BugfixSignal<boost::signal2<void, string const &, InsetBase*> > hideSignal;
}
void Dialogs::hide(string const & name, InsetBase* inset)
{ {
static BugfixSignal<boost::signal2<void, string const &, InsetBase*> > hideSignal()(name, inset);
thesignal;
return thesignal();
} }
@ -56,7 +62,7 @@ Dialogs::Dialogs(LyXView & lyxview)
{ {
// Connect signals // Connect signals
redrawGUI().connect(boost::bind(&Dialogs::redraw, this)); redrawGUI().connect(boost::bind(&Dialogs::redraw, this));
hide().connect(boost::bind(&Dialogs::hideSlot, this, _1, _2)); hideSignal().connect(boost::bind(&Dialogs::hideSlot, this, _1, _2));
// All this is slated to go // All this is slated to go
init_pimpl(); init_pimpl();
@ -83,13 +89,13 @@ Dialog * Dialogs::find(string const & name)
} }
void Dialogs::show(string const & name) void Dialogs::show(string const & name, string const & data)
{ {
Dialog * dialog = find(name); Dialog * dialog = find(name);
if (!dialog) if (!dialog)
return; return;
dialog->show(); dialog->show(data);
} }

View File

@ -18,7 +18,7 @@
#include <boost/scoped_ptr.hpp> #include <boost/scoped_ptr.hpp>
#include <boost/signals/signal0.hpp> #include <boost/signals/signal0.hpp>
#include <boost/signals/signal1.hpp> #include <boost/signals/signal1.hpp>
#include <boost/signals/signal2.hpp>
class Dialog; class Dialog;
class InsetBase; class InsetBase;
@ -73,10 +73,6 @@ public:
Put into some sort of alphabetical order */ Put into some sort of alphabetical order */
//@{ //@{
/// ///
void showCharacter();
/// connected to the character dialog also
void setUserFreeFont();
///
void showDocument(); void showDocument();
/// show the contents of a file. /// show the contents of a file.
void showFile(string const &); void showFile(string const &);
@ -110,24 +106,37 @@ public:
void showVCLogFile(); void showVCLogFile();
//@} //@}
///name == "about" etc /** \param name == "about" etc; an identifier used to
void show(string const & name); launch a particular dialog.
/** name == "bibtex", "citation" etc \param data is a string encoding of the data used to populate
data is generated by the Inset::write method, to be read by the the dialog. Several of these dialogs do not need any data,
Inset::read method in the frontends. so it defaults to string().
inset is stored. On a subsequent Apply from the frontends, the */
stored inset will be modified. If no inset is stored, then a void show(string const & name, string const & data = string());
new one will be created at the current cursor position.
*/ /** \param name == "bibtex", "citation" etc; an identifier used to
launch a particular dialog.
\param data is a string representation of the Inset contents.
It is often little more than the output from Inset::write.
It is passed to, and parsed by, the frontend dialog.
\param inset is _not_ passed to the frontend dialog.
It is stored internally and used by the kernel to ascertain
what to do with the FuncRequest dispatched from the frontend
dialog on 'Apply'; should it be used to create a new inset at
the current cursor position or modify an existing, 'open' inset?
*/
void show(string const & name, string const & data, InsetBase * inset); void show(string const & name, string const & data, InsetBase * inset);
/** name == "citation", "bibtex" etc.
Update the contents of the dialog. /** \param name == "citation", "bibtex" etc; an identifier used
*/ to update the contents of a particular dialog with \param data .
See the comments to 'show', above.
*/
void update(string const & name, string const & data); void update(string const & name, string const & data);
/** All Dialogs of the given 'name' will be closed if they are
connected to the given 'inset'. /** All Dialogs of the given \param name will be closed if they are
*/ connected to the given \param inset.
static boost::signal2<void, string const &, InsetBase*> & hide(); */
static void hide(string const & name, InsetBase * inset);
/// ///
void disconnect(string const & name); void disconnect(string const & name);
/// ///

View File

@ -1,3 +1,8 @@
2003-03-12 Angus Leeming <leeming@lyx.org>
* ControlCharacter.[Ch]: rewrite to use the Dialog-based scheme and
the new dispatch lfuns.
2003-03-09 Angus Leeming <leeming@lyx.org> 2003-03-09 Angus Leeming <leeming@lyx.org>
Flatten the ButtonController tree by splitting it into a Controller Flatten the ButtonController tree by splitting it into a Controller

View File

@ -10,30 +10,25 @@
#include <config.h> #include <config.h>
#include "ControlCharacter.h" #include "ControlCharacter.h"
#include "ViewBase.h"
#include "ButtonController.h" #include "ButtonController.h"
#include "buffer.h" #include "buffer.h"
#include "bufferview_funcs.h" // ToggleAndShow #include "bufferview_funcs.h"
#include "funcrequest.h"
#include "gettext.h" #include "gettext.h"
#include "language.h" #include "language.h"
#include "frontends/LyXView.h"
ControlCharacter::ControlCharacter(Dialog & parent)
ControlCharacter::ControlCharacter(LyXView & lv, Dialogs & d) : Dialog::Controller(parent),
: ControlDialogBD(lv, d),
font_(0), toggleall_(false) font_(0), toggleall_(false)
{} {}
void ControlCharacter::setParams() void ControlCharacter::initialiseParams(string const &)
{ {
// Do this the first time only. Used as a flag for whether or not the // Do this the first time only.
// view has been built
if (!font_.get()) if (!font_.get())
font_.reset(new LyXFont(LyXFont::ALL_IGNORE)); font_.reset(new LyXFont(LyXFont::ALL_IGNORE));
@ -45,24 +40,24 @@ void ControlCharacter::setParams()
getBar() != frnt::IGNORE || getBar() != frnt::IGNORE ||
getColor() != LColor::ignore || getColor() != LColor::ignore ||
font_->language() != ignore_language) font_->language() != ignore_language)
bc().valid(); dialog().bc().valid();
} }
void ControlCharacter::apply() void ControlCharacter::clearParams()
{}
void ControlCharacter::dispatchParams()
{ {
// Nothing to apply. (Can be called from the Toolbar.) // Nothing to dispatch. (Can be called from the Toolbar.)
if (!font_.get()) if (!font_.get())
return; return;
// Apply from the view if it's visible. Otherwise, use the stored values string data;
if (bufferIsAvailable()) if (font2string(*font_.get(), toggleall_, data)) {
view().apply(); kernel().dispatch(FuncRequest(LFUN_FREEFONT_UPDATE, data));
}
toggleAndShow(bufferview(), *(font_.get()), toggleall_);
lv_.view_state_changed();
buffer()->markDirty();
lv_.message(_("Character set"));
} }
@ -220,7 +215,7 @@ void ControlCharacter::setLanguage(string const & val)
font_->setLanguage(ignore_language); font_->setLanguage(ignore_language);
else if (val == "reset") else if (val == "reset")
font_->setLanguage(buffer()->params.language); font_->setLanguage(kernel().buffer()->params.language);
else else
font_->setLanguage(languages.getLanguage(val)); font_->setLanguage(languages.getLanguage(val));

View File

@ -13,17 +13,22 @@
#define CONTROLCHARACTER_H #define CONTROLCHARACTER_H
#include "ControlDialog_impl.h" #include "Dialog.h"
#include "character.h" #include "character.h"
#include <boost/scoped_ptr.hpp>
/** A controller for Character dialogs. class ControlCharacter : public Dialog::Controller {
*/
class ControlCharacter : public ControlDialogBD {
public: public:
/// ///
ControlCharacter(LyXView &, Dialogs &); ControlCharacter(Dialog &);
///
virtual void initialiseParams(string const &);
///
virtual void clearParams();
///
virtual void dispatchParams();
///
virtual bool isBufferDependent() const { return true; }
/// ///
void setFamily(LyXFont::FONT_FAMILY); void setFamily(LyXFont::FONT_FAMILY);
@ -58,13 +63,7 @@ public:
string getLanguage() const; string getLanguage() const;
/// ///
bool getToggleAll() const; bool getToggleAll() const;
/// Get changed parameters and Dispatch them to the kernel.
virtual void apply();
private: private:
/// set the params before show or update.
virtual void setParams();
/// ///
boost::scoped_ptr<LyXFont> font_; boost::scoped_ptr<LyXFont> font_;
/// ///

View File

@ -21,18 +21,6 @@ void gui_show_dialog(Dialogs * d, char const * name, char const * data)
d->show(name, data, 0); d->show(name, data, 0);
} }
void gui_ShowCharacter(Dialogs & d)
{
d.showCharacter();
}
void gui_SetUserFreeFont(Dialogs & d)
{
d.setUserFreeFont();
}
void gui_ShowDocument(Dialogs & d) void gui_ShowDocument(Dialogs & d)
{ {
d.showDocument(); d.showDocument();

View File

@ -21,8 +21,6 @@ extern "C" {
void gui_show_dialog(Dialogs *, char const * name, char const * data); void gui_show_dialog(Dialogs *, char const * name, char const * data);
void gui_ShowCharacter(Dialogs &);
void gui_SetUserFreeFont(Dialogs &);
void gui_ShowDocument(Dialogs &); void gui_ShowDocument(Dialogs &);
void gui_ShowFile(string const &, Dialogs &); void gui_ShowFile(string const &, Dialogs &);
void gui_ShowForks(Dialogs &); void gui_ShowForks(Dialogs &);

View File

@ -1,3 +1,13 @@
2003-03-12 Angus Leeming <leeming@lyx.org>
* Dialogs.C:
* Dialogs2.C:
* Dialogs_impl.h: remove character dialog.
* Dialogs3.C: add character dialog.
* QCharacter.[Ch]: changes to use the new Dialog-based scheme.
2003-03-12 John Levon <levon@movementarian.org> 2003-03-12 John Levon <levon@movementarian.org>
* QSearch.C: don't disable checkboxes on RO doc (bug 937) * QSearch.C: don't disable checkboxes on RO doc (bug 937)

View File

@ -27,8 +27,7 @@ Dialogs::~Dialogs()
Dialogs::Impl::Impl(LyXView & lv, Dialogs & d) Dialogs::Impl::Impl(LyXView & lv, Dialogs & d)
: character(lv, d), : document(lv, d),
document(lv, d),
file(lv, d), file(lv, d),
logfile(lv, d), logfile(lv, d),
paragraph(lv, d), paragraph(lv, d),

View File

@ -15,18 +15,6 @@
#include "Dialogs_impl.h" #include "Dialogs_impl.h"
void Dialogs::showCharacter()
{
pimpl_->character.controller().show();
}
void Dialogs::setUserFreeFont()
{
pimpl_->character.controller().apply();
}
void Dialogs::showDocument() void Dialogs::showDocument()
{ {
pimpl_->document.controller().show(); pimpl_->document.controller().show();

View File

@ -16,6 +16,7 @@
#include "ControlAboutlyx.h" #include "ControlAboutlyx.h"
#include "ControlBibtex.h" #include "ControlBibtex.h"
#include "ControlChanges.h" #include "ControlChanges.h"
#include "ControlCharacter.h"
#include "ControlCitation.h" #include "ControlCitation.h"
#include "ControlError.h" #include "ControlError.h"
#include "ControlERT.h" #include "ControlERT.h"
@ -38,6 +39,8 @@
#include "QBibtexDialog.h" #include "QBibtexDialog.h"
#include "QChanges.h" #include "QChanges.h"
#include "QChangesDialog.h" #include "QChangesDialog.h"
#include "QCharacter.h"
#include "QCharacterDialog.h"
#include "QCitation.h" #include "QCitation.h"
#include "QCitationDialog.h" #include "QCitationDialog.h"
#include "QError.h" #include "QError.h"
@ -81,10 +84,9 @@
namespace { namespace {
char const * const dialognames[] = { "about", "bibitem", "bibtex", "changes", char const * const dialognames[] = { "about", "bibitem", "bibtex", "changes",
"citation", "error", "ert", "external", "character", "citation", "error", "ert", "external", "float", "graphics",
"float", "graphics", "include", "index", "include", "index", "label", "minipage", "ref", "tabular", "tabularcreate",
"label", "minipage", "ref", "tabular", "toc", "url", "wrap" };
"tabularcreate", "toc", "url", "wrap" };
char const * const * const end_dialognames = char const * const * const end_dialognames =
dialognames + (sizeof(dialognames) / sizeof(char *)); dialognames + (sizeof(dialognames) / sizeof(char *));
@ -133,6 +135,10 @@ Dialog * Dialogs::build(string const & name)
dialog->setController(new ControlChanges(*dialog)); dialog->setController(new ControlChanges(*dialog));
dialog->setView(new QChanges(*dialog)); dialog->setView(new QChanges(*dialog));
dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy); dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
} else if (name == "character") {
dialog->setController(new ControlCharacter(*dialog));
dialog->setView(new QCharacter(*dialog));
dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
} else if (name == "citation") { } else if (name == "citation") {
dialog->setController(new ControlCitation(*dialog)); dialog->setController(new ControlCitation(*dialog));
dialog->setView(new QCitation(*dialog)); dialog->setView(new QCitation(*dialog));

View File

@ -14,7 +14,6 @@
#include "Dialogs.h" #include "Dialogs.h"
#include "controllers/GUI.h" #include "controllers/GUI.h"
#include "ControlCharacter.h"
#include "ControlDocument.h" #include "ControlDocument.h"
#include "ControlForks.h" #include "ControlForks.h"
#include "ControlLog.h" #include "ControlLog.h"
@ -69,9 +68,6 @@
typedef GUI<ControlCharacter, QCharacter, OkApplyCancelReadOnlyPolicy, Qt2BC>
CharacterDialog;
typedef GUI<ControlDocument, QDocument, NoRepeatedApplyReadOnlyPolicy, Qt2BC> typedef GUI<ControlDocument, QDocument, NoRepeatedApplyReadOnlyPolicy, Qt2BC>
DocumentDialog; DocumentDialog;
@ -114,7 +110,6 @@ VCLogFileDialog;
struct Dialogs::Impl { struct Dialogs::Impl {
Impl(LyXView & lv, Dialogs & d); Impl(LyXView & lv, Dialogs & d);
CharacterDialog character;
DocumentDialog document; DocumentDialog document;
FileDialog file; FileDialog file;
LogFileDialog logfile; LogFileDialog logfile;

View File

@ -29,11 +29,11 @@
using namespace frnt; using namespace frnt;
using std::vector; using std::vector;
typedef Qt2CB<ControlCharacter, Qt2DB<QCharacterDialog> > base_class; typedef QController<ControlCharacter, QView<QCharacterDialog> > base_class;
QCharacter::QCharacter() QCharacter::QCharacter(Dialog & parent)
: base_class(qt_("LyX: Change Character Settings")) : base_class(parent, qt_("LyX: Change Character Settings"))
{ {
} }

View File

@ -14,7 +14,7 @@
#define QCHARACTER_H #define QCHARACTER_H
#include "Qt2Base.h" #include "QDialogView.h"
#include "controllers/character.h" #include "controllers/character.h"
#include "controllers/frnt_lang.h" #include "controllers/frnt_lang.h"
@ -28,12 +28,12 @@ class QCharacterDialog;
class QCharacter class QCharacter
: public Qt2CB<ControlCharacter, Qt2DB<QCharacterDialog> > : public QController<ControlCharacter, QView<QCharacterDialog> >
{ {
public: public:
friend class QCharacterDialog; friend class QCharacterDialog;
QCharacter(); QCharacter(Dialog &);
private: private:
/// Apply changes /// Apply changes
virtual void apply(); virtual void apply();

View File

@ -1,3 +1,15 @@
2003-03-12 Angus Leeming <leeming@lyx.org>
* Dialogs.C:
* Dialogs2.C:
* Dialogs_impl.h: remove character dialog.
* Dialogs3.C: add character dialog.
* FormCharacter.[Ch]:
* forms/form_character.[Ch]: changes to use the new Dialog-based
scheme.
2003-03-10 Angus Leeming <leeming@lyx.org> 2003-03-10 Angus Leeming <leeming@lyx.org>
* Dialogs3.C (build): the "tabularcreate" dialog is always valid. * Dialogs3.C (build): the "tabularcreate" dialog is always valid.

View File

@ -27,8 +27,7 @@ Dialogs::~Dialogs()
Dialogs::Impl::Impl(LyXView & lv, Dialogs & d) Dialogs::Impl::Impl(LyXView & lv, Dialogs & d)
: character(lv, d), : document(lv, d),
document(lv, d),
file(lv, d), file(lv, d),
forks(lv, d), forks(lv, d),
logfile(lv, d), logfile(lv, d),

View File

@ -15,18 +15,6 @@
#include "Dialogs_impl.h" #include "Dialogs_impl.h"
void Dialogs::showCharacter()
{
pimpl_->character.controller().show();
}
void Dialogs::setUserFreeFont()
{
pimpl_->character.controller().apply();
}
void Dialogs::showDocument() void Dialogs::showDocument()
{ {
pimpl_->document.controller().show(); pimpl_->document.controller().show();

View File

@ -18,6 +18,7 @@
#include "ControlAboutlyx.h" #include "ControlAboutlyx.h"
#include "ControlBibtex.h" #include "ControlBibtex.h"
#include "ControlChanges.h" #include "ControlChanges.h"
#include "ControlCharacter.h"
#include "ControlCitation.h" #include "ControlCitation.h"
#include "ControlCommand.h" #include "ControlCommand.h"
#include "ControlError.h" #include "ControlError.h"
@ -41,6 +42,8 @@
#include "forms/form_bibtex.h" #include "forms/form_bibtex.h"
#include "FormChanges.h" #include "FormChanges.h"
#include "forms/form_changes.h" #include "forms/form_changes.h"
#include "FormCharacter.h"
#include "forms/form_character.h"
#include "FormCitation.h" #include "FormCitation.h"
#include "forms/form_citation.h" #include "forms/form_citation.h"
#include "FormError.h" #include "FormError.h"
@ -79,10 +82,9 @@
namespace { namespace {
char const * const dialognames[] = { "about", "bibitem", "bibtex", "changes", char const * const dialognames[] = { "about", "bibitem", "bibtex", "changes",
"citation", "error", "ert", "external", "character", "citation", "error", "ert", "external", "float", "graphics",
"float", "graphics", "include", "index", "include", "index", "label", "minipage", "ref", "tabular", "tabularcreate",
"label", "minipage", "ref", "tabular", "toc", "url", "wrap" };
"tabularcreate", "toc", "url", "wrap" };
char const * const * const end_dialognames = char const * const * const end_dialognames =
dialognames + (sizeof(dialognames) / sizeof(char *)); dialognames + (sizeof(dialognames) / sizeof(char *));
@ -127,6 +129,10 @@ Dialog * Dialogs::build(string const & name)
dialog->setController(new ControlBibtex(*dialog)); dialog->setController(new ControlBibtex(*dialog));
dialog->setView(new FormBibtex(*dialog)); dialog->setView(new FormBibtex(*dialog));
dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy); dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
} else if (name == "character") {
dialog->setController(new ControlCharacter(*dialog));
dialog->setView(new FormCharacter(*dialog));
dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
} else if (name == "changes") { } else if (name == "changes") {
dialog->setController(new ControlChanges(*dialog)); dialog->setController(new ControlChanges(*dialog));
dialog->setView(new FormChanges(*dialog)); dialog->setView(new FormChanges(*dialog));

View File

@ -21,10 +21,6 @@
#include "FormBrowser.h" #include "FormBrowser.h"
#include "forms/form_browser.h" #include "forms/form_browser.h"
#include "ControlCharacter.h"
#include "FormCharacter.h"
#include "forms/form_character.h"
#include "ControlDocument.h" #include "ControlDocument.h"
#include "FormDocument.h" #include "FormDocument.h"
#include "forms/form_document.h" #include "forms/form_document.h"
@ -84,9 +80,6 @@
#include "ControlVCLog.h" #include "ControlVCLog.h"
#include "FormVCLog.h" #include "FormVCLog.h"
typedef GUI<ControlCharacter, FormCharacter, OkApplyCancelReadOnlyPolicy, xformsBC>
CharacterDialog;
typedef GUI<ControlDocument, FormDocument, NoRepeatedApplyReadOnlyPolicy, xformsBC> typedef GUI<ControlDocument, FormDocument, NoRepeatedApplyReadOnlyPolicy, xformsBC>
DocumentDialog; DocumentDialog;
@ -137,7 +130,6 @@ VCLogFileDialog;
struct Dialogs::Impl { struct Dialogs::Impl {
Impl(LyXView & lv, Dialogs & d); Impl(LyXView & lv, Dialogs & d);
CharacterDialog character;
DocumentDialog document; DocumentDialog document;
FileDialog file; FileDialog file;
ForksDialog forks; ForksDialog forks;

View File

@ -34,10 +34,10 @@ using std::find;
using namespace frnt; using namespace frnt;
typedef FormCB<ControlCharacter, FormDB<FD_character> > base_class; typedef FormController<ControlCharacter, FormView<FD_character> > base_class;
FormCharacter::FormCharacter() FormCharacter::FormCharacter(Dialog & parent)
: base_class(_("Character Layout"), false) : base_class(parent, _("Character Layout"), false)
{} {}

View File

@ -14,7 +14,7 @@
#define FORM_CHARACTER_H #define FORM_CHARACTER_H
#include "FormBase.h" #include "FormDialogView.h"
#include "lyxfont.h" // for LyXFont enums #include "lyxfont.h" // for LyXFont enums
#include "ControlCharacter.h" // for ControlCharacter enum #include "ControlCharacter.h" // for ControlCharacter enum
#include "LColor.h" // for LColor enum #include "LColor.h" // for LColor enum
@ -31,10 +31,10 @@ struct FD_character;
* in their documents. * in their documents.
*/ */
class FormCharacter class FormCharacter
: public FormCB<ControlCharacter, FormDB<FD_character> > { : public FormController<ControlCharacter, FormView<FD_character> > {
public: public:
/// ///
FormCharacter(); FormCharacter(Dialog &);
private: private:
/// Apply from dialog /// Apply from dialog

View File

@ -33,7 +33,7 @@ char const * latex_mathstyle[] = {
kb_action latex_mathfontcmds[] = { kb_action latex_mathfontcmds[] = {
LFUN_BOLD, LFUN_SANS, LFUN_ROMAN, LFUN_ITAL, LFUN_CODE, LFUN_BOLD, LFUN_SANS, LFUN_ROMAN, LFUN_ITAL, LFUN_CODE,
LFUN_NOUN, LFUN_FRAK, LFUN_EMPH, LFUN_FREE, LFUN_DEFAULT LFUN_NOUN, LFUN_FRAK, LFUN_EMPH, LFUN_FREEFONT_APPLY, LFUN_DEFAULT
}; };

View File

@ -64,7 +64,7 @@ shortcut:
resize: FL_RESIZE_X resize: FL_RESIZE_X
gravity: FL_NorthWest FL_NorthEast gravity: FL_NorthWest FL_NorthEast
name: choice_family name: choice_family
callback: C_FormBaseInputCB callback: C_FormDialogView_InputCB
argument: 0 argument: 0
-------------------- --------------------
@ -82,7 +82,7 @@ shortcut:
resize: FL_RESIZE_X resize: FL_RESIZE_X
gravity: FL_NorthWest FL_NorthEast gravity: FL_NorthWest FL_NorthEast
name: choice_series name: choice_series
callback: C_FormBaseInputCB callback: C_FormDialogView_InputCB
argument: 0 argument: 0
-------------------- --------------------
@ -100,7 +100,7 @@ shortcut:
resize: FL_RESIZE_X resize: FL_RESIZE_X
gravity: FL_NorthWest FL_NorthEast gravity: FL_NorthWest FL_NorthEast
name: choice_shape name: choice_shape
callback: C_FormBaseInputCB callback: C_FormDialogView_InputCB
argument: 0 argument: 0
-------------------- --------------------
@ -118,7 +118,7 @@ shortcut:
resize: FL_RESIZE_X resize: FL_RESIZE_X
gravity: FL_NorthWest FL_NorthEast gravity: FL_NorthWest FL_NorthEast
name: choice_size name: choice_size
callback: C_FormBaseInputCB callback: C_FormDialogView_InputCB
argument: 0 argument: 0
-------------------- --------------------
@ -136,7 +136,7 @@ shortcut:
resize: FL_RESIZE_X resize: FL_RESIZE_X
gravity: FL_NorthWest FL_NorthEast gravity: FL_NorthWest FL_NorthEast
name: choice_bar name: choice_bar
callback: C_FormBaseInputCB callback: C_FormDialogView_InputCB
argument: 0 argument: 0
-------------------- --------------------
@ -154,7 +154,7 @@ shortcut:
resize: FL_RESIZE_NONE resize: FL_RESIZE_NONE
gravity: FL_SouthEast FL_SouthEast gravity: FL_SouthEast FL_SouthEast
name: button_apply name: button_apply
callback: C_FormBaseApplyCB callback: C_FormDialogView_ApplyCB
argument: 0 argument: 0
-------------------- --------------------
@ -172,7 +172,7 @@ shortcut:
resize: FL_RESIZE_NONE resize: FL_RESIZE_NONE
gravity: FL_SouthEast FL_SouthEast gravity: FL_SouthEast FL_SouthEast
name: button_close name: button_close
callback: C_FormBaseCancelCB callback: C_FormDialogView_CancelCB
argument: 0 argument: 0
-------------------- --------------------
@ -190,7 +190,7 @@ shortcut:
resize: FL_RESIZE_X resize: FL_RESIZE_X
gravity: FL_NorthWest FL_NorthEast gravity: FL_NorthWest FL_NorthEast
name: choice_color name: choice_color
callback: C_FormBaseInputCB callback: C_FormDialogView_InputCB
argument: 0 argument: 0
-------------------- --------------------
@ -208,7 +208,7 @@ shortcut:
resize: FL_RESIZE_X resize: FL_RESIZE_X
gravity: FL_NorthWest FL_NorthEast gravity: FL_NorthWest FL_NorthEast
name: check_toggle_all name: check_toggle_all
callback: C_FormBaseInputCB callback: C_FormDialogView_InputCB
argument: 0 argument: 0
-------------------- --------------------
@ -226,7 +226,7 @@ shortcut:
resize: FL_RESIZE_X resize: FL_RESIZE_X
gravity: FL_NorthWest FL_NorthEast gravity: FL_NorthWest FL_NorthEast
name: choice_language name: choice_language
callback: C_FormBaseInputCB callback: C_FormDialogView_InputCB
argument: 0 argument: 0
-------------------- --------------------

View File

@ -35,7 +35,7 @@ InsetError::InsetError(string const & str, bool)
InsetError::~InsetError() InsetError::~InsetError()
{ {
Dialogs::hide()("error", this); Dialogs::hide("error", this);
} }

View File

@ -36,5 +36,5 @@ void MailInset::updateDialog(BufferView * bv) const
void MailInset::hideDialog() const void MailInset::hideDialog() const
{ {
Dialogs::hide()(name(), &inset()); Dialogs::hide(name(), &inset());
} }

View File

@ -1101,9 +1101,13 @@ void LyXFunc::dispatch(FuncRequest const & ev, bool verbose)
changeDepth(view(), TEXT(false), 1); changeDepth(view(), TEXT(false), 1);
break; break;
case LFUN_FREE: case LFUN_FREEFONT_APPLY:
owner->getDialogs().setUserFreeFont(); apply_freefont(view());
break; break;
case LFUN_FREEFONT_UPDATE:
update_and_apply_freefont(view(), argument);
break;
case LFUN_RECONFIGURE: case LFUN_RECONFIGURE:
Reconfigure(view()); Reconfigure(view());
@ -1232,9 +1236,12 @@ void LyXFunc::dispatch(FuncRequest const & ev, bool verbose)
owner->getDialogs().showParagraph(); owner->getDialogs().showParagraph();
break; break;
case LFUN_LAYOUT_CHARACTER: case LFUN_LAYOUT_CHARACTER: {
owner->getDialogs().showCharacter(); string data = freefont2string();
break; if (!data.empty())
owner->getDialogs().show("character", data);
break;
}
case LFUN_LAYOUT_TABULAR: case LFUN_LAYOUT_TABULAR:
if (view()->theLockingInset()) { if (view()->theLockingInset()) {
@ -1409,7 +1416,7 @@ void LyXFunc::dispatch(FuncRequest const & ev, bool verbose)
break; break;
case LFUN_DIALOG_HIDE: case LFUN_DIALOG_HIDE:
Dialogs::hide()(argument, 0); Dialogs::hide(argument, 0);
break; break;
case LFUN_DIALOG_DISCONNECT_INSET: case LFUN_DIALOG_DISCONNECT_INSET:

View File

@ -661,7 +661,7 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd)
case LFUN_FRAK: handleFont(bv, cmd.argument, "mathfrak"); break; case LFUN_FRAK: handleFont(bv, cmd.argument, "mathfrak"); break;
case LFUN_ITAL: handleFont(bv, cmd.argument, "mathit"); break; case LFUN_ITAL: handleFont(bv, cmd.argument, "mathit"); break;
case LFUN_NOUN: handleFont(bv, cmd.argument, "mathbb"); break; case LFUN_NOUN: handleFont(bv, cmd.argument, "mathbb"); break;
case LFUN_FREE: handleFont(bv, cmd.argument, "textrm"); break; case LFUN_FREEFONT_APPLY: handleFont(bv, cmd.argument, "textrm"); break;
case LFUN_DEFAULT: handleFont(bv, cmd.argument, "textnormal"); break; case LFUN_DEFAULT: handleFont(bv, cmd.argument, "textnormal"); break;
//case LFUN_GREEK: //case LFUN_GREEK: