]> git.saurik.com Git - wxWidgets.git/blame - include/wx/docview.h
correction for compilation with -cpp-precomp option
[wxWidgets.git] / include / wx / docview.h
CommitLineData
c801d85f
KB
1/////////////////////////////////////////////////////////////////////////////
2// Name: docview.h
3// Purpose: Doc/View classes
4// Author: Julian Smart
5// Modified by:
6// Created: 01/02/97
7// RCS-ID: $Id$
8// Copyright: (c)
3f4a0c5b 9// Licence: wxWindows licence
c801d85f
KB
10/////////////////////////////////////////////////////////////////////////////
11
34138703
JS
12#ifndef _WX_DOCH__
13#define _WX_DOCH__
c801d85f
KB
14
15#ifdef __GNUG__
caf0debf 16 #pragma interface "docview.h"
c801d85f
KB
17#endif
18
19#include "wx/defs.h"
20#include "wx/list.h"
21#include "wx/cmndata.h"
22#include "wx/string.h"
23
47d67540 24#if wxUSE_PRINTING_ARCHITECTURE
caf0debf 25 #include "wx/print.h"
c801d85f
KB
26#endif
27
28class WXDLLEXPORT wxWindow;
29class WXDLLEXPORT wxDocument;
30class WXDLLEXPORT wxView;
31class WXDLLEXPORT wxDocTemplate;
32class WXDLLEXPORT wxDocManager;
33class WXDLLEXPORT wxPrintInfo;
34class WXDLLEXPORT wxCommand;
35class WXDLLEXPORT wxCommandProcessor;
36class WXDLLEXPORT wxFileHistory;
7f555861 37class WXDLLEXPORT wxConfigBase;
c801d85f 38
a533f5c1
RR
39#if wxUSE_STD_IOSTREAM
40 #include "wx/ioswrap.h"
41#else
42 #include "wx/stream.h"
43#endif
c801d85f
KB
44
45// Document manager flags
caf0debf
VZ
46enum
47{
48 wxDOC_SDI = 1,
49 wxDOC_MDI,
50 wxDOC_NEW,
51 wxDOC_SILENT,
52 wxDEFAULT_DOCMAN_FLAGS = wxDOC_SDI
53};
c801d85f
KB
54
55// Document template flags
caf0debf
VZ
56enum
57{
58 wxTEMPLATE_VISIBLE = 1,
59 wxTEMPLATE_INVISIBLE,
60 wxDEFAULT_TEMPLATE_FLAGS = wxTEMPLATE_VISIBLE
61};
c801d85f 62
caf0debf 63#define wxMAX_FILE_HISTORY 9
c801d85f
KB
64
65class WXDLLEXPORT wxDocument : public wxEvtHandler
66{
caf0debf
VZ
67 DECLARE_ABSTRACT_CLASS(wxDocument)
68
69public:
70 wxDocument(wxDocument *parent = (wxDocument *) NULL);
71 ~wxDocument();
72
73 // accessors
74 void SetFilename(const wxString& filename, bool notifyViews = FALSE);
75 wxString GetFilename() const { return m_documentFile; }
76
77 void SetTitle(const wxString& title) { m_documentTitle = title; };
78 wxString GetTitle() const { return m_documentTitle; }
79
80 void SetDocumentName(const wxString& name) { m_documentTypeName = name; };
81 wxString GetDocumentName() const { return m_documentTypeName; }
82
83 bool GetDocumentSaved() const { return m_savedYet; }
84 void SetDocumentSaved(bool saved = TRUE) { m_savedYet = saved; }
85
86 virtual bool Close();
87 virtual bool Save();
88 virtual bool SaveAs();
89 virtual bool Revert();
90
a533f5c1 91#if wxUSE_STD_IOSTREAM
dd107c50
VZ
92 virtual wxSTD ostream& SaveObject(wxSTD ostream& stream);
93 virtual wxSTD istream& LoadObject(wxSTD istream& stream);
a533f5c1 94#else
23a54e14
RR
95 virtual wxOutputStream& SaveObject(wxOutputStream& stream);
96 virtual wxInputStream& LoadObject(wxInputStream& stream);
a533f5c1 97#endif
caf0debf 98
54da4255
DW
99#if wxUSE_SERIAL
100 // need this to keep from hiding the virtual from wxObject
101 virtual void LoadObject(wxObjectInputStream& stream) { wxObject::LoadObject(stream); };
102#endif
103
caf0debf
VZ
104 // Called by wxWindows
105 virtual bool OnSaveDocument(const wxString& filename);
106 virtual bool OnOpenDocument(const wxString& filename);
107 virtual bool OnNewDocument();
108 virtual bool OnCloseDocument();
109
110 // Prompts for saving if about to close a modified document. Returns TRUE
111 // if ok to close the document (may have saved in the meantime, or set
112 // modified to FALSE)
113 virtual bool OnSaveModified();
114
115 // Called by framework if created automatically by the default document
116 // manager: gives document a chance to initialise and (usually) create a
117 // view
118 virtual bool OnCreate(const wxString& path, long flags);
119
120 // By default, creates a base wxCommandProcessor.
121 virtual wxCommandProcessor *OnCreateCommandProcessor();
122 virtual wxCommandProcessor *GetCommandProcessor() const { return m_commandProcessor; }
123 virtual void SetCommandProcessor(wxCommandProcessor *proc) { m_commandProcessor = proc; }
124
125 // Called after a view is added or removed. The default implementation
126 // deletes the document if this is there are no more views.
127 virtual void OnChangedViewList();
128
129 virtual bool DeleteContents();
130
131 virtual bool Draw(wxDC&);
132 virtual bool IsModified() const { return m_documentModified; }
133 virtual void Modify(bool mod) { m_documentModified = mod; }
134
135 virtual bool AddView(wxView *view);
136 virtual bool RemoveView(wxView *view);
137 wxList& GetViews() const { return (wxList&) m_documentViews; }
138 wxView *GetFirstView() const;
139
140 virtual void UpdateAllViews(wxView *sender = (wxView *) NULL, wxObject *hint = (wxObject *) NULL);
141
142 // Remove all views (because we're closing the document)
143 virtual bool DeleteAllViews();
144
145 // Other stuff
146 virtual wxDocManager *GetDocumentManager() const;
147 virtual wxDocTemplate *GetDocumentTemplate() const { return m_documentTemplate; }
148 virtual void SetDocumentTemplate(wxDocTemplate *temp) { m_documentTemplate = temp; }
149
150 // Get title, or filename if no title, else [unnamed]
151 virtual bool GetPrintableName(wxString& buf) const;
152
153 // Returns a window that can be used as a parent for document-related
154 // dialogs. Override if necessary.
155 virtual wxWindow *GetDocumentWindow() const;
156
157protected:
158 wxList m_documentViews;
159 wxString m_documentFile;
160 wxString m_documentTitle;
161 wxString m_documentTypeName;
162 wxDocTemplate* m_documentTemplate;
163 bool m_documentModified;
164 wxDocument* m_documentParent;
165 wxCommandProcessor* m_commandProcessor;
166 bool m_savedYet;
c801d85f
KB
167};
168
169class WXDLLEXPORT wxView: public wxEvtHandler
170{
caf0debf 171 DECLARE_ABSTRACT_CLASS(wxView)
c801d85f 172
caf0debf
VZ
173public:
174 // wxView(wxDocument *doc = (wxDocument *) NULL);
175 wxView();
176 ~wxView();
c801d85f 177
caf0debf
VZ
178 wxDocument *GetDocument() const { return m_viewDocument; }
179 void SetDocument(wxDocument *doc);
c801d85f 180
caf0debf
VZ
181 wxString GetViewName() const { return m_viewTypeName; }
182 void SetViewName(const wxString& name) { m_viewTypeName = name; };
c801d85f 183
caf0debf
VZ
184 wxFrame *GetFrame() const { return m_viewFrame ; }
185 void SetFrame(wxFrame *frame) { m_viewFrame = frame; }
c801d85f 186
caf0debf
VZ
187 virtual void OnActivateView(bool activate, wxView *activeView, wxView *deactiveView);
188 virtual void OnDraw(wxDC *dc) = 0;
189 virtual void OnPrint(wxDC *dc, wxObject *info);
190 virtual void OnUpdate(wxView *sender, wxObject *hint = (wxObject *) NULL);
191 virtual void OnChangeFilename();
c801d85f 192
caf0debf
VZ
193 // Called by framework if created automatically by the default document
194 // manager class: gives view a chance to initialise
195 virtual bool OnCreate(wxDocument *WXUNUSED(doc), long WXUNUSED(flags)) { return TRUE; };
c801d85f 196
caf0debf
VZ
197 // Checks if the view is the last one for the document; if so, asks user
198 // to confirm save data (if modified). If ok, deletes itself and returns
199 // TRUE.
200 virtual bool Close(bool deleteWindow = TRUE);
201
202 // Override to do cleanup/veto close
203 virtual bool OnClose(bool deleteWindow);
2b854a32 204
e3065973 205#if WXWIN_COMPATIBILITY
caf0debf
VZ
206 // Defeat compiler warning
207 bool OnClose() { return wxEvtHandler::OnClose(); }
2b854a32 208#endif
c801d85f 209
caf0debf
VZ
210 // Extend event processing to search the document's event table
211 virtual bool ProcessEvent(wxEvent& event);
c801d85f 212
caf0debf
VZ
213 // A view's window can call this to notify the view it is (in)active.
214 // The function then notifies the document manager.
215 virtual void Activate(bool activate);
c801d85f 216
caf0debf
VZ
217 wxDocManager *GetDocumentManager() const
218 { return m_viewDocument->GetDocumentManager(); }
c801d85f 219
47d67540 220#if wxUSE_PRINTING_ARCHITECTURE
caf0debf 221 virtual wxPrintout *OnCreatePrintout();
c801d85f
KB
222#endif
223
caf0debf
VZ
224protected:
225 wxDocument* m_viewDocument;
226 wxString m_viewTypeName;
227 wxFrame* m_viewFrame;
c801d85f
KB
228};
229
230// Represents user interface (and other) properties of documents and views
231class WXDLLEXPORT wxDocTemplate: public wxObject
232{
caf0debf
VZ
233DECLARE_CLASS(wxDocTemplate)
234
235friend class WXDLLEXPORT wxDocManager;
236
237public:
238 // Associate document and view types. They're for identifying what view is
239 // associated with what template/document type
240 wxDocTemplate(wxDocManager *manager,
241 const wxString& descr,
242 const wxString& filter,
243 const wxString& dir,
244 const wxString& ext,
245 const wxString& docTypeName,
246 const wxString& viewTypeName,
247 wxClassInfo *docClassInfo = (wxClassInfo *) NULL,
248 wxClassInfo *viewClassInfo = (wxClassInfo *)NULL,
249 long flags = wxDEFAULT_TEMPLATE_FLAGS);
250
251 ~wxDocTemplate();
252
253 // By default, these two member functions dynamically creates document and
254 // view using dynamic instance construction. Override these if you need a
255 // different method of construction.
256 virtual wxDocument *CreateDocument(const wxString& path, long flags = 0);
257 virtual wxView *CreateView(wxDocument *doc, long flags = 0);
258
259 wxString GetDefaultExtension() const { return m_defaultExt; };
260 wxString GetDescription() const { return m_description; }
261 wxString GetDirectory() const { return m_directory; };
262 wxDocManager *GetDocumentManager() const { return m_documentManager; }
263 void SetDocumentManager(wxDocManager *manager) { m_documentManager = manager; }
264 wxString GetFileFilter() const { return m_fileFilter; };
265 long GetFlags() const { return m_flags; };
266 virtual wxString GetViewName() const { return m_viewTypeName; }
267 virtual wxString GetDocumentName() const { return m_docTypeName; }
268
269 void SetFileFilter(const wxString& filter) { m_fileFilter = filter; };
270 void SetDirectory(const wxString& dir) { m_directory = dir; };
271 void SetDescription(const wxString& descr) { m_description = descr; };
272 void SetDefaultExtension(const wxString& ext) { m_defaultExt = ext; };
273 void SetFlags(long flags) { m_flags = flags; };
274
275 bool IsVisible() const { return ((m_flags & wxTEMPLATE_VISIBLE) == wxTEMPLATE_VISIBLE); }
276
277 virtual bool FileMatchesTemplate(const wxString& path);
278
279protected:
280 long m_flags;
281 wxString m_fileFilter;
282 wxString m_directory;
283 wxString m_description;
284 wxString m_defaultExt;
285 wxString m_docTypeName;
286 wxString m_viewTypeName;
287 wxDocManager* m_documentManager;
288
289 // For dynamic creation of appropriate instances.
290 wxClassInfo* m_docClassInfo;
291 wxClassInfo* m_viewClassInfo;
c801d85f
KB
292};
293
caf0debf
VZ
294// One object of this class may be created in an application, to manage all
295// the templates and documents.
c801d85f
KB
296class WXDLLEXPORT wxDocManager: public wxEvtHandler
297{
caf0debf
VZ
298 DECLARE_DYNAMIC_CLASS(wxDocManager)
299
300public:
301 wxDocManager(long flags = wxDEFAULT_DOCMAN_FLAGS, bool initialize = TRUE);
302 ~wxDocManager();
303
304 virtual bool Initialize();
305
306 // Handlers for common user commands
307 void OnFileClose(wxCommandEvent& event);
308 void OnFileNew(wxCommandEvent& event);
309 void OnFileOpen(wxCommandEvent& event);
310 void OnFileRevert(wxCommandEvent& event);
311 void OnFileSave(wxCommandEvent& event);
312 void OnFileSaveAs(wxCommandEvent& event);
313 void OnPrint(wxCommandEvent& event);
314 void OnPrintSetup(wxCommandEvent& event);
315 void OnPreview(wxCommandEvent& event);
316 void OnUndo(wxCommandEvent& event);
317 void OnRedo(wxCommandEvent& event);
318
f2506310
JS
319 // Handlers for UI update commands
320 void OnUpdateFileOpen(wxUpdateUIEvent& event);
321 void OnUpdateFileClose(wxUpdateUIEvent& event);
322 void OnUpdateFileRevert(wxUpdateUIEvent& event);
323 void OnUpdateFileNew(wxUpdateUIEvent& event);
324 void OnUpdateFileSave(wxUpdateUIEvent& event);
325 void OnUpdateFileSaveAs(wxUpdateUIEvent& event);
326 void OnUpdateUndo(wxUpdateUIEvent& event);
327 void OnUpdateRedo(wxUpdateUIEvent& event);
328
329 void OnUpdatePrint(wxUpdateUIEvent& event);
330 void OnUpdatePrintSetup(wxUpdateUIEvent& event);
331 void OnUpdatePreview(wxUpdateUIEvent& event);
332
caf0debf
VZ
333 // Extend event processing to search the view's event table
334 virtual bool ProcessEvent(wxEvent& event);
335
5f170f33
VZ
336 // called when file format detection didn't work, can be overridden to do
337 // something in this case
0a0352f2
JS
338 // This is of course completely stupid, because if the file dialog is
339 // cancelled you get an assert. Brilliant. -- JACS
340// virtual void OnOpenFileFailure() { wxFAIL_MSG(_T("file format mismatch")); }
341 virtual void OnOpenFileFailure() { }
5f170f33 342
caf0debf
VZ
343 virtual wxDocument *CreateDocument(const wxString& path, long flags = 0);
344 virtual wxView *CreateView(wxDocument *doc, long flags = 0);
345 virtual void DeleteTemplate(wxDocTemplate *temp, long flags = 0);
346 virtual bool FlushDoc(wxDocument *doc);
347 virtual wxDocTemplate *MatchTemplate(const wxString& path);
348 virtual wxDocTemplate *SelectDocumentPath(wxDocTemplate **templates,
349 int noTemplates, wxString& path, long flags, bool save = FALSE);
350 virtual wxDocTemplate *SelectDocumentType(wxDocTemplate **templates,
52b9ca21 351 int noTemplates, bool sort = FALSE);
caf0debf 352 virtual wxDocTemplate *SelectViewType(wxDocTemplate **templates,
52b9ca21 353 int noTemplates, bool sort = FALSE);
caf0debf
VZ
354 virtual wxDocTemplate *FindTemplateForPath(const wxString& path);
355
356 void AssociateTemplate(wxDocTemplate *temp);
357 void DisassociateTemplate(wxDocTemplate *temp);
358
359 wxDocument *GetCurrentDocument() const;
360
361 void SetMaxDocsOpen(int n) { m_maxDocsOpen = n; }
362 int GetMaxDocsOpen() const { return m_maxDocsOpen; }
363
364 // Add and remove a document from the manager's list
365 void AddDocument(wxDocument *doc);
366 void RemoveDocument(wxDocument *doc);
367
368 // Clear remaining documents and templates
369 bool Clear(bool force = TRUE);
370
371 // Views or windows should inform the document manager
372 // when a view is going in or out of focus
373 virtual void ActivateView(wxView *view, bool activate = TRUE, bool deleting = FALSE);
374 virtual wxView *GetCurrentView() const;
375
0b237b67
JS
376 wxList& GetDocuments() { return m_docs; }
377 wxList& GetTemplates() { return m_templates; }
caf0debf
VZ
378
379 // Make a default document name
380 virtual bool MakeDefaultName(wxString& buf);
381
f2506310
JS
382 // Make a frame title (override this to do something different)
383 virtual wxString MakeFrameTitle(wxDocument* doc);
384
caf0debf
VZ
385 virtual wxFileHistory *OnCreateFileHistory();
386 virtual wxFileHistory *GetFileHistory() const { return m_fileHistory; }
387
388 // File history management
389 virtual void AddFileToHistory(const wxString& file);
0c5d3e1c 390 virtual void RemoveFileFromHistory(int i);
caf0debf
VZ
391 virtual int GetNoHistoryFiles() const;
392 virtual wxString GetHistoryFile(int i) const;
393 virtual void FileHistoryUseMenu(wxMenu *menu);
394 virtual void FileHistoryRemoveMenu(wxMenu *menu);
702ca7c0 395#if wxUSE_CONFIG
caf0debf
VZ
396 virtual void FileHistoryLoad(wxConfigBase& config);
397 virtual void FileHistorySave(wxConfigBase& config);
398#endif // wxUSE_CONFIG
399
400 virtual void FileHistoryAddFilesToMenu();
401 virtual void FileHistoryAddFilesToMenu(wxMenu* menu);
402
ac0ac824
JS
403 inline wxString GetLastDirectory() const { return m_lastDirectory; }
404 inline void SetLastDirectory(const wxString& dir) { m_lastDirectory = dir; }
405
f2506310
JS
406 // Get the current document manager
407 static wxDocManager* GetDocumentManager() { return sm_docManager; }
408
caf0debf
VZ
409protected:
410 long m_flags;
411 int m_defaultDocumentNameCounter;
412 int m_maxDocsOpen;
413 wxList m_docs;
414 wxList m_templates;
415 wxView* m_currentView;
416 wxFileHistory* m_fileHistory;
ac0ac824 417 wxString m_lastDirectory;
f2506310 418 static wxDocManager* sm_docManager;
caf0debf
VZ
419
420 DECLARE_EVENT_TABLE()
c801d85f
KB
421};
422
caf0debf
VZ
423// ----------------------------------------------------------------------------
424// A default child frame
425// ----------------------------------------------------------------------------
c801d85f 426
caf0debf 427class WXDLLEXPORT wxDocChildFrame : public wxFrame
c801d85f 428{
caf0debf
VZ
429 DECLARE_CLASS(wxDocChildFrame)
430
431public:
432 wxDocChildFrame(wxDocument *doc,
433 wxView *view,
434 wxFrame *frame,
435 wxWindowID id,
436 const wxString& title,
437 const wxPoint& pos = wxDefaultPosition,
438 const wxSize& size = wxDefaultSize,
439 long type = wxDEFAULT_FRAME_STYLE,
440 const wxString& name = "frame");
441 ~wxDocChildFrame();
442
443 // Extend event processing to search the view's event table
444 virtual bool ProcessEvent(wxEvent& event);
445
446 void OnActivate(wxActivateEvent& event);
447 void OnCloseWindow(wxCloseEvent& event);
448
449 wxDocument *GetDocument() const { return m_childDocument; }
450 wxView *GetView() const { return m_childView; }
451 void SetDocument(wxDocument *doc) { m_childDocument = doc; }
452 void SetView(wxView *view) { m_childView = view; }
0d8737fd 453 bool Destroy() { m_childView = (wxView *)NULL; return wxFrame::Destroy(); }
caf0debf
VZ
454
455protected:
456 wxDocument* m_childDocument;
457 wxView* m_childView;
458
459 DECLARE_EVENT_TABLE()
460};
c801d85f 461
caf0debf
VZ
462// ----------------------------------------------------------------------------
463// A default parent frame
464// ----------------------------------------------------------------------------
c801d85f 465
caf0debf
VZ
466class WXDLLEXPORT wxDocParentFrame : public wxFrame
467{
468 DECLARE_CLASS(wxDocParentFrame)
c801d85f 469
caf0debf
VZ
470public:
471 wxDocParentFrame(wxDocManager *manager,
472 wxFrame *frame,
473 wxWindowID id,
474 const wxString& title,
475 const wxPoint& pos = wxDefaultPosition,
476 const wxSize& size = wxDefaultSize,
477 long type = wxDEFAULT_FRAME_STYLE,
478 const wxString& name = "frame");
c801d85f 479
caf0debf
VZ
480 // Extend event processing to search the document manager's event table
481 virtual bool ProcessEvent(wxEvent& event);
c801d85f 482
caf0debf 483 wxDocManager *GetDocumentManager() const { return m_docManager; }
c801d85f 484
caf0debf
VZ
485 void OnExit(wxCommandEvent& event);
486 void OnMRUFile(wxCommandEvent& event);
487 void OnCloseWindow(wxCloseEvent& event);
c801d85f 488
caf0debf
VZ
489protected:
490 wxDocManager *m_docManager;
491
492 DECLARE_EVENT_TABLE()
493};
c801d85f 494
caf0debf
VZ
495// ----------------------------------------------------------------------------
496// Provide simple default printing facilities
497// ----------------------------------------------------------------------------
c801d85f 498
caf0debf
VZ
499#if wxUSE_PRINTING_ARCHITECTURE
500class WXDLLEXPORT wxDocPrintout : public wxPrintout
501{
502 DECLARE_DYNAMIC_CLASS(wxDocPrintout)
c801d85f 503
caf0debf
VZ
504public:
505 wxDocPrintout(wxView *view = (wxView *) NULL, const wxString& title = "Printout");
506 bool OnPrintPage(int page);
507 bool HasPage(int page);
508 bool OnBeginDocument(int startPage, int endPage);
509 void GetPageInfo(int *minPage, int *maxPage, int *selPageFrom, int *selPageTo);
c801d85f 510
caf0debf 511 virtual wxView *GetView() { return m_printoutView; }
c801d85f 512
caf0debf
VZ
513protected:
514 wxView* m_printoutView;
c801d85f 515};
caf0debf 516#endif // wxUSE_PRINTING_ARCHITECTURE
c801d85f 517
caf0debf
VZ
518// ----------------------------------------------------------------------------
519// Command processing framework
520// ----------------------------------------------------------------------------
c801d85f 521
caf0debf 522class WXDLLEXPORT wxCommand : public wxObject
c801d85f 523{
caf0debf 524 DECLARE_CLASS(wxCommand)
c801d85f 525
caf0debf
VZ
526public:
527 wxCommand(bool canUndoIt = FALSE, const wxString& name = "");
528 ~wxCommand();
c801d85f 529
caf0debf
VZ
530 // Override this to perform a command
531 virtual bool Do() = 0;
532
533 // Override this to undo a command
534 virtual bool Undo() = 0;
535
536 virtual bool CanUndo() const { return m_canUndo; }
537 virtual wxString GetName() const { return m_commandName; }
538
539protected:
540 bool m_canUndo;
541 wxString m_commandName;
c801d85f
KB
542};
543
caf0debf 544class WXDLLEXPORT wxCommandProcessor : public wxObject
c801d85f 545{
caf0debf
VZ
546 DECLARE_DYNAMIC_CLASS(wxCommandProcessor)
547
548public:
549 wxCommandProcessor(int maxCommands = 100);
550 ~wxCommandProcessor();
551
552 // Pass a command to the processor. The processor calls Do(); if
553 // successful, is appended to the command history unless storeIt is FALSE.
554 virtual bool Submit(wxCommand *command, bool storeIt = TRUE);
555 virtual bool Undo();
556 virtual bool Redo();
557 virtual bool CanUndo() const;
558 virtual bool CanRedo() const;
559
560 // Call this to manage an edit menu.
561 void SetEditMenu(wxMenu *menu) { m_commandEditMenu = menu; }
562 wxMenu *GetEditMenu() const { return m_commandEditMenu; }
563 virtual void SetMenuStrings();
564 virtual void Initialize();
565
566 wxList& GetCommands() const { return (wxList&) m_commands; }
567 int GetMaxCommands() const { return m_maxNoCommands; }
568 virtual void ClearCommands();
569
5e0e6ceb
JS
570 // By default, the accelerators are "\tCtrl+Z" and "\tCtrl+Y"
571 const wxString& GetUndoAccelerator() const { return m_undoAccelerator; }
572 const wxString& GetRedoAccelerator() const { return m_redoAccelerator; }
573
574 void SetUndoAccelerator(const wxString& accel) { m_undoAccelerator = accel; }
575 void SetRedoAccelerator(const wxString& accel) { m_redoAccelerator = accel; }
576
caf0debf
VZ
577protected:
578 int m_maxNoCommands;
579 wxList m_commands;
580 wxNode* m_currentCommand;
581 wxMenu* m_commandEditMenu;
5e0e6ceb
JS
582 wxString m_undoAccelerator;
583 wxString m_redoAccelerator;
c801d85f
KB
584};
585
caf0debf 586// ----------------------------------------------------------------------------
7f555861 587// File history management
caf0debf 588// ----------------------------------------------------------------------------
7f555861 589
caf0debf 590class WXDLLEXPORT wxFileHistory : public wxObject
c801d85f 591{
caf0debf 592 DECLARE_DYNAMIC_CLASS(wxFileHistory)
c801d85f 593
caf0debf
VZ
594public:
595 wxFileHistory(int maxFiles = 9);
596 ~wxFileHistory();
7f555861 597
caf0debf
VZ
598 // Operations
599 virtual void AddFileToHistory(const wxString& file);
0c5d3e1c 600 virtual void RemoveFileFromHistory(int i);
caf0debf
VZ
601 virtual int GetMaxFiles() const { return m_fileMaxFiles; }
602 virtual void UseMenu(wxMenu *menu);
7f555861 603
caf0debf
VZ
604 // Remove menu from the list (MDI child may be closing)
605 virtual void RemoveMenu(wxMenu *menu);
7f555861 606
caf0debf
VZ
607#if wxUSE_CONFIG
608 virtual void Load(wxConfigBase& config);
609 virtual void Save(wxConfigBase& config);
610#endif // wxUSE_CONFIG
611
612 virtual void AddFilesToMenu();
613 virtual void AddFilesToMenu(wxMenu* menu); // Single menu
614
615 // Accessors
616 virtual wxString GetHistoryFile(int i) const;
617
618 // A synonym for GetNoHistoryFiles
619 virtual int GetCount() const { return m_fileHistoryN; }
620 int GetNoHistoryFiles() const { return m_fileHistoryN; }
621
622 wxList& GetMenus() const { return (wxList&) m_fileMenus; }
623
624protected:
625 // Last n files
626 wxChar** m_fileHistory;
627 // Number of files saved
628 int m_fileHistoryN;
629 // Menus to maintain (may need several for an MDI app)
630 wxList m_fileMenus;
631 // Max files to maintain
632 int m_fileMaxFiles;
c801d85f
KB
633};
634
a533f5c1 635#if wxUSE_STD_IOSTREAM
c801d85f
KB
636// For compatibility with existing file formats:
637// converts from/to a stream to/from a temporary file.
dd107c50
VZ
638bool WXDLLEXPORT wxTransferFileToStream(const wxString& filename, wxSTD ostream& stream);
639bool WXDLLEXPORT wxTransferStreamToFile(wxSTD istream& stream, const wxString& filename);
dc1efb1d
JS
640#else
641// For compatibility with existing file formats:
642// converts from/to a stream to/from a temporary file.
643bool WXDLLEXPORT wxTransferFileToStream(const wxString& filename, wxOutputStream& stream);
644bool WXDLLEXPORT wxTransferStreamToFile(wxInputStream& stream, const wxString& filename);
a533f5c1 645#endif
c801d85f 646
caf0debf 647#endif // _WX_DOCH__