00001
#include "StdAfx.h"
00002
#include "AddFontSettings.h"
00003
00004 CAddFontSettings::CAddFontSettings()
00005 {
00006 m_iFontIndex = 0;
00007 m_iFontID = 1;
00008 m_pstrFontNames = m_pstrFontFilenames = NULL;
00009
00010
if(
CFontManager::GetSingletonPtr() == NULL)
00011
return;
00012
00013
if(
CFontManager::GetSingleton().
size() > 0)
00014 {
00015 m_pstrFontNames =
new CString[
CFontManager::GetSingleton().
size()];
00016 m_pstrFontFilenames =
new CString[
CFontManager::GetSingleton().
size()];
00017 }
00018
else
00019 m_pstrFontNames = m_pstrFontFilenames = NULL;
00020 }
00021
00022 CAddFontSettings::~CAddFontSettings()
00023 {
00024 SAFEDEL_ARRAY(m_pstrFontNames)
00025 SAFEDEL_ARRAY(m_pstrFontFilenames)
00026 }
00027
00028
bool CAddFontSettings::PropertyChanging( const
void* pvProperty ,
void* pvNewValue )
00029 {
00030
bool bChangeOK = CAddResourceSettings::PropertyChanging(pvProperty, pvNewValue);
00031
00032
if(
CFontManager::GetSingletonPtr() == NULL)
00033
return false;
00034
00035
if(pvProperty == &m_strResourceName)
00036 {
00037
CCustomFont *pFont =
CFontManager::GetSingleton().
GetResource(-1, -1, (*(CString *)pvNewValue),
"");
00038
if(pFont !=NULL)
00039
return false;
00040
else
00041 {
00042 m_strResourceName = *(CString *)pvNewValue;
00043 m_pCurrentFont->SetName(m_strResourceName);
00044
00045
for (
int i=0; i<
CFontManager::GetSingleton().
size(); i++)
00046 {
00047
CCustomFont *pFont = (
CCustomFont *)
CFontManager::GetSingleton().
at(i);
00048
if(pFont == m_pCurrentFont)
00049 {
00050 m_iFontIndex = i;
00051
break;
00052 }
00053 }
00054
00055 m_bUpdateRequired =
true;
00056 }
00057 }
00058
00059
if(pvProperty == &m_strResourceXMLFilename)
00060 {
00061
CCustomFont *pFont =
CFontManager::GetSingleton().
LoadResource(NULL, (*(CString *)pvNewValue));
00062
if(pFont != NULL && m_pCurrentFont !=pFont)
00063 {
00064 m_pCurrentFont = pFont;
00065 m_strResourceXMLFilename = *(CString *)pvNewValue;
00066 m_strResourceName = pFont->
GetName();
00067
00068 m_bUpdateRequired =
true;
00069 }
00070 }
00071
00072
if(pvProperty == &m_strResourcesDatabaseFilename)
00073 {
00074
int iRetValue =
CFontManager::GetSingleton().
LoadXML(NULL, (*(CString *)pvNewValue));
00075
00076
00077
00078 m_strResourcesDatabaseFilename = *(CString *)pvNewValue;
00079
00080 m_bUpdateRequired =
true;
00081 }
00082
00083
if(pvProperty == &m_iFontIndex)
00084 {
00085
int iTempTexIndex = *(
int *)pvNewValue;
00086
CCustomFont *pFont =
CFontManager::GetSingleton().
GetResource(iTempTexIndex);
00087
00088 m_strResourceName = pFont->
GetName();
00089 m_iFontIndex = iTempTexIndex;
00090 m_pCurrentFont = pFont;
00091
00092 m_bUpdateRequired =
true;
00093 }
00094
00095
return bChangeOK;
00096 }
00097
00098
void CAddFontSettings::GetProperties( EPropList& PropList )
00099 {
00100 CAddResourceSettings::GetProperties(PropList);
00101
00102
if(
CFontManager::GetSingletonPtr() == NULL)
00103
return;
00104
00105 PropList.AddTab(
"Font(s)");
00106 PropList.AddPropSeparator(
this,
"Tools");
00107
00108 EPropertyCombo *pFontCombo = PropList.AddPropCombo(
this,
"Font", &m_iFontIndex);
00109
for (
int i=0; i<
CFontManager::GetSingleton().
size(); i++)
00110 {
00111
CCustomFont *pFont = (
CCustomFont *)
CFontManager::GetSingleton().
at(i);
00112 pFontCombo->AddString(pFont->
GetName(), i);
00113 }
00114
00115 PropList.AddPropFile(
this,
"XML File", &m_strResourceXMLFilename,
"XML Files (*.xml)|*.xml|All Files (*.*)|*.*||")->SetComment(
"Font XML File");
00116 PropList.AddPropFile(
this,
"XML Database", &m_strResourcesDatabaseFilename,
"XML Files (*.xml)|*.xml|All Files (*.*)|*.*||")->SetComment(
"Fonts Database XML File");
00117 }