xtd 0.2.0
colored_tab_pages.cpp

demonstrates the use of xtd::forms::tab_page control with unicode text.

Windows

macOS

Gnome

#include <xtd/drawing/colors>
#include <xtd/drawing/pens>
#include <xtd/forms/application>
#include <xtd/forms/form>
#include <xtd/forms/tab_control>
#include <xtd/forms/tab_page>
#include <xtd/cdebug>
using namespace xtd;
using namespace xtd::collections::generic;
using namespace xtd::drawing;
using namespace xtd::forms;
class form1 : public form {
public:
form1() {
text("Colored Tab pages example");
controls().push_back(colored_tab_control);
size({600, 450});
color_image_list.image_size({16, 16});
color_image_list.images().push_back(image_from_color(color_image_list.image_size(), color));
auto colored_tab_page = new_ptr<forms::tab_page>();
colored_tab_page->image_index(colored_tab_pages.size()).parent(colored_tab_control).text(color.name()).back_color(color);
colored_tab_pages.push_back(colored_tab_page);
};
colored_tab_control.image_list(color_image_list);
colored_tab_control.dock(dock_style::fill);
colored_tab_control.alignment(tab_alignment::bottom);
}
private:
auto image_from_color(const drawing::size& size, const color& color)->image {
auto colored_bitmap = bitmap {size};
auto g = graphics::from_image(colored_bitmap);
g.fill_ellipse(solid_brush {color}, 0, 0, colored_bitmap.width(), colored_bitmap.height());
g.draw_ellipse(pens::black(), 0, 0, colored_bitmap.width() - 1, colored_bitmap.height() - 1);
return colored_bitmap;
}
image_list color_image_list;
tab_control colored_tab_control;
list<ptr<tab_page>> colored_tab_pages;
};
auto main() -> int {
application::run(form1 {});
}
Represents a strongly typed list of objects that can be accessed by index. Provides methods to search...
Definition list.hpp:80
Encapsulates a GDI+ bitmap, which consists of the pixel data for a graphics image and its attributes....
Definition bitmap.hpp:26
Represents an ARGB (alpha, red, green, blue) color.
Definition color.hpp:46
xtd::string name() const noexcept
Gets the name of this xtd::drawing::color.
static xtd::drawing::color light_green() noexcept
A system-defined color object.
static xtd::drawing::color light_blue() noexcept
A system-defined color object.
static xtd::drawing::color light_pink() noexcept
A system-defined color object.
static xtd::drawing::color light_yellow() noexcept
A system-defined color object.
static graphics from_image(const xtd::drawing::image &image)
Creates a new xtd::drawing::graphics from the specified xtd::drawing::image.
static xtd::drawing::pen black()
A system-defined pen object with a width of 1.
Defines a xtd::drawing::brush of a single color. Brushes are used to fill graphics shapes,...
Definition solid_brush.hpp:29
static void run()
Begins running a standard application message loop on the current thread, without a form.
Represents a window or dialog box that makes up an application's user interface.
Definition form.hpp:54
Provides methods to manage a collection of xtd::drawing::image objects. This class cannot be inherite...
Definition image_list.hpp:30
Manages a related set of tab pages.
Definition tab_control.hpp:39
size_t size
Represents a size of any object in bytes.
Definition size.hpp:23
ptr< type_t > new_ptr(args_t &&... args)
The xtd::new_ptr operator creates a xtd::ptr object.
Definition new_ptr.hpp:24
@ g
The G key.
Definition console_key.hpp:100
@ bottom
The tabs are located across the bottom of the control.
Definition tab_alignment.hpp:26
@ fill
All the control's edges are docked to the all edges of its containing control and sized appropriately...
Definition dock_style.hpp:35
The xtd::collections::generic namespace contains interfaces and classes that define generic collectio...
Definition comparer.hpp:16
The xtd::drawing namespace provides access to GDI+ basic graphics functionality. More advanced functi...
Definition actions_system_images.hpp:10
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition texts.hpp:217
Contains classes that represent ASCII and Unicode character encodings; abstract base classes for conv...
Definition basic_string_builder.hpp:16
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
Stores an ordered pair of integers, which specify a height and width.
Definition size.hpp:31