xtd - Reference Guide  0.2.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
split_container.h
Go to the documentation of this file.
1 #pragma once
5 #include "orientation.h"
6 #include "scrollable_control.h"
7 #include "splitter.h"
8 #include "splitter_panel.h"
9 
11 namespace xtd {
13  namespace forms {
23  class forms_export_ split_container : public xtd::forms::scrollable_control {
24  public:
26 
30  set_can_focus(false);
31  size(default_size());
32  controls().push_back_range({panel2_, splitter_, panel1_});
33  arrange_children();
34  }
36 
38 
40  drawing::size default_size() const override {return {150, 100};}
41 
44  virtual xtd::forms::orientation orientation() const {return orientation_;}
49  if (orientation_ != orientation) {
50  orientation_ = orientation;
51  arrange_children();
52  }
53  return *this;
54  }
55 
58  virtual const splitter_panel& panel1() const {return panel1_;};
61  virtual splitter_panel& panel1() {return panel1_;};
62 
65  virtual const splitter_panel& panel2() const {return panel2_;};
68  virtual splitter_panel& panel2() {return panel2_;};
69 
72  virtual int splitter_distance() const {return splitter_distance_;}
76  virtual split_container& splitter_distance(int splitter_distance) {
77  if (splitter_distance_ != splitter_distance) {
78  splitter_distance_ = splitter_distance;
79  if (orientation_ == xtd::forms::orientation::horizontal) panel1_.height(splitter_distance);
80  else panel1_.width(splitter_distance);
81  }
82  return *this;
83  }
84 
87  virtual xtd::forms::splitter_style splitter_style() const {return splitter_.splitter_style();}
92  if (splitter_.splitter_style() != splitter_style) {
93  splitter_.splitter_style(splitter_style);
94  }
95  return *this;
96  }
97 
101  virtual int splitter_width() const {return splitter_width_;}
106  virtual split_container& splitter_width(int splitter_width) {
107  if (splitter_width_ != splitter_width) {
108  splitter_width_ = splitter_width;
109  arrange_children();
110  }
111  return *this;
112  }
114 
115  protected:
117 
119  void on_resize(const event_args& e) override {
121  }
123 
124  private:
125  void arrange_children() {
126  if (orientation_ == xtd::forms::orientation::vertical) {
127  panel1_.dock(xtd::forms::dock_style::left);
128  panel1_.width(splitter_distance_);
129  splitter_.dock(xtd::forms::dock_style::left);
130  splitter_.width(splitter_width_);
131  } else {
132  panel1_.dock(xtd::forms::dock_style::top);
133  panel1_.height(splitter_distance_);
134  splitter_.dock(xtd::forms::dock_style::top);
135  splitter_.height(splitter_width_);
136  }
137  panel2_.dock(xtd::forms::dock_style::fill);
138  }
139 
141  splitter_panel panel1_;
142  splitter splitter_;
143  splitter_panel panel2_;
144  int splitter_distance_ = 50;
145  //int splitter_increment_ = 1;
146  int splitter_width_ = 4;
147  };
148  }
149 }
The control or element is oriented horizontally.
Represents the base class for classes that contain event data, and provides a value to use for events...
Definition: event_args.h:18
Contains xtd::forms::orientation enum class.
split_container()
Initializes a new instance of the split_container class.
Definition: split_container.h:29
virtual const splitter_panel & panel2() const
Gets the right or bottom panel of the splitter_panel, depending on orientation.
Definition: split_container.h:65
Stores an ordered pair of integers, which specify a height and width.
Definition: size.h:25
Creates a panel that is associated with a split_container.
Definition: splitter_panel.h:23
virtual splitter_panel & panel1()
Gets the left or top panel of the splitter_panel, depending on orientation.
Definition: split_container.h:61
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
virtual int32_t height() const
Gets the height of the control.
All the control's edges are docked to the all edges of its containing control and sized appropriately...
virtual const splitter_panel & panel1() const
Gets the left or top panel of the splitter_panel, depending on orientation.
Definition: split_container.h:58
Contains xtd::forms::scrollable_control control.
orientation
Specifies the orientation of controls or elements of controls.
Definition: orientation.h:18
virtual int splitter_distance() const
Gets the location of the splitter, in pixels, from the left or top edge of the split_container.
Definition: split_container.h:72
Represents a control consisting of a movable bar that divides a container's display area into two res...
Definition: split_container.h:23
Specifies that both the width and height property values of the control are defined.
Defines a base class for controls that support auto-scrolling behavior.
Definition: scrollable_control.h:18
Contains xtd::forms::splitter control.
virtual int splitter_width() const
Gets or sets the width of the splitter in pixels.
Definition: split_container.h:101
virtual split_container & splitter_distance(int splitter_distance)
Sets the location of the splitter, in pixels, from the left or top edge of the split_container.
Definition: split_container.h:76
virtual xtd::forms::orientation orientation() const
Gets a value indicating the horizontal or vertical orientation of the split_container panels...
Definition: split_container.h:44
drawing::size default_size() const override
Gets the default size of the control.
Definition: split_container.h:40
Contains xtd::forms::splitter_panel container.
virtual split_container & splitter_width(int splitter_width)
Gets or sets the width of the splitter in pixels.
Definition: split_container.h:106
virtual xtd::forms::splitter_style splitter_style() const
Gets the style of the splitter.
Definition: split_container.h:87
The control's left edge is docked to the left edge of its containing control.
splitter_style
Represent splitter style used by splitter control.
Definition: splitter_style.h:17
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition: about_box.h:13
The control's top edge is docked to the top of its containing control.
virtual void on_resize(const event_args &e)
Raises the control::resize event.
virtual split_container & orientation(xtd::forms::orientation orientation)
Sets a value indicating the horizontal or vertical orientation of the split_container panels...
Definition: split_container.h:48
void on_resize(const event_args &e) override
Raises the control::resize event.
Definition: split_container.h:119
virtual splitter_panel & panel2()
Gets the right or bottom panel of the splitter_panel, depending on orientation.
Definition: split_container.h:68
virtual split_container & splitter_style(xtd::forms::splitter_style splitter_style)
Sets the style of the splitter.
Definition: split_container.h:91
Represents a splitter control that enables the user to resize docked controls.
Definition: splitter.h:22
The control or element is oriented vertically.