📄 qwt__mathml__text__engine_8cpp-source.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>Qwt User's Guide: qwt_mathml_text_engine.cpp Source File</title><link href="doxygen.css" rel="stylesheet" type="text/css"><link href="tabs.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.4.6 --><div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="classes.html"><span>Classes</span></a></li> <li id="current"><a href="files.html"><span>Files</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> </ul></div><h1>qwt_mathml_text_engine.cpp</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************</span><a name="l00002"></a>00002 <span class="comment"> * Qwt Widget Library</span><a name="l00003"></a>00003 <span class="comment"> * Copyright (C) 1997 Josef Wilgen</span><a name="l00004"></a>00004 <span class="comment"> * Copyright (C) 2003 Uwe Rathmann</span><a name="l00005"></a>00005 <span class="comment"> *</span><a name="l00006"></a>00006 <span class="comment"> * This library is free software; you can redistribute it and/or</span><a name="l00007"></a>00007 <span class="comment"> * modify it under the terms of the Qwt License, Version 1.0</span><a name="l00008"></a>00008 <span class="comment"> *****************************************************************************/</span><a name="l00009"></a>00009 <a name="l00010"></a>00010 <span class="comment">// vim: expandtab</span><a name="l00011"></a>00011 <a name="l00012"></a>00012 <span class="preprocessor">#include <qglobal.h></span><a name="l00013"></a>00013 <span class="preprocessor">#if QT_VERSION >= 0x040000</span><a name="l00014"></a>00014 <span class="preprocessor"></span><a name="l00015"></a>00015 <span class="preprocessor">#include <qstring.h></span><a name="l00016"></a>00016 <span class="preprocessor">#include <qpainter.h></span><a name="l00017"></a>00017 <span class="preprocessor">#include "qwt_mathml_text_engine.h"</span><a name="l00018"></a>00018 <a name="l00019"></a>00019 <span class="preprocessor">#include <qtmmlwidget.h></span><a name="l00020"></a>00020 <a name="l00022"></a><a class="code" href="class_qwt_math_m_l_text_engine.html#f88b085974808e0497d120044672f721">00022</a> <a class="code" href="class_qwt_math_m_l_text_engine.html#f88b085974808e0497d120044672f721">QwtMathMLTextEngine::QwtMathMLTextEngine</a>()<a name="l00023"></a>00023 {<a name="l00024"></a>00024 }<a name="l00025"></a>00025 <a name="l00027"></a><a class="code" href="class_qwt_math_m_l_text_engine.html#864d4265a7621e7389b21d419e6503ff">00027</a> <a class="code" href="class_qwt_math_m_l_text_engine.html#864d4265a7621e7389b21d419e6503ff">QwtMathMLTextEngine::~QwtMathMLTextEngine</a>()<a name="l00028"></a>00028 {<a name="l00029"></a>00029 }<a name="l00030"></a>00030 <a name="l00041"></a><a class="code" href="class_qwt_math_m_l_text_engine.html#2af5e9efb10eee9c28cce50699cdfdab">00041</a> <span class="keywordtype">int</span> <a class="code" href="class_qwt_math_m_l_text_engine.html#2af5e9efb10eee9c28cce50699cdfdab">QwtMathMLTextEngine::heightForWidth</a>(<span class="keyword">const</span> QFont& font, <span class="keywordtype">int</span> flags,<a name="l00042"></a>00042 <span class="keyword">const</span> QString& text, <span class="keywordtype">int</span>)<span class="keyword"> const</span><a name="l00043"></a>00043 <span class="keyword"></span>{<a name="l00044"></a>00044 <span class="keywordflow">return</span> <a class="code" href="class_qwt_math_m_l_text_engine.html#ecb16b442a1ff15418dc31860e11c27b">textSize</a>(font, flags, text).height();<a name="l00045"></a>00045 }<a name="l00046"></a>00046 <a name="l00056"></a><a class="code" href="class_qwt_math_m_l_text_engine.html#ecb16b442a1ff15418dc31860e11c27b">00056</a> QSize <a class="code" href="class_qwt_math_m_l_text_engine.html#ecb16b442a1ff15418dc31860e11c27b">QwtMathMLTextEngine::textSize</a>(<span class="keyword">const</span> QFont &font,<a name="l00057"></a>00057 <span class="keywordtype">int</span>, <span class="keyword">const</span> QString& text)<span class="keyword"> const</span><a name="l00058"></a>00058 <span class="keyword"></span>{<a name="l00059"></a>00059 <span class="keyword">static</span> QString t;<a name="l00060"></a>00060 <span class="keyword">static</span> QSize sz;<a name="l00061"></a>00061 <a name="l00062"></a>00062 <span class="keywordflow">if</span> ( text != t )<a name="l00063"></a>00063 {<a name="l00064"></a>00064 QtMmlDocument doc;<a name="l00065"></a>00065 doc.setContent(text);<a name="l00066"></a>00066 doc.setBaseFontPointSize(font.pointSize());<a name="l00067"></a>00067 <a name="l00068"></a>00068 sz = doc.size();<a name="l00069"></a>00069 t = text;<a name="l00070"></a>00070 }<a name="l00071"></a>00071 <a name="l00072"></a>00072 <span class="keywordflow">return</span> sz;<a name="l00073"></a>00073 }<a name="l00074"></a>00074 <a name="l00083"></a><a class="code" href="class_qwt_math_m_l_text_engine.html#21ae25c70e4ff79cde60072e4bd75a29">00083</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_math_m_l_text_engine.html#21ae25c70e4ff79cde60072e4bd75a29">QwtMathMLTextEngine::textMargins</a>(<span class="keyword">const</span> QFont &, <span class="keyword">const</span> QString &,<a name="l00084"></a>00084 <span class="keywordtype">int</span> &left, <span class="keywordtype">int</span> &right, <span class="keywordtype">int</span> &top, <span class="keywordtype">int</span> &bottom)<span class="keyword"> const</span><a name="l00085"></a>00085 <span class="keyword"></span>{<a name="l00086"></a>00086 left = right = top = bottom = 0;<a name="l00087"></a>00087 }<a name="l00088"></a>00088 <a name="l00097"></a><a class="code" href="class_qwt_math_m_l_text_engine.html#476c19642bf2c69a1abf0021547a1d7e">00097</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_math_m_l_text_engine.html#476c19642bf2c69a1abf0021547a1d7e">QwtMathMLTextEngine::draw</a>(QPainter *painter, <span class="keyword">const</span> QRect &rect,<a name="l00098"></a>00098 <span class="keywordtype">int</span> flags, <span class="keyword">const</span> QString& text)<span class="keyword"> const</span><a name="l00099"></a>00099 <span class="keyword"></span>{<a name="l00100"></a>00100 QtMmlDocument doc;<a name="l00101"></a>00101 doc.setContent(text);<a name="l00102"></a>00102 doc.setBaseFontPointSize(painter->font().pointSize());<a name="l00103"></a>00103 <a name="l00104"></a>00104 <span class="keyword">const</span> QSize docSize = doc.size();<a name="l00105"></a>00105 <a name="l00106"></a>00106 QPoint pos = rect.topLeft();<a name="l00107"></a>00107 <span class="keywordflow">if</span> ( rect.width() > docSize.width() )<a name="l00108"></a>00108 {<a name="l00109"></a>00109 <span class="keywordflow">if</span> ( flags & Qt::AlignRight )<a name="l00110"></a>00110 pos.setX(rect.right() - docSize.width());<a name="l00111"></a>00111 <span class="keywordflow">if</span> ( flags & Qt::AlignHCenter )<a name="l00112"></a>00112 pos.setX(rect.center().x() - docSize.width() / 2);<a name="l00113"></a>00113 }<a name="l00114"></a>00114 <span class="keywordflow">if</span> ( rect.height() > docSize.height() )<a name="l00115"></a>00115 {<a name="l00116"></a>00116 <span class="keywordflow">if</span> ( flags & Qt::AlignBottom )<a name="l00117"></a>00117 pos.setY(rect.bottom() - docSize.height());<a name="l00118"></a>00118 <span class="keywordflow">if</span> ( flags & Qt::AlignVCenter )<a name="l00119"></a>00119 pos.setY(rect.center().y() - docSize.height() / 2);<a name="l00120"></a>00120 }<a name="l00121"></a>00121 <a name="l00122"></a>00122 doc.paint(painter, pos);<a name="l00123"></a>00123 }<a name="l00124"></a>00124 <a name="l00131"></a><a class="code" href="class_qwt_math_m_l_text_engine.html#59ca5842c32fd12cfd2aeeef5c985600">00131</a> <span class="keywordtype">bool</span> <a class="code" href="class_qwt_math_m_l_text_engine.html#59ca5842c32fd12cfd2aeeef5c985600">QwtMathMLTextEngine::mightRender</a>(<span class="keyword">const</span> QString &text)<span class="keyword"> const</span><a name="l00132"></a>00132 <span class="keyword"></span>{<a name="l00133"></a>00133 <span class="keywordflow">return</span> text.trimmed().startsWith(<span class="stringliteral">"<math"</span>);<a name="l00134"></a>00134 }<a name="l00135"></a>00135 <a name="l00136"></a>00136 <span class="preprocessor">#endif // QT_VERSION < 0x040000</span></pre></div><hr size="1"><address style="align: right;"><small>Generated on Mon Feb 26 21:22:37 2007 for Qwt User's Guide by <a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.6 </small></address></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -