xtd - Reference Guide  0.1.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
Loading...
Searching...
No Matches
scrollable_control.h
Go to the documentation of this file.
1
4#pragma once
5#include "control.h"
7
9namespace xtd {
11 namespace forms {
19 public:
22 virtual bool auto_scroll() const {return auto_scroll_;}
26 virtual scrollable_control& auto_scroll(bool auto_scroll) {
27 if (auto_scroll_ != auto_scroll) {
28 auto_scroll_ = auto_scroll;
29 recreate_handle();
30 }
31 return *this;
32 }
33
36 drawing::size auto_scroll_margin() const {return auto_scroll_margin_;}
41 if (auto_scroll_margin_ != value) {
42 auto_scroll_margin_ = value;
43 perform_layout();
44 }
45 return *this;
46 }
47
50 drawing::rectangle display_rectangle() const override {return display_rectangle_;}
51
54 virtual bool h_scroll() const {return h_scroll_;}
58 virtual scrollable_control& h_scroll(bool h_scroll) {
59 if (h_scroll_ != h_scroll) {
60 h_scroll_ = h_scroll;
61 recreate_handle();
62 }
63 return *this;
64 }
65
68 virtual bool v_scroll() const {return v_scroll_;}
72 virtual scrollable_control& v_scroll(bool v_scroll) {
73 if (v_scroll_ != v_scroll) {
74 v_scroll_ = v_scroll;
75 recreate_handle();
76 }
77 return *this;
78 }
79
80 protected:
82 scrollable_control() = default;
83
84 forms::create_params create_params() const override;
85
86 void on_layout(const event_args& e) override {
87 control::on_layout(e);
88 if (auto_scroll_) {
89 display_rectangle_ = client_rectangle_;
90 display_rectangle_.height(display_rectangle_.height() - system_information::horizontal_scroll_bar_height());
91 display_rectangle_.width(display_rectangle_.width() - system_information::vertical_scroll_bar_width());
92 for (auto item : controls()) {
93 if (item.get().visible())
94 display_rectangle_ = drawing::rectangle::make_union(display_rectangle_, item.get().bounds());
95 }
96 display_rectangle_.width(display_rectangle_.width() + auto_scroll_margin_.width());
97 display_rectangle_.height(display_rectangle_.height() + auto_scroll_margin_.height());
98 }
99 }
100
102 bool auto_scroll_ = false;
103 bool h_scroll_ = false;
104 bool v_scroll_ = false;
105 drawing::rectangle display_rectangle_;
106 drawing::size auto_scroll_margin_;
108 };
109 }
110}
Stores a set of four integers that represent the location and size of a rectangle.
Definition: rectangle.h:25
Stores an ordered pair of integers, which specify a height and width.
Definition: size.h:25
Represents the base class for classes that contain event data, and provides a value to use for events...
Definition: event_args.h:18
Defines the base class for controls, which are components with visual representation.
Definition: control.h:67
Defines a base class for controls that support auto-scrolling behavior.
Definition: scrollable_control.h:18
virtual scrollable_control & h_scroll(bool h_scroll)
Sets a value indicating whether the horizontal scroll bar is visible.
Definition: scrollable_control.h:58
virtual scrollable_control & v_scroll(bool v_scroll)
Sets a value indicating whether the vertical scroll bar is visible.
Definition: scrollable_control.h:72
scrollable_control()=default
Initialize a new instance of scrollable_control class.
void on_layout(const event_args &e) override
Raises the control::layout event.
Definition: scrollable_control.h:86
forms::create_params create_params() const override
Gets the required creation parameters when the control handle is created.
virtual scrollable_control & auto_scroll(bool auto_scroll)
Sets a value indicating whether the container enables the user to scroll to any controls placed outsi...
Definition: scrollable_control.h:26
drawing::rectangle display_rectangle() const override
Gets the rectangle that represents the virtual display area of the control.
Definition: scrollable_control.h:50
virtual bool v_scroll() const
Gets a value indicating whether the vertical scroll bar is visible.
Definition: scrollable_control.h:68
scrollable_control & auto_scroll_margin(const drawing::size &value)
Sets the size of the auto-scroll margin.
Definition: scrollable_control.h:40
drawing::size auto_scroll_margin() const
Gets the size of the auto-scroll margin.
Definition: scrollable_control.h:36
virtual bool h_scroll() const
Gets a value indicating whether the horizontal scroll bar is visible.
Definition: scrollable_control.h:54
virtual bool auto_scroll() const
Gets a value indicating whether the container enables the user to scroll to any controls placed outsi...
Definition: scrollable_control.h:22
Contains xtd::forms::control control.
#define forms_export_
Define shared library export.
Definition: forms_export.h:13
@ e
The E key.
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition: about_box.h:13
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition: system_report.h:17
Contains xtd::forms::system_information class.