From 4a842aeb20a0f0b9e34baff4bc0fac820845c453 Mon Sep 17 00:00:00 2001 From: Angus Leeming Date: Wed, 12 Mar 2003 22:17:50 +0000 Subject: [PATCH] Yesterday's character dialog patch git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6472 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/ChangeLog | 6 + .../{font-free.xpm => font-free-apply.xpm} | 0 lib/ui/default.ui | 6 +- src/BufferView_pimpl.C | 12 -- src/ChangeLog | 17 ++ src/LyXAction.C | 5 +- src/ToolbarDefaults.C | 2 +- src/bufferview_funcs.C | 166 +++++++++++++++++- src/bufferview_funcs.h | 37 +++- src/commandtags.h | 3 +- src/frontends/ChangeLog | 9 + src/frontends/Dialogs.C | 20 ++- src/frontends/Dialogs.h | 51 +++--- src/frontends/controllers/ChangeLog | 5 + src/frontends/controllers/ControlCharacter.C | 41 ++--- src/frontends/controllers/ControlCharacter.h | 23 ++- src/frontends/guiapi.C | 12 -- src/frontends/guiapi.h | 2 - src/frontends/qt2/ChangeLog | 10 ++ src/frontends/qt2/Dialogs.C | 3 +- src/frontends/qt2/Dialogs2.C | 12 -- src/frontends/qt2/Dialogs3.C | 14 +- src/frontends/qt2/Dialogs_impl.h | 5 - src/frontends/qt2/QCharacter.C | 6 +- src/frontends/qt2/QCharacter.h | 6 +- src/frontends/xforms/ChangeLog | 12 ++ src/frontends/xforms/Dialogs.C | 3 +- src/frontends/xforms/Dialogs2.C | 12 -- src/frontends/xforms/Dialogs3.C | 14 +- src/frontends/xforms/Dialogs_impl.h | 8 - src/frontends/xforms/FormCharacter.C | 6 +- src/frontends/xforms/FormCharacter.h | 6 +- src/frontends/xforms/FormMathsStyle.C | 2 +- src/frontends/xforms/forms/form_character.fd | 20 +-- src/insets/inseterror.C | 2 +- src/insets/mailinset.C | 2 +- src/lyxfunc.C | 21 ++- src/mathed/formulabase.C | 2 +- 38 files changed, 390 insertions(+), 193 deletions(-) rename lib/images/{font-free.xpm => font-free-apply.xpm} (100%) diff --git a/lib/ChangeLog b/lib/ChangeLog index 724d9cda36..20383755eb 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,9 @@ +2003-03-12 Angus Leeming + + * images/font-free.xpm: renamed as font-free-apply.xpm. + + * ui/default.ui: s/font-free/font-free-apply/ + 2003-03-12 Dekel Tsur * lyx2lyx/lyx2lyx (main): Print error messages to stderr. diff --git a/lib/images/font-free.xpm b/lib/images/font-free-apply.xpm similarity index 100% rename from lib/images/font-free.xpm rename to lib/images/font-free-apply.xpm diff --git a/lib/ui/default.ui b/lib/ui/default.ui index 0b732bc561..c89eb07fb6 100644 --- a/lib/ui/default.ui +++ b/lib/ui/default.ui @@ -219,8 +219,8 @@ Menuset End Menu "insert_special" - Item "Superscript|S" "command-sequence math-mode ; math-superscript ; font-free; " - Item "Subscript|u" "command-sequence math-mode ; math-subscript ; 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-apply; " Item "HFill|H" "hfill-insert" Item "Hyphenation Point|P" "hyphenation-point-insert" Item "Ligature Break|k" "ligature-break-insert" @@ -423,7 +423,7 @@ Toolbar Separator Icon "font-emph" Icon "font-noun" - Icon "font-free" + Icon "font-free-apply" Separator Icon "ert-insert" Icon "math-mode" diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index 79df187825..7090caa658 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -997,18 +997,6 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev_in) switchKeyMap(); 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: MenuInsertLyXFile(ev.argument); break; diff --git a/src/ChangeLog b/src/ChangeLog index 84292e173a..3b74809012 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,20 @@ +2003-03-12 Angus Leeming + + * 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 * buffer.C: diff --git a/src/LyXAction.C b/src/LyXAction.C index 06f1dab078..f19f819197 100644 --- a/src/LyXAction.C +++ b/src/LyXAction.C @@ -191,8 +191,9 @@ void LyXAction::init() { LFUN_DEFAULT, "font-default", N_("Default font style"), Noop }, { LFUN_EMPH, "font-emph", N_("Toggle emphasize"), Noop }, - { LFUN_FREE, "font-free", N_("Toggle user defined style"), - Noop }, + { LFUN_FREEFONT_APPLY, "font-free-apply", + N_("Toggle user defined style"), Noop }, + { LFUN_FREEFONT_UPDATE, "font-free-update", "", Noop }, { LFUN_NOUN, "font-noun", N_("Toggle noun style"), Noop }, { LFUN_ROMAN, "font-roman", N_("Toggle roman font style"), Noop }, diff --git a/src/ToolbarDefaults.C b/src/ToolbarDefaults.C index 86c5c151bb..b26a0dcf5a 100644 --- a/src/ToolbarDefaults.C +++ b/src/ToolbarDefaults.C @@ -73,7 +73,7 @@ void ToolbarDefaults::init() add(LFUN_EMPH); add(LFUN_NOUN); - add(LFUN_FREE); + add(LFUN_FREEFONT_APPLY); add(SEPARATOR); add(LFUN_INSET_FOOTNOTE); diff --git a/src/bufferview_funcs.C b/src/bufferview_funcs.C index 4ed3413732..feec11d5e8 100644 --- a/src/bufferview_funcs.C +++ b/src/bufferview_funcs.C @@ -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 - * Copyright 1995-2001 The LyX Team. - * - * ====================================================== */ + * Full author contact details are available in file CREDITS + */ #include @@ -14,6 +17,7 @@ #include "BufferView.h" #include "paragraph.h" #include "lyxfont.h" +#include "lyxlex.h" #include "lyxtext.h" #include "buffer.h" #include "lyx_cb.h" @@ -27,11 +31,157 @@ #include "frontends/Alert.h" #include "support/lstrings.h" +#include "Lsstream.h" #include "insets/updatableinset.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(Int)); + + } else if (token == "series") { + font.setSeries(static_cast(Int)); + + } else if (token == "shape") { + font.setShape(static_cast(Int)); + + } else if (token == "size") { + font.setSize(static_cast(Int)); + + } else if (token == "emph") { + font.setEmph(static_cast(Int)); + + } else if (token == "underbar") { + font.setUnderbar(static_cast(Int)); + + } else if (token == "noun") { + font.setNoun(static_cast(Int)); + + } else if (token == "number") { + font.setNumber(static_cast(Int)); + + } else if (token == "color") { + font.setColor(static_cast(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) { LyXFont font(LyXFont::ALL_IGNORE); @@ -77,7 +227,7 @@ void lang(BufferView * bv, string const & l) // Change environment depth. // if decInc >= 0, increment depth -// if decInc < 0, decrement depth +// if decInc < 0, decrement depth void changeDepth(BufferView * bv, LyXText * text, int decInc) { if (!bv->available() || !text) diff --git a/src/bufferview_funcs.h b/src/bufferview_funcs.h index 0d27e4650a..e829c53dcd 100644 --- a/src/bufferview_funcs.h +++ b/src/bufferview_funcs.h @@ -1,13 +1,15 @@ // -*- 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 - * Copyright 1995-2001 The LyX Team. - * - * ====================================================== */ + * Full author contact details are available in file CREDITS + */ #ifndef BUFFERVIEW_FUNCS_H #define BUFFERVIEW_FUNCS_H @@ -18,6 +20,27 @@ class BufferView; class LyXFont; 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 *); /// diff --git a/src/commandtags.h b/src/commandtags.h index 6e39dd5e67..e93134a3e9 100644 --- a/src/commandtags.h +++ b/src/commandtags.h @@ -46,7 +46,8 @@ enum kb_action { LFUN_HYPHENATION, LFUN_LIGATURE_BREAK, LFUN_HFILL, - LFUN_FREE, // 30 + LFUN_FREEFONT_APPLY, + LFUN_FREEFONT_UPDATE, #if 0 LFUN_FOOTMELT, // schedule for deletion LFUN_MARGINMELT, // schedule for deletion diff --git a/src/frontends/ChangeLog b/src/frontends/ChangeLog index bb832714c3..225f7c0adb 100644 --- a/src/frontends/ChangeLog +++ b/src/frontends/ChangeLog @@ -1,3 +1,12 @@ +2003-03-12 Angus Leeming + + * 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 * Dialogs.h (hide): make it a static method that returns a diff --git a/src/frontends/Dialogs.C b/src/frontends/Dialogs.C index bfbfd10e20..8f31720b85 100644 --- a/src/frontends/Dialogs.C +++ b/src/frontends/Dialogs.C @@ -13,6 +13,7 @@ #include "Dialogs.h" #include "controllers/Dialog.h" +#include #include @@ -43,11 +44,16 @@ boost::signal0 & Dialogs::redrawGUI() } -boost::signal2 & Dialogs::hide() +namespace { + +BugfixSignal > hideSignal; + +} + + +void Dialogs::hide(string const & name, InsetBase* inset) { - static BugfixSignal > - thesignal; - return thesignal(); + hideSignal()(name, inset); } @@ -56,7 +62,7 @@ Dialogs::Dialogs(LyXView & lyxview) { // Connect signals 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 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); if (!dialog) return; - dialog->show(); + dialog->show(data); } diff --git a/src/frontends/Dialogs.h b/src/frontends/Dialogs.h index c528fc3c1c..7903119799 100644 --- a/src/frontends/Dialogs.h +++ b/src/frontends/Dialogs.h @@ -18,7 +18,7 @@ #include #include #include -#include + class Dialog; class InsetBase; @@ -73,10 +73,6 @@ public: Put into some sort of alphabetical order */ //@{ /// - void showCharacter(); - /// connected to the character dialog also - void setUserFreeFont(); - /// void showDocument(); /// show the contents of a file. void showFile(string const &); @@ -110,24 +106,37 @@ public: void showVCLogFile(); //@} - ///name == "about" etc - void show(string const & name); - /** name == "bibtex", "citation" etc - data is generated by the Inset::write method, to be read by the - Inset::read method in the frontends. - inset is stored. On a subsequent Apply from the frontends, the - stored inset will be modified. If no inset is stored, then a - new one will be created at the current cursor position. - */ + /** \param name == "about" etc; an identifier used to + launch a particular dialog. + \param data is a string encoding of the data used to populate + the dialog. Several of these dialogs do not need any data, + so it defaults to string(). + */ + void show(string const & name, string const & data = string()); + + /** \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); - /** 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); - /** All Dialogs of the given 'name' will be closed if they are - connected to the given 'inset'. - */ - static boost::signal2 & hide(); + + /** All Dialogs of the given \param name will be closed if they are + connected to the given \param inset. + */ + static void hide(string const & name, InsetBase * inset); /// void disconnect(string const & name); /// diff --git a/src/frontends/controllers/ChangeLog b/src/frontends/controllers/ChangeLog index 4579834a2b..ba80f12748 100644 --- a/src/frontends/controllers/ChangeLog +++ b/src/frontends/controllers/ChangeLog @@ -1,3 +1,8 @@ +2003-03-12 Angus Leeming + + * ControlCharacter.[Ch]: rewrite to use the Dialog-based scheme and + the new dispatch lfuns. + 2003-03-09 Angus Leeming Flatten the ButtonController tree by splitting it into a Controller diff --git a/src/frontends/controllers/ControlCharacter.C b/src/frontends/controllers/ControlCharacter.C index b593ec008d..aaf48c846d 100644 --- a/src/frontends/controllers/ControlCharacter.C +++ b/src/frontends/controllers/ControlCharacter.C @@ -10,30 +10,25 @@ #include - #include "ControlCharacter.h" - -#include "ViewBase.h" #include "ButtonController.h" #include "buffer.h" -#include "bufferview_funcs.h" // ToggleAndShow +#include "bufferview_funcs.h" +#include "funcrequest.h" #include "gettext.h" #include "language.h" -#include "frontends/LyXView.h" - -ControlCharacter::ControlCharacter(LyXView & lv, Dialogs & d) - : ControlDialogBD(lv, d), +ControlCharacter::ControlCharacter(Dialog & parent) + : Dialog::Controller(parent), 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 - // view has been built + // Do this the first time only. if (!font_.get()) font_.reset(new LyXFont(LyXFont::ALL_IGNORE)); @@ -45,24 +40,24 @@ void ControlCharacter::setParams() getBar() != frnt::IGNORE || getColor() != LColor::ignore || 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()) return; - // Apply from the view if it's visible. Otherwise, use the stored values - if (bufferIsAvailable()) - view().apply(); - - toggleAndShow(bufferview(), *(font_.get()), toggleall_); - lv_.view_state_changed(); - buffer()->markDirty(); - lv_.message(_("Character set")); + string data; + if (font2string(*font_.get(), toggleall_, data)) { + kernel().dispatch(FuncRequest(LFUN_FREEFONT_UPDATE, data)); + } } @@ -220,7 +215,7 @@ void ControlCharacter::setLanguage(string const & val) font_->setLanguage(ignore_language); else if (val == "reset") - font_->setLanguage(buffer()->params.language); + font_->setLanguage(kernel().buffer()->params.language); else font_->setLanguage(languages.getLanguage(val)); diff --git a/src/frontends/controllers/ControlCharacter.h b/src/frontends/controllers/ControlCharacter.h index 454ff33680..ca8062b76d 100644 --- a/src/frontends/controllers/ControlCharacter.h +++ b/src/frontends/controllers/ControlCharacter.h @@ -13,17 +13,22 @@ #define CONTROLCHARACTER_H -#include "ControlDialog_impl.h" +#include "Dialog.h" #include "character.h" -#include -/** A controller for Character dialogs. - */ -class ControlCharacter : public ControlDialogBD { +class ControlCharacter : public Dialog::Controller { 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); @@ -58,13 +63,7 @@ public: string getLanguage() const; /// bool getToggleAll() const; - - /// Get changed parameters and Dispatch them to the kernel. - virtual void apply(); private: - /// set the params before show or update. - virtual void setParams(); - /// boost::scoped_ptr font_; /// diff --git a/src/frontends/guiapi.C b/src/frontends/guiapi.C index c2d90b71ef..cbae88913e 100644 --- a/src/frontends/guiapi.C +++ b/src/frontends/guiapi.C @@ -21,18 +21,6 @@ void gui_show_dialog(Dialogs * d, char const * name, char const * data) d->show(name, data, 0); } -void gui_ShowCharacter(Dialogs & d) -{ - d.showCharacter(); -} - - -void gui_SetUserFreeFont(Dialogs & d) -{ - d.setUserFreeFont(); -} - - void gui_ShowDocument(Dialogs & d) { d.showDocument(); diff --git a/src/frontends/guiapi.h b/src/frontends/guiapi.h index 597b13dea2..1ef1241e84 100644 --- a/src/frontends/guiapi.h +++ b/src/frontends/guiapi.h @@ -21,8 +21,6 @@ extern "C" { 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_ShowFile(string const &, Dialogs &); void gui_ShowForks(Dialogs &); diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index 4beae6e4f1..1eac2eecc7 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,13 @@ +2003-03-12 Angus Leeming + + * 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 * QSearch.C: don't disable checkboxes on RO doc (bug 937) diff --git a/src/frontends/qt2/Dialogs.C b/src/frontends/qt2/Dialogs.C index bd466b5398..b5a434cdf5 100644 --- a/src/frontends/qt2/Dialogs.C +++ b/src/frontends/qt2/Dialogs.C @@ -27,8 +27,7 @@ Dialogs::~Dialogs() Dialogs::Impl::Impl(LyXView & lv, Dialogs & d) - : character(lv, d), - document(lv, d), + : document(lv, d), file(lv, d), logfile(lv, d), paragraph(lv, d), diff --git a/src/frontends/qt2/Dialogs2.C b/src/frontends/qt2/Dialogs2.C index 82d6b74959..6e6e1eda80 100644 --- a/src/frontends/qt2/Dialogs2.C +++ b/src/frontends/qt2/Dialogs2.C @@ -15,18 +15,6 @@ #include "Dialogs_impl.h" -void Dialogs::showCharacter() -{ - pimpl_->character.controller().show(); -} - - -void Dialogs::setUserFreeFont() -{ - pimpl_->character.controller().apply(); -} - - void Dialogs::showDocument() { pimpl_->document.controller().show(); diff --git a/src/frontends/qt2/Dialogs3.C b/src/frontends/qt2/Dialogs3.C index 077011638a..734aa5d6a3 100644 --- a/src/frontends/qt2/Dialogs3.C +++ b/src/frontends/qt2/Dialogs3.C @@ -16,6 +16,7 @@ #include "ControlAboutlyx.h" #include "ControlBibtex.h" #include "ControlChanges.h" +#include "ControlCharacter.h" #include "ControlCitation.h" #include "ControlError.h" #include "ControlERT.h" @@ -38,6 +39,8 @@ #include "QBibtexDialog.h" #include "QChanges.h" #include "QChangesDialog.h" +#include "QCharacter.h" +#include "QCharacterDialog.h" #include "QCitation.h" #include "QCitationDialog.h" #include "QError.h" @@ -81,10 +84,9 @@ namespace { char const * const dialognames[] = { "about", "bibitem", "bibtex", "changes", - "citation", "error", "ert", "external", - "float", "graphics", "include", "index", - "label", "minipage", "ref", "tabular", - "tabularcreate", "toc", "url", "wrap" }; +"character", "citation", "error", "ert", "external", "float", "graphics", +"include", "index", "label", "minipage", "ref", "tabular", "tabularcreate", +"toc", "url", "wrap" }; char const * const * const end_dialognames = dialognames + (sizeof(dialognames) / sizeof(char *)); @@ -133,6 +135,10 @@ Dialog * Dialogs::build(string const & name) dialog->setController(new ControlChanges(*dialog)); dialog->setView(new QChanges(*dialog)); 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") { dialog->setController(new ControlCitation(*dialog)); dialog->setView(new QCitation(*dialog)); diff --git a/src/frontends/qt2/Dialogs_impl.h b/src/frontends/qt2/Dialogs_impl.h index 4712a62132..76de9c376a 100644 --- a/src/frontends/qt2/Dialogs_impl.h +++ b/src/frontends/qt2/Dialogs_impl.h @@ -14,7 +14,6 @@ #include "Dialogs.h" #include "controllers/GUI.h" -#include "ControlCharacter.h" #include "ControlDocument.h" #include "ControlForks.h" #include "ControlLog.h" @@ -69,9 +68,6 @@ -typedef GUI -CharacterDialog; - typedef GUI DocumentDialog; @@ -114,7 +110,6 @@ VCLogFileDialog; struct Dialogs::Impl { Impl(LyXView & lv, Dialogs & d); - CharacterDialog character; DocumentDialog document; FileDialog file; LogFileDialog logfile; diff --git a/src/frontends/qt2/QCharacter.C b/src/frontends/qt2/QCharacter.C index dac9c882f3..e3091e773d 100644 --- a/src/frontends/qt2/QCharacter.C +++ b/src/frontends/qt2/QCharacter.C @@ -29,11 +29,11 @@ using namespace frnt; using std::vector; -typedef Qt2CB > base_class; +typedef QController > base_class; -QCharacter::QCharacter() - : base_class(qt_("LyX: Change Character Settings")) +QCharacter::QCharacter(Dialog & parent) + : base_class(parent, qt_("LyX: Change Character Settings")) { } diff --git a/src/frontends/qt2/QCharacter.h b/src/frontends/qt2/QCharacter.h index ad955842a8..8d29563919 100644 --- a/src/frontends/qt2/QCharacter.h +++ b/src/frontends/qt2/QCharacter.h @@ -14,7 +14,7 @@ #define QCHARACTER_H -#include "Qt2Base.h" +#include "QDialogView.h" #include "controllers/character.h" #include "controllers/frnt_lang.h" @@ -28,12 +28,12 @@ class QCharacterDialog; class QCharacter - : public Qt2CB > + : public QController > { public: friend class QCharacterDialog; - QCharacter(); + QCharacter(Dialog &); private: /// Apply changes virtual void apply(); diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 89cdf69295..dbe21084f9 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,15 @@ +2003-03-12 Angus Leeming + + * 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 * Dialogs3.C (build): the "tabularcreate" dialog is always valid. diff --git a/src/frontends/xforms/Dialogs.C b/src/frontends/xforms/Dialogs.C index 63fc41a07f..62b04a2d30 100644 --- a/src/frontends/xforms/Dialogs.C +++ b/src/frontends/xforms/Dialogs.C @@ -27,8 +27,7 @@ Dialogs::~Dialogs() Dialogs::Impl::Impl(LyXView & lv, Dialogs & d) - : character(lv, d), - document(lv, d), + : document(lv, d), file(lv, d), forks(lv, d), logfile(lv, d), diff --git a/src/frontends/xforms/Dialogs2.C b/src/frontends/xforms/Dialogs2.C index 9dc74d6f35..9f9feca9aa 100644 --- a/src/frontends/xforms/Dialogs2.C +++ b/src/frontends/xforms/Dialogs2.C @@ -15,18 +15,6 @@ #include "Dialogs_impl.h" -void Dialogs::showCharacter() -{ - pimpl_->character.controller().show(); -} - - -void Dialogs::setUserFreeFont() -{ - pimpl_->character.controller().apply(); -} - - void Dialogs::showDocument() { pimpl_->document.controller().show(); diff --git a/src/frontends/xforms/Dialogs3.C b/src/frontends/xforms/Dialogs3.C index e2a66c82fc..9817abd872 100644 --- a/src/frontends/xforms/Dialogs3.C +++ b/src/frontends/xforms/Dialogs3.C @@ -18,6 +18,7 @@ #include "ControlAboutlyx.h" #include "ControlBibtex.h" #include "ControlChanges.h" +#include "ControlCharacter.h" #include "ControlCitation.h" #include "ControlCommand.h" #include "ControlError.h" @@ -41,6 +42,8 @@ #include "forms/form_bibtex.h" #include "FormChanges.h" #include "forms/form_changes.h" +#include "FormCharacter.h" +#include "forms/form_character.h" #include "FormCitation.h" #include "forms/form_citation.h" #include "FormError.h" @@ -79,10 +82,9 @@ namespace { char const * const dialognames[] = { "about", "bibitem", "bibtex", "changes", - "citation", "error", "ert", "external", - "float", "graphics", "include", "index", - "label", "minipage", "ref", "tabular", - "tabularcreate", "toc", "url", "wrap" }; +"character", "citation", "error", "ert", "external", "float", "graphics", +"include", "index", "label", "minipage", "ref", "tabular", "tabularcreate", +"toc", "url", "wrap" }; char const * const * const end_dialognames = dialognames + (sizeof(dialognames) / sizeof(char *)); @@ -127,6 +129,10 @@ Dialog * Dialogs::build(string const & name) dialog->setController(new ControlBibtex(*dialog)); dialog->setView(new FormBibtex(*dialog)); 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") { dialog->setController(new ControlChanges(*dialog)); dialog->setView(new FormChanges(*dialog)); diff --git a/src/frontends/xforms/Dialogs_impl.h b/src/frontends/xforms/Dialogs_impl.h index 8fd40e7e17..4942644fca 100644 --- a/src/frontends/xforms/Dialogs_impl.h +++ b/src/frontends/xforms/Dialogs_impl.h @@ -21,10 +21,6 @@ #include "FormBrowser.h" #include "forms/form_browser.h" -#include "ControlCharacter.h" -#include "FormCharacter.h" -#include "forms/form_character.h" - #include "ControlDocument.h" #include "FormDocument.h" #include "forms/form_document.h" @@ -84,9 +80,6 @@ #include "ControlVCLog.h" #include "FormVCLog.h" -typedef GUI -CharacterDialog; - typedef GUI DocumentDialog; @@ -137,7 +130,6 @@ VCLogFileDialog; struct Dialogs::Impl { Impl(LyXView & lv, Dialogs & d); - CharacterDialog character; DocumentDialog document; FileDialog file; ForksDialog forks; diff --git a/src/frontends/xforms/FormCharacter.C b/src/frontends/xforms/FormCharacter.C index 2765515d31..d4ba682f13 100644 --- a/src/frontends/xforms/FormCharacter.C +++ b/src/frontends/xforms/FormCharacter.C @@ -34,10 +34,10 @@ using std::find; using namespace frnt; -typedef FormCB > base_class; +typedef FormController > base_class; -FormCharacter::FormCharacter() - : base_class(_("Character Layout"), false) +FormCharacter::FormCharacter(Dialog & parent) + : base_class(parent, _("Character Layout"), false) {} diff --git a/src/frontends/xforms/FormCharacter.h b/src/frontends/xforms/FormCharacter.h index 8a132cda98..42e987bb7b 100644 --- a/src/frontends/xforms/FormCharacter.h +++ b/src/frontends/xforms/FormCharacter.h @@ -14,7 +14,7 @@ #define FORM_CHARACTER_H -#include "FormBase.h" +#include "FormDialogView.h" #include "lyxfont.h" // for LyXFont enums #include "ControlCharacter.h" // for ControlCharacter enum #include "LColor.h" // for LColor enum @@ -31,10 +31,10 @@ struct FD_character; * in their documents. */ class FormCharacter - : public FormCB > { + : public FormController > { public: /// - FormCharacter(); + FormCharacter(Dialog &); private: /// Apply from dialog diff --git a/src/frontends/xforms/FormMathsStyle.C b/src/frontends/xforms/FormMathsStyle.C index 5d88021329..155dbb9b4c 100644 --- a/src/frontends/xforms/FormMathsStyle.C +++ b/src/frontends/xforms/FormMathsStyle.C @@ -33,7 +33,7 @@ char const * latex_mathstyle[] = { kb_action latex_mathfontcmds[] = { 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 }; diff --git a/src/frontends/xforms/forms/form_character.fd b/src/frontends/xforms/forms/form_character.fd index c0f0c7af21..6eac504cfe 100644 --- a/src/frontends/xforms/forms/form_character.fd +++ b/src/frontends/xforms/forms/form_character.fd @@ -64,7 +64,7 @@ shortcut: resize: FL_RESIZE_X gravity: FL_NorthWest FL_NorthEast name: choice_family -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -82,7 +82,7 @@ shortcut: resize: FL_RESIZE_X gravity: FL_NorthWest FL_NorthEast name: choice_series -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -100,7 +100,7 @@ shortcut: resize: FL_RESIZE_X gravity: FL_NorthWest FL_NorthEast name: choice_shape -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -118,7 +118,7 @@ shortcut: resize: FL_RESIZE_X gravity: FL_NorthWest FL_NorthEast name: choice_size -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -136,7 +136,7 @@ shortcut: resize: FL_RESIZE_X gravity: FL_NorthWest FL_NorthEast name: choice_bar -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -154,7 +154,7 @@ shortcut: resize: FL_RESIZE_NONE gravity: FL_SouthEast FL_SouthEast name: button_apply -callback: C_FormBaseApplyCB +callback: C_FormDialogView_ApplyCB argument: 0 -------------------- @@ -172,7 +172,7 @@ shortcut: resize: FL_RESIZE_NONE gravity: FL_SouthEast FL_SouthEast name: button_close -callback: C_FormBaseCancelCB +callback: C_FormDialogView_CancelCB argument: 0 -------------------- @@ -190,7 +190,7 @@ shortcut: resize: FL_RESIZE_X gravity: FL_NorthWest FL_NorthEast name: choice_color -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -208,7 +208,7 @@ shortcut: resize: FL_RESIZE_X gravity: FL_NorthWest FL_NorthEast name: check_toggle_all -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -226,7 +226,7 @@ shortcut: resize: FL_RESIZE_X gravity: FL_NorthWest FL_NorthEast name: choice_language -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- diff --git a/src/insets/inseterror.C b/src/insets/inseterror.C index 858fcf6f15..14f81578d2 100644 --- a/src/insets/inseterror.C +++ b/src/insets/inseterror.C @@ -35,7 +35,7 @@ InsetError::InsetError(string const & str, bool) InsetError::~InsetError() { - Dialogs::hide()("error", this); + Dialogs::hide("error", this); } diff --git a/src/insets/mailinset.C b/src/insets/mailinset.C index 8cf6e8606f..b7563a0cb0 100644 --- a/src/insets/mailinset.C +++ b/src/insets/mailinset.C @@ -36,5 +36,5 @@ void MailInset::updateDialog(BufferView * bv) const void MailInset::hideDialog() const { - Dialogs::hide()(name(), &inset()); + Dialogs::hide(name(), &inset()); } diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 7638abb4b4..708d97a0e9 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -1101,9 +1101,13 @@ void LyXFunc::dispatch(FuncRequest const & ev, bool verbose) changeDepth(view(), TEXT(false), 1); break; - case LFUN_FREE: - owner->getDialogs().setUserFreeFont(); - break; + case LFUN_FREEFONT_APPLY: + apply_freefont(view()); + break; + + case LFUN_FREEFONT_UPDATE: + update_and_apply_freefont(view(), argument); + break; case LFUN_RECONFIGURE: Reconfigure(view()); @@ -1232,9 +1236,12 @@ void LyXFunc::dispatch(FuncRequest const & ev, bool verbose) owner->getDialogs().showParagraph(); break; - case LFUN_LAYOUT_CHARACTER: - owner->getDialogs().showCharacter(); - break; + case LFUN_LAYOUT_CHARACTER: { + string data = freefont2string(); + if (!data.empty()) + owner->getDialogs().show("character", data); + break; + } case LFUN_LAYOUT_TABULAR: if (view()->theLockingInset()) { @@ -1409,7 +1416,7 @@ void LyXFunc::dispatch(FuncRequest const & ev, bool verbose) break; case LFUN_DIALOG_HIDE: - Dialogs::hide()(argument, 0); + Dialogs::hide(argument, 0); break; case LFUN_DIALOG_DISCONNECT_INSET: diff --git a/src/mathed/formulabase.C b/src/mathed/formulabase.C index 4bc566a1e4..16428223d7 100644 --- a/src/mathed/formulabase.C +++ b/src/mathed/formulabase.C @@ -661,7 +661,7 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd) case LFUN_FRAK: handleFont(bv, cmd.argument, "mathfrak"); break; case LFUN_ITAL: handleFont(bv, cmd.argument, "mathit"); 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_GREEK: -- 2.39.2