27static wxBitmap InvertColors(
const wxBitmap& original) {
28 wxImage image = original.ConvertToImage();
29 unsigned char* data = image.GetData();
30 unsigned char* p_idata = data;
31 for (
int i = 0; i < image.GetSize().y; i++) {
32 for (
int j = 0; j < image.GetSize().x; j++) {
33 unsigned char v = *p_idata;
44 return wxBitmap(image);
48 EventVar& color_change_evt,
bool touch)
49 : m_color_change_evt(color_change_evt),
51 m_day_bitmap(LoadSvgStdIcon(svg_file, parent, touch)),
52 m_night_bitmap(InvertColors(m_day_bitmap)),
53 m_bitmap(m_day_bitmap) {
54 m_color_change_lstnr.
Init(m_color_change_evt, [&](
const ObservedEvt& ev) {
55 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.
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.
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.
Class StdIcon, typically a small monochrome svg icon.