sptk2 logo
SPTK Home Page
CWindow.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#ifdef _WIN32
30#include <WinSock2.h>
31#include <Windows.h>
32#endif
33
34#include <FL/Fl_Double_Window.H>
35#include <sptk5/Strings.h>
36#include <sptk5/cutils>
37#include <sptk5/gui/CLayoutManager.h>
38#include <sptk5/gui/CWindowShape.h>
39
40namespace sptk {
41
53class SP_EXPORT CWindow
54 : public Fl_Double_Window
55 , public CLayoutManager
56 , public CWindowShape
57{
58public:
65 CWindow(int w, int h, const char* label = 0L)
66 : Fl_Double_Window(w, h, label)
67 , CLayoutManager(this, 10, CLayoutAlign::NONE)
68 , CWindowShape(this)
69 {
70 }
71
80 CWindow(int x, int y, int w, int h, const char* label = 0L)
81 : Fl_Double_Window(x, y, w, h)
82 , CLayoutManager(this, 10, CLayoutAlign::NONE)
83 , CWindowShape(this)
84 {
85 }
86
90 void draw() override;
91
95 void show() override
96 {
97 Fl_Double_Window::show();
98 }
99
105 void show(int argc, char* argv[])
106 {
107 Fl_Double_Window::show(argc, argv);
108 }
109
113 void hide() override;
114
118 virtual void relayout()
119 {
120 resize(x(), y(), w(), h());
121 }
122
126 void clear() override
127 {
128 Fl_Double_Window::clear();
129 }
130
138 void resize(int x, int y, int w, int h) override;
139
146 bool preferredSize(int& w, int& h) override;
147
153 int handle(int event) override;
154
161 void load(const std::shared_ptr<xdoc::Node>& node, CLayoutXMLmode xmlMode) override;
162
168 void load(const std::shared_ptr<xdoc::Node>& node) override
169 {
170 load(node, CLayoutXMLmode::DATA);
171 }
172
179 void save(const std::shared_ptr<xdoc::Node>& node, CLayoutXMLmode xmlMode) const override;
180
186 virtual void save(const xdoc::SNode& node) const
187 {
188 save(node, CLayoutXMLmode::DATA);
189 }
190
196 void loadPosition(const xdoc::SNode& node);
197
203 void savePosition(const xdoc::SNode& node) const;
204
208 const String& label() const override
209 {
210 return m_label;
211 }
212
214
218 String className() const override
219 {
220 return "window";
221 }
222};
226} // namespace sptk
virtual const String & label() const
Definition: CLayoutClient.h:213
Layout Manager.
Definition: CLayoutManager.h:103
Window non-rectangular shape support.
Definition: CWindowShape.h:50
Window widget.
Definition: CWindow.h:57
const String & label() const override
Returns the current label.
Definition: CWindow.h:208
void savePosition(const xdoc::SNode &node) const
Saves the window position into XML node.
void show() override
Custom show method.
Definition: CWindow.h:95
virtual void relayout()
Relayouts window's widgets that have CLayoutClient interface.
Definition: CWindow.h:118
CWindow(int x, int y, int w, int h, const char *label=0L)
Constructor.
Definition: CWindow.h:80
void show(int argc, char *argv[])
Custom show method.
Definition: CWindow.h:105
String className() const override
Returns widget class name (internal SPTK RTTI).
Definition: CWindow.h:218
void load(const std::shared_ptr< xdoc::Node > &node, CLayoutXMLmode xmlMode) override
Loads window coordinates and widgets from XML node.
void loadPosition(const xdoc::SNode &node)
Loads the window position from XML node.
void draw() override
Draws a window, including an optional background image.
CWindow(int w, int h, const char *label=0L)
Constructor.
Definition: CWindow.h:65
virtual void save(const xdoc::SNode &node) const
Saves window coordinates and widgets into XML node.
Definition: CWindow.h:186
void save(const std::shared_ptr< xdoc::Node > &node, CLayoutXMLmode xmlMode) const override
Saves window coordinates and widgets into XML node.
bool preferredSize(int &w, int &h) override
Computes the optimal window size.
int handle(int event) override
Custom window events handle.
void resize(int x, int y, int w, int h) override
Resizes the window and inside widgets.
void load(const std::shared_ptr< xdoc::Node > &node) override
Loads window coordinates and widgets from XML node.
Definition: CWindow.h:168
void clear() override
Removes all the widgets inside the window.
Definition: CWindow.h:126
void hide() override
Custom hide method.
Definition: String.h:49
CLayoutAlign
Definition: CLayoutClient.h:44
CLayoutXMLmode
Definition: CLayoutClient.h:57

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