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.

124 lines
4.2KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2013 - Raw Material Software 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. #ifndef __JUCER_MAINWINDOW_JUCEHEADER__
  18. #define __JUCER_MAINWINDOW_JUCEHEADER__
  19. #include "../Project/jucer_ProjectContentComponent.h"
  20. //==============================================================================
  21. /**
  22. The big top-level window where everything happens.
  23. */
  24. class MainWindow : public DocumentWindow,
  25. public ApplicationCommandTarget,
  26. public FileDragAndDropTarget,
  27. public DragAndDropContainer
  28. {
  29. public:
  30. //==============================================================================
  31. MainWindow();
  32. ~MainWindow();
  33. //==============================================================================
  34. void closeButtonPressed() override;
  35. //==============================================================================
  36. bool canOpenFile (const File& file) const;
  37. bool openFile (const File& file);
  38. void setProject (Project* newProject);
  39. Project* getProject() const { return currentProject; }
  40. void makeVisible();
  41. void restoreWindowPosition();
  42. bool closeProject (Project* project);
  43. bool closeCurrentProject();
  44. void showNewProjectWizard();
  45. bool isInterestedInFileDrag (const StringArray& files) override;
  46. void filesDropped (const StringArray& filenames, int mouseX, int mouseY) override;
  47. void activeWindowStatusChanged() override;
  48. void updateTitle (const String& documentName);
  49. ProjectContentComponent* getProjectContentComponent() const;
  50. //==============================================================================
  51. ApplicationCommandTarget* getNextCommandTarget() override;
  52. void getAllCommands (Array <CommandID>& commands) override;
  53. void getCommandInfo (CommandID commandID, ApplicationCommandInfo& result) override;
  54. bool perform (const InvocationInfo& info) override;
  55. bool shouldDropFilesWhenDraggedExternally (const DragAndDropTarget::SourceDetails& sourceDetails,
  56. StringArray& files, bool& canMoveFiles) override;
  57. private:
  58. ScopedPointer <Project> currentProject;
  59. static const char* getProjectWindowPosName() { return "projectWindowPos"; }
  60. void createProjectContentCompIfNeeded();
  61. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainWindow)
  62. };
  63. //==============================================================================
  64. class MainWindowList
  65. {
  66. public:
  67. MainWindowList();
  68. void forceCloseAllWindows();
  69. bool askAllWindowsToClose();
  70. void closeWindow (MainWindow*);
  71. void createWindowIfNoneAreOpen();
  72. void openDocument (OpenDocumentManager::Document*, bool grabFocus);
  73. bool openFile (const File& file);
  74. MainWindow* createNewMainWindow();
  75. MainWindow* getOrCreateFrontmostWindow();
  76. MainWindow* getOrCreateEmptyWindow();
  77. Project* getFrontmostProject();
  78. void reopenLastProjects();
  79. void saveCurrentlyOpenProjectList();
  80. void updateAllWindowTitles();
  81. void avoidSuperimposedWindows (MainWindow*);
  82. void sendLookAndFeelChange();
  83. OwnedArray<MainWindow> windows;
  84. private:
  85. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainWindowList)
  86. };
  87. #endif // __JUCER_MAINWINDOW_JUCEHEADER__