From a059061eb7085fd30e66060700f9b687dce73a5f Mon Sep 17 00:00:00 2001 From: Blake-Madden Date: Wed, 20 Dec 2023 11:23:59 -0500 Subject: [PATCH] Replace wxDECLARE_NO_COPY_CLASS with deleted functions in samples Use standard C++11 way of making classes non-copyable instead of wx-specific macro. Closes #24150. --- samples/collpane/collpane.cpp | 12 ++++++++---- samples/dataview/mymodels.h | 4 ++-- samples/debugrpt/debugrpt.cpp | 7 ++++--- samples/dialogs/dialogs.cpp | 7 ++++--- samples/dialogs/dialogs.h | 3 ++- samples/docview/doc.h | 14 +++++++++----- samples/docview/docview.h | 3 ++- samples/docview/view.h | 4 ++-- samples/grid/griddemo.cpp | 11 ++++++----- samples/htlbox/htlbox.cpp | 3 ++- samples/html/test/test.cpp | 3 ++- samples/image/image.cpp | 8 ++++---- samples/ipc/baseserver.cpp | 4 ++-- samples/listctrl/listtest.h | 13 +++++++------ samples/mdi/mdi.h | 8 ++++---- samples/opengl/isosurf/isosurf.h | 3 ++- samples/opengl/penguin/penguin.h | 3 ++- samples/splitter/splitter.cpp | 16 ++++++++++------ samples/widgets/itemcontainer.cpp | 4 ++-- samples/widgets/widgets.cpp | 4 ++-- 20 files changed, 78 insertions(+), 56 deletions(-) diff --git a/samples/collpane/collpane.cpp b/samples/collpane/collpane.cpp index 69f7ec8d0e..7c6e0d5a1a 100644 --- a/samples/collpane/collpane.cpp +++ b/samples/collpane/collpane.cpp @@ -71,16 +71,19 @@ class MyApp: public wxApp { public: MyApp() { } + MyApp(const MyApp&) = delete; + MyApp& operator=(const MyApp&) = delete; virtual bool OnInit() override; - - wxDECLARE_NO_COPY_CLASS(MyApp); }; class MyFrame: public wxFrame { public: MyFrame(); + MyFrame(const MyFrame&) = delete; + MyFrame& operator=(const MyFrame&) = delete; + virtual ~MyFrame(); // Menu commands @@ -103,13 +106,15 @@ private: wxBoxSizer *m_paneSizer; wxDECLARE_EVENT_TABLE(); - wxDECLARE_NO_COPY_CLASS(MyFrame); }; class MyDialog : public wxDialog { public: MyDialog(wxFrame *parent); + MyDialog(const MyDialog&) = delete; + MyDialog& operator=(const MyDialog&) = delete; + void OnToggleStatus(wxCommandEvent& WXUNUSED(ev)); void OnAlignButton(wxCommandEvent& WXUNUSED(ev)); void OnPaneChanged(wxCollapsiblePaneEvent& event); @@ -119,7 +124,6 @@ private: wxGridSizer *m_paneSizer; wxDECLARE_EVENT_TABLE(); - wxDECLARE_NO_COPY_CLASS(MyDialog); }; diff --git a/samples/dataview/mymodels.h b/samples/dataview/mymodels.h index 40f86e6666..f4467de67d 100644 --- a/samples/dataview/mymodels.h +++ b/samples/dataview/mymodels.h @@ -245,6 +245,8 @@ class MyIndexListModel : public wxDataViewIndexListModel { public: MyIndexListModel() { } + MyIndexListModel(const MyIndexListModel&) = delete; + MyIndexListModel& operator=(const MyIndexListModel&) = delete; void Fill(const wxArrayString& strings) { @@ -266,8 +268,6 @@ public: private: wxArrayString m_strings; - - wxDECLARE_NO_COPY_CLASS(MyIndexListModel); }; enum ModelFlags diff --git a/samples/debugrpt/debugrpt.cpp b/samples/debugrpt/debugrpt.cpp index 89f7bb2eef..9dcced128f 100644 --- a/samples/debugrpt/debugrpt.cpp +++ b/samples/debugrpt/debugrpt.cpp @@ -157,6 +157,8 @@ class MyFrame : public wxFrame { public: MyFrame(); + MyFrame(const MyFrame&) = delete; + MyFrame& operator=(const MyFrame&) = delete; private: void OnListLoadedDLLs(wxCommandEvent& event); @@ -185,7 +187,6 @@ private: // number of lines drawn in OnPaint() int m_numLines; - wxDECLARE_NO_COPY_CLASS(MyFrame); wxDECLARE_EVENT_TABLE(); }; @@ -202,6 +203,8 @@ class MyApp : public wxApp public: // call wxHandleFatalExceptions here MyApp(); + MyApp(const MyApp&) = delete; + MyApp& operator=(const MyApp&) = delete; // create our main window here virtual bool OnInit() override; @@ -219,8 +222,6 @@ public: private: bool m_uploadReport; - - wxDECLARE_NO_COPY_CLASS(MyApp); }; wxIMPLEMENT_APP(MyApp); diff --git a/samples/dialogs/dialogs.cpp b/samples/dialogs/dialogs.cpp index a49ce3da85..e493326d93 100644 --- a/samples/dialogs/dialogs.cpp +++ b/samples/dialogs/dialogs.cpp @@ -1318,6 +1318,8 @@ public: sizerBtns->Add(new wxButton(this, wxID_RESET, "&Reset all"), wxSizerFlags().Border(wxLEFT)); } + MyRearrangeDialog(const MyRearrangeDialog&) = delete; + MyRearrangeDialog& operator=(const MyRearrangeDialog&) = delete; // call this instead of ShowModal() to update order and labels array in // case the dialog was not cancelled @@ -1409,7 +1411,6 @@ private: wxTextCtrl *m_text; wxDECLARE_EVENT_TABLE(); - wxDECLARE_NO_COPY_CLASS(MyRearrangeDialog); }; wxBEGIN_EVENT_TABLE(MyRearrangeDialog, wxRearrangeDialog) @@ -1731,6 +1732,8 @@ public: : m_dialog(&dialog) { } + MyCustomizeHook(const MyCustomizeHook&) = delete; + MyCustomizeHook& operator=(const MyCustomizeHook&) = delete; // Override pure virtual base class method to add our custom controls. virtual void AddCustomControls(wxFileDialogCustomize& customizer) override @@ -1804,8 +1807,6 @@ private: wxFileDialogStaticText* m_label; wxString m_info; - - wxDECLARE_NO_COPY_CLASS(MyCustomizeHook); }; void MyFrame::FileOpen(wxCommandEvent& WXUNUSED(event) ) diff --git a/samples/dialogs/dialogs.h b/samples/dialogs/dialogs.h index eab880b7d8..a1471d22a5 100644 --- a/samples/dialogs/dialogs.h +++ b/samples/dialogs/dialogs.h @@ -190,6 +190,8 @@ class TestMessageBoxDialog : public wxDialog { public: TestMessageBoxDialog(wxWindow *parent); + TestMessageBoxDialog(const TestMessageBoxDialog&) = delete; + TestMessageBoxDialog& operator=(const TestMessageBoxDialog&) = delete; bool Create(); @@ -256,7 +258,6 @@ private: wxStaticText *m_labelResult; wxDECLARE_EVENT_TABLE(); - wxDECLARE_NO_COPY_CLASS(TestMessageBoxDialog); }; #if wxUSE_RICHMSGDLG diff --git a/samples/docview/doc.h b/samples/docview/doc.h index f5fc6938ad..4b1753300e 100644 --- a/samples/docview/doc.h +++ b/samples/docview/doc.h @@ -164,6 +164,8 @@ class wxTextDocument : public wxDocument { public: wxTextDocument() : wxDocument() { } + wxTextDocument(const wxTextDocument&) = delete; + wxTextDocument &operator=(const wxTextDocument&) = delete; virtual bool OnCreate(const wxString& path, long flags) override; @@ -178,7 +180,6 @@ protected: void OnTextChange(wxCommandEvent& event); - wxDECLARE_NO_COPY_CLASS(wxTextDocument); wxDECLARE_ABSTRACT_CLASS(wxTextDocument); }; @@ -190,9 +191,11 @@ class TextEditDocument : public wxTextDocument { public: TextEditDocument() : wxTextDocument() { } + TextEditDocument(const TextEditDocument&) = delete; + TextEditDocument &operator=(const TextEditDocument&) = delete; + virtual wxTextCtrl* GetTextCtrl() const override; - wxDECLARE_NO_COPY_CLASS(TextEditDocument); wxDECLARE_DYNAMIC_CLASS(TextEditDocument); }; @@ -207,6 +210,8 @@ class ImageDocument : public wxDocument { public: ImageDocument() : wxDocument() { } + ImageDocument(const ImageDocument&) = delete; + ImageDocument &operator=(const ImageDocument&) = delete; virtual bool OnOpenDocument(const wxString& file) override; @@ -218,7 +223,6 @@ protected: private: wxImage m_image; - wxDECLARE_NO_COPY_CLASS(ImageDocument); wxDECLARE_DYNAMIC_CLASS(ImageDocument); }; @@ -229,6 +233,8 @@ class ImageDetailsDocument : public wxDocument { public: ImageDetailsDocument(ImageDocument *parent); + ImageDetailsDocument(const ImageDetailsDocument&) = delete; + ImageDetailsDocument &operator=(const ImageDetailsDocument&) = delete; // accessors for ImageDetailsView wxSize GetSize() const { return m_size; } @@ -242,8 +248,6 @@ private: unsigned long m_numColours; wxBitmapType m_type; bool m_hasAlpha; - - wxDECLARE_NO_COPY_CLASS(ImageDetailsDocument); }; #endif // _WX_SAMPLES_DOCVIEW_DOC_H_ diff --git a/samples/docview/docview.h b/samples/docview/docview.h index 49a531896f..fe5e2cabe2 100644 --- a/samples/docview/docview.h +++ b/samples/docview/docview.h @@ -35,6 +35,8 @@ public: }; MyApp(); + MyApp(const MyApp&) = delete; + MyApp& operator=(const MyApp&) = delete; // override some wxApp virtual methods virtual bool OnInit() override; @@ -90,7 +92,6 @@ private: wxMenu *m_menuEdit; wxDECLARE_EVENT_TABLE(); - wxDECLARE_NO_COPY_CLASS(MyApp); }; wxDECLARE_APP(MyApp); diff --git a/samples/docview/view.h b/samples/docview/view.h index af587492d2..baefee6baa 100644 --- a/samples/docview/view.h +++ b/samples/docview/view.h @@ -155,14 +155,14 @@ class ImageDetailsView : public wxView { public: ImageDetailsView(ImageDetailsDocument *doc); + ImageDetailsView(const ImageDetailsView&) = delete; + ImageDetailsView& operator=(const ImageDetailsView&) = delete; virtual void OnDraw(wxDC *dc) override; virtual bool OnClose(bool deleteWindow) override; private: wxFrame *m_frame; - - wxDECLARE_NO_COPY_CLASS(ImageDetailsView); }; #endif // _WX_SAMPLES_DOCVIEW_VIEW_H_ diff --git a/samples/grid/griddemo.cpp b/samples/grid/griddemo.cpp index e0a21882bc..b4cea19e54 100644 --- a/samples/grid/griddemo.cpp +++ b/samples/grid/griddemo.cpp @@ -49,6 +49,8 @@ public: m_colBg(colBg) { } + CustomColumnHeaderRenderer(const CustomColumnHeaderRenderer&) = delete; + CustomColumnHeaderRenderer& operator=(const CustomColumnHeaderRenderer&) = delete; virtual void DrawLabel(const wxGrid& WXUNUSED(grid), wxDC& dc, @@ -74,8 +76,6 @@ public: private: const wxColour m_colFg, m_colBg; - - wxDECLARE_NO_COPY_CLASS(CustomColumnHeaderRenderer); }; // And a custom attributes provider which uses custom column header renderer @@ -91,6 +91,8 @@ public: m_useCustom(false) { } + CustomColumnHeadersProvider(const CustomColumnHeadersProvider&) = delete; + CustomColumnHeadersProvider& operator=(const CustomColumnHeadersProvider&) = delete; // enable or disable the use of custom renderer for column headers void UseCustomColHeaders(bool use = true) { m_useCustom = use; } @@ -114,8 +116,6 @@ private: m_customEvenRenderer; bool m_useCustom; - - wxDECLARE_NO_COPY_CLASS(CustomColumnHeadersProvider); }; // ---------------------------------------------------------------------------- @@ -2437,6 +2437,8 @@ class TabularGridFrame : public wxFrame { public: TabularGridFrame(); + TabularGridFrame(const TabularGridFrame&) = delete; + TabularGridFrame& operator=(const TabularGridFrame&) = delete; private: enum // control ids @@ -2626,7 +2628,6 @@ private: bool m_shouldUpdateRowOrder, m_shouldUpdateColOrder; - wxDECLARE_NO_COPY_CLASS(TabularGridFrame); wxDECLARE_EVENT_TABLE(); }; diff --git a/samples/htlbox/htlbox.cpp b/samples/htlbox/htlbox.cpp index 571cab0c68..a760ea245d 100644 --- a/samples/htlbox/htlbox.cpp +++ b/samples/htlbox/htlbox.cpp @@ -60,6 +60,8 @@ class MyHtmlListBox : public wxHtmlListBox public: MyHtmlListBox() { } MyHtmlListBox(wxWindow *parent, bool multi = false); + MyHtmlListBox(const MyHtmlListBox&) = delete; + MyHtmlListBox& operator=(const MyHtmlListBox&) = delete; void SetChangeSelFg(bool change) { m_change = change; } void UpdateFirstItem(); @@ -90,7 +92,6 @@ public: wxTextFile m_file; #endif - wxDECLARE_NO_COPY_CLASS(MyHtmlListBox); wxDECLARE_DYNAMIC_CLASS(MyHtmlListBox); }; diff --git a/samples/html/test/test.cpp b/samples/html/test/test.cpp index c5402495e9..509887c54e 100644 --- a/samples/html/test/test.cpp +++ b/samples/html/test/test.cpp @@ -50,6 +50,8 @@ public: // no custom background initially to avoid confusing people m_drawCustomBg = false; } + MyHtmlWindow(const MyHtmlWindow&) = delete; + MyHtmlWindow& operator=(const MyHtmlWindow&) = delete; virtual wxHtmlOpeningStatus OnOpeningURL(wxHtmlURLType WXUNUSED(type), const wxString& WXUNUSED(url), @@ -71,7 +73,6 @@ private: bool m_drawCustomBg; wxDECLARE_EVENT_TABLE(); - wxDECLARE_NO_COPY_CLASS(MyHtmlWindow); }; // Define a new frame type: this is going to be our main frame diff --git a/samples/image/image.cpp b/samples/image/image.cpp index 27ee4975c8..9714b04de9 100644 --- a/samples/image/image.cpp +++ b/samples/image/image.cpp @@ -1261,6 +1261,8 @@ public: Show(); } + MySVGFrame(const MySVGFrame&) = delete; + MySVGFrame& operator=(const MySVGFrame&) = delete; private: void OnPaint(wxPaintEvent&) @@ -1290,8 +1292,6 @@ private: const wxBitmapBundle m_bundle; wxBitmap m_bitmap; - - wxDECLARE_NO_COPY_CLASS(MySVGFrame); }; void MyFrame::OnNewSVGFrame(wxCommandEvent&) @@ -1413,6 +1413,8 @@ public: Show(); } + MyGraphicsFrame(const MyGraphicsFrame&) = delete; + MyGraphicsFrame& operator=(const MyGraphicsFrame&) = delete; private: void OnPaint(wxPaintEvent& WXUNUSED(event)) @@ -1433,8 +1435,6 @@ private: wxImage m_image; wxBitmap m_bitmap; - - wxDECLARE_NO_COPY_CLASS(MyGraphicsFrame); }; void MyFrame::OnTestGraphics(wxCommandEvent& WXUNUSED(event)) diff --git a/samples/ipc/baseserver.cpp b/samples/ipc/baseserver.cpp index 1576ccf735..9898bc284f 100644 --- a/samples/ipc/baseserver.cpp +++ b/samples/ipc/baseserver.cpp @@ -78,6 +78,8 @@ class BenchConnection : public wxConnection { public: BenchConnection() { m_advise = false; } + BenchConnection(const BenchConnection&) = delete; + BenchConnection& operator=(const BenchConnection&) = delete; virtual bool OnPoke(const wxString& topic, const wxString& item, @@ -99,8 +101,6 @@ private: // should we notify the client about changes to m_item? bool m_advise; - - wxDECLARE_NO_COPY_CLASS(BenchConnection); }; // a simple server accepting connections to IPC_TOPIC and IPC_BENCHMARK_TOPIC diff --git a/samples/listctrl/listtest.h b/samples/listctrl/listtest.h index 1538799ebb..4920cba6f5 100644 --- a/samples/listctrl/listtest.h +++ b/samples/listctrl/listtest.h @@ -20,11 +20,10 @@ class MyApp: public wxApp { public: MyApp() { } + MyApp(const MyApp&) = delete; + MyApp& operator=(const MyApp&) = delete; virtual bool OnInit() override; - -private: - wxDECLARE_NO_COPY_CLASS(MyApp); }; class MyListCtrl: public wxListCtrl @@ -40,6 +39,8 @@ public: m_updated = -1; } + MyListCtrl(const MyListCtrl&) = delete; + MyListCtrl &operator=(const MyListCtrl&) = delete; // add one item to the listctrl in report mode void InsertItemInReportView(int i); @@ -90,7 +91,6 @@ private: // checked boxes in virtual list wxSelectionStore m_checked; - wxDECLARE_NO_COPY_CLASS(MyListCtrl); wxDECLARE_EVENT_TABLE(); }; @@ -99,6 +99,9 @@ class MyFrame: public wxFrame { public: MyFrame(const wxString& title); + MyFrame(const MyFrame&) = delete; + MyFrame &operator=(const MyFrame&) = delete; + virtual ~MyFrame(); protected: @@ -185,8 +188,6 @@ private: // number of items to initialize list/report view with int m_numListItems; - - wxDECLARE_NO_COPY_CLASS(MyFrame); wxDECLARE_EVENT_TABLE(); }; diff --git a/samples/mdi/mdi.h b/samples/mdi/mdi.h index 1dee3e51b4..c8e1804e31 100644 --- a/samples/mdi/mdi.h +++ b/samples/mdi/mdi.h @@ -25,6 +25,8 @@ public: m_frame(frame) { } + MenuEventLogger(const MenuEventLogger&) = delete; + MenuEventLogger& operator=(const MenuEventLogger&) = delete; protected: void LogMenuOpenClose(wxMenuEvent& event, const char *action) @@ -52,8 +54,6 @@ protected: const wxString m_label; wxFrame* const m_frame; - - wxDECLARE_NO_COPY_CLASS(MenuEventLogger); }; class MyCanvas : public wxScrolledWindow, @@ -155,6 +155,8 @@ private: { public: EventHandler(unsigned numChild) : m_numChild(numChild) { } + EventHandler(const EventHandler&) = delete; + EventHandler &operator=(const EventHandler&) = delete; private: void OnRefresh(wxCommandEvent& event) @@ -166,8 +168,6 @@ private: const unsigned m_numChild; wxDECLARE_EVENT_TABLE(); - - wxDECLARE_NO_COPY_CLASS(EventHandler); }; wxDECLARE_EVENT_TABLE(); diff --git a/samples/opengl/isosurf/isosurf.h b/samples/opengl/isosurf/isosurf.h index 4a7305d0c6..659b19c3c1 100644 --- a/samples/opengl/isosurf/isosurf.h +++ b/samples/opengl/isosurf/isosurf.h @@ -47,6 +47,8 @@ public: TestGLCanvas(wxWindow *parent, wxWindowID id = wxID_ANY, int *gl_attrib = nullptr); + TestGLCanvas(const TestGLCanvas&) = delete; + TestGLCanvas& operator=(const TestGLCanvas&) = delete; virtual ~TestGLCanvas(); @@ -69,7 +71,6 @@ private: GLfloat m_xrot; GLfloat m_yrot; - wxDECLARE_NO_COPY_CLASS(TestGLCanvas); wxDECLARE_EVENT_TABLE(); }; diff --git a/samples/opengl/penguin/penguin.h b/samples/opengl/penguin/penguin.h index d1bfdc83fb..ca37b2f119 100644 --- a/samples/opengl/penguin/penguin.h +++ b/samples/opengl/penguin/penguin.h @@ -79,6 +79,8 @@ public: const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = "TestGLCanvas"); + TestGLCanvas(const TestGLCanvas&) = delete; + TestGLCanvas& operator=(const TestGLCanvas&) = delete; virtual ~TestGLCanvas(); @@ -98,7 +100,6 @@ private: GLData m_gldata; DXFRenderer m_renderer; - wxDECLARE_NO_COPY_CLASS(TestGLCanvas); wxDECLARE_EVENT_TABLE(); }; diff --git a/samples/splitter/splitter.cpp b/samples/splitter/splitter.cpp index e6d73e38a4..3d100be780 100644 --- a/samples/splitter/splitter.cpp +++ b/samples/splitter/splitter.cpp @@ -71,16 +71,19 @@ class MyApp: public wxApp { public: MyApp() { } + MyApp(const MyApp&) = delete; + MyApp& operator=(const MyApp&) = delete; virtual bool OnInit() override; - - wxDECLARE_NO_COPY_CLASS(MyApp); }; class MyFrame: public wxFrame { public: MyFrame(); + MyFrame(const MyFrame&) = delete; + MyFrame& operator=(const MyFrame&) = delete; + virtual ~MyFrame(); void ToggleFlag(int flag, bool enable); @@ -136,13 +139,14 @@ private: bool m_allowDClick = true; wxDECLARE_EVENT_TABLE(); - wxDECLARE_NO_COPY_CLASS(MyFrame); }; class MySplitterWindow : public wxSplitterWindow { public: MySplitterWindow(MyFrame *parent); + MySplitterWindow(const MySplitterWindow&) = delete; + MySplitterWindow &operator=(const MySplitterWindow &) = delete; // event handlers void OnPositionChanged(wxSplitterEvent& event); @@ -155,21 +159,21 @@ private: MyFrame *m_frame; wxDECLARE_EVENT_TABLE(); - wxDECLARE_NO_COPY_CLASS(MySplitterWindow); }; class MyCanvas: public wxScrolledWindow { public: MyCanvas(wxWindow* parent, bool mirror); + MyCanvas(const MyCanvas&) = delete; + MyCanvas &operator=(const MyCanvas &) = delete; + virtual ~MyCanvas(){} virtual void OnDraw(wxDC& dc) override; private: bool m_mirror; - - wxDECLARE_NO_COPY_CLASS(MyCanvas); }; // ============================================================================ diff --git a/samples/widgets/itemcontainer.cpp b/samples/widgets/itemcontainer.cpp index 30b02d1c82..47cda198c7 100644 --- a/samples/widgets/itemcontainer.cpp +++ b/samples/widgets/itemcontainer.cpp @@ -40,6 +40,8 @@ public: { m_tracker->StartTrackingData(); } + TrackedClientData(const TrackedClientData&) = delete; + TrackedClientData& operator=(const TrackedClientData&) = delete; virtual ~TrackedClientData() { @@ -54,8 +56,6 @@ public: private: ItemContainerWidgetsPage *m_tracker; int m_value; - - wxDECLARE_NO_COPY_CLASS(TrackedClientData); }; // ============================================================================ diff --git a/samples/widgets/widgets.cpp b/samples/widgets/widgets.cpp index c9d0b41593..b4f186ad19 100644 --- a/samples/widgets/widgets.cpp +++ b/samples/widgets/widgets.cpp @@ -142,6 +142,8 @@ public: m_logTarget = nullptr; #endif // USE_LOG } + WidgetsApp(const WidgetsApp&) = delete; + WidgetsApp& operator=(const WidgetsApp&) = delete; // override base class virtuals // ---------------------------- @@ -158,8 +160,6 @@ private: #if USE_LOG wxLog* m_logTarget; #endif // USE_LOG - - wxDECLARE_NO_COPY_CLASS(WidgetsApp); }; wxDECLARE_APP(WidgetsApp); // This provides a convenient wxGetApp() accessor.