31#include "observable/evtvar.h"
46 StdIcon(
const wxWindow* parent,
const std::string& svg_file,
47 obs::EventVar& color_change_evt,
bool touch);
53 obs::Listener m_color_change_lstnr;
54 obs::EventVar& m_color_change_evt;
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 obs::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;
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, obs::EventVar &color_change_evt, bool touch)
Create an icon.
const wxBitmap & GetBitmap()
Return bitmap, either day or inverted night variant.
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.