sptk2 logo
SPTK Home Page
CButtonGroup.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 <FL/Fl_Box.H>
30#include <FL/Fl_Button.H>
31#include <FL/Fl_Group.H>
32#include <FL/Fl_Input_.H>
33#include <sptk5/Strings.h>
34#include <sptk5/gui/CControl.h>
35#include <sptk5/gui/CInput.h>
36
37namespace sptk {
38
49class SP_EXPORT CButtonGroup
50 : public CControl
51{
55 int m_maxHeight {0};
56
60 std::string m_lastValue;
61
65 Strings m_buttonLabels;
66
70 Fl_Button* m_otherButton {nullptr};
71
75 CInput_* m_otherInput {nullptr};
76
77protected:
81 virtual void controlDataChanged();
82
88 int buttonIndex(const char* buttonLabel);
89
94
98 virtual Fl_Button* createButton(const char* label, int sz = 10,
99 CLayoutAlign layoutAlignment = CLayoutAlign::TOP) = 0;
100
104 void ctor_init();
105
112 CButtonGroup(const char* label = nullptr, int layoutSize = 20,
113 CLayoutAlign layoutAlignment = CLayoutAlign::TOP);
114
115#ifdef __COMPATIBILITY_MODE__
124 CButtonGroup(int, int, int, int, const char* = 0);
125#endif
126
127public:
132 void buttons(const Strings& buttonList);
133
137 const Strings& buttons() const
138 {
139 return m_buttonLabels;
140 }
141
145 virtual void clearButtons();
146
150 Variant data() const override;
151
159 void data(const Variant& v) override;
160
166 void load(Query*) override;
167
173 void save(Query*) override;
174
183 void load(const xdoc::SNode& node, CLayoutXMLmode xmlMode) override;
184
192 void load(const xdoc::SNode& node) override
193 {
194 load(node, CLayoutXMLmode::DATA);
195 }
196
205 void save(const xdoc::SNode& node, CLayoutXMLmode xmlMode) const override;
206
214 void save(const xdoc::SNode& node) const override
215 {
216 save(node, CLayoutXMLmode::DATA);
217 }
218
224 bool valid() const override
225 {
226 return true;
227 }
228
235 bool preferredSize(int& w, int& h) override;
236
240 Fl_Button* otherButton() const
241 {
242 return m_otherButton;
243 }
244
249 {
250 return m_otherInput;
251 }
252};
256} // namespace sptk
Definition: CButtonGroup.h:51
const Strings & buttons() const
Definition: CButtonGroup.h:137
virtual void controlDataChanged()
virtual void clearButtons()
bool valid() const override
Definition: CButtonGroup.h:224
CButtonGroup(const char *label=nullptr, int layoutSize=20, CLayoutAlign layoutAlignment=CLayoutAlign::TOP)
void buttons(const Strings &buttonList)
void data(const Variant &v) override
bool preferredSize(int &w, int &h) override
CInput_ * otherInput() const
Definition: CButtonGroup.h:248
void load(const xdoc::SNode &node, CLayoutXMLmode xmlMode) override
Variant data() const override
virtual Fl_Button * createButton(const char *label, int sz=10, CLayoutAlign layoutAlignment=CLayoutAlign::TOP)=0
int buttonIndex(const char *buttonLabel)
void save(Query *) override
void save(const xdoc::SNode &node) const override
Saves control data to XML.
Definition: CButtonGroup.h:214
void load(Query *) override
void save(const xdoc::SNode &node, CLayoutXMLmode xmlMode) const override
void load(const xdoc::SNode &node) override
Loads control data from XML.
Definition: CButtonGroup.h:192
Fl_Button * otherButton() const
Definition: CButtonGroup.h:240
Base class for most of SPTK widgets.
Definition: CControl.h:222
Definition: CInput.h:56
Definition: Query.h:239
Definition: Strings.h:52
Definition: Variant.h:372
CLayoutAlign
Definition: CLayoutClient.h:44
CLayoutXMLmode
Definition: CLayoutClient.h:57
@ TOP
Align to the right.

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