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.

121 lines
5.1KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library - "Jules' Utility Class Extensions"
  4. Copyright 2004-11 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_PAINTROUTINE_JUCEHEADER__
  19. #define __JUCER_PAINTROUTINE_JUCEHEADER__
  20. #include "paintelements/jucer_PaintElement.h"
  21. class JucerDocument;
  22. class PathPoint;
  23. //==============================================================================
  24. /**
  25. Contains a set of PaintElements that constitute some kind of paint() method.
  26. */
  27. class PaintRoutine
  28. {
  29. public:
  30. //==============================================================================
  31. PaintRoutine();
  32. ~PaintRoutine();
  33. //==============================================================================
  34. void changed();
  35. bool perform (UndoableAction* action, const String& actionName);
  36. //==============================================================================
  37. int getNumElements() const noexcept { return elements.size(); }
  38. PaintElement* getElement (const int index) const noexcept { return elements [index]; }
  39. int indexOfElement (PaintElement* e) const noexcept { return elements.indexOf (e); }
  40. bool containsElement (PaintElement* e) const noexcept { return elements.contains (e); }
  41. //==============================================================================
  42. void clear();
  43. PaintElement* addElementFromXml (const XmlElement& xml, const int index, const bool undoable);
  44. PaintElement* addNewElement (PaintElement* elementToCopy, const int index, const bool undoable);
  45. void removeElement (PaintElement* element, const bool undoable);
  46. void elementToFront (PaintElement* element, const bool undoable);
  47. void elementToBack (PaintElement* element, const bool undoable);
  48. const Colour getBackgroundColour() const noexcept { return backgroundColour; }
  49. void setBackgroundColour (const Colour& newColour) noexcept;
  50. void fillWithBackground (Graphics& g, const bool drawOpaqueBackground);
  51. void drawElements (Graphics& g, const Rectangle<int>& relativeTo);
  52. void dropImageAt (const File& f, int x, int y);
  53. //==============================================================================
  54. SelectedItemSet <PaintElement*>& getSelectedElements() noexcept { return selectedElements; }
  55. SelectedItemSet <PathPoint*>& getSelectedPoints() noexcept { return selectedPoints; }
  56. static const char* const clipboardXmlTag;
  57. void copySelectedToClipboard();
  58. void paste();
  59. void deleteSelected();
  60. void selectAll();
  61. void selectedToFront();
  62. void selectedToBack();
  63. void groupSelected();
  64. void ungroupSelected();
  65. void startDragging (const Rectangle<int>& parentArea);
  66. void dragSelectedComps (int dxFromDragStart, int dyFromDragStart, const Rectangle<int>& parentArea);
  67. void endDragging();
  68. void bringLostItemsBackOnScreen (const Rectangle<int>& parentArea);
  69. //==============================================================================
  70. void setDocument (JucerDocument* const doc) { document = doc; }
  71. JucerDocument* getDocument() const noexcept { return document; }
  72. //==============================================================================
  73. static const char* xmlTagName;
  74. XmlElement* createXml() const;
  75. bool loadFromXml (const XmlElement& xml);
  76. void fillInGeneratedCode (GeneratedCode& code, String& paintMethodCode) const;
  77. //==============================================================================
  78. private:
  79. OwnedArray <PaintElement> elements;
  80. SelectedItemSet <PaintElement*> selectedElements;
  81. SelectedItemSet <PathPoint*> selectedPoints;
  82. JucerDocument* document;
  83. Colour backgroundColour;
  84. friend class DeleteElementAction;
  85. friend class FrontOrBackElementAction;
  86. void moveElementZOrder (int oldIndex, int newIndex);
  87. };
  88. #endif // __JUCER_PAINTROUTINE_JUCEHEADER__