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.

80 lines
2.7KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2022 - Raw Material Software Limited
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. By using JUCE, you agree to the terms of both the JUCE 7 End-User License
  8. Agreement and JUCE Privacy Policy.
  9. End User License Agreement: www.juce.com/juce-7-licence
  10. Privacy Policy: www.juce.com/juce-privacy-policy
  11. Or: You may also use this code under the terms of the GPL v3 (see
  12. www.gnu.org/licenses).
  13. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  14. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  15. DISCLAIMED.
  16. ==============================================================================
  17. */
  18. #pragma once
  19. //==============================================================================
  20. class TextButtonHandler : public ButtonHandler
  21. {
  22. public:
  23. TextButtonHandler()
  24. : ButtonHandler ("Text Button", "juce::TextButton", typeid (TextButton), 150, 24)
  25. {
  26. registerColour (juce::TextButton::buttonColourId, "background (normal)", "bgColOff");
  27. registerColour (juce::TextButton::buttonOnColourId, "background (on)", "bgColOn");
  28. registerColour (juce::TextButton::textColourOffId, "text colour (normal)", "textCol");
  29. registerColour (juce::TextButton::textColourOnId, "text colour (on)", "textColOn");
  30. }
  31. Component* createNewComponent (JucerDocument*) override
  32. {
  33. return new TextButton ("new button", String());
  34. }
  35. void getEditableProperties (Component* component, JucerDocument& document,
  36. Array<PropertyComponent*>& props, bool multipleSelected) override
  37. {
  38. ButtonHandler::getEditableProperties (component, document, props, multipleSelected);
  39. if (multipleSelected)
  40. return;
  41. addColourProperties (component, document, props);
  42. }
  43. XmlElement* createXmlFor (Component* comp, const ComponentLayout* layout) override
  44. {
  45. return ButtonHandler::createXmlFor (comp, layout);
  46. }
  47. bool restoreFromXml (const XmlElement& xml, Component* comp, const ComponentLayout* layout) override
  48. {
  49. return ButtonHandler::restoreFromXml (xml, comp, layout);
  50. }
  51. void fillInCreationCode (GeneratedCode& code, Component* component, const String& memberVariableName) override
  52. {
  53. ButtonHandler::fillInCreationCode (code, component, memberVariableName);
  54. String s;
  55. s << getColourIntialisationCode (component, memberVariableName)
  56. << '\n';
  57. code.constructorCode += s;
  58. }
  59. };