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.

116 lines
4.0KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2015 - ROLI Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. #pragma once
  18. #include "../Project/jucer_ProjectContentComponent.h"
  19. //==============================================================================
  20. /**
  21. The big top-level window where everything happens.
  22. */
  23. class MainWindow : public DocumentWindow,
  24. public ApplicationCommandTarget,
  25. public FileDragAndDropTarget,
  26. public DragAndDropContainer
  27. {
  28. public:
  29. //==============================================================================
  30. MainWindow();
  31. ~MainWindow();
  32. //==============================================================================
  33. void closeButtonPressed() override;
  34. //==============================================================================
  35. bool canOpenFile (const File& file) const;
  36. bool openFile (const File& file);
  37. void setProject (Project* newProject);
  38. Project* getProject() const { return currentProject; }
  39. void makeVisible();
  40. void restoreWindowPosition();
  41. bool closeProject (Project* project);
  42. bool closeCurrentProject();
  43. void showNewProjectWizard();
  44. bool isInterestedInFileDrag (const StringArray& files) override;
  45. void filesDropped (const StringArray& filenames, int mouseX, int mouseY) override;
  46. void activeWindowStatusChanged() override;
  47. ProjectContentComponent* getProjectContentComponent() const;
  48. //==============================================================================
  49. ApplicationCommandTarget* getNextCommandTarget() override;
  50. void getAllCommands (Array <CommandID>& commands) override;
  51. void getCommandInfo (CommandID commandID, ApplicationCommandInfo& result) override;
  52. bool perform (const InvocationInfo& info) override;
  53. bool shouldDropFilesWhenDraggedExternally (const DragAndDropTarget::SourceDetails& sourceDetails,
  54. StringArray& files, bool& canMoveFiles) override;
  55. private:
  56. ScopedPointer<Project> currentProject;
  57. static const char* getProjectWindowPosName() { return "projectWindowPos"; }
  58. void createProjectContentCompIfNeeded();
  59. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainWindow)
  60. };
  61. //==============================================================================
  62. class MainWindowList
  63. {
  64. public:
  65. MainWindowList();
  66. void forceCloseAllWindows();
  67. bool askAllWindowsToClose();
  68. void closeWindow (MainWindow*);
  69. void createWindowIfNoneAreOpen();
  70. void openDocument (OpenDocumentManager::Document*, bool grabFocus);
  71. bool openFile (const File& file);
  72. MainWindow* createNewMainWindow();
  73. MainWindow* getFrontmostWindow (bool createIfNotFound = true);
  74. MainWindow* getOrCreateEmptyWindow();
  75. Project* getFrontmostProject();
  76. void reopenLastProjects();
  77. void saveCurrentlyOpenProjectList();
  78. void avoidSuperimposedWindows (MainWindow*);
  79. void sendLookAndFeelChange();
  80. OwnedArray<MainWindow> windows;
  81. private:
  82. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainWindowList)
  83. };