xtd - Reference Guide  0.1.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
Loading...
Searching...
No Matches
colored_tab_pages.cpp

The following code example demonstrate the use of tab_control and colored tab_page containers.

Windows

macOS

Gnome

#include <xtd/xtd>
using namespace std;
using namespace xtd;
using namespace xtd::drawing;
using namespace xtd::forms;
class form1 : public form {
public:
form1() {
text("Colored Tab pages example");
controls().push_back(tab_control_colored);
size({600, 450});
image_list_.image_size({16, 16});
for_each(colors.begin(), colors.end(), [&](auto color) {
auto bitmap = drawing::bitmap(image_list_.image_size());
auto graphics = drawing::graphics::from_image(bitmap);
graphics.fill_ellipse(solid_brush(color), 0, 0, bitmap.width(), bitmap.height());
graphics.draw_ellipse(pens::black(), 0, 0, bitmap.width() - 1, bitmap.height() - 1);
image_list_.images().push_back(bitmap);
auto tab_page = control::create<forms::tab_page>(tab_control_colored, color.name(), drawing::point::empty, drawing::size::empty, color);
tab_page->image_index(tab_pages.size());
tab_pages.push_back(move(tab_page));
});
tab_control_colored.image_list(image_list_);
tab_control_colored.dock(dock_style::fill);
tab_control_colored.alignment(tab_alignment::bottom);
}
private:
vector<color> colors = {colors::light_pink(), colors::light_green(), colors::light_blue(), colors::light_yellow()};
image_list image_list_;
tab_control tab_control_colored;
vector<shared_ptr<tab_page>> tab_pages;
};
int main() {
application::run(form1());
}
Represents an ARGB (alpha, red, green, blue) color.
Definition: color.h:39
colors for all the standard colors. This class cannot be inherited.
Definition: colors.h:20
Represents a window or dialog box that makes up an application's user interface.
Definition: form.h:40
Provides methods to manage a collection of xtd::drawing::image objects. This class cannot be inherite...
Definition: image_list.h:25
Manages a related set of tab pages.
Definition: tab_control.h:26
size_t size
Represents a size of any object in bytes.
Definition: types.h:171
The xtd::drawing namespace provides access to GDI+ basic graphics functionality. More advanced functi...
Definition: bitmap.h:11
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition: about_box.h:13
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition: system_report.h:17