]> git.lyx.org Git - features.git/commitdiff
Implementation of controller-view split for FormCharacter.
authorAngus Leeming <leeming@lyx.org>
Wed, 21 Mar 2001 13:27:03 +0000 (13:27 +0000)
committerAngus Leeming <leeming@lyx.org>
Wed, 21 Mar 2001 13:27:03 +0000 (13:27 +0000)
Some small clean-ups of code in frontends/controllers and frontends/xforms.
Added size_type and size() to Languages in language.h

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1798 a592a061-630c-0410-9148-cb99ea01b6c8

35 files changed:
src/ChangeLog
src/frontends/controllers/ButtonController.C
src/frontends/controllers/ButtonController.h
src/frontends/controllers/ButtonPolicies.h
src/frontends/controllers/ChangeLog
src/frontends/controllers/ControlBase.C
src/frontends/controllers/ControlBase.h
src/frontends/controllers/ControlBibitem.h
src/frontends/controllers/ControlBibtex.h
src/frontends/controllers/ControlCharacter.C [new file with mode: 0644]
src/frontends/controllers/ControlCharacter.h [new file with mode: 0644]
src/frontends/controllers/ControlCitation.C
src/frontends/controllers/ControlCitation.h
src/frontends/controllers/ControlCommand.C
src/frontends/controllers/ControlCommand.h
src/frontends/controllers/ControlConnections.C
src/frontends/controllers/ControlConnections.h
src/frontends/controllers/ControlLog.C
src/frontends/controllers/ControlVCLog.C
src/frontends/controllers/Makefile.am
src/frontends/controllers/ViewBase.h
src/frontends/controllers/helper_funcs.C [new file with mode: 0644]
src/frontends/controllers/helper_funcs.h [new file with mode: 0644]
src/frontends/xforms/ChangeLog
src/frontends/xforms/Dialogs.C
src/frontends/xforms/FormBase.C
src/frontends/xforms/FormBibitem.C
src/frontends/xforms/FormBibtex.C
src/frontends/xforms/FormCharacter.C
src/frontends/xforms/FormCharacter.h
src/frontends/xforms/FormCitation.C
src/frontends/xforms/form_character.C
src/frontends/xforms/form_character.h
src/frontends/xforms/forms/form_character.fd
src/language.h

index bda4314831c2520e5bb2369bf1f884d775e131ed..be601967126f11ccd267b9e18762d5a6cb465345 100644 (file)
@@ -1,3 +1,7 @@
+2001-03-20  Angus Leeming  <a.leeming@ic.ac.uk>
+
+       * language.h (Languages): added size_type and size().
+
 2001-03-20  Lars Gullik Bjønnes  <larsbj@trylle.birdstep.com>
 
        * buffer.C (parseSingleLyXformat2Token): Try to give a bit better
index 762255ca1c7a6e1074340cf0826e6a1dc5ea2e73..5653a4a3a69ca192884c08ce19e110d25d8d765f 100644 (file)
@@ -4,7 +4,7 @@
  *
  *           LyX, The Document Processor
  *
- *           Copyright 2000 The LyX Team.
+ *           Copyright 2000-2001 The LyX Team.
  *
  * ======================================================
  *
index 97d4ee0f86c2d22aa7fae12dbfe433db89d383e3..c3fec57b00cdf7c79c960fb7792f3f44930a18be 100644 (file)
@@ -4,7 +4,7 @@
  *
  *           LyX, The Document Processor
  *
- *           Copyright 2000 The LyX Team.
+ *           Copyright 2000-2001 The LyX Team.
  *
  * ======================================================
  *
index 3282305833005a8afef94b3bc9e85c09351c03bf..8f386ca4222a79a75b7248ce3d8a360f3858d44f 100644 (file)
@@ -9,7 +9,7 @@
  *           LyX, The Document Processor
  *
  *           Copyright 1995 Matthias Ettrich
- *           Copyright 1995-2000 The LyX Team.
+ *           Copyright 1995-2001 The LyX Team.
  *
  *           This file Copyright 2000
  *           Allan Rae
index 4aca29f7ca7a6243c4fe80fb6f15aec242fdbea4..7953f89026acb93e7c125d56261febe3a8f128fb 100644 (file)
@@ -1,3 +1,15 @@
+2001-03-21  Angus Leeming  <a.leeming@ic.ac.uk>
+
+       * ControlCharacter.[Ch]: new files; controller for the character popup.
+
+       * ControlCitation.[Ch] (getStringFromVector, getVectorFromString):
+       moved to new files helper_funcs.[Ch].
+
+       * helper_funcs.[Ch]: new files. Some useful helper functions and
+       functors.
+
+       * Makefile.am: added new files.
+
 2001-03-20  Angus Leeming  <a.leeming@ic.ac.uk>
 
        * ControlCitation.C (getBibkeyInfo): parse non-BibTeX entries correctly.
index 6b18056c3fdcfe0684ee22b68671f078c1dc6ca5..8d3ea3584687aca60c598ce1e23a0f5da31c54ec 100644 (file)
@@ -4,7 +4,7 @@
  *
  *           LyX, The Document Processor
  *
- *           Copyright 2000 The LyX Team.
+ *           Copyright 2001 The LyX Team.
  *
  * ======================================================
  *
index 7593ec3f15711d81fe9ed5bb2381cfc42bae7080..d3c73ef7dc967463435447d437e468810cdec81f 100644 (file)
@@ -4,7 +4,7 @@
  *
  *           LyX, The Document Processor
  *
- *           Copyright 2000 The LyX Team.
+ *           Copyright 2001 The LyX Team.
  *
  * ======================================================
  *
@@ -28,8 +28,8 @@
 #endif
 
 #include "DialogBase.h" // This can go eventually
+#include "ButtonController.h"
 
-class ButtonControllerBase;
 class Dialogs;
 class LyXView;
 class ViewBase;
@@ -79,5 +79,6 @@ protected:
        LyXView & lv_;
 };
 
+#include "ViewBase.h"
 
 #endif // CONTROLBASE_H
index e6ead2ad8d0373930277416fcfebeed87ecc2608..f2c5176ac129a450ca7d0415057694a742f89c2f 100644 (file)
@@ -21,8 +21,6 @@
 #endif
 
 #include "ControlCommand.h"
-#include "ButtonController.h"
-#include "ViewBase.h"
 
 /** A controller for Bibitem dialogs.
  */
index 2771ed36d5b27ca8d51189eadc2161ee1d902265..42789a18c9f806137f7c2f959c4e390b2334d978 100644 (file)
@@ -21,8 +21,6 @@
 #endif
 
 #include "ControlCommand.h"
-#include "ButtonController.h"
-#include "ViewBase.h"
 
 /** A controller for Bibtex dialogs.
  */
diff --git a/src/frontends/controllers/ControlCharacter.C b/src/frontends/controllers/ControlCharacter.C
new file mode 100644 (file)
index 0000000..45746ca
--- /dev/null
@@ -0,0 +1,350 @@
+/**
+ * \file ControlCharacter.C
+ * Copyright 2001 The LyX Team.
+ * See the file COPYING.
+ *
+ * \author Angus Leeming, a.leeming@.ac.uk
+ */
+
+#include <vector>
+
+#ifdef __GNUG_
+#pragma implementation
+#endif
+
+#include <config.h>
+
+#include "ControlCharacter.h"
+#include "bufferview_funcs.h"
+#include "Dialogs.h"
+#include "Liason.h"
+#include "LyXView.h"
+#include "buffer.h"
+#include "lyxtext.h"
+#include "language.h"
+
+using Liason::setMinibuffer;
+using SigC::slot;
+using std::vector;
+
+ControlCharacter::ControlCharacter(LyXView & lv, Dialogs & d)
+       : ControlConnectBD(lv, d), font_(0), toggleall_(false)
+{
+       d.showLayoutCharacter.connect(slot(this, &ControlCharacter::show));
+       d.setUserFreeFont.connect(slot(this, &ControlCharacter::apply));
+}
+
+
+void ControlCharacter::show()
+{
+       if (!lv_.view()->available()) return;
+
+       if (font_) delete font_;
+       font_ = new LyXFont(LyXFont::ALL_IGNORE);
+
+       bc().readOnly(isReadonly());
+       view().show();
+}
+
+
+void ControlCharacter::update()
+{
+       if (!lv_.view()->available()) return;
+
+       if (font_) delete font_;
+       font_ = new LyXFont(LyXFont::ALL_IGNORE);
+
+       bc().readOnly(isReadonly());
+       view().update();
+}
+
+
+void ControlCharacter::hide()
+{
+       if (font_) {
+               delete font_;
+               font_ = 0;
+       }
+
+       disconnect();
+       view().hide();
+}
+
+
+void ControlCharacter::apply()
+{
+       if (!lv_.view()->available())
+               return;
+   
+       view().apply();
+
+       ToggleAndShow(lv_.view(), *font_, toggleall_);
+       lv_.view()->setState();
+       lv_.buffer()->markDirty();
+       setMinibuffer(&lv_, _("Character set"));
+}
+
+
+void ControlCharacter::setFamily(LyXFont::FONT_FAMILY val)
+{
+       font_->setFamily(val);
+}
+
+void ControlCharacter::setSeries(LyXFont::FONT_SERIES val)
+{
+       font_->setSeries(val);
+}
+
+void ControlCharacter::setShape(LyXFont::FONT_SHAPE val)
+{
+       font_->setShape(val);
+}
+
+void ControlCharacter::setSize(LyXFont::FONT_SIZE val)
+{
+       font_->setSize(val);
+}
+
+void ControlCharacter::setBar(ControlCharacter::FONT_STATE val)
+{
+       switch (val) {
+       case IGNORE:
+               font_->setEmph(LyXFont::IGNORE);
+               font_->setUnderbar(LyXFont::IGNORE);
+               font_->setNoun(LyXFont::IGNORE);
+               font_->setLatex(LyXFont::IGNORE);
+               break;
+
+       case EMPH_TOGGLE:
+               font_->setEmph(LyXFont::TOGGLE);
+               break;
+
+       case UNDERBAR_TOGGLE:
+               font_->setUnderbar(LyXFont::TOGGLE);
+               break;
+
+       case NOUN_TOGGLE:
+               font_->setNoun(LyXFont::TOGGLE);
+               break;
+
+       case LATEX_TOGGLE:
+               font_->setLatex(LyXFont::TOGGLE);
+               break;
+
+       case INHERIT:
+               font_->setEmph(LyXFont::INHERIT);
+               font_->setUnderbar(LyXFont::INHERIT);
+               font_->setNoun(LyXFont::INHERIT);
+               font_->setLatex(LyXFont::INHERIT);
+               break;
+       }
+}
+
+void ControlCharacter::setColor(LColor::color val)
+{
+       switch (val) {
+       case LColor::ignore:
+       case LColor::none:
+       case LColor::black:
+       case LColor::white:
+       case LColor::red:
+       case LColor::green:
+       case LColor::blue:
+       case LColor::cyan:
+       case LColor::magenta:
+       case LColor::yellow:
+       case LColor::inherit:
+               font_->setColor(val);
+               break;
+
+       default:
+               break;
+       }
+}
+
+       
+void ControlCharacter::setLanguage(string const & val)
+{
+       if (val == _("No change"))
+               font_->setLanguage(ignore_language);
+
+       else if ( val == _("Reset"))
+               font_->setLanguage(lv_.buffer()->params.language);
+
+       else
+               font_->setLanguage(languages.getLanguage(val));
+}
+
+void ControlCharacter::setToggleAll(bool t)
+{
+       toggleall_ = t;
+}
+
+
+vector<ControlCharacter::FamilyPair> const getFamilyData()
+{
+       vector<ControlCharacter::FamilyPair> family(5);
+
+       ControlCharacter::FamilyPair pr;
+       pr.first = _("No change");  pr.second = LyXFont::IGNORE_FAMILY;
+       family[0] = pr;
+       pr.first = _("Roman");      pr.second = LyXFont::ROMAN_FAMILY;
+       family[1] = pr;
+       pr.first = _("Sans Serif"); pr.second = LyXFont::SANS_FAMILY;
+       family[2] = pr;
+       pr.first = _("Typewriter"); pr.second = LyXFont::TYPEWRITER_FAMILY;
+       family[3] = pr;
+       pr.first = _("Reset");      pr.second = LyXFont::INHERIT_FAMILY;
+       family[4] = pr;
+
+       return family;
+}
+
+
+vector<ControlCharacter::SeriesPair> const getSeriesData()
+{
+       vector<ControlCharacter::SeriesPair> series(4);
+
+       ControlCharacter::SeriesPair pr;
+       pr.first = _("No change"); pr.second = LyXFont::IGNORE_SERIES;
+       series[0] = pr;
+       pr.first = _("Medium");    pr.second = LyXFont::MEDIUM_SERIES;
+       series[1] = pr;
+       pr.first = _("Bold");      pr.second = LyXFont::BOLD_SERIES;
+       series[2] = pr;
+       pr.first = _("Reset");     pr.second = LyXFont::INHERIT_SERIES;
+       series[3] = pr;
+       
+       return series;
+}
+
+
+vector<ControlCharacter::ShapePair> const getShapeData()
+{
+       vector<ControlCharacter::ShapePair> shape(6);
+
+       ControlCharacter::ShapePair pr;
+       pr.first = _("No change");  pr.second = LyXFont::IGNORE_SHAPE;
+       shape[0] = pr;
+       pr.first = _("Upright");    pr.second = LyXFont::UP_SHAPE;
+       shape[1] = pr;
+       pr.first = _("Italic");     pr.second = LyXFont::ITALIC_SHAPE;
+       shape[2] = pr;
+       pr.first = _("Slanted");    pr.second = LyXFont::SLANTED_SHAPE;
+       shape[3] = pr;
+       pr.first = _("Small Caps"); pr.second = LyXFont::SMALLCAPS_SHAPE;
+       shape[4] = pr;
+       pr.first = _("Reset");      pr.second = LyXFont::INHERIT_SHAPE;
+       shape[5] = pr;
+       
+       return shape;
+}
+
+
+vector<ControlCharacter::SizePair> const getSizeData()
+{
+       vector<ControlCharacter::SizePair> size(14);
+
+       ControlCharacter::SizePair pr;
+       pr.first = _("No change"); pr.second = LyXFont::IGNORE_SIZE;
+       size[0] = pr;
+       pr.first = _("Tiny");      pr.second = LyXFont::SIZE_TINY;
+       size[1] = pr;
+       pr.first = _("Smallest");  pr.second = LyXFont::SIZE_SCRIPT;
+       size[2] = pr;
+       pr.first = _("Smaller");   pr.second = LyXFont::SIZE_FOOTNOTE;
+       size[3] = pr;
+       pr.first = _("Small");     pr.second = LyXFont::SIZE_SMALL;
+       size[4] = pr;
+       pr.first = _("Normal");    pr.second = LyXFont::SIZE_NORMAL;
+       size[5] = pr;
+       pr.first = _("Large");     pr.second = LyXFont::SIZE_LARGE;
+       size[6] = pr;
+       pr.first = _("Larger");    pr.second = LyXFont::SIZE_LARGER;
+       size[7] = pr;
+       pr.first = _("Largest");   pr.second = LyXFont::SIZE_LARGEST;
+       size[8] = pr;
+       pr.first = _("Huge");      pr.second = LyXFont::SIZE_HUGE;
+       size[9] = pr;
+       pr.first = _("Huger");     pr.second = LyXFont::SIZE_HUGER;
+       size[10] = pr;
+       pr.first = _("Increase");  pr.second = LyXFont::INCREASE_SIZE;
+       size[11] = pr;
+       pr.first = _("Decrease");  pr.second = LyXFont::DECREASE_SIZE;
+       size[12] = pr;
+       pr.first = _("Reset");     pr.second = LyXFont::INHERIT_SIZE;
+       size[13] = pr;
+       
+       return size;
+}
+
+
+vector<ControlCharacter::BarPair> const getBarData()
+{
+       vector<ControlCharacter::BarPair> bar(6);
+
+       ControlCharacter::BarPair pr;
+       pr.first = _("No change");  pr.second = ControlCharacter::IGNORE;
+       bar[0] = pr;
+       pr.first = _("Emph");       pr.second = ControlCharacter::EMPH_TOGGLE;
+       bar[1] = pr;
+       pr.first = _("Underbar");   pr.second = ControlCharacter::UNDERBAR_TOGGLE;
+       bar[2] = pr;
+       pr.first = _("Noun");       pr.second = ControlCharacter::NOUN_TOGGLE;
+       bar[3] = pr;
+       pr.first = _("LaTeX mode"); pr.second = ControlCharacter::LATEX_TOGGLE;
+       bar[4] = pr;
+       pr.first = _("Reset");      pr.second = ControlCharacter::INHERIT;
+       bar[5] = pr;
+       
+       return bar;
+}
+
+
+vector<ControlCharacter::ColorPair> const getColorData()
+{
+       vector<ControlCharacter::ColorPair> color(11);
+
+       ControlCharacter::ColorPair pr;
+       pr.first = _("No change"); pr.second = LColor::ignore;
+       color[0] = pr;
+       pr.first = _("No color");  pr.second = LColor::none;
+       color[1] = pr;
+       pr.first = _("Black");     pr.second = LColor::black;
+       color[2] = pr;
+       pr.first = _("White");     pr.second = LColor::white;
+       color[3] = pr;
+       pr.first = _("Red");       pr.second = LColor::red;
+       color[4] = pr;
+       pr.first = _("Green");     pr.second = LColor::green;
+       color[5] = pr;
+       pr.first = _("Blue");      pr.second = LColor::blue;
+       color[6] = pr;
+       pr.first = _("Cyan");      pr.second = LColor::cyan;
+       color[7] = pr;
+       pr.first = _("Magenta");   pr.second = LColor::magenta;
+       color[8] = pr;
+       pr.first = _("Yellow");    pr.second = LColor::yellow;
+       color[9] = pr;
+       pr.first = _("Reset");     pr.second = LColor::inherit;
+       color[10] = pr;
+       
+       return color;
+}
+
+
+vector<string> const getLanguageData()
+{
+       vector<string> langs(languages.size() + 2);
+
+       langs[0] = _("No change");
+       langs[1] = _("Reset");
+
+       vector<string>::size_type i = 1;
+       for (Languages::const_iterator cit = languages.begin(); 
+            cit != languages.end(); ++cit) {
+               langs[++i] = cit->second.lang();
+       }
+
+       return langs;
+}
diff --git a/src/frontends/controllers/ControlCharacter.h b/src/frontends/controllers/ControlCharacter.h
new file mode 100644 (file)
index 0000000..92a671f
--- /dev/null
@@ -0,0 +1,130 @@
+/**
+ * \file ControlCharacter.h
+ * Copyright 2001 The LyX Team.
+ * See the file COPYING.
+ *
+ * \author Angus Leeming, a.leeming@.ac.uk
+ */
+
+#ifndef CONTROLCHARACTER_H
+#define CONTROLCHARACTER_H
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include "ControlConnections.h"
+#include "lyxfont.h"
+#include "LColor.h"
+
+/** A controller for Character dialogs.
+ */
+class ControlCharacter : public ControlConnectBD
+{
+public:
+       ///
+       enum FONT_STATE {
+               ///
+               IGNORE,
+               ///
+               EMPH_TOGGLE,
+               ///
+               UNDERBAR_TOGGLE,
+               ///
+               NOUN_TOGGLE,
+               ///
+               LATEX_TOGGLE,
+               ///
+               INHERIT
+       };
+       
+       ///
+       typedef std::pair<string, LyXFont::FONT_FAMILY> FamilyPair;
+       ///
+       typedef std::pair<string, LyXFont::FONT_SERIES> SeriesPair;
+       ///
+       typedef std::pair<string, LyXFont::FONT_SHAPE>  ShapePair;
+       ///
+       typedef std::pair<string, LyXFont::FONT_SIZE>   SizePair;
+       ///
+       typedef std::pair<string, FONT_STATE> BarPair;
+       ///
+       typedef std::pair<string, LColor::color> ColorPair;
+
+       ///
+       ControlCharacter(LyXView &, Dialogs &);
+
+       ///
+       void setFamily(LyXFont::FONT_FAMILY);
+       ///
+       void setSeries(LyXFont::FONT_SERIES);
+       ///
+       void setShape(LyXFont::FONT_SHAPE);
+       ///
+       void setSize(LyXFont::FONT_SIZE);
+       ///
+       void setBar(FONT_STATE);
+       ///
+       void setColor(LColor::color);
+       ///
+       void setLanguage(string const &);
+       ///
+       void setToggleAll(bool);
+
+protected:
+       /// Get changed parameters and Dispatch them to the kernel.
+       virtual void apply();
+       /// Show the dialog.
+       virtual void show();
+       /// Update the dialog.
+       virtual void update();
+       /// Hide the dialog.
+       virtual void hide();
+
+private:
+       LyXFont * font_;
+       bool toggleall_;
+};
+
+/// Helper functions
+std::vector<ControlCharacter::FamilyPair> const getFamilyData();
+///
+std::vector<ControlCharacter::SeriesPair> const getSeriesData();
+///
+std::vector<ControlCharacter::ShapePair>  const getShapeData();
+///
+std::vector<ControlCharacter::SizePair>   const getSizeData();
+///
+std::vector<ControlCharacter::BarPair>    const getBarData();
+///
+std::vector<ControlCharacter::ColorPair>  const getColorData();
+///
+std::vector<string> const getLanguageData();
+
+/** This class instantiates and makes available the GUI-specific
+    ButtonController and View.
+ */
+template <class GUIview, class GUIbc>
+class GUICharacter : public ControlCharacter {
+public:
+       ///
+       GUICharacter(LyXView &, Dialogs &);
+       ///
+       virtual ButtonControllerBase & bc() { return bc_; }
+       ///
+       virtual ViewBase & view() { return view_; }
+
+private:
+       ///
+       ButtonController<NoRepeatedApplyReadOnlyPolicy, GUIbc> bc_;
+       ///
+       GUIview view_;
+};
+
+template <class GUIview, class GUIbc>
+GUICharacter<GUIview, GUIbc>::GUICharacter(LyXView & lv, Dialogs & d)
+       : ControlCharacter(lv, d),
+         view_(*this)
+{}
+
+#endif // CONTROLCHARACTER_H
index 9e25086f29821eb0b46ffb5ad0f58281765b8d0b..05a409e4c95a83a6f300d99c22fa6f2add8cb137 100644 (file)
@@ -4,7 +4,7 @@
  *
  *           LyX, The Document Processor
  *
- *           Copyright 2000 The LyX Team.
+ *           Copyright 2001 The LyX Team.
  *
  * ======================================================
  *
 
 #include "ControlCitation.h"
 #include "buffer.h"
-#include "ButtonController.h"
 #include "Dialogs.h"
 #include "LyXView.h"
-#include "ViewBase.h"
+#include "helper_funcs.h"
 #include "support/lstrings.h"
 #include "support/LRegex.h"
 
@@ -129,29 +128,6 @@ string const ControlCitation::getBibkeyInfo(string const & key)
 }
 
 
-string const getStringFromVector(vector<string> const & vec, char delim)
-{
-       string str;
-       for (vector<string>::size_type i=0; i<vec.size(); ++i) {
-               if (i > 0) str += tostr(delim);
-               str += vec[i];
-       }
-       return str;
-}
-
-vector<string> const getVectorFromString(string const & str, char delim)
-{
-       vector<string> vec;
-       string keys(str);
-       string tmp;
-       keys = frontStrip(split(keys, tmp, delim));
-       while (!tmp.empty()) {
-               vec.push_back(tmp);
-               keys = frontStrip(split(keys, tmp, delim));
-       }
-       return vec;
-}
-
 vector<string>::const_iterator
 searchKeys(ControlCitation const & controller,
           vector<string> const & keys,
@@ -185,7 +161,7 @@ simpleSearch(ControlCitation const & controller,
             ControlCitation::Direction dir,
             bool caseSensitive)
 {
-       vector<string> searchwords = getVectorFromString(expr, ' ');
+       vector<string> searchwords = getVectorFromString(expr, " ");
 
        // Loop over all keys from start...
        for (vector<string>::const_iterator it = start;
index 173004db4b7fd7b1ce6748e252eaa9fe49706cb6..fc6b2c56a9ef3c31cf51a0d97380b464ee173a3d 100644 (file)
@@ -4,7 +4,7 @@
  *
  *           LyX, The Document Processor
  *
- *           Copyright 2000 The LyX Team.
+ *           Copyright 2001 The LyX Team.
  *
  * ======================================================
  *
@@ -20,8 +20,6 @@
 #endif
 
 #include "ControlCommand.h"
-#include "ButtonController.h"
-#include "ViewBase.h"
 
 /** A controller for Citation dialogs. All citation-specific functionality
     should go in here.
@@ -93,12 +91,6 @@ GUICitation<GUIview, GUIbc>::GUICitation(LyXView & lv, Dialogs & d)
 /** Helper functions, of possible use to all frontends
  */
 
-/** Multiple citation keys are stored in InsetCommandParams::contents as a
-    comma-separated string. These two functions convert to/from a vector. */
-string const getStringFromVector(std::vector<string> const &, char delim=',');
-///
-std::vector<string> const getVectorFromString(string const &, char delim=',');
-
 /** Search a BibTeX info field for the given key and return the
     associated field. */
 string const parseBibTeX(string data, string const & findkey);
index bc2744db00c245e307e11372c84a2925812b6926..b728bed8de69b1895120a809b69519bee7cf66f7 100644 (file)
 
 #include "ControlCommand.h"
 #include "BufferView.h"
-#include "ButtonController.h"
 #include "Dialogs.h"
 #include "lyxfunc.h"
 #include "LyXView.h"
 #include "support/LAssert.h"
-#include "ViewBase.h"
 
 ControlCommand::ControlCommand(LyXView & lv, Dialogs & d, kb_action ac)
        : ControlConnectInset<InsetCommand>(lv, d),
index 802c422c3eaa7cc2920efa4665c5c646300273e6..b5373a49fb35092ec4ffdbe59b8813c0bbb9ec73 100644 (file)
@@ -4,7 +4,7 @@
  *
  *           LyX, The Document Processor
  *
- *           Copyright 2000 The LyX Team.
+ *           Copyright 2001 The LyX Team.
  *
  * ======================================================
  *
@@ -28,9 +28,6 @@
 #include "insets/insetcommand.h"
 #include "commandtags.h" // kb_action
 
-class Dialogs;
-class LyXView;
-
 /** The Inset dialog controller. Connects/disconnects signals, launches 
     GUI-dependent View and returns the output from this View to the kernel.
  */
index 0ec1080609f58e7deec980687f819bd45eda39a1..a98c1d4df45d8028b28671cf25f07da1a2016d7b 100644 (file)
@@ -4,7 +4,7 @@
  *
  *           LyX, The Document Processor
  *
- *           Copyright 2000 The LyX Team.
+ *           Copyright 2001 The LyX Team.
  *
  * ======================================================
  *
@@ -20,7 +20,6 @@
 
 #include "ControlConnections.h"
 #include "Dialogs.h"
-#include "ViewBase.h"
 #include "insets/lyxinset.h"
 
 using SigC::slot;
index 7fd9c5732efcb26fef63a4e279fbf3a53a5edcef..63a3b5883b78761bd3e162472ccd84b0ae39d164 100644 (file)
@@ -4,7 +4,7 @@
  *
  *           LyX, The Document Processor
  *
- *           Copyright 2000 The LyX Team.
+ *           Copyright 2001 The LyX Team.
  *
  * ======================================================
  *
index ff00b6cf5622b23a71b339ba86543cf92b876818..5e0a7a41e886ca569f24ff3de7538d86644a92ff 100644 (file)
 #endif
 
 #include <config.h>
-#include "ButtonController.h"
 #include "ControlLog.h"
 #include "LyXView.h"
 #include "Dialogs.h"
 #include "lyxrc.h"
-#include "ViewBase.h"
 
 using std::make_pair;
 using SigC::slot;
index acba9d795cd62ee22601049c461df307604d7f87..f6d357abd0c920f7a7e7fd6e56eb673c6c8f38ba 100644 (file)
@@ -7,7 +7,7 @@
  *
  * ======================================================
  *
- * \file ControlVCLog.h
+ * \file ControlVCLog.C
  * \author John Levon, moz@compsoc.man.ac.uk
  * \author Angus Leeming <a.leeming@ic.ac.uk>
  */
 #endif
 
 #include <config.h>
-#include "buffer.h"
-#include "ButtonController.h"
 #include "ControlVCLog.h"
+#include "buffer.h"
 #include "LyXView.h"
 #include "Dialogs.h"
 #include "lyxrc.h"
-#include "ViewBase.h"
 
 using SigC::slot;
 
index 65fcafb648eb2195813c6e7c3c6a9376a97147e5..bda959c5f7940957feffd53aa038b3765f379215 100644 (file)
@@ -20,6 +20,8 @@ libcontrollers_la_SOURCES=\
        ControlBibitem.h \
        ControlBibtex.C \
        ControlBibtex.h \
+       ControlCharacter.C \
+       ControlCharacter.h \
        ControlCitation.C \
        ControlCitation.h \
        ControlCommand.C \
@@ -30,7 +32,9 @@ libcontrollers_la_SOURCES=\
        ControlLog.h \
        ControlVCLog.C \
        ControlVCLog.h \
-       ViewBase.h
+       ViewBase.h \
+       helper_funcs.C \
+       helper_funcs.h
 
 # just copied from old lyx repository
 dist-hook:
index 541bbe933579ed22d802a08b52edd5fb097e0612..a99d51f1aee465fc86807cc3b9cdb1fbea091f32 100644 (file)
@@ -4,7 +4,7 @@
  *
  *           LyX, The Document Processor
  *
- *           Copyright 2000 The LyX Team.
+ *           Copyright 2001 The LyX Team.
  *
  * ======================================================
  *
diff --git a/src/frontends/controllers/helper_funcs.C b/src/frontends/controllers/helper_funcs.C
new file mode 100644 (file)
index 0000000..96b4043
--- /dev/null
@@ -0,0 +1,55 @@
+/* This file is part of
+ * ====================================================== 
+ *
+ *           LyX, The Document Processor
+ *
+ *           Copyright 2001 The LyX Team.
+ *
+ * ======================================================
+ *
+ * \file helper_funcs.C
+ * \author Angus Leeming <a.leeming@ic.ac.uk>
+ */
+
+#include <vector>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include <config.h>
+#include "LString.h"
+#include "helper_funcs.h"
+
+using std::vector;
+
+string const getStringFromVector(vector<string> const & vec,
+                                string const & delim)
+{
+       string str;
+       for (vector<string>::size_type i=0; i<vec.size(); ++i) {
+               if (i > 0) str += delim;
+               str += vec[i];
+       }
+       return str;
+}
+
+vector<string> const getVectorFromString(string const & str,
+                                        string const & delim)
+{
+       vector<string> vec;
+       string keys(str);
+
+       for(;;) {
+               string::size_type const idx = keys.find(delim);
+               if (idx == string::npos) break;
+               
+               vec.push_back(keys.substr(0, idx));
+
+               string::size_type const start = idx + delim.size();
+               keys = keys.substr(start);
+       }
+
+       return vec;
+}
+
diff --git a/src/frontends/controllers/helper_funcs.h b/src/frontends/controllers/helper_funcs.h
new file mode 100644 (file)
index 0000000..4e6be14
--- /dev/null
@@ -0,0 +1,97 @@
+// -*- C++ -*-
+/* This file is part of
+ * ====================================================== 
+ *
+ *           LyX, The Document Processor
+ *
+ *           Copyright 2001 The LyX Team.
+ *
+ * ======================================================
+ *
+ * \file ControlCitation.h
+ * \author Angus Leeming <a.leeming@ic.ac.uk>
+ */
+
+#ifndef HELPERFUNCS_H
+#define HELPERFUNCS_H
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+/** Functions to convert a string to/from a vector. */
+
+///
+string const
+getStringFromVector(std::vector<string> const & vec, string const & delim=",");
+
+///
+std::vector<string> const
+getVectorFromString(string const & str, string const & delim=",");
+
+/** Functions to extract vectors of the first and second elems from a
+    vector<pair<A,B> >
+*/
+
+///
+template <class A, class B>
+std::vector<A> const getFirst(std::vector<std::pair<A,B> > const & pairVec)
+{
+       typedef std::vector<std::pair<A,B> > PV;
+
+       std::vector<A> first(pairVec.size());
+
+       for (PV::size_type i = 0; i < pairVec.size(); ++i) {
+               first[i] = pairVec[i].first;
+       }
+
+       return first;
+}
+///
+template <class A, class B>
+std::vector<B> const getSecond(std::vector<std::pair<A,B> > const & pairVec)
+{
+       typedef std::vector<std::pair<A,B> > PV;
+
+       std::vector<B> second(pairVec.size());
+
+       for (PV::size_type i = 0; i < pairVec.size(); ++i) {
+               second[i] = pairVec[i].second;
+       }
+
+       return second;
+}
+
+
+template<class Pair>
+struct firster {
+       typedef typename Pair::first_type first_type;
+       first_type const & operator()(Pair const & p) { return p.first; }
+};
+
+template<class Pair>
+struct seconder {
+       typedef typename Pair::second_type second_type;
+       second_type const & operator()(Pair const & p) { return p.second; }
+};
+
+template<class Pair>
+typename Pair::first_type const getFirst(std::vector<Pair> const & pr)
+{
+       std::vector<typename Pair::first_type> tmp(pr.size);
+       std::transform(pr.begin(), pr.end(), tmp.begin(), firster<Pair>());
+       return tmp;
+}
+
+template<class Pair>
+typename Pair::second_type const getSecond(std::vector<Pair> const & pr)
+{
+       std::vector<typename Pair::second_type> tmp(pr.size);
+       std::transform(pr.begin(), pr.end(), tmp.begin(), seconder<Pair>());
+       return tmp;
+}
+
+
+
+#endif // HELPERFUNCS_H
+
index b17729df061ca9cd68ae5474722104df1a2aa8a5..f01740649d27b4a123c10477f8c119a7afff15cb 100644 (file)
@@ -1,3 +1,15 @@
+2001-03-21  Angus Leeming  <a.leeming@ic.ac.uk>
+
+       * FormCharacter.[Ch]:
+       * forms/form_character.fd: implemented controller-view split.
+
+       * Dialogs.C: associated changes.
+
+       * FormBase.C (input): changed return to SMI_VALID.
+
+       * FormCitation.C (updateBrowser): ensure that the keys are stripped of
+       any surrounding whitespace.
+
 2001-03-20  Angus Leeming  <a.leeming@ic.ac.uk>
 
        * FormBase.[Ch] (input): no longer pure virtual. Has defualt state of
index 776df33c40d852b711c4a38bce145d3c2ba81f33..23dd91174f72aa0272e3424b80c2782baad3fecc 100644 (file)
 
 #include "Dialogs.h"
 
+#include "xformsBC.h"
+
 #include "ControlBibitem.h"
 #include "ControlBibtex.h"
+#include "ControlCharacter.h"
 #include "ControlCitation.h"
 #include "ControlLog.h"
 #include "ControlVCLog.h"
-#include "xformsBC.h"
 
-#include "form_bibitem.h" // needed for clean destructtion of boost::scoped ptr
+#include "combox.h"       // needed for clean destructtion of boost::scoped ptr
+#include "form_bibitem.h"
 #include "form_bibtex.h"
 #include "form_browser.h"
+#include "form_character.h"
 #include "form_citation.h"
 
 #include "FormBibitem.h"
 #include "FormBibtex.h"
+#include "FormCharacter.h"
 #include "FormCitation.h"
 #include "FormLog.h"
 #include "FormVCLog.h"
 
-#include "FormCharacter.h"
 #include "FormCopyright.h"
 #include "FormCredits.h"
 #include "FormDocument.h"
@@ -66,13 +70,13 @@ Dialogs::Dialogs(LyXView * lv)
 {
        splash_.reset(new FormSplash(lv, this));
 
-       add(new GUICitation<FormCitation, xformsBC>(*lv, *this));
        add(new GUIBibitem<FormBibitem, xformsBC>(*lv, *this));
        add(new GUIBibtex<FormBibtex, xformsBC>(*lv, *this));
+       add(new GUICharacter<FormCharacter, xformsBC>(*lv, *this));
+       add(new GUICitation<FormCitation, xformsBC>(*lv, *this));
        add(new GUILog<FormLog, xformsBC>(*lv, *this));
        add(new GUIVCLog<FormVCLog, xformsBC>(*lv, *this));
 
-       add(new FormCharacter(lv, this));
        add(new FormCopyright(lv, this));
        add(new FormCredits(lv, this));
        add(new FormDocument(lv, this));
index 30cfc33d0ce08fc6e2ca3defa28177e88bd820d4..d1cd266962af69fe6f15d9833d52aca719cae89a 100644 (file)
@@ -91,7 +91,7 @@ void FormBase::InputCB(FL_OBJECT * ob, long data)
 
 ButtonPolicy::SMInput FormBase::input(FL_OBJECT *, long)
 {
-       return ButtonPolicy::SMI_NOOP;
+       return ButtonPolicy::SMI_VALID;
 }
 
 
index 69aeb1afa544d6c9e97ac9d4e82bfbb8fc475813..f37487573f0e09f119c3542eb123eef211996e14 100644 (file)
 #endif
 
 #include <config.h>
+#include "xformsBC.h"
 #include "ControlBibitem.h"
 #include "FormBibitem.h"
 #include "form_bibitem.h"
 #include "gettext.h"
-#include "xformsBC.h"
 #include "support/lstrings.h" // compare
 
 typedef FormCB<ControlBibitem, FormDB<FD_form_bibitem> > base_class;
index 333a8f4cf7037225f2bb0279cdc88a2e400126f7..cd29bcdd06bc6a6f6f4af9ff1efb2cbb7de4d7fe 100644 (file)
 #endif
 
 #include <config.h>
+#include "xformsBC.h"
 #include "ControlBibtex.h"
 #include "FormBibtex.h"
 #include "form_bibtex.h"
 #include "gettext.h"
-#include "xformsBC.h"
 #include "debug.h"
 
 typedef FormCB<ControlBibtex, FormDB<FD_form_bibtex> > base_class;
index 5689892814207113a1e17f148c25da88eaf7f834..22779640769e0a3e084ca67856e085dda7b2479d 100644 (file)
  * Copyright 2001 The LyX Team.
  * See the file COPYING.
  *
- * \author Edwin Leuven, leuven@fee.uva.nl
+ * \author Edwin Leuven,  leuven@fee.uva.nl
+ * \author Angus Leeming, a.leeming@ic.ac.uk
  */
 
-#include <config.h>
-
-#include FORMS_H_LOCATION
+#include <vector>
 
 #ifdef __GNUG_
 #pragma implementation
 #endif
 
+#include <config.h>
+
+#include "xformsBC.h"
+#include "ControlCharacter.h"
 #include "FormCharacter.h"
 #include "form_character.h"
-#include "bufferview_funcs.h"
-#include "Dialogs.h"
-#include "Liason.h"
-#include "LyXView.h"
-#include "buffer.h"
-#include "lyxtext.h"
-#include "language.h"
+#include "gettext.h"
 #include "combox.h"
+#include "helper_funcs.h"
 
-using Liason::setMinibuffer;
-using SigC::slot;
+using std::vector;
+using std::back_inserter;
+using std::transform;
 
-FormCharacter::FormCharacter(LyXView * lv, Dialogs * d)
-       : FormBaseBD(lv, d, _("Character Layout"))
-{
-   // let the popup be shown
-   // This is a permanent connection so we won't bother
-   // storing a copy because we won't be disconnecting.
-   d->showLayoutCharacter.connect(slot(this, &FormCharacter::show));
-   // for LFUN_FREE
-   d->setUserFreeFont.connect(slot(this, &FormCharacter::apply));
-}
+typedef FormCB<ControlCharacter, FormDB<FD_form_character> > base_class;
 
+FormCharacter::FormCharacter(ControlCharacter & c)
+       : base_class(c, _("Character Layout"))
+{}
 
-FL_FORM * FormCharacter::form() const
+
+void FormCharacter::ComboInputCB(int, void * v, Combox * combox)
 {
-   if (dialog_.get()) 
-     return dialog_->form;
-   return 0;
+       FormCharacter * pre = static_cast<FormCharacter*>(v);
+       pre->InputCB(reinterpret_cast<FL_OBJECT *>(combox), 0);
 }
 
-
 void FormCharacter::build()
 {
-   dialog_.reset(build_character());
-
-   // Manage the ok, apply and cancel/close buttons
-   bc().setApply(dialog_->button_apply);
-   bc().setCancel(dialog_->button_close);
-   bc().refresh();
-   bc().addReadOnly (dialog_->check_toggle_all);
-   
-   fl_addto_choice(dialog_->choice_family,
-                  _(" No change %l| Roman | Sans Serif | Typewriter %l| Reset "));
-   fl_addto_choice(dialog_->choice_series,
-                  _(" No change %l| Medium | Bold %l| Reset "));
-   fl_addto_choice(dialog_->choice_shape,
-                  _(" No change %l| Upright | Italic | Slanted | Small Caps "
-                    "%l| Reset "));
-   fl_addto_choice(dialog_->choice_size,
-                  _(" No change %l| Tiny | Smallest | Smaller | Small "
-                    "| Normal | Large | Larger | Largest | Huge | Huger "
-                    "%l| Increase | Decrease | Reset "));
-   fl_addto_choice(dialog_->choice_bar,
-                  _(" No change %l| Emph | Underbar | Noun | LaTeX mode %l| Reset "));
-   fl_addto_choice(dialog_->choice_color,
-                  _(" No change %l| No color | Black | White | Red | Green "
-                    "| Blue | Cyan | Magenta | Yellow %l| Reset "));
-   fl_addto_choice(dialog_->choice_language,
-                  _(" English %l| German | French "));
-
-   // insert default language box manually
-   fl_addto_form(dialog_->form);
-   FL_OBJECT * ob = dialog_->choice_language;
-   combo_language2_.reset(new Combox(FL_COMBOX_DROPLIST));
-   combo_language2_->add(ob->x, ob->y, ob->w, ob->h, 250);
-   combo_language2_->shortcut("#L", 1);
-   fl_end_form();
-
-   // build up the combox entries
-   combo_language2_->addline(_("No change"));
-   combo_language2_->addline(_("Reset"));
-   for (Languages::const_iterator cit = languages.begin(); 
-       cit != languages.end(); ++cit) {
-       combo_language2_->addto((*cit).second.lang());
-   }
+       dialog_.reset(build_character());
+
+       vector<ControlCharacter::FamilyPair> const family = getFamilyData();
+       vector<ControlCharacter::SeriesPair> const series = getSeriesData();
+       vector<ControlCharacter::ShapePair>  const shape  = getShapeData();
+       vector<ControlCharacter::SizePair>   const size   = getSizeData();
+       vector<ControlCharacter::BarPair>    const bar    = getBarData();
+       vector<ControlCharacter::ColorPair>  const color  = getColorData();
+       vector<string> const language = getLanguageData();
+
+       // Store the enums for later
+       family_ = getSecond(family);
+       series_ = getSecond(series);
+       shape_ = getSecond(shape);
+       size_ = getSecond(size);
+       bar_ = getSecond(bar);
+       color_ = getSecond(color);
+
+       // create a string of entries " entry1 | entry2 | entry3 | entry4 "
+       // with which to initialise the xforms choice object.
+       string choice = " " + getStringFromVector(getFirst(family), " | ") +" ";
+       fl_addto_choice(dialog_->choice_family, choice.c_str());
+
+       choice = " " + getStringFromVector(getFirst(series), " | ") + " ";
+       fl_addto_choice(dialog_->choice_series, choice.c_str());
+
+       choice = " " + getStringFromVector(getFirst(shape), " | ") + " ";
+       fl_addto_choice(dialog_->choice_shape, choice.c_str());
+
+       choice = " " + getStringFromVector(getFirst(size), " | ") + " ";
+       fl_addto_choice(dialog_->choice_size, choice.c_str());
+
+       choice = " " + getStringFromVector(getFirst(bar), " | ") + " ";
+       fl_addto_choice(dialog_->choice_bar, choice.c_str());
+
+       choice = " " + getStringFromVector(getFirst(color), " | ") + " ";
+       fl_addto_choice(dialog_->choice_color, choice.c_str());
+
+       // xforms appears to need this to prevent a crash...
+       // fl_addto_choice(dialog_->choice_language,
+       //              _(" English %l| German | French "));
+
+       // insert default language box manually
+       fl_addto_form(dialog_->form);
+               FL_OBJECT * ob = dialog_->choice_language;
+               combo_language2_.reset(new Combox(FL_COMBOX_DROPLIST));
+               combo_language2_->add(ob->x, ob->y, ob->w, ob->h, 250);
+               combo_language2_->shortcut("#L", 1);
+               combo_language2_->setcallback(ComboInputCB, this);
+       fl_end_form();
+
+       // build up the combox entries
+       for (vector<string>::const_iterator cit = language.begin(); 
+            cit != language.end(); ++cit) {
+               combo_language2_->addto(*cit);
+       }
+       combo_language2_->select_text(*language.begin());
+
+       // Manage the ok, apply and cancel/close buttons
+       bc().setApply(dialog_->button_apply);
+       bc().setCancel(dialog_->button_close);
+       bc().refresh();
+       bc().addReadOnly(dialog_->check_toggle_all);
 }
 
 
 void FormCharacter::apply()
 {
-   if (!lv_->view()->available() || !dialog_.get())
-     return;
-   
-   LyXFont font(LyXFont::ALL_IGNORE);
-   
-   int pos = fl_get_choice(dialog_->choice_family);
-   switch (pos) {
-      case 1: font.setFamily(LyXFont::IGNORE_FAMILY); break;
-      case 2: font.setFamily(LyXFont::ROMAN_FAMILY); break;
-      case 3: font.setFamily(LyXFont::SANS_FAMILY); break;
-      case 4: font.setFamily(LyXFont::TYPEWRITER_FAMILY); break;
-      case 5: font.setFamily(LyXFont::INHERIT_FAMILY); break;
-   }
-   
-   pos = fl_get_choice(dialog_->choice_series);
-   switch (pos) {
-      case 1: font.setSeries(LyXFont::IGNORE_SERIES); break;
-      case 2: font.setSeries(LyXFont::MEDIUM_SERIES); break;
-      case 3: font.setSeries(LyXFont::BOLD_SERIES); break;
-      case 4: font.setSeries(LyXFont::INHERIT_SERIES); break;
-   }
-   
-   pos = fl_get_choice(dialog_->choice_shape);
-   switch (pos) {
-      case 1: font.setShape(LyXFont::IGNORE_SHAPE); break;
-      case 2: font.setShape(LyXFont::UP_SHAPE); break;
-      case 3: font.setShape(LyXFont::ITALIC_SHAPE); break;
-      case 4: font.setShape(LyXFont::SLANTED_SHAPE); break;
-      case 5: font.setShape(LyXFont::SMALLCAPS_SHAPE); break;
-      case 6: font.setShape(LyXFont::INHERIT_SHAPE); break;
-   }
-   
-   pos = fl_get_choice(dialog_->choice_size);
-   switch (pos) {
-      case 1: font.setSize(LyXFont::IGNORE_SIZE); break;
-      case 2: font.setSize(LyXFont::SIZE_TINY); break;
-      case 3: font.setSize(LyXFont::SIZE_SCRIPT); break;
-      case 4: font.setSize(LyXFont::SIZE_FOOTNOTE); break;
-      case 5: font.setSize(LyXFont::SIZE_SMALL); break;
-      case 6: font.setSize(LyXFont::SIZE_NORMAL); break;
-      case 7: font.setSize(LyXFont::SIZE_LARGE); break;
-      case 8: font.setSize(LyXFont::SIZE_LARGER); break;
-      case 9: font.setSize(LyXFont::SIZE_LARGEST); break;
-      case 10: font.setSize(LyXFont::SIZE_HUGE); break;
-      case 11: font.setSize(LyXFont::SIZE_HUGER); break;
-      case 12: font.setSize(LyXFont::INCREASE_SIZE); break;
-      case 13: font.setSize(LyXFont::DECREASE_SIZE); break;
-      case 14: font.setSize(LyXFont::INHERIT_SIZE); break;
-   }
-   
-   pos = fl_get_choice(dialog_->choice_bar);
-   switch (pos) {
-      case 1: font.setEmph(LyXFont::IGNORE);
-      font.setUnderbar(LyXFont::IGNORE);
-      font.setNoun(LyXFont::IGNORE);
-      font.setLatex(LyXFont::IGNORE);
-      break;
-      case 2: font.setEmph(LyXFont::TOGGLE); break;
-      case 3: font.setUnderbar(LyXFont::TOGGLE); break;
-      case 4: font.setNoun(LyXFont::TOGGLE); break;
-      case 5: font.setLatex(LyXFont::TOGGLE); break;
-      case 6: font.setEmph(LyXFont::INHERIT);
-      font.setUnderbar(LyXFont::INHERIT);
-      font.setNoun(LyXFont::INHERIT);
-      font.setLatex(LyXFont::INHERIT);
-      break;
-   }
-   
-   pos = fl_get_choice(dialog_->choice_color);
-   switch (pos) {
-      case 1: font.setColor(LColor::ignore); break;
-      case 2: font.setColor(LColor::none); break;
-      case 3: font.setColor(LColor::black); break;
-      case 4: font.setColor(LColor::white); break;
-      case 5: font.setColor(LColor::red); break;
-      case 6: font.setColor(LColor::green); break;
-      case 7: font.setColor(LColor::blue); break;
-      case 8: font.setColor(LColor::cyan); break;
-      case 9: font.setColor(LColor::magenta); break;
-      case 10: font.setColor(LColor::yellow); break;
-      case 11: font.setColor(LColor::inherit); break;
-   }
+       int pos = fl_get_choice(dialog_->choice_family);
+       controller().setFamily(family_[pos-1]);
+
+       pos = fl_get_choice(dialog_->choice_series);
+       controller().setSeries(series_[pos-1]);
    
-   int const choice = combo_language2_->get();
-   if (choice == 1)
-     font.setLanguage(ignore_language);
-   else if (choice == 2)
-     font.setLanguage(lv_->buffer()->params.language);
-   else
-     font.setLanguage(languages.getLanguage(combo_language2_->getline()));
+       pos = fl_get_choice(dialog_->choice_shape);
+       controller().setShape(shape_[pos-1]);
 
+       pos = fl_get_choice(dialog_->choice_size);
+       controller().setSize(size_[pos-1]);
    
-   bool toggleall = fl_get_button(dialog_->check_toggle_all);
-   ToggleAndShow(lv_->view(), font, toggleall);
-   lv_->view()->setState();
-   lv_->buffer()->markDirty();
-   setMinibuffer(lv_, _("Character set"));
-}
+       pos = fl_get_choice(dialog_->choice_bar);
+       controller().setBar(bar_[pos-1]);
+   
+       pos = fl_get_choice(dialog_->choice_color);
+       controller().setColor(color_[pos-1]);
 
+       controller().setLanguage(combo_language2_->getline());
 
-void FormCharacter::update()
-{
-    if (!dialog_.get())
-        return;
-   
-    bc().readOnly(lv_->buffer()->isReadonly());
+       bool const toggleall = fl_get_button(dialog_->check_toggle_all);
+       controller().setToggleAll(toggleall);
 }
index ca7cdaebab5c5be4f5b92892edaa8924627a4f52..03ddeaffbe80f75ce02b173a347cb4b54f6905c2 100644 (file)
@@ -5,6 +5,7 @@
  * See the file COPYING.
  * 
  * \author Edwin Leuven, leuven@fee.uva.nl
+ * \author Angus Leeming, a.leeming@.ac.uk
  */
 
 #ifndef FORM_CHARACTER_H
 #pragma interface
 #endif
 
-#include "FormBaseDeprecated.h"
+#include "FormBase.h"
+#include "lyxfont.h"          // for LyXFont enums
+#include "ControlCharacter.h" // for ControlCharacter enum
+#include "LColor.h"           // for LColor enum
 
 class Combox;
 struct FD_form_character;
@@ -26,14 +30,12 @@ struct FD_form_character;
  * The character dialog allows users to change the character settings
  * in their documents.
  */
-class FormCharacter : public FormBaseBD {
+class FormCharacter
+       : public FormCB<ControlCharacter, FormDB<FD_form_character> > {
 public:
        ///
-       FormCharacter(LyXView *, Dialogs *);
+       FormCharacter(ControlCharacter &);
 private:
-       
-       /// Pointer to the actual instantiation of the ButtonController.
-       virtual xformsBC & bc();
 
        /// Build the popup
        virtual void build();
@@ -41,29 +43,30 @@ private:
        /// Apply from popup
        virtual void apply();
    
-       /// Update the popup.
-       virtual void update();
-   
-       /// Pointer to the actual instantiation of the xform's form
-       virtual FL_FORM * form() const;
+       /// Nothing to update...
+       virtual void update() {}
 
-       ///
+       /** Callback method (used only to activate Apply button when
+           combox is changed */
+       static void ComboInputCB(int, void *, Combox *);
+
+       /// Type definition from the fdesign produced header file.
        FD_form_character * build_character();
        
-       /// Real GUI implementation.
-       boost::scoped_ptr<FD_form_character> dialog_;
-
        ///
        boost::scoped_ptr<Combox> combo_language2_;
-
-       /// The ButtonController
-       ButtonController<NoRepeatedApplyReadOnlyPolicy, xformsBC> bc_;
+       ///
+       std::vector<LyXFont::FONT_FAMILY>         family_;
+       ///
+       std::vector<LyXFont::FONT_SERIES>         series_;
+       ///
+       std::vector<LyXFont::FONT_SHAPE>          shape_;
+       ///
+       std::vector<LyXFont::FONT_SIZE>           size_;
+       ///
+       std::vector<ControlCharacter::FONT_STATE> bar_;
+       ///
+       std::vector<LColor::color>                color_;
 };
 
-
-inline
-xformsBC & FormCharacter::bc()
-{
-       return bc_;
-}
 #endif
index eb63893974e0ab8444eac6e4642fd28d4b1df631..a5580f0799ed2fd359cdb8551536b030c38dcc49 100644 (file)
@@ -25,6 +25,7 @@
 #include "support/lstrings.h"
 #include "xforms_helpers.h"
 #include "xformsBC.h"
+#include "helper_funcs.h"
 
 using std::find;
 using std::max;
@@ -317,8 +318,11 @@ void FormCitation::updateBrowser(FL_OBJECT * browser,
 {
        fl_clear_browser(browser);
 
-       for (vector<string>::size_type i = 0; i < keys.size(); ++i)
-               fl_add_browser_line(browser, keys[i].c_str());
+       for (vector<string>::const_iterator it = keys.begin();
+            it < keys.end(); ++it) {
+               string key = frontStrip(strip(*it));
+               fl_add_browser_line(browser, key.c_str());
+       }
 }
 
 
index 16d9c95aea37c2ce1884a6ab34a8cc66eeb20ab3..079f35e2c56a0003b35ec73165a870b5c01d8979 100644 (file)
@@ -38,7 +38,7 @@ FD_form_character * FormCharacter::build_character()
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_gravity(obj, FL_NorthWest, FL_NorthEast);
     fl_set_object_resize(obj, FL_RESIZE_X);
-    fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0);
+    fl_set_object_callback(obj, C_FormBaseInputCB, 0);
   {
     char const * const dummy = N_("Series:|#S");
     fdui->choice_series = obj = fl_add_choice(FL_NORMAL_CHOICE, 94, 55, 191, 30, idex(_(dummy)));
@@ -48,7 +48,7 @@ FD_form_character * FormCharacter::build_character()
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_gravity(obj, FL_NorthWest, FL_NorthEast);
     fl_set_object_resize(obj, FL_RESIZE_X);
-    fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0);
+    fl_set_object_callback(obj, C_FormBaseInputCB, 0);
   {
     char const * const dummy = N_("Shape:|#H");
     fdui->choice_shape = obj = fl_add_choice(FL_NORMAL_CHOICE, 94, 95, 191, 30, idex(_(dummy)));
@@ -58,7 +58,7 @@ FD_form_character * FormCharacter::build_character()
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_gravity(obj, FL_NorthWest, FL_NorthEast);
     fl_set_object_resize(obj, FL_RESIZE_X);
-    fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0);
+    fl_set_object_callback(obj, C_FormBaseInputCB, 0);
   {
     char const * const dummy = N_("Size:|#Z");
     fdui->choice_size = obj = fl_add_choice(FL_NORMAL_CHOICE, 95, 275, 191, 30, idex(_(dummy)));
@@ -68,7 +68,7 @@ FD_form_character * FormCharacter::build_character()
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_gravity(obj, FL_NorthWest, FL_NorthEast);
     fl_set_object_resize(obj, FL_RESIZE_X);
-    fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0);
+    fl_set_object_callback(obj, C_FormBaseInputCB, 0);
   {
     char const * const dummy = N_("Misc:|#M");
     fdui->choice_bar = obj = fl_add_choice(FL_NORMAL_CHOICE, 95, 335, 190, 30, idex(_(dummy)));
@@ -78,7 +78,7 @@ FD_form_character * FormCharacter::build_character()
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_gravity(obj, FL_NorthWest, FL_NorthEast);
     fl_set_object_resize(obj, FL_RESIZE_X);
-    fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0);
+    fl_set_object_callback(obj, C_FormBaseInputCB, 0);
   {
     char const * const dummy = N_("Apply|#A");
     fdui->button_apply = obj = fl_add_button(FL_NORMAL_BUTTON, 60, 375, 80, 30, idex(_(dummy)));
@@ -86,7 +86,7 @@ FD_form_character * FormCharacter::build_character()
   }
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast);
-    fl_set_object_callback(obj, C_FormBaseDeprecatedApplyCB, 0);
+    fl_set_object_callback(obj, C_FormBaseApplyCB, 0);
   {
     char const * const dummy = N_("Cancel|#N");
     fdui->button_close = obj = fl_add_button(FL_RETURN_BUTTON, 175, 375, 80, 30, idex(_(dummy)));
@@ -94,7 +94,7 @@ FD_form_character * FormCharacter::build_character()
   }
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast);
-    fl_set_object_callback(obj, C_FormBaseDeprecatedCancelCB, 0);
+    fl_set_object_callback(obj, C_FormBaseCancelCB, 0);
   {
     char const * const dummy = N_("Color:|#C");
     fdui->choice_color = obj = fl_add_choice(FL_NORMAL_CHOICE, 95, 135, 191, 30, idex(_(dummy)));
@@ -104,7 +104,7 @@ FD_form_character * FormCharacter::build_character()
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_gravity(obj, FL_NorthWest, FL_NorthEast);
     fl_set_object_resize(obj, FL_RESIZE_X);
-    fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0);
+    fl_set_object_callback(obj, C_FormBaseInputCB, 0);
   {
     char const * const dummy = N_("Toggle on all these|#T");
     fdui->check_toggle_all = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 30, 215, 255, 25, idex(_(dummy)));
@@ -112,13 +112,13 @@ FD_form_character * FormCharacter::build_character()
   }
     fl_set_object_gravity(obj, FL_NorthWest, FL_NorthEast);
     fl_set_object_resize(obj, FL_RESIZE_X);
-    fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0);
+    fl_set_object_callback(obj, C_FormBaseInputCB, 0);
   fdui->choice_language = obj = fl_add_choice(FL_DROPLIST_CHOICE, 95, 175, 190, 30, _("Language:"));
     fl_set_object_boxtype(obj, FL_FRAME_BOX);
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_gravity(obj, FL_NorthWest, FL_NorthEast);
     fl_set_object_resize(obj, FL_RESIZE_X);
-    fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0);
+    fl_set_object_callback(obj, C_FormBaseInputCB, 0);
   obj = fl_add_labelframe(FL_ENGRAVED_FRAME, 10, 265, 280, 45, _("These are never toggled"));
     fl_set_object_lstyle(obj, FL_BOLD_STYLE);
     fl_set_object_gravity(obj, FL_NorthWest, FL_NorthEast);
index 74168bfd94d10d0511da5a9e14a0df734a4d7eed..6b5144415c68752c25a39198f56b3a9a2dea3ce8 100644 (file)
@@ -5,9 +5,9 @@
 #define FD_form_character_h_
 
 /** Callbacks, globals and object handlers **/
-extern  "C" void C_FormBaseDeprecatedInputCB(FL_OBJECT *, long);
-extern  "C" void C_FormBaseDeprecatedApplyCB(FL_OBJECT *, long);
-extern  "C" void C_FormBaseDeprecatedCancelCB(FL_OBJECT *, long);
+extern  "C" void C_FormBaseInputCB(FL_OBJECT *, long);
+extern  "C" void C_FormBaseApplyCB(FL_OBJECT *, long);
+extern  "C" void C_FormBaseCancelCB(FL_OBJECT *, long);
 
 
 /**** Forms and Objects ****/
index 25ce74c2858c03b13804851363980a36599ea31a..fbc4bc394c661d1fa6056968216c8e3ebf403e22 100644 (file)
@@ -64,7 +64,7 @@ shortcut:
 resize: FL_RESIZE_X
 gravity: FL_NorthWest FL_NorthEast
 name: choice_family
-callback: C_FormBaseDeprecatedInputCB
+callback: C_FormBaseInputCB
 argument: 0
 
 --------------------
@@ -82,7 +82,7 @@ shortcut:
 resize: FL_RESIZE_X
 gravity: FL_NorthWest FL_NorthEast
 name: choice_series
-callback: C_FormBaseDeprecatedInputCB
+callback: C_FormBaseInputCB
 argument: 0
 
 --------------------
@@ -100,7 +100,7 @@ shortcut:
 resize: FL_RESIZE_X
 gravity: FL_NorthWest FL_NorthEast
 name: choice_shape
-callback: C_FormBaseDeprecatedInputCB
+callback: C_FormBaseInputCB
 argument: 0
 
 --------------------
@@ -118,7 +118,7 @@ shortcut:
 resize: FL_RESIZE_X
 gravity: FL_NorthWest FL_NorthEast
 name: choice_size
-callback: C_FormBaseDeprecatedInputCB
+callback: C_FormBaseInputCB
 argument: 0
 
 --------------------
@@ -136,7 +136,7 @@ shortcut:
 resize: FL_RESIZE_X
 gravity: FL_NorthWest FL_NorthEast
 name: choice_bar
-callback: C_FormBaseDeprecatedInputCB
+callback: C_FormBaseInputCB
 argument: 0
 
 --------------------
@@ -154,7 +154,7 @@ shortcut:
 resize: FL_RESIZE_NONE
 gravity: FL_SouthEast FL_SouthEast
 name: button_apply
-callback: C_FormBaseDeprecatedApplyCB
+callback: C_FormBaseApplyCB
 argument: 0
 
 --------------------
@@ -172,7 +172,7 @@ shortcut: ^M
 resize: FL_RESIZE_NONE
 gravity: FL_SouthEast FL_SouthEast
 name: button_close
-callback: C_FormBaseDeprecatedCancelCB
+callback: C_FormBaseCancelCB
 argument: 0
 
 --------------------
@@ -190,7 +190,7 @@ shortcut:
 resize: FL_RESIZE_X
 gravity: FL_NorthWest FL_NorthEast
 name: choice_color
-callback: C_FormBaseDeprecatedInputCB
+callback: C_FormBaseInputCB
 argument: 0
 
 --------------------
@@ -208,7 +208,7 @@ shortcut:
 resize: FL_RESIZE_X
 gravity: FL_NorthWest FL_NorthEast
 name: check_toggle_all
-callback: C_FormBaseDeprecatedInputCB
+callback: C_FormBaseInputCB
 argument: 0
 
 --------------------
@@ -226,7 +226,7 @@ shortcut:
 resize: FL_RESIZE_X
 gravity: FL_NorthWest FL_NorthEast
 name: choice_language
-callback: C_FormBaseDeprecatedInputCB
+callback: C_FormBaseInputCB
 argument: 0
 
 --------------------
index e9bf9de31e047459dd7dd78baf31b68bbfdfed38..3bfe43b457f8a8f39ac7385f5c3d5eb36da576d8 100644 (file)
@@ -86,12 +86,18 @@ public:
        ///
        typedef LanguageList::const_iterator const_iterator;
        ///
+       typedef LanguageList::size_type size_type;
+       ///
        void read(string const & filename);
        ///
        void setDefaults();
        ///
        Language const * getLanguage(string const & language) const;
        ///
+       size_type size() const {
+               return languagelist.size();
+       }
+       ///
        const_iterator begin() const {
                 return languagelist.begin();
         }
@@ -109,6 +115,6 @@ private:
 extern Languages languages;
 extern Language const * default_language;
 extern Language const * english_language;
-extern Language const *ignore_language;
+extern Language const * ignore_language;
 
 #endif