sptk2 logo
SPTK Home Page
CLayoutClient.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 alexey overridep@gmail.com. │
24└──────────────────────────────────────────────────────────────────────────────┘
25*/
26
27#pragma once
28
29#include <FL/Fl_Widget.H>
30#include <sptk5/xdoc/Node.h>
31#include <string>
32
33namespace sptk {
34
43enum class CLayoutAlign : uint8_t
44{
45 NONE,
46 LEFT,
47 RIGHT,
48 TOP,
49 BOTTOM,
50 CLIENT
51};
52
56enum class CLayoutXMLmode : uint8_t
57{
61 DATA = 1,
62
66 LAYOUT = 2,
67
71 LAYOUTDATA = 3
72};
73
81class SP_EXPORT CLayoutClient
82{
83 friend class CLayoutManager;
84
95 int m_layoutSize;
96
100 int m_lastPreferredW {0};
101
105 int m_lastPreferredH {0};
106
107protected:
111 int lastPreferredH() const;
112
116 int lastPreferredW() const;
117
122 void lastPreferredH(int height);
123
128 void lastPreferredW(int width);
129
133 Fl_Widget* m_widget;
134
139
144
149
150public:
157 CLayoutClient(Fl_Widget* widget, int layoutSize, CLayoutAlign ca);
158
163 {
164 }
165
171 {
172 return m_layoutAlign;
173 }
174
180 {
181 m_layoutAlign = al;
182 }
183
187 int layoutSize() const
188 {
189 return m_layoutSize;
190 }
191
195 void layoutSize(int ls)
196 {
197 m_layoutSize = ls;
198 }
199
204 virtual void label(const String& l)
205 {
206 m_label = l;
207 m_widget->label(m_label.c_str());
208 }
209
213 virtual const String& label() const
214 {
215 return m_label;
216 }
217
223 void name(const char* aname)
224 {
225 m_name = aname;
226 }
227
233 void name(const String& aname)
234 {
235 m_name = aname;
236 }
237
241 const String& name() const
242 {
243 return m_name;
244 }
245
256 virtual bool preferredSize(int& w, int& h)
257 {
258 return false;
259 }
260
268 virtual bool computeSize(int& w, int& h)
269 {
270 bool rc = preferredSize(w, h);
271 m_lastPreferredW = w;
272 m_lastPreferredH = h;
273 return rc;
274 }
275
279 virtual String className() const
280 {
281 return "Undefined";
282 }
283
287 Fl_Widget* widget() const
288 {
289 return m_widget;
290 }
291
300 virtual void load(const xdoc::SNode& node, CLayoutXMLmode xmlMode);
301
309 virtual void load(const std::shared_ptr<xdoc::Node>& node)
310 {
311 load(node, CLayoutXMLmode::LAYOUT);
312 }
313
322 virtual void save(const std::shared_ptr<xdoc::Node>& node, CLayoutXMLmode xmlMode) const;
323};
327} // namespace sptk
Definition: CLayoutClient.h:82
void name(const String &aname)
Definition: CLayoutClient.h:233
virtual void load(const xdoc::SNode &node, CLayoutXMLmode xmlMode)
void lastPreferredW(int width)
String m_name
Definition: CLayoutClient.h:138
int lastPreferredW() const
int layoutSize() const
Definition: CLayoutClient.h:187
CLayoutClient(Fl_Widget *widget, int layoutSize, CLayoutAlign ca)
void layoutAlign(CLayoutAlign al)
Definition: CLayoutClient.h:179
Fl_Widget * widget() const
Definition: CLayoutClient.h:287
virtual const String & label() const
Definition: CLayoutClient.h:213
virtual bool preferredSize(int &w, int &h)
Definition: CLayoutClient.h:256
const String & name() const
Definition: CLayoutClient.h:241
virtual void load(const std::shared_ptr< xdoc::Node > &node)
Definition: CLayoutClient.h:309
String m_label
Definition: CLayoutClient.h:143
CLayoutAlign layoutAlign() const
Definition: CLayoutClient.h:170
virtual void save(const std::shared_ptr< xdoc::Node > &node, CLayoutXMLmode xmlMode) const
Fl_Widget * m_widget
Definition: CLayoutClient.h:133
int lastPreferredH() const
void lastPreferredH(int height)
virtual ~CLayoutClient()
Definition: CLayoutClient.h:162
void name(const char *aname)
Definition: CLayoutClient.h:223
void layoutSize(int ls)
Definition: CLayoutClient.h:195
virtual bool computeSize(int &w, int &h)
Definition: CLayoutClient.h:268
CLayoutAlign m_layoutAlign
Definition: CLayoutClient.h:148
virtual String className() const
Definition: CLayoutClient.h:279
virtual void label(const String &l)
Definition: CLayoutClient.h:204
Layout Manager.
Definition: CLayoutManager.h:103
Definition: String.h:49
CLayoutAlign
Definition: CLayoutClient.h:44
CLayoutXMLmode
Definition: CLayoutClient.h:57
@ BOTTOM
Align to the top.
@ RIGHT
Align to the left.
@ TOP
Align to the right.
@ LEFT
Do not use allignment.
@ CLIENT
Align to the bottom.

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