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