Fixing unicode in georges edit dll
This commit is contained in:
parent
bb792b8307
commit
01d5edd47b
6 changed files with 58 additions and 58 deletions
|
@ -63,7 +63,7 @@ BOOL CChildFrame::OnCreateClient( LPCREATESTRUCT /*lpcs*/,
|
|||
}
|
||||
|
||||
// Load state
|
||||
theApp.loadWindowState (this, "child", true, false);
|
||||
theApp.loadWindowState (this, _T("child"), true, false);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -385,7 +385,7 @@ void CDfnEditListCtrl::getNewItemText (uint item, uint subItem, std::string &ret
|
|||
|
||||
// ***************************************************************************
|
||||
|
||||
void CDfnEditListCtrl::getBrowseInfo (uint item, uint subItem, std::string &defExt, std::string &defFilename, std::string &defDir, std::string &filter)
|
||||
void CDfnEditListCtrl::getBrowseInfo (uint item, uint subItem, std::string &defExt, std::string &defFilename, std::string &defDir, std::tstring &filter)
|
||||
{
|
||||
if (subItem == 2)
|
||||
{
|
||||
|
@ -621,7 +621,7 @@ void CDfnParentEditListCtrl::getNewItemText (uint item, uint subItem, std::strin
|
|||
|
||||
// ***************************************************************************
|
||||
|
||||
void CDfnParentEditListCtrl::getBrowseInfo (uint item, uint subItem, std::string &defExt, std::string &defFilename, std::string &defDir, std::string &filter)
|
||||
void CDfnParentEditListCtrl::getBrowseInfo (uint item, uint subItem, std::string &defExt, std::string &defFilename, std::string &defDir, std::tstring &filter)
|
||||
{
|
||||
filter = DfnFilter;
|
||||
defDir = theApp.RootSearchPath;
|
||||
|
|
|
@ -36,7 +36,7 @@ class CDfnParentEditListCtrl : public CEditListCtrl
|
|||
CEditListCtrl::TItemEdit getItemEditMode (uint item, uint subItem);
|
||||
void getMemComboBoxProp (uint item, uint subItem, std::string ®Adr, bool &browse);
|
||||
void getNewItemText (uint item, uint subItem, std::string &ret);
|
||||
void getBrowseInfo (uint item, uint subItem, std::string &defExt, std::string &defFilename, std::string &defDir, std::string &filter);
|
||||
void getBrowseInfo (uint item, uint subItem, std::string &defExt, std::string &defFilename, std::string &defDir, std::tstring &filter);
|
||||
public:
|
||||
class CDfnDialog *Dialog;
|
||||
};
|
||||
|
@ -47,7 +47,7 @@ class CDfnEditListCtrl : public CEditListCtrl
|
|||
void getComboBoxStrings (uint item, uint subItem, std::vector<std::string> &retStrings);
|
||||
void getMemComboBoxProp (uint item, uint subItem, std::string ®Adr, bool &browse);
|
||||
void getNewItemText (uint item, uint subItem, std::string &ret);
|
||||
void getBrowseInfo (uint item, uint subItem, std::string &defExt, std::string &defFilename, std::string &defDir, std::string &filter);
|
||||
void getBrowseInfo (uint item, uint subItem, std::string &defExt, std::string &defFilename, std::string &defDir, std::tstring &filter);
|
||||
void onItemChanged (uint item, uint subItem);
|
||||
public:
|
||||
class CDfnDialog *Dialog;
|
||||
|
|
|
@ -39,8 +39,8 @@ using namespace NLGEORGES;
|
|||
using namespace std;
|
||||
|
||||
|
||||
const char* TypeFilter = "Type Files (*.typ)|*.typ|All Files (*.*)|*.*||";
|
||||
const char* DfnFilter = "Form Definition Files (*.dfn)|*.dfn|All Files (*.*)|*.*||";
|
||||
const TCHAR* TypeFilter = _T("Type Files (*.typ)|*.typ|All Files (*.*)|*.*||");
|
||||
const TCHAR* DfnFilter = _T("Form Definition Files (*.dfn)|*.dfn|All Files (*.*)|*.*||");
|
||||
CSplashScreen* splashScreen=new CSplashScreen;
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CGeorgesEditApp
|
||||
|
@ -711,9 +711,9 @@ bool CGeorgesEditApp::getColor (NLMISC::CRGBA &color)
|
|||
bool CGeorgesEditApp::yesNo (const char* message)
|
||||
{
|
||||
if (m_pMainWnd)
|
||||
return m_pMainWnd->MessageBox (message, _T("Georges Edit"), MB_YESNO|MB_ICONQUESTION) != IDNO;
|
||||
return m_pMainWnd->MessageBox (utf8ToTStr(message), _T("Georges Edit"), MB_YESNO|MB_ICONQUESTION) != IDNO;
|
||||
else
|
||||
return MessageBox (NULL, message, _T("Georges Edit"), MB_YESNO|MB_ICONQUESTION) != IDNO;
|
||||
return MessageBox (NULL, utf8ToTStr(message), _T("Georges Edit"), MB_YESNO|MB_ICONQUESTION) != IDNO;
|
||||
}
|
||||
|
||||
void CGeorgesEditApp::loadPlugins ()
|
||||
|
@ -829,10 +829,10 @@ NLGEORGES::IEditDocument *CGeorgesEditApp::createDocument (const char *dfnName,
|
|||
// Set the filename
|
||||
if (strcmp (pathName, "") != 0)
|
||||
{
|
||||
doc->SetPathName ( pathName, FALSE );
|
||||
doc->SetPathName (utf8ToTStr(pathName), FALSE );
|
||||
|
||||
// Create the file
|
||||
doc->OnSaveDocument( pathName );
|
||||
doc->OnSaveDocument(utf8ToTStr(pathName) );
|
||||
}
|
||||
|
||||
// Init the frame
|
||||
|
@ -908,8 +908,8 @@ LONG GetRegKey(HKEY key, LPCTSTR subkey, LPTSTR retdata)
|
|||
|
||||
if (retval == ERROR_SUCCESS)
|
||||
{
|
||||
long datasize = MAX_PATH;
|
||||
char data[MAX_PATH];
|
||||
long datasize = MAX_PATH * sizeof(TCHAR);
|
||||
TCHAR data[MAX_PATH];
|
||||
RegQueryValue(hkey, NULL, data, &datasize);
|
||||
lstrcpy(retdata, data);
|
||||
RegCloseKey(hkey);
|
||||
|
@ -936,7 +936,7 @@ void CGeorgesEditApp::OnViewRefresh()
|
|||
}
|
||||
}
|
||||
|
||||
void CGeorgesEditApp::saveWindowState (const CWnd *wnd, const char *name, bool controlBar)
|
||||
void CGeorgesEditApp::saveWindowState (const CWnd *wnd, const TCHAR *name, bool controlBar)
|
||||
{
|
||||
HKEY hKey;
|
||||
nlverify (RegCreateKey (HKEY_CURRENT_USER, _T(GEORGES_EDIT_BASE_REG_KEY "\\Windows states"), &hKey) == ERROR_SUCCESS);
|
||||
|
@ -952,7 +952,7 @@ void CGeorgesEditApp::saveWindowState (const CWnd *wnd, const char *name, bool c
|
|||
nlverify (RegCloseKey (hKey) == ERROR_SUCCESS);
|
||||
}
|
||||
|
||||
void CGeorgesEditApp::loadWindowState (CWnd *wnd, const char *name, bool mdiChildWnd, bool controlBar)
|
||||
void CGeorgesEditApp::loadWindowState (CWnd *wnd, const TCHAR *name, bool mdiChildWnd, bool controlBar)
|
||||
{
|
||||
HKEY hKey;
|
||||
if (RegOpenKey (HKEY_CURRENT_USER, _T(GEORGES_EDIT_BASE_REG_KEY "\\Windows states"), &hKey) == ERROR_SUCCESS)
|
||||
|
@ -993,20 +993,20 @@ void CGeorgesEditApp::saveState ()
|
|||
// Save the main window state
|
||||
nlassert (m_pMainWnd);
|
||||
if (ResizeMain)
|
||||
saveWindowState (m_pMainWnd, "main", false);
|
||||
saveWindowState (m_pMainWnd, _T("main"), false);
|
||||
|
||||
saveWindowState (&((CMainFrame*)m_pMainWnd)->FileBrowser, "browser", true);
|
||||
saveWindowState (&((CMainFrame*)m_pMainWnd)->OutputConsole, "output", true);
|
||||
saveWindowState (&((CMainFrame*)m_pMainWnd)->FileBrowser, _T("browser"), true);
|
||||
saveWindowState (&((CMainFrame*)m_pMainWnd)->OutputConsole, _T("output"), true);
|
||||
}
|
||||
|
||||
void CGeorgesEditApp::loadState ()
|
||||
{
|
||||
nlassert (m_pMainWnd);
|
||||
if (ResizeMain)
|
||||
loadWindowState (m_pMainWnd, "main", false, false);
|
||||
loadWindowState (m_pMainWnd, _T("main"), false, false);
|
||||
|
||||
loadWindowState (&((CMainFrame*)m_pMainWnd)->FileBrowser, "browser", false, true);
|
||||
loadWindowState (&((CMainFrame*)m_pMainWnd)->OutputConsole, "output", false, true);
|
||||
loadWindowState (&((CMainFrame*)m_pMainWnd)->FileBrowser, _T("browser"), false, true);
|
||||
loadWindowState (&((CMainFrame*)m_pMainWnd)->OutputConsole, _T("output"), false, true);
|
||||
}
|
||||
|
||||
void CGeorgesEditApp::OnFileSaveAll()
|
||||
|
@ -1060,7 +1060,7 @@ bool CGeorgesEditApp::SerialIntoMemStream (const char *formName, CGeorgesEditDoc
|
|||
{
|
||||
// Get the string
|
||||
CString str = doc->GetPathName ();
|
||||
name = str;
|
||||
name = tStrToUtf8(str);
|
||||
uint pos = name.rfind ('.');
|
||||
if (pos != string::npos)
|
||||
{
|
||||
|
@ -1268,7 +1268,7 @@ bool CGeorgesEditApp::SerialFromMemStream (const char *formName, CGeorgesEditDoc
|
|||
{
|
||||
// Get the string
|
||||
CString str = doc->GetPathName ();
|
||||
nameParent = str;
|
||||
nameParent = tStrToUtf8(str);
|
||||
uint pos = nameParent.rfind ('.');
|
||||
if (pos != string::npos)
|
||||
{
|
||||
|
@ -1423,20 +1423,20 @@ bool CGeorgesEditApp::SerialFromMemStream (const char *formName, CGeorgesEditDoc
|
|||
|
||||
BOOL CGeorgesEditApp::OnDDECommand(LPTSTR lpszCommand)
|
||||
{
|
||||
if (strncmp (lpszCommand, "Open", 4) == 0)
|
||||
if (_tcsncmp (lpszCommand, _T("Open"), 4) == 0)
|
||||
{
|
||||
string name = lpszCommand;
|
||||
tstring name = lpszCommand;
|
||||
name = name.substr (6, name.size ()-8);
|
||||
OpenDocumentFile (name.c_str ());
|
||||
}
|
||||
else if (strncmp (lpszCommand, "Georges Copy", 4) == 0)
|
||||
else if (_tcsncmp(lpszCommand, _T("Georges Copy"), 4) == 0)
|
||||
{
|
||||
// Get ext name
|
||||
string name = lpszCommand;
|
||||
tstring name = lpszCommand;
|
||||
name = name.substr (6, name.size ()-8);
|
||||
|
||||
// Get the extension
|
||||
std::string ext = NLMISC::CFile::getExtension(name);
|
||||
std::string ext = NLMISC::CFile::getExtension(tStrToUtf8(name.c_str()));
|
||||
string dfnName = ext + ".dfn";
|
||||
|
||||
// Get the doc template
|
||||
|
@ -1452,7 +1452,7 @@ BOOL CGeorgesEditApp::OnDDECommand(LPTSTR lpszCommand)
|
|||
// Create the frame
|
||||
CFrameWnd* pFrame = docTemplate->CreateNewFrame(doc, NULL);
|
||||
nlassert (pFrame);
|
||||
if (doc->loadFormFile (name.c_str ()))
|
||||
if (doc->loadFormFile(tStrToUtf8(name.c_str()).c_str()))
|
||||
{
|
||||
|
||||
doc->updateDocumentStructure ();
|
||||
|
@ -1491,21 +1491,21 @@ BOOL CGeorgesEditApp::OnDDECommand(LPTSTR lpszCommand)
|
|||
outputError (tmp);
|
||||
}
|
||||
}
|
||||
else if (strncmp (lpszCommand, "Derive", 6) == 0)
|
||||
else if (_tcsncmp(lpszCommand, _T("Derive"), 6) == 0)
|
||||
{
|
||||
// Get ext name
|
||||
string name = lpszCommand;
|
||||
tstring name = lpszCommand;
|
||||
name = name.substr (8, name.size ()-10);
|
||||
|
||||
// Get the extension
|
||||
std::string ext = NLMISC::CFile::getExtension(name);
|
||||
std::string ext = NLMISC::CFile::getExtension(tStrToUtf8(name.c_str()));
|
||||
string dfnName = ext + ".dfn";
|
||||
|
||||
// Create a document
|
||||
CGeorgesEditDocForm *doc = (CGeorgesEditDocForm*)createDocument (dfnName.c_str (), "");
|
||||
if (doc)
|
||||
{
|
||||
std::string nameFile = NLMISC::CFile::getFilename(name);
|
||||
std::string nameFile = NLMISC::CFile::getFilename(tStrToUtf8(name.c_str()));
|
||||
doc->addParent (nameFile.c_str());
|
||||
doc->updateDocumentStructure ();
|
||||
doc->UpdateAllViews (NULL);
|
||||
|
@ -1517,14 +1517,14 @@ BOOL CGeorgesEditApp::OnDDECommand(LPTSTR lpszCommand)
|
|||
outputError (tmp);
|
||||
}
|
||||
}
|
||||
else if (strncmp (lpszCommand, "CreateForm", 10) == 0)
|
||||
else if (_tcsncmp(lpszCommand, _T("CreateForm"), 10) == 0)
|
||||
{
|
||||
// Get ext name
|
||||
string name = lpszCommand;
|
||||
tstring name = lpszCommand;
|
||||
name = name.substr (10, name.size ()-12);
|
||||
|
||||
// Get the extension
|
||||
std::string dfnName = NLMISC::CFile::getFilename(name);
|
||||
std::string dfnName = NLMISC::CFile::getFilename(tStrToUtf8(name.c_str()));
|
||||
|
||||
// Create a document
|
||||
CGeorgesEditDocForm *doc = (CGeorgesEditDocForm*)createDocument (dfnName.c_str (), "");
|
||||
|
|
|
@ -41,8 +41,8 @@
|
|||
#define GEORGES_EDIT_BASE_REG_KEY "Software\\Nevrax\\Georges Edit"
|
||||
#define GEORGES_EDIT_BROWSE_LABEL "--- Browse..."
|
||||
|
||||
extern const char* TypeFilter;
|
||||
extern const char* DfnFilter;
|
||||
extern const TCHAR* TypeFilter;
|
||||
extern const TCHAR* DfnFilter;
|
||||
|
||||
class CGeorgesEditDoc;
|
||||
|
||||
|
@ -155,8 +155,8 @@ public:
|
|||
// Get a template form
|
||||
CMultiDocTemplate *getFormDocTemplate (const char *dfnName);
|
||||
|
||||
void saveWindowState (const CWnd *wnd, const char *name, bool controlBar);
|
||||
void loadWindowState (CWnd *wnd, const char *name, bool changeShowWindow, bool controlBar);
|
||||
void saveWindowState (const CWnd *wnd, const TCHAR *name, bool controlBar);
|
||||
void loadWindowState (CWnd *wnd, const TCHAR *name, bool changeShowWindow, bool controlBar);
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
|
|
|
@ -223,10 +223,10 @@ BOOL CGeorgesEditDocForm::OnNewDocument()
|
|||
string defFilename = theApp.RootSearchPath;
|
||||
defFilename += "*.dfn";
|
||||
|
||||
CFileDialog dlgFile (TRUE, _T("*.dfn"), defFilename.c_str (), OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, DfnFilter, theApp.m_pMainWnd);
|
||||
CFileDialog dlgFile(TRUE, _T("*.dfn"), utf8ToTStr(defFilename.c_str()), OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, DfnFilter, theApp.m_pMainWnd);
|
||||
if (dlgFile.DoModal () == IDOK)
|
||||
{
|
||||
if (initDocument (dlgFile.GetFileName (), true))
|
||||
if (initDocument(tStrToUtf8(dlgFile.GetFileName()).c_str(), true))
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
@ -491,7 +491,7 @@ BOOL CGeorgesEditDoc::OnOpenDocument(LPCTSTR lpszPathName)
|
|||
try
|
||||
{
|
||||
// Read the form with the loader
|
||||
Type = FormLoader.loadType (lpszPathName);
|
||||
Type = FormLoader.loadType(tStrToUtf8(lpszPathName));
|
||||
if (!Type)
|
||||
{
|
||||
char msg[512];
|
||||
|
@ -517,11 +517,11 @@ BOOL CGeorgesEditDoc::OnOpenDocument(LPCTSTR lpszPathName)
|
|||
try
|
||||
{
|
||||
// Read the form with the loader
|
||||
Dfn = FormLoader.loadFormDfn (lpszPathName, true);
|
||||
Dfn = FormLoader.loadFormDfn (tStrToUtf8(lpszPathName), true);
|
||||
if (!Dfn)
|
||||
{
|
||||
char msg[512];
|
||||
smprintf (msg, 512, "Error while loading Dfn file %s", lpszPathName);
|
||||
smprintf (msg, 512, "Error while loading Dfn file %s", tStrToUtf8(lpszPathName).c_str());
|
||||
theApp.outputError (msg);
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -554,13 +554,13 @@ BOOL CGeorgesEditDoc::OnOpenDocument(LPCTSTR lpszPathName)
|
|||
if (theApp.getFormDocTemplate (dfnName.c_str ()) == NULL)
|
||||
{
|
||||
char message[512];
|
||||
smprintf (message, 512, "Can't open the file '%s'.", lpszPathName);
|
||||
smprintf (message, 512, "Can't open the file '%s'.", tStrToUtf8(lpszPathName).c_str());
|
||||
theApp.outputError (message);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Read the form with the loader
|
||||
if (!loadFormFile (lpszPathName))
|
||||
if (!loadFormFile (tStrToUtf8(lpszPathName).c_str()))
|
||||
return FALSE;
|
||||
|
||||
if (theApp.ExeStandalone)
|
||||
|
@ -743,7 +743,7 @@ BOOL CGeorgesEditDoc::OnSaveDocument(LPCTSTR lpszPathName)
|
|||
|
||||
// Open the filt
|
||||
COFile file;
|
||||
if (file.open (lpszPathName))
|
||||
if (file.open(tStrToUtf8(lpszPathName)))
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -778,7 +778,7 @@ BOOL CGeorgesEditDoc::OnSaveDocument(LPCTSTR lpszPathName)
|
|||
Dfn->Header.MinorVersion++;
|
||||
flushValueChange ();
|
||||
}
|
||||
Dfn->write (xmlStream.getDocument (), lpszPathName);
|
||||
Dfn->write (xmlStream.getDocument (), tStrToUtf8(lpszPathName));
|
||||
modify (NULL, NULL, false);
|
||||
UpdateAllViews (NULL);
|
||||
return TRUE;
|
||||
|
@ -793,11 +793,11 @@ BOOL CGeorgesEditDoc::OnSaveDocument(LPCTSTR lpszPathName)
|
|||
((CForm*)(UForm*)Form)->Header.MinorVersion++;
|
||||
flushValueChange ();
|
||||
}
|
||||
((CForm*)(UForm*)Form)->write (xmlStream.getDocument (), lpszPathName);
|
||||
if (strcmp (xmlStream.getErrorString (), "") != 0)
|
||||
((CForm*)(UForm*)Form)->write (xmlStream.getDocument (), tStrToUtf8(lpszPathName));
|
||||
if (strcmp(xmlStream.getErrorString().c_str(), "") != 0)
|
||||
{
|
||||
char message[512];
|
||||
smprintf (message, 512, "Error while saving file: %s", xmlStream.getErrorString ());
|
||||
smprintf (message, 512, "Error while saving file: %s", xmlStream.getErrorString().c_str());
|
||||
theApp.outputError (message);
|
||||
}
|
||||
modify (NULL, NULL, false);
|
||||
|
@ -1122,7 +1122,7 @@ void CGeorgesEditDoc::getFilename (std::string &pathname)
|
|||
{
|
||||
AFX_MANAGE_STATE(AfxGetStaticModuleState());
|
||||
|
||||
pathname = (const char*)GetPathName ();
|
||||
pathname = tStrToUtf8(GetPathName());
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
|
@ -1131,7 +1131,7 @@ void CGeorgesEditDoc::getTitle (std::string &title)
|
|||
{
|
||||
AFX_MANAGE_STATE(AfxGetStaticModuleState());
|
||||
|
||||
title = (const char*)GetTitle ();
|
||||
title = tStrToUtf8(GetTitle());
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
|
@ -1327,11 +1327,11 @@ void CGeorgesEditDoc::setModifiedState (bool modified)
|
|||
}
|
||||
else
|
||||
{
|
||||
string title = (const char*)GetTitle ();
|
||||
string title = tStrToUtf8(GetTitle());
|
||||
if ( (title.size ()>=2) && (title[title.size()-1] == '*') && (title[title.size()-2] == ' ') )
|
||||
{
|
||||
title.resize (title.size () - 2);
|
||||
SetTitle (title.c_str());
|
||||
SetTitle (utf8ToTStr(title));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue