1 /*
2   ==============================================================================
3 
4    This file is part of the JUCE library.
5    Copyright (c) 2020 - Raw Material Software Limited
6 
7    JUCE is an open source library subject to commercial or open-source
8    licensing.
9 
10    By using JUCE, you agree to the terms of both the JUCE 6 End-User License
11    Agreement and JUCE Privacy Policy (both effective as of the 16th June 2020).
12 
13    End User License Agreement: www.juce.com/juce-6-licence
14    Privacy Policy: www.juce.com/juce-privacy-policy
15 
16    Or: You may also use this code under the terms of the GPL v3 (see
17    www.gnu.org/licenses).
18 
19    JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
20    EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
21    DISCLAIMED.
22 
23   ==============================================================================
24 */
25 
26 namespace juce
27 {
28 
29 //==============================================================================
30 /**
31     A PropertyComponent that contains a button.
32 
33     This type of property component can be used if you need a button to trigger some
34     kind of action.
35 
36     @see PropertyComponent
37 
38     @tags{GUI}
39 */
40 class JUCE_API  ButtonPropertyComponent  : public PropertyComponent
41 {
42 public:
43     //==============================================================================
44     /** Creates a button component.
45 
46         @param propertyName         the property name to be passed to the PropertyComponent
47         @param triggerOnMouseDown   this is passed to the Button::setTriggeredOnMouseDown() method
48     */
49     ButtonPropertyComponent (const String& propertyName,
50                              bool triggerOnMouseDown);
51 
52     /** Destructor. */
53     ~ButtonPropertyComponent() override;
54 
55     //==============================================================================
56     /** Called when the user clicks the button.
57     */
58     virtual void buttonClicked() = 0;
59 
60     /** Returns the string that should be displayed in the button.
61 
62         If you need to change this string, call refresh() to update the component.
63     */
64     virtual String getButtonText() const = 0;
65 
66     //==============================================================================
67     /** @internal */
68     void refresh() override;
69 
70 private:
71     TextButton button;
72 
73     JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ButtonPropertyComponent)
74 };
75 
76 } // namespace juce
77