21 #include "wx/cmdproc.h"
23 #if wxUSE_PRINTING_ARCHITECTURE
28 #include <wx/module.h>
31 #include <wx/docview.h>
33 #include <wx/filedlg.h>
50 BEGIN_DECLARE_EVENT_TYPES()
52 DECLARE_EXPORTED_EVENT_TYPE( A2DDOCVIEWDLLEXP, wxEVT_ADD_DOCUMENT, 1 )
54 DECLARE_EXPORTED_EVENT_TYPE( A2DDOCVIEWDLLEXP, wxEVT_REMOVE_DOCUMENT, 1 )
56 DECLARE_EXPORTED_EVENT_TYPE( A2DDOCVIEWDLLEXP, wxEVT_CHANGED_DOCUMENT, 1 )
58 DECLARE_EXPORTED_EVENT_TYPE( A2DDOCVIEWDLLEXP, wxEVT_CANNOT_OPEN_DOCUMENT, 1 )
59 END_DECLARE_EVENT_TYPES()
89 : a2dCommandProcessorEvent( type, 0 )
105 : a2dCommandProcessorEvent( type, 0 )
116 const wxString& WXUNUSED( undoLabel ),
bool WXUNUSED( canUndo ),
117 const wxString& WXUNUSED( redoLabel ),
bool WXUNUSED( canRedo ),
120 : a2dCommandProcessorEvent( wxEVT_MENUSTRINGS, 0 )
131 : a2dCommandProcessorEvent( wxEVT_RECORD, 0 )
140 : a2dCommandProcessorEvent( event )
144 m_record = event.m_record;
156 wxString& GetRecord() {
return m_record; }
175 #define EVT_ADD_DOCUMENT(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_ADD_DOCUMENT, wxID_ANY, wxID_ANY, (wxObjectEventFunction) static_cast< wxDocCommandProcessorEventFunction > (& func), (wxObject *) NULL ),
177 #define EVT_REMOVE_DOCUMENT(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_REMOVE_DOCUMENT, wxID_ANY, wxID_ANY, (wxObjectEventFunction) static_cast< wxDocCommandProcessorEventFunction > (& func), (wxObject *) NULL ),
179 #define EVT_CHANGED_DOCUMENT(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_CHANGED_DOCUMENT, wxID_ANY, wxID_ANY, (wxObjectEventFunction) static_cast< wxDocCommandProcessorEventFunction > (& func), (wxObject *) NULL ),
181 #define EVT_CANNOT_OPEN_DOCUMENT(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_CANNOT_OPEN_DOCUMENT, wxID_ANY, wxID_ANY, (wxObjectEventFunction) static_cast< wxDocCommandProcessorEventFunction > (& func), (wxObject *) NULL ),
183 #define EVT_RECORD(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_RECORD, wxID_ANY, wxID_ANY, (wxObjectEventFunction) static_cast< wxDocCommandProcessorEventFunction > (& func), (wxObject *) NULL ),
189 DECLARE_MENU_ITEMID( CmdMenu_Exit )
190 DECLARE_MENU_ITEMID( CmdMenu_FileClose )
191 DECLARE_MENU_ITEMID( CmdMenu_FileCloseAll )
192 DECLARE_MENU_ITEMID( CmdMenu_FileOpen )
193 DECLARE_MENU_ITEMID( CmdMenu_FileNew )
194 DECLARE_MENU_ITEMID( CmdMenu_FileSave )
195 DECLARE_MENU_ITEMID( CmdMenu_FileSaveAll )
196 DECLARE_MENU_ITEMID( CmdMenu_FileSaveAs )
197 DECLARE_MENU_ITEMID( CmdMenu_FileImport )
198 DECLARE_MENU_ITEMID( CmdMenu_FileExport )
199 DECLARE_MENU_ITEMID( CmdMenu_FileRevert )
200 DECLARE_MENU_ITEMID( CmdMenu_CreateView )
201 DECLARE_MENU_ITEMID( CmdMenu_Print )
202 DECLARE_MENU_ITEMID( CmdMenu_Preview )
203 DECLARE_MENU_ITEMID( CmdMenu_PrintView )
204 DECLARE_MENU_ITEMID( CmdMenu_PreviewView )
205 DECLARE_MENU_ITEMID( CmdMenu_PrintDocument )
206 DECLARE_MENU_ITEMID( CmdMenu_PreviewDocument )
207 DECLARE_MENU_ITEMID( CmdMenu_PrintSetup )
208 DECLARE_MENU_ITEMID( CmdMenu_EmptyDocument )
244 #if defined(_DEBUG) && defined (SMART_POINTER_DEBUG)
245 a2dInitCurrentSmartPointerOwner m_initCurrentSmartPointerOwner;
249 DECLARE_EVENT_TABLE()
267 bool initialize =
true,
268 int maxCommands = -1 );
288 void OnMenu( wxCommandEvent& event );
294 wxString
AskFile(
const wxString& message,
const wxString& default_path =
"",
295 const wxString& default_filename =
"",
const wxString& default_extension =
"",
296 const wxString& wildcard =
"*.*",
int flags = 0,
297 int x = -1,
int y = -1 )
301 wxString expandedPath = default_path;
303 if ( !default_path.IsEmpty() && !path.ExpandPath( expandedPath ) )
308 return wxFileSelector( message, expandedPath, default_filename, default_extension, wildcard, flags, parent, x, y );
321 virtual void OnExit();
330 virtual void Initialize();
333 virtual bool SubmitToDocument(
a2dCommand* command,
bool storeIt =
true );
338 bool FileClose(
bool force =
true );
443 wxPageSetupDialogData GetDefaultPrintSettings();
446 wxPageSetupDialogData* GetPrintSetup(
a2dPrintWhat printWhat );
504 virtual a2dError CreateDocuments(
const wxString& path,
507 int dialogflags = wxFD_OPEN,
523 const wxString& viewTypeName = wxT(
"" ),
547 a2dError AddCreatedDocument(
a2dDocument* newDoc,
bool sentPreAddCreatedDocumentEvent =
false,
548 bool sentPostCreateDocumentEvent =
false,
562 virtual a2dView* CreateView(
a2dDocument* doc,
const wxString& viewTypeName = wxT(
"" ),
608 wxArrayString* selectedPaths,
610 int dialogflags = wxFD_OPEN,
664 const wxString& viewTypeName = wxT(
"" ),
712 a2dCommandProcessor* GetCurrentDocumentCommandProcessor()
const;
749 bool CloseDocuments(
bool force =
true );
756 bool Clear(
bool force =
true );
766 bool Exit(
bool force =
true );
776 a2dView* GetCurrentView()
const;
788 virtual bool MakeDefaultName( wxString& buf );
806 virtual wxString MakeFrameTitle(
a2dDocument* doc,
const wxString& modifiedIndicator = wxT(
"" ) );
809 virtual a2dFileHistory* OnCreateFileHistory();
818 virtual void RemoveFileFromHistory(
size_t i );
821 virtual size_t GetHistoryFilesCount()
const;
824 virtual a2dFileHistoryItem* GetHistoryFileItem(
size_t i )
const;
827 virtual wxString GetHistoryFile(
size_t i )
const;
836 virtual void FileHistoryUseMenu( wxMenu* menu );
839 virtual void FileHistoryRemoveMenu( wxMenu* menu );
843 virtual void FileHistoryLoad( wxConfigBase& config );
845 virtual void FileHistorySave( wxConfigBase& config );
846 #endif // wxUSE_CONFIG
849 virtual void FileHistoryAddFilesToMenu();
852 virtual void FileHistoryAddFilesToMenu( wxMenu* menu );
868 virtual void SetCurrentView(
a2dView* view );
875 void CheckCurrentView(
a2dView* view );
877 #if wxUSE_PRINTING_ARCHITECTURE
878 wxPageSetupDialogData* GetPageSetupData(
void )
const {
return m_pageSetupData; }
879 void SetPageSetupData(
const wxPageSetupDialogData& pageSetupData ) { *m_pageSetupData = pageSetupData; }
880 void SetPageSetupData( wxPageSetupDialogData* pageSetupData );
888 virtual bool ProcessEvent( wxEvent& event );
891 void SetUndo(
bool withUndo ) { m_withUndo = withUndo; }
899 void OnUndo( wxCommandEvent& event );
902 void OnRedo( wxCommandEvent& event );
906 void OnUpdateFileOpen( wxUpdateUIEvent& event );
908 void OnUpdateFileClose( wxUpdateUIEvent& event );
910 void OnUpdateFileCloseAll( wxUpdateUIEvent& event );
912 void OnUpdateFileRevert( wxUpdateUIEvent& event );
914 void OnUpdateFileNew( wxUpdateUIEvent& event );
916 void OnUpdateFileSave( wxUpdateUIEvent& event );
918 void OnUpdateFileSaveAll( wxUpdateUIEvent& event );
920 void OnUpdateFileSaveAs( wxUpdateUIEvent& event );
922 void OnUpdateCreateView( wxUpdateUIEvent& event );
925 void OnUpdateUndo( wxUpdateUIEvent& event );
927 void OnUpdateRedo( wxUpdateUIEvent& event );
930 void OnUpdatePrint( wxUpdateUIEvent& event );
932 void OnUpdatePrintSetup( wxUpdateUIEvent& event );
934 void OnUpdatePreview( wxUpdateUIEvent& event );
1003 #if wxUSE_PRINTING_ARCHITECTURE
1046 virtual void RecordF( wxObject* sender,
const wxChar* Format, ... );
1048 virtual void RecordF(
const wxChar* Format, ... );
1067 class A2DDOCVIEWDLLEXP a2dFileHistoryItem : public
a2dObject
1072 m_docTemplate = docTemplate;
1073 m_viewTemplate = viewTemplate;
1074 m_filename = filename;
1079 wxFileName m_filename;
1085 {
return new a2dFileHistoryItem( m_filename, m_docTemplate, m_viewTemplate ); };
1087 #if wxART2D_USE_CVGIO
1089 virtual void DoLoad( wxObject* parent,
a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts ) {}
1090 #endif //wxART2D_USE_CVGIO
1099 class A2DDOCVIEWDLLEXP a2dFileHistory :
public wxObject
1102 a2dFileHistory(
size_t maxFiles = 9, wxWindowID idBase = wxID_FILE1 );
1103 virtual ~a2dFileHistory();
1107 virtual void RemoveFileFromHistory(
size_t i );
1108 virtual int GetMaxFiles()
const {
return (
int )m_fileMaxFiles; }
1109 virtual void UseMenu( wxMenu* menu );
1112 virtual void RemoveMenu( wxMenu* menu );
1115 virtual void Load( wxConfigBase& config );
1116 virtual void Save( wxConfigBase& config );
1117 #endif // wxUSE_CONFIG
1119 virtual void AddFilesToMenu();
1120 virtual void AddFilesToMenu( wxMenu* menu );
1123 virtual wxString GetHistoryFile(
size_t i )
const;
1124 a2dFileHistoryItem* GetHistoryFileItem(
size_t i )
const;
1125 virtual size_t GetCount()
const {
return m_fileHistoryList.size(); }
1127 const wxList& GetMenus()
const {
return m_fileMenus; }
1129 #if wxABI_VERSION >= 20802
1131 void SetBaseId( wxWindowID baseId ) { m_idBase = baseId; }
1132 wxWindowID GetBaseId()
const {
return m_idBase; }
1133 #endif // wxABI 2.8.2+
1138 a2dFileHistoryItemList m_fileHistoryList;
1143 size_t m_fileMaxFiles;
1147 wxWindowID m_idBase;
1149 DECLARE_DYNAMIC_CLASS( a2dFileHistory )
1150 DECLARE_NO_COPY_CLASS( a2dFileHistory )
1173 #if wxUSE_PRINTING_ARCHITECTURE
1174 m_wxThePrintPaperDatabase = NULL;
1178 virtual bool OnInit();
1179 virtual void OnExit();
1186 #if wxUSE_PRINTING_ARCHITECTURE
1187 wxPrintPaperDatabase* m_wxThePrintPaperDatabase;
1191 #endif // _WX_DOCCOMH__
wxString AskFile(const wxString &message, const wxString &default_path="", const wxString &default_filename="", const wxString &default_extension="", const wxString &wildcard="*.*", int flags=0, int x=-1, int y=-1)
ask for a file using a file selector.
a2dDocviewModule()
constructor
a2dDocumentTemplate * m_preferredExportTemplate
preferred document template for Exporting files.
a2dDocumentTemplateList m_docTemplates
templates for documents
bool GetUndo()
get undo storage setting
void(wxEvtHandler::* wxDocCommandProcessorEventFunction)(a2dCommandEvent &)
internal event function for static event tables declaration
a2dDocumentTemplate * m_preferredImportTemplate
preferred document template for Importing files.
class to map references to objects stored in XML, in order to make the connection later on...
The a2dViewTemplate class is used to model the relationship between a document class and a view class...
const a2dError a2dError_CouldNotEvaluatePath
const a2dDocumentList & GetDocuments() const
returns a reference to the a2dDocumentList, which contains all a2dDocument's that are open...
One Global instance of this class exists, in order to get to global needed objects.
const a2dPrintWhat a2dPRINT_Preview
general print preview
void SetPreferredImportDocumentTemplate(a2dDocumentTemplate *docTemplate)
Set the preferred document template for Importing files.
const a2dViewTemplateList & GetViewTemplates()
returns a reference to the a2dViewTemplateList, which contains all a2dViewTemplate's.
The a2dDocumentTemplate class is used to model the relationship between a document class and files...
Input and output handler for the XmlSer format.
virtual wxEvent * Clone(bool deep=true) const
clone the event.
bool m_busyExit
set when terminating application
const a2dDocumentTemplateList & GetDocTemplates()
returns a reference to the a2dDocumentTemplateList, which contains all a2dDocumentTemplate's.
a2dCommandEvent(const a2dCommandEvent &event)
constructor
unsigned int a2dTemplateFlagMask
mask of flags for a2dTemplateFlag
a2dView event, to report events in the a2dView class
void SetUndo(bool withUndo)
set undo storage or not
long m_flags
user flags use at will ( not used internal )
Holds a view on a a2dDocument.
The document class can be used to model an application's file-based data.
wxPageSetupDialogData * m_pageSetupData
this is the global printer page setup data for printer
wxUint16 a2dPrintWhat
defines what to print
Docview classes for document view, window and frame.
One object of this class may be created in an application, to manage all the templates and documents...
virtual a2dFileHistory * GetFileHistory() const
returns a pointer to the file history list
size_t GetMaxDocsOpen() const
Gets the maximum number of documents that can be open at a time.
A2DGENERALDLLEXP a2dSmrtPtr< a2dGeneralGlobal > a2dGeneralGlobals
a global pointer to get to global instance of important classes.
a2dDocumentTemplate * GetPreferredExportDocumentTemplate()
Return the preferred document template for Exporting files.
Input and output handler for the XmlSer format.
a2dCommandEvent(wxEventType type, a2dCommand *cmd, a2dDocument *doc=NULL)
constructor
a2dFileHistory * m_fileHistory
the file history
const a2dPrintWhat a2dPRINT_Print
general print
a2dSmrtPtrList< a2dFileHistoryItem > a2dFileHistoryItemList
list of a2dFileHistoryItem
One Global instance of this class exists, in order to get to.
a2dView * m_currentView
the current view (active or inactive)
a2dCommand * m_cmd
see GetCommand()
a2dDocumentList m_docs
list of all that are open
void SetPreferredExportDocumentTemplate(a2dDocumentTemplate *docTemplate)
Set the preferred document template for Exporting files.
a2dViewTemplateList m_viewTemplates
templates for views
general modules header files all together.
a2dDocviewGlobal * a2dDocviewGlobals
a global pointer to get to global instance of important classes.
wxString GetLastDirectory() const
Gets the directory to be displayed to the user when opening a file. Initially this is empty...
void SetMaxDocsOpen(size_t n)
Sets the maximum number of documents that can be open at a time.
a2dCommand * GetCommand()
the command ( if there was one ) that did it.
void SetPreferredOpenDocumentTemplate(a2dDocumentTemplate *docTemplate)
Set the preferred document template for Opening files.
a2dCommandEvent(a2dCommand *cmd, const wxString &undoLabel, bool canUndo, const wxString &redoLabel, bool canRedo, a2dDocument *doc=NULL)
constructor
Event sent to a2dCommandProcessor.
bool m_withUndo
if set, for commands which can undo, will be submitted like that.
a2dDocumentCommandProcessor * GetDocviewCommandProcessor() const
Gets a2dDocumentCommandProcessor pointer.
a2dCommandEvent(wxEventType type, a2dDocument *doc)
constructor
A module to initialize the docview framework.
used to report a2dDocument events
static const a2dTemplateFlagMask LOAD
void SetBusyExit(bool exitBusy)
size_t m_maxDocsOpen
the maximum of documents allowed open
a2dDocumentTemplate * GetPreferredOpenDocumentTemplate()
Return the preferred document template for Opening files.
static const a2dTemplateFlagMask VISIBLE
a2dDocumentTemplate * m_preferredOpenTemplate
preferred document template for Opening files.
int m_defaultDocumentNameCounter
to create unique new names for file
a2dDocumentTemplate * GetPreferredImportDocumentTemplate()
Return the preferred document template for Importing files.
A2DDOCVIEWDLLEXP_DATA(extern a2dDocviewGlobal *) a2dDocviewGlobals
global object to get to the only a2dDocviewGlobal
wxWindow * wxFindSuitableParent()
find a parent wxWindow pointer to place a control into
a2dCommandEvent(const wxString &record)
constructor
void SetLastDirectory(const wxString &dir)
Sets the directory to be displayed to the user when opening a file. Initially this is empty...
wxString m_lastDirectory
the last visited directory
CloneOptions
options for cloning
a2dDocument * m_currentDocument
the current active document
a2dDocument * GetDocument()
the document created/removed or on which the command was applied.
bool GetBusyExit()
return true if the application is bussy exiting.
holds one file for placing in history list
unsigned int a2dDocumentFlagMask
mask of flags for a2dDocumentFlag
a base command for the a2dCommandProcessor