C++ class: Painter¶
Description¶
Abstract rectangle and text rendering interface.
Qualified name : gaspardos::gui::Painter.
Header : bindings/cpp/widgets.hpp. C++98.
When to use it¶
Connect Widgets to native rendering or a test renderer.
Simple program example¶
#include "widgets.hpp"
#include <cstdio>
#include <cstring>
class ConsolePainter : public gaspardos::gui::Painter
{
public:
int64_t fill(int, int, int, int, uint32_t)
{
return 0;
}
int64_t text(int, int, uint32_t, const char* value)
{
std::puts(value);
return 0;
}
};
int main()
{
gaspardos::gui::Widgets widgets(320, 200);
gaspardos::gui::Event ready = { gaspardos::gui::Ready, 0, 0, 0, 0 };
widgets.event(ready);
ConsolePainter painter;
return widgets.paint(painter) == 0 ? 0 : 1;
}
Building from Windows¶
Save the program above as build/api-examples/Painter.cpp from the repository root. Create the directory if necessary.
PowerShell — from the repository root:
New-Item -ItemType Directory -Force build/api-examples | Out-Null
& .\build-x64-install\bin\x86_64-gaspardos-g++.exe -std=c++98 -O2 -Ibindings/cpp build/api-examples/Painter.cpp -o build/api-examples/Painter-x64.elf
if ($LASTEXITCODE -ne 0) { throw "C++ compilation/link failed" }
Run the ELF on GaspardOS, not Windows. The driver supplies CRT and libraries. Prepare the required volumes/services; examples bound their waits and may exit on backpressure rather than retry. Successful compilation does not validate kernel execution.
The headers, implementation files, native wrappers and complete examples are available under Source files.
Class methods¶
virtual ~Painter()¶
Virtual destructor.
virtual int64_t fill(int x, int y, int w, int h, uint32_t color) = 0¶
Rectangle; implement a signed result, negative error including -11 for retry.
virtual int64_t text(int x, int y, uint32_t color, const char* value) = 0¶
NUL-terminated text; native colors 0x00BBGGRR.