OpenCPN Partial API docs
Loading...
Searching...
No Matches
field_text.h
Go to the documentation of this file.
1/***************************************************************************
2 * Copyright (C) 2025 by NoCodeHummel *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ***************************************************************************
19 */
20
25#ifndef TEXT_FIELD_H
26#define TEXT_FIELD_H
27
28#include <wx/wx.h>
29#include <wx/sizer.h>
30#include <wx/stattext.h>
31#include <wx/string.h>
32#include <wx/textctrl.h>
33#include <wx/valtext.h>
34
38class TextField : public wxTextCtrl {
39public:
49 TextField(wxWindow* parent, const wxString& label, const wxString& value = "",
50 wxWindowID id = wxID_ANY);
51
56 void OnError(const wxString& msg);
57
58 void SetValidator(const wxValidator& validator = wxDefaultValidator) override;
59
64 void OnTextChanged(wxCommandEvent& event);
65
66private:
67 wxStaticText* m_error_text;
68};
69
73class TextValidator : public wxTextValidator {
74public:
75 bool Validate(wxWindow* parent) override;
76
80 virtual wxValidator* Clone() const override = 0;
81
85 virtual wxString IsValid(const wxString& val) const override = 0;
86};
87
88#endif // TEXT_FIELD_H
Text field with validator and error handler.
Definition field_text.h:38
TextField(wxWindow *parent, const wxString &label, const wxString &value="", wxWindowID id=wxID_ANY)
Add new text field to the form grid.
void OnError(const wxString &msg)
Shows an error below the text field.
void OnTextChanged(wxCommandEvent &event)
Text changed event handler.
Base class for member to implement validation rules.
Definition field_text.h:73
virtual wxString IsValid(const wxString &val) const override=0
Member to implement the validation rules.
virtual wxValidator * Clone() const override=0
Member to implement the instance clone.