46 StdIcon(
const wxWindow* parent,
const std::string& svg_file,
47 EventVar& color_change_evt,
bool touch);
56 wxBitmap m_day_bitmap;
57 wxBitmap m_night_bitmap;
72static wxBitmap InvertColors(
const wxBitmap& original) {
73 wxImage image = original.ConvertToImage();
74 unsigned char* data = image.GetData();
75 unsigned char* p_idata = data;
76 for (
int i = 0; i < image.GetSize().y; i++) {
77 for (
int j = 0; j < image.GetSize().x; j++) {
78 unsigned char v = *p_idata;
89 return wxBitmap(image);
93 EventVar& color_change_evt,
bool touch)
94 : m_color_change_evt(color_change_evt),
97 m_night_bitmap(InvertColors(m_day_bitmap)),
98 m_bitmap(m_day_bitmap) {
99 m_color_change_lstnr.
Init(m_color_change_evt, [&](
const ObservedEvt& ev) {
100 m_bitmap = ev.GetInt() == 0 ? m_night_bitmap : m_day_bitmap;
Generic event handling between MVC Model and Controller based on a shared EventVar variable.
Define an action to be performed when a KeyProvider is notified.
void Init(const KeyProvider &kp, const std::function< void(ObservedEvt &ev)> &action)
Initiate an object yet not listening.
Custom event class for OpenCPN's notification system.
Small monochrome SVG icon scaled to the height of a char.
StdIcon(const wxWindow *parent, const std::string &svg_file, EventVar &color_change_evt, bool touch)
Create an icon.
const wxBitmap & GetBitmap()
Return bitmap, either day or inverted night variant.
A common variable shared between producer and consumer which supports Listen() and Notify().
Class StdIcon, typically a small monochrome svg icon.
wxBitmap LoadSvgStdIcon(const std::string &svg_file, const wxWindow *w, bool touch)
Load an svg icon from standard path, roughly scaled to the height of a char.