Back to index

lightning-sunbird  0.9+nobinonly
nsMathMLmfracFrame.h
Go to the documentation of this file.
00001 /* ***** BEGIN LICENSE BLOCK *****
00002  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00003  *
00004  * The contents of this file are subject to the Mozilla Public License Version
00005  * 1.1 (the "License"); you may not use this file except in compliance with
00006  * the License. You may obtain a copy of the License at
00007  * http://www.mozilla.org/MPL/
00008  *
00009  * Software distributed under the License is distributed on an "AS IS" basis,
00010  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00011  * for the specific language governing rights and limitations under the
00012  * License.
00013  *
00014  * The Original Code is Mozilla MathML Project.
00015  *
00016  * The Initial Developer of the Original Code is
00017  * The University Of Queensland.
00018  * Portions created by the Initial Developer are Copyright (C) 1999
00019  * the Initial Developer. All Rights Reserved.
00020  *
00021  * Contributor(s):
00022  *   Roger B. Sidje <rbs@maths.uq.edu.au>
00023  *   David J. Fiddes <D.J.Fiddes@hw.ac.uk>
00024  *   Shyjan Mahamud <mahamud@cs.cmu.edu>
00025  *
00026  * Alternatively, the contents of this file may be used under the terms of
00027  * either of the GNU General Public License Version 2 or later (the "GPL"),
00028  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00029  * in which case the provisions of the GPL or the LGPL are applicable instead
00030  * of those above. If you wish to allow use of your version of this file only
00031  * under the terms of either the GPL or the LGPL, and not to allow others to
00032  * use your version of this file under the terms of the MPL, indicate your
00033  * decision by deleting the provisions above and replace them with the notice
00034  * and other provisions required by the GPL or the LGPL. If you do not delete
00035  * the provisions above, a recipient may use your version of this file under
00036  * the terms of any one of the MPL, the GPL or the LGPL.
00037  *
00038  * ***** END LICENSE BLOCK ***** */
00039 
00040 #ifndef nsMathMLmfracFrame_h___
00041 #define nsMathMLmfracFrame_h___
00042 
00043 #include "nsCOMPtr.h"
00044 #include "nsMathMLContainerFrame.h"
00045 
00046 //
00047 // <mfrac> -- form a fraction from two subexpressions 
00048 //
00049 
00050 /*
00051 The MathML REC describes:
00052 
00053 The <mfrac> element is used for fractions. It can also be used to mark up 
00054 fraction-like objects such as binomial coefficients and Legendre symbols. 
00055 The syntax for <mfrac> is:
00056   <mfrac> numerator denominator </mfrac>
00057 
00058 Attributes of <mfrac>:
00059      Name                      values                     default 
00060   linethickness  number [ v-unit ] | thin | medium | thick  1 
00061 
00062 E.g., 
00063 linethickness=2 actually means that linethickness=2*DEFAULT_THICKNESS
00064 (DEFAULT_THICKNESS is not specified by MathML, see below.)
00065 
00066 The linethickness attribute indicates the thickness of the horizontal
00067 "fraction bar", or "rule", typically used to render fractions. A fraction
00068 with linethickness="0" renders without the bar, and might be used within
00069 binomial coefficients. A linethickness greater than one might be used with
00070 nested fractions. 
00071 
00072 In general, the value of linethickness can be a number, as a multiplier
00073 of the default thickness of the fraction bar (the default thickness is
00074 not specified by MathML), or a number with a unit of vertical length (see
00075 Section 2.3.3), or one of the keywords medium (same as 1), thin (thinner
00076 than 1, otherwise up to the renderer), or thick (thicker than 1, otherwise
00077 up to the renderer). 
00078 
00079 The <mfrac> element sets displaystyle to "false", or if it was already
00080 false increments scriptlevel by 1, within numerator and denominator.
00081 These attributes are inherited by every element from its rendering 
00082 environment, but can be set explicitly only on the <mstyle> 
00083 element. 
00084 */
00085 
00086 class nsMathMLmfracFrame : public nsMathMLContainerFrame {
00087 public:
00088   friend nsresult NS_NewMathMLmfracFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame);
00089 
00090   virtual void
00091   SetAdditionalStyleContext(PRInt32          aIndex, 
00092                             nsStyleContext*  aStyleContext);
00093   virtual nsStyleContext*
00094   GetAdditionalStyleContext(PRInt32 aIndex) const;
00095 
00096   virtual eMathMLFrameType GetMathMLFrameType();
00097 
00098   NS_IMETHOD
00099   AttributeChanged(nsIContent*     aChild,
00100                    PRInt32         aNameSpaceID,
00101                    nsIAtom*        aAttribute,
00102                    PRInt32         aModType);
00103 
00104   NS_IMETHOD
00105   Init(nsPresContext*  aPresContext,
00106        nsIContent*      aContent,
00107        nsIFrame*        aParent,
00108        nsStyleContext*  aContext,
00109        nsIFrame*        aPrevInFlow);
00110 
00111   NS_IMETHOD
00112   Reflow(nsPresContext*          aPresContext,
00113          nsHTMLReflowMetrics&     aDesiredSize,
00114          const nsHTMLReflowState& aReflowState,
00115          nsReflowStatus&          aStatus);
00116 
00117   NS_IMETHOD
00118   Place(nsIRenderingContext& aRenderingContext,
00119         PRBool               aPlaceOrigin,
00120         nsHTMLReflowMetrics& aDesiredSize);
00121 
00122   NS_IMETHOD 
00123   Paint(nsPresContext*      aPresContext,
00124         nsIRenderingContext& aRenderingContext,
00125         const nsRect&        aDirtyRect,
00126         nsFramePaintLayer    aWhichLayer,
00127         PRUint32             aFlags = 0);
00128 
00129   NS_IMETHOD
00130   TransmitAutomaticData();
00131 
00132   NS_IMETHOD
00133   UpdatePresentationData(PRInt32         aScriptLevelIncrement,
00134                          PRUint32        aFlagsValues,
00135                          PRUint32        aFlagsToUpdate);
00136 
00137   NS_IMETHOD
00138   UpdatePresentationDataFromChildAt(PRInt32         aFirstIndex,
00139                                     PRInt32         aLastIndex,
00140                                     PRInt32         aScriptLevelIncrement,
00141                                     PRUint32        aFlagsValues,
00142                                     PRUint32        aFlagsToUpdate);
00143 
00144   // override the base method so that we can deal with the fraction line
00145   virtual nscoord
00146   FixInterFrameSpacing(nsHTMLReflowMetrics& aDesiredSize);
00147 
00148   // helper to translate the thickness attribute into a usable form
00149   static nscoord 
00150   CalcLineThickness(nsPresContext*  aPresContext,
00151                     nsStyleContext*  aStyleContext,
00152                     nsString&        aThicknessAttribute,
00153                     nscoord          onePixel,
00154                     nscoord          aDefaultRuleThickness);
00155 
00156 protected:
00157   nsMathMLmfracFrame();
00158   virtual ~nsMathMLmfracFrame();
00159   
00160   virtual PRIntn GetSkipSides() const { return 0; }
00161 
00162   PRBool
00163   IsBevelled();
00164 
00165   PRInt32 mInnerScriptLevel;
00166   nsRect  mLineRect;
00167   nsMathMLChar* mSlashChar;
00168 };
00169 
00170 #endif /* nsMathMLmfracFrame_h___ */