Jamba C++ API 7.5.0
Loading...
Searching...
No Matches
TextEditView.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018-2019 pongasoft
3 *
4 * Licensed under the Apache License, Version 2.0 or the MIT license,
5 * at your option. You may not use this file except in compliance with
6 * one of these licenses. You may obtain copies of the licenses at:
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 * https://opensource.org/licenses/MIT
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 * License for the specific language governing permissions and limitations under
15 * the License.
16 *
17 * @author Yan Pujante
18 */
19#pragma once
20
21#include <vstgui4/vstgui/lib/controls/ctextedit.h>
22#include <vstgui4/vstgui/lib/controls/icontrollistener.h>
24
26
27using namespace VSTGUI;
28using namespace Params;
29
32class TextEdit : public CTextEdit
33{
34public:
35 explicit TextEdit(const CRect &iSize) : CTextEdit(iSize, nullptr, UNDEFINED_PARAM_ID) {};
36};
37
47class TextEditView : public CustomViewAdapter<TextEdit>
48{
49public:
50 // Constructor
51 explicit TextEditView(const CRect &iSize) : CustomViewAdapter(iSize), fOnChangeListener{new CLabelListener(fText)}
52 {
53 registerControlListener(fOnChangeListener.get());
54 }
55
56 // registerParameters
57 void registerParameters() override;
58
59 // setListener
60 void setListener(IControlListener *l) override;
61
62protected:
63 // the underlying jmb parameter of type UTF8String
65
66private:
68 struct CLabelListener : public IControlListener {
70 void valueChanged(CControl *pControl) override;
72 };
73
74 std::unique_ptr<CLabelListener> fOnChangeListener;
75
76
77public:
78 class Creator : public CustomViewCreator<TextEditView, CustomViewAdapter<TextEdit>>
79 {
80 public:
81 explicit Creator(char const *iViewName = nullptr, char const *iDisplayName = nullptr) :
82 CustomViewCreator(iViewName, iDisplayName, VSTGUI::UIViewCreator::kCTextEdit)
83 {
84 }
85 };
86};
87
88}
89
This is the main class that the plugin should use as it exposes only the necessary methods of the par...
Definition GUIJmbParameter.h:497
CustomViewAdapter(const CRect &iSize, Args &&...args)
Definition CustomView.h:344
CustomViewCreator(char const *iViewName=nullptr, char const *iDisplayName=nullptr, char const *iBaseViewName=VSTGUI::UIViewCreator::kCView)
Definition CustomViewCreator.h:1318
TextEdit(const CRect &iSize)
Definition TextEditView.h:35
Creator(char const *iViewName=nullptr, char const *iDisplayName=nullptr)
Definition TextEditView.h:81
GUIJmbParam< UTF8String > fText
Definition TextEditView.h:64
void setListener(IControlListener *l) override
Definition TextEditView.cpp:42
void registerParameters() override
Subclasses should override this method to register each parameter.
Definition TextEditView.cpp:30
TextEditView(const CRect &iSize)
Definition TextEditView.h:51
std::unique_ptr< CLabelListener > fOnChangeListener
Definition TextEditView.h:74
Definition Types.h:30
Definition CustomController.h:25
constexpr ParamID UNDEFINED_PARAM_ID
Constant used throughout the code to test whether the ParamID represents a valid id or an undefined o...
Definition Types.h:48
Control listener to handle changes to the CTextLabel and propagates to fText.
Definition TextEditView.h:68
GUIJmbParam< UTF8String > & fText
Definition TextEditView.h:71
CLabelListener(GUIJmbParam< UTF8String > &iText)
Definition TextEditView.h:69
void valueChanged(CControl *pControl) override
Definition TextEditView.cpp:54