xtd 1.0.0
Loading...
Searching...
No Matches
xtd::forms::control::control_collection Class Reference
Inheritance diagram for xtd::forms::control::control_collection:
xtd::forms::layout::arranged_element_collection< control_ref > xtd::object

Definition

Represents a collection of controls.

Public Aliases

using base
 Represents the base type of the collection.

Public Constructors

 control_collection ()=default
 Creates a new object xtd::forms::control::control_collection with specified allocator (optional).

Operators

value_type operator[] (const xtd::string &name) const
 Gets the first xtd::forms::control::control_collection in the list with the specified name.
value_type operator[] (const xtd::string &name)
 Gets the first xtd::forms::control::control_collection in the list with the specified name.

Public Methods

void add (const control_ref &value) override
template<typename control_t>
void add (control_t &value)
template<typename control_t, typename ... args_t>
control_t & emplace_front (args_t &&...args)
 Creates and inserts specified control at specified position.
template<typename control_t, typename ... args_t>
control_t & emplace_at (xtd::usize index, args_t &&...args)
 Creates and inserts specified control at specified position.
template<typename control_t, typename ... args_t>
control_t & emplace_back (args_t &&...args)
 Creates and adds a control to the end.
void insert (xtd::usize index, const control_ref &value) override
 Inserts specified element at specified index.
template<typename control_t>
void insert (xtd::usize index, control_t &value)

Public Deprecated Methods

template<typename control_t>
void push_back (control_t &value)

Protected Methods

void on_item_removed (xtd::usize index, control_ref &item) override
 Raises the xtd::forms::layout::arranged_element_collection::item_removed event.

Additional Inherited Members

using base_type
 Represents the list base type.
using const_base_type
 Represents the list base type.
using size_type
 Represents the list size type (usually xtd::usize).
using reference
 Represents the reference of list value type.
using const_reference
 Represents the const reference of list value type.
using pointer
 Represents the pointer of list value type.
using const_pointer
 Represents the const pointer of list value type.
using read_only_collection
 Represents the read only collection of of list.
using reverse_iterator
 Represents the reverse iterator type of the collection.
using const_reverse_iterator
 Represents the const reverse iterator type of the collection.
event< arranged_element_collection, delegate< void(xtd::usize, control_ref &item)> > item_added
 Occurs when an item is added to the collection.
event< arranged_element_collection, delegate< void(xtd::usize, control_ref &item)> > item_updated
 Occurs when an item is updated in the collection.
event< arranged_element_collection, delegate< void(xtd::usize, control_ref &item)> > item_removed
 Occurs when an item is removed from the collection.
static constexpr xtd::usize npos
 Represents a value that is not a valid position in a collection.
static constexpr xtd::usize bpos
 Represents the index of the first valid element in a collection.
static constexpr xtd::usize epos
 Represents the index of the last valid element in a collection.
 arranged_element_collection ()=default
 Initializes a new instance of the xtd::forms::layout::arranged_element_collection class that is empty.
 arranged_element_collection (size_type capacity)
 Constructs the container with specified count default-inserted instances of type_t. No copies are made.
 arranged_element_collection (const xtd::collections::generic::ienumerable< control_ref > &collection)
 Initializes a new instance of the xtd::forms::layout::arranged_element_collection <type_t> class that contains elements copied from the specified collection and has sufficient capacity to accommodate the number of elements copied.
 arranged_element_collection (const arranged_element_collection &collection)
 Default copy constructor with specified list.
 arranged_element_collection (arranged_element_collection &&collection)
 Move constructor with specified list.
 arranged_element_collection (const base_type &collection)
 Copy constructor with specified base type list.
 arranged_element_collection (base_type &&collection)
 Move constructor with specified base type list.
 arranged_element_collection (std::initializer_list< control_ref > items)
 Constructs the container with the contents of the specified initializer list, and allocator.
 arranged_element_collection (input_iterator_t first, input_iterator_t last)
 Constructs the container with the contents of the range [first, last).
auto capacity () const noexcept -> size_type
 Gets the total number of elements the internal data structure can hold without resizing.
auto capacity (size_type value) -> void
 Sets the total number of elements the internal data structure can hold without resizing.
auto count () const noexcept -> size_type override
 Gets the number of elements contained in the xtd::forms::layout::arranged_element_collection <type_t>.
auto data () -> pointer
 Direct access to the underlying array.
auto data () const -> const_pointer
 Direct access to the underlying array.
const auto & items () const
 Returns the underlying base type items.
auto & items ()
 Returns the underlying base type items.
virtual auto sorted () const noexcept -> bool
 Checks whether the container is sorted.
virtual auto sorted (bool value) -> arranged_element_collection &
 Sets the container is sorted.
auto add (const control_ref &item) -> void override
 Adds an item to the xtd::forms::layout::arranged_element_collection <type_t>.
virtual auto add (control_ref &&item) -> void
 Adds an item to the xtd::forms::layout::arranged_element_collection <type_t>.
virtual auto add_range (const arranged_element_collection &collection) -> void
 Adds elements to the end.
virtual auto add_range (const std::vector< control_ref > &collection) -> void
 Adds elements to the end.
virtual auto add_range (const std::initializer_list< control_ref > &collection) -> void
 Adds elements to the end.
auto add_range (collection_t &&collection) -> void
 Adds elements to the end.
auto add_range (const collection_t &collection) -> void
 Adds elements to the end.
auto clear () -> void override
 Removes all items from the xtd::forms::layout::arranged_element_collection <type_t>.
auto contains (const control_ref &item) const noexcept -> bool override
 Determines whether the xtd::forms::layout::arranged_element_collection <type_t> contains a specific value.
auto copy_to (xtd::array< control_ref > &array, xtd::usize array_index) const -> void override
 Copies the elements of the xtd::forms::layout::arranged_element_collection <type_t> to an xtd::array, starting at a particular xtd::array index.
auto get_enumerator () const noexcept -> xtd::collections::generic::enumerator< control_ref > override
 Returns an enumerator that iterates through the xtd::forms::layout::arranged_element_collection <type_t>.
virtual auto sort () -> arranged_element_collection &
 Sorts the content.
auto remove (const control_ref &item) -> bool override
 Removes the first occurrence of a specific object from the xtd::forms::layout::arranged_element_collection <type_t>.
virtual auto remove_at (xtd::usize index) -> void
 Erases element at specified index.
auto reverse () -> arranged_element_collection &
 Reverses the order of the elements in the entire xtd::collections::generic::list <type_t>.
auto reverse (size_type index, size_type count) -> arranged_element_collection &
 Reverses the order of the elements in the specified range.
auto to_array () const noexcept -> xtd::array< control_ref >
 Gets an array with the elements of the container.
auto operator= (const arranged_element_collection &other) -> arranged_element_collection &
 Copy assignment operator. Replaces the contents with a copy of the contents of other.
auto operator= (arranged_element_collection &&other) noexcept -> arranged_element_collection &
 Move assignment operator. Replaces the contents with those of other using move semantics (i.e. the data in other is moved from other into this container). other is in a valid but unspecified state afterwards.
auto operator= (const std::initializer_list< control_ref > &items) -> arranged_element_collection &
 Replaces the contents with those identified by initializer list ilist.
auto operator[] (size_type index) -> value_type &
 Access specified element.
auto operator[] (size_type index) const -> const value_type &
 Access specified element.
 operator const_base_type & () const noexcept
 Returns a reference to the underlying base type.
 operator base_type & () noexcept
 Returns a reference to the underlying base type.
auto operator== (const arranged_element_collection &value) const -> bool
auto operator!= (const arranged_element_collection &value) const -> bool
auto max_size () const noexcept -> size_type
 Returns the maximum possible number of elements.
auto at (size_type pos) -> reference
 Access specified element with bounds checking.
auto at (size_type pos) const -> const_reference
 Access specified element with bounds checking.
auto back () -> reference
 Access the last element.
auto back () const -> const_reference
 Access the last element.
auto crbegin () const noexcept -> const_reverse_iterator
 Returns a reverse iterator to the end.
auto crend () const noexcept -> const_reverse_iterator
 Returns a reverse iterator to the end.
auto front () -> reference
 Access the first element.
auto front () const -> const_reference
 Access the first element.
auto get_allocator () const noexcept
 Returns the associated allocator.
auto emplace (xtd::collections::generic::list< value_type >::const_iterator pos, args_t &&... args) -> void
 Inserts specified element at specified position.
auto emplace_back (args_t &&... args) -> void
 Adds an element to the end.
auto erase (xtd::collections::generic::list< value_type >::iterator pos)
 Erases element at specified position.
auto erase (xtd::collections::generic::list< value_type >::const_iterator pos)
 Erases element at specified position.
auto erase (xtd::collections::generic::list< value_type >::iterator first, xtd::collections::generic::list< value_type >::iterator last)
 Erases elements at specified range.
auto erase (xtd::collections::generic::list< value_type >::const_iterator first, xtd::collections::generic::list< value_type >::const_iterator last)
 Erases elements at specified range.
auto erase_at (xtd::usize index) -> void
 Erases element at specified index.
auto insert (xtd::collections::generic::list< value_type >::const_iterator pos, const control_ref &value)
 Inserts specified element at specified position.
auto insert (xtd::collections::generic::list< value_type >::const_iterator pos, control_ref &&value)
 Inserts specified element at specified position.
auto insert_at (xtd::usize index, const control_ref &value) -> void
 Inserts specified element at specified index.
auto pop_back () -> void
 Removes the last element of the container.
auto push_back (const control_ref &item) -> void
 Adds an element to the end.
auto push_back (control_ref &&item) -> void
 Adds an element to the end.
auto push_back_range (const arranged_element_collection &collection) -> void
 Adds elements to the end.
auto push_back_range (const std::vector< control_ref > &collection) -> void
 Adds elements to the end.
auto push_back_range (const std::initializer_list< control_ref > &collection) -> void
 Adds elements to the end.
auto push_back_range (collection_t &&collection) -> void
 Adds elements to the end.
auto push_back_range (iterator_t begin, iterator_t end) -> void
 Adds elements to the end.
auto to_vector () const noexcept -> std::vector< control_ref >
 Gets an array with the elements of the container.
auto rbegin () noexcept
 Returns a reverse iterator to the end.
auto rbegin () const noexcept
 Returns a reverse iterator to the end.
auto rend () noexcept
 Returns a reverse iterator to the end.
auto rend () const noexcept
 Returns a reverse iterator to the end.
auto reserve (size_type size) -> void
 Reserves storage.
auto shrink_to_fit () -> void
 Reduces memory usage by freeing unused memory.
 object ()=default
 Create a new instance of the ultimate base class object.
virtual auto equals (const object &obj) const noexcept -> bool
 Determines whether the specified object is equal to the current object.
virtual auto get_hash_code () const noexcept -> xtd::usize
 Serves as a hash function for a particular type.
virtual auto get_type () const noexcept -> type_object
 Gets the type of the current instance.
template<typename object_t>
auto memberwise_clone () const -> xtd::unique_ptr_object< object_t >
 Creates a shallow copy of the current object.
virtual auto to_string () const -> xtd::string
 Returns a xtd::string that represents the current object.
template<typename object_a_t, typename object_b_t>
static auto equals (const object_a_t &object_a, const object_b_t &object_b) noexcept -> bool
 Determines whether the specified object instances are considered equal.
template<typename object_a_t, typename object_b_t>
static auto reference_equals (const object_a_t &object_a, const object_b_t &object_b) noexcept -> bool
 Determines whether the specified object instances are the same instance.
virtual auto on_item_added (xtd::usize index, control_ref &item) -> void
 Raises the xtd::forms::layout::arranged_element_collection::item_added event.
virtual auto on_item_updated (xtd::usize index, control_ref &item) -> void
 Raises the xtd::forms::layout::arranged_element_collection::item_updated event.

Member Typedef Documentation

◆ base

Represents the base type of the collection.

Constructor & Destructor Documentation

◆ control_collection()

xtd::forms::control::control_collection::control_collection ( )
explicitdefault

Creates a new object xtd::forms::control::control_collection with specified allocator (optional).

Remarks
If allocator not specified, the std::allocator<value_type> is used.

Member Function Documentation

◆ operator[]() [1/2]

value_type xtd::forms::control::control_collection::operator[] ( const xtd::string & name) const

Gets the first xtd::forms::control::control_collection in the list with the specified name.

Parameters
nameThe name of the xtd::forms::control to get from the list.
Returns
The first xtd::forms::control in the list with the given Name. This item returns optional with no value if no xtd::forms::control with the given name can be found.
Remarks
The operator [] property is case-sensitive when searching for names. That is, if two controls exist with the names "Lname" and "lname", operator [] property will find only the xtd::forms::control with the xtd::forms::control::name() that you specify, not both.

◆ operator[]() [2/2]

value_type xtd::forms::control::control_collection::operator[] ( const xtd::string & name)

Gets the first xtd::forms::control::control_collection in the list with the specified name.

Parameters
nameThe name of the xtd::forms::control to get from the list.
Returns
The first xtd::forms::control in the list with the given Name. This item returns optional with no value if no xtd::forms::control with the given name can be found.
Remarks
The operator [] property is case-sensitive when searching for names. That is, if two controls exist with the names "Lname" and "lname", operator [] property will find only the xtd::forms::control with the xtd::forms::control::name() that you specify, not both.

◆ emplace_front()

template<typename control_t, typename ... args_t>
control_t & xtd::forms::control::control_collection::emplace_front ( args_t &&... args)
inline

Creates and inserts specified control at specified position.

Parameters
posThe iterator before which the content will be inserted. pos may be the xtd::forms::control::control_collection::end iterator.
argsThe arguments to forward to the create method of the control
Returns
A reference to the created control.
Remarks
The control will be destroyed automatically when the control no longer has a parent.
For creation and insertion, this method uses the xtd::forms::control::create methods of the various controls.
Examples
The folowing example demonstartes the use of xtd::forms::control::control_collection::emplace, xtd::forms::control::control_collection::emplace_at and xtd::forms::control::control_collection::emplace_back methods.
#include <xtd/xtd>
auto main() -> int {
auto button1_clicked = 0, button2_clicked = 0;
auto form1 = form::create("Emplace example");
form1.controls().emplace_front<button>("Button 1", point{50, 50})
.click += delegate_ {form1.controls()["label1"].get().text(string::format("Button 1 clicked {} times", ++button1_clicked));};
form1.controls().emplace_at<button>(1, "Button 2", point {50, 100}, size {200, 75})
.auto_repeat(true)
.click += delegate_ {form1.controls()["label2"].get().text(string::format("Button 2 clicked {} times", ++button2_clicked));};
form1.controls().emplace_at<label>(2, "Button 1 clicked 0 times", point {50, 200}, size {200, 23}, "label1");
form1.controls().emplace_back<label>("Button 2 clicked 0 times", point {50, 230}, size {200, 23}, "label2");
application::run(form1);
}
Represents a Windows button control.
Definition button.hpp:49
event< control, event_handler > click
Occurs when the xtd::forms::control is clicked.
Definition control.hpp:1471
static form create()
A factory to create an xtd::forms::form.
static auto format(const basic_string< char > &fmt, args_t &&... args) -> basic_string
#define delegate_
The declaration of a delegate type is similar to a method signature. It has a return value and any nu...
Definition delegate.hpp:1018
xtd::forms::style_sheets::control label
The label data allows you to specify the box of a label control.
Definition label.hpp:25
@ point
Specifies a printer's point (1/72 inch) as the unit of measure.
Definition graphics_unit.hpp:25
constexpr auto size() const noexcept -> size_type
Returns the number of elements.
Definition read_only_span.hpp:217

◆ emplace_at()

template<typename control_t, typename ... args_t>
control_t & xtd::forms::control::control_collection::emplace_at ( xtd::usize index,
args_t &&... args )
inline

Creates and inserts specified control at specified position.

Parameters
indexThe index before which the content will be inserted.
argsThe arguments to forward to the create method of the control
Returns
A reference to the created control.
Remarks
The control will be destroyed automatically when the control no longer has a parent.
For creation and insertion, this method uses the xtd::forms::control::create methods of the various controls.
Examples
The folowing example demonstartes the use of xtd::forms::control::control_collection::emplace, xtd::forms::control::control_collection::emplace_at and xtd::forms::control::control_collection::emplace_back methods.
#include <xtd/xtd>
auto main() -> int {
auto button1_clicked = 0, button2_clicked = 0;
auto form1 = form::create("Emplace example");
form1.controls().emplace_front<button>("Button 1", point{50, 50})
.click += delegate_ {form1.controls()["label1"].get().text(string::format("Button 1 clicked {} times", ++button1_clicked));};
form1.controls().emplace_at<button>(1, "Button 2", point {50, 100}, size {200, 75})
.auto_repeat(true)
.click += delegate_ {form1.controls()["label2"].get().text(string::format("Button 2 clicked {} times", ++button2_clicked));};
form1.controls().emplace_at<label>(2, "Button 1 clicked 0 times", point {50, 200}, size {200, 23}, "label1");
form1.controls().emplace_back<label>("Button 2 clicked 0 times", point {50, 230}, size {200, 23}, "label2");
application::run(form1);
}

◆ emplace_back()

template<typename control_t, typename ... args_t>
control_t & xtd::forms::control::control_collection::emplace_back ( args_t &&... args)
inline

Creates and adds a control to the end.

Parameters
argsThe arguments to forward to the create method of the control
Returns
A reference to the created control.
Remarks
The control will be destroyed automatically when the control no longer has a parent.
For creation and insertion, this method uses the xtd::forms::control::create methods of the various controls.
Examples
The folowing example demonstartes the use of xtd::forms::control::control_collection::emplace, xtd::forms::control::control_collection::emplace_at and xtd::forms::control::control_collection::emplace_back methods.
#include <xtd/xtd>
auto main() -> int {
auto button1_clicked = 0, button2_clicked = 0;
auto form1 = form::create("Emplace example");
form1.controls().emplace_front<button>("Button 1", point{50, 50})
.click += delegate_ {form1.controls()["label1"].get().text(string::format("Button 1 clicked {} times", ++button1_clicked));};
form1.controls().emplace_at<button>(1, "Button 2", point {50, 100}, size {200, 75})
.auto_repeat(true)
.click += delegate_ {form1.controls()["label2"].get().text(string::format("Button 2 clicked {} times", ++button2_clicked));};
form1.controls().emplace_at<label>(2, "Button 1 clicked 0 times", point {50, 200}, size {200, 23}, "label1");
form1.controls().emplace_back<label>("Button 2 clicked 0 times", point {50, 230}, size {200, 23}, "label2");
application::run(form1);
}

◆ insert()

void xtd::forms::control::control_collection::insert ( xtd::usize index,
const control_ref & value )
overridevirtual

Inserts specified element at specified index.

Parameters
indexThe index before which the content will be inserted.
valueThe element to insert.

Reimplemented from xtd::forms::layout::arranged_element_collection< control_ref >.

◆ on_item_removed()

void xtd::forms::control::control_collection::on_item_removed ( xtd::usize index,
control_ref & item )
inlineoverrideprotectedvirtual

Raises the xtd::forms::layout::arranged_element_collection::item_removed event.

Parameters
indexThe index of the item.
itemThe item removed.

Reimplemented from xtd::forms::layout::arranged_element_collection< control_ref >.


The documentation for this class was generated from the following file: