The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

108 lines
4.0KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library - "Jules' Utility Class Extensions"
  4. Copyright 2004-10 by Raw Material Software Ltd.
  5. ------------------------------------------------------------------------------
  6. JUCE can be redistributed and/or modified under the terms of the GNU General
  7. Public License (Version 2), as published by the Free Software Foundation.
  8. A copy of the license is included in the JUCE distribution, or can be found
  9. online at www.gnu.org/licenses.
  10. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  13. ------------------------------------------------------------------------------
  14. To release a closed-source product which uses JUCE, commercial licenses are
  15. available: visit www.rawmaterialsoftware.com/juce for more information.
  16. ==============================================================================
  17. */
  18. #ifndef __JUCER_OPENDOCUMENTMANAGER_JUCEHEADER__
  19. #define __JUCER_OPENDOCUMENTMANAGER_JUCEHEADER__
  20. #include "../model/Project/jucer_Project.h"
  21. #include "../model/Drawable/jucer_DrawableDocument.h"
  22. //==============================================================================
  23. /**
  24. */
  25. class OpenDocumentManager
  26. {
  27. public:
  28. //==============================================================================
  29. OpenDocumentManager();
  30. ~OpenDocumentManager();
  31. juce_DeclareSingleton_SingleThreaded_Minimal (OpenDocumentManager);
  32. //==============================================================================
  33. class Document
  34. {
  35. public:
  36. Document() {}
  37. virtual ~Document() {}
  38. virtual bool loadedOk() const = 0;
  39. virtual bool isForFile (const File& file) const = 0;
  40. virtual bool isForNode (const ValueTree& node) const = 0;
  41. virtual bool refersToProject (Project& project) const = 0;
  42. virtual const String getName() const = 0;
  43. virtual const String getType() const = 0;
  44. virtual bool needsSaving() const = 0;
  45. virtual bool save() = 0;
  46. virtual bool hasFileBeenModifiedExternally() = 0;
  47. virtual void reloadFromFile() = 0;
  48. virtual Component* createEditor() = 0;
  49. virtual Component* createViewer() = 0;
  50. virtual void fileHasBeenRenamed (const File& newFile) = 0;
  51. };
  52. Document* getDocumentForFile (Project* project, const File& file);
  53. bool canOpenFile (const File& file);
  54. //==============================================================================
  55. int getNumOpenDocuments() const;
  56. Document* getOpenDocument (int index) const;
  57. void moveDocumentToTopOfStack (Document* doc);
  58. bool closeDocument (int index, bool saveIfNeeded);
  59. bool closeDocument (Document* document, bool saveIfNeeded);
  60. bool closeAllDocumentsUsingProject (Project& project, bool saveIfNeeded);
  61. void closeFile (const File& f, bool saveIfNeeded);
  62. bool anyFilesNeedSaving() const;
  63. bool saveAll();
  64. FileBasedDocument::SaveResult saveIfNeededAndUserAgrees (Document* doc);
  65. void reloadModifiedFiles();
  66. void fileHasBeenRenamed (const File& oldFile, const File& newFile);
  67. //==============================================================================
  68. class DocumentCloseListener
  69. {
  70. public:
  71. DocumentCloseListener() {}
  72. virtual ~DocumentCloseListener() {}
  73. virtual void documentAboutToClose (Document* document) = 0;
  74. };
  75. void addListener (DocumentCloseListener* listener);
  76. void removeListener (DocumentCloseListener* listener);
  77. //==============================================================================
  78. juce_UseDebuggingNewOperator
  79. private:
  80. OwnedArray <Document> documents;
  81. Array <DocumentCloseListener*> listeners;
  82. };
  83. #endif // __JUCER_OPENDOCUMENTMANAGER_JUCEHEADER__