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.
tab_control.h
Go to the documentation of this file.
1 #pragma once
5 #include "control.h"
6 #include "image_list.h"
7 #include "tab_alignment.h"
8 
10 namespace xtd {
12  namespace forms {
14  class tab_page;
16 
26  class forms_export_ tab_control : public control {
27  public:
29  tab_control();
30 
33  virtual tab_alignment alignment() const {return alignment_;}
37  virtual tab_control& alignment(tab_alignment alignment);
38 
39  drawing::size default_size() const override {return {200, 100};}
40 
44  virtual const forms::image_list& image_list() const {return image_list_;}
45  /*
49  virtual forms::image_list& image_list() {return image_list_;}
50  */
55  virtual tab_control& image_list(const forms::image_list& value);
56 
59  virtual size_t selected_index() const {return selected_index_;}
63  virtual tab_control& selected_index(size_t selected_index);
64 
68  virtual control_collection& tab_pages() {return controls();}
72  virtual const control_collection& tab_pages() const {return controls();}
73 
77 
79  static const size_t npos = std::numeric_limits<size_t>::max();
80 
81  protected:
82  forms::create_params create_params() const override;
83 
84  drawing::size measure_control() const override;
85 
86  void on_control_added(const control_event_args &e) override;
87  void on_control_removed(const control_event_args &e) override;
88 
89  void on_handle_created(const event_args& e) override;
90 
93  virtual void on_selected_index_changed(const event_args& e) {selected_index_changed(*this, e);}
94 
95  void wnd_proc(message& message) override;
96 
98  virtual void wm_reflect_command(message& message);
99 
100  friend class tab_page;
101  size_t get_child_index(intptr_t page) {
102  for (size_t index = 0;index < controls().size(); ++index)
103  if (controls()[index].get().handle() == page) return index;
104  return npos;
105  }
106  tab_alignment alignment_ = tab_alignment::top;
107  forms::image_list image_list_;
108  size_t selected_index_ = npos;
110  };
111  }
112 }
Provides methods to manage a collection of xtd::drawing::image objects. This class cannot be inherite...
Definition: image_list.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
tab_alignment
Specifies the locations of the tabs in a tab control.
Definition: tab_alignment.h:18
Represents a collection of controls.
Definition: control.h:134
Stores an ordered pair of integers, which specify a height and width.
Definition: size.h:25
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
virtual tab_alignment alignment() const
Gets the area of the control (for example, along the top) where the tabs are aligned.
Definition: tab_control.h:33
virtual void on_selected_index_changed(const event_args &e)
Raises the tab_control::selected_index_changed event.
Definition: tab_control.h:93
The tabs are located across the top of the control.
Represents an event.
Definition: event.h:21
virtual const control_collection & tab_pages() const
Gets the collection of tab pages in this tab control.
Definition: tab_control.h:72
Contains xtd::forms::image_list component.
virtual control_collection & tab_pages()
Gets the collection of tab pages in this tab control.
Definition: tab_control.h:68
drawing::size default_size() const override
Gets the default size of the control.
Definition: tab_control.h:39
Manages a related set of tab pages.
Definition: tab_control.h:26
Implements a Windows message.
Definition: message.h:25
Defines the base class for controls, which are components with visual representation.
Definition: control.h:68
Represents a single tab page in a tab_control.
Definition: tab_page.h:23
Contains xtd::forms::tab_alignment enum class.
event< tab_control, event_handler > selected_index_changed
Occurs when the selected_index property has changed.
Definition: tab_control.h:76
Contains xtd::forms::control control.
Provides data for the control_added and control_removed events.
Definition: control_event_args.h:23
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition: about_box.h:13
virtual const forms::image_list & image_list() const
Gets the images to display on the control&#39;s tabs.
Definition: tab_control.h:44
virtual size_t selected_index() const
Gets the index of the currently selected tab page.
Definition: tab_control.h:59