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.
Public Member Functions | Static Public Member Functions | List of all members
xtd::forms::country Class Reference

#include <country.h>

Definition

Represent a country with name, alpha codes, numeric code, emoticon and flag.

Namespace
xtd::forms
Library
xtd.forms
Examples
The following code example demonstrate the use of country component.
#include <xtd/xtd>
using namespace std;
using namespace xtd;
using namespace xtd::drawing;
using namespace xtd::forms;
namespace examples {
class main_form : public form {
public:
static void main() {
application::run(main_form());
}
main_form() {
text("Countries example");
client_size({600, 500});
countries_list_box.parent(*this);
countries_list_box.location({10, 10});
countries_list_box.size({200, 480});
countries_list_box.items().push_back({country.name(), country});
countries_list_box.selected_value_changed += [&] {
country_flag_picture_box.image(bitmap(any_cast<forms::country>(countries_list_box.selected_item().tag()).flag(), {256, 192}));
country_flag_squared_picture_box.image(bitmap(any_cast<forms::country>(countries_list_box.selected_item().tag()).flag_squared(), {128, 128}));
country_emoticon_label.text(any_cast<forms::country>(countries_list_box.selected_item().tag()).emoticon());
country_code_label.text(ustring::format("Codes : {} ({}) / {}", any_cast<forms::country>(countries_list_box.selected_item().tag()).alpha_3_code(), any_cast<forms::country>(countries_list_box.selected_item().tag()).alpha_2_code(), any_cast<forms::country>(countries_list_box.selected_item().tag()).numeric_code()));
};
countries_list_box.selected_index(0);
country_panel.parent(*this);
country_panel.location({220, 10});
country_panel.size({370, 480});
country_panel.border_style(forms::border_style::fixed_3d);
country_panel.back_color(system_colors::window());
country_panel.auto_scroll(true);
country_flag_picture_box.parent(country_panel);
country_flag_picture_box.location({10, 10});
country_flag_picture_box.size({256, 192});
country_flag_squared_picture_box.parent(country_panel);
country_flag_squared_picture_box.location({10, 212});
country_flag_squared_picture_box.size({128, 128});
country_emoticon_label.parent(country_panel);
country_emoticon_label.font({country_emoticon_label.font(), 64});
country_emoticon_label.location({10, 350});
country_emoticon_label.auto_size(true);
country_code_label.parent(country_panel);
country_code_label.location({10, 445});
country_code_label.auto_size(true);
}
private:
list_box countries_list_box;
panel country_panel;
picture_box country_flag_picture_box;
picture_box country_flag_squared_picture_box;
label country_emoticon_label;
label country_code_label;
};
}
startup_(examples::main_form);
Examples:
countries.cpp.

Public Member Functions

virtual const xtd::ustring alpha_2_code () const
 Gets the country alpha 2 code. More...
 
virtual const xtd::ustring alpha_3_code () const
 Gets the country alpha 3 code. More...
 
virtual const xtd::ustring emoticon () const
 Gets the country emoticon. More...
 
virtual const xtd::drawing::image flag () const
 Gets the country flag. More...
 
virtual const xtd::drawing::image flag_squared () const
 Gets the country flag. More...
 
virtual const xtd::ustring name () const
 Gets the country name. More...
 
virtual int numeric_code () const
 Gets the country numeric code. More...
 
virtual xtd::ustring to_string () const noexcept override
 Returns a string containing the name, alpha codes and numeric code of the country. More...
 
- Public Member Functions inherited from xtd::object
 object ()=default
 Create a new instance of the ultimate base class object. More...
 
virtual bool equals (const object &obj) const noexcept
 Determines whether the specified object is equal to the current object. More...
 
virtual size_t get_hash_code () const noexcept
 Serves as a hash function for a particular type. More...
 
template<typename object_t >
std::unique_ptr< object_t > memberwise_clone () const
 Gets the type of the current instance. More...
 

Static Public Member Functions

static const country empty ()
 Get an empty country. More...
 
static country from_alpha_2_code (const xtd::ustring &alpha_2_code)
 Gets a country from alpha 2 code. More...
 
static country from_alpha_3_code (const xtd::ustring &alpha_3_code)
 Gets a country from alpha 3 code. More...
 
static country from_name (const xtd::ustring &name)
 Gets a country from name. More...
 
static country from_numeric_code (int numeric_code)
 Gets a country from numeric code. More...
 
- Static Public Member Functions inherited from xtd::object
static bool equals (const object &object_a, const object &object_b) noexcept
 Determines whether the specified object instances are considered equal. More...
 
static bool reference_equals (const object &object_a, const object &object_b) noexcept
 Determines whether the specified object instances are the same instance. More...
 

Member Function Documentation

◆ alpha_2_code()

virtual const xtd::ustring xtd::forms::country::alpha_2_code ( ) const
inlinevirtual

Gets the country alpha 2 code.

Returns
A string that represent the alpha 2 code.

◆ alpha_3_code()

virtual const xtd::ustring xtd::forms::country::alpha_3_code ( ) const
inlinevirtual

Gets the country alpha 3 code.

Returns
A string that represent the alpha 3 code.

◆ emoticon()

virtual const xtd::ustring xtd::forms::country::emoticon ( ) const
inlinevirtual

Gets the country emoticon.

Returns
A string that represent the emoticon.

◆ empty()

static const country xtd::forms::country::empty ( )
static

Get an empty country.

Returns
An empty country

◆ flag()

virtual const xtd::drawing::image xtd::forms::country::flag ( ) const
virtual

Gets the country flag.

Returns
A xtd::drawing::image that represent the flag of 1024 x 768 pixels.

◆ flag_squared()

virtual const xtd::drawing::image xtd::forms::country::flag_squared ( ) const
virtual

Gets the country flag.

Returns
A xtd::drawing::image that represent the flag of 1024 x 1024 pixels.

◆ from_alpha_2_code()

static country xtd::forms::country::from_alpha_2_code ( const xtd::ustring alpha_2_code)
static

Gets a country from alpha 2 code.

Returns
If exist a xtd::forms::country that represent alpha 2 coded; otherwise xtd::forms::country::empty.

◆ from_alpha_3_code()

static country xtd::forms::country::from_alpha_3_code ( const xtd::ustring alpha_3_code)
static

Gets a country from alpha 3 code.

Returns
If exist a xtd::forms::country that represent alpha 3 coded; otherwise xtd::forms::country::empty.

◆ from_name()

static country xtd::forms::country::from_name ( const xtd::ustring name)
static

Gets a country from name.

Returns
If exist a xtd::forms::country that represent name; otherwise xtd::forms::country::empty.

◆ from_numeric_code()

static country xtd::forms::country::from_numeric_code ( int  numeric_code)
static

Gets a country from numeric code.

Returns
If exist a xtd::forms::country that represent numeric coded; otherwise xtd::forms::country::empty.

◆ name()

virtual const xtd::ustring xtd::forms::country::name ( ) const
inlinevirtual

Gets the country name.

Returns
A string that represent the country.
Examples:
countries.cpp.

◆ numeric_code()

virtual int xtd::forms::country::numeric_code ( ) const
inlinevirtual

Gets the country numeric code.

Returns
A signed-integer that represent the numeric code.

◆ to_string()

virtual xtd::ustring xtd::forms::country::to_string ( ) const
overridevirtualnoexcept

Returns a string containing the name, alpha codes and numeric code of the country.

Returns
A string containing the name, alpha codes and numeric code of the country.

Reimplemented from xtd::object.


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