1998-05-22 15:57:05 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2008-10-03 11:16:01 -04:00
|
|
|
// Name: samples/docview/docview.h
|
1998-05-22 15:57:05 -04:00
|
|
|
// Purpose: Document/view demo
|
|
|
|
// Author: Julian Smart
|
2008-10-03 11:16:01 -04:00
|
|
|
// Modified by: Vadim Zeitlin: merge with the MDI version and general cleanup
|
1998-05-22 15:57:05 -04:00
|
|
|
// Created: 04/01/98
|
2008-10-03 11:16:01 -04:00
|
|
|
// Copyright: (c) 1998 Julian Smart
|
|
|
|
// (c) 2008 Vadim Zeitlin
|
2010-07-13 09:29:13 -04:00
|
|
|
// Licence: wxWindows licence
|
1998-05-22 15:57:05 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2008-10-03 11:16:01 -04:00
|
|
|
#ifndef _WX_SAMPLES_DOCVIEW_DOCVIEW_H_
|
|
|
|
#define _WX_SAMPLES_DOCVIEW_DOCVIEW_H_
|
1998-05-22 15:57:05 -04:00
|
|
|
|
|
|
|
#include "wx/docview.h"
|
2015-02-15 13:35:13 -05:00
|
|
|
#include "wx/vector.h"
|
1998-05-22 15:57:05 -04:00
|
|
|
|
2008-10-03 11:16:01 -04:00
|
|
|
class MyCanvas;
|
1998-05-22 15:57:05 -04:00
|
|
|
|
|
|
|
// Define a new application
|
2008-04-06 09:57:23 -04:00
|
|
|
class MyApp : public wxApp
|
1998-05-22 15:57:05 -04:00
|
|
|
{
|
2000-07-15 15:51:35 -04:00
|
|
|
public:
|
2008-10-03 11:16:01 -04:00
|
|
|
// 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
|
|
|
|
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
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual bool OnInit() wxOVERRIDE;
|
|
|
|
virtual int OnExit() wxOVERRIDE;
|
2008-10-03 11:16:01 -04:00
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void OnInitCmdLine(wxCmdLineParser& parser) wxOVERRIDE;
|
|
|
|
virtual bool OnCmdLineParsed(wxCmdLineParser& parser) wxOVERRIDE;
|
2008-10-03 11:16:01 -04:00
|
|
|
|
2015-03-19 11:42:17 -04:00
|
|
|
#ifdef __WXMAC__
|
2015-02-15 13:35:13 -05:00
|
|
|
virtual void MacNewFile() wxOVERRIDE;
|
2015-03-19 11:42:17 -04:00
|
|
|
#endif // __WXMAC__
|
2015-02-15 13:35:13 -05:00
|
|
|
|
2008-10-03 11:16:01 -04:00
|
|
|
// our specific methods
|
|
|
|
Mode GetMode() const { return m_mode; }
|
2010-11-09 19:36:39 -05:00
|
|
|
wxFrame *CreateChildFrame(wxView *view, bool isCanvas);
|
2008-04-06 09:57:23 -04:00
|
|
|
|
2008-10-03 11:16:01 -04:00
|
|
|
// 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; }
|
1998-05-22 15:57:05 -04:00
|
|
|
|
2008-10-03 11:16:01 -04:00
|
|
|
private:
|
|
|
|
// append the standard document-oriented menu commands to this menu
|
|
|
|
void AppendDocumentFileCommands(wxMenu *menu, bool supportsPrinting);
|
1998-05-22 15:57:05 -04:00
|
|
|
|
2008-10-03 11:16:01 -04:00
|
|
|
// create the edit menu for drawing documents
|
|
|
|
wxMenu *CreateDrawingEditMenu();
|
2008-04-06 09:57:23 -04:00
|
|
|
|
2008-10-03 11:16:01 -04:00
|
|
|
// 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);
|
2008-04-06 09:57:23 -04:00
|
|
|
|
|
|
|
|
2008-10-03 11:16:01 -04:00
|
|
|
// 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
|
2000-07-15 15:51:35 -04:00
|
|
|
void OnAbout(wxCommandEvent& event);
|
1998-05-22 15:57:05 -04:00
|
|
|
|
2015-02-15 13:35:13 -05:00
|
|
|
// contains the file names given on the command line, possibly empty
|
|
|
|
wxVector<wxString> m_filesFromCmdLine;
|
1998-05-22 15:57:05 -04:00
|
|
|
|
2008-10-03 11:16:01 -04:00
|
|
|
// the currently used mode
|
|
|
|
Mode m_mode;
|
|
|
|
|
|
|
|
// only used if m_mode == Mode_Single
|
|
|
|
MyCanvas *m_canvas;
|
|
|
|
wxMenu *m_menuEdit;
|
1998-05-22 15:57:05 -04:00
|
|
|
|
2014-03-30 03:07:55 -04:00
|
|
|
wxDECLARE_EVENT_TABLE();
|
2009-02-08 06:45:59 -05:00
|
|
|
wxDECLARE_NO_COPY_CLASS(MyApp);
|
2008-10-03 11:16:01 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
DECLARE_APP(MyApp)
|
1998-05-22 15:57:05 -04:00
|
|
|
|
2008-10-03 11:16:01 -04:00
|
|
|
#endif // _WX_SAMPLES_DOCVIEW_DOCVIEW_H_
|