mirror of https://github.com/odrling/Aegisub
Unused standard paths class
Originally committed to SVN as r1273.
This commit is contained in:
parent
f36ccd9e99
commit
01f49dda8d
|
@ -40,14 +40,16 @@
|
|||
////////////
|
||||
// Includes
|
||||
#include <wx/dir.h>
|
||||
#include <ft2build.h>
|
||||
#ifdef WIN32
|
||||
#include <shlobj.h>
|
||||
#endif
|
||||
#include "font_file_lister.h"
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
#include FT_GLYPH_H
|
||||
#include FT_SFNT_NAMES_H
|
||||
#include <shlobj.h>
|
||||
#endif
|
||||
#include "font_file_lister.h"
|
||||
#include "text_file_writer.h"
|
||||
#include "text_file_reader.h"
|
||||
|
||||
|
||||
////////////////////
|
||||
|
@ -58,8 +60,10 @@ FontFileLister *FontFileLister::instance = NULL;
|
|||
///////////////
|
||||
// Constructor
|
||||
FontFileLister::FontFileLister() {
|
||||
#ifdef WIN32
|
||||
// Initialize freetype2
|
||||
FT_Init_FreeType(&ft2lib);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -105,17 +109,16 @@ void FontFileLister::DoClearData() {
|
|||
///////////////////////////
|
||||
// Gather data from system
|
||||
void FontFileLister::DoGatherData() {
|
||||
#ifdef WIN32
|
||||
|
||||
// Get fonts folder
|
||||
wxString source;
|
||||
#ifdef WIN32
|
||||
TCHAR szPath[MAX_PATH];
|
||||
if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_FONTS,NULL,0,szPath))) {
|
||||
source = wxString(szPath);
|
||||
}
|
||||
else source = wxGetOSDirectory() + _T("\\fonts");
|
||||
source += _T("\\");
|
||||
#endif
|
||||
if (source == _T("")) return;
|
||||
|
||||
// Get the list of fonts in the fonts folder
|
||||
wxArrayString fontfiles;
|
||||
|
@ -139,6 +142,13 @@ void FontFileLister::DoGatherData() {
|
|||
FT_Done_Face(face);
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
// TODO: implement fconfig
|
||||
return;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -45,7 +45,9 @@
|
|||
|
||||
////////////
|
||||
// Typedefs
|
||||
#ifdef WIN32
|
||||
typedef struct FT_LibraryRec_ *FT_Library;
|
||||
#endif
|
||||
typedef std::map<wxString,wxArrayString> FontMap;
|
||||
|
||||
|
||||
|
@ -53,9 +55,11 @@ typedef std::map<wxString,wxArrayString> FontMap;
|
|||
// Font file lister
|
||||
class FontFileLister {
|
||||
private:
|
||||
static FontFileLister *instance;
|
||||
#ifdef WIN32
|
||||
FT_Library ft2lib;
|
||||
#endif
|
||||
|
||||
static FontFileLister *instance;
|
||||
FontMap fontTable;
|
||||
wxArrayString fontFiles;
|
||||
|
||||
|
|
|
@ -0,0 +1,92 @@
|
|||
// Copyright (c) 2007, Rodrigo Braz Monteiro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
// * Neither the name of the Aegisub Group nor the names of its contributors
|
||||
// may be used to endorse or promote products derived from this software
|
||||
// without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// -----------------------------------------------------------------------------
|
||||
//
|
||||
// AEGISUB
|
||||
//
|
||||
// Website: http://aegisub.cellosoft.com
|
||||
// Contact: mailto:zeratul@cellosoft.com
|
||||
//
|
||||
|
||||
|
||||
///////////
|
||||
// Headers
|
||||
#include <wx/stdpaths.h>
|
||||
#include "standard_paths.h"
|
||||
|
||||
|
||||
////////////////
|
||||
// Get instance
|
||||
StandardPaths *StandardPaths::GetInstance() {
|
||||
if (!instance) instance = new StandardPaths();
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
||||
///////////////
|
||||
// Constructor
|
||||
StandardPaths::StandardPaths() {
|
||||
wxFileName aegiPath(wxStandardPaths::Get().GetExecutablePath());
|
||||
SetPathValue(_T("?install"),aegiPath.GetPath());
|
||||
SetPathValue(_T("?user"),wxStandardPaths::Get().GetUserDataDir());
|
||||
SetPathValue(_T("?temp"),wxStandardPaths::Get().GetTempDir());
|
||||
}
|
||||
|
||||
|
||||
///////////////
|
||||
// Decode path
|
||||
wxString StandardPaths::DoDecodePath(wxString path) {
|
||||
// Decode
|
||||
if (path[0] == _T('?')) {
|
||||
// TODO
|
||||
return path;
|
||||
}
|
||||
|
||||
// Nothing to decode
|
||||
else return path;
|
||||
}
|
||||
|
||||
|
||||
///////////////
|
||||
// Encode path
|
||||
wxString StandardPaths::DoEncodePath(wxString path) {
|
||||
// TODO
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////
|
||||
// Set value of a ? path
|
||||
void StandardPaths::DoSetPathValue(wxString path,wxString value) {
|
||||
paths[path] = value;
|
||||
}
|
||||
|
||||
|
||||
///////////////////
|
||||
// Static instance
|
||||
StandardPaths *StandardPaths::instance = NULL;
|
|
@ -0,0 +1,65 @@
|
|||
// Copyright (c) 2007, Rodrigo Braz Monteiro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
// * Neither the name of the Aegisub Group nor the names of its contributors
|
||||
// may be used to endorse or promote products derived from this software
|
||||
// without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// -----------------------------------------------------------------------------
|
||||
//
|
||||
// AEGISUB
|
||||
//
|
||||
// Website: http://aegisub.cellosoft.com
|
||||
// Contact: mailto:zeratul@cellosoft.com
|
||||
//
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
///////////
|
||||
// Headers
|
||||
#include <wx/wxprec.h>
|
||||
#include <map>
|
||||
|
||||
|
||||
//////////////////////////////////
|
||||
// Standard path conversion class
|
||||
class StandardPaths {
|
||||
private:
|
||||
static StandardPaths *instance;
|
||||
static StandardPaths *GetInstance();
|
||||
|
||||
std::map<wxString,wxString> paths;
|
||||
|
||||
StandardPaths();
|
||||
|
||||
wxString DoDecodePath(wxString path);
|
||||
wxString DoEncodePath(wxString path);
|
||||
void DoSetPathValue(wxString path,wxString value);
|
||||
|
||||
public:
|
||||
static wxString DecodePath(wxString path) { return GetInstance()->DoDecodePath(path); }
|
||||
static wxString EncodePath(wxString path) { return GetInstance()->DoEncodePath(path); }
|
||||
static void SetPathValue(wxString path,wxString value) { GetInstance()->DoSetPathValue(path,value); }
|
||||
};
|
Loading…
Reference in New Issue