23 #include "docviewprec.h"
52 #if wxUSE_PRINTING_ARCHITECTURE
53 #include "wx/prntbase.h"
54 #include "wx/printdlg.h"
57 #include "wx/msgdlg.h"
58 #include "wx/choicdlg.h"
59 #include "wx/confbase.h"
61 #include "wx/cmdproc.h"
63 #include "wx/tokenzr.h"
64 #include <wx/xrc/xmlres.h>
69 #include "wx/docview.h"
78 #if wxUSE_STD_IOSTREAM
79 #include "wx/ioswrap.h"
86 #include "wx/wfstream.h"
100 #pragma warning(disable: 4660)
118 #pragma warning(default: 4660)
141 DEFINE_EVENT_TYPE( wxEVT_SIGNAL )
142 DEFINE_EVENT_TYPE( wxEVT_DISCONNECT_ALLVIEWS )
143 DEFINE_EVENT_TYPE( wxEVT_SAVE_DOCUMENT )
144 DEFINE_EVENT_TYPE( wxEVT_SAVEAS_DOCUMENT )
145 DEFINE_EVENT_TYPE( wxEVT_EXPORT_DOCUMENT )
146 DEFINE_EVENT_TYPE( wxEVT_IMPORT_DOCUMENT )
147 DEFINE_EVENT_TYPE( wxEVT_CLOSE_DOCUMENT )
148 DEFINE_EVENT_TYPE( wxEVT_OPEN_DOCUMENT )
149 DEFINE_EVENT_TYPE( wxEVT_NEW_DOCUMENT )
150 DEFINE_EVENT_TYPE( wxEVT_CREATE_DOCUMENT )
151 DEFINE_EVENT_TYPE( wxEVT_ADD_VIEW )
152 DEFINE_EVENT_TYPE( wxEVT_REMOVE_VIEW )
153 DEFINE_EVENT_TYPE( wxEVT_UPDATE_VIEWS )
154 DEFINE_EVENT_TYPE( wxEVT_ENABLE_VIEWS )
155 DEFINE_EVENT_TYPE( wxEVT_DISCONNECT_VIEW )
157 DEFINE_EVENT_TYPE( wxEVT_REPORT_VIEWS )
158 DEFINE_EVENT_TYPE( wxEVT_CHANGEDFILENAME_DOCUMENT )
159 DEFINE_EVENT_TYPE( wxEVT_CHANGEDTITLE_DOCUMENT )
160 DEFINE_EVENT_TYPE( wxEVT_CHANGEDMODIFY_DOCUMENT )
161 DEFINE_EVENT_TYPE( wxEVT_POST_LOAD_DOCUMENT )
163 DEFINE_EVENT_TYPE( wxEVT_CLOSE_VIEW )
164 DEFINE_EVENT_TYPE( wxEVT_CREATE_VIEW )
165 DEFINE_EVENT_TYPE( wxEVT_SET_DOCUMENT )
166 DEFINE_EVENT_TYPE( wxEVT_ACTIVATE_VIEW )
167 DEFINE_EVENT_TYPE( wxEVT_ACTIVATE_VIEW_SENT_FROM_CHILD )
168 DEFINE_EVENT_TYPE( wxEVT_ENABLE_VIEW )
169 DEFINE_EVENT_TYPE( wxEVT_CHANGEDFILENAME_VIEW )
170 DEFINE_EVENT_TYPE( wxEVT_CHANGEDTITLE_VIEW )
172 DEFINE_EVENT_TYPE( wxEVT_PRE_ADD_DOCUMENT )
173 DEFINE_EVENT_TYPE( wxEVT_POST_CREATE_DOCUMENT )
174 DEFINE_EVENT_TYPE( wxEVT_POST_CREATE_VIEW )
176 #if wxUSE_PRINTING_ARCHITECTURE
184 static inline wxString FindExtension(
const wxChar* path );
206 static wxString FindExtension(
const wxChar* path )
209 wxFileName::SplitPath( path, NULL, NULL, &ext );
246 if ( mask == a2dTemplateFlag::NON )
248 if ( mask == a2dTemplateFlag::ALL )
252 if ( 0 < ( mask & a2dTemplateFlag::VISIBLE ) && !
m_visible )
return false;
253 if ( 0 < ( mask & a2dTemplateFlag::MARK ) && !
m_mark )
return false;
254 if ( 0 < ( mask & a2dTemplateFlag::LOAD ) && !
m_load )
return false;
255 if ( 0 < ( mask & a2dTemplateFlag::SAVE ) && !
m_save )
return false;
256 if ( 0 < ( mask & a2dTemplateFlag::IMPORTING ) && !
m_import )
return false;
257 if ( 0 < ( mask & a2dTemplateFlag::EXPORTING ) && !
m_export )
return false;
264 if ( which == a2dTemplateFlag::ALL )
303 case a2dTemplateFlag::VISIBLE:
return m_visible;
304 case a2dTemplateFlag::MARK:
return m_mark;
305 case a2dTemplateFlag::LOAD:
return m_load;
306 case a2dTemplateFlag::SAVE:
return m_save;
307 case a2dTemplateFlag::IMPORTING:
return m_import;
308 case a2dTemplateFlag::EXPORTING:
return m_export;
310 wxFAIL_MSG( wxT(
"This Flag not implemented" ) );
337 m_askSaveWhenOwned =
true;
339 m_documentModified = 0;
340 m_documentParent = parent;
343 m_documentTitle = wxT(
"" );
345 m_documentTypeName = wxT(
"" );
346 m_documentFile = wxFileName();
352 m_modificationtime = wxDateTime::Now();
395 bool a2dDocument::SmrtPtrRelease()
404 wxASSERT_MSG(
m_refcount >= 0, wxT(
"a2dDocument::Release Negative reference count" ) );
451 a2dDocumentEvent eventremoveall( wxEVT_DISCONNECT_ALLVIEWS,
m_documentFile );
452 eventremoveall.SetEventObject(
this );
454 ProcessEvent( eventremoveall );
465 a2dCloseDocumentEvent event(
m_id );
466 event.SetEventObject(
this );
467 event.SetCanVeto( !force );
471 if ( ProcessEvent( event ) && !event.GetVeto() )
496 else if ( event.CanVeto() )
499 wxFAIL_MSG( wxT(
"You can not Cancel this Close Document event" ) );
508 wxString name = wxT(
"" );
521 event.SetEventObject(
this );
523 if ( ProcessEvent( event ) && event.
IsAllowed() )
532 wxString filename = fileTosaveTo.GetFullPath();
533 a2dDocumentEvent event( wxEVT_SAVEAS_DOCUMENT, filename.IsEmpty() ?
m_documentFile : fileTosaveTo, flags );
535 event.SetEventObject(
this );
537 if ( ProcessEvent( event ) && event.IsAllowed() )
556 wxString fullname = event.
GetFileName().GetFullName();
558 + wxT(
" (" ) << docTemplate->
GetFileFilter() << wxT(
") |" )
563 fullname = wxFileSelector( _(
"Save as" ),
568 wxFD_SAVE | wxFD_OVERWRITE_PROMPT,
571 if ( fullname.IsEmpty() )
579 wxFileName::SplitPath( fullname, NULL, NULL, &ext );
583 fullname += wxT(
"." );
587 #if wxUSE_STD_IOSTREAM
588 a2dDocumentFileOutputStream store( fullname.mb_str(), wxSTD ios_base::out | wxSTD ios_base::binary );
589 if ( store.fail() || store.bad() )
598 wxFileOutputStream storeUnbuf( fullname );
599 if ( storeUnbuf.GetLastError() != wxSTREAM_NO_ERROR )
607 wxBufferedOutputStream store( storeUnbuf );
614 handler->SetFileName( fullname );
634 wxString filetosave = event.
GetFileName().GetFullPath();
649 #if wxUSE_STD_IOSTREAM
650 a2dDocumentFileOutputStream store( filetosave.mb_str(), wxSTD ios_base::out | wxSTD ios_base::binary );
651 if ( store.fail() || store.bad() )
660 wxFileOutputStream storeUnbuf( filetosave );
661 if ( storeUnbuf.GetLastError() != wxSTREAM_NO_ERROR )
669 wxBufferedOutputStream store( storeUnbuf );
684 handler->SetFileName( filetosave );
702 wxString filename = fileTosaveTo.GetFullPath();
703 a2dDocumentEvent event( wxEVT_EXPORT_DOCUMENT, doctemplate, filename.IsEmpty() ?
m_documentFile : fileTosaveTo, flags );
704 event.SetEventObject(
this );
706 if ( ProcessEvent( event ) && event.IsAllowed() )
726 if ( path.IsEmpty() )
734 wxString fileName( path );
736 wxFileName::SplitPath( fileName, & path, & name, & ext );
738 if ( ext.IsEmpty() || ext == wxT(
"" ) )
740 fileName += wxT(
"." );
744 #if wxUSE_STD_IOSTREAM
745 a2dDocumentFileOutputStream store( fileName.mb_str(), wxSTD ios_base::out | wxSTD ios_base::binary );
746 if ( store.fail() || store.bad() )
755 wxFileOutputStream storeUnbuf( fileName );
756 if ( storeUnbuf.GetLastError() != wxSTREAM_NO_ERROR )
764 wxBufferedOutputStream store( storeUnbuf );
771 handler->SetFileName( fileName );
788 wxString filename = fileToImport.GetFullPath();
789 a2dDocumentEvent event( wxEVT_IMPORT_DOCUMENT, doctemplate, filename, flags );
790 event.SetEventObject(
this );
792 if ( ProcessEvent( event ) && event.
IsAllowed() )
804 wxString path = file.GetFullPath();
814 if ( path.IsEmpty() )
821 wxString fileName( path );
823 wxFileName::SplitPath( fileName, & path, & name, & ext );
827 fileName += wxT(
"." );
833 #if wxUSE_STD_IOSTREAM
834 a2dDocumentFileInputStream store( fileName.mb_str(), wxSTD ios_base::in | wxSTD ios_base::binary );
835 if ( store.fail() || store.bad() )
843 wxFileInputStream storeUnbuf( fileName );
844 if ( !storeUnbuf.Ok() )
851 wxBufferedInputStream store( storeUnbuf );
857 handler->SetFileName( path );
859 #if wxUSE_STD_IOSTREAM
863 int res =
LoadObject( store, handler ).GetLastError();
885 #if wxUSE_STD_IOSTREAM
886 a2dDocumentFileInputStream store( file.GetFullPath().mb_str(), wxSTD ios_base::in | wxSTD ios_base::binary );
887 if ( store.fail() || store.bad() )
896 wxFileInputStream storeUnbuf( file.GetFullPath() );
897 if ( !storeUnbuf.Ok() )
904 wxBufferedInputStream store( storeUnbuf );
919 handler->SetFileName( file.GetFullPath() );
921 #if wxUSE_STD_IOSTREAM
926 int res =
LoadObject( store, handler ).GetLastError();
944 #if wxUSE_STD_IOSTREAM
945 int isOK = ( stream.fail() || stream.bad() ) == 0;
947 int isOK = stream.IsOk ();
957 if ( !handler->
Load( stream,
this ) )
965 a2dDocumentEvent event( wxEVT_POST_LOAD_DOCUMENT );
966 event.SetEventObject(
this );
967 ProcessEvent( event );
991 #if wxART2D_USE_CVGIO
997 if ( parser.
GetName() == wxT(
"title" ) )
1013 out.WriteAttribute( wxT(
"classname" ), GetClassInfo()->GetClassName() );
1027 out.WriteAttribute( wxT(
"classname" ), GetClassInfo()->GetClassName() );
1035 #endif //wxART2D_USE_CVGIO
1039 #if wxUSE_STD_IOSTREAM
1040 int isOK = ( stream.fail() || stream.bad() ) == 0;
1042 int isOK = stream.IsOk ();
1049 if ( handler->
CanSave(
this ) )
1051 if ( !handler->
Save( stream,
this ) )
1097 return _(
"unnamed" );
1103 return wxTheApp->GetTopWindow();
1122 wxString title = _(
"unnamed" );
1128 if ( wxTheApp->GetAppName() != wxT(
"" ) )
1129 msgTitle = wxTheApp->GetAppName();
1131 msgTitle = _(
"Warning" );
1134 prompt.Printf( _(
"Do you want to save changes to document %s?" ),
1135 (
const wxChar* )title );
1137 int res = wxMessageBox( prompt, msgTitle,
1138 canCancel ? wxYES_NO | wxCANCEL | wxICON_QUESTION : wxYES_NO | wxICON_QUESTION,
1146 else if ( res == wxYES )
1153 else if ( res == wxCANCEL )
1174 a2dDocumentEvent event( wxEVT_CHANGEDMODIFY_DOCUMENT );
1175 event.SetEventObject(
this );
1176 ProcessEvent( event );
1181 a2dDocumentEvent event( wxEVT_REPORT_VIEWS, allviews );
1182 event.SetEventObject(
this );
1183 ProcessEvent( event );
1188 a2dDocumentEvent event( wxEVT_UPDATE_VIEWS, sender );
1189 event.SetEventObject(
this );
1190 event.SetUpdateHint( hint );
1191 event.SetUpdateObject( objecthint );
1192 ProcessEvent( event );
1197 a2dDocumentEvent event( wxEVT_ENABLE_VIEWS, sender, enable );
1198 event.SetEventObject(
this );
1199 ProcessEvent( event );
1210 event.SetEventObject(
this );
1211 ProcessEvent( event );
1224 event.SetEventObject(
this );
1225 ProcessEvent( event );
1255 m_viewTypeName = wxT(
"" );
1259 m_viewEnabled =
true;
1282 wxASSERT_MSG(
m_refcount == 0, wxT(
"deleting a2dView while referenced" ) );
1295 bool a2dView::SmrtPtrRelease()
1299 wxASSERT_MSG(
m_refcount >= 0, wxT(
"a2dView::Release Negative reference count" ) );
1310 if ( GetEvtHandlerEnabled() )
1324 bool restorestate = GetEvtHandlerEnabled();
1329 a2dViewEvent event( wxEVT_ENABLE_VIEW, enable,
m_id );
1330 event.SetEventObject(
this );
1332 SetEvtHandlerEnabled(
false );
1333 event.ResumePropagation( wxEVENT_PROPAGATE_MAX );
1334 m_display->GetEventHandler()->ProcessEvent( event );
1335 event.StopPropagation();
1339 SetEvtHandlerEnabled(
true );
1343 a2dViewEvent Event( wxEVT_ENABLE_VIEW, enable,
m_id );
1344 Event.SetEventObject(
this );
1350 SetEvtHandlerEnabled( restorestate );
1364 bool viewRemoved =
false;
1369 a2dDocumentEvent eventremove( wxEVT_REMOVE_VIEW,
this,
true,
m_id );
1370 eventremove.SetEventObject(
this );
1389 a2dDocumentEvent eventadd( wxEVT_ADD_VIEW,
this, viewRemoved ,
m_id );
1390 eventadd.SetEventObject(
this );
1395 viewevent.SetEventObject(
this );
1415 a2dViewEvent activateEvent( wxEVT_ACTIVATE_VIEW, activate,
m_id );
1416 activateEvent.SetEventObject(
this );
1419 bool oldEnableState = GetEvtHandlerEnabled();
1420 SetEvtHandlerEnabled(
false );
1424 a2dViewEvent activateEvent( wxEVT_ACTIVATE_VIEW_SENT_FROM_CHILD, activate,
m_id );
1425 activateEvent.SetEventObject(
this );
1426 activateEvent.ResumePropagation( wxEVENT_PROPAGATE_MAX );
1427 m_display->GetEventHandler()->ProcessEvent( activateEvent );
1428 activateEvent.StopPropagation();
1431 SetEvtHandlerEnabled( oldEnableState );
1441 ( event.GetEventType() == wxEVT_ENABLE_VIEW ) ||
1442 ( event.GetEventType() == wxEVT_ENABLE_VIEWS )
1448 bool processed =
false;
1450 if ( event.GetEventType() == wxEVT_ACTIVATE )
1459 else if ( event.GetEventType() == wxEVT_SET_FOCUS )
1461 processed = a2dObject::ProcessEvent( event );
1469 else if ( event.GetEventType() == wxEVT_KILL_FOCUS )
1475 processed = a2dObject::ProcessEvent( event );
1479 else if ( event.GetEventType() == wxEVT_CLOSE_WINDOW )
1481 wxCloseEvent& closeevent = ( wxCloseEvent& ) event;
1487 processed =
Close( !closeevent.CanVeto() );
1492 processed =
Close( !closeevent.CanVeto() );
1495 else if ( event.GetEventType() == wxEVT_IDLE )
1504 processed = a2dObject::ProcessEvent( event );
1512 if (
this != event.GetEventObject() )
1525 bool processed =
false;
1533 event.SetEventObject(
this );
1534 processed =
m_viewTemplate->GetViewConnector()->ProcessEvent( event );
1566 a2dCloseViewEvent event(
m_id );
1567 event.SetEventObject(
this );
1573 SetEvtHandlerEnabled(
false );
1575 SetEvtHandlerEnabled(
true );
1589 bool oldEnableState = GetEvtHandlerEnabled();
1590 SetEvtHandlerEnabled(
false );
1591 event.ResumePropagation( wxEVENT_PROPAGATE_MAX );
1593 m_display->GetEventHandler()->ProcessEvent( event );
1594 event.StopPropagation();
1595 SetEvtHandlerEnabled( oldEnableState );
1615 a2dDocumentEvent eventremove( wxEVT_REMOVE_VIEW,
this,
true,
m_id );
1616 eventremove.SetEventObject(
this );
1643 a2dDocumentEvent event( wxEVT_UPDATE_VIEWS,
this );
1646 event.SetUpdateHint( hint );
1647 event.SetUpdateObject( hintObject );
1660 event.GetReportList()->push_back(
this );
1665 if (
this != event.GetEventObject() )
1685 bool oldEnableState = GetEvtHandlerEnabled();
1686 SetEvtHandlerEnabled(
false );
1691 eventView.SetEventObject(
this );
1692 eventView.ResumePropagation( wxEVENT_PROPAGATE_MAX );
1693 m_display->GetEventHandler()->ProcessEvent( eventView );
1694 eventView.StopPropagation();
1697 SetEvtHandlerEnabled( oldEnableState );
1705 bool oldEnableState = GetEvtHandlerEnabled();
1706 SetEvtHandlerEnabled(
false );
1711 eventView.SetEventObject(
this );
1712 eventView.ResumePropagation( wxEVENT_PROPAGATE_MAX );
1713 m_display->GetEventHandler()->ProcessEvent( eventView );
1714 eventView.StopPropagation();
1717 SetEvtHandlerEnabled( oldEnableState );
1720 #if wxUSE_PRINTING_ARCHITECTURE
1725 #endif // wxUSE_PRINTING_ARCHITECTURE
1741 const wxString& descr,
1742 const wxString& filter,
1743 const wxString& dir,
1744 const wxString& ext,
1745 const wxString& docTypeName,
1746 wxClassInfo* docClassInfo,
1747 a2dViewConnector* connector,
1765 #if wxUSE_PRINTING_ARCHITECTURE
1772 #if wxUSE_PRINTING_ARCHITECTURE
1778 a2dObject* a2dDocumentTemplate::SmrtPtrOwn()
1784 bool a2dDocumentTemplate::SmrtPtrRelease()
1788 wxASSERT_MSG(
m_refcount >= 0, wxT(
"a2dDocumentTemplate::Release Negative reference count" ) );
1797 a2dObject* a2dDocumentTemplate::DoClone( CloneOptions WXUNUSED( options ),
a2dRefMap* refs )
const
1799 wxLogMessage( _(
"Not implemented" ) );
1803 void a2dDocumentTemplate::SetPageSetupData( wxPageSetupDialogData* pageSetupData )
1805 #if wxUSE_PRINTING_ARCHITECTURE
1827 #if wxART2D_USE_CVGIO
1830 wxLogMessage( _(
"Not implemented" ) );
1835 wxLogMessage( _(
"Not implemented" ) );
1838 #endif //wxART2D_USE_CVGIO
1861 a2dDocumentEvent createdDocument( wxEVT_CREATE_DOCUMENT, path, flags );
1862 createdDocument.SetEventObject(
this );
1863 doc->ProcessEvent( createdDocument );
1876 a2dTemplateEvent preAddCreatedDocumentEvent( newDoc, wxEVT_PRE_ADD_DOCUMENT, flags );
1877 preAddCreatedDocumentEvent.SetEventObject(
this );
1879 ret =
m_connector->ProcessEvent( preAddCreatedDocumentEvent );
1882 ret = ProcessEvent( preAddCreatedDocumentEvent );
1893 a2dTemplateEvent postCreatedDocumentEvent( newDoc, wxEVT_POST_CREATE_DOCUMENT, flags );
1894 postCreatedDocumentEvent.SetEventObject(
this );
1896 ret =
m_connector->ProcessEvent( postCreatedDocumentEvent );
1899 ret = ProcessEvent( postCreatedDocumentEvent );
1907 if ( FindExtension( path ) != wxT(
"" ) )
1912 #if wxUSE_STD_IOSTREAM
1913 a2dDocumentFileInputStream store( path.mb_str(), wxSTD ios_base::in | wxSTD ios_base::binary );
1914 if ( store.fail() || store.bad() )
1920 wxFileInputStream storeUnbuf( path );
1921 if ( !storeUnbuf.Ok() )
1926 wxBufferedInputStream store( storeUnbuf );
1934 wxString anything = wxT (
"*" );
1935 while ( parser.HasMoreTokens() )
1937 wxString filter = parser.GetNextToken();
1938 wxString filterExt = FindExtension ( filter );
1939 if ( filter.IsSameAs ( anything ) ||
1940 filterExt.IsSameAs ( anything ) ||
1941 filterExt.IsSameAs ( FindExtension ( path ) ) )
1951 a2dDocumentTemplateAuto::a2dDocumentTemplateAuto(
1952 const wxString& descr,
1953 const wxString& filter,
1954 const wxString& dir,
1955 const wxString& ext,
1956 const wxString& docTypeName,
1957 wxClassInfo* docClassInfo,
1958 a2dViewConnector* connector,
1960 a2dDocumentTemplate( descr, filter, dir, ext, docTypeName, docClassInfo, connector, flags, NULL )
1972 for( a2dDocumentTemplateList::const_iterator iter = allDocTemplates.begin(); iter != allDocTemplates.end(); ++iter )
1974 a2dDocumentTemplateList::value_type temp = *iter;
1976 temp->GetDocumentIOHandlerStrIn() &&
1977 temp->GetDocumentIOHandlerStrIn()->CanLoad( stream, document, temp->GetDocumentClassInfo() ) )
1978 return temp->GetDocumentIOHandlerStrIn();
1987 for( a2dDocumentTemplateList::const_iterator iter = allDocTemplates.begin(); iter != allDocTemplates.end(); ++iter )
1989 a2dDocumentTemplateList::value_type temp = *iter;
1990 if ( temp !=
this && temp->GetDocumentTypeName() ==
GetDocumentTypeName() && temp->GetDocumentIOHandlerStrOut() && temp->GetDocumentIOHandlerStrOut()->CanSave( document ) )
1992 if ( filename.IsEmpty() )
1993 return temp->GetDocumentIOHandlerStrOut();
1996 wxString path, name, ext;
1997 wxFileName::SplitPath( filename, & path, & name, & ext );
1998 if ( ext == temp->GetDefaultExtension() )
1999 return temp->GetDocumentIOHandlerStrOut();
2010 const wxString& descr,
2011 const wxString& docTypeName,
2012 const wxString& viewTypeName,
2013 wxClassInfo* viewClassInfo,
2014 a2dViewConnector* connector,
2028 #if wxUSE_PRINTING_ARCHITECTURE
2035 #if wxUSE_PRINTING_ARCHITECTURE
2041 a2dObject* a2dViewTemplate::SmrtPtrOwn()
2047 bool a2dViewTemplate::SmrtPtrRelease()
2051 wxASSERT_MSG(
m_refcount >= 0, wxT(
"a2dViewTemplate::Release Negative reference count" ) );
2060 a2dObject* a2dViewTemplate::DoClone( CloneOptions WXUNUSED( options ),
a2dRefMap* refs )
const
2062 wxLogMessage( _(
"Not implemented" ) );
2066 void a2dViewTemplate::SetPageSetupData( wxPageSetupDialogData* pageSetupData )
2068 #if wxUSE_PRINTING_ARCHITECTURE
2075 #if wxART2D_USE_CVGIO
2078 wxLogMessage( _(
"Not implemented" ) ) ;
2083 wxLogMessage( _(
"Not implemented" ) );
2085 #endif //wxART2D_USE_CVGIO
2090 return ( a2dView* ) NULL;
2100 a2dViewEvent createdView( wxEVT_CREATE_VIEW, flags, view->
GetId() );
2101 createdView.SetEventObject(
this );
2106 a2dTemplateEvent postCreatedViewEvent( wxEVT_POST_CREATE_VIEW, view, flags );
2107 postCreatedViewEvent.SetEventObject(
this );
2108 m_connector->ProcessEvent( postCreatedViewEvent );
2113 return ( a2dView* ) NULL;
2120 BEGIN_EVENT_TABLE( a2dViewConnector,
a2dObject )
2126 a2dViewConnector::a2dViewConnector()
2128 m_initialPos = wxPoint( 0, 0 );
2129 m_initialSize = wxSize( 300, 400 );
2130 m_initialStyle = wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE;
2132 m_OnlyDisconnect =
false;
2137 wxASSERT_MSG(
m_refcount == 0, wxT(
"deleting a2dViewConnector while referenced" ) );
2166 void a2dViewConnector::OnPostCreateDocument( a2dTemplateEvent& event )
2169 a2dViewTemplate* viewtempl;
2174 true, event.GetTemplateMaskFlags() );
2178 wxLogMessage( _(
"No view available for this document in a2dViewConnector" ) );
2188 wxLogMessage( _(
"a2dViewConnector no view was created" ) );
2196 a2dViewTemplate* viewtempl;
2201 true, viewTemplateFlags );
2203 a2dView* createdView;
2207 wxLogMessage( _(
"No view available for this document in a2dViewConnector" ) );
2212 createdView = viewtempl->
CreateView( doc, flags );
2216 wxLogMessage( _(
"a2dViewConnector no view was created" ) );
2226 theViewToDisconnect->
Close(
true );
2230 theViewToDisconnect->
Activate(
false );
2233 a2dDocumentEvent eventremove( wxEVT_REMOVE_VIEW, theViewToDisconnect,
true, theViewToDisconnect->
GetId() );
2234 eventremove.SetEventObject( theViewToDisconnect );
2235 theViewToDisconnect->
GetDocument()->ProcessEvent( eventremove );
2241 void a2dViewConnector::OnCloseView( a2dCloseViewEvent& event )
2247 bool oldEnableState = theViewToClose->GetEvtHandlerEnabled();
2248 theViewToClose->SetEvtHandlerEnabled(
false );
2250 event.ResumePropagation( wxEVENT_PROPAGATE_MAX );
2252 theViewToClose->
GetDisplayWindow()->GetEventHandler()->ProcessEvent( event );
2253 event.StopPropagation();
2255 theViewToClose->SetEvtHandlerEnabled( oldEnableState );
2266 m_createChildframe =
false;
2272 m_createChildframe = other.m_createChildframe;
2278 m_createChildframe = createChildframe;
2281 void a2dFrameViewConnector::OnPostCreateView( a2dTemplateEvent& event )
2283 a2dView* newview = event.
GetView();
2286 if ( m_createChildframe )
2294 viewFrame->Show(
true );
2326 BEGIN_EVENT_TABLE( a2dDocumentViewScrolledWindow,
a2dViewWindow<wxScrolledWindow> )
2328 EVT_PAINT( a2dDocumentViewScrolledWindow::OnPaint )
2331 a2dDocumentViewScrolledWindow::a2dDocumentViewScrolledWindow( a2dView* view, wxWindow* parent, wxWindowID
id, const wxPoint& pos, const wxSize& size, const
long style, const wxString& name ):
2332 a2dViewWindow<wxScrolledWindow>( view, parent,
id, pos, size, style, name )
2337 a2dViewWindow<wxScrolledWindow>( parent, id, pos, size, style, name )
2356 a2dDocumentViewWindow::a2dDocumentViewWindow( a2dView* view, wxWindow* parent, wxWindowID
id, const wxPoint& pos, const wxSize& size, const
long style, const wxString& name ):
2357 a2dViewWindow<wxWindow>( view, parent,
id, pos, size, style, name )
2362 a2dViewWindow<wxWindow>( parent, id, pos, size, style, name )
2375 #if wxUSE_PRINTING_ARCHITECTURE
2377 a2dDocumentPrintout::a2dDocumentPrintout( a2dView* view,
const wxString& title )
2378 : wxPrintout( title )
2380 m_printoutView = view;
2383 bool a2dDocumentPrintout::OnPrintPage(
int WXUNUSED( page ) )
2388 int ppiScreenX, ppiScreenY;
2389 GetPPIScreen( &ppiScreenX, &ppiScreenY );
2390 int ppiPrinterX, ppiPrinterY;
2391 GetPPIPrinter( &ppiPrinterX, &ppiPrinterY );
2398 float scale = ( float )( (
float )ppiPrinterX / ( float )ppiScreenX );
2402 int pageWidth, pageHeight;
2404 dc->GetSize( &w, &h );
2405 GetPageSizePixels( &pageWidth, &pageHeight );
2409 float overallScale = scale * ( float )( w / (
float )pageWidth );
2410 dc->SetUserScale( overallScale, overallScale );
2412 if ( m_printoutView )
2414 m_printoutView->OnPrint( dc, NULL );
2419 bool a2dDocumentPrintout::HasPage(
int pageNum )
2421 return ( pageNum == 1 );
2424 bool a2dDocumentPrintout::OnBeginDocument(
int startPage,
int endPage )
2426 if ( !wxPrintout::OnBeginDocument( startPage, endPage ) )
2432 void a2dDocumentPrintout::GetPageInfo(
int* minPage,
int* maxPage,
int* selPageFrom,
int* selPageTo )
2440 #endif // wxUSE_PRINTING_ARCHITECTURE
2450 EVT_MENU( wxID_EXIT, a2dDocumentFrame::OnExit )
2451 EVT_MENU_RANGE( wxID_FILE1, wxID_FILE9, a2dDocumentFrame::OnMRUFile )
2454 EVT_CLOSE( a2dDocumentFrame::OnCloseWindow )
2455 EVT_PAINT( a2dDocumentFrame::OnPaint )
2459 a2dDocumentFrame::a2dDocumentFrame()
2461 m_destroyOnCloseView =
true;
2462 m_isParentFrame =
true;
2470 const wxString& title,
2474 const wxString& name )
2475 : wxFrame( frame, id, title, pos, size, style, name )
2489 const wxString& title,
2493 const wxString& name )
2494 : wxFrame( frame, id, title, pos, size, style, name )
2510 const wxString& title,
2514 const wxString& name )
2516 bool res = wxFrame::Create( frame,
id, title, pos, size, style, name );
2532 bool a2dDocumentFrame::ProcessConnectedEvent( wxEvent& event )
2536 event.Skip(
false );
2543 void a2dDocumentFrame::ConnectEvent( wxEventType type, wxEvtHandler* evtObject )
2548 bool a2dDocumentFrame::DisconnectEvent( wxEventType type, wxEvtHandler* evtObject )
2577 GetParent()->Refresh();
2587 a2dDocument* doc = ( ( a2dView* )event.GetEventObject() )->GetDocument();
2599 static wxEvent* ActiveEvent = NULL;
2602 if ( ActiveEvent == &event )
2605 ActiveEvent = &event;
2608 if ( event.GetEventType() == wxEVT_CLOSE_WINDOW )
2623 wxCloseEvent& closeevent = ( wxCloseEvent& ) event;
2629 if ( wxEvtHandler::ProcessEvent( event ) && !closeevent.GetVeto() )
2643 if ( wxTheApp->GetTopWindow() == this )
2661 if ( wxEvtHandler::ProcessEvent( event ) && !closeevent.GetVeto() )
2663 closeevent.SetCanVeto(
false );
2673 else if ( event.GetEventType() == wxEVT_ACTIVATE )
2682 ret = wxEvtHandler::ProcessEvent( event );
2684 else if ( event.GetEventType() == wxEVT_IDLE )
2691 ret = wxEvtHandler::ProcessEvent( event );
2701 if ( !wxEvtHandler::ProcessEvent( event ) )
2720 if ( event.CanVeto() )
2722 if ( !GetIsParentFrame() )
2754 int n = event.GetId() - wxID_FILE1;
2759 if ( wxFile::Exists( fileHistItem->m_filename.GetFullPath() ) )
2772 fileHistItem->m_filename.GetFullPath().c_str() );
2784 wxPaintDC dc(
this );
2802 m_view = ( a2dView* ) viewevent.GetEventObject();
2813 if ( ! GetToolBar() )
2819 wxString error = _T(
"No Bitmap for a2dToolCmd found for:" ) + cmdId.
GetIdName();
2820 wxASSERT_MSG( cmdId.GetBitmap().Ok(), error );
2821 GetToolBar()->AddTool( cmdId.
GetId(), cmdId.
GetLabel(), cmdId.GetBitmap(), cmdId.GetHelp(), cmdId.
GetKind() );
2824 void a2dDocumentFrame::ConnectCmdId(
const a2dMenuIdItem& cmdId )
2832 parentMenu->Append( item );
2838 parentMenu->Append( cmdId.
GetId(), wxGetTranslation( cmdId.
GetText() ), wxGetTranslation( cmdId.GetHelp() ), cmdId.
IsCheckable() );
2844 parentMenu->Delete( cmdId.
GetId() );
Automatic template, which searches a suitable handler for the document.
#define EVT_UPDATE_VIEWS(func)
event from a document when its views need to be updated
void EnableAllViews(bool enable, a2dView *sender=(a2dView *) NULL)
calls Enable( true/false ) for each view.
virtual void DeleteContents()
called when there is a need to clear the contents of the document.
a2dSmrtPtr< a2dCommandProcessor > m_commandProcessor
A pointer to the command processor associated with this document.
void DisassociateViewTemplates()
remove All references to a a2dViewTemplate from the wxViewTemplateReflist
a2dError m_lastError
error code used when LoadObject is returning.
virtual void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
Load settings.
a2dDocument * m_documentParent
parant document if set.
void ReportViews(a2dViewList *allviews)
sents a ::wxEVT_REPORT_VIEWS to all views, via the a2dDocumentCommandProcessor.
#define EVT_OPEN_DOCUMENT(func)
event for document when a document has been opened
bool IsModified() const
Has the document been modified.
void WriteElement(const wxString &name, const wxString &content=wxT(""), bool newLine=true)
Writes start and end tag.
const a2dError a2dError_NoDocTemplateRef
virtual wxString GetName() const
Returns the name of this object, if no name is given the internal id will be returned.
static const a2dTemplateFlagMask LOAD_IMPORT
wxString m_documentTypeName
The document type name given to the a2dDocumentTemplate constructor,.
virtual void OnPrint(wxDC *dc, wxObject *info)
called from a2dDocumentPrintout when printing a view.
#define EVT_SAVE_DOCUMENT(func)
event sent to document when a document needs to be saved
virtual a2dIOHandlerStrIn * GetDocumentIOHandlerForLoad(a2dDocumentInputStream &stream, a2dDocument *document)
if there is an io handler, and it can load the document of this template, return it ...
void OnCloseView(a2dCloseViewEvent &event)
Intercept to do cleanup/veto closing of a view.
XMLeventType Next()
Walks to next element and returns event type.
virtual bool Load(a2dDocumentInputStream &stream, wxObject *obj)=0
override to read the stream and store (part of) the contents in to a specific a2dDocument or othere o...
class to map references to objects stored in XML, in order to make the connection later on...
extend a2dViewConnector to have a a2dDocumentViewScrolledWindow for each view.
#define EVT_NEW_DOCUMENT(func)
event for document when a document new document was created
void SetFilename(const wxFileName &filename, bool notifyViews=false)
Sets the filename for this document. Usually called by the framework.
a2dViewConnector()
Constructor.
wxClassInfo * m_viewClassInfo
For dynamic creation of appropriate instances.
The a2dViewTemplate class is used to model the relationship between a document class and a view class...
void RemoveCmdMenu(wxMenu *parentMenu, const a2dMenuIdItem &cmdId)
remove a command menu from the parent menu.
a2dView * GetView()
Gives the a2dView in case of event types concerning a view.
const a2dError a2dError_CouldNotEvaluatePath
static const a2dTemplateFlagMask SAVE
wxString GetDirectory() const
Returns the default directory, as passed to the document template constructor.
void WriteStartElementAttributes(const wxString &name, bool newLine=true)
Writes start tag which has attributes.
const a2dPrintWhat a2dPRINT_Preview
general print preview
const a2dViewTemplateList & GetViewTemplates()
returns a reference to the a2dViewTemplateList, which contains all a2dViewTemplate's.
bool m_isClosed
set true when document is closed or when busy closing document.
a2dDocumentTemplate * GetDocumentTemplate() const
Gets a2dDocumentTemplate pointer which was used to create the a2dView.
a2dDocument(a2dDocument *parent=(a2dDocument *) NULL)
Constructor.
wxPageSetupDialogData * m_pageSetupData
this is the printer page setup data for all views with this template
virtual void SetDisplayWindow(wxWindow *display)
Set the display window.
bool Exit(bool force=true)
Called to Exit the application properly.
static const a2dTemplateFlagMask DEFAULT
const a2dError a2dError_NoError
wxWindow * GetDisplayWindow()
Get the display window.
void OnExportDocument(a2dDocumentEvent &event)
The default handler for ::wxEVT_EXPORT_DOCUMENT.
a2dObject * Clone(CloneOptions options, a2dRefMap *refs=NULL) const
create an exact copy of this property
wxString m_directory
The default directory for files of this type.
wxOutputStream a2dDocumentOutputStream
output stream based wxStreams
void OnNewDocument(a2dDocumentEvent &event)
called after creating a new document from a template , in order to initialize it. ...
void ConnectEvent(wxEventType type, wxEvtHandler *eventSink)
void SetError(a2dError error)
in case of errors when sending an event, this can be set to tell the reason of failure ...
The a2dDocumentTemplate class is used to model the relationship between a document class and files...
static const a2dTemplateFlagMask SAVE_EXPORT
a2dCommandProcessor * GetCommandProcessor() const
Returns a pointer to the command processor associated with this document.
void OnDisConnectView(a2dTemplateEvent &event)
handler for ::wxEVT_DISCONNECT_VIEW
const a2dError a2dError_FileCouldNotOpen
virtual ~a2dViewConnector()=0
destructor
void SetClosed()
sets closed flag to true, and calls Release() view.
Input and output handler for the XmlSer format.
wxString GetDescription() const
Returns the text description of this template, as passed to the document template constructor...
void AddCmdToToolbar(const a2dMenuIdItem &cmdId)
add items to toolbar using a predefined command ID.
void OnDisConnectView(a2dDocumentEvent &event)
handler for ::wxEVT_DISCONNECT_ALLVIEWS
void CheckCurrentView(a2dView *view)
Views do inform the document manager when a view will be destroyed.
a2dDocumentPtr m_documentCreate
if set this will be used instead of m_docClassInfo to initiate new documents
virtual a2dDocumentInputStream & LoadObject(a2dDocumentInputStream &stream, a2dIOHandlerStrIn *handler)
handling loading of the document from a stream
bool GetEnable()
when ::wxEVT_ENABLE_VIEW get enable value of the event
a2dView * GetView()
Get the view created.
#define EVT_SAVEAS_DOCUMENT(func)
event sent to document when a document needs to be saved in a different file
using a file stream for input, stream the file into a a2dDocument or other object ...
void OnCloseWindow(wxCloseEvent &event)
default for closing this frame via close button.
wxSize m_initialSize
size for new view
a2dSmrtPtr< a2dIOHandlerStrOut > m_ioHandlerStrOut
used for writing the document to streams.
void Load(wxObject *parent, a2dIOHandlerXmlSerIn &parser)
used by CVG parser
const a2dDocumentTemplateList & GetDocTemplates()
returns a reference to the a2dDocumentTemplateList, which contains all a2dDocumentTemplate's.
unsigned int a2dTemplateFlagMask
mask of flags for a2dTemplateFlag
bool SaveAs(const wxFileName &fileTosaveTo=wxFileName(wxT("")), a2dDocumentFlagMask flags=a2dREFDOC_NON)
Tries to save the document by sending a a2dDocumentEvent ::wxEVT_SAVEAS_DOCUMENT event.
virtual void OnDraw(wxDC *dc)=0
needs to be implemented to print a view, also so used for simple redrawing of views.
a2dView event, to report events in the a2dView class
bool m_mark
template is marked
bool m_askSaveWhenOwned
Set when Owners become zero and document will be deleted. May also be overruled by user...
bool m_export
template is for exporting documents
virtual bool CanLoad(a2dDocumentInputStream &stream, const wxObject *obj=NULL, wxClassInfo *docClassInfo=NULL)=0
Should return true if the handler can read from the stream.
This class is used to connect newly created a2dView's to a wxFrame and/or wxWindow.
wxPoint & GetInitialPosition()
Get position used for new created views or frames or windows.
Docview framework its controlling class.
wxString GetContent()
Returns the current content.
specialized wxWindow to handle a2dView events
#define EVT_ENABLE_VIEWS(func)
event from a document when its views need to be enabled or disabled
a2dSmrtPtr< a2dView > m_keepalive
a2dSmrtPtr< a2dDocument > m_viewDocument
the document to which this view belongs.
void OnImportDocument(a2dDocumentEvent &event)
The default handler for ::wxEVT_IMPORT_DOCUMENT.
bool GetActive()
when ::wxEVT_ACTIVATE_VIEW get activation value of the event
virtual a2dDocument * CreateDocument(const wxFileName &path, a2dDocumentFlagMask flags=a2dREFDOC_NON)
Creates a new document.
bool m_viewEnabled
Is the view enabled?
void OnOpenDocument(a2dDocumentEvent &event)
load a document from a file into this document
~a2dDocumentTemplate()
Destructor.
void WriteEndElement(bool newLine=true)
Writes correspondending end tag for the current start tag.
bool Close(bool force)
Closes the document if not vetod.
const a2dError a2dError_FileHistory
void OnChangeFilename(a2dViewEvent &event)
default handler for file changed event sent from a2dView
const a2dError a2dError_IOHandler
#define EVT_DISCONNECT_ALLVIEWS(func)
event for document before all view are closed.
void WriteStartDocument(const wxString &version, const wxString &encoding, bool standalone)
Writes the XML header declaration.
virtual void Update(unsigned int hint=0, wxObject *hintObject=NULL)
force a2dDocumentEvent ::wxEVT_UPDATE_VIEWS event
virtual void UpdateAllViews(a2dView *sender=(a2dView *) NULL, unsigned int hint=a2dVIEW_UPDATE_ALL, wxObject *objecthint=(wxObject *) NULL)
sent Update events to all a2dView which display or use this document.
bool IsClosed()
A closed flag is set when a view is closed.
void SetCanVeto(bool canVeto)
If the event can not be vetod this is set to false.
a2dSmrtPtr< a2dViewConnector > m_connector
class used to connect new views with Frames and windows.
const a2dError a2dError_CouldNotCreateDocument
virtual a2dError CreateDocuments(const wxString &path, a2dDocumentFlagMask documentflags=a2dREFDOC_NON, a2dDocumentTemplate *wantedDocTemplate=NULL, int dialogflags=wxFD_OPEN, a2dTemplateFlagMask docTemplateFlags=a2dTemplateFlag::VISIBLE)
Creates new documents in a manner determined by the flags parameter, which can be: ...
Holds a view on a a2dDocument.
void AssociateViewTemplate(a2dViewTemplate *temp)
add a reference to a a2dViewTemplate to the wxViewTemplateReflist
virtual void CreateCommandProcessor()
create a command processor and set it for the document.
wxString m_docTypeName
The named type of the document associated with this template.
void OnRemoveView(a2dDocumentEvent &event)
what to do when a view using this document will stop using it.
event sent to a2dViewConnector
#define EVT_REPORT_VIEWS(func)
event from a document when its views need to reported
a2dView * GetView()
get the pointer to a a2dView to which view events are sent
~a2dDocumentFrame()
destructor
#define EVT_ADD_VIEW(func)
event sent to document when a view has been added to the document
#define EVT_CLOSE_DOCUMENT(func)
event for document before a document will be closed ( can veto)
void OnChangeFilename(a2dDocumentEvent &event)
default handler for file changed event sent from a2dDocument with type wxEVT_CHANGEDFILENAME_DOCUMENT...
void OnCmdMenuId(wxCommandEvent &event)
wxDateTime m_modificationtime
last modification time when this document was stored.
a2dDocument * GetDocument()
the document created.
The document class can be used to model an application's file-based data.
bool m_visible
template is visible
void DisConnectAllViews()
Disconnect a2dView's using this document.
const a2dError a2dError_SaveFile
static const a2dTemplateFlagMask NON
bool Create(bool parentFrame, wxWindow *frame, a2dView *view=NULL, wxWindowID id=-1, const wxString &title=wxT("a2dDocumentFrame"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_FRAME_STYLE, const wxString &name=wxT("frame"))
Constructor for two-step-creation (2nd step)
void AddCmdMenu(wxMenu *parentMenu, const a2dMenuIdItem &cmdId)
add a menu to the parent menu, and connect it to the eventhandler of the frame
virtual a2dFileHistoryItem * GetHistoryFileItem(size_t i) const
return the a2dFileHistoryItem of the i'th file in the history
#define EVT_DISCONNECT_VIEW(func)
event sent to connector to disconnect a certain view from its document
wxSize m_initialSize
size for new frames
void SetDocumentTemplate(a2dDocumentTemplate *temp)
Set a2dDocumentTemplate pointer.
bool ProcessEvent(wxEvent &event)
Modified event handler to also sent event to a2dView or wxDocviewCommonEvents.
wxString m_documentTitle
Document title.
#define EVT_CHANGEDFILENAME_DOCUMENT(func)
event sent to view when the filename of a document has changed.
bool Clear(bool force=true)
Clear remaining documents and templates.
virtual void ReportError(const a2dError &error, const wxString &errorstr=wxEmptyString)
concatenate to the the error report the given error.
void OnSetFocus(wxFocusEvent &event)
called on (de)activating (wxWindow) containing the view.
virtual bool ProcessEvent(wxEvent &event)
void Veto()
veto the operation (usually it's allowed by default)
wxUint16 a2dPrintWhat
defines what to print
Docview classes for document view, window and frame.
const a2dPrintWhat a2dPRINT_PreviewDocument
preview print a2dDocument
long m_documentModified
modified flag
void OnAddView(a2dDocumentEvent &event)
what to do when a view starts using this document
virtual bool MakeDefaultName(wxString &buf)
Make a default document name.
bool IsAllowed() const
for implementation code only: is the operation allowed?
void OnCloseView(a2dCloseViewEvent &event)
::wxEVT_CLOSE_VIEW event handler to do cleanup/veto Close of the view.
The a2dDocumentFrame class provides a default frame for displaying documents.
bool m_isClosed
close flag, to indicate that the view is being closed are is closed.
const a2dError a2dError_CouldNotLoad
void OnKillFocus(wxFocusEvent &event)
when a view goes out of focus ( when only one view per window
virtual a2dIOHandlerStrOut * GetDocumentIOHandlerForSave(const wxString &filename, a2dDocument *document)
if there is an io handler, and it can save the document of this template, return it ...
wxString GetFileFilter() const
Returns the file filter, as passed to the document template constructor.
#define EVT_CLOSE_VIEW(func)
event sent to document and view when a view needs to be closed ( can veto)
a2dDocument * SentPreAddCreatedDocumentEvent(a2dDocument *newDoc, a2dDocumentFlagMask flags)
sents a wxEVT_PRE_ADD_DOCUMENT event to m_connector if available.
void OnEnable(a2dViewEvent &event)
default handler for EVT_ENABLE_VIEW event.
#define EVT_POST_CREATE_DOCUMENT(func)
sent from a doc template after it created a document
void Veto(bool veto=true)
use to veto event when the closing of the view needs to be refused in a handler.
bool m_import
template is for importing documents
#define EVT_ACTIVATE_VIEW_SENT_FROM_CHILD(func)
event sent from view and its display up the parent chain.
void OnChangeTitle(a2dDocumentEvent &event)
default handler for file changed event sent from a2dDocument with type wxEVT_CHANGEDTITLE_DOCUMENT ...
a2dViewTemplate(const wxString &descr, const wxString &docTypeName, const wxString &viewTypeName, wxClassInfo *viewClassInfo=(wxClassInfo *) NULL, a2dViewConnector *connector=(a2dViewConnector *) NULL, long flags=a2dTemplateFlag::DEFAULT, const wxSize &size=wxSize(0, 0))
Associate document and view types. They're for identifying what view is associated with what template...
wxUint32 m_id
This identifies the view in event processing.
a2dSmrtPtr< a2dViewConnector > m_connector
class used to connect new views with Frames and windows.
virtual bool Draw(wxDC &context)
Might be used to draw the contents of a document to a a2dView using a wxDc as the drawing context...
bool SentPostCreateDocumentEvent(a2dDocument *newDoc, a2dDocumentFlagMask flags)
sents a wxEVT_POST_CREATE_DOCUMENT called in general from a2dDocumentCommandProcessor() when a new do...
virtual void RemoveFileFromHistory(size_t i)
Remove a file from history.
void Modify(bool mod)
set the docuent as modified or not
static const a2dTemplateFlagMask EXPORTING
Input and output handler for the XmlSer format.
bool GetVeto() const
If the event can be vetod this return true.
wxClassInfo * m_docClassInfo
Run-time class information that allows document instances to be constructed dynamically.
help class which makes it possible to store a smart pointer as a wxObject*
bool Export(a2dDocumentTemplate *doctemplate, const wxFileName &fileTosaveTo=wxFileName(wxT("")), a2dDocumentFlagMask flags=a2dREFDOC_NON)
Tries to save the document by sending a a2dDocumentEvent ::wxEVT_EXPORT_DOCUMENT event.
virtual void OnDraw(wxDC &dc)
Override this function to draw the graphic (or just process EVT_PAINT)
uses a wxFrame to hold new views or to create child wxFrame's to hold new views.
virtual void ClearCommands()
remove all commands stored
void SetFileName(const wxFileName &filename)
set filename of file to open, before sending the event.
wxFrame * m_docframe
the frame which receives events and often redirect those to the document manager. ...
#define EVT_CREATE_DOCUMENT(func)
event sent to document from template when a document has been created
virtual bool Save(a2dDocumentOutputStream &stream, const wxObject *obj)=0
Override to write to the stream and store (part of) of the document contents in the stream...
void WriteEndAttributes(bool close=false)
"Closes" the start tag after writing all attributes (writes the ">" or "/>" bracket).
static const a2dTemplateFlagMask IMPORTING
void Activate(bool activate)
is called via ProcessEvent() when the view becomes active
virtual bool Submit(a2dCommand *command, bool storeIt=true)
next to the base class submit, it sets a2DocumentCommandProcessor for a2dCommand
int m_refcount
how many references to this object do exist
const a2dPrintWhat a2dPRINT_Print
general print
a2dDocumentTemplate * GetDocumentTemplate()
Get the template choosen to import / export.
void OnSaveDocument(a2dDocumentEvent &event)
Called by wxWindows when a file needs to be saved.
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
Save settings.
wxString m_description
A short description of this template.
a2dViewTemplatePtr m_viewTemplate
view was created from this view template or if not used NULL
using a file stream for output, stream a a2dDocument or other wxObject into a stream.
const a2dError a2dError_SaveObject
virtual a2dIOHandlerStrIn * GetDocumentIOHandlerForLoad(a2dDocumentInputStream &stream, a2dDocument *document)
if there is an io handler, and it can load the document of this template, return it ...
long m_initialStyle
style for new frames
a2dDocumentFlagMask GetFlags()
gives the a2dDocumentFlagMask in case of event types concerning a document.
bool m_savedYet
saved flag
const a2dError a2dError_ImportObject
void OnMRUFile(wxCommandEvent &event)
called by API and only handled if this is the Parent Frame
virtual wxPrintout * OnCreatePrintout(a2dPrintWhat typeOfPrint, const wxPageSetupDialogData &pageSetupData)
called from the a2dDocumentCommandProcessor to create a wxPrintout are derived class ...
a2dDocumentFlagMask GetFlags()
the document flags as set by a2dDocumentTemplate::CreateDocument()
a2dDocumentFrame()
Constructor for two step creation, call a2dDocumentFrame::Create later.
virtual wxWindow * GetAssociatedWindow() const
Returns a window that can be used as a parent for document-related dialogs. Override if necessary...
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
Save settings.
void OnExit(wxCommandEvent &event)
called by API and only handled if this is the Parent Frame
const a2dError a2dError_Canceled
virtual bool Revert()
Normally should undo all changes by rereading the file again.
#define EVT_CHANGEDTITLE_DOCUMENT(func)
event sent to view when the title of a document has changed.
void OnCloseView(a2dCloseViewEvent &event)
default for closing a view in this frame
#define EVT_IMPORT_DOCUMENT(func)
event for document when a document will be imported
wxInputStream a2dDocumentInputStream
input stream based wxStreams
wxString m_description
A short description of this template.
~a2dViewTemplate()
Destructor.
static const a2dTemplateFlagMask MARK
virtual bool CanSave(const wxObject *obj=NULL)=0
Should return true if the handler can write this document to a stream.
wxPoint m_initialPos
position for new frames
void OnPaint(wxPaintEvent &event)
default handler for paint events, it calls OnDraw().
a2dDocument * GetDocument() const
get the document of the view
a2dDocviewGlobal * a2dDocviewGlobals
a global pointer to get to global instance of important classes.
void ProcessConnectedEvent(wxEvent &event)
wxCHECK_VERSION(2,9,0)
wxFileName m_documentFile
Filename associated with this document ("" if none).
long GetInitialStyle()
Get style used for new created a2dDocumentFrame.
a2dDocumentViewWindow(a2dView *view, wxWindow *parent, wxWindowID id=-1, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxHSCROLL|wxVSCROLL, const wxString &name=wxT("a2dDocumentViewWindow"))
Constructor for creation with view.
virtual bool Close(bool force=false)
Close a view and remove the view from its document.
wxUint32 GetId()
Get the id of the view (used for identification in event processing.
a2dFrameViewConnector()
Constructor.
wxPageSetupDialogData * m_pageSetupData
this is the printer page setup data for all documents with this template
virtual a2dIOHandlerStrOut * GetDocumentIOHandlerForSave(const wxString &filename, a2dDocument *document)
if there is an io handler, and it can save the document of this template, return it ...
bool m_isParentFrame
is this the docframe or not.
a2dTemplateFlag m_flags
The flags passed to the constructor.
virtual a2dView * CreateView(a2dDocument *doc, a2dDocumentFlagMask flags=a2dREFDOC_NON)
Creates a new view for the given document.
#define EVT_CHANGEDFILENAME_VIEW(func)
event sent from view upwards to display, when the filename of a document has changed.
void OnEnableViews(a2dDocumentEvent &event)
default handler for a2dDocumentEvent of type ::wxEVT_ENABLE_VIEWS
wxFileName & GetFileName()
get filename of file to open
void Require(const XMLeventType &type, wxString name)
Forces a special tag.
bool ReleaseObject(T *object)
release a certain object from the list
#define EVT_ENABLE_VIEW(func)
event sent to connector to disable or enable for a certain view
a2dViewTemplateList m_viewTemplates
templates for views
wxString m_docTypeName
The named type of the document associated with this template.
virtual bool ProcessEvent(wxEvent &event)
Extend event processing to search the view's event table.
void SetViewTypeName(const wxString &name)
set type name of the view.
a2dAutoZeroPtr< a2dObject > ** GetAutoZeroPtrList()
return the list head pointer for autozero pointers to this object
sent to document before closing
virtual void ReportErrorF(const a2dError &error, const wxChar *Format,...)
concatenate to the the error report the given error.
wxString GetPrintableName() const
Get title, or filename if no title, else [unnamed].
a2dObject * DoClone(a2dObject::CloneOptions options, a2dRefMap *refs) const
Clone document.
const a2dPrintWhat a2dPRINT_PrintDocument
print a2dDocument
bool GetActive()
return if the view is active/
itSmart Find(T *object)
Find a specific object.
~a2dDocumentTemplateAuto()
Destructor.
wxString m_defaultExt
The default extension for files of this type.
wxUint32 m_id
This identifies the document in event processing.
a2dDocumentCommandProcessor * GetDocviewCommandProcessor() const
Gets a2dDocumentCommandProcessor pointer.
virtual a2dView * CreateView(a2dDocument *doc, const wxString &viewTypeName=wxT(""), a2dDocumentFlagMask flags=a2dREFDOC_NON, a2dTemplateFlagMask mask=a2dTemplateFlag::DEFAULT)
create a new view from a list of a2dViewTemplate's
bool DisconnectEventAll(wxEvtHandler *eventSink)
Remove all dynamic events in classA, going to classB (eventSink)
void SetDocumentSaved(bool saved=true)
Sets the document saved flag.
void OnUpdate(a2dDocumentEvent &event)
default handler for a2dDocumentEvent ::wxEVT_UPDATE_VIEWS
bool m_active
true if this view is activated ( its display window has the focus and recieves mouse events ) ...
used to report a2dDocument events
static const a2dTemplateFlagMask LOAD
void SetTitle(const wxString &title, bool notifyViews=false)
Sets the title for this document.
void OnSaveAsDocument(a2dDocumentEvent &event)
default handler for a2dDocumentEvent of type ::wxEVT_SAVEAS_DOCUMENT
wxString m_fileFilter
The file filter (such as *.txt) to be used in file selector dialogs.
const a2dError a2dError_ExportFile
wxSize & GetInitialSize()
GGet size used for new created views or frames or windows.
bool m_save
template is for saving documents
wxString m_viewTypeName
The named type of the view associated with this template.
bool Enable(bool enable)
returns true if view was enabled/disabled, false if nothing done
wxString GetDocumentTypeName() const
Returns the document type name, as passed to the document template constructor.
void SetDocument(a2dDocument *doc)
Set the document for the view and add it to the document its viewlist.
void OnExecuteCommand(wxCommandEvent &event)
void SetDocumentTypeName(const wxString &name)
Sets the document type name for this document. See the comment for documentTypeName.
void SetView(a2dView *view)
set a pointer to a a2dView to sent view events to.
bool m_load
template is for loading documents
const a2dPrintWhat a2dPRINT_PreviewView
preview print a2dView
void OnCreateDocument(a2dDocumentEvent &event)
default handler for ::wxEVT_CREATE_DOCUMENT, Called after creation of document from a template...
a2dTemplateFlag m_flags
The flags passed to the constructor.
a2dSmrtPtr< a2dIOHandlerStrIn > m_ioHandlerStrIn
used for reading the document from streams.
static const a2dTemplateFlagMask VISIBLE
specialized wxWindow derived template class to handle a2dView events
const a2dPrintWhat a2dPRINT_PrintView
print a2dView
bool Save()
Saves the document by sending a a2dDocumentEvent ::wxEVT_SAVE_DOCUMENT event.
void DisassociateViewTemplate(a2dViewTemplate *temp)
remove a reference to a a2dViewTemplate from the wxViewTemplateReflist
virtual void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
Load settings.
~a2dDocumentViewWindow()
Destructor.
a2dDocumentTemplate(const wxString &descr, const wxString &filter, const wxString &dir, const wxString &ext, const wxString &docTypeName, wxClassInfo *docClassInfo=(wxClassInfo *) NULL, a2dViewConnector *connector=(a2dViewConnector *) NULL, long flags=a2dTemplateFlag::DEFAULT, a2dIOHandlerStrIn *handlerIn=NULL, a2dIOHandlerStrOut *handlerOut=NULL)
Associate document and view types. They're for identifying what view is associated with what template...
wxWindow * m_display
In case of using a window for displaying the view, this holds the window.
virtual a2dViewTemplate * SelectViewType(a2dDocument *doc, const a2dViewTemplateList &list, const wxString &viewTypeName=wxT(""), bool sort=false, a2dTemplateFlagMask viewTemplateFlags=a2dTemplateFlag::VISIBLE)
Returns a view template by asking the user.
void OnReport(a2dDocumentEvent &event)
handler for the ::wxEVT_REPORT_VIEWS
wxString GetDefaultExtension() const
Returns the default file extension for the document data, as passed to the document template construc...
bool CheckMask(a2dTemplateFlagMask mask)
Check if given mask matches (flags in mask, or at least set)
void OnCloseDocument(a2dCloseDocumentEvent &event)
called when document is closed
bool Import(a2dDocumentTemplate *doctemplate, const wxFileName &fileToImport=wxFileName(wxT("")), a2dDocumentFlagMask flags=a2dREFDOC_NON)
Tries to read a file into the document by sending a a2dDocumentEvent ::wxEVT_IMPORT_DOCUMENT event...
bool m_destroyOnCloseView
when closing the view the frame will be destroyed.
virtual bool FileMatchesTemplate(const wxString &path)
to test if a file that needs to be loaded, is suitable for this template.
virtual int SaveModifiedDialog(bool canCancel=true)
dialog when the user needs to confirm saving a document
wxString m_viewTypeName
set via the a2dViewTemplate on generation of this view.
void Init(wxFrame *docframe, bool createChildframe=true)
The pointer m_docframe will be initialized.
a2dDocumentTemplatePtr m_documentTemplate
A pointer to the template from which this document was created.
CloneOptions
options for cloning
virtual a2dDocumentOutputStream & SaveObject(a2dDocumentOutputStream &stream, a2dIOHandlerStrOut *handler)
handling saving and exporting of the document to a stream
#define EVT_REMOVE_VIEW(func)
event sent to document when a view will be removed from the document
a2dSmrtPtr< a2dView > m_view
void SetView(a2dView *view)
Set the view created.
bool CanVeto() const
If the event can be vetod this is set.
static const a2dTemplateFlagMask ALL
bool GetEnable()
when ::wxEVT_ENABLE_VIEWS get enable value of the event
bool m_OnlyDisconnect
see SetOnlyDisconnect()
void OnActivateViewSentFromChild(a2dViewEvent &viewevent)
sets m_view to the current active view, generate by a2dView::Activate()
void SetViewTemplate(a2dViewTemplate *viewtemplate)
to set the view template from which this view was created.
holds one file for placing in history list
unsigned int a2dDocumentFlagMask
mask of flags for a2dDocumentFlag
#define a2dREFOBJECTPTR_KEEPALIVE
wxString GetViewTypeName() const
get type name of the view.
#define EVT_EXPORT_DOCUMENT(func)
event for document when a document will be exported