sptk2 logo
SPTK Home Page
CScroll.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_Group.H>
30
31#include <sptk5/gui/CLayoutClient.h>
32#include <sptk5/gui/CLayoutManager.h>
33#include <sptk5/gui/CScrollBar.h>
34
35namespace sptk {
36
46{ // values for type()
47 HORIZONTAL = 1,
48 VERTICAL = 2,
49 BOTH = 3,
50 ALWAYS_ON = 4,
51 HORIZONTAL_ALWAYS = 5,
52 VERTICAL_ALWAYS = 6,
53 BOTH_ALWAYS = 7
54};
55
62class SP_EXPORT CScroll
63 : public ::Fl_Group
64 , public CLayoutManager
65{
66
70 int m_xposition {0};
71
75 int m_yposition {0};
76
80 int m_oldx {0};
81
85 int m_oldy {0};
86
90 static void hscrollbar_cb(Fl_Widget*, void*);
91
95 static void scrollbar_cb(Fl_Widget*, void*);
96
100 void ctor_init();
101
105 void fix_scrollbar_order();
106
110 static void draw_clip(void* v, int X, int Y, int W, int H);
111
115 void bbox(int& X, int& Y, int& W, int& H);
116
117public:
124 CScroll(const char* label = 0, int layoutSize = 10, CLayoutAlign layoutAlign = CLayoutAlign::TOP);
125
126#ifdef __COMPATIBILITY_MODE__
135 CScroll(int x, int y, int w, int h, const char* label = 0L);
136#endif
137
142
147
148
156 void resize(int x, int y, int w, int h) override;
157
161 void draw() override;
162
169 bool preferredSize(int& w, int& h) override;
170
174 void clear() override;
175
179 virtual void position(int X, int Y);
180
184 int xposition() const
185 {
186 return m_xposition;
187 }
188
192 int yposition() const
193 {
194 return m_yposition;
195 }
196
200 int handle(int) override;
201
206 static CLayoutClient* creator(const xdoc::SNode& node);
207
211 String className() const override
212 {
213 return "scroll";
214 }
215};
219} // namespace sptk
Definition: CLayoutClient.h:82
Layout Manager.
Definition: CLayoutManager.h:103
Definition: CScrollBar.h:45
Scroll area widget.
Definition: CScroll.h:65
virtual void position(int X, int Y)
Sets the position of the scrolled area.
int yposition() const
Returns the y-position of the scrolled area.
Definition: CScroll.h:192
void clear() override
Removes all the child widgets.
String className() const override
Returns widget class name (internal SPTK RTTI).
Definition: CScroll.h:211
int handle(int) override
Custom handle method.
CScrollBar hscrollbar
Definition: CScroll.h:146
void draw() override
Custom draw() method.
CScrollBar scrollbar
Definition: CScroll.h:141
int xposition() const
Returns the x-position of the scrolled area.
Definition: CScroll.h:184
bool preferredSize(int &w, int &h) override
Computes the optimal group size.
static CLayoutClient * creator(const xdoc::SNode &node)
Creates a widget based on the XML node information.
void resize(int x, int y, int w, int h) override
Resizes the group and inside widgets.
CScroll(const char *label=0, int layoutSize=10, CLayoutAlign layoutAlign=CLayoutAlign::TOP)
Constructor in SPTK style.
Definition: String.h:49
CScrollbarMode
Different modes for scrollbars.
Definition: CScroll.h:46
CLayoutAlign
Definition: CLayoutClient.h:44
@ TOP
Align to the right.

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