From 34a730f89c1a620b8d4a4eaaae0afc5bcaa747f6 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 7 Nov 2021 16:36:43 +0000 Subject: [PATCH] Small cleanup of wxGenericTreeCtrl-specific parts of the sample Use HAS_GENERIC_TREECTRL for testing whether we're actually using it or not instead of checking for USE_GENERIC_TREECTRL and then port names with a native control, which was done inconsistently, as it included wxQt in one place, but not the other one. Also avoid repeating CreateButtonsImageList() declaration twice, as this resulted in having unbalanced curly braces in this file, which was just unpleasant. No real changes. --- samples/treectrl/treetest.cpp | 7 +++---- samples/treectrl/treetest.h | 9 +++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/samples/treectrl/treetest.cpp b/samples/treectrl/treetest.cpp index ff584dbaf6..38bf36bcc6 100644 --- a/samples/treectrl/treetest.cpp +++ b/samples/treectrl/treetest.cpp @@ -748,7 +748,7 @@ void MyFrame::OnToggleAlternateStates(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnToggleButtons(wxCommandEvent& WXUNUSED(event)) { -#if USE_GENERIC_TREECTRL || !defined(__WXMSW__) +#ifdef HAS_GENERIC_TREECTRL if ( wxGetApp().ShowButtons() ) { m_treeCtrl->CreateButtonsImageList(-1); @@ -1064,9 +1064,9 @@ void MyTreeCtrl::CreateStateImageList(bool del) AssignStateImageList(states); } -#if USE_GENERIC_TREECTRL || (!defined(__WXMSW__) && !defined(__WXQT__)) void MyTreeCtrl::CreateButtonsImageList(int size) { +#ifdef HAS_GENERIC_TREECTRL if ( size == -1 ) { SetButtonsImageList(NULL); @@ -1112,8 +1112,7 @@ void MyTreeCtrl::CreateButtonsImageList(int size) AssignButtonsImageList(images); #else -void MyTreeCtrl::CreateButtonsImageList(int WXUNUSED(size)) -{ + wxUnusedVar(size); #endif } diff --git a/samples/treectrl/treetest.h b/samples/treectrl/treetest.h index 43439ea8d5..865a39d1fa 100644 --- a/samples/treectrl/treetest.h +++ b/samples/treectrl/treetest.h @@ -8,6 +8,8 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// +// This can be defined to 1 to force using wxGenericTreeCtrl even on the +// platforms where the native controls would normally be used (wxMSW and wxQt). #define USE_GENERIC_TREECTRL 0 #if USE_GENERIC_TREECTRL @@ -18,6 +20,13 @@ #endif #endif +// This one is defined if we're actually using the generic control, either +// because it was explicitly requested above or because there is no other one +// on this platform anyhow. +#if USE_GENERIC_TREECTRL || (!defined(__WXMSW__) && !defined(__WXQT__)) + #define HAS_GENERIC_TREECTRL +#endif + // Define a new application type class MyApp : public wxApp {