[vos-d] Terangreal and Unicode?

2005-09-04 Thread Reed Hedges

I guess wxgtk 2.6 in Debian is built in Unicode mode, and while I
noticed some random bits and pieces of TerAngreal with stuff in #ifdef
wxUSE_UNICODE conditionals, and some wxStrings are converted with
wxString::mb_str(), it's generally incomplete.

If build in Unicode mode, wxChar is a wchar_t, otherwise it's an 8 bit
char.  Wx provides some objects to convert between char* in various
encodings, and wxChar (whichever of the above it might be).  So I think
to create a wxString from an ASCII char* you do this:

  const char* cstr = "foo";
  wxString wxstr(cstr, wxConvUTF8);

In Unicode mode, wxString uses the predefined wxConvUTF8 object to
convert cstr from UTF8 (ASCII) to Unicode.  In non-unicode mode it just
uses cstr, or maybe wxConvUTF8 actally does no conversion... whatever.

And to get a UTF8 string:

  cstr = (const char*) wxstr.mb_str();

Again, in Unicode mode, mb_str() converts to ASCII, while in non-unicode
mode it just returns the ASCII string.  Maybe you need to do this, not
100% certain yet:

  cstr = (const char*) wxstr.mb_str(wxConvUTF8);

And of course string literals have different syntax, wx provides the wxT
macro to do the right thing depending on the mode (though for the most
part we are already using that in terangreal).

I made a few changes along those lines and got wxterangreal to build but
now it crashes in CS, as does wxtest, in csDriverDBReader.

Has anyone else been hacking on Terangreal to build in unicode mode?
Anyone want my patch while I figure out why it's crashing? (I suspect
that some combination of my graphics hardware and X configuration is
revealing the crashing bug)  I have a bunch of other modifications I
made to terangreal mixed in at the moment, though, I'd have to seperate
them.

One thing we will need to do is add support for different encodings to
things like the talkative message strings and property values.  Or maybe
just change them to always use unicode?


Reed



___
vos-d mailing list
vos-d@interreality.org
http://www.interreality.org/cgi-bin/mailman/listinfo/vos-d


[vos-d] Re: Terangreal and Unicode?

2005-09-04 Thread Lalo Martins
And so says Reed Hedges on 05/09/05 09:44...
> Has anyone else been hacking on Terangreal to build in unicode mode?
actually, I have (see the thread "can't compile ter'angreal from cvs").
With help from Peter and a lot of back-bending over wx documentation,
this is what I came up with.  I didn't submit a patch earlier because
it's now segfaulting to me - but vostest segfaults identically, so it's
probably not wxRelated().

best,
   Lalo Martins
--
  So many of our dreams at first seem impossible,
   then they seem improbable, and then, when we
   summon the will, they soon become inevitable.
--
http://www.exoweb.net/  mailto:[EMAIL PROTECTED]
GNU: never give up freedom http://www.gnu.org/
? +build
? Makefile.in
? aclocal.m4
? autom4te.cache
? config.guess
? config.sub
? configure
? depcomp
? install-sh
? ltmain.sh
? missing
? unicode.diff
? vos-browser-config.h.in
? apps/Makefile.in
? apps/terangreal/Makefile.in
Index: apps/terangreal/ter_mainframe.cc
===
RCS file: /home/cvsroot/vos-browser/apps/terangreal/ter_mainframe.cc,v
retrieving revision 1.8
diff -u -r1.8 ter_mainframe.cc
--- apps/terangreal/ter_mainframe.cc	13 Aug 2005 21:00:41 -	1.8
+++ apps/terangreal/ter_mainframe.cc	5 Sep 2005 02:36:23 -
@@ -115,8 +115,8 @@
 mb->Append(winmenu, wxT("Windows"));
 
 wxMenu* helpmenu = new wxMenu();
-helpmenu->Append(wxID_ABOUT, "About...");
-helpmenu->Append(wxID_HELP, "Help...");
+helpmenu->Append(wxID_ABOUT, wxT("About..."));
+helpmenu->Append(wxID_HELP, wxT("Help..."));
 mb->Append(helpmenu, wxT("Help"));
 
 SetMenuBar(mb);
@@ -124,7 +124,7 @@
 
 void TerWxMainFrame::constructHelp()
 {
-helpdialog = new wxDialog(0 , -1, "wxTer'Angreal Keys",
+helpdialog = new wxDialog(0 , -1, wxT("wxTer'Angreal Keys"),
 wxDefaultPosition, wxSize(520, 220));
 int w, h;
 helpdialog->GetClientSize(&w, &h);
@@ -147,7 +147,7 @@
 
 void TerWxMainFrame::constructAbout()
 {
-aboutdialog = new wxDialog(0 , -1, "About wxTer'Angreal",
+aboutdialog = new wxDialog(0 , -1, wxT("About wxTer'Angreal"),
wxDefaultPosition, wxSize(500, 200));
 int w, h;
 aboutdialog->GetClientSize(&w, &h);
@@ -580,7 +580,7 @@
 
 void TerWxMainFrame::setStatus(const std::string& s)
 {
-status->SetLabel(s.c_str());
+status->SetLabel(wxString(s.c_str(), *wxConvCurrent));
 }
 
 void TerWxMainFrame::warpAvatarHome(wxCommandEvent&)
Index: apps/terangreal/ter_prefs.cc
===
RCS file: /home/cvsroot/vos-browser/apps/terangreal/ter_prefs.cc,v
retrieving revision 1.2
diff -u -r1.2 ter_prefs.cc
--- apps/terangreal/ter_prefs.cc	9 Mar 2005 08:13:24 -	1.2
+++ apps/terangreal/ter_prefs.cc	5 Sep 2005 02:36:23 -
@@ -83,16 +83,16 @@
 {
 try {
 avatar.assign(ta, true);
-nickentry->SetValue(avatar->getNick().c_str());
+nickentry->SetValue(wxString(avatar->getNick().c_str(), *wxConvCurrent));
 
 double x, y, z, r;
 
 avatar->getObject3D()->getOrientationHT(x, y, z, r);
 
-rotx->SetValue(wxString::Format("%f", x));
-roty->SetValue(wxString::Format("%f", y));
-rotz->SetValue(wxString::Format("%f", z));
-rotr->SetValue(wxString::Format("%f", r));
+rotx->SetValue(wxString::Format(wxT("%f"), x));
+	roty->SetValue(wxString::Format(wxT("%f"), y));
+	rotz->SetValue(wxString::Format(wxT("%f"), z));
+	rotr->SetValue(wxString::Format(wxT("%f"), r));
 } catch(std::runtime_error) {
 }
 }
@@ -105,57 +105,56 @@
 void TerPrefs::setNick(wxCommandEvent&)
 {
 try {
-#if wxUSE_UNICODE
-avatar->setNick(nickentry->GetValue().mb_str().data());
-#else
 avatar->setNick(nickentry->GetValue().mb_str());
-#endif
 } catch(std::runtime_error e) {
 LOG("terprefs", 3, "Exception setting nick: " << e.what());
-wxMessageBox(e.what(), wxT(""), wxICON_EXCLAMATION, this);
+wxMessageBox(wxString(e.what(), *wxConvCurrent),
+		 wxT(""), wxICON_EXCLAMATION, this);
 }
 }
 
 void TerPrefs::setAvatarModel(wxCommandEvent&)
 {
-wxString sel = wxFileSelector("Please select an avatar to load", "", "",
-  "",
-  "Quake MD2 (*.md2)|*.md2|3D Studio (*.3ds)|*.3ds",
+wxString sel = wxFileSelector(wxT("Please select an avatar to load"),
+  wxT(""), wxT(""), wxT(""),
+  wxT("Quake MD2 (*.md2)|*.md2|3D Studio (*.3ds)|*.3ds"),
   wxOPEN | wxFILE_MUST_EXIST);
 if(!sel.empty()) {
 try {
 vRef m = meta_cast(avatar->getObject3D());
-m->setModelToFile(sel.c_str());
+m->setModelToFile(sel.mb_str());
 } catch(std::runtime_error& e) {
 LOG("te

Re: [vos-d] Terangreal and Unicode?

2005-09-04 Thread res
On 05.09.2005 03:44, Reed Hedges wrote:
> I made a few changes along those lines and got wxterangreal to build but
> now it crashes in CS, as does wxtest, in csDriverDBReader.

A backtrace may be helpful.

-f.r.



signature.asc
Description: OpenPGP digital signature
___
vos-d mailing list
vos-d@interreality.org
http://www.interreality.org/cgi-bin/mailman/listinfo/vos-d