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.
track_bar.h
Go to the documentation of this file.
1 #pragma once
5 #include "control.h"
6 #include "orientation.h"
7 #include "tick_style.h"
8 
10 namespace xtd {
12  namespace forms {
25  class forms_export_ track_bar : public control {
26  public:
28 
32  track_bar();
34 
36 
40  drawing::size default_size() const override {return {104, 45};}
41 
45  virtual int32_t large_change() {return large_change_;}
50  virtual track_bar& large_change(int32_t large_change);
51 
54  virtual int32_t maximum() {return maximum_;}
59  virtual track_bar& maximum(int32_t maximum);
60 
63  virtual int32_t minimum() {return minimum_;}
68  virtual track_bar& minimum(int32_t minimum);
69 
72  virtual forms::orientation orientation() const {return orientation_;}
78 
83  virtual int32_t small_change() {return small_change_;}
89  virtual track_bar& small_change(int32_t small_change);
90 
94  virtual int32_t tick_frequency() {return tick_frequency_;}
99  virtual track_bar& tick_frequency(int32_t tick_frequency);
100 
104  virtual forms::tick_style tick_style() {return tick_style_;}
110 
114  virtual int32_t value() {return value_;}
119  virtual track_bar& value(int32_t value);
121 
123 
129  void set_range(int min_value, int max_value) {
130  minimum(min_value);
131  maximum(min_value > max_value ? min_value : max_value);
132  }
133 
137  xtd::ustring to_string() const noexcept override {return ustring::format("{}, minimum: {}, maximum: {}, value: {}", ustring::full_class_name(*this), minimum_, maximum_, value_);}
139 
141 
147 
153 
154  protected:
156 
160  forms::create_params create_params() const override;
161 
162  drawing::size measure_control() const override;
163 
166  void on_handle_created(const event_args& e) override;
167 
175  virtual void on_scroll(const event_args& e);
176 
179  virtual void on_value_changed(const event_args& e);
180 
187  void set_bounds_core(int32_t x, int32_t y, int32_t width, int32_t height, bounds_specified specified) override {
188  control::set_bounds_core(x, y, width, height, specified);
189  if ((specified & bounds_specified::width) == bounds_specified::width || (specified & bounds_specified::height) == bounds_specified::height)
190  recreate_handle();
191  }
192 
196  void set_client_size_core(int32_t width, int32_t height) override {
197  control::set_client_size_core(width, height);
198  recreate_handle();
199  }
200 
204  void wnd_proc(message& message) override;
206 
207  private:
208  void wm_scroll(message& message);
209 
210  int32_t large_change_ = 5;
211  int32_t maximum_ = 10;
212  int32_t minimum_ = 0;
214  int32_t small_change_ = 1;
215  int32_t tick_frequency_ = 1;
217  int32_t value_ = 0;
218  };
219  }
220 }
virtual forms::tick_style tick_style()
Gets a value indicating how to display the tick marks on the track bar.
Definition: track_bar.h:104
The control or element is oriented horizontally.
void set_range(int min_value, int max_value)
Sets the minimum and maximum values for a xtd::forms::track_bar.
Definition: track_bar.h:129
virtual int32_t large_change()
Gets a value to be added to or subtracted from the value property when the scroll box is moved a larg...
Definition: track_bar.h:45
virtual int32_t value()
Gets a numeric value that represents the current position of the scroll box on the track bar...
Definition: track_bar.h:114
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.
Stores an ordered pair of integers, which specify a height and width.
Definition: size.h:25
Specifies that the top edge of the control is defined.
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
Starts at the lower-right corner of the screen.
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:48
Specifies that the left edge of the control is defined.
virtual int32_t minimum()
Gets the lower limit of the range this track_bar is working with.
Definition: track_bar.h:63
virtual forms::orientation orientation() const
Gets a value indicating the horizontal or vertical orientation of the track bar.
Definition: track_bar.h:72
orientation
Specifies the orientation of controls or elements of controls.
Definition: orientation.h:18
virtual void set_client_size_core(int32_t width, int32_t height)
Sets the size of the client area of the control.
Specifies that the height of the control is defined.
void set_bounds_core(int32_t x, int32_t y, int32_t width, int32_t height, bounds_specified specified) override
Performs the work of setting the specified bounds of this control.
Definition: track_bar.h:187
Represents an event.
Definition: event.h:21
drawing::size default_size() const override
Gets the default size of the control.
Definition: track_bar.h:40
tick_style
Specifies the location of tick marks in a track_bar control.
Definition: tick_style.h:18
virtual int32_t tick_frequency()
Gets a value that specifies the delta between ticks drawn on the control.
Definition: track_bar.h:94
xtd::ustring to_string() const noexcept override
Returns a string that represents the track_bar control.
Definition: track_bar.h:137
virtual int32_t small_change()
Gets he value added to or subtracted from the Value property when the scroll box is moved a small dis...
Definition: track_bar.h:83
Specifies that the width of the control is defined.
virtual int32_t maximum()
Gets the upper limit of the range this track_bar is working with.
Definition: track_bar.h:54
Implements a Windows message.
Definition: message.h:25
Defines the base class for controls, which are components with visual representation.
Definition: control.h:68
event< track_bar, event_handler > value_changed
Occurs when the value property of a track bar changes, either by movement of the scroll box or by man...
Definition: track_bar.h:151
static ustring full_class_name()
Gets the fully qualified class name of the objec_t, including the namespace of the objec_t...
Definition: ustring.h:442
static ustring format(const ustring &fmt, args_t &&... args)
Writes the text representation of the specified arguments list, to string using the specified format ...
Definition: ustring.h:700
Contains xtd::forms::control control.
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition: about_box.h:13
bounds_specified
Specifies the bounds of the control to use when defining a control&#39;s size and position. This enumeration has a flags attribute that allows a bitwise combination of its member values.
Definition: bounds_specified.h:18
virtual void set_bounds_core(int32_t x, int32_t y, int32_t width, int32_t height, bounds_specified specified)
Performs the work of setting the specified bounds of this control.
void set_client_size_core(int32_t width, int32_t height) override
Sets the size of the client area of the control.
Definition: track_bar.h:196
event< track_bar, event_handler > scroll
Occurs when either a mouse or keyboard action moves the scroll box.
Definition: track_bar.h:146
Contains xtd::forms::tick_style enum class.
Represents a standard Windows track bar.
Definition: track_bar.h:25