mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
* Split out getLanguageData from character.[Ch] into its own files,
frnt_lang.[Ch]. Move all these functions into namespace frnt as namespace charcter doesn't make much sense anymore. * Associated changes to ControlCharacter and to FormCharacter. * Use the same approach to internationalise the language names in the document dialog. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4087 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
93ad5c74f1
commit
b2bef6f65a
@ -1,12 +1,17 @@
|
||||
2002-04-29 Angus Leeming <a.leeming@ic.ac.uk>
|
||||
|
||||
* character.[Ch] (getLanguageData): returns a vector<LanguagePair>
|
||||
where LanguagePair is a display string and an identifying string.
|
||||
The display string is internationalised.
|
||||
* character.[Ch]: rename namespace character as namespace frnt.
|
||||
|
||||
* frnt_lang.[Ch]: new file. Move getLanguageData from character.[Ch]
|
||||
as several dialogs will use this info. The function now returns a
|
||||
vector<LanguagePair> where LanguagePair is a display string and an
|
||||
identifying string. The display string is internationalised.
|
||||
|
||||
* ControlCharacter.C (getLanguage, setLanguage): Do not internationalise
|
||||
the identifying strings, "No change" and "Reset".
|
||||
|
||||
* Makefile.am: add frnt_lang.[Ch].
|
||||
|
||||
2002-04-25 Herbert Voss <voss@lyx.org>
|
||||
|
||||
* ControlSendto.C (allFormats): don't add the graphics extensions to the
|
||||
|
@ -52,7 +52,7 @@ void ControlCharacter::setParams()
|
||||
getSeries() != LyXFont::IGNORE_SERIES ||
|
||||
getShape() != LyXFont::IGNORE_SHAPE ||
|
||||
getSize() != LyXFont::IGNORE_SIZE ||
|
||||
getBar() != character::IGNORE ||
|
||||
getBar() != frnt::IGNORE ||
|
||||
getColor() != LColor::ignore ||
|
||||
font_->language() != ignore_language)
|
||||
bc().valid();
|
||||
@ -132,51 +132,51 @@ void ControlCharacter::setSize(LyXFont::FONT_SIZE val)
|
||||
}
|
||||
|
||||
|
||||
character::FONT_STATE ControlCharacter::getBar() const
|
||||
frnt::FONT_STATE ControlCharacter::getBar() const
|
||||
{
|
||||
if (!font_.get())
|
||||
return character::IGNORE;
|
||||
return frnt::IGNORE;
|
||||
|
||||
if (font_->emph() == LyXFont::TOGGLE)
|
||||
return character::EMPH_TOGGLE;
|
||||
return frnt::EMPH_TOGGLE;
|
||||
|
||||
if (font_->underbar() == LyXFont::TOGGLE)
|
||||
return character::UNDERBAR_TOGGLE;
|
||||
return frnt::UNDERBAR_TOGGLE;
|
||||
|
||||
if (font_->noun() == LyXFont::TOGGLE)
|
||||
return character::NOUN_TOGGLE;
|
||||
return frnt::NOUN_TOGGLE;
|
||||
|
||||
if (font_->emph() == LyXFont::IGNORE &&
|
||||
font_->underbar() == LyXFont::IGNORE &&
|
||||
font_->noun() == LyXFont::IGNORE)
|
||||
return character::IGNORE;
|
||||
return frnt::IGNORE;
|
||||
|
||||
return character::INHERIT;
|
||||
return frnt::INHERIT;
|
||||
}
|
||||
|
||||
|
||||
void ControlCharacter::setBar(character::FONT_STATE val)
|
||||
void ControlCharacter::setBar(frnt::FONT_STATE val)
|
||||
{
|
||||
switch (val) {
|
||||
case character::IGNORE:
|
||||
case frnt::IGNORE:
|
||||
font_->setEmph(LyXFont::IGNORE);
|
||||
font_->setUnderbar(LyXFont::IGNORE);
|
||||
font_->setNoun(LyXFont::IGNORE);
|
||||
break;
|
||||
|
||||
case character::EMPH_TOGGLE:
|
||||
case frnt::EMPH_TOGGLE:
|
||||
font_->setEmph(LyXFont::TOGGLE);
|
||||
break;
|
||||
|
||||
case character::UNDERBAR_TOGGLE:
|
||||
case frnt::UNDERBAR_TOGGLE:
|
||||
font_->setUnderbar(LyXFont::TOGGLE);
|
||||
break;
|
||||
|
||||
case character::NOUN_TOGGLE:
|
||||
case frnt::NOUN_TOGGLE:
|
||||
font_->setNoun(LyXFont::TOGGLE);
|
||||
break;
|
||||
|
||||
case character::INHERIT:
|
||||
case frnt::INHERIT:
|
||||
font_->setEmph(LyXFont::INHERIT);
|
||||
font_->setUnderbar(LyXFont::INHERIT);
|
||||
font_->setNoun(LyXFont::INHERIT);
|
||||
|
@ -36,7 +36,7 @@ public:
|
||||
///
|
||||
void setSize(LyXFont::FONT_SIZE);
|
||||
///
|
||||
void setBar(character::FONT_STATE);
|
||||
void setBar(frnt::FONT_STATE);
|
||||
///
|
||||
void setColor(LColor::color);
|
||||
///
|
||||
@ -53,7 +53,7 @@ public:
|
||||
///
|
||||
LyXFont::FONT_SIZE getSize() const;
|
||||
///
|
||||
character::FONT_STATE getBar() const;
|
||||
frnt::FONT_STATE getBar() const;
|
||||
///
|
||||
LColor::color getColor() const;
|
||||
///
|
||||
|
@ -13,6 +13,8 @@ libcontrollers_la_SOURCES= \
|
||||
biblio.h \
|
||||
character.C \
|
||||
character.h \
|
||||
frnt_lang.C \
|
||||
frnt_lang.h \
|
||||
ButtonController.h \
|
||||
ButtonControllerBase.C \
|
||||
ButtonControllerBase.h \
|
||||
|
@ -20,11 +20,10 @@
|
||||
|
||||
#include "gettext.h"
|
||||
#include "character.h"
|
||||
#include "language.h"
|
||||
|
||||
using std::vector;
|
||||
|
||||
namespace character {
|
||||
namespace frnt {
|
||||
|
||||
vector<FamilyPair> const getFamilyData()
|
||||
{
|
||||
@ -175,23 +174,4 @@ vector<ColorPair> const getColorData()
|
||||
return color;
|
||||
}
|
||||
|
||||
|
||||
vector<LanguagePair> const getLanguageData()
|
||||
{
|
||||
vector<LanguagePair> langs(languages.size() + 2);
|
||||
|
||||
langs[0].first = N_("No change"); langs[0].second = "No change";
|
||||
langs[1].first = N_("Reset"); langs[1].second = "Reset";
|
||||
|
||||
vector<string>::size_type i = 2;
|
||||
for (Languages::const_iterator cit = languages.begin();
|
||||
cit != languages.end(); ++cit) {
|
||||
langs[i].first = cit->second.display();
|
||||
langs[i].second = cit->second.lang();
|
||||
++i;
|
||||
}
|
||||
|
||||
return langs;
|
||||
}
|
||||
|
||||
} // namespace character
|
||||
} // namespace frnt
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include "LColor.h"
|
||||
|
||||
/** Functions of use to the character GUI controller and view */
|
||||
namespace character {
|
||||
namespace frnt {
|
||||
///
|
||||
enum FONT_STATE {
|
||||
///
|
||||
@ -50,8 +50,6 @@ namespace character {
|
||||
typedef std::pair<string, FONT_STATE> BarPair;
|
||||
///
|
||||
typedef std::pair<string, LColor::color> ColorPair;
|
||||
///
|
||||
typedef std::pair<string, string> LanguagePair;
|
||||
|
||||
///
|
||||
std::vector<FamilyPair> const getFamilyData();
|
||||
@ -65,9 +63,7 @@ namespace character {
|
||||
std::vector<BarPair> const getBarData();
|
||||
///
|
||||
std::vector<ColorPair> const getColorData();
|
||||
///
|
||||
std::vector<LanguagePair> const getLanguageData();
|
||||
|
||||
} // namespace character
|
||||
} // namespace frnt
|
||||
|
||||
#endif // CHARACTERHELPERS
|
||||
|
41
src/frontends/controllers/frnt_lang.C
Normal file
41
src/frontends/controllers/frnt_lang.C
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* \file frnt_lang.C
|
||||
* Copyright 2002 the LyX Team
|
||||
* Read the file COPYING
|
||||
*
|
||||
* \author Angus Leeming, a.leeming@ic.ac.uk
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation
|
||||
#endif
|
||||
|
||||
#include "frnt_lang.h"
|
||||
#include "gettext.h"
|
||||
#include "language.h"
|
||||
|
||||
using std::vector;
|
||||
|
||||
namespace frnt {
|
||||
|
||||
vector<LanguagePair> const getLanguageData()
|
||||
{
|
||||
vector<LanguagePair> langs(languages.size() + 2);
|
||||
|
||||
langs[0].first = N_("No change"); langs[0].second = "No change";
|
||||
langs[1].first = N_("Reset"); langs[1].second = "Reset";
|
||||
|
||||
vector<string>::size_type i = 2;
|
||||
for (Languages::const_iterator cit = languages.begin();
|
||||
cit != languages.end(); ++cit) {
|
||||
langs[i].first = cit->second.display();
|
||||
langs[i].second = cit->second.lang();
|
||||
++i;
|
||||
}
|
||||
|
||||
return langs;
|
||||
}
|
||||
|
||||
} // namespace frnt
|
31
src/frontends/controllers/frnt_lang.h
Normal file
31
src/frontends/controllers/frnt_lang.h
Normal file
@ -0,0 +1,31 @@
|
||||
// -*- C++ -*-
|
||||
/*
|
||||
* \file frnt_lang.h
|
||||
* Copyright 2002 the LyX Team
|
||||
* Read the file COPYING
|
||||
*
|
||||
* \author Angus Leeming, a.leeming@ic.ac.uk
|
||||
*/
|
||||
|
||||
#ifndef FRNT_LANG_H
|
||||
#define FRNT_LANG_H
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include "LString.h"
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
/** Ease the use of internationalised language strings in the dialogs.
|
||||
*/
|
||||
namespace frnt {
|
||||
///
|
||||
typedef std::pair<string, string> LanguagePair;
|
||||
///
|
||||
std::vector<LanguagePair> const getLanguageData();
|
||||
|
||||
} // namespace frnt
|
||||
|
||||
#endif // FRNT_LANG_H
|
@ -2,9 +2,13 @@
|
||||
|
||||
* FormCharacter.h: store a vector<string> lang_ of language identifiers.
|
||||
|
||||
* FormCharacter.C: changes associated with character::getLanguageData
|
||||
* FormCharacter.C: changes associated with frnt::getLanguageData
|
||||
returning a vector<LanguagePair> rather than a vector<string>.
|
||||
|
||||
* FormDocument.h: store a vector<string> lang_ of language identifiers.
|
||||
|
||||
* FormDocument.C: internationalise the languages on display.
|
||||
|
||||
2002-04-26 John Levon <moz@compsoc.man.ac.uk>
|
||||
|
||||
* FormMathsPanel.C: translate Close
|
||||
|
@ -22,13 +22,14 @@
|
||||
#include "gettext.h"
|
||||
#include "combox.h"
|
||||
#include "helper_funcs.h"
|
||||
#include "frnt_lang.h"
|
||||
|
||||
#include "support/lstrings.h"
|
||||
|
||||
using std::vector;
|
||||
using std::find;
|
||||
|
||||
using namespace character;
|
||||
using namespace frnt;
|
||||
|
||||
typedef FormCB<ControlCharacter, FormDB<FD_form_character> > base_class;
|
||||
|
||||
@ -53,7 +54,7 @@ void FormCharacter::build()
|
||||
vector<SizePair> const size = getSizeData();
|
||||
vector<BarPair> const bar = getBarData();
|
||||
vector<ColorPair> const color = getColorData();
|
||||
vector<LanguagePair> const language = getLanguageData();
|
||||
vector<LanguagePair> const langs = getLanguageData();
|
||||
|
||||
// Store the identifiers for later
|
||||
family_ = getSecond(family);
|
||||
@ -62,7 +63,7 @@ void FormCharacter::build()
|
||||
size_ = getSecond(size);
|
||||
bar_ = getSecond(bar);
|
||||
color_ = getSecond(color);
|
||||
lang_ = getSecond(language);
|
||||
lang_ = getSecond(langs);
|
||||
|
||||
// create a string of entries " entry1 | entry2 | entry3 | entry4 "
|
||||
// with which to initialise the xforms choice object.
|
||||
@ -99,9 +100,10 @@ void FormCharacter::build()
|
||||
fl_end_form();
|
||||
|
||||
// build up the combox entries
|
||||
for (vector<LanguagePair>::const_iterator cit = language.begin();
|
||||
cit != language.end(); ++cit) {
|
||||
combo_language2_->addto(_(cit->first));
|
||||
vector<LanguagePair>::const_iterator it = langs.begin();
|
||||
vector<LanguagePair>::const_iterator end = langs.end();
|
||||
for (; it != end; ++it) {
|
||||
combo_language2_->addto(_(it->first));
|
||||
}
|
||||
combo_language2_->select(1);
|
||||
|
||||
@ -205,7 +207,7 @@ ButtonPolicy::SMInput FormCharacter::input(FL_OBJECT *, long)
|
||||
activate = ButtonPolicy::SMI_VALID;
|
||||
|
||||
pos = fl_get_choice(dialog_->choice_bar);
|
||||
if (bar_[pos-1] != character::IGNORE)
|
||||
if (bar_[pos-1] != frnt::IGNORE)
|
||||
activate = ButtonPolicy::SMI_VALID;
|
||||
|
||||
pos = fl_get_choice(dialog_->choice_color);
|
||||
|
@ -68,7 +68,7 @@ private:
|
||||
///
|
||||
std::vector<LyXFont::FONT_SIZE> size_;
|
||||
///
|
||||
std::vector<character::FONT_STATE> bar_;
|
||||
std::vector<frnt::FONT_STATE> bar_;
|
||||
///
|
||||
std::vector<LColor::color> color_;
|
||||
///
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "vspace.h"
|
||||
#include "bmtable.h"
|
||||
#include "language.h"
|
||||
#include "frnt_lang.h"
|
||||
#include "LyXView.h"
|
||||
#include "lyxfunc.h"
|
||||
#include "lyxrc.h"
|
||||
@ -241,6 +242,10 @@ void FormDocument::build()
|
||||
"default|auto|latin1|latin2|latin3|latin4|latin5|latin9"
|
||||
"|koi8-r|koi8-u|cp866|cp1251|iso88595");
|
||||
|
||||
vector<frnt::LanguagePair> const langs = frnt::getLanguageData();
|
||||
// Store the identifiers for later
|
||||
lang_ = getSecond(langs);
|
||||
|
||||
// The language is a combo-box and has to be inserted manually
|
||||
obj = language_->choice_language;
|
||||
fl_deactivate_object(obj);
|
||||
@ -252,10 +257,12 @@ void FormDocument::build()
|
||||
combo_language->setcallback(ComboInputCB, this);
|
||||
fl_end_form();
|
||||
|
||||
for (Languages::const_iterator cit = languages.begin();
|
||||
cit != languages.end(); ++cit) {
|
||||
combo_language->addto(cit->second.lang());
|
||||
vector<frnt::LanguagePair>::const_iterator lit = langs.begin();
|
||||
vector<frnt::LanguagePair>::const_iterator lend = langs.end();
|
||||
for (; lit != lend; ++lit) {
|
||||
combo_language->addto(_(lit->first));
|
||||
}
|
||||
combo_language->select(1);
|
||||
|
||||
fl_addto_choice(language_->choice_quotes_language,
|
||||
_(" ``text'' | ''text'' | ,,text`` | ,,text'' |"
|
||||
@ -887,9 +894,9 @@ bool FormDocument::language_apply(BufferParams & params)
|
||||
else
|
||||
params.quotes_times = InsetQuotes::DoubleQ;
|
||||
|
||||
int const pos = combo_language->get();
|
||||
Language const * old_language = params.language;
|
||||
Language const * new_language =
|
||||
languages.getLanguage(combo_language->getline());
|
||||
Language const * new_language = languages.getLanguage(lang_[pos-1]);
|
||||
if (!new_language)
|
||||
new_language = default_language;
|
||||
|
||||
@ -1083,12 +1090,29 @@ void FormDocument::class_update(BufferParams const & params)
|
||||
}
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
template<class A>
|
||||
typename vector<A>::size_type findPos(vector<A> const & vec, A const & val)
|
||||
{
|
||||
typename vector<A>::const_iterator it =
|
||||
std::find(vec.begin(), vec.end(), val);
|
||||
if (it == vec.end())
|
||||
return 0;
|
||||
return it - vec.begin();
|
||||
}
|
||||
|
||||
} // namespace anon
|
||||
|
||||
|
||||
void FormDocument::language_update(BufferParams const & params)
|
||||
{
|
||||
if (!language_.get())
|
||||
return;
|
||||
|
||||
combo_language->select(params.language->lang());
|
||||
int const pos = int(findPos(lang_, params.language->lang()));
|
||||
combo_language->select(pos+1);
|
||||
|
||||
fl_set_choice_text(language_->choice_inputenc, params.inputenc.c_str());
|
||||
fl_set_choice(language_->choice_quotes_language, params.quotes_language + 1);
|
||||
fl_set_button(language_->radio_single, 0);
|
||||
|
@ -185,6 +185,8 @@ private:
|
||||
boost::scoped_ptr<Combox> combo_doc_class;
|
||||
/// The ButtonController
|
||||
ButtonController<NoRepeatedApplyReadOnlyPolicy, xformsBC> bc_;
|
||||
///
|
||||
std::vector<string> lang_;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user