// Copyright (C) 2000-2007, Luca Padovani . // // This file is part of GtkMathView, a flexible, high-quality rendering // engine for MathML documents. // // GtkMathView is free software; you can redistribute it and/or modify it // under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // GtkMathView is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this program. If not, see . #ifndef __FormattingContext_hh__ #define __FormattingContext_hh__ #include "scaled.hh" #include "Variant.hh" #include "RGBColor.hh" #include "Length.hh" // full path needed for Win32 #include "../../common/mathvariants/MathVariant.hh" #include "FastScopedHashMap.hh" #include "MathGraphicDevice.hh" class GMV_MathView_EXPORT FormattingContext { public: #if GMV_ENABLE_BOXML FormattingContext(const SmartPtr&, const SmartPtr&); #else FormattingContext(const SmartPtr&); #endif ~FormattingContext(); enum PropertyId { MATH_MODE, SIZE, ACTUAL_SIZE, VARIANT, COLOR, BACKGROUND_COLOR, SCRIPT_LEVEL, MIN_SIZE, DISPLAY_STYLE, SIZE_MULT, MATHML_ELEMENT, #if GMV_ENABLE_BOXML BOXML_ELEMENT, #endif AVAILABLE_WIDTH, STRETCH_OP, STRETCH_TO_WIDTH, STRETCH_TO_HEIGHT, STRETCH_TO_DEPTH, STRETCH_HORIZ, STRETCH_VERT, NEGATIVE_VERYVERYTHICK_SPACE, NEGATIVE_VERYTHICK_SPACE, NEGATIVE_THICK_SPACE, NEGATIVE_MEDIUM_SPACE, NEGATIVE_THIN_SPACE, NEGATIVE_VERYTHIN_SPACE, NEGATIVE_VERYVERYTHIN_SPACE, ZERO_SPACE, VERYVERYTHIN_SPACE, VERYTHIN_SPACE, THIN_SPACE, MEDIUM_SPACE, THICK_SPACE, VERYTHICK_SPACE, VERYVERYTHICK_SPACE, LAST_NAMED_PROPERTY_ENTRY }; bool getMathMode(void) const { return get(MATH_MODE); } void setMathMode(bool m) { set(MATH_MODE, m); } scaled getSize(void) const { return get(SIZE); } void setSize(const scaled& s) { set(SIZE, s); } scaled getActualSize(void) const { return get(ACTUAL_SIZE); } void setActualSize(const scaled& s) { set(ACTUAL_SIZE, s); } MathVariant getVariant(void) const { return get(VARIANT); } void setVariant(MathVariant v) { set(VARIANT, v); } RGBColor getColor(void) const { return get(COLOR); } void setColor(const RGBColor& c) { set(COLOR, c); } RGBColor getBackground(void) const { return get(BACKGROUND_COLOR); } void setBackground(const RGBColor& c) { set(BACKGROUND_COLOR, c); } int getScriptLevel(void) const { return get(SCRIPT_LEVEL); } void setScriptLevel(int l) { addScriptLevel(l - getScriptLevel()); } void addScriptLevel(int); scaled getMinSize(void) const { return get(MIN_SIZE); } void setMinSize(scaled s) { set(MIN_SIZE, s); } bool getDisplayStyle(void) const { return get(DISPLAY_STYLE); } void setDisplayStyle(bool b) { set(DISPLAY_STYLE, b); } double getSizeMultiplier(void) const { return get(SIZE_MULT); } void setSizeMultiplier(double f) { set(SIZE_MULT, f); } Length getMathSpace(int i) const { return get(i); } void setMathSpace(int i, const Length& l) { set(i, l); } scaled getAvailableWidth(void) const { return get(AVAILABLE_WIDTH); } void setAvailableWidth(const scaled& w) { set(AVAILABLE_WIDTH, w); } SmartPtr getStretchOperator(void) const; void setStretchOperator(const SmartPtr&); scaled getStretchToWidth(void) const { return get(STRETCH_TO_WIDTH); } void setStretchToWidth(const scaled& w) { set(STRETCH_TO_WIDTH, w); } scaled getStretchToHeight(void) const { return get(STRETCH_TO_HEIGHT); } void setStretchToHeight(const scaled& h) { set(STRETCH_TO_HEIGHT, h); } scaled getStretchToDepth(void) const { return get(STRETCH_TO_DEPTH); } void setStretchToDepth(const scaled& d) { set(STRETCH_TO_DEPTH, d); } scaled getStretchH(void) const { return get(STRETCH_HORIZ); } void setStretchH(const scaled& h) { set(STRETCH_HORIZ, h); } scaled getStretchV(void) const { return get(STRETCH_VERT); } void setStretchV(const scaled& v) { set(STRETCH_VERT, v); } void push(const SmartPtr&); SmartPtr getMathMLElement(void) const; SmartPtr MGD(void) const; #if GMV_ENABLE_BOXML void push(const SmartPtr&); SmartPtr getBoxMLElement(void) const; SmartPtr BGD(void) const; #endif // GMV_ENABLE_BOXML protected: template void set(int id, const T& v) { map.set(id, Variant::create(v)); } template T get(int id) const { return as(map.get(id)); } public: void push(void) { map.push(); } void pop() { map.pop(); } private: SmartPtr mathGraphicDevice; #if GMV_ENABLE_BOXML SmartPtr boxGraphicDevice; #endif // GMV_ENABLE_BOXML FastScopedHashMap > map; }; #endif // __FormattingContext_hh__