projects
/
wxWidgets.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
create collate_key on demand
[wxWidgets.git]
/
samples
/
docview
/
docview.cpp
diff --git
a/samples/docview/docview.cpp
b/samples/docview/docview.cpp
index 69d22c48a46d4a663a4b702401b6e5bc895a9272..c8d4adcf7368e737efbdcbae27e2f1e24bc85836 100644
(file)
--- a/
samples/docview/docview.cpp
+++ b/
samples/docview/docview.cpp
@@
-7,7
+7,7
@@
// RCS-ID: $Id$
// Copyright: (c) 1998 Julian Smart
// (c) 2008 Vadim Zeitlin
// RCS-ID: $Id$
// Copyright: (c) 1998 Julian Smart
// (c) 2008 Vadim Zeitlin
-// Licence: wxWindows licen
s
e
+// Licence: wxWindows licen
c
e
/////////////////////////////////////////////////////////////////////////////
/*
/////////////////////////////////////////////////////////////////////////////
/*
@@
-55,12
+55,13
@@
#include "view.h"
#include "wx/cmdline.h"
#include "view.h"
#include "wx/cmdline.h"
+#include "wx/config.h"
#ifdef __WXMAC__
#include "wx/filename.h"
#endif
#ifdef __WXMAC__
#include "wx/filename.h"
#endif
-#if
!defined(__WXMSW__) && !defined(__WXPM__)
+#if
ndef wxHAS_IMAGES_IN_RESOURCES
#include "doc.xpm"
#include "chart.xpm"
#include "notepad.xpm"
#include "doc.xpm"
#include "chart.xpm"
#include "notepad.xpm"
@@
-148,7
+149,12
@@
bool MyApp::OnInit()
if ( !wxApp::OnInit() )
return false;
if ( !wxApp::OnInit() )
return false;
- SetAppName("DocView Sample");
+ ::wxInitAllImageHandlers();
+
+ // Fill in the application information fields before creating wxConfig.
+ SetVendorName("wxWidgets");
+ SetAppName("wx_docview_sample");
+ SetAppDisplayName("wxWidgets DocView Sample");
//// Create a document manager
wxDocManager *docManager = new wxDocManager;
//// Create a document manager
wxDocManager *docManager = new wxDocManager;
@@
-157,7
+163,7
@@
bool MyApp::OnInit()
new wxDocTemplate(docManager, "Drawing", "*.drw", "", "drw",
"Drawing Doc", "Drawing View",
CLASSINFO(DrawingDocument), CLASSINFO(DrawingView));
new wxDocTemplate(docManager, "Drawing", "*.drw", "", "drw",
"Drawing Doc", "Drawing View",
CLASSINFO(DrawingDocument), CLASSINFO(DrawingView));
-#if defined( __WXMAC__ ) &&
defined( wxOSX_USE_CARBON )
+#if defined( __WXMAC__ ) &&
wxOSX_USE_CARBON
wxFileName::MacRegisterDefaultTypeAndCreator("drw" , 'WXMB' , 'WXMA');
#endif
wxFileName::MacRegisterDefaultTypeAndCreator("drw" , 'WXMB' , 'WXMA');
#endif
@@
-173,9
+179,13
@@
bool MyApp::OnInit()
new wxDocTemplate(docManager, "Text", "*.txt;*.text", "", "txt;text",
"Text Doc", "Text View",
CLASSINFO(TextEditDocument), CLASSINFO(TextEditView));
new wxDocTemplate(docManager, "Text", "*.txt;*.text", "", "txt;text",
"Text Doc", "Text View",
CLASSINFO(TextEditDocument), CLASSINFO(TextEditView));
-#if defined( __WXMAC__ )
&& defined( wxOSX_USE_CARBON )
+#if defined( __WXMAC__ )
&& wxOSX_USE_CARBON
wxFileName::MacRegisterDefaultTypeAndCreator("txt" , 'TEXT' , 'WXMA');
#endif
wxFileName::MacRegisterDefaultTypeAndCreator("txt" , 'TEXT' , 'WXMA');
#endif
+ // Create a template relating image documents to their views
+ new wxDocTemplate(docManager, "Image", "*.png;*.jpg", "", "png;jpg",
+ "Image Doc", "Image View",
+ CLASSINFO(ImageDocument), CLASSINFO(ImageView));
}
// create the main frame window
}
// create the main frame window
@@
-211,26
+221,34
@@
bool MyApp::OnInit()
// A nice touch: a history of files visited. Use this menu.
docManager->FileHistoryUseMenu(menuFile);
// A nice touch: a history of files visited. Use this menu.
docManager->FileHistoryUseMenu(menuFile);
+#if wxUSE_CONFIG
+ docManager->FileHistoryLoad(*wxConfig::Get());
+#endif // wxUSE_CONFIG
+
if ( m_mode == Mode_Single )
{
m_canvas = new MyCanvas(NULL, frame);
m_menuEdit = CreateDrawingEditMenu();
if ( m_mode == Mode_Single )
{
m_canvas = new MyCanvas(NULL, frame);
m_menuEdit = CreateDrawingEditMenu();
+ docManager->CreateNewDocument();
}
CreateMenuBarForFrame(frame, menuFile, m_menuEdit);
frame->SetIcon(wxICON(doc));
}
CreateMenuBarForFrame(frame, menuFile, m_menuEdit);
frame->SetIcon(wxICON(doc));
- frame->Centre(
wxBOTH
);
- frame->Show(
true
);
+ frame->Centre();
+ frame->Show();
- SetTopWindow(frame);
return true;
}
int MyApp::OnExit()
{
return true;
}
int MyApp::OnExit()
{
- delete wxDocManager::GetDocumentManager();
+ wxDocManager * const manager = wxDocManager::GetDocumentManager();
+#if wxUSE_CONFIG
+ manager->FileHistorySave(*wxConfig::Get());
+#endif // wxUSE_CONFIG
+ delete manager;
return wxApp::OnExit();
}
return wxApp::OnExit();
}
@@
-240,6
+258,7
@@
void MyApp::AppendDocumentFileCommands(wxMenu *menu, bool supportsPrinting)
menu->Append(wxID_CLOSE);
menu->Append(wxID_SAVE);
menu->Append(wxID_SAVEAS);
menu->Append(wxID_CLOSE);
menu->Append(wxID_SAVE);
menu->Append(wxID_SAVEAS);
+ menu->Append(wxID_REVERT, _("Re&vert..."));
if ( supportsPrinting )
{
if ( supportsPrinting )
{
@@
-277,10
+296,11
@@
void MyApp::CreateMenuBarForFrame(wxFrame *frame, wxMenu *file, wxMenu *edit)
frame->SetMenuBar(menubar);
}
frame->SetMenuBar(menubar);
}
-wxFrame *MyApp::CreateChildFrame(wx
Document *doc, wx
View *view, bool isCanvas)
+wxFrame *MyApp::CreateChildFrame(wxView *view, bool isCanvas)
{
// create a child frame of appropriate class for the current mode
wxFrame *subframe;
{
// create a child frame of appropriate class for the current mode
wxFrame *subframe;
+ wxDocument *doc = view->GetDocument();
#if wxUSE_MDI_ARCHITECTURE
if ( GetMode() == Mode_MDI )
{
#if wxUSE_MDI_ARCHITECTURE
if ( GetMode() == Mode_MDI )
{
@@
-309,7
+329,7
@@
wxFrame *MyApp::CreateChildFrame(wxDocument *doc, wxView *view, bool isCanvas)
wxSize(300, 300)
);
wxSize(300, 300)
);
- subframe->Centre(
wxBOTH
);
+ subframe->Centre();
}
wxMenu *menuFile = new wxMenu;
}
wxMenu *menuFile = new wxMenu;
@@
-366,15
+386,24
@@
void MyApp::OnAbout(wxCommandEvent& WXUNUSED(event))
wxFAIL_MSG( "unknown mode ");
}
wxFAIL_MSG( "unknown mode ");
}
+#ifdef __VISUALC6__
+ const int docsCount =
+ wxDocManager::GetDocumentManager()->GetDocuments().GetCount();
+#else
+ const int docsCount =
+ wxDocManager::GetDocumentManager()->GetDocumentsVector().size();
+#endif
+
wxLogMessage
(
"This is the wxWidgets Document/View Sample\n"
"running in %s mode.\n"
wxLogMessage
(
"This is the wxWidgets Document/View Sample\n"
"running in %s mode.\n"
+ "%d open documents.\n"
"\n"
"Authors: Julian Smart, Vadim Zeitlin\n"
"\n"
"Usage: docview [--{mdi,sdi,single}]",
"\n"
"Authors: Julian Smart, Vadim Zeitlin\n"
"\n"
"Usage: docview [--{mdi,sdi,single}]",
- modeName
+ modeName,
+ docsCount
);
}
);
}
-