⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wg__renderedstring_8cpp-source.html

📁 一个小巧的嵌入式图形系统wGUI, 可以用VC编译
💻 HTML
📖 第 1 页 / 共 2 页
字号:
00105 <a name="l00106"></a><a class="code" href="classwGui_1_1CRenderedString.html#a2">00106</a> <span class="keywordtype">void</span> CRenderedString::GetMetrics(<a class="code" href="classwGui_1_1CPoint.html">CPoint</a>* pBoundedDimensions, <a class="code" href="classwGui_1_1CPoint.html">CPoint</a>* pOriginOffset, std::vector&lt;CRect&gt;* pCharacterRects)<span class="keyword"> const</span>00107 <span class="keyword"></span>{00108      <span class="keywordflow">if</span> (! m_bCachedMetricsValid)00109      {00110           m_CachedCharacterRects.clear();00111 00112           <span class="keywordtype">int</span> iMinY = 0;00113           <span class="keywordtype">int</span> iMaxY = 0;00114           <span class="keywordtype">int</span> iLength = 0;00115           <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i = 0; i &lt; <a class="code" href="classwGui_1_1CRenderedString.html#n1">m_sString</a>.size(); ++i)00116           {00117                FT_Glyph_Metrics* pMetrics;00118                <span class="keywordflow">if</span> (<a class="code" href="classwGui_1_1CRenderedString.html#n2">m_MaskChar</a> == <span class="charliteral">' '</span>)00119                {00120                     pMetrics = <a class="code" href="classwGui_1_1CRenderedString.html#n0">m_pFontEngine</a>-&gt;<a class="code" href="classwGui_1_1CFontEngine.html#a3">GetMetrics</a>(<a class="code" href="classwGui_1_1CRenderedString.html#n1">m_sString</a>[i]);00121                }00122                <span class="keywordflow">else</span>00123                {00124                     pMetrics = <a class="code" href="classwGui_1_1CRenderedString.html#n0">m_pFontEngine</a>-&gt;<a class="code" href="classwGui_1_1CFontEngine.html#a3">GetMetrics</a>(<a class="code" href="classwGui_1_1CRenderedString.html#n2">m_MaskChar</a>);00125                }00126 00127                <span class="comment">//FT_Glyph_Metrics* pMetrics = m_pFontEngine-&gt;GetMetrics(m_sString[i]);</span>00128                <span class="keywordflow">if</span> ((pMetrics-&gt;horiBearingY - pMetrics-&gt;height) &lt; iMinY)00129                {00130                     iMinY = pMetrics-&gt;horiBearingY - pMetrics-&gt;height;00131                }00132                <span class="keywordflow">if</span> (pMetrics-&gt;horiBearingY &gt; iMaxY)00133                {00134                     iMaxY = pMetrics-&gt;horiBearingY;00135                }00136                iLength += (pMetrics-&gt;horiAdvance);00137                <span class="comment">// The top and bottom values of the rect are not actually in rect coordinates at this point, since iMaxY and iMinY are not yet know</span>00138                m_CachedCharacterRects.push_back(00139                     <a class="code" href="classwGui_1_1CRect.html">CRect</a>((iLength - pMetrics-&gt;horiAdvance) &gt;&gt; 6, pMetrics-&gt;horiBearingY &gt;&gt; 6, iLength &gt;&gt; 6, pMetrics-&gt;height &gt;&gt; 6));00140           }00141 00142           iMinY = iMinY &gt;&gt; 6;00143           iMaxY = iMaxY &gt;&gt; 6;00144           iLength = iLength &gt;&gt; 6;00145 00146           <span class="comment">// now fix the top and bottom values of the rects</span>00147           <span class="keywordflow">for</span>(std::vector&lt;CRect&gt;::iterator iter = m_CachedCharacterRects.begin(); iter != m_CachedCharacterRects.end(); ++iter)00148           {00149                iter-&gt;SetTop(iMaxY - iter-&gt;Top());00150                iter-&gt;SetBottom(iter-&gt;Top() + iter-&gt;Bottom());00151           }00152 00153           <span class="comment">// Tack an empty rect on the end</span>00154           m_CachedCharacterRects.push_back(<a class="code" href="classwGui_1_1CRect.html">CRect</a>(iLength, iMaxY, iLength, iMinY));00155 00156           m_CachedBoundedDimensions = <a class="code" href="classwGui_1_1CPoint.html">CPoint</a>(iLength, iMaxY - iMinY);00157 00158           <span class="keywordflow">switch</span> (m_eHorzAlign)00159           {00160           <span class="keywordflow">case</span> <a class="code" href="classwGui_1_1CRenderedString.html#s8s5">HALIGN_CENTER</a>:00161                m_OriginOffset.<a class="code" href="classwGui_1_1CPoint.html#a4">SetX</a>(-iLength / 2);00162                <span class="keywordflow">break</span>;00163           <span class="keywordflow">case</span> <a class="code" href="classwGui_1_1CRenderedString.html#s8s6">HALIGN_RIGHT</a>:00164                m_OriginOffset.<a class="code" href="classwGui_1_1CPoint.html#a4">SetX</a>(-iLength);00165                <span class="keywordflow">break</span>;00166           <span class="keywordflow">case</span> <a class="code" href="classwGui_1_1CRenderedString.html#s8s4">HALIGN_LEFT</a>:00167           <span class="keywordflow">default</span>:00168                m_OriginOffset.<a class="code" href="classwGui_1_1CPoint.html#a4">SetX</a>(0);00169                <span class="keywordflow">break</span>;00170           }00171 00172           <span class="keywordflow">switch</span> (m_eVertAlign)00173           {00174           <span class="keywordflow">case</span> <a class="code" href="classwGui_1_1CRenderedString.html#s7s2">VALIGN_TOP</a>:00175                m_OriginOffset.<a class="code" href="classwGui_1_1CPoint.html#a5">SetY</a>(0);00176                <span class="keywordflow">break</span>;00177           <span class="keywordflow">case</span> <a class="code" href="classwGui_1_1CRenderedString.html#s7s3">VALIGN_BOTTOM</a>:00178                m_OriginOffset.<a class="code" href="classwGui_1_1CPoint.html#a5">SetY</a>(iMinY - iMaxY);00179                <span class="keywordflow">break</span>;00180           <span class="keywordflow">case</span> <a class="code" href="classwGui_1_1CRenderedString.html#s7s1">VALIGN_CENTER</a>:00181                m_OriginOffset.<a class="code" href="classwGui_1_1CPoint.html#a5">SetY</a>((iMinY - iMaxY) / 2);00182                <span class="keywordflow">break</span>;00183           <span class="keywordflow">case</span> <a class="code" href="classwGui_1_1CRenderedString.html#s7s0">VALIGN_NORMAL</a>:00184           <span class="keywordflow">default</span>:00185                m_OriginOffset.<a class="code" href="classwGui_1_1CPoint.html#a5">SetY</a>(-iMaxY);00186                <span class="keywordflow">break</span>;00187           }00188 00189           m_bCachedMetricsValid = <span class="keyword">true</span>;00190      }00191 00192      <span class="keywordflow">if</span> (pBoundedDimensions)00193      {00194           *pBoundedDimensions = m_CachedBoundedDimensions;00195      }00196 00197      <span class="keywordflow">if</span> (pOriginOffset)00198      {00199           *pOriginOffset = m_OriginOffset;00200      }00201 00202      <span class="keywordflow">if</span> (pCharacterRects)00203      {00204           *pCharacterRects = m_CachedCharacterRects;00205      }00206 }00207 00208 }</pre></div><hr><address style="align: right;"><small>Generated on Sat Oct 25 12:43:24 2003 for wGui by<a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border=0 width=110 height=53></a>1.2.18 </small></address></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -