Debian Codegraph @

code/global/Utils.cpp

raw
1 /*
2 Copyright (C) 2013 wxLauncher Team
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18
19 #include "generated/configure_launcher.h"
20
21 #include "Utils.h"
22
23 namespace TextUtils {
24 #include <wx/arrimpl.cpp>
25 WX_DEFINE_OBJARRAY(ArrayOfWords);
26
27 void FillArrayOfWordsFromTokens(wxStringTokenizer &tokens,
28 wxDC &dc,
29 wxFont* testFont,
30 ArrayOfWords& words,
31 const bool useAppleDebugFilter) {
32 while ( tokens.HasMoreTokens() ) {
33 wxString tok = tokens.GetNextToken();
34 #if IS_APPLE
35 if (useAppleDebugFilter) {
36 // left over from tokenizing executable in debug .app
37 if (tok.Lower() == _T("(debug)")) {
38 tok = _T("");
39 }
40 // remove the text after ".app" in the FSO executable name
41 // the trailing / ensures that the .app indicates an extension
42 int DotAppIndex = tok.Find(_T(".app/"));
43 if (DotAppIndex != wxNOT_FOUND) {
44 tok = tok.Mid(0, DotAppIndex + 4); // 4 to retain ".app"
45 }
46 }
47 #endif
48 int x, y;
49 dc.GetTextExtent(tok, &x, &y, NULL, NULL, testFont);
50
51 Words* temp = new Words();
52 temp->size.SetWidth(x);
53 temp->size.SetHeight(y);
54 temp->word = tok;
55
56 words.Add(temp);
57 }
58 }
59 }