FDOSTUI
FreeDOS Text User Interface
scroller.hpp
Go to the documentation of this file.
1 /*
2  SCROLLER.HPP
3 
4  License CC0 PUBLIC DOMAIN
5 
6  To the extent possible under law, Mark J. Olesen has waived all copyright
7  and related or neighboring rights to FDOSTUI Library. This work is published
8  from: United States.
9 */
10 #ifndef __scroller_hpp__
11 
12 #include "group.hpp"
13 #include "scrllbar.hpp"
14 
15 class scroller : public group
16 {
17 
18 public:
19 
20  scroller(
21  int const i_pos_x,
22  int const i_pos_y,
23  unsigned int const i_len_x,
24  unsigned int const i_len_y);
25 
26  virtual
27  ~scroller();
28 
29  virtual int
30  add(
31  widget*const i_widget);
32 
33  virtual void
34  draw() const;
35 
36  virtual enum event_response
37  event_key(
38  struct event_key const& i_event);
39 
40  virtual enum event_response
42  struct event_mouse const& i_event);
43 
44  int
45  get_scroll_pos_x() const;
46 
47  int
48  get_scroll_pos_y() const;
49 
50  virtual void
51  set_parent(
52  group*const i_parent);
53 
54 protected:
55 
60 
61  void
63 
64 private:
65 
66  scroller();
67 
68  scroller(
69  const scroller&);
70 
71  scroller&
72  operator=(scroller const&);
73 
74  static void
76  widget const* i_widget,
77  void* io_user_data);
78 
79  static void
81  widget const* i_widget,
82  void* io_user_data);
83 
84 public:
85 
86  void
88 
89 };
90 
91 inline int
93  widget*const i_widget)
94 {
95  int l_exit;
96 
97  l_exit= group::add(i_widget);
98 
99  if (0 == l_exit)
100  {
102  }
103 
104  return l_exit;
105 }
106 
107 inline void
109  group*const i_parent)
110 {
111  if (this != i_parent)
112  {
113  group::set_parent(i_parent);
114  m_horizontal.set_parent(i_parent);
115  m_vertical.set_parent(i_parent);
116  }
117 }
118 
119 inline int
121 {
122  return m_scroll_pos_x;
123 }
124 
125 inline int
127 {
128  return m_scroll_pos_y;
129 }
130 
131 #define __scroller_hpp__
132 #endif
void set_scroll_bounds()
configure scrollbar boundaries
Definition: scroller.cpp:251
scrollbar m_vertical
Definition: scroller.hpp:57
Allows the user to view a small portion of a large area via scrolling.
Definition: scroller.hpp:15
A slider widget with navigational arrow buttons at each end.
Definition: scrllbar.hpp:14
contains scrollbar class
static void vertical_cb(widget const *i_widget, void *io_user_data)
vertical scrollbar callback
Definition: scroller.cpp:30
base class for all derived widgets
Definition: widget.hpp:19
scrollbar m_horizontal
Definition: scroller.hpp:56
virtual void set_parent(group *const i_parent)
set parent widget
Definition: scroller.hpp:108
int m_scroll_pos_x
Definition: scroller.hpp:58
container to hold a collection of widgets
Definition: group.hpp:15
virtual void set_parent(group *const i_parent)
sets the parent group of the widget
Definition: widget.hpp:358
int m_scroll_pos_y
Definition: scroller.hpp:59
event_response
response
Definition: event.h:14
virtual void draw() const
draws the widget
Definition: scroller.cpp:72
int get_scroll_pos_y() const
get scroll (vertical) position in y direction
Definition: scroller.hpp:126
virtual int add(widget *const i_widget)
add child widget
Definition: group.cpp:72
int get_scroll_pos_x() const
get scroll (horizontal) position in x direction
Definition: scroller.hpp:120
static void horizontal_cb(widget const *i_widget, void *io_user_data)
horizontal scrollbar callback
Definition: scroller.cpp:17
void scroll_internal()
internal scroll handler, called when scrollbar changes.
Definition: scroller.cpp:182
contains group class
virtual enum event_response event_mouse(struct event_mouse const &i_event)
handle mouse event
Definition: scroller.cpp:149
virtual int add(widget *const i_widget)
add widget to the scroll bar group
Definition: scroller.hpp:92
virtual ~scroller()
destructor
Definition: scroller.cpp:66
container for a mouse event
Definition: event.h:37
virtual enum event_response event_key(struct event_key const &i_event)
handle key event
Definition: scroller.cpp:97
container for a keyboard event
Definition: event.h:23