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.

119 lines
5.0KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library - "Jules' Utility Class Extensions"
  4. Copyright 2004-9 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_COMPONENTDOCUMENT_JUCEHEADER__
  19. #define __JUCER_COMPONENTDOCUMENT_JUCEHEADER__
  20. #include "../jucer_Headers.h"
  21. #include "jucer_Project.h"
  22. #include "jucer_Coordinate.h"
  23. //==============================================================================
  24. class ComponentDocument : public ValueTree::Listener
  25. {
  26. public:
  27. //==============================================================================
  28. ComponentDocument (Project* project, const File& cppFile);
  29. ~ComponentDocument();
  30. static bool isComponentFile (const File& file);
  31. bool save();
  32. bool reload();
  33. bool hasChangedSinceLastSave();
  34. typedef SelectedItemSet<uint32> SelectedItems;
  35. //==============================================================================
  36. Value getClassName() { return getRootValueNonUndoable ("className"); }
  37. Value getClassDescription() { return getRootValueNonUndoable ("classDesc"); }
  38. Value getCanvasWidth() { return getRootValueNonUndoable ("width"); }
  39. Value getCanvasHeight() { return getRootValueNonUndoable ("height"); }
  40. void createClassProperties (Array <PropertyComponent*>& props);
  41. const String getNonExistentMemberName (String suggestedName);
  42. //==============================================================================
  43. int getNumComponents() const;
  44. const ValueTree getComponent (int index) const;
  45. const ValueTree getComponentWithMemberName (const String& name) const;
  46. Component* createComponent (int index);
  47. void updateComponent (Component* comp);
  48. bool containsComponent (Component* comp) const;
  49. const ValueTree getComponentState (Component* comp) const;
  50. void getComponentProperties (Array <PropertyComponent*>& props, Component* comp);
  51. bool isStateForComponent (const ValueTree& storedState, Component* comp) const;
  52. Coordinate::MarkerResolver* createMarkerResolver (const ValueTree& state);
  53. const StringArray getComponentMarkers (bool horizontal) const;
  54. const RectangleCoordinates getCoordsFor (const ValueTree& componentState) const;
  55. bool setCoordsFor (ValueTree& componentState, const RectangleCoordinates& newSize);
  56. void addNewComponentMenuItems (PopupMenu& menu) const;
  57. void performNewComponentMenuItem (int menuResultCode);
  58. //==============================================================================
  59. void beginDrag (const Array<Component*>& items, const MouseEvent& e,
  60. Component* parentForOverlays, const ResizableBorderComponent::Zone& zone);
  61. void continueDrag (const MouseEvent& e);
  62. void endDrag (const MouseEvent& e);
  63. //==============================================================================
  64. ValueTree& getRoot() { return root; }
  65. UndoManager* getUndoManager();
  66. void beginNewTransaction();
  67. void valueTreePropertyChanged (ValueTree& treeWhosePropertyHasChanged, const var::identifier& property);
  68. void valueTreeChildrenChanged (ValueTree& treeWhoseChildHasChanged);
  69. void valueTreeParentChanged (ValueTree& treeWhoseParentHasChanged);
  70. static const char* const idProperty;
  71. static const char* const compBoundsProperty;
  72. static const char* const memberNameProperty;
  73. static const char* const compNameProperty;
  74. private:
  75. Project* project;
  76. File cppFile;
  77. ValueTree root;
  78. UndoManager undoManager;
  79. bool changedSinceSaved;
  80. void checkRootObject();
  81. ValueTree getComponentGroup() const;
  82. Value getRootValueUndoable (const var::identifier& name) { return root.getPropertyAsValue (name, getUndoManager()); }
  83. Value getRootValueNonUndoable (const var::identifier& name) { return root.getPropertyAsValue (name, 0); }
  84. void writeCode (OutputStream& cpp, OutputStream& header);
  85. void writeMetadata (OutputStream& out);
  86. };
  87. #endif // __JUCER_COMPONENTDOCUMENT_JUCEHEADER__