1998-05-22 15:57:05 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2008-10-03 11:16:01 -04:00
|
|
|
// Name: samples/docview/docview.cpp
|
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
|
|
|
This sample show document/view support in wxWidgets.
|
|
|
|
|
|
|
|
It can be run in several ways:
|
|
|
|
* With "--mdi" command line option to use multiple MDI child frames
|
|
|
|
for the multiple documents (this is the default).
|
|
|
|
* With "--sdi" command line option to use multiple top level windows
|
|
|
|
for the multiple documents
|
|
|
|
* With "--single" command line option to support opening a single
|
|
|
|
document only
|
|
|
|
|
|
|
|
Notice that doing it like this somewhat complicates the code, you could
|
|
|
|
make things much simpler in your own programs by using either
|
|
|
|
wxDocParentFrame or wxDocMDIParentFrame unconditionally (and never using
|
|
|
|
the single mode) instead of supporting all of them as this sample does.
|
|
|
|
*/
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// headers
|
|
|
|
// ----------------------------------------------------------------------------
|
1998-05-22 15:57:05 -04:00
|
|
|
|
|
|
|
// For compilers that support precompilation, includes "wx/wx.h".
|
|
|
|
#include "wx/wxprec.h"
|
|
|
|
|
|
|
|
#ifdef __BORLANDC__
|
2008-10-03 11:16:01 -04:00
|
|
|
#pragma hdrstop
|
1998-05-22 15:57:05 -04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef WX_PRECOMP
|
2008-10-03 11:16:01 -04:00
|
|
|
#include "wx/wx.h"
|
|
|
|
#include "wx/stockitem.h"
|
1998-05-22 15:57:05 -04:00
|
|
|
#endif
|
|
|
|
|
1998-09-25 11:28:18 -04:00
|
|
|
#if !wxUSE_DOC_VIEW_ARCHITECTURE
|
2008-10-03 11:16:01 -04:00
|
|
|
#error You must set wxUSE_DOC_VIEW_ARCHITECTURE to 1 in setup.h!
|
1998-05-22 15:57:05 -04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "wx/docview.h"
|
2008-10-03 11:16:01 -04:00
|
|
|
#include "wx/docmdi.h"
|
1998-05-22 15:57:05 -04:00
|
|
|
|
2018-05-12 18:11:41 -04:00
|
|
|
#if wxUSE_AUI
|
|
|
|
#include "wx/aui/tabmdi.h"
|
|
|
|
#endif // wxUSE_AUI
|
|
|
|
|
1998-05-22 15:57:05 -04:00
|
|
|
#include "docview.h"
|
|
|
|
#include "doc.h"
|
|
|
|
#include "view.h"
|
2008-10-03 11:16:01 -04:00
|
|
|
|
|
|
|
#include "wx/cmdline.h"
|
2011-07-22 12:16:03 -04:00
|
|
|
#include "wx/config.h"
|
2008-10-03 11:16:01 -04:00
|
|
|
|
2003-01-10 11:13:40 -05:00
|
|
|
#ifdef __WXMAC__
|
2008-10-03 11:16:01 -04:00
|
|
|
#include "wx/filename.h"
|
2003-01-10 11:13:40 -05:00
|
|
|
#endif
|
1998-05-22 15:57:05 -04:00
|
|
|
|
2012-03-03 19:28:58 -05:00
|
|
|
#ifndef wxHAS_IMAGES_IN_RESOURCES
|
2008-10-03 11:16:01 -04:00
|
|
|
#include "doc.xpm"
|
|
|
|
#include "chart.xpm"
|
|
|
|
#include "notepad.xpm"
|
|
|
|
#endif
|
1998-05-22 15:57:05 -04:00
|
|
|
|
2008-10-03 11:16:01 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// MyApp implementation
|
|
|
|
// ----------------------------------------------------------------------------
|
1998-05-22 15:57:05 -04:00
|
|
|
|
2015-04-23 07:49:01 -04:00
|
|
|
wxIMPLEMENT_APP(MyApp);
|
1998-05-22 15:57:05 -04:00
|
|
|
|
2014-03-30 03:07:55 -04:00
|
|
|
wxBEGIN_EVENT_TABLE(MyApp, wxApp)
|
2008-10-03 11:16:01 -04:00
|
|
|
EVT_MENU(wxID_ABOUT, MyApp::OnAbout)
|
2014-03-30 03:07:55 -04:00
|
|
|
wxEND_EVENT_TABLE()
|
2008-10-03 11:16:01 -04:00
|
|
|
|
|
|
|
MyApp::MyApp()
|
1998-05-22 15:57:05 -04:00
|
|
|
{
|
2008-10-03 11:16:01 -04:00
|
|
|
#if wxUSE_MDI_ARCHITECTURE
|
|
|
|
m_mode = Mode_MDI;
|
|
|
|
#else
|
|
|
|
m_mode = Mode_SDI;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
m_canvas = NULL;
|
|
|
|
m_menuEdit = NULL;
|
1998-05-22 15:57:05 -04:00
|
|
|
}
|
|
|
|
|
2008-10-03 11:16:01 -04:00
|
|
|
// constants for the command line options names
|
|
|
|
namespace CmdLineOption
|
1998-05-22 15:57:05 -04:00
|
|
|
{
|
2008-04-06 09:57:23 -04:00
|
|
|
|
2018-05-12 13:34:54 -04:00
|
|
|
#if wxUSE_MDI_ARCHITECTURE
|
2008-10-03 11:16:01 -04:00
|
|
|
const char * const MDI = "mdi";
|
2018-05-12 13:34:54 -04:00
|
|
|
#endif // wxUSE_MDI_ARCHITECTURE
|
2018-05-12 18:11:41 -04:00
|
|
|
#if wxUSE_AUI
|
|
|
|
const char * const AUI = "aui";
|
|
|
|
#endif // wxUSE_AUI
|
2008-10-03 11:16:01 -04:00
|
|
|
const char * const SDI = "sdi";
|
|
|
|
const char * const SINGLE = "single";
|
|
|
|
|
|
|
|
} // namespace CmdLineOption
|
|
|
|
|
|
|
|
void MyApp::OnInitCmdLine(wxCmdLineParser& parser)
|
|
|
|
{
|
|
|
|
wxApp::OnInitCmdLine(parser);
|
|
|
|
|
2018-05-12 13:34:54 -04:00
|
|
|
#if wxUSE_MDI_ARCHITECTURE
|
2008-10-03 11:16:01 -04:00
|
|
|
parser.AddSwitch("", CmdLineOption::MDI,
|
|
|
|
"run in MDI mode: multiple documents, single window");
|
2018-05-12 13:34:54 -04:00
|
|
|
#endif // wxUSE_MDI_ARCHITECTURE
|
2018-05-12 18:11:41 -04:00
|
|
|
#if wxUSE_AUI
|
|
|
|
parser.AddSwitch("", CmdLineOption::AUI,
|
|
|
|
"run in MDI mode using AUI: multiple documents, single window");
|
|
|
|
#endif // wxUSE_AUI
|
2008-10-03 11:16:01 -04:00
|
|
|
parser.AddSwitch("", CmdLineOption::SDI,
|
|
|
|
"run in SDI mode: multiple documents, multiple windows");
|
|
|
|
parser.AddSwitch("", CmdLineOption::SINGLE,
|
|
|
|
"run in single document mode");
|
2015-02-15 13:35:13 -05:00
|
|
|
|
|
|
|
parser.AddParam("document-file",
|
|
|
|
wxCMD_LINE_VAL_STRING,
|
|
|
|
wxCMD_LINE_PARAM_MULTIPLE | wxCMD_LINE_PARAM_OPTIONAL);
|
2008-10-03 11:16:01 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool MyApp::OnCmdLineParsed(wxCmdLineParser& parser)
|
|
|
|
{
|
|
|
|
int numModeOptions = 0;
|
|
|
|
|
|
|
|
#if wxUSE_MDI_ARCHITECTURE
|
|
|
|
if ( parser.Found(CmdLineOption::MDI) )
|
|
|
|
{
|
|
|
|
m_mode = Mode_MDI;
|
|
|
|
numModeOptions++;
|
|
|
|
}
|
|
|
|
#endif // wxUSE_MDI_ARCHITECTURE
|
|
|
|
|
2018-05-12 18:11:41 -04:00
|
|
|
#if wxUSE_AUI
|
|
|
|
if ( parser.Found(CmdLineOption::AUI) )
|
|
|
|
{
|
|
|
|
m_mode = Mode_AUI;
|
|
|
|
numModeOptions++;
|
|
|
|
}
|
|
|
|
#endif // wxUSE_AUI
|
|
|
|
|
2008-10-03 11:16:01 -04:00
|
|
|
if ( parser.Found(CmdLineOption::SDI) )
|
|
|
|
{
|
|
|
|
m_mode = Mode_SDI;
|
|
|
|
numModeOptions++;
|
|
|
|
}
|
2007-02-03 19:34:18 -05:00
|
|
|
|
2008-10-03 11:16:01 -04:00
|
|
|
if ( parser.Found(CmdLineOption::SINGLE) )
|
1998-05-22 15:57:05 -04:00
|
|
|
{
|
2008-10-03 11:16:01 -04:00
|
|
|
m_mode = Mode_Single;
|
|
|
|
numModeOptions++;
|
1998-05-22 15:57:05 -04:00
|
|
|
}
|
2008-04-06 09:57:23 -04:00
|
|
|
|
2008-10-03 11:16:01 -04:00
|
|
|
if ( numModeOptions > 1 )
|
|
|
|
{
|
|
|
|
wxLogError("Only a single option choosing the mode can be given.");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-02-15 13:35:13 -05:00
|
|
|
// save any files given on the command line: we'll open them in OnInit()
|
|
|
|
// later, after creating the frame
|
|
|
|
for ( size_t i = 0; i != parser.GetParamCount(); ++i )
|
|
|
|
m_filesFromCmdLine.push_back(parser.GetParam(i));
|
|
|
|
|
2008-10-03 11:16:01 -04:00
|
|
|
return wxApp::OnCmdLineParsed(parser);
|
|
|
|
}
|
|
|
|
|
2015-03-19 11:42:17 -04:00
|
|
|
#ifdef __WXMAC__
|
2015-02-15 13:35:13 -05:00
|
|
|
void MyApp::MacNewFile()
|
|
|
|
{
|
|
|
|
wxDocManager::GetDocumentManager()->CreateNewDocument();
|
|
|
|
}
|
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
|
|
|
bool MyApp::OnInit()
|
|
|
|
{
|
|
|
|
if ( !wxApp::OnInit() )
|
|
|
|
return false;
|
|
|
|
|
2009-09-24 12:04:06 -04:00
|
|
|
::wxInitAllImageHandlers();
|
|
|
|
|
2011-07-22 12:16:03 -04:00
|
|
|
// Fill in the application information fields before creating wxConfig.
|
|
|
|
SetVendorName("wxWidgets");
|
|
|
|
SetAppName("wx_docview_sample");
|
|
|
|
SetAppDisplayName("wxWidgets DocView Sample");
|
2008-10-03 11:16:01 -04:00
|
|
|
|
2000-07-15 15:51:35 -04:00
|
|
|
//// Create a document manager
|
2008-10-03 11:16:01 -04:00
|
|
|
wxDocManager *docManager = new wxDocManager;
|
2001-01-17 11:18:49 -05:00
|
|
|
|
2000-07-15 15:51:35 -04:00
|
|
|
//// Create a template relating drawing documents to their views
|
2008-10-03 11:16:01 -04:00
|
|
|
new wxDocTemplate(docManager, "Drawing", "*.drw", "", "drw",
|
|
|
|
"Drawing Doc", "Drawing View",
|
|
|
|
CLASSINFO(DrawingDocument), CLASSINFO(DrawingView));
|
2008-04-06 09:57:23 -04:00
|
|
|
|
2008-10-03 11:16:01 -04:00
|
|
|
if ( m_mode == Mode_Single )
|
2000-07-15 15:51:35 -04:00
|
|
|
{
|
2008-10-03 11:16:01 -04:00
|
|
|
// If we've only got one window, we only get to edit one document at a
|
|
|
|
// time. Therefore no text editing, just doodling.
|
|
|
|
docManager->SetMaxDocsOpen(1);
|
2000-07-15 15:51:35 -04:00
|
|
|
}
|
2008-10-03 11:16:01 -04:00
|
|
|
else // multiple documents mode: allow documents of different types
|
2003-01-10 11:13:40 -05:00
|
|
|
{
|
2008-10-03 11:16:01 -04:00
|
|
|
// Create a template relating text documents to their views
|
|
|
|
new wxDocTemplate(docManager, "Text", "*.txt;*.text", "", "txt;text",
|
|
|
|
"Text Doc", "Text View",
|
|
|
|
CLASSINFO(TextEditDocument), CLASSINFO(TextEditView));
|
2009-09-24 12:04:06 -04:00
|
|
|
// Create a template relating image documents to their views
|
|
|
|
new wxDocTemplate(docManager, "Image", "*.png;*.jpg", "", "png;jpg",
|
|
|
|
"Image Doc", "Image View",
|
2010-05-13 10:37:06 -04:00
|
|
|
CLASSINFO(ImageDocument), CLASSINFO(ImageView));
|
2003-01-10 11:13:40 -05:00
|
|
|
}
|
2008-04-06 09:57:23 -04:00
|
|
|
|
2008-10-03 11:16:01 -04:00
|
|
|
// create the main frame window
|
2018-05-12 18:11:41 -04:00
|
|
|
wxFrame *frame = NULL;
|
|
|
|
switch ( m_mode )
|
2000-07-15 15:51:35 -04:00
|
|
|
{
|
2018-05-12 18:11:41 -04:00
|
|
|
#if wxUSE_MDI_ARCHITECTURE
|
|
|
|
case Mode_MDI:
|
|
|
|
frame = new wxDocMDIParentFrame(docManager, NULL, wxID_ANY,
|
|
|
|
GetAppDisplayName(),
|
|
|
|
wxDefaultPosition,
|
|
|
|
wxSize(500, 400));
|
|
|
|
break;
|
2008-10-03 11:16:01 -04:00
|
|
|
#endif // wxUSE_MDI_ARCHITECTURE
|
2018-05-12 18:11:41 -04:00
|
|
|
|
|
|
|
#if wxUSE_AUI
|
|
|
|
case Mode_AUI:
|
|
|
|
frame = new wxDocParentFrameAny<wxAuiMDIParentFrame>
|
|
|
|
(
|
|
|
|
docManager, NULL, wxID_ANY,
|
|
|
|
GetAppDisplayName(),
|
|
|
|
wxDefaultPosition,
|
|
|
|
wxSize(500, 400)
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
#endif // wxUSE_AUI
|
|
|
|
|
|
|
|
case Mode_SDI:
|
|
|
|
case Mode_Single:
|
|
|
|
frame = new wxDocParentFrame(docManager, NULL, wxID_ANY,
|
|
|
|
GetAppDisplayName(),
|
|
|
|
wxDefaultPosition,
|
|
|
|
wxSize(500, 400));
|
|
|
|
break;
|
2000-07-15 15:51:35 -04:00
|
|
|
}
|
2008-04-06 09:57:23 -04:00
|
|
|
|
2008-10-03 11:16:01 -04:00
|
|
|
// and its menu bar
|
|
|
|
wxMenu *menuFile = new wxMenu;
|
2008-04-06 09:57:23 -04:00
|
|
|
|
2008-10-03 11:16:01 -04:00
|
|
|
menuFile->Append(wxID_NEW);
|
|
|
|
menuFile->Append(wxID_OPEN);
|
2008-04-06 09:57:23 -04:00
|
|
|
|
2008-10-03 11:16:01 -04:00
|
|
|
if ( m_mode == Mode_Single )
|
|
|
|
AppendDocumentFileCommands(menuFile, true);
|
2008-04-06 09:57:23 -04:00
|
|
|
|
2008-10-03 11:16:01 -04:00
|
|
|
menuFile->AppendSeparator();
|
|
|
|
menuFile->Append(wxID_EXIT);
|
2008-04-06 09:57:23 -04:00
|
|
|
|
2008-10-03 11:16:01 -04:00
|
|
|
// A nice touch: a history of files visited. Use this menu.
|
|
|
|
docManager->FileHistoryUseMenu(menuFile);
|
2011-07-22 12:16:03 -04:00
|
|
|
#if wxUSE_CONFIG
|
|
|
|
docManager->FileHistoryLoad(*wxConfig::Get());
|
|
|
|
#endif // wxUSE_CONFIG
|
|
|
|
|
2008-04-06 09:57:23 -04:00
|
|
|
|
2008-10-03 11:16:01 -04:00
|
|
|
if ( m_mode == Mode_Single )
|
|
|
|
{
|
|
|
|
m_canvas = new MyCanvas(NULL, frame);
|
|
|
|
m_menuEdit = CreateDrawingEditMenu();
|
|
|
|
}
|
2008-04-06 09:57:23 -04:00
|
|
|
|
2008-10-03 11:16:01 -04:00
|
|
|
CreateMenuBarForFrame(frame, menuFile, m_menuEdit);
|
2008-04-06 09:57:23 -04:00
|
|
|
|
2008-10-03 11:16:01 -04:00
|
|
|
frame->SetIcon(wxICON(doc));
|
2010-11-09 19:36:39 -05:00
|
|
|
frame->Centre();
|
|
|
|
frame->Show();
|
2008-04-06 09:57:23 -04:00
|
|
|
|
2015-02-15 13:35:13 -05:00
|
|
|
if ( m_filesFromCmdLine.empty() )
|
|
|
|
{
|
2019-01-03 11:04:13 -05:00
|
|
|
// on macOS the dialog will be shown by MacNewFile
|
|
|
|
#ifndef __WXMAC__
|
2015-02-15 13:35:13 -05:00
|
|
|
docManager->CreateNewDocument();
|
2019-01-03 11:04:13 -05:00
|
|
|
#endif
|
2015-02-15 13:35:13 -05:00
|
|
|
}
|
|
|
|
else // we have files to open on command line
|
|
|
|
{
|
|
|
|
for ( size_t i = 0; i != m_filesFromCmdLine.size(); ++i )
|
|
|
|
docManager->CreateDocument(m_filesFromCmdLine[i], wxDOC_SILENT);
|
|
|
|
}
|
|
|
|
|
2004-05-27 14:07:04 -04:00
|
|
|
return true;
|
1998-05-22 15:57:05 -04:00
|
|
|
}
|
|
|
|
|
2008-10-03 11:16:01 -04:00
|
|
|
int MyApp::OnExit()
|
1998-05-22 15:57:05 -04:00
|
|
|
{
|
2011-07-22 12:16:03 -04:00
|
|
|
wxDocManager * const manager = wxDocManager::GetDocumentManager();
|
|
|
|
#if wxUSE_CONFIG
|
|
|
|
manager->FileHistorySave(*wxConfig::Get());
|
|
|
|
#endif // wxUSE_CONFIG
|
|
|
|
delete manager;
|
2008-10-03 11:16:01 -04:00
|
|
|
|
|
|
|
return wxApp::OnExit();
|
1998-05-22 15:57:05 -04:00
|
|
|
}
|
|
|
|
|
2008-10-03 11:16:01 -04:00
|
|
|
void MyApp::AppendDocumentFileCommands(wxMenu *menu, bool supportsPrinting)
|
|
|
|
{
|
|
|
|
menu->Append(wxID_CLOSE);
|
|
|
|
menu->Append(wxID_SAVE);
|
|
|
|
menu->Append(wxID_SAVEAS);
|
2010-03-23 06:49:51 -04:00
|
|
|
menu->Append(wxID_REVERT, _("Re&vert..."));
|
2000-07-15 15:51:35 -04:00
|
|
|
|
2008-10-03 11:16:01 -04:00
|
|
|
if ( supportsPrinting )
|
|
|
|
{
|
|
|
|
menu->AppendSeparator();
|
|
|
|
menu->Append(wxID_PRINT);
|
|
|
|
menu->Append(wxID_PRINT_SETUP, "Print &Setup...");
|
|
|
|
menu->Append(wxID_PREVIEW);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
wxMenu *MyApp::CreateDrawingEditMenu()
|
1998-05-22 15:57:05 -04:00
|
|
|
{
|
2008-10-03 11:16:01 -04:00
|
|
|
wxMenu * const menu = new wxMenu;
|
|
|
|
menu->Append(wxID_UNDO);
|
|
|
|
menu->Append(wxID_REDO);
|
|
|
|
menu->AppendSeparator();
|
|
|
|
menu->Append(wxID_CUT, "&Cut last segment");
|
2008-04-06 09:57:23 -04:00
|
|
|
|
2008-10-03 11:16:01 -04:00
|
|
|
return menu;
|
|
|
|
}
|
2008-04-06 09:57:23 -04:00
|
|
|
|
2008-10-03 11:16:01 -04:00
|
|
|
void MyApp::CreateMenuBarForFrame(wxFrame *frame, wxMenu *file, wxMenu *edit)
|
|
|
|
{
|
|
|
|
wxMenuBar *menubar = new wxMenuBar;
|
2008-04-06 09:57:23 -04:00
|
|
|
|
2008-10-03 11:16:01 -04:00
|
|
|
menubar->Append(file, wxGetStockLabel(wxID_FILE));
|
2008-04-06 09:57:23 -04:00
|
|
|
|
2008-10-03 11:16:01 -04:00
|
|
|
if ( edit )
|
|
|
|
menubar->Append(edit, wxGetStockLabel(wxID_EDIT));
|
2008-04-06 09:57:23 -04:00
|
|
|
|
2008-10-03 11:16:01 -04:00
|
|
|
wxMenu *help= new wxMenu;
|
|
|
|
help->Append(wxID_ABOUT);
|
|
|
|
menubar->Append(help, wxGetStockLabel(wxID_HELP));
|
2008-04-06 09:57:23 -04:00
|
|
|
|
2008-10-03 11:16:01 -04:00
|
|
|
frame->SetMenuBar(menubar);
|
|
|
|
}
|
2008-04-06 09:57:23 -04:00
|
|
|
|
2010-11-09 19:36:39 -05:00
|
|
|
wxFrame *MyApp::CreateChildFrame(wxView *view, bool isCanvas)
|
2008-10-03 11:16:01 -04:00
|
|
|
{
|
|
|
|
// create a child frame of appropriate class for the current mode
|
2018-05-12 18:11:41 -04:00
|
|
|
wxFrame *subframe = NULL;
|
2010-11-09 19:36:39 -05:00
|
|
|
wxDocument *doc = view->GetDocument();
|
2018-05-12 18:11:41 -04:00
|
|
|
switch ( GetMode() )
|
2008-10-03 11:16:01 -04:00
|
|
|
#if wxUSE_MDI_ARCHITECTURE
|
|
|
|
{
|
2018-05-12 18:11:41 -04:00
|
|
|
case Mode_MDI:
|
|
|
|
subframe = new wxDocMDIChildFrame
|
|
|
|
(
|
|
|
|
doc,
|
|
|
|
view,
|
|
|
|
wxStaticCast(GetTopWindow(), wxDocMDIParentFrame),
|
|
|
|
wxID_ANY,
|
|
|
|
"Child Frame",
|
|
|
|
wxDefaultPosition,
|
|
|
|
wxSize(300, 300)
|
|
|
|
);
|
|
|
|
break;
|
2008-10-03 11:16:01 -04:00
|
|
|
#endif // wxUSE_MDI_ARCHITECTURE
|
|
|
|
|
2018-05-12 18:11:41 -04:00
|
|
|
#if wxUSE_AUI
|
|
|
|
case Mode_AUI:
|
|
|
|
subframe = new wxDocChildFrameAny<wxAuiMDIChildFrame, wxAuiMDIParentFrame>
|
|
|
|
(
|
|
|
|
doc,
|
|
|
|
view,
|
|
|
|
wxStaticCast(GetTopWindow(), wxAuiMDIParentFrame),
|
|
|
|
wxID_ANY,
|
|
|
|
"Child Frame",
|
|
|
|
wxDefaultPosition,
|
|
|
|
wxSize(300, 300)
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
#endif // wxUSE_AUI
|
|
|
|
|
|
|
|
case Mode_SDI:
|
|
|
|
case Mode_Single:
|
|
|
|
subframe = new wxDocChildFrame
|
|
|
|
(
|
|
|
|
doc,
|
|
|
|
view,
|
|
|
|
wxStaticCast(GetTopWindow(), wxDocParentFrame),
|
|
|
|
wxID_ANY,
|
|
|
|
"Child Frame",
|
|
|
|
wxDefaultPosition,
|
|
|
|
wxSize(300, 300)
|
|
|
|
);
|
|
|
|
|
|
|
|
subframe->Centre();
|
|
|
|
break;
|
2008-04-06 09:57:23 -04:00
|
|
|
}
|
|
|
|
|
2008-10-03 11:16:01 -04:00
|
|
|
wxMenu *menuFile = new wxMenu;
|
2008-04-06 09:57:23 -04:00
|
|
|
|
2008-10-03 11:16:01 -04:00
|
|
|
menuFile->Append(wxID_NEW);
|
|
|
|
menuFile->Append(wxID_OPEN);
|
|
|
|
AppendDocumentFileCommands(menuFile, isCanvas);
|
|
|
|
menuFile->AppendSeparator();
|
|
|
|
menuFile->Append(wxID_EXIT);
|
2008-04-06 09:57:23 -04:00
|
|
|
|
2008-10-03 11:16:01 -04:00
|
|
|
wxMenu *menuEdit;
|
|
|
|
if ( isCanvas )
|
|
|
|
{
|
|
|
|
menuEdit = CreateDrawingEditMenu();
|
1998-05-22 15:57:05 -04:00
|
|
|
|
2008-10-03 11:16:01 -04:00
|
|
|
doc->GetCommandProcessor()->SetEditMenu(menuEdit);
|
|
|
|
doc->GetCommandProcessor()->Initialize();
|
|
|
|
}
|
|
|
|
else // text frame
|
|
|
|
{
|
|
|
|
menuEdit = new wxMenu;
|
|
|
|
menuEdit->Append(wxID_COPY);
|
|
|
|
menuEdit->Append(wxID_PASTE);
|
|
|
|
menuEdit->Append(wxID_SELECTALL);
|
|
|
|
}
|
2000-07-15 15:51:35 -04:00
|
|
|
|
2008-10-03 11:16:01 -04:00
|
|
|
CreateMenuBarForFrame(subframe, menuFile, menuEdit);
|
1998-05-22 15:57:05 -04:00
|
|
|
|
2008-10-03 11:16:01 -04:00
|
|
|
subframe->SetIcon(isCanvas ? wxICON(chrt) : wxICON(notepad));
|
1998-05-22 15:57:05 -04:00
|
|
|
|
2008-10-03 11:16:01 -04:00
|
|
|
return subframe;
|
1998-05-22 15:57:05 -04:00
|
|
|
}
|
|
|
|
|
2008-10-03 11:16:01 -04:00
|
|
|
void MyApp::OnAbout(wxCommandEvent& WXUNUSED(event))
|
1998-05-22 15:57:05 -04:00
|
|
|
{
|
2008-10-03 11:16:01 -04:00
|
|
|
wxString modeName;
|
|
|
|
switch ( m_mode )
|
|
|
|
{
|
|
|
|
#if wxUSE_MDI_ARCHITECTURE
|
|
|
|
case Mode_MDI:
|
|
|
|
modeName = "MDI";
|
|
|
|
break;
|
|
|
|
#endif // wxUSE_MDI_ARCHITECTURE
|
|
|
|
|
2018-05-12 18:11:41 -04:00
|
|
|
#if wxUSE_AUI
|
|
|
|
case Mode_AUI:
|
|
|
|
modeName = "AUI";
|
|
|
|
break;
|
|
|
|
#endif // wxUSE_AUI
|
|
|
|
|
2008-10-03 11:16:01 -04:00
|
|
|
case Mode_SDI:
|
|
|
|
modeName = "SDI";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Mode_Single:
|
|
|
|
modeName = "single document";
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
wxFAIL_MSG( "unknown mode ");
|
|
|
|
}
|
2012-11-26 18:53:44 -05:00
|
|
|
|
|
|
|
const int docsCount =
|
|
|
|
wxDocManager::GetDocumentManager()->GetDocumentsVector().size();
|
1998-05-22 15:57:05 -04:00
|
|
|
|
2008-10-03 11:16:01 -04:00
|
|
|
wxLogMessage
|
|
|
|
(
|
|
|
|
"This is the wxWidgets Document/View Sample\n"
|
|
|
|
"running in %s mode.\n"
|
2012-11-24 12:37:12 -05:00
|
|
|
"%d open documents.\n"
|
2008-10-03 11:16:01 -04:00
|
|
|
"\n"
|
|
|
|
"Authors: Julian Smart, Vadim Zeitlin\n"
|
|
|
|
"\n"
|
2018-05-12 18:11:41 -04:00
|
|
|
"Usage: docview [--{mdi,aui,sdi,single}]",
|
2012-11-24 12:37:12 -05:00
|
|
|
modeName,
|
2012-11-26 18:53:44 -05:00
|
|
|
docsCount
|
2008-10-03 11:16:01 -04:00
|
|
|
);
|
1998-05-22 15:57:05 -04:00
|
|
|
}
|