ae35e5c
From 66ae9a6f2ac526d80559967cda428cd48e5859ee Mon Sep 17 00:00:00 2001
ae35e5c
From: dghart <dghart@users.sourceforge.net>
ae35e5c
Date: Sat, 12 Feb 2022 15:45:54 +0000
ae35e5c
Subject: [PATCH] Compilation fixes for wxWidgets 3.1.6
ae35e5c
ae35e5c
Workarounds for the addition of wxBitmapBundle.
ae35e5c
---
ae35e5c
 Devices.cpp    |  4 ++++
ae35e5c
 MyDirs.cpp     |  9 +++++++++
ae35e5c
 MyTreeCtrl.cpp | 49 ++++++++++++++++++++++++++++++++++++++-----------
ae35e5c
 3 files changed, 51 insertions(+), 11 deletions(-)
ae35e5c
ae35e5c
diff --git a/Devices.cpp b/Devices.cpp
ae35e5c
index 5b8cfe9..dc77cdc 100644
ae35e5c
--- a/Devices.cpp
ae35e5c
+++ b/Devices.cpp
ae35e5c
@@ -210,7 +210,11 @@ wxString bitmap; config->Read(Rootname+subgrp+wxT("/Bitmap"), &bitmap);
ae35e5c
 wxString tooltip; config->Read(Rootname+subgrp+wxT("/Tooltip"), &tooltip);
ae35e5c
 
ae35e5c
 bitmap = BITMAPSDIR + bitmap;
ae35e5c
+#if wxVERSION_NUMBER > 3105
ae35e5c
+Create(MyFrame::mainframe->panelette, -1, wxBitmapBundle::FromBitmap(bitmap), wxDefaultPosition, wxDefaultSize, wxNO_BORDER);
ae35e5c
+#else
ae35e5c
 Create(MyFrame::mainframe->panelette, -1, bitmap, wxDefaultPosition, wxDefaultSize, wxNO_BORDER);
ae35e5c
+#endif
ae35e5c
 SetToolTip(tooltip);
ae35e5c
 }
ae35e5c
 
ae35e5c
diff --git a/MyDirs.cpp b/MyDirs.cpp
ae35e5c
index 68f41a8..f370d5b 100644
ae35e5c
--- a/MyDirs.cpp
ae35e5c
+++ b/MyDirs.cpp
ae35e5c
@@ -522,10 +522,19 @@ for (size_t n=0; n < count; ++n)
ae35e5c
                                                                                                         array->Item(n)->tooltip, wxITEM_NORMAL);
ae35e5c
      else
ae35e5c
       { if (array->Item(n)->bitmaplocation.AfterLast(('/')) == wxT("MyDocuments.xpm")) // If Documents and the label is empty, supply a default
ae35e5c
+#if wxVERSION_NUMBER > 3105
ae35e5c
+          toolBar->AddTool(IDM_TOOLBAR_bmfirst+n, label.empty() ? wxString(_("Documents")) : label,wxBitmapBundle::FromBitmap(array->Item(n)->bitmaplocation),
ae35e5c
+                                                                                                        array->Item(n)->tooltip, wxITEM_NORMAL);
ae35e5c
+         else                                                                                                    
ae35e5c
+          toolBar->AddTool(IDM_TOOLBAR_bmfirst + n, label, wxBitmapBundle::FromBitmap(array->Item(n)->bitmaplocation), array->Item(n)->tooltip, wxITEM_NORMAL);
ae35e5c
+
ae35e5c
+#else
ae35e5c
           toolBar->AddTool(IDM_TOOLBAR_bmfirst+n, label.empty() ? wxString(_("Documents")) : label, array->Item(n)->bitmaplocation,
ae35e5c
+
ae35e5c
                                                                                                         array->Item(n)->tooltip, wxITEM_NORMAL);
ae35e5c
          else                                                                                                    
ae35e5c
           toolBar->AddTool(IDM_TOOLBAR_bmfirst + n, label, array->Item(n)->bitmaplocation, array->Item(n)->tooltip, wxITEM_NORMAL);
ae35e5c
+#endif //wxVERSION_NUMBER > 3105
ae35e5c
       }
ae35e5c
   }
ae35e5c
 
ae35e5c
diff --git a/MyTreeCtrl.cpp b/MyTreeCtrl.cpp
ae35e5c
index bc1b607..735b6cf 100644
ae35e5c
--- a/MyTreeCtrl.cpp
ae35e5c
+++ b/MyTreeCtrl.cpp
ae35e5c
@@ -1336,7 +1336,27 @@ void MyTreeCtrl::PaintLevel(wxGenericTreeItem *item, wxDC &dc, int level, int &y
ae35e5c
                     dc.DrawLine(3, y_mid, x - 5, y_mid);
ae35e5c
                 dc.DrawLine(x + 5, y_mid, x + m_spacing, y_mid);
ae35e5c
             }
ae35e5c
+#if wxVERSION_NUMBER > 3105
ae35e5c
+            if ( m_imagesButtons.HasImages() )
ae35e5c
+            {
ae35e5c
+                // draw the image button here
ae35e5c
+                int image_h = 0,  image_w = 0;
ae35e5c
+                int image = item->IsExpanded() ? wxTreeItemIcon_Expanded
ae35e5c
+                                               : wxTreeItemIcon_Normal;
ae35e5c
+                if ( item->IsSelected() )
ae35e5c
+                    image += wxTreeItemIcon_Selected - wxTreeItemIcon_Normal;
ae35e5c
+
ae35e5c
+                wxImageList* const
ae35e5c
+                    imageListButtons = m_imagesButtons.GetImageList();
ae35e5c
+                imageListButtons->GetSize(image, image_w, image_h);
ae35e5c
+                int xx = x - image_w/2;
ae35e5c
+                int yy = y_mid - image_h/2;
ae35e5c
 
ae35e5c
+                wxDCClipper clip(dc, xx, yy, image_w, image_h);
ae35e5c
+                imageListButtons->Draw(image, dc, xx, yy,
ae35e5c
+                                         wxIMAGELIST_DRAW_TRANSPARENT);
ae35e5c
+            }
ae35e5c
+#else // !wxVERSION_NUMBER > 3105
ae35e5c
             if (m_imageListButtons != NULL)
ae35e5c
             {
ae35e5c
                 // draw the image button here
ae35e5c
@@ -1352,9 +1372,10 @@ void MyTreeCtrl::PaintLevel(wxGenericTreeItem *item, wxDC &dc, int level, int &y
ae35e5c
                                          wxIMAGELIST_DRAW_TRANSPARENT);
ae35e5c
                 dc.DestroyClippingRegion();
ae35e5c
             }
ae35e5c
-
ae35e5c
+#endif
ae35e5c
     }
ae35e5c
   }
ae35e5c
+
ae35e5c
            else // no custom buttons
ae35e5c
             {
ae35e5c
                 static const int wImage = 9;
ae35e5c
@@ -1495,15 +1516,17 @@ if (headerwindow->IsHidden(i)) continue;                                  // //
ae35e5c
       image = NO_IMAGE;  // //item->GetImage(i);
ae35e5c
       }
ae35e5c
   
ae35e5c
-  if(image != NO_IMAGE) 
ae35e5c
-   {
ae35e5c
-      if(m_imageListNormal) {
ae35e5c
-    m_imageListNormal->GetSize(image, image_w, image_h);
ae35e5c
-    image_w += 4;
ae35e5c
-                          }
ae35e5c
-      else {
ae35e5c
-    image = NO_IMAGE;
ae35e5c
-          }
ae35e5c
+    if (image != NO_IMAGE) 
ae35e5c
+     {
ae35e5c
+#if wxVERSION_NUMBER > 3105
ae35e5c
+      if (GetImageList()) {
ae35e5c
+          GetImageList()->GetSize(image, image_w, image_h);
ae35e5c
+#else
ae35e5c
+      if (m_imageListNormal) {
ae35e5c
+        m_imageListNormal->GetSize(image, image_w, image_h);
ae35e5c
+#endif // wxVERSION_NUMBER > 3105
ae35e5c
+        image_w += 4;
ae35e5c
+      } else { image = NO_IMAGE;  }
ae35e5c
    }
ae35e5c
 
ae35e5c
   // honor text alignment
ae35e5c
@@ -1581,8 +1604,12 @@ if (headerwindow->IsHidden(i)) continue;                                  // //
ae35e5c
           item->GetY() + extraH, clip_width,
ae35e5c
           total_h);
ae35e5c
 
ae35e5c
-  if(image != NO_IMAGE) {
ae35e5c
+  if (image != NO_IMAGE) {
ae35e5c
+#if wxVERSION_NUMBER > 3105
ae35e5c
+      GetImageList()->Draw(image, dc, image_x,
ae35e5c
+#else
ae35e5c
       m_imageListNormal->Draw(image, dc, image_x,
ae35e5c
+#endif
ae35e5c
              item->GetY() +((total_h > image_h)?
ae35e5c
                 ((total_h-image_h)/2):0),
ae35e5c
              wxIMAGELIST_DRAW_TRANSPARENT);
ae35e5c
-- 
ae35e5c
2.37.1
ae35e5c