OSDN Git Service

On windows, Molecule#path, Molecule#dir does not work correctly when the path include...
authortoshinagata1964 <toshinagata1964@a2be9bc6-48de-4e38-9406-05402d4bc13c>
Fri, 30 Sep 2011 09:32:27 +0000 (09:32 +0000)
committertoshinagata1964 <toshinagata1964@a2be9bc6-48de-4e38-9406-05402d4bc13c>
Fri, 30 Sep 2011 09:32:27 +0000 (09:32 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/molby/trunk@127 a2be9bc6-48de-4e38-9406-05402d4bc13c

memo.txt
wxSources/ConsoleFrame.cpp
wxSources/GlobalParameterFilesFrame.cpp
wxSources/GlobalParameterFrame.cpp
wxSources/MoleculeView.cpp
wxSources/MyApp.cpp
wxSources/MyClipboardData.cpp
wxSources/MyDocManager.cpp
wxSources/MyDocument.cpp
wxSources/RubyDialogFrame.cpp
xcode-build/Molby.xcodeproj/project.pbxproj

index 8b6dcf6..c7e0281 100755 (executable)
--- a/memo.txt
+++ b/memo.txt
@@ -260,3 +260,7 @@ Final compile date/time is now shown in the 'About' window.
 Fix mdcrd import to allow coordinates using full 8 digits (like -123.456 or 1234.567).
 Occasional crash during minimization is fixed.
 
+2011.9.30.
+ Windows の文字コードで厄介なバグを発見。内部コードを UTF-8 にしているのだが、Dir.pwd などは Windows の内部コードそのもの(Shift-JIS?)で動作するので、Molecule#path などと矛盾が生じる。さらに、Ruby_FileStringValuePtr などは Shift-JIS を前提としているので、Molecule#path などもおかしな文字列を生成してしまう。このため、パスに日本語が入っていると open(mol.path + "/test.txt", "w") などがうまくいかない。さてどうしたものか?
+→ wxConvUTF8 の代わりに Windows では *wxConvCurrent を使うようにした。
+
index ea22c49..608299e 100755 (executable)
@@ -23,6 +23,7 @@
 
 #include "MyApp.h"
 #include "../MolLib/Ruby_bind/Molby_extern.h"
+#include "MyMBConv.h"
 
 BEGIN_EVENT_TABLE(ConsoleFrame, wxMDIChildFrame)
        EVT_UPDATE_UI(wxID_CLOSE, ConsoleFrame::OnUpdateUI)
@@ -252,7 +253,7 @@ ConsoleFrame::OnEnterPressed(wxKeyEvent& event)
                RubyValue val;
                Molecule *mol = MoleculeCallback_currentMolecule();
                MoleculeLock(mol);
-               val = Molby_evalRubyScriptOnMolecule(string.mb_str(wxConvUTF8), MoleculeCallback_currentMolecule(), &status);
+               val = Molby_evalRubyScriptOnMolecule(string.mb_str(WX_DEFAULT_CONV), MoleculeCallback_currentMolecule(), &status);
                MoleculeUnlock(mol);
                if (status != -1) {  /*  Status -1 is already handled  */
                        MyAppCallback_setConsoleColor(1);
index fa1eaef..1199413 100644 (file)
@@ -28,6 +28,7 @@
 #include "MyListCtrl.h"
 #include "../MolLib/MolLib.h"
 #include "../MolLib/Missing.h"
+#include "MyMBConv.h"
 
 // #include "../MolLib/Ruby_bind/Molby_extern.h"
 
@@ -134,7 +135,7 @@ GlobalParameterFilesFrame::OnAddGlobalParameterFile(wxCommandEvent& event)
                if (i >= 0) {
                        char *s;
                        asprintf(&s, "File '%s' has already been read. Do you want to replace the parameters?", ParameterGetComment(src_idx));
-                       wxString mes(s, wxConvUTF8);
+                       wxString mes(s, WX_DEFAULT_CONV);
                        if (::wxMessageBox(mes, _T("Reload global parameter file"), wxOK | wxCANCEL | wxICON_EXCLAMATION) != wxOK)
                                return;
                }
@@ -181,15 +182,15 @@ GlobalParameterFilesFrame::OnRemoveGlobalParameterFile(wxCommandEvent& event)
                        cp = ParameterGetComment(ip->src);
                        if (cn > 0)
                                files << _T(", ");
-                       files << wxString(cp, wxConvUTF8);
+                       files << wxString(cp, WX_DEFAULT_CONV);
                        cn++;
                }
        }
        if (cn == 0)
                return;
        
-       asprintf(&s, "Do you really want to unload the parameter%s %s?", (cn > 1 ? "s" : ""), (const char *)files.mb_str(wxConvUTF8));
-       wxString mes(s, wxConvUTF8);
+       asprintf(&s, "Do you really want to unload the parameter%s %s?", (cn > 1 ? "s" : ""), (const char *)files.mb_str(WX_DEFAULT_CONV));
+       wxString mes(s, WX_DEFAULT_CONV);
        if (::wxMessageBox(mes, _T("Unload global parameter file"), wxOK | wxCANCEL | wxICON_EXCLAMATION) != wxOK)
                return;
        for (i = gGlobalParInfo.count - 1; i >= gGlobalParInfo.builtinCount; i--) {
@@ -240,7 +241,7 @@ GlobalParameterFilesFrame::GetItemText(MyListCtrl *ctrl, long row, long column)
                else
                        p = ip->dir;
        }
-       wxString str((p ? p : ""), wxConvUTF8);
+       wxString str((p ? p : ""), WX_DEFAULT_CONV);
        return str;
 }
 
index fd56e40..d56b707 100755 (executable)
@@ -24,6 +24,7 @@
 #include "MyApp.h"
 #include "MyListCtrl.h"
 #include "../MolLib/Ruby_bind/Molby_extern.h"
+#include "MyMBConv.h"
 
 BEGIN_EVENT_TABLE(GlobalParameterFrame, wxMDIChildFrame)
        EVT_CLOSE(GlobalParameterFrame::OnCloseWindow)
@@ -108,14 +109,14 @@ GlobalParameterFrame::GetItemText(MyListCtrl *ctrl, long row, long column) const
 {
        char buf[128];
        MainView_valueForTable(NULL, column, row, buf, sizeof buf);
-       wxString *str = new wxString(buf, wxConvUTF8);
+       wxString *str = new wxString(buf, WX_DEFAULT_CONV);
        return *str;
 }
 
 int
 GlobalParameterFrame::SetItemText(MyListCtrl *ctrl, long row, long column, const wxString &value)
 {
-//     MainView_setValueForTable(NULL, column, row, value.mb_str(wxConvUTF8));
+//     MainView_setValueForTable(NULL, column, row, value.mb_str(WX_DEFAULT_CONV));
        return 0;
 }
 
index edffddb..1992966 100755 (executable)
@@ -39,6 +39,7 @@
 #include "MySlider.h"
 #include "MyListCtrl.h"
 #include "../MolLib/Missing.h"
+#include "MyMBConv.h"
 
 #include "wx/tglbtn.h"
 #include "wx/listctrl.h"
@@ -140,7 +141,7 @@ MoleculeView::OnCreate(wxDocument *doc, long WXUNUSED(flags) )
                        MainView_tableTitleForIndex(mview, i, buf, sizeof buf);
                        if (buf[0] == 0)
                                break;
-                       wxString itemTitle(buf, wxConvUTF8);
+                       wxString itemTitle(buf, WX_DEFAULT_CONV);
                        choiceItems.Add(itemTitle);
                }
        /*      static wxString choiceItems[] = {
@@ -543,7 +544,7 @@ MoleculeView::OnFrameTextAction(wxCommandEvent &event)
        nframes = MoleculeGetNumberOfFrames(mview->mol);
        if (nframes != 0) {
                str = frameText->GetValue();
-               ival = atoi((const char *)str.mb_str(wxConvUTF8));
+               ival = atoi((const char *)str.mb_str(WX_DEFAULT_CONV));
                if (ival >= 0 && ival < nframes) {
                        MoleculeSelectFrame(mview->mol, ival, 1);
                        MoleculeUnlock(mview->mol);
@@ -696,14 +697,14 @@ MoleculeView::GetItemText(MyListCtrl *ctrl, long row, long column) const
 {
        char buf[128];
        MainView_valueForTable(mview, column, row, buf, sizeof buf);
-       wxString *str = new wxString(buf, wxConvUTF8);
+       wxString *str = new wxString(buf, WX_DEFAULT_CONV);
        return *str;
 }
 
 int
 MoleculeView::SetItemText(MyListCtrl *ctrl, long row, long column, const wxString &value)
 {
-       MainView_setValueForTable(mview, column, row, value.mb_str(wxConvUTF8));
+       MainView_setValueForTable(mview, column, row, value.mb_str(WX_DEFAULT_CONV));
        return 0;
 }
 
@@ -885,7 +886,7 @@ void
 MainViewCallback_drawInfoText(MainView *mview, const char *label)
 {
        if (mview != NULL && mview->ref != NULL) {
-               wxString labelstr(label, wxConvUTF8);
+               wxString labelstr(label, WX_DEFAULT_CONV);
                ((MoleculeView *)(mview->ref))->infotext->SetLabel(labelstr);
        }
 }
@@ -959,7 +960,7 @@ MainViewCallback_newFromFile(const char *fname)
   if (fname == NULL || *fname == 0) {
     doc = manager->CreateDocument(wxT(""), wxDOC_NEW);
   } else {
-    wxString fnamestr(fname, wxConvUTF8);  /*  UTF8 -> wxString  */
+    wxString fnamestr(fname, wxConvFile);
     doc = manager->CreateDocument(fnamestr, wxDOC_SILENT);
   }
   return MainViewCallback_activeView();
@@ -970,7 +971,7 @@ MainViewCallback_importFromFile(MainView *mview, const char *fname)
 {
   MyDocument *doc;
   if (mview != NULL && mview->ref != NULL && (doc = (((MoleculeView *)(mview->ref))->MolDocument())) != NULL) {
-    wxString fnamestr(fname, wxConvUTF8);  /*  UTF8 -> wxString  */
+    wxString fnamestr(fname, wxConvFile);
     // doc->importFromFile(fnamestr);
     MainViewCallback_setNeedsDisplay(mview, 1);
     return 1;
@@ -985,7 +986,7 @@ MainViewCallback_getFilename(MainView *mview, char *buf, int bufsize)
   if (mview != NULL && mview->ref != NULL && (doc = (((MoleculeView *)(mview->ref))->MolDocument())) != NULL) {
     wxString fname;
     fname = doc->GetFilename();
-    strncpy(buf, (const char*)fname.mb_str(wxConvUTF8), bufsize - 1);  /*  wxString -> UTF8  */
+    strncpy(buf, (const char*)fname.mb_str(wxConvFile), bufsize - 1);
     buf[bufsize - 1] = 0;
   } else {
     buf[0] = 0;
@@ -1116,7 +1117,7 @@ int
 MainViewCallback_addTableColumn(MainView *mview, const char *name, int width, int editable)
 {
        int idx;
-       wxString nstr(name, wxConvUTF8);
+       wxString nstr(name, WX_DEFAULT_CONV);
        MyListCtrl *listctrl = s_MyListCtrlFromMainView(mview);
        if (listctrl == NULL)
                return 0;
index 3f73390..09a97a3 100755 (executable)
@@ -49,6 +49,7 @@
 #include "ProgressFrame.h"
 #include "GlobalParameterFrame.h"
 #include "GlobalParameterFilesFrame.h"
+#include "MyMBConv.h"
 
 #include "../MolLib/MolLib.h"
 #include "../MolLib/Ruby_bind/Molby.h"
@@ -104,7 +105,7 @@ MyApp::FindResourcePath()
        if (ref != NULL) {
                UInt8 buffer[256];
                if (CFURLGetFileSystemRepresentation(ref, true, buffer, sizeof buffer)) {
-                       wxString dirname((const char *)buffer, wxConvUTF8);
+                       wxString dirname((const char *)buffer, WX_DEFAULT_CONV);
                        CFRelease(ref);
                        return dirname;
                }
@@ -172,8 +173,8 @@ bool MyApp::OnInit(void)
        {
                //  Check if the same application is already running
                char *buf;
-               asprintf(&buf, "Molby-%s", (const char *)wxGetUserId().mb_str(wxConvUTF8));
-               wxString name(buf, wxConvUTF8);
+               asprintf(&buf, "Molby-%s", (const char *)wxGetUserId().mb_str(WX_DEFAULT_CONV));
+               wxString name(buf, WX_DEFAULT_CONV);
                malloc(16);
                free(buf);
                m_checker = new wxSingleInstanceChecker(name);
@@ -290,8 +291,8 @@ bool MyApp::OnInit(void)
                        free(wbuf);
                }
 
-               wxString fnamestr(fname, wxConvUTF8);
-               Molby_startup(wxFileExists(fnamestr) ? fname : NULL, (const char *)dirname.mb_str(wxConvUTF8));
+               wxString fnamestr(fname, wxConvFile);
+               Molby_startup(wxFileExists(fnamestr) ? fname : NULL, (const char *)dirname.mb_str(wxConvFile));
                
                wxSetWorkingDirectory(cwd);
                MyAppCallback_showScriptMessage("%% ");
@@ -488,7 +489,7 @@ MyApp::AppendConsoleMessage(const char *mes)
 {
        wxTextCtrl *textCtrl;
        if (consoleFrame != NULL && (textCtrl = consoleFrame->textCtrl) != NULL) {
-               wxString string(mes, wxConvUTF8);
+               wxString string(mes, WX_DEFAULT_CONV);
                textCtrl->AppendText(string);
                return string.Len();
        } else return 0;
@@ -519,7 +520,7 @@ MyApp::SetConsoleColor(int color)
 void
 MyApp::ShowProgressPanel(const char *mes)
 {
-       wxString string((mes ? mes : ""), wxConvUTF8);
+       wxString string((mes ? mes : ""), WX_DEFAULT_CONV);
        if (m_progressFrame == NULL) {
 #if __WXMAC__
                {
@@ -567,7 +568,7 @@ void
 MyApp::SetProgressMessage(const char *mes)
 {
        if (m_progressFrame != NULL) {
-               wxString string((mes ? mes : ""), wxConvUTF8);
+               wxString string((mes ? mes : ""), WX_DEFAULT_CONV);
                m_progressFrame->SetProgressMessage(string);
        }
 }
@@ -706,7 +707,7 @@ MyApp::UpdateScriptMenu(wxMenuBar *mbar)
                if (title == NULL || title[0] == 0) {
                        smenu->AppendSeparator();
                } else {
-                       wxString stitle(scriptMenuTitles[i], wxConvUTF8);
+                       wxString stitle(scriptMenuTitles[i], WX_DEFAULT_CONV);
                        wxMenuItem *item = new wxMenuItem(smenu, myMenuID_CustomScript + i, stitle);
                        smenu->Append(item);
                }
@@ -925,7 +926,7 @@ MyApp::CallSubProcess(const char *cmdline, const char *procname)
        int status = 0;
        char buf[256];
        size_t len, len_total;
-       wxString cmdstr(cmdline, wxConvUTF8);
+       wxString cmdstr(cmdline, WX_DEFAULT_CONV);
 #if defined(__WXMSW__)
        extern int myKillAllChildren(long pid, wxSignal sig, wxKillError *krc);
 #endif
@@ -1103,7 +1104,7 @@ void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event) )
                         gVersionString, gCopyrightString, sLastBuildString,
                         wxMAJOR_VERSION, wxMINOR_VERSION, wxRELEASE_NUMBER,
                         gRubyVersion, gRubyCopyright);
-       wxString str(s, wxConvUTF8);
+       wxString str(s, WX_DEFAULT_CONV);
     (void)wxMessageBox(str, _T("Molby"));
 }
 
@@ -1136,16 +1137,16 @@ MyAppCallback_saveGlobalSettings(void)
 char *
 MyAppCallback_getGlobalSettings(const char *key)
 {
-       wxString wxkey(key, wxConvUTF8);
+       wxString wxkey(key, WX_DEFAULT_CONV);
        wxString wxvalue = wxGetApp().GetDefaultSetting(wxkey);
-       return strdup(wxvalue.mb_str(wxConvUTF8));
+       return strdup(wxvalue.mb_str(WX_DEFAULT_CONV));
 }
 
 void
 MyAppCallback_setGlobalSettings(const char *key, const char *value)
 {
-       wxString wxkey(key, wxConvUTF8);
-       wxString wxvalue(value, wxConvUTF8);
+       wxString wxkey(key, WX_DEFAULT_CONV);
+       wxString wxvalue(value, WX_DEFAULT_CONV);
        wxGetApp().SetDefaultSetting(wxkey, wxvalue);
 }
 
@@ -1201,7 +1202,7 @@ MyAppCallback_showScriptMessage(const char *fmt, ...)
                {
                        wxString str;
                        str.PrintfV(wxString::FromUTF8(fmt).GetData(), ap);
-                       p = strdup((const char *)str.mb_str(wxConvUTF8));
+                       p = strdup((const char *)str.mb_str(WX_DEFAULT_CONV));
                }
 #endif
                if (p != NULL) {
@@ -1266,7 +1267,7 @@ MyAppCallback_getTextWithPrompt(const char *prompt, char *buf, int bufsize)
        wxStaticText *stext;
        wxTextCtrl *tctrl;
        int retval;
-       wxString pstr(prompt, wxConvUTF8);
+       wxString pstr(prompt, WX_DEFAULT_CONV);
        {       //  Vertical sizer containing [prompt, textbox, buttons]
                wxBoxSizer *sizer1;
                sizer1 = new wxBoxSizer(wxVERTICAL);
@@ -1282,7 +1283,7 @@ MyAppCallback_getTextWithPrompt(const char *prompt, char *buf, int bufsize)
                tctrl->SetFocus();
        }
        if (dialog->ShowModal() == wxID_OK) {
-               strncpy(buf, (const char *)(tctrl->GetValue().mb_str(wxConvUTF8)), bufsize - 1);
+               strncpy(buf, (const char *)(tctrl->GetValue().mb_str(WX_DEFAULT_CONV)), bufsize - 1);
                buf[bufsize - 1] = 0;
                retval = 1;
        } else {
@@ -1306,8 +1307,8 @@ MyAppCallback_messageBox(const char *message, const char *title, int flags, int
                case 2: wxicon = wxICON_EXCLAMATION; break;
                default: wxicon = wxICON_INFORMATION; break;
        }
-       wxString wxmessage(message, wxConvUTF8);
-       wxString wxtitle(title, wxConvUTF8);
+       wxString wxmessage(message, WX_DEFAULT_CONV);
+       wxString wxtitle(title, WX_DEFAULT_CONV);
        retval = ::wxMessageBox(wxmessage, wxtitle, wxflags | wxicon);
        return (retval == wxOK ? 1 : 0);
 }
index e0302dc..b1a4091 100644 (file)
  */
 
 #include "MyClipboardData.h"
+#include "MyMBConv.h"
 
 MyClipboardData::MyClipboardData(const char *type):
        wxDataObjectSimple()
 {
-       wxString ftype(type, wxConvUTF8);
+       wxString ftype(type, WX_DEFAULT_CONV);
        wxDataFormat customFormat((const wxChar *)ftype);
        buffer = NULL;
        length = 0;
index b39ee86..2a48981 100644 (file)
@@ -16,6 +16,7 @@
  */
 
 #include "MyDocManager.h"
+#include "MyMBConv.h"
 
 BEGIN_EVENT_TABLE(MyDocManager, wxDocManager)
 EVT_MENU(wxID_SAVE, MyDocManager::OnFileSave)
@@ -34,7 +35,7 @@ MyDocManager::SetDocumentTypesEnabled(const char **extensions, bool flag)
        for (iter = tlist.begin(); iter != tlist.end(); ++iter) {
                int i;
                wxDocTemplate *dt = (wxDocTemplate *)(*iter);
-               const char *p = (const char *)(dt->GetDefaultExtension().mb_str(wxConvUTF8));
+               const char *p = (const char *)(dt->GetDefaultExtension().mb_str(WX_DEFAULT_CONV));
                for (i = 0; extensions[i] != NULL; i++) {
                        if (strcmp(extensions[i], p) == 0) {
                                dt->SetFlags(flag ? wxTEMPLATE_VISIBLE : wxTEMPLATE_INVISIBLE);
index ef6c14d..7ebb2e1 100755 (executable)
@@ -52,6 +52,7 @@
 #include "MyCommand.h"
 #include "MyClipboardData.h"
 #include "MyThread.h"
+#include "MyMBConv.h"
 
 #include "../MolLib/Ruby_bind/Molby_extern.h"
 #include "../MolLib/MD/MDCore.h"
@@ -1159,7 +1160,7 @@ sEraseLogFiles(const wxString& tdir, int status)
        if (success) {
                return 0;
        } else {
-               MyAppCallback_errorMessageBox("Error during deleting log file '%s'", (const char *)dir2.mb_str(wxConvUTF8));
+               MyAppCallback_errorMessageBox("Error during deleting log file '%s'", (const char *)dir2.mb_str(wxConvFile));
                return -1;
        }
 }
@@ -1196,7 +1197,7 @@ MyDocument::OnInvokeAntechamber(wxCommandEvent &event)
        /*  Move to the temporary directory and export the molecule as a pdb  */
        wxString cwd = wxFileName::GetCwd();
        if (!wxFileName::SetCwd(tdir)) {
-               MyAppCallback_errorMessageBox("Cannot move to the temporary directory '%s'", (const char *)tdir.mb_str(wxConvUTF8));
+               MyAppCallback_errorMessageBox("Cannot move to the temporary directory '%s'", (const char *)tdir.mb_str(WX_DEFAULT_CONV));
                return;
        }
        {
@@ -1267,7 +1268,7 @@ MyDocument::OnInvokeAntechamber(wxCommandEvent &event)
 
        if (status == 0) {
                wxString acfile = tdir + wxFileName::GetPathSeparator() + _T("mol.ac");
-               status = MolActionCreateAndPerform(mol, SCRIPT_ACTION("s"), "import_ac", (const char *)acfile.mb_str(wxConvUTF8));
+               status = MolActionCreateAndPerform(mol, SCRIPT_ACTION("s"), "import_ac", (const char *)acfile.mb_str(wxConvFile));
                if (status != 0) {
                        MyAppCallback_errorMessageBox("Cannot import antechamber output.");
                }
@@ -1276,7 +1277,7 @@ MyDocument::OnInvokeAntechamber(wxCommandEvent &event)
        if (calc_charge && status == 0) {
                wxString sqmfile = tdir + wxFileName::GetPathSeparator() + _T("sqm.out");
                if (wxFileName::FileExists(sqmfile)) {
-                       status = MolActionCreateAndPerform(mol, SCRIPT_ACTION("s"), "import_sqmout", (const char *)sqmfile.mb_str(wxConvUTF8));
+                       status = MolActionCreateAndPerform(mol, SCRIPT_ACTION("s"), "import_sqmout", (const char *)sqmfile.mb_str(wxConvFile));
                        if (status != 0) {
                                MyAppCallback_errorMessageBox("Cannot import sqm output.");
                        }
@@ -1285,7 +1286,7 @@ MyDocument::OnInvokeAntechamber(wxCommandEvent &event)
 
        if (status == 0) {
                wxString frcmodfile = tdir + wxFileName::GetPathSeparator() + _T("frcmod");
-               status = MolActionCreateAndPerform(mol, SCRIPT_ACTION("s"), "import_frcmod", (const char *)frcmodfile.mb_str(wxConvUTF8));
+               status = MolActionCreateAndPerform(mol, SCRIPT_ACTION("s"), "import_frcmod", (const char *)frcmodfile.mb_str(wxConvFile));
                if (status != 0) {
                        MyAppCallback_errorMessageBox("Cannot import parmchk output.");
                }
@@ -1507,7 +1508,7 @@ sMoleculePasteboardObjectOfType(const char *type, const void *data, int length)
        if (strcmp(type, "TEXT") == 0) {
                wxTextDataObject *tp = new wxTextDataObject();
                if (data != NULL) {
-                       wxString str((const char *)data, wxConvUTF8, length);
+                       wxString str((const char *)data, WX_DEFAULT_CONV, length);
                        tp->SetText(str);
                }
                return tp;
@@ -1557,7 +1558,7 @@ MoleculeCallback_readFromPasteboard(const char *type, void **dptr, int *length)
                        if (strcmp(type, "TEXT") == 0) {
                                wxTextDataObject *tp = (wxTextDataObject *)dp;
                                wxString str = tp->GetText();
-                               const char *cp = str.mb_str(wxConvUTF8);
+                               const char *cp = str.mb_str(WX_DEFAULT_CONV);
                                len = strlen(cp);
                                p = malloc(len + 1);
                                if (p != NULL) {
@@ -1627,7 +1628,7 @@ MoleculeCallback_displayName(Molecule *mol, char *buf, int bufsize)
   if (doc != NULL) {
     wxString fname;
     doc->GetPrintableName(fname);
-    strncpy(buf, (const char*)fname.mb_str(wxConvUTF8), bufsize - 1);  /*  wxString -> UTF8  */
+    strncpy(buf, (const char*)fname.mb_str(wxConvFile), bufsize - 1);
     buf[bufsize - 1] = 0;
   } else {
     buf[0] = 0;
index ee1be01..b30fdee 100644 (file)
@@ -29,6 +29,7 @@
 
 #include "RubyDialogFrame.h"
 #include "MyApp.h"
+#include "MyMBConv.h"
 
 BEGIN_EVENT_TABLE(RubyDialogFrame, wxDialog)
 //    EVT_TEXT_ENTER(-1, ConsoleFrame::OnEnterPressed)
@@ -144,7 +145,7 @@ RubyDialogFrame::CreateStandardButtons(const char *oktitle, const char *cancelti
                ((wxWindow *)ditems[0])->Show(false);
        } else {
                if (oktitle[0] != 0) {
-                       wxString label1(oktitle, wxConvUTF8);
+                       wxString label1(oktitle, WX_DEFAULT_CONV);
                        ((wxButton *)ditems[0])->SetLabel(label1);
                }
                ((wxWindow *)ditems[0])->Connect(-1, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(RubyDialogFrame::OnDialogItemAction), NULL, this);
@@ -153,7 +154,7 @@ RubyDialogFrame::CreateStandardButtons(const char *oktitle, const char *cancelti
                ((wxWindow *)ditems[1])->Show(false);
        } else {
                if (canceltitle[0] != 0) {
-                       wxString label2(canceltitle, wxConvUTF8);
+                       wxString label2(canceltitle, WX_DEFAULT_CONV);
                        ((wxButton *)ditems[1])->SetLabel(label2);
                }
                ((wxWindow *)ditems[1])->Connect(-1, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(RubyDialogFrame::OnDialogItemAction), NULL, this);
@@ -191,7 +192,7 @@ RubyDialogCallback_setRubyObject(RubyDialog *dref, RubyValue val)
 void
 RubyDialogCallback_setWindowTitle(RubyDialog *dref, const char *title)
 {
-       wxString str(title, wxConvUTF8);
+       wxString str(title, WX_DEFAULT_CONV);
        ((RubyDialogFrame *)dref)->SetLabel(str);
 }
 
@@ -279,7 +280,7 @@ RubyDialogCallback_createItem(RubyDialog *dref, const char *type, const char *ti
        wxWindow *control = NULL;
        wxRect rect, offset;
        RubyDialogFrame *parent = ((RubyDialogFrame *)dref);
-       wxString tstr((title ? title : ""), wxConvUTF8);
+       wxString tstr((title ? title : ""), WX_DEFAULT_CONV);
        bool no_action = false;
        
        rect = wxRectFromRDRect(frame);
@@ -421,7 +422,7 @@ RubyDialogCallback_setFrameOfItem(RDItem *item, RDRect rect)
 void
 RubyDialogCallback_setStringToItem(RDItem *item, const char *s)
 {
-       wxString str(s, wxConvUTF8);
+       wxString str(s, WX_DEFAULT_CONV);
        if (wxDynamicCast((wxWindow *)item, wxTextCtrl) != NULL) {
                ((wxTextCtrl *)item)->SetValue(str);
        }
@@ -437,7 +438,7 @@ RubyDialogCallback_getStringFromItem(RDItem *item, char *buf, int bufsize)
                buf[0] = 0;
                return;
        }
-       strncpy(buf, str.mb_str(wxConvUTF8), bufsize - 1);
+       strncpy(buf, str.mb_str(WX_DEFAULT_CONV), bufsize - 1);
        buf[bufsize - 1] = 0;
 }
 
@@ -450,7 +451,7 @@ RubyDialogCallback_getStringPtrFromItem(RDItem *item)
        } else {
                return NULL;
        }
-       return strdup(str.mb_str(wxConvUTF8));
+       return strdup(str.mb_str(WX_DEFAULT_CONV));
 }
 
 char *
@@ -462,13 +463,13 @@ RubyDialogCallback_titleOfItem(RDItem *item)
        } else {
                str = ((wxWindow *)item)->GetLabel();
        }
-       return strdup(str.mb_str(wxConvUTF8));
+       return strdup(str.mb_str(WX_DEFAULT_CONV));
 }
 
 void
 RubyDialogCallback_setTitleToItem(RDItem *item, const char *s)
 {
-       wxString str(s, wxConvUTF8);
+       wxString str(s, WX_DEFAULT_CONV);
        if (wxDynamicCast((wxWindow *)item, wxTextCtrl) != NULL) {
                ((wxTextCtrl *)item)->SetValue(str);
        } else {
@@ -556,7 +557,7 @@ RubyDialogCallback_countSubItems(RDItem *item)
 int
 RubyDialogCallback_appendSubItem(RDItem *item, const char *s)
 {
-       wxString str(s, wxConvUTF8);
+       wxString str(s, WX_DEFAULT_CONV);
        if (wxDynamicCast((wxWindow *)item, wxChoice) != NULL) {
                return ((wxChoice *)item)->Append(str);
        } else return -1;
@@ -565,7 +566,7 @@ RubyDialogCallback_appendSubItem(RDItem *item, const char *s)
 int
 RubyDialogCallback_insertSubItem(RDItem *item, const char *s, int pos)
 {
-       wxString str(s, wxConvUTF8);
+       wxString str(s, WX_DEFAULT_CONV);
        if (wxDynamicCast((wxWindow *)item, wxChoice) != NULL && pos >= 0 && pos < ((wxChoice *)item)->GetCount()) {
                return ((wxChoice *)item)->Insert(str, pos);
        } else return -1;
@@ -585,7 +586,7 @@ RubyDialogCallback_titleOfSubItem(RDItem *item, int pos)
 {
        if (wxDynamicCast((wxWindow *)item, wxChoice) != NULL && pos >= 0 && pos < ((wxChoice *)item)->GetCount()) {
                wxString str = ((wxChoice *)item)->GetString(pos);
-               return strdup(str.mb_str(wxConvUTF8));
+               return strdup(str.mb_str(WX_DEFAULT_CONV));
        } else return NULL;
 }
 
@@ -621,7 +622,7 @@ RubyDialogCallback_sizeOfString(RDItem *item, const char *s)
                s2 = strchr(s1, '\n');
                if (s2 == NULL)
                        s2 = sfin;
-               wxString str(s1, wxConvUTF8, s2 - s1);
+               wxString str(s1, WX_DEFAULT_CONV, s2 - s1);
                dc.GetTextExtent(str, &w, &h, &descent, &leading);
                if (size.width < w)
                        size.width = w;
@@ -649,10 +650,10 @@ int
 RubyDialogCallback_savePanel(const char *title, const char *dirname, const char *wildcard, char *buf, int bufsize)
 {
        int result;
-       wxString pstr((dirname ? dirname : ""), wxConvUTF8);
-       wxString tstr((title ? title : "Choose a file"), wxConvUTF8);
-       wxString fstr(buf, wxConvUTF8);
-       wxString wstr((wildcard ? wildcard : "All files (*.*)|*.*"), wxConvUTF8);
+       wxString pstr((dirname ? dirname : ""), WX_DEFAULT_CONV);
+       wxString tstr((title ? title : "Choose a file"), WX_DEFAULT_CONV);
+       wxString fstr(buf, WX_DEFAULT_CONV);
+       wxString wstr((wildcard ? wildcard : "All files (*.*)|*.*"), WX_DEFAULT_CONV);
        wxFileDialog *dialog = new wxFileDialog(NULL, tstr, pstr, fstr, wstr, wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
        if (dialog->ShowModal() == wxID_OK) {
                strncpy(buf, dialog->GetPath().mb_str(wxConvFile), bufsize - 1);
@@ -670,11 +671,11 @@ int
 RubyDialogCallback_openPanel(const char *title, const char *dirname, const char *wildcard, char ***array, int for_directories, int multiple_selection)
 {
        int result = 0;
-       wxString pstr((dirname ? dirname : ""), wxConvUTF8);
-       wxString wstr((wildcard ? wildcard : "All files (*.*)|*.*"), wxConvUTF8);
+       wxString pstr((dirname ? dirname : ""), WX_DEFAULT_CONV);
+       wxString wstr((wildcard ? wildcard : "All files (*.*)|*.*"), WX_DEFAULT_CONV);
        int style = wxFD_OPEN | (multiple_selection ? wxFD_MULTIPLE : 0);
        if (for_directories) {
-               wxString tstr((title ? title : "Choose a directory"), wxConvUTF8);
+               wxString tstr((title ? title : "Choose a directory"), WX_DEFAULT_CONV);
                wxDirDialog *dialog = new wxDirDialog(NULL, tstr, pstr);
                if (dialog->ShowModal() == wxID_OK) {
                        *array = (char **)malloc(sizeof(char *));
@@ -683,7 +684,7 @@ RubyDialogCallback_openPanel(const char *title, const char *dirname, const char
                }
                dialog->Destroy();
        } else {
-               wxString tstr((title ? title : "Choose a file"), wxConvUTF8);
+               wxString tstr((title ? title : "Choose a file"), WX_DEFAULT_CONV);
                wxFileDialog *dialog = new wxFileDialog(NULL, tstr, pstr, _T(""), wstr, style);
                if (dialog->ShowModal() == wxID_OK) {
                        *array = (char **)malloc(sizeof(char *));
index 5c78200..d40be73 100755 (executable)
@@ -88,6 +88,7 @@
                29B97325FDCFA39411CA2CEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; };
                8D1107320486CEB800E47090 /* Molby.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Molby.app; sourceTree = BUILT_PRODUCTS_DIR; };
                9E12580E119EC42E00E95DC3 /* docview.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = docview.cpp; path = ../wxSources/docview.cpp; sourceTree = SOURCE_ROOT; };
+               E40DDC6C1435C03E000F0E81 /* MyMBConv.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MyMBConv.h; path = ../wxSources/MyMBConv.h; sourceTree = SOURCE_ROOT; };
                E4299DA60F2A191600780B44 /* ruby_types.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ruby_types.c; sourceTree = "<group>"; };
                E42D8AEF1030193F00C20247 /* MDGraphite.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = MDGraphite.c; sourceTree = "<group>"; };
                E42D8AF01030193F00C20247 /* MDGraphite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MDGraphite.h; sourceTree = "<group>"; };
                                E4A4667410C15B4300E40A9D /* listctrl.cpp */,
                                9E12580E119EC42E00E95DC3 /* docview.cpp */,
                                E4513F530EED72C0009DF1F7 /* MyListCtrl.h */,
+                               E40DDC6C1435C03E000F0E81 /* MyMBConv.h */,
                                E4513F540EED72C0009DF1F7 /* MyListCtrl.cpp */,
                                E4C8CBDD10B83060006C4692 /* MyDocManager.h */,
                                E4C8CBDE10B83060006C4692 /* MyDocManager.cpp */,