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.
This commit is contained in:
Blake-Madden 2023-12-20 11:23:59 -05:00 committed by Vadim Zeitlin
parent 33de6dce6f
commit a059061eb7
20 changed files with 78 additions and 56 deletions

View file

@ -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);
};

View file

@ -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

View file

@ -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);

View file

@ -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) )

View file

@ -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

View file

@ -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_

View file

@ -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);

View file

@ -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_

View file

@ -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();
};

View file

@ -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);
};

View file

@ -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

View file

@ -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))

View file

@ -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

View file

@ -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();
};

View file

@ -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();

View file

@ -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();
};

View file

@ -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();
};

View file

@ -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);
};
// ============================================================================

View file

@ -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);
};
// ============================================================================

View file

@ -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.