Package: tipptrainer
Version: 0.6.0-17.1
Severity: wishlist
Tags: patch

Dear Maintainer,

I wanted to play with some wx code. In the process I port tipptrainer to
wx2.6+ code and drop deprecated wx2.4 features. So I decide to share it
with you.

I did only basic test and compilation was done with wx2.8. The
url/server part must be checked carefully.

Best regards,
Gregory
diff -burNad tipptrainer-0.6.0/src/commonElements.cpp tipptrainer-0.6.0_port_wx_28/src/commonElements.cpp
--- tipptrainer-0.6.0/src/commonElements.cpp	2004-08-08 17:38:02.000000000 +0200
+++ tipptrainer-0.6.0_port_wx_28/src/commonElements.cpp	2011-07-08 21:24:01.621615467 +0200
@@ -35,7 +35,7 @@
   }
 
   if (retval == 0
-      || (url.GetProtocolName() == wxString(_T("file"))
+      || (url.GetScheme() == wxString(_T("file"))
 	  && !((wxFileInputStream*)retval)->Ok())) {
     delete retval;
     return 0;
diff -burNad tipptrainer-0.6.0/src/dirs.cpp tipptrainer-0.6.0_port_wx_28/src/dirs.cpp
--- tipptrainer-0.6.0/src/dirs.cpp	2003-11-23 00:22:30.000000000 +0100
+++ tipptrainer-0.6.0_port_wx_28/src/dirs.cpp	2011-07-08 21:23:58.391829635 +0200
@@ -16,7 +16,7 @@
 
 UrlFile::UrlFile (const wxString& url) {
   if (url.Length() > 0) {
-    wxURL u(wxURL::ConvertFromURI(url));
+    wxURL u(wxURL::Unescape(url));
     Init(u);
   }
 }
@@ -33,17 +33,17 @@
 }
 
 void UrlFile::Init (wxURL& url) {
-  this->protocol = url.GetProtocolName();
+  this->protocol = url.GetScheme();
   if (this->protocol == _T("file")) {
     this->path.Assign(UrlToFileName(url.GetURL()));
   } else {
-    this->server = url.GetHostName();
-    setFullPath(wxURL::ConvertFromURI(url.GetPath()));
+    this->server = url.GetServer();
+    setFullPath(wxURL::Unescape(url.GetPath()));
   }
 }
 
 wxURL* UrlFile::getURL () const {
-  return new wxURL(wxURL::ConvertFromURI(getURLstr()));
+  return new wxURL(wxURL::Unescape(getURLstr()));
 }
 
 wxString UrlFile::getURLstr () const {
@@ -58,7 +58,7 @@
     if (this->server.Length() > 0) {
       return this->protocol + wxString(_T("://"))
 		     + this->server
-         + wxURL::ConvertToValidURI(getFullPath(true));
+         + wxURI(getFullPath(true)).BuildURI();
     } else {
       return _T("");
     }
@@ -101,13 +101,14 @@
    * and that's why wxFileSys::FileNameToURL fails.
    */
   retval += wxURL::ConvertToValidURI(filename.GetVolume()+ wxFileName::GetVolumeSeparator());
+  retval += wxURI(filename.GetVolume()+ wxFileName::GetVolumeSeparator()).BuildURI();
 #endif
-  retval += wxURL::ConvertToValidURI(filename.GetFullPath(wxPATH_UNIX));
+  retval += wxURI(filename.GetFullPath(wxPATH_UNIX)).BuildURI();
   return retval;
 }
 
 wxFileName UrlFile::UrlToFileName (const wxString& url) {
-  wxString fullpath = wxURL::ConvertFromURI(url.Mid(wxString(_T("file:")).Len()));
+  wxString fullpath = wxURL::Unescape(url.Mid(wxString(_T("file:")).Len()));
 #ifdef __WXMSW__
   if (fullpath.compare(0,2,wxString(_T("//"))) == 0) {
     fullpath = fullpath.Mid(2);
diff -burNad tipptrainer-0.6.0/src/inputcontrol.h tipptrainer-0.6.0_port_wx_28/src/inputcontrol.h
--- tipptrainer-0.6.0/src/inputcontrol.h	2004-01-06 21:45:04.000000000 +0100
+++ tipptrainer-0.6.0_port_wx_28/src/inputcontrol.h	2011-07-08 21:07:22.375142826 +0200
@@ -33,8 +33,8 @@
   void setFont (wxFont& newFont);
   inline wxFont* getFont () { return localfont; };
 
-  void setBgColor (wxColor* newColor) { bgcolor= newColor; };
-  wxColor* getBgColor () { return bgcolor; };
+  void setBgColor (const wxColor* newColor) { bgcolor= newColor; };
+  const wxColor* getBgColor () { return bgcolor; };
 
   void setTextColor (wxColor* newColor) { textcolor= newColor; };
   wxColor* getTextColor () { return textcolor; };
@@ -45,7 +45,7 @@
 private:
   wxFont* localfont;
   wxColour* textcolor;
-  wxColour* bgcolor;
+  const wxColour* bgcolor;
 
   wxUChar specialLineEnd;
 
diff -burNad tipptrainer-0.6.0/src/lektionsauswahl.cpp tipptrainer-0.6.0_port_wx_28/src/lektionsauswahl.cpp
--- tipptrainer-0.6.0/src/lektionsauswahl.cpp	2004-07-05 20:18:12.000000000 +0200
+++ tipptrainer-0.6.0_port_wx_28/src/lektionsauswahl.cpp	2011-07-08 21:13:19.294253860 +0200
@@ -45,7 +45,6 @@
 			  _("Built-in lessons"), false);
   this->notebook->AddPage(getAddonLessonPage(this->notebook),
 			  _("Add-on lessons"), false);
-  wxNotebookSizer* nbs = new wxNotebookSizer(notebook);
 
   //create and add the buttons
   this->btnOk = new wxButton(this, B1, _("Start lesson"));
@@ -55,7 +54,7 @@
   buttonSizer->Add(this->btnCancel,1,wxEXPAND|wxALIGN_CENTER);
 
   wxBoxSizer* dialogSizer = new wxBoxSizer(wxVERTICAL);
-  dialogSizer->Add(nbs,1,wxEXPAND);
+  dialogSizer->Add(notebook,1,wxEXPAND);
   dialogSizer->Add(buttonSizer,0,wxALL|wxALIGN_CENTRE,10);
 
   SetSizer(dialogSizer);
diff -burNad tipptrainer-0.6.0/src/optionen.cpp tipptrainer-0.6.0_port_wx_28/src/optionen.cpp
--- tipptrainer-0.6.0/src/optionen.cpp	2004-08-08 16:04:31.000000000 +0200
+++ tipptrainer-0.6.0_port_wx_28/src/optionen.cpp	2011-07-08 21:13:59.320339880 +0200
@@ -41,7 +41,6 @@
 			  _("Localization"), false);
   notebook->AddPage(getDataLocationPage(notebook),
 			  _("Data location"), false);
-  wxNotebookSizer* nbs = new wxNotebookSizer(notebook);
 
   /* now the buttons
    */
@@ -52,7 +51,7 @@
 		   10,wxALIGN_CENTER);
 
   wxBoxSizer* dialogSizer = new wxBoxSizer(wxVERTICAL);
-  dialogSizer->Add(nbs,1,wxEXPAND);
+  dialogSizer->Add(notebook,1,wxEXPAND);
   dialogSizer->Add(buttonSizer,0,wxALIGN_CENTER|wxALL,10);
 
   SetSizer(dialogSizer);

Reply via email to