sptk2 logo
SPTK Home Page
CControlList.h
1/*
2╔══════════════════════════════════════════════════════════════════════════════╗
3║ SIMPLY POWERFUL TOOLKIT (SPTK) ║
4╟──────────────────────────────────────────────────────────────────────────────╢
5║ copyright © 1999-2022 Alexey Parshin. All rights reserved. ║
6║ email alexeyp@gmail.com ║
7╚══════════════════════════════════════════════════════════════════════════════╝
8┌──────────────────────────────────────────────────────────────────────────────┐
9│ This library is free software; you can redistribute it and/or modify it │
10│ under the terms of the GNU Library General Public License as published by │
11│ the Free Software Foundation; either version 2 of the License, or (at your │
12│ option) any later version. │
13│ │
14│ This library is distributed in the hope that it will be useful, but │
15│ WITHOUT ANY WARRANTY; without even the implied warranty of │
16│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library │
17│ General Public License for more details. │
18│ │
19│ You should have received a copy of the GNU Library General Public License │
20│ along with this library; if not, write to the Free Software Foundation, │
21│ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. │
22│ │
23│ Please report all bugs and problems to alexeyp@gmail.com. │
24└──────────────────────────────────────────────────────────────────────────────┘
25*/
26
27#pragma once
28
29#include <map>
30#include <sptk5/CaseInsensitiveCompare.h>
31#include <sptk5/gui/CControl.h>
32
33namespace sptk {
34
45using CStringControlMap = std::map<std::string, CControl*, CaseInsensitiveCompare>;
46
50class SP_EXPORT CControlList
51 : public CStringControlMap
52{
53protected:
57 void scanControls(const Fl_Group* group);
58
59public:
63 CControlList() = default;
64
68 void add(CControl* control);
69
73 void add(const CControlList& l);
74
78 void add(const Fl_Group& g);
79
83 void remove(const CControl* control)
84 {
85 erase(control->fieldName());
86 }
87
91 void remove(const CControlList& l);
92
96 bool contains(const CControl* control) const
97 {
98 if (!control)
99 {
100 return false;
101 }
102 return find(control->fieldName()) != end();
103 }
104
108 CControlList& operator=(const Fl_Group& g)
109 {
110 clear();
111 add(g);
112 return *this;
113 }
114
119 {
120 if (&l != this)
121 {
122 clear();
123 add(l);
124 }
125 return *this;
126 }
127
132 {
133 add(c);
134 return *this;
135 }
136
140 CControlList& operator<<(const Fl_Group& g)
141 {
142 add(g);
143 return *this;
144 }
145
150 {
151 add(l);
152 return *this;
153 }
154
158 void reset();
159};
163} // namespace sptk
List of CControl object pointers in Fl_Group.
Definition: CControlList.h:52
CControlList & operator<<(const CControlList &l)
Addition operation.
Definition: CControlList.h:149
void scanControls(const Fl_Group *group)
Scan group to find all CControl objects inside, including children groups.
void remove(const CControlList &l)
Removes a list of CControl pointers from the list.
void reset()
Sends reset() signal to all the widgets in the list.
CControlList & operator=(const CControlList &l)
Assignment operation.
Definition: CControlList.h:118
bool contains(const CControl *control) const
Returns true if the control for the same field name exists.
Definition: CControlList.h:96
void add(const CControlList &l)
Adds a list of CControl pointers into the list.
void add(CControl *control)
Adds a CControl pointer into the list.
CControlList & operator<<(const Fl_Group &g)
Addition operation.
Definition: CControlList.h:140
CControlList & operator=(const Fl_Group &g)
Assignment operation.
Definition: CControlList.h:108
CControlList & operator<<(CControl *c)
Addition operation.
Definition: CControlList.h:131
CControlList()=default
Constructor.
void remove(const CControl *control)
Removes CControl pointer from the list.
Definition: CControlList.h:83
void add(const Fl_Group &g)
Adds a list of CControl pointers from the group into the list.
Base class for most of SPTK widgets.
Definition: CControl.h:222
virtual const String & fieldName() const
Returns control's field name for universal data connection.
Definition: CControl.h:582
std::map< std::string, CControl *, CaseInsensitiveCompare > CStringControlMap
String to Control map. Uses strings and pointers to CControl. Strings are control field names.
Definition: CControlList.h:45

Fri Oct 14 2022 09:58:31: SPTK 5.4.1