]> git.lyx.org Git - lyx.git/commitdiff
Yesterday's character dialog patch
authorAngus Leeming <leeming@lyx.org>
Wed, 12 Mar 2003 22:17:50 +0000 (22:17 +0000)
committerAngus Leeming <leeming@lyx.org>
Wed, 12 Mar 2003 22:17:50 +0000 (22:17 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6472 a592a061-630c-0410-9148-cb99ea01b6c8

39 files changed:
lib/ChangeLog
lib/images/font-free-apply.xpm [new file with mode: 0644]
lib/images/font-free.xpm [deleted file]
lib/ui/default.ui
src/BufferView_pimpl.C
src/ChangeLog
src/LyXAction.C
src/ToolbarDefaults.C
src/bufferview_funcs.C
src/bufferview_funcs.h
src/commandtags.h
src/frontends/ChangeLog
src/frontends/Dialogs.C
src/frontends/Dialogs.h
src/frontends/controllers/ChangeLog
src/frontends/controllers/ControlCharacter.C
src/frontends/controllers/ControlCharacter.h
src/frontends/guiapi.C
src/frontends/guiapi.h
src/frontends/qt2/ChangeLog
src/frontends/qt2/Dialogs.C
src/frontends/qt2/Dialogs2.C
src/frontends/qt2/Dialogs3.C
src/frontends/qt2/Dialogs_impl.h
src/frontends/qt2/QCharacter.C
src/frontends/qt2/QCharacter.h
src/frontends/xforms/ChangeLog
src/frontends/xforms/Dialogs.C
src/frontends/xforms/Dialogs2.C
src/frontends/xforms/Dialogs3.C
src/frontends/xforms/Dialogs_impl.h
src/frontends/xforms/FormCharacter.C
src/frontends/xforms/FormCharacter.h
src/frontends/xforms/FormMathsStyle.C
src/frontends/xforms/forms/form_character.fd
src/insets/inseterror.C
src/insets/mailinset.C
src/lyxfunc.C
src/mathed/formulabase.C

index 724d9cda363524bf9bab1a01a66e10d64c972723..20383755ebd7428d0d714a22e2e3dfbd7652bdc5 100644 (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>
 
        * lyx2lyx/lyx2lyx (main): Print error messages to stderr.
diff --git a/lib/images/font-free-apply.xpm b/lib/images/font-free-apply.xpm
new file mode 100644 (file)
index 0000000..124f93e
--- /dev/null
@@ -0,0 +1,27 @@
+/* XPM */
+static char const * free_xpm[] = {
+"20 20 2 1",
+"      c None",
+".     c #000000000000",
+"                    ",
+"                    ",
+"                    ",
+"......            . ",
+".                 . ",
+".     ...  . ..  ...",
+".    .   . ..  .  . ",
+".... .   . .   .  . ",
+".    .   . .   .  . ",
+".    .   . .   .  . ",
+".    .   . .   .  . ",
+".     ...  .   .  ..",
+"                    ",
+"                    ",
+"          .         ",
+"          .         ",
+"        .....       ",
+"         ...        ",
+"          .         ",
+"                    "};
+
+
diff --git a/lib/images/font-free.xpm b/lib/images/font-free.xpm
deleted file mode 100644 (file)
index 124f93e..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/* XPM */
-static char const * free_xpm[] = {
-"20 20 2 1",
-"      c None",
-".     c #000000000000",
-"                    ",
-"                    ",
-"                    ",
-"......            . ",
-".                 . ",
-".     ...  . ..  ...",
-".    .   . ..  .  . ",
-".... .   . .   .  . ",
-".    .   . .   .  . ",
-".    .   . .   .  . ",
-".    .   . .   .  . ",
-".     ...  .   .  ..",
-"                    ",
-"                    ",
-"          .         ",
-"          .         ",
-"        .....       ",
-"         ...        ",
-"          .         ",
-"                    "};
-
-
index 0b732bc561ceb827db5d38bd17783df619d63a2a..c89eb07fb6701ad8ed335373dbc91b0ff254e769 100644 (file)
@@ -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"
index 79df187825ed210eb6e12ae46ea065db18a7aef1..7090caa6588ee785cc0a895007b9dfd53f39fc5e 100644 (file)
@@ -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;
index 84292e173ac2f4c99a6a4661c3e49f6d05a8a92a..3b748090124d11180902afc1008df43680bf426d 100644 (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>
 
        * buffer.C:
index 06f1dab0780e4c031d109bd58399b04e4f64c97d..f19f819197251f48e561225b705b59740b20a5e9 100644 (file)
@@ -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 },
index 86c5c151bbd89415c2659352f1e627238063cf45..b26a0dcf5a392b8f499c112789937c95bed04f2d 100644 (file)
@@ -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);
index 4ed3413732a7a4c8fb59f63780989a631949a29c..feec11d5e8e02cae6c9f11b1e73aca4eed7044c0 100644 (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
- *           Copyright 1995-2001 The LyX Team.
- *
- * ====================================================== */
+ * Full author contact details are available in file CREDITS
+ */
 
 #include <config.h>
 
@@ -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"
 #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<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)
 {
        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)
index 0d27e4650ac9958e7be378c439f3f9f544ed53a5..e829c53dcd5cacaf51cacefb85f62d31fbafb95a 100644 (file)
@@ -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 *);
 ///
index 6e39dd5e67fe5f87f26c97ea6ca81db9718e1e2f..e93134a3e91a4389d29daa988a68b66013e148d8 100644 (file)
@@ -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
index bb832714c37e88d81a2de1ee90ce6b43a493e2f4..225f7c0adb7ef27b1c7dbd971cc585ebfec40feb 100644 (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>
 
        * Dialogs.h (hide): make it a static method that returns a
index bfbfd10e207048d8f08a3f3a061adad18e84dc36..8f31720b854685ee83f12e384ab243fabcc901cc 100644 (file)
@@ -13,6 +13,7 @@
 
 #include "Dialogs.h"
 #include "controllers/Dialog.h"
+#include <boost/signals/signal2.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*> >
-               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);
 }
 
 
index c528fc3c1cd34f24b4bc0ca35b0d0548cc699271..7903119799ba2f28aea20ab4eeaabf9fe609dd0f 100644 (file)
@@ -18,7 +18,7 @@
 #include <boost/scoped_ptr.hpp>
 #include <boost/signals/signal0.hpp>
 #include <boost/signals/signal1.hpp>
-#include <boost/signals/signal2.hpp>
+
 
 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<void, string const &, InsetBase*> & 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);
        ///
index 4579834a2b0ce3f46c6cfec1b5f6768754ca4066..ba80f1274813b2409f292ef0e3ebb86af474a67f 100644 (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>
 
        Flatten the ButtonController tree by splitting it into a Controller
index b593ec008d8afcfe820f8b974a088d734176714f..aaf48c846d05cb1c9e586529aa3e9e89c6d6f087 100644 (file)
 
 #include <config.h>
 
-
 #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));
index 454ff33680e06a1d39e7cb6e470863eea6548de7..ca8062b76d1d4cf619e48c55bc739e80f8c465f8 100644 (file)
 #define CONTROLCHARACTER_H
 
 
-#include "ControlDialog_impl.h"
+#include "Dialog.h"
 #include "character.h"
 
-#include <boost/scoped_ptr.hpp>
 
-/** 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<LyXFont> font_;
        ///
index c2d90b71ef5ad3bfdd0ff813249c1665073edfbe..cbae88913e9b7d2499de992c984ea60661aaa559 100644 (file)
@@ -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();
index 597b13dea21a86249fd3f514f5b076b3cd74f30d..1ef1241e844ff52cbd13060eb48b3ca9c6f44b95 100644 (file)
@@ -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 &);
index 4beae6e4f1a589dc451d3c395503a0a60abaed4b..1eac2eecc78aad93567731bc534018dac3f69350 100644 (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>
 
        * QSearch.C: don't disable checkboxes on RO doc (bug 937)
index bd466b53982e55c961347b50a9e55d4e65cfb1d5..b5a434cdf5c0d45a5b62852142cd1ffe4508439c 100644 (file)
@@ -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),
index 82d6b749598568dab81da7be80a00220e41d96e0..6e6e1eda8067d3f843419867fd4f9e13a48196bc 100644 (file)
 #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();
index 077011638a0dec041f311125555436a15fa02cd4..734aa5d6a3b47b3b9b23955104043dcb18319194 100644 (file)
@@ -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"
 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));
index 4712a621320deea9d811cbb664b0c355b717bf5f..76de9c376aa12723ab4dde0e15f279ce474dd5a5 100644 (file)
@@ -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<ControlCharacter, QCharacter, OkApplyCancelReadOnlyPolicy, Qt2BC>
-CharacterDialog;
-
 typedef GUI<ControlDocument, QDocument, NoRepeatedApplyReadOnlyPolicy, Qt2BC>
 DocumentDialog;
 
@@ -114,7 +110,6 @@ VCLogFileDialog;
 struct Dialogs::Impl {
        Impl(LyXView & lv, Dialogs & d);
 
-       CharacterDialog     character;
        DocumentDialog      document;
        FileDialog          file;
        LogFileDialog       logfile;
index dac9c882f37b19b567064a26ddad5e157ebec60e..e3091e773db76196e415103bc398a5909666d4b1 100644 (file)
 using namespace frnt;
 using std::vector;
 
-typedef Qt2CB<ControlCharacter, Qt2DB<QCharacterDialog> > base_class;
+typedef QController<ControlCharacter, QView<QCharacterDialog> > base_class;
 
 
-QCharacter::QCharacter()
-       : base_class(qt_("LyX: Change Character Settings"))
+QCharacter::QCharacter(Dialog & parent)
+       : base_class(parent, qt_("LyX: Change Character Settings"))
 {
 }
 
index ad955842a8bc86c2b763010c41aaa4b16062f111..8d295639191a59ca435b767534f378ac83fc98dd 100644 (file)
@@ -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<ControlCharacter, Qt2DB<QCharacterDialog> >
+       : public QController<ControlCharacter, QView<QCharacterDialog> >
 {
 public:
        friend class QCharacterDialog;
 
-       QCharacter();
+       QCharacter(Dialog &);
 private:
        /// Apply changes
        virtual void apply();
index 89cdf69295dccf427291f8da2ad8c0cd24890c65..dbe21084f9992b9a1cd1ca31aeb4174ba2d43713 100644 (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>
 
        * Dialogs3.C (build): the "tabularcreate" dialog is always valid.
index 63fc41a07f396bd77977e0413f8073e554dd718f..62b04a2d303f2031d6967c1527d5b8105cb1ad66 100644 (file)
@@ -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),
index 9dc74d6f35af9467ef92516d974c0f221144f53d..9f9feca9aab74c0e8ec6f1798bfd1f3c9ea17900 100644 (file)
 #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();
index e2a66c82fc33b2a2c53070b2cbd14ab36a4b00b7..9817abd872adf2bbc0cf859b718ebd786c2d0e6c 100644 (file)
@@ -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"
 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));
index 8fd40e7e17417b05a197692b65a69972b005b688..4942644fca24f4d04aaef6f1dbbe5d7f4db21a30 100644 (file)
 #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<ControlCharacter, FormCharacter, OkApplyCancelReadOnlyPolicy, xformsBC>
-CharacterDialog;
-
 typedef GUI<ControlDocument, FormDocument, NoRepeatedApplyReadOnlyPolicy, xformsBC>
 DocumentDialog;
 
@@ -137,7 +130,6 @@ VCLogFileDialog;
 struct Dialogs::Impl {
        Impl(LyXView & lv, Dialogs & d);
 
-        CharacterDialog     character;
        DocumentDialog      document;
        FileDialog          file;
        ForksDialog         forks;
index 2765515d319df4036d35e758a157466dbbc1b634..d4ba682f1344718ee9452ce14d2827e93eedb5b7 100644 (file)
@@ -34,10 +34,10 @@ using std::find;
 
 using namespace frnt;
 
-typedef FormCB<ControlCharacter, FormDB<FD_character> > base_class;
+typedef FormController<ControlCharacter, FormView<FD_character> > base_class;
 
-FormCharacter::FormCharacter()
-       : base_class(_("Character Layout"), false)
+FormCharacter::FormCharacter(Dialog & parent)
+       : base_class(parent, _("Character Layout"), false)
 {}
 
 
index 8a132cda982860d11959603beda9c5a0de1f728b..42e987bb7b65cdb769e684e9767e02b1e5cbadb9 100644 (file)
@@ -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<ControlCharacter, FormDB<FD_character> > {
+       : public FormController<ControlCharacter, FormView<FD_character> > {
 public:
        ///
-       FormCharacter();
+       FormCharacter(Dialog &);
 private:
 
        /// Apply from dialog
index 5d880213296cfada159762bf5b4c4bb52836508c..155dbb9b4c35ed02078541eb4cdf9a02d2f23b42 100644 (file)
@@ -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
 };
 
 
index c0f0c7af21bc6f51ef82bd12f54a2b992eab0119..6eac504cfe666d37eb59e806e0c6c20724eca393 100644 (file)
@@ -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
 
 --------------------
index 858fcf6f15d802d36aed6012808f56f10affae19..14f81578d2e6e6dd5a910d7ebc52ae3f12372183 100644 (file)
@@ -35,7 +35,7 @@ InsetError::InsetError(string const & str, bool)
 
 InsetError::~InsetError()
 {
-       Dialogs::hide()("error", this);
+       Dialogs::hide("error", this);
 }
 
 
index 8cf6e8606f7fe19ebc901b2784a0892522888fb9..b7563a0cb0be205cc713634c1ba56c29a229922b 100644 (file)
@@ -36,5 +36,5 @@ void MailInset::updateDialog(BufferView * bv) const
 
 void MailInset::hideDialog() const
 {
-       Dialogs::hide()(name(), &inset());
+       Dialogs::hide(name(), &inset());
 }
index 7638abb4b4aa672a09e1ea180443198868df761d..708d97a0e9a536c5b383dd85a1c064d24712fabb 100644 (file)
@@ -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:
index 4bc566a1e454bead082c1107350042b710d72c28..16428223d79e677a172b7e3c9f33221c24f07ba9 100644 (file)
@@ -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: