SDL Window Engine  20200905
swe_wingui_scroll.h
1 /***************************************************************************
2  * Copyright (C) 2017 by SWE team <sdl.window.engine@gmail.com> *
3  * *
4  * Part of the SWE: SDL Window Engine: *
5  * https://github.com/AndreyBarmaley/sdl-window-engine *
6  * *
7  * This program is free software; you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation; either version 3 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * This program is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU General Public License *
18  * along with this program; if not, write to the *
19  * Free Software Foundation, Inc., *
20  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21  ***************************************************************************/
22 
23 #ifndef _SWE_GUI_SCROLL_
24 #define _SWE_GUI_SCROLL_
25 
26 #include "swe_wingui.h"
27 
29 namespace SWE
30 {
31  class ListWidget;
32 
33  // ScrollBar emit signals: Signal::ScrollBarMoved
34  class ScrollBar : public Window
35  {
36  TexturePos txcur;
37 
38  protected:
39  void signalReceive(int, const SignalMember*) override;
40  void windowMoveEvent(const Point &) override;
41  void windowResizeEvent(const Size &) override;
42  bool scrollUpEvent(void) override;
43  bool scrollDownEvent(void) override;
44  bool mousePressEvent(const ButtonEvent &) override;
45  bool mouseReleaseEvent(const ButtonEvent &) override;
46  bool mouseMotionEvent(const Point &, u32 buttons) override;
47 
48  public:
49  ScrollBar(bool, ListWidget &);
50  ScrollBar(const Point &, const Size &, bool vertical, ListWidget &);
51 
52  bool isAreaPoint(const Point &) const override;
53  bool isVerticalOrientation(void) const;
54 
55  const TexturePos & textureCursor(void) const;
56  void setTextureCursor(const Texture &);
57 
58  virtual Rect scrollArea(void) const;
59  void renderWindow(void) override;
60 
61  const char* className(void) const override { return "SWE::ScrollBar"; }
62 #ifdef SWE_WITH_JSON
63  JsonObject toJson(void) const override
64  {
65  JsonObject res = Window::toJson();
66  res.addObject("cursor", txcur.toJson());
67  return res;
68  }
69 #endif
70  static int transformToListTopRow(const ScrollBar &, const ListWidget &);
71  static Point transformToScrollCursor(const ListWidget &, const ScrollBar &);
72  static Point transformToScrollCursor(const Point &, const ScrollBar &);
73  };
74 
75 
76 } // SWE
77 #endif
Definition: swe_surface.h:154
класс объектов сцены DisplayScene, с возможностью отправки/получения сигналов
Definition: swe_events.h:56
Definition: swe_wingui_scroll.h:34
пространство SWE.
Definition: swe_binarybuf.cpp:30
класс прямоугольника
Definition: swe_rect.h:144
класс точки с двумя координатами
Definition: swe_rect.h:72
void signalReceive(int, const SignalMember *) override
метод получатель, вызывается при signalEmit со стороны отправителя
Definition: swe_wingui_scroll.cpp:171
Definition: swe_surface.h:210
event класс кнопки мыши
Definition: swe_events.h:145
класс двухмерной размерности
Definition: swe_rect.h:36
Definition: swe_wingui_list.h:61
базовый класс графических объектов сцены DisplayScene.
Definition: swe_window.h:57
const char * className(void) const override
идентификацинная метка класса
Definition: swe_wingui_scroll.h:61