sptk2 logo
SPTK Home Page
CWindowShape.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 <sptk5/gui/CShapePoint.h>
30#include <sptk5/gui/sptk_fltk_version.h>
31#include <vector>
32
33namespace sptk {
34
40class CWindow;
41
49class SP_EXPORT CWindowShape
50{
54 sptk::CWindow* m_window;
55
59 int m_lastW {0};
60
64 int m_lastH {0};
65
66protected:
70 int m_resizingZone {0};
71
75 int m_pushedX {0};
76
80 int m_pushedY {0};
81
85 std::vector<CShapePoint> m_shapePoints;
86
90 bool m_shapeChanged {true};
91
95 int m_borderWidth {6};
96
100 bool m_borderCleared {false};
101
105 bool m_shapeExtension {false};
106
112 int mouseZone(int mouseX, int mouseY) const;
113
119 void changeSize(int mouseX, int mouseY);
120
127 virtual int shapeCursorHandle(int event);
128
129public:
134 explicit CWindowShape(sptk::CWindow* window);
135
140 {
141 }
142
149 {
150 return m_resizingZone != 0;
151 }
152
153protected:
161
165 bool borderCleared() const
166 {
167 return m_borderCleared;
168 }
169
174
178 void resizingShape(int w, int h)
179 {
180 if (m_lastW == w && m_lastH == h)
181 return;
182 shapeResize(w, h);
183 m_shapeChanged = true;
184 m_lastW = w;
185 m_lastH = h;
186 }
187
194 virtual void shapeResize(int w, int h)
195 {
196 // Implemented in derived class
197 }
198};
202} // namespace sptk
Window non-rectangular shape support.
Definition: CWindowShape.h:50
virtual int shapeCursorHandle(int event)
Changes the window cursor based on the mouse position in the window.
virtual void shapeResize(int w, int h)
Shape resize.
Definition: CWindowShape.h:194
CWindowShape(sptk::CWindow *window)
Constructor.
void initShapeExtension()
Initializes shape extension.
bool borderCleared() const
Returns true if border was cleared for the shape.
Definition: CWindowShape.h:165
virtual ~CWindowShape()
Destructor.
Definition: CWindowShape.h:139
std::vector< CShapePoint > m_shapePoints
Definition: CWindowShape.h:85
void shapeApply()
Sets the shape to the window during window->draw()
void resizingShape(int w, int h)
Calls resizeShape() from inside CWindow::resize()
Definition: CWindowShape.h:178
void changeSize(int mouseX, int mouseY)
Resizes the window based on mouse zone and mouse screen coordinates.
bool shapeResizing()
Returns true if the window is resizing as a result of border drag.
Definition: CWindowShape.h:148
int mouseZone(int mouseX, int mouseY) const
Computes mouse zone from window coordinates.
Window widget.
Definition: CWindow.h:57

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