From a12309c76b8fdcc69d0daf38f0b3068ca54d70d2 Mon Sep 17 00:00:00 2001 From: Angus Leeming Date: Wed, 21 Mar 2001 13:27:03 +0000 Subject: [PATCH] Implementation of controller-view split for FormCharacter. 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 --- src/ChangeLog | 4 + src/frontends/controllers/ButtonController.C | 2 +- src/frontends/controllers/ButtonController.h | 2 +- src/frontends/controllers/ButtonPolicies.h | 2 +- src/frontends/controllers/ChangeLog | 12 + src/frontends/controllers/ControlBase.C | 2 +- src/frontends/controllers/ControlBase.h | 5 +- src/frontends/controllers/ControlBibitem.h | 2 - src/frontends/controllers/ControlBibtex.h | 2 - src/frontends/controllers/ControlCharacter.C | 350 ++++++++++++++++++ src/frontends/controllers/ControlCharacter.h | 130 +++++++ src/frontends/controllers/ControlCitation.C | 30 +- src/frontends/controllers/ControlCitation.h | 10 +- src/frontends/controllers/ControlCommand.C | 2 - src/frontends/controllers/ControlCommand.h | 5 +- .../controllers/ControlConnections.C | 3 +- .../controllers/ControlConnections.h | 2 +- src/frontends/controllers/ControlLog.C | 2 - src/frontends/controllers/ControlVCLog.C | 6 +- src/frontends/controllers/Makefile.am | 6 +- src/frontends/controllers/ViewBase.h | 2 +- src/frontends/controllers/helper_funcs.C | 55 +++ src/frontends/controllers/helper_funcs.h | 97 +++++ src/frontends/xforms/ChangeLog | 12 + src/frontends/xforms/Dialogs.C | 14 +- src/frontends/xforms/FormBase.C | 2 +- src/frontends/xforms/FormBibitem.C | 2 +- src/frontends/xforms/FormBibtex.C | 2 +- src/frontends/xforms/FormCharacter.C | 271 +++++--------- src/frontends/xforms/FormCharacter.h | 51 +-- src/frontends/xforms/FormCitation.C | 8 +- src/frontends/xforms/form_character.C | 20 +- src/frontends/xforms/form_character.h | 6 +- src/frontends/xforms/forms/form_character.fd | 20 +- src/language.h | 8 +- 35 files changed, 857 insertions(+), 292 deletions(-) create mode 100644 src/frontends/controllers/ControlCharacter.C create mode 100644 src/frontends/controllers/ControlCharacter.h create mode 100644 src/frontends/controllers/helper_funcs.C create mode 100644 src/frontends/controllers/helper_funcs.h diff --git a/src/ChangeLog b/src/ChangeLog index bda4314831..be60196712 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2001-03-20 Angus Leeming + + * language.h (Languages): added size_type and size(). + 2001-03-20 Lars Gullik Bjønnes * buffer.C (parseSingleLyXformat2Token): Try to give a bit better diff --git a/src/frontends/controllers/ButtonController.C b/src/frontends/controllers/ButtonController.C index 762255ca1c..5653a4a3a6 100644 --- a/src/frontends/controllers/ButtonController.C +++ b/src/frontends/controllers/ButtonController.C @@ -4,7 +4,7 @@ * * LyX, The Document Processor * - * Copyright 2000 The LyX Team. + * Copyright 2000-2001 The LyX Team. * * ====================================================== * diff --git a/src/frontends/controllers/ButtonController.h b/src/frontends/controllers/ButtonController.h index 97d4ee0f86..c3fec57b00 100644 --- a/src/frontends/controllers/ButtonController.h +++ b/src/frontends/controllers/ButtonController.h @@ -4,7 +4,7 @@ * * LyX, The Document Processor * - * Copyright 2000 The LyX Team. + * Copyright 2000-2001 The LyX Team. * * ====================================================== * diff --git a/src/frontends/controllers/ButtonPolicies.h b/src/frontends/controllers/ButtonPolicies.h index 3282305833..8f386ca422 100644 --- a/src/frontends/controllers/ButtonPolicies.h +++ b/src/frontends/controllers/ButtonPolicies.h @@ -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 diff --git a/src/frontends/controllers/ChangeLog b/src/frontends/controllers/ChangeLog index 4aca29f7ca..7953f89026 100644 --- a/src/frontends/controllers/ChangeLog +++ b/src/frontends/controllers/ChangeLog @@ -1,3 +1,15 @@ +2001-03-21 Angus Leeming + + * 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 * ControlCitation.C (getBibkeyInfo): parse non-BibTeX entries correctly. diff --git a/src/frontends/controllers/ControlBase.C b/src/frontends/controllers/ControlBase.C index 6b18056c3f..8d3ea35846 100644 --- a/src/frontends/controllers/ControlBase.C +++ b/src/frontends/controllers/ControlBase.C @@ -4,7 +4,7 @@ * * LyX, The Document Processor * - * Copyright 2000 The LyX Team. + * Copyright 2001 The LyX Team. * * ====================================================== * diff --git a/src/frontends/controllers/ControlBase.h b/src/frontends/controllers/ControlBase.h index 7593ec3f15..d3c73ef7dc 100644 --- a/src/frontends/controllers/ControlBase.h +++ b/src/frontends/controllers/ControlBase.h @@ -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 diff --git a/src/frontends/controllers/ControlBibitem.h b/src/frontends/controllers/ControlBibitem.h index e6ead2ad8d..f2c5176ac1 100644 --- a/src/frontends/controllers/ControlBibitem.h +++ b/src/frontends/controllers/ControlBibitem.h @@ -21,8 +21,6 @@ #endif #include "ControlCommand.h" -#include "ButtonController.h" -#include "ViewBase.h" /** A controller for Bibitem dialogs. */ diff --git a/src/frontends/controllers/ControlBibtex.h b/src/frontends/controllers/ControlBibtex.h index 2771ed36d5..42789a18c9 100644 --- a/src/frontends/controllers/ControlBibtex.h +++ b/src/frontends/controllers/ControlBibtex.h @@ -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 index 0000000000..45746ca997 --- /dev/null +++ b/src/frontends/controllers/ControlCharacter.C @@ -0,0 +1,350 @@ +/** + * \file ControlCharacter.C + * Copyright 2001 The LyX Team. + * See the file COPYING. + * + * \author Angus Leeming, a.leeming@.ac.uk + */ + +#include + +#ifdef __GNUG_ +#pragma implementation +#endif + +#include + +#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 const getFamilyData() +{ + vector 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 const getSeriesData() +{ + vector 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 const getShapeData() +{ + vector 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 const getSizeData() +{ + vector 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 const getBarData() +{ + vector 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 const getColorData() +{ + vector 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 const getLanguageData() +{ + vector langs(languages.size() + 2); + + langs[0] = _("No change"); + langs[1] = _("Reset"); + + vector::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 index 0000000000..92a671fbf3 --- /dev/null +++ b/src/frontends/controllers/ControlCharacter.h @@ -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 FamilyPair; + /// + typedef std::pair SeriesPair; + /// + typedef std::pair ShapePair; + /// + typedef std::pair SizePair; + /// + typedef std::pair BarPair; + /// + typedef std::pair 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 const getFamilyData(); +/// +std::vector const getSeriesData(); +/// +std::vector const getShapeData(); +/// +std::vector const getSizeData(); +/// +std::vector const getBarData(); +/// +std::vector const getColorData(); +/// +std::vector const getLanguageData(); + +/** This class instantiates and makes available the GUI-specific + ButtonController and View. + */ +template +class GUICharacter : public ControlCharacter { +public: + /// + GUICharacter(LyXView &, Dialogs &); + /// + virtual ButtonControllerBase & bc() { return bc_; } + /// + virtual ViewBase & view() { return view_; } + +private: + /// + ButtonController bc_; + /// + GUIview view_; +}; + +template +GUICharacter::GUICharacter(LyXView & lv, Dialogs & d) + : ControlCharacter(lv, d), + view_(*this) +{} + +#endif // CONTROLCHARACTER_H diff --git a/src/frontends/controllers/ControlCitation.C b/src/frontends/controllers/ControlCitation.C index 9e25086f29..05a409e4c9 100644 --- a/src/frontends/controllers/ControlCitation.C +++ b/src/frontends/controllers/ControlCitation.C @@ -4,7 +4,7 @@ * * LyX, The Document Processor * - * Copyright 2000 The LyX Team. + * Copyright 2001 The LyX Team. * * ====================================================== * @@ -22,10 +22,9 @@ #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 const & vec, char delim) -{ - string str; - for (vector::size_type i=0; i 0) str += tostr(delim); - str += vec[i]; - } - return str; -} - -vector const getVectorFromString(string const & str, char delim) -{ - vector 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::const_iterator searchKeys(ControlCitation const & controller, vector const & keys, @@ -185,7 +161,7 @@ simpleSearch(ControlCitation const & controller, ControlCitation::Direction dir, bool caseSensitive) { - vector searchwords = getVectorFromString(expr, ' '); + vector searchwords = getVectorFromString(expr, " "); // Loop over all keys from start... for (vector::const_iterator it = start; diff --git a/src/frontends/controllers/ControlCitation.h b/src/frontends/controllers/ControlCitation.h index 173004db4b..fc6b2c56a9 100644 --- a/src/frontends/controllers/ControlCitation.h +++ b/src/frontends/controllers/ControlCitation.h @@ -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::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 const &, char delim=','); -/// -std::vector 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); diff --git a/src/frontends/controllers/ControlCommand.C b/src/frontends/controllers/ControlCommand.C index bc2744db00..b728bed8de 100644 --- a/src/frontends/controllers/ControlCommand.C +++ b/src/frontends/controllers/ControlCommand.C @@ -20,12 +20,10 @@ #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(lv, d), diff --git a/src/frontends/controllers/ControlCommand.h b/src/frontends/controllers/ControlCommand.h index 802c422c3e..b5373a49fb 100644 --- a/src/frontends/controllers/ControlCommand.h +++ b/src/frontends/controllers/ControlCommand.h @@ -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. */ diff --git a/src/frontends/controllers/ControlConnections.C b/src/frontends/controllers/ControlConnections.C index 0ec1080609..a98c1d4df4 100644 --- a/src/frontends/controllers/ControlConnections.C +++ b/src/frontends/controllers/ControlConnections.C @@ -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; diff --git a/src/frontends/controllers/ControlConnections.h b/src/frontends/controllers/ControlConnections.h index 7fd9c5732e..63a3b5883b 100644 --- a/src/frontends/controllers/ControlConnections.h +++ b/src/frontends/controllers/ControlConnections.h @@ -4,7 +4,7 @@ * * LyX, The Document Processor * - * Copyright 2000 The LyX Team. + * Copyright 2001 The LyX Team. * * ====================================================== * diff --git a/src/frontends/controllers/ControlLog.C b/src/frontends/controllers/ControlLog.C index ff00b6cf56..5e0a7a41e8 100644 --- a/src/frontends/controllers/ControlLog.C +++ b/src/frontends/controllers/ControlLog.C @@ -17,12 +17,10 @@ #endif #include -#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; diff --git a/src/frontends/controllers/ControlVCLog.C b/src/frontends/controllers/ControlVCLog.C index acba9d795c..f6d357abd0 100644 --- a/src/frontends/controllers/ControlVCLog.C +++ b/src/frontends/controllers/ControlVCLog.C @@ -7,7 +7,7 @@ * * ====================================================== * - * \file ControlVCLog.h + * \file ControlVCLog.C * \author John Levon, moz@compsoc.man.ac.uk * \author Angus Leeming */ @@ -17,13 +17,11 @@ #endif #include -#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; diff --git a/src/frontends/controllers/Makefile.am b/src/frontends/controllers/Makefile.am index 65fcafb648..bda959c5f7 100644 --- a/src/frontends/controllers/Makefile.am +++ b/src/frontends/controllers/Makefile.am @@ -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: diff --git a/src/frontends/controllers/ViewBase.h b/src/frontends/controllers/ViewBase.h index 541bbe9335..a99d51f1ae 100644 --- a/src/frontends/controllers/ViewBase.h +++ b/src/frontends/controllers/ViewBase.h @@ -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 index 0000000000..96b40435b6 --- /dev/null +++ b/src/frontends/controllers/helper_funcs.C @@ -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 + */ + +#include + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include +#include "LString.h" +#include "helper_funcs.h" + +using std::vector; + +string const getStringFromVector(vector const & vec, + string const & delim) +{ + string str; + for (vector::size_type i=0; i 0) str += delim; + str += vec[i]; + } + return str; +} + +vector const getVectorFromString(string const & str, + string const & delim) +{ + vector 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 index 0000000000..4e6be14a62 --- /dev/null +++ b/src/frontends/controllers/helper_funcs.h @@ -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 + */ + +#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 const & vec, string const & delim=","); + +/// +std::vector const +getVectorFromString(string const & str, string const & delim=","); + +/** Functions to extract vectors of the first and second elems from a + vector > +*/ + +/// +template +std::vector const getFirst(std::vector > const & pairVec) +{ + typedef std::vector > PV; + + std::vector first(pairVec.size()); + + for (PV::size_type i = 0; i < pairVec.size(); ++i) { + first[i] = pairVec[i].first; + } + + return first; +} +/// +template +std::vector const getSecond(std::vector > const & pairVec) +{ + typedef std::vector > PV; + + std::vector second(pairVec.size()); + + for (PV::size_type i = 0; i < pairVec.size(); ++i) { + second[i] = pairVec[i].second; + } + + return second; +} + + +template +struct firster { + typedef typename Pair::first_type first_type; + first_type const & operator()(Pair const & p) { return p.first; } +}; + +template +struct seconder { + typedef typename Pair::second_type second_type; + second_type const & operator()(Pair const & p) { return p.second; } +}; + +template +typename Pair::first_type const getFirst(std::vector const & pr) +{ + std::vector tmp(pr.size); + std::transform(pr.begin(), pr.end(), tmp.begin(), firster()); + return tmp; +} + +template +typename Pair::second_type const getSecond(std::vector const & pr) +{ + std::vector tmp(pr.size); + std::transform(pr.begin(), pr.end(), tmp.begin(), seconder()); + return tmp; +} + + + +#endif // HELPERFUNCS_H + diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index b17729df06..f01740649d 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,15 @@ +2001-03-21 Angus Leeming + + * 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 * FormBase.[Ch] (input): no longer pure virtual. Has defualt state of diff --git a/src/frontends/xforms/Dialogs.C b/src/frontends/xforms/Dialogs.C index 776df33c40..23dd91174f 100644 --- a/src/frontends/xforms/Dialogs.C +++ b/src/frontends/xforms/Dialogs.C @@ -17,25 +17,29 @@ #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(*lv, *this)); add(new GUIBibitem(*lv, *this)); add(new GUIBibtex(*lv, *this)); + add(new GUICharacter(*lv, *this)); + add(new GUICitation(*lv, *this)); add(new GUILog(*lv, *this)); add(new GUIVCLog(*lv, *this)); - add(new FormCharacter(lv, this)); add(new FormCopyright(lv, this)); add(new FormCredits(lv, this)); add(new FormDocument(lv, this)); diff --git a/src/frontends/xforms/FormBase.C b/src/frontends/xforms/FormBase.C index 30cfc33d0c..d1cd266962 100644 --- a/src/frontends/xforms/FormBase.C +++ b/src/frontends/xforms/FormBase.C @@ -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; } diff --git a/src/frontends/xforms/FormBibitem.C b/src/frontends/xforms/FormBibitem.C index 69aeb1afa5..f37487573f 100644 --- a/src/frontends/xforms/FormBibitem.C +++ b/src/frontends/xforms/FormBibitem.C @@ -12,11 +12,11 @@ #endif #include +#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 > base_class; diff --git a/src/frontends/xforms/FormBibtex.C b/src/frontends/xforms/FormBibtex.C index 333a8f4cf7..cd29bcdd06 100644 --- a/src/frontends/xforms/FormBibtex.C +++ b/src/frontends/xforms/FormBibtex.C @@ -12,11 +12,11 @@ #endif #include +#include "xformsBC.h" #include "ControlBibtex.h" #include "FormBibtex.h" #include "form_bibtex.h" #include "gettext.h" -#include "xformsBC.h" #include "debug.h" typedef FormCB > base_class; diff --git a/src/frontends/xforms/FormCharacter.C b/src/frontends/xforms/FormCharacter.C index 5689892814..2277964076 100644 --- a/src/frontends/xforms/FormCharacter.C +++ b/src/frontends/xforms/FormCharacter.C @@ -3,204 +3,133 @@ * 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 - -#include FORMS_H_LOCATION +#include #ifdef __GNUG_ #pragma implementation #endif +#include + +#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 > 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(v); + pre->InputCB(reinterpret_cast(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 const family = getFamilyData(); + vector const series = getSeriesData(); + vector const shape = getShapeData(); + vector const size = getSizeData(); + vector const bar = getBarData(); + vector const color = getColorData(); + vector 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::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); } diff --git a/src/frontends/xforms/FormCharacter.h b/src/frontends/xforms/FormCharacter.h index ca7cdaebab..03ddeaffbe 100644 --- a/src/frontends/xforms/FormCharacter.h +++ b/src/frontends/xforms/FormCharacter.h @@ -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 @@ -16,7 +17,10 @@ #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 > { 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 dialog_; - /// boost::scoped_ptr combo_language2_; - - /// The ButtonController - ButtonController bc_; + /// + std::vector family_; + /// + std::vector series_; + /// + std::vector shape_; + /// + std::vector size_; + /// + std::vector bar_; + /// + std::vector color_; }; - -inline -xformsBC & FormCharacter::bc() -{ - return bc_; -} #endif diff --git a/src/frontends/xforms/FormCitation.C b/src/frontends/xforms/FormCitation.C index eb63893974..a5580f0799 100644 --- a/src/frontends/xforms/FormCitation.C +++ b/src/frontends/xforms/FormCitation.C @@ -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::size_type i = 0; i < keys.size(); ++i) - fl_add_browser_line(browser, keys[i].c_str()); + for (vector::const_iterator it = keys.begin(); + it < keys.end(); ++it) { + string key = frontStrip(strip(*it)); + fl_add_browser_line(browser, key.c_str()); + } } diff --git a/src/frontends/xforms/form_character.C b/src/frontends/xforms/form_character.C index 16d9c95aea..079f35e2c5 100644 --- a/src/frontends/xforms/form_character.C +++ b/src/frontends/xforms/form_character.C @@ -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); diff --git a/src/frontends/xforms/form_character.h b/src/frontends/xforms/form_character.h index 74168bfd94..6b5144415c 100644 --- a/src/frontends/xforms/form_character.h +++ b/src/frontends/xforms/form_character.h @@ -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 ****/ diff --git a/src/frontends/xforms/forms/form_character.fd b/src/frontends/xforms/forms/form_character.fd index 25ce74c285..fbc4bc394c 100644 --- a/src/frontends/xforms/forms/form_character.fd +++ b/src/frontends/xforms/forms/form_character.fd @@ -64,7 +64,7 @@ shortcut: resize: FL_RESIZE_X gravity: FL_NorthWest FL_NorthEast name: choice_family -callback: C_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 -------------------- diff --git a/src/language.h b/src/language.h index e9bf9de31e..3bfe43b457 100644 --- a/src/language.h +++ b/src/language.h @@ -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 -- 2.39.2