wxwidgets/samples/docview/docview.h
Vadim Zeitlin 4f4c5fcfdf Use nullptr instead of NULL in the code and documentation
This is a combination of running clang-tidy with modernize-use-nullptr
check for some ports (GTK, X11, OSX) and manual changes to the ports for
which it couldn't be used easily (MSW, DFB) and also manually updating
the docs.

Also replace NULL with null or nullptr in the comments as this is more
consistent with the use of nullptr in the code and makes it simpler to
grep for the remaining occurrences of NULL itself.

And also use null in the assert messages.

Only a few occurrences of "NULL" are still left in non-C files, mostly
corresponding to unclear comments or string output which it might not be
safe to change.
2022-10-18 01:25:25 +02:00

98 lines
3 KiB
C++

/////////////////////////////////////////////////////////////////////////////
// Name: samples/docview/docview.h
// Purpose: Document/view demo
// Author: Julian Smart
// Modified by: Vadim Zeitlin: merge with the MDI version and general cleanup
// Created: 04/01/98
// Copyright: (c) 1998 Julian Smart
// (c) 2008 Vadim Zeitlin
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_SAMPLES_DOCVIEW_DOCVIEW_H_
#define _WX_SAMPLES_DOCVIEW_DOCVIEW_H_
#include "wx/docview.h"
#include "wx/vector.h"
class MyCanvas;
// Define a new application
class MyApp : public wxApp
{
public:
// this sample can be launched in several different ways:
enum Mode
{
#if wxUSE_MDI_ARCHITECTURE
Mode_MDI, // MDI mode: multiple documents, single top level window
#endif // wxUSE_MDI_ARCHITECTURE
#if wxUSE_AUI
Mode_AUI, // MDI AUI mode
#endif // wxUSE_AUI
Mode_SDI, // SDI mode: multiple documents, multiple top level windows
Mode_Single // single document mode (and hence single top level window)
};
MyApp();
// override some wxApp virtual methods
virtual bool OnInit() override;
virtual int OnExit() override;
virtual void OnInitCmdLine(wxCmdLineParser& parser) override;
virtual bool OnCmdLineParsed(wxCmdLineParser& parser) override;
#ifdef __WXMAC__
virtual void MacNewFile() override;
#endif // __WXMAC__
// our specific methods
Mode GetMode() const { return m_mode; }
wxFrame *CreateChildFrame(wxView *view, bool isCanvas);
// these accessors should only be called in single document mode, otherwise
// the pointers are null and an assert is triggered
MyCanvas *GetMainWindowCanvas() const
{ wxASSERT(m_canvas); return m_canvas; }
wxMenu *GetMainWindowEditMenu() const
{ wxASSERT(m_menuEdit); return m_menuEdit; }
private:
// append the standard document-oriented menu commands to this menu
void AppendDocumentFileCommands(wxMenu *menu, bool supportsPrinting);
// create the edit menu for drawing documents
wxMenu *CreateDrawingEditMenu();
// create and associate with the given frame the menu bar containing the
// given file and edit (possibly null) menus as well as the standard help
// one
void CreateMenuBarForFrame(wxFrame *frame, wxMenu *file, wxMenu *edit);
// force close all windows
void OnForceCloseAll(wxCommandEvent& event);
// show the about box: as we can have different frames it's more
// convenient, even if somewhat less usual, to handle this in the
// application object itself
void OnAbout(wxCommandEvent& event);
// contains the file names given on the command line, possibly empty
wxVector<wxString> m_filesFromCmdLine;
// the currently used mode
Mode m_mode;
// only used if m_mode == Mode_Single
MyCanvas *m_canvas;
wxMenu *m_menuEdit;
wxDECLARE_EVENT_TABLE();
wxDECLARE_NO_COPY_CLASS(MyApp);
};
wxDECLARE_APP(MyApp);
#endif // _WX_SAMPLES_DOCVIEW_DOCVIEW_H_