Skip to content

build/api-examples/Painter.cpp

Complete program from the Painter API reference. Save it at the path shown above and use the build command in the reference page.

Source files · Download Painter.cpp

#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;
}