📄 wg__application_8cpp-source.html
字号:
00285 }00286 00287 <a name="l00288"></a><a class="code" href="classwGui_1_1CApplication.html#a13">00288</a> <a class="code" href="classwGui_1_1CFontEngine.html">CFontEngine</a>* CApplication::GetFontEngine(std::string sFontFileName, <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> iFontSize)00289 {00290 <span class="comment">// First search to see if the requested font engine already exists</span>00291 t_FontEngineMap::iterator iterFontEngine = <a class="code" href="classwGui_1_1CApplication.html#n8">m_FontEngines</a>.find(std::make_pair(sFontFileName, iFontSize));00292 <a class="code" href="classwGui_1_1CFontEngine.html">CFontEngine</a>* pFontEngine = 0;00293 00294 <span class="keywordflow">if</span> (iterFontEngine == <a class="code" href="classwGui_1_1CApplication.html#n8">m_FontEngines</a>.end())00295 {00296 <span class="comment">// Requested font engine doesn't exist, so create one and add it to the map</span>00297 <span class="keywordflow">try</span>00298 {00299 <span class="keywordflow">if</span> (sFontFileName.find_first_of(<span class="stringliteral">"\\/"</span>) != std::string::npos)00300 {00301 <span class="comment">// if the Font File name that was passed in includes a path, just check there</span>00302 std::ifstream FileTest(sFontFileName.c_str());00303 <span class="keywordtype">bool</span> bFileExists = FileTest.is_open();00304 FileTest.close();00305 <span class="keywordflow">if</span> (bFileExists)00306 {00307 pFontEngine = <span class="keyword">new</span> <a class="code" href="classwGui_1_1CFontEngine.html">CFontEngine</a>(sFontFileName, iFontSize);00308 }00309 }00310 <span class="keywordflow">else</span>00311 {00312 <span class="comment">// otherwise check the Font Path from the global config</span>00313 std::list<std::string> FontPaths = stdex::DetokenizeString(<a class="code" href="classwGui_1_1CApplication.html#n15">m_GlobalConfig</a>.<a class="code" href="classwGui_1_1CConfigStore.html#a2">GetStringEntry</a>(<span class="stringliteral">"FONTPATH"</span>).second, <span class="stringliteral">";"</span>);00314 <span class="keywordflow">for</span>(std::list<std::string>::iterator iter = FontPaths.begin(); iter != FontPaths.end(); ++iter)00315 {00316 std::string sFullPath = *iter;00317 <span class="keywordflow">if</span> (!iter->empty() && (*iter)[iter->length()] != <span class="charliteral">'\\'</span> && (*iter)[iter->length()] != <span class="charliteral">'/'</span>)00318 {00319 sFullPath += <span class="stringliteral">"/"</span>;00320 }00321 sFullPath += sFontFileName;00322 std::ifstream FileTest(sFullPath.c_str());00323 <span class="keywordtype">bool</span> bFileExists = FileTest.is_open();00324 FileTest.close();00325 <span class="keywordflow">if</span> (bFileExists)00326 {00327 pFontEngine = <span class="keyword">new</span> <a class="code" href="classwGui_1_1CFontEngine.html">CFontEngine</a>(sFullPath, iFontSize);00328 }00329 }00330 }00331 <span class="keywordflow">if</span> (pFontEngine)00332 {00333 <a class="code" href="classwGui_1_1CApplication.html#n8">m_FontEngines</a>.insert(std::make_pair(std::make_pair(sFontFileName, iFontSize), pFontEngine));00334 }00335 }00336 <span class="keywordflow">catch</span> (<a class="code" href="classwGui_1_1Wg__Ex__FreeType.html">Wg_Ex_FreeType</a>& DEBUG_ONLY(e))00337 {00338 <span class="keywordflow">if</span> (!<a class="code" href="classwGui_1_1CApplication.html#n10">m_bHandleExceptionsInternally</a>)00339 {00340 <span class="keywordflow">throw</span>;00341 }00342 Trace(<span class="stringliteral">"CApplication::GetFontEngine - Exception thrown while creating Font Engine : "</span> + e.std_what());00343 }00344 }00345 <span class="keywordflow">else</span>00346 {00347 pFontEngine = iterFontEngine->second;00348 }00349 00350 <span class="keywordflow">return</span> pFontEngine;00351 }00352 00353 <a name="l00354"></a><a class="code" href="classwGui_1_1CApplication.html#a16">00354</a> <span class="keywordtype">void</span> CApplication::EnableResourcePool(<span class="keywordtype">bool</span> bEnable)00355 {00356 <a class="code" href="classwGui_1_1CApplication.html#n11">m_bResourcePoolEnabled</a> = bEnable;00357 <span class="keywordflow">if</span> (bEnable == <span class="keyword">false</span>)00358 {00359 <a class="code" href="classwGui_1_1CApplication.html#n12">m_ResourceHandlePool</a>.clear();00360 }00361 }00362 00363 <a name="l00364"></a><a class="code" href="classwGui_1_1CApplication.html#a17">00364</a> <span class="keywordtype">bool</span> CApplication::AddToResourcePool(<a class="code" href="classwGui_1_1CResourceHandle.html">CResourceHandle</a>& ResourceHandle)00365 {00366 <span class="keywordtype">bool</span> bSuccess = <span class="keyword">false</span>;00367 00368 <span class="keywordflow">if</span> (m_bResourcePoolEnabled)00369 {00370 <a class="code" href="classwGui_1_1CApplication.html#n12">m_ResourceHandlePool</a>.push_back(ResourceHandle);00371 }00372 00373 <span class="keywordflow">return</span> bSuccess;00374 }00375 00376 <a name="l00377"></a><a class="code" href="classwGui_1_1CApplication.html#a18">00377</a> <span class="keywordtype">void</span> CApplication::SetMouseCursor(<a class="code" href="classwGui_1_1CCursorResourceHandle.html">CCursorResourceHandle</a>* pCursorResourceHandle)00378 {00379 <span class="comment">// The auto pointer is used to make sure that the cursor handle is valid until we're done using the cursor</span>00380 <span class="keywordflow">if</span> (pCursorResourceHandle && pCursorResourceHandle != <a class="code" href="classwGui_1_1CApplication.html#n13">m_pCurrentCursorResourceHandle</a>.get())00381 {00382 std::auto_ptr<CCursorResourceHandle> pNewCursorResourceHandle(<span class="keyword">new</span> <a class="code" href="classwGui_1_1CCursorResourceHandle.html">CCursorResourceHandle</a>(*pCursorResourceHandle));00383 <a class="code" href="classwGui_1_1CApplication.html#n13">m_pCurrentCursorResourceHandle</a> = pNewCursorResourceHandle;00384 SDL_SetCursor(<a class="code" href="classwGui_1_1CApplication.html#n13">m_pCurrentCursorResourceHandle</a>->Cursor());00385 }00386 <span class="keywordflow">else</span>00387 {00388 <span class="keywordflow">if</span>( <a class="code" href="classwGui_1_1CApplication.html#n13">m_pCurrentCursorResourceHandle</a>.get() )00389 {00390 <span class="preprocessor"> #ifdef MSVC6 // VC6's auto pointers are really broken</span>00391 <span class="preprocessor"></span> <span class="keyword">delete</span> <a class="code" href="classwGui_1_1CApplication.html#n13">m_pCurrentCursorResourceHandle</a>.release();00392 <a class="code" href="classwGui_1_1CApplication.html#n13">m_pCurrentCursorResourceHandle</a> = std::auto_ptr<CCursorResourceHandle>(0);00393 <span class="preprocessor"> #else</span>00394 <span class="preprocessor"></span> <a class="code" href="classwGui_1_1CApplication.html#n13">m_pCurrentCursorResourceHandle</a>.reset(0);00395 <span class="preprocessor"> #endif // MSVC6</span>00396 <span class="preprocessor"></span> SDL_SetCursor(<a class="code" href="classwGui_1_1CApplication.html#n14">m_pSystemDefaultCursor</a>);00397 }00398 }00399 }00400 00401 <a name="l00402"></a><a class="code" href="classwGui_1_1CApplication.html#a20">00402</a> <span class="keywordtype">bool</span> CApplication::HandleMessage(<a class="code" href="classwGui_1_1CMessage.html">CMessage</a>* pMessage)00403 {00404 <span class="keywordtype">bool</span> bHandled = <span class="keyword">false</span>;00405 00406 <span class="keywordflow">if</span> (pMessage)00407 {00408 <span class="keywordflow">switch</span> (pMessage-><a class="code" href="classwGui_1_1CMessage.html#a2">MessageType</a>())00409 {00410 <span class="keywordflow">case</span> CMessage::APP_EXIT :00411 <a class="code" href="classwGui_1_1CApplication.html#a12">ApplicationExit</a>();00412 bHandled = <span class="keyword">true</span>;00413 <span class="keywordflow">break</span>;00414 <span class="keywordflow">default</span>:00415 <span class="keywordflow">break</span>;00416 }00417 }00418 00419 <span class="keywordflow">return</span> bHandled;00420 }00421 00422 }</pre></div><hr><address style="align: right;"><small>Generated on Sat Oct 25 12:43:21 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 + -