#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
#undef OFF
#endif
+
class LyXLex;
///
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;
+
+ ///
+ bool isRightToLeft() const;
///
- LyXDirection getFontDirection() 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 */
to this font. Returns number of chars written. Base is the
font state active now.
*/
- int latexWriteStartChanges(string &, LyXFont const & base,
+ 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.
*/
- int latexWriteEndChanges(string &, LyXFont const & base,
+ int latexWriteEndChanges(ostream &, LyXFont const & base,
LyXFont const & next) const;
-
+
/// Build GUI description of font state
string stateText() const;
///
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;
ostream & operator<<(ostream &, LyXFont::FONT_MISC_STATE);
-inline LyXFont::LyXFont()
+inline
+LyXFont::LyXFont()
{
bits = sane;
+ lang = default_language;
}
-inline LyXFont::LyXFont(LyXFont const & x)
+inline
+LyXFont::LyXFont(LyXFont const & x)
{
bits = x.bits;
+ lang = x.lang;
}
-inline LyXFont::LyXFont(LyXFont::FONT_INIT1)
+inline
+LyXFont::LyXFont(LyXFont::FONT_INIT1)
{
bits = inherit;
+ lang = default_language;
}
-inline LyXFont::LyXFont(LyXFont::FONT_INIT2)
+inline
+LyXFont::LyXFont(LyXFont::FONT_INIT2)
{
bits = ignore;
+ lang = ignore_language;
}
-inline LyXFont::LyXFont(LyXFont::FONT_INIT3)
+inline
+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::operator=(LyXFont const & x)
+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 bits.direction;
+ return lang;
}
+
+inline
+bool LyXFont::isRightToLeft() const
+{
+ return lang->RightToLeft;
+}
+
+
+inline
+bool LyXFont::isVisibleRightToLeft() const
+{
+ 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;
}