tags 748634 + patch

Dear Olly,

In first place, thanks for your sugestions and time.

After
 cleaning up comments and reconsidering all your recommendations I've 
recompiled and tested with versions 2.8 and 3.0 of the library (both 
available in testing) and it works fine. I've attached a new patch with 
comments removed, versions verified and null checks in place.

wxWX2MBbuf is not wxString but a dual type macro so I have used casting instead 
of your proposal.

The only doubt I hold is with function wxImage.ConvertAlphaToMask():
    In 2.8 code works well with package included tiles (a bmp without Alpha 
returns true). However, it fails when calling this function in 3.0 and 
previous img.HasAlpha() check is required.
    I guess it's an wxwidgets behavior change.

Anyway, now migration to wxwidgets3.0 is a step nearer. 


Cheers,
  
David
diff -Nru --from-file orig/chipw-2.0.6/ orig/chipw-2.0.6/debian/changelog chipw-2.0.6/debian/changelog
--- orig/chipw-2.0.6/debian/changelog	2011-12-16 14:50:53.000000000 +0100
+++ chipw-2.0.6/debian/changelog	2014-06-03 19:31:39.176154934 +0200
@@ -1,3 +1,10 @@
+chipw (2.0.6-1.2) unstable; urgency=low
+
+  * Non-maintainer upload
+  * Update to use wxWidgets3.0
+
+ -- David <deiv...@yahoo.es> Tue, 3 Jun 2014 19:31:39 +0200
+
 chipw (2.0.6-1.1) unstable; urgency=low
 
   * Non-maintainer upload at maintainer's request.
diff -Nru --from-file orig/chipw-2.0.6/ orig/chipw-2.0.6/debian/control chipw-2.0.6/debian/control
--- orig/chipw-2.0.6/debian/control	2011-12-16 14:47:25.000000000 +0100
+++ chipw-2.0.6/debian/control	2014-06-03 01:28:04.853789962 +0200
@@ -2,7 +2,7 @@
 Section: games
 Priority: optional
 Maintainer: Luke Faraone <l...@faraone.cc>
-Build-Depends: cdbs, debhelper (>= 7), libwxgtk2.8-dev
+Build-Depends: cdbs, debhelper (>= 7), libwxgtk3.0-dev
 DM-Upload-Allowed: yes
 Standards-Version: 3.9.0
 Homepage: http://www.microstupidity.com/chipw/
diff -Nru --from-file orig/chipw-2.0.6/ orig/chipw-2.0.6/src/leveleditview.cpp chipw-2.0.6/src/leveleditview.cpp
--- orig/chipw-2.0.6/src/leveleditview.cpp	2011-12-15 16:40:24.000000000 +0100
+++ chipw-2.0.6/src/leveleditview.cpp	2014-06-03 19:27:04.847603711 +0200
@@ -210,10 +210,15 @@
 void LevelEditView::OnChangeFilename() {
     if(GetDocument() != NULL && GetFrame() != NULL) {
         wxString name;
-        GetDocument()->GetPrintableName(name);
         wxString title = wxT("Chip's Workshop");
-        if(name)
+#if wxCHECK_VERSION(2,8,5)
+        name=GetDocument()->GetUserReadableName();
+        title += wxT(" - ") + name;
+#else
+        GetDocument()->GetPrintableName(name);
+        if(!name.empty())
             title += wxT(" - ") + name;
+#endif
         if(level != NULL && !level->title.empty())
             title += wxT(" (") + wxString(level->title.c_str(), wxConvISO8859_1) + wxT(")");
         if(GetFrame()->IsKindOf(CLASSINFO(wxTopLevelWindow)))
@@ -343,7 +348,7 @@
                 std::string title = level->title;
                 {
                     const wxWX2MBbuf str = dlg.title.mb_str(wxConvISO8859_1);
-                    if(str != NULL)
+                    if((const void *) str != NULL)
                         title = str;
                     else
                         wxLogError(wxT("Failed to set level title."));
@@ -351,7 +356,7 @@
                 std::string psw = level->psw;
                 {
                     const wxWX2MBbuf str = dlg.psw.mb_str(wxConvISO8859_1);
-                    if(str != NULL)
+                    if((const void *) str != NULL)
                         psw = str;
                     else
                         wxLogError(wxT("Failed to set level password."));
@@ -369,7 +374,7 @@
                 std::string hint = level->hint;
                 {
                     const wxWX2MBbuf str = dlg.hint.mb_str(wxConvISO8859_1);
-                    if(str != NULL)
+                    if ((const void *) str != NULL)
                         hint = str;
                     else
                         wxLogError(wxT("Failed to set level hint."));
@@ -827,7 +832,11 @@
         wxRegion region(x1, y1, selw * GetTileW(), selh * GetTileH());
         region.Xor(x2, y2, w * GetTileW(), h * GetTileH());
         wxDC* dc = NewClientDC();
+#if wxCHECK_VERSION(2,8,11)
+        dc->SetDeviceClippingRegion(region);
+#else
         dc->SetClippingRegion(region);
+#endif
         DrawSelection(dc, 0, 0, 32, 32);
         delete dc;
     }
@@ -896,7 +905,11 @@
 
 void LevelEditView::DrawSelection(wxDC* dc, wxUint32 x, wxUint32 y, wxUint32 w, wxUint32 h) {
     if(x < 32 && y < 32 && w > 0 && h > 0) {
+#if wxCHECK_VERSION(2,9,0)
+        wxRasterOperationMode origfunc = dc->GetLogicalFunction();
+#else
         int origfunc = dc->GetLogicalFunction();
+#endif
         dc->SetLogicalFunction(wxINVERT);
         dc->SetPen(*wxTRANSPARENT_PEN);
         dc->SetBrush(*wxBLACK_BRUSH);
@@ -963,7 +976,11 @@
                 continue;
             }
             if(tilelist != NULL && tilelist->IsSelected(tileselgrid[x + TILESEL_WIDTH * y])) {
-                int origfunc = dc->GetLogicalFunction();
+#if wxCHECK_VERSION(2,9,0)
+                wxRasterOperationMode origfunc = dc->GetLogicalFunction();
+#else
+		int origfunc = dc->GetLogicalFunction();
+#endif
                 dc->SetLogicalFunction(wxINVERT);
                 dc->SetPen(*wxTRANSPARENT_PEN);
                 dc->SetBrush(*wxBLACK_BRUSH);
diff -Nru --from-file orig/chipw-2.0.6/ orig/chipw-2.0.6/src/listmenumgr.cpp chipw-2.0.6/src/listmenumgr.cpp
--- orig/chipw-2.0.6/src/listmenumgr.cpp	2011-12-15 16:40:24.000000000 +0100
+++ chipw-2.0.6/src/listmenumgr.cpp	2014-06-03 18:15:16.851527122 +0200
@@ -81,7 +81,12 @@
             wxMenuItem* item = *itemit;
             if(item == NULL)
                 continue;
-            item->SetText(GetItemLabel(i, newitems, emptytext));
+            
+#if wxCHECK_VERSION(2,8,5)
+            item->SetItemLabel(GetItemLabel(i, newitems, emptytext));
+#else
+            item->SetText(GetItemLabel(i,newitems,emptytext));
+#endif
             item->Enable((unsigned int) i < newitems.size());
         }
         // Add items if the length has increased.
diff -Nru --from-file orig/chipw-2.0.6/ orig/chipw-2.0.6/src/tileset.cpp chipw-2.0.6/src/tileset.cpp
--- orig/chipw-2.0.6/src/tileset.cpp	2011-12-15 16:40:24.000000000 +0100
+++ chipw-2.0.6/src/tileset.cpp	2014-06-03 00:46:18.469299483 +0200
@@ -210,11 +210,11 @@
     if(!CheckMaxSize(size, size))
         return false;
     // Avoiding alpha simplifies the code, and it doesn't seem to work well in wxWidgets anyway.
-    if(!img.ConvertAlphaToMask()) {
+    if(img.HasAlpha() && !img.ConvertAlphaToMask()) {
         wxLogError(wxT("Failed to generate image mask."));
         return false;
     }
-    if(CheckOk(img2) && !img2.ConvertAlphaToMask()) {
+    if(CheckOk(img2) && img2.HasAlpha() && !img2.ConvertAlphaToMask()) {
         wxLogError(wxT("Failed to generate secondary image mask."));
         return false;
     }

Reply via email to