#include FORMS_H_LOCATION
#include "LString.h"
#include "debug.h"
-#include "direction.h"
+#include "language.h"
#include "LColor.h"
// It might happen that locale.h defines ON and OFF. This is not good
IGNORE_SIZE
};
- enum FONT_DIRECTION {
- ///
- LTR_DIR,
- ///
- RTL_DIR,
- ///
- TOGGLE_DIR,
- ///
- INHERIT_DIR,
- ///
- IGNORE_DIR
- };
-
/// Used for emph, underbar, noun and latex toggles
enum FONT_MISC_STATE {
///
LyXFont(LyXFont::FONT_INIT2);
/// Shortcut initialization
LyXFont(LyXFont::FONT_INIT3);
+ /// Shortcut initialization
+ LyXFont(LyXFont::FONT_INIT1, Language const * l);
+ /// Shortcut initialization
+ LyXFont(LyXFont::FONT_INIT2, Language const * l);
+ /// Shortcut initialization
+ LyXFont(LyXFont::FONT_INIT3, Language const * l);
/// LyXFont x, y; x = y;
LyXFont & operator=(LyXFont const & x);
LColor::color color() const;
///
- FONT_DIRECTION direction() const;
+ Language const * language() const;
///
- LyXDirection getFontDirection() const;
+ bool isRightToLeft() const;
+
+ ///
+ bool isVisibleRightToLeft() const;
///
LyXFont & setFamily(LyXFont::FONT_FAMILY f);
///
LyXFont & setColor(LColor::color c);
///
- LyXFont & setDirection(LyXFont::FONT_DIRECTION d);
+ LyXFont & setLanguage(Language const * l);
/// Set family after LyX text format
LyXFont & setLyXFamily(string const &);
* a INHERIT_FAMILY was asked for. This is necessary for the
* toggle-user-defined-style button on the toolbar.
*/
- void update(LyXFont const & newfont, bool toggleall = false);
+ void update(LyXFont const & newfont,
+ Language const * default_lang,
+ bool toggleall = false);
/** Reduce font to fall back to template where possible.
Equal fields are reduced to INHERIT */
/// Writes the changes from this font to orgfont in .lyx format in file
void lyxWriteChanges(LyXFont const & orgfont, ostream &) const;
-
/** Writes the head of the LaTeX needed to change to this font.
Writes to string, the head of the LaTeX needed to change
to this font. Returns number of chars written. Base is the
*/
int latexWriteStartChanges(ostream &, LyXFont const & base,
LyXFont const & prev) const;
+
/** Writes tha tail of the LaTeX needed to chagne to this font.
Returns number of chars written. Base is the font state we want
to achieve.
///
friend inline
bool operator==(LyXFont const & font1, LyXFont const & font2) {
- return font1.bits == font2.bits;
+ return font1.bits == font2.bits &&
+ font1.lang == font2.lang;
}
///
friend inline
bool operator!=(LyXFont const & font1, LyXFont const & font2) {
- return font1.bits != font2.bits;
+ return font1.bits != font2.bits ||
+ font1.lang != font2.lang;
}
/// compares two fonts, ignoring the setting of the Latex part.
fb1.emph == emph &&
fb1.underbar == underbar &&
fb1.noun == noun &&
- fb1.latex == latex &&
- fb1.direction == direction;
+ fb1.latex == latex;
}
bool operator!=(FontBits const & fb1) const {
return !(fb1 == *this);
FONT_MISC_STATE underbar;
FONT_MISC_STATE noun;
FONT_MISC_STATE latex;
- FONT_DIRECTION direction;
};
FontBits bits;
+ Language const * lang;
/// Sane font
static FontBits sane;
LyXFont::LyXFont()
{
bits = sane;
+ lang = default_language;
}
LyXFont::LyXFont(LyXFont const & x)
{
bits = x.bits;
+ lang = x.lang;
}
LyXFont::LyXFont(LyXFont::FONT_INIT1)
{
bits = inherit;
+ lang = default_language;
}
LyXFont::LyXFont(LyXFont::FONT_INIT2)
{
bits = ignore;
+ lang = ignore_language;
}
LyXFont::LyXFont(LyXFont::FONT_INIT3)
{
bits = sane;
+ lang = default_language;
+}
+inline
+LyXFont::LyXFont(LyXFont::FONT_INIT1, Language const * l)
+{
+ bits = inherit;
+ lang = l;
+}
+
+
+inline
+LyXFont::LyXFont(LyXFont::FONT_INIT2, Language const * l)
+{
+ bits = ignore;
+ lang = l;
}
+inline
+LyXFont::LyXFont(LyXFont::FONT_INIT3, Language const * l)
+{
+ bits = sane;
+ lang = l;
+}
+
inline
LyXFont & LyXFont::operator=(LyXFont const & x)
{
bits = x.bits;
+ lang = x.lang;
return *this;
}
inline
-LyXFont::FONT_DIRECTION LyXFont::direction() const
+Language const * LyXFont::language() const
+{
+ return lang;
+}
+
+
+inline
+bool LyXFont::isRightToLeft() const
+{
+ return lang->RightToLeft;
+}
+
+
+inline
+bool LyXFont::isVisibleRightToLeft() const
{
- return bits.direction;
+ return (lang->RightToLeft && latex() != ON);
}
+
inline
LyXFont & LyXFont::setFamily(LyXFont::FONT_FAMILY f)
{
inline
-LyXFont & LyXFont::setDirection(LyXFont::FONT_DIRECTION d)
+LyXFont & LyXFont::setLanguage(Language const * l)
{
- bits.direction = d;
+ lang = l;
return *this;
}