xtd 0.2.0
Loading...
Searching...
No Matches
xtd::forms::country Class Reference
Inheritance diagram for xtd::forms::country:
xtd::object xtd::iequatable< country > xtd::interface xtd::equality_operators< type_t, equatable_t >

Definition

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

Header
#include <xtd/forms/country>
Namespace
xtd::forms
Library
xtd.forms
Examples
The following code example demonstrates the use of country component.
#include <xtd/forms/application>
#include <xtd/forms/countries>
#include <xtd/forms/form>
#include <xtd/forms/label>
#include <xtd/forms/list_box>
#include <xtd/forms/picture_box>
#include <xtd/diagnostics/debug>
#include <xtd/drawing/system_colors>
#include <xtd/startup>
using namespace xtd;
using namespace xtd::drawing;
using namespace xtd::forms;
namespace countries_example {
class main_form : public form {
public:
static auto main() {
//locale::global(locale {"fr_FR.utf-8"});
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.anchor(anchor_styles::left | anchor_styles::top | anchor_styles::bottom);
for (auto country : countries::get_countries())
countries_list_box.items().push_back({country.name(), country});
countries_list_box.sorted(true);
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(string::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_item(countries::belgium().name());
country_panel.parent(*this);
country_panel.location({220, 10});
country_panel.size({370, 480});
country_panel.anchor(anchor_styles::left | anchor_styles::top | anchor_styles::right | anchor_styles::bottom);
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.flat_style(xtd::forms::flat_style::system);
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_(countries_example::main_form::main);
Encapsulates a GDI+ bitmap, which consists of the pixel data for a graphics image and its attributes....
Definition bitmap.h:26
Provides a collection of xtd::forms::country for all countries in the world. This class cannot be inh...
Definition countries.h:24
Represent a country with name, alpha codes, numeric code, emoticon and flag.
Definition country.h:34
virtual const xtd::string name() const noexcept
Gets the country name.
Represents a window or dialog box that makes up an application's user interface.
Definition form.h:54
Represents a standard Windows label.
Definition label.h:38
Represents a standard Windows list box.
Definition list_box.h:33
Used to group collections of controls.
Definition panel.h:32
Represents a standard Windows picture box.
Definition picture_box.h:34
#define startup_(main_method)
Defines the entry point to be called when the application loads. Generally this is set either to the ...
Definition startup.h:175
@ text
The xtd::forms::status_bar_panel displays text in the standard font.
@ system
The appearance of the control is determined by the user's operating system.
The xtd::drawing namespace provides access to GDI+ basic graphics functionality. More advanced functi...
Definition brush.h:18
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition xtd_about_box.h:12
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10
Examples
countries.cpp.

Public Fields

static const country empty ()
 Gets an empty country.
 

Public Static Methods

static country from_alpha_2_code (const xtd::string &alpha_2_code)
 Gets a country from alpha 2 code.
 
static country from_alpha_3_code (const xtd::string &alpha_3_code)
 Gets a country from alpha 3 code.
 
static country from_name (const xtd::string &name)
 Gets a country from name.
 
static country from_numeric_code (int32 numeric_code)
 Gets a country from numeric code.
 

Public Methods

template<typename object_a_t , typename object_b_t >
static bool equals (const object_a_t &object_a, const object_b_t &object_b) noexcept
 Determines whether the specified object instances are considered equal.
 
bool equals (const country &value) const noexcept override
 
virtual xtd::string to_string () const noexcept override
 Returns a string containing the name, alpha codes and numeric code of the country.
 
virtual bool equals (const object &obj) const noexcept
 Determines whether the specified object is equal to the current object.
 

Public Properties

virtual const xtd::string alpha_2_code () const noexcept
 Gets the country alpha 2 code.
 
virtual const xtd::string alpha_3_code () const noexcept
 Gets the country alpha 3 code.
 
virtual const xtd::string emoticon () const noexcept
 Gets the country emoticon.
 
virtual const xtd::drawing::image flag () const noexcept
 Gets the country flag.
 
virtual const xtd::drawing::image flag_squared () const noexcept
 Gets the country flag.
 
virtual const xtd::string name () const noexcept
 Gets the country name.
 
virtual int32 numeric_code () const noexcept
 Gets the country numeric code.
 

Additional Inherited Members

- Public Member Functions inherited from xtd::object
 object ()=default
 Create a new instance of the ultimate base class object.
 
virtual size_t get_hash_code () const noexcept
 Serves as a hash function for a particular type.
 
virtual type_object get_type () const noexcept
 Gets the type of the current instance.
 
template<typename object_t >
xtd::uptr< object_t > memberwise_clone () const
 Creates a shallow copy of the current object.
 
- Public Member Functions inherited from xtd::iequatable< country >
virtual bool equals (const country &) const noexcept=0
 Indicates whether the current object is equal to another object of the same type.
 
- Static Public Member Functions inherited from xtd::object
template<typename object_a_t , typename object_b_t >
static bool equals (const object_a_t &object_a, const object_b_t &object_b) noexcept
 Determines whether the specified object instances are considered equal.
 
template<typename object_a_t , typename object_b_t >
static bool reference_equals (const object_a_t &object_a, const object_b_t &object_b) noexcept
 Determines whether the specified object instances are the same instance.
 

Member Function Documentation

◆ empty()

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

Gets an empty country.

Returns
An empty country

◆ alpha_2_code()

virtual const xtd::string xtd::forms::country::alpha_2_code ( ) const
virtualnoexcept

Gets the country alpha 2 code.

Returns
A string that represent the alpha 2 code.

◆ alpha_3_code()

virtual const xtd::string xtd::forms::country::alpha_3_code ( ) const
virtualnoexcept

Gets the country alpha 3 code.

Returns
A string that represent the alpha 3 code.

◆ emoticon()

virtual const xtd::string xtd::forms::country::emoticon ( ) const
virtualnoexcept

Gets the country emoticon.

Returns
A string that represent the emoticon.

◆ flag()

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

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
virtualnoexcept

Gets the country flag.

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

◆ name()

virtual const xtd::string xtd::forms::country::name ( ) const
virtualnoexcept

Gets the country name.

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

◆ numeric_code()

virtual int32 xtd::forms::country::numeric_code ( ) const
virtualnoexcept

Gets the country numeric code.

Returns
A signed-integer that represent the numeric code.

◆ to_string()

virtual xtd::string 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.

◆ from_alpha_2_code()

static country xtd::forms::country::from_alpha_2_code ( const xtd::string 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::string 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::string 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 ( int32  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.

◆ equals() [1/2]

virtual bool xtd::object::equals ( const object obj) const
virtualnoexcept

Determines whether the specified object is equal to the current object.

Parameters
objThe object to compare with the current object.
Returns
true if the specified object is equal to the current object. otherwise, false.
Examples
The following code example compares the current instance with another object.
#include <xtd/console>
using namespace xtd;
auto main() -> int {
auto object1 = new_ptr<object>();
auto object2 = new_ptr<object>();
auto object3 = object2;
console::write_line(object1->equals(*object3));
console::write_line(*object1 == *object3);
object3 = object1;
console::write_line(object1->equals(*object3));
console::write_line(*object1 == *object3);
}
// This code produces the following output :
//
// false
// false
// true
// true
static void write_line()
Writes the current line terminator to the standard output stream using the specified format informati...

Reimplemented from xtd::object.

◆ equals() [2/2]

template<typename object_a_t , typename object_b_t >
static bool xtd::object::equals ( const object_a_t &  object_a,
const object_b_t &  object_b 
)
inlinestaticnoexcept

Determines whether the specified object instances are considered equal.

Parameters
object_aThe first object to compare.
object_bThe second object to compare.
Returns
true if object_a is the same instance as object_b or if both are null references or if object_a(object_b) returns true. otherwise, false.
Examples
The following code example compares different objects.
#include <xtd/console>
using namespace xtd;
auto main() -> int {
string s1 = "Tom";
string s2 = "Carol";
console::write_line("object::equals(\"{0}\", \"{1}\") => {2}", s1, s2, object::equals(s1, s2));
s1 = "Tom";
s2 = "Tom";
console::write_line("object::equals(\"{0}\", \"{1}\") => {2}", s1, s2, object::equals(s1, s2));
s1 = "";
s2 = "Tom";
console::write_line("object::equals(\"{0}\", \"{1}\") => {2}", s1, s2, object::equals(s1, s2));
s1 = "Carol";
s2 = "";
console::write_line("object::equals(\"{0}\", \"{1}\") => {2}", s1, s2, object::equals(s1, s2));
s1 = "";
s2 = "";
console::write_line("object::equals(\"{0}\", \"{1}\") => {2}", s1, s2, object::equals(s1, s2));
}
// This code produces the following output :
//
// object::equals("Tom", "Carol") => false
// object::equals("Tom", "Tom") => true
// object::equals("", "Tom") => false
// object::equals("Carol", "") => false
// object::equals("", "") => true
virtual bool equals(const object &obj) const noexcept
Determines whether the specified object is equal to the current object.

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