Hi doublemax,
thank you so much for your help and the helpful topic, but something seems to be wrong with my code, it still doesn´t work
here is my code:
rxLED.cpp
Code: Select all
#include "rxLED.h"
rxLED::rxLED(wxWindow* parent, int diameter = 50) : wxWindow(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTRANSPARENT_WINDOW)
{
Connect(wxEVT_PAINT, wxPaintEventHandler(rxLED::OnPaint));
this->diameter = diameter;
this->radius = diameter / 2;
this->colour = rxGrey;
this->SetMaxSize(wxSize(diameter, diameter));
this->SetWindowStyleFlag(wxTRANSPARENT_WINDOW);
this->SetBackgroundStyle(wxBG_STYLE_PAINT);
}
void rxLED::OnPaint(wxPaintEvent& event)
{
wxBufferedPaintDC dc(this);
repaint(dc);
}
void rxLED::setColour(wxColour* colour)
{
this->colour = colour;
}
void rxLED::repaint(wxBufferedPaintDC &dc) {
wxGraphicsGradientStops led_stops;
led_stops.Add(*wxWHITE, 0.0f);
led_stops.Add(*colour, 0.7f);
led_stops.Add(*colour, 1.0f);
wxGraphicsGradientStops ring_stops;
ring_stops.Add(wxColour(30, 30, 30), 0.0f);
ring_stops.Add(wxColour(30, 30, 30), 0.8f);
ring_stops.Add(wxColour(255, 255, 255), 0.9f);
ring_stops.Add(wxColour(60, 60, 60), 1.0f);
wxPoint start(radius, radius);
wxPoint end(radius, radius);
wxGraphicsContext* gc = wxGraphicsContext::Create(dc);
gc->SetBrush(gc->CreateRadialGradientBrush(start.x, start.y, end.x, end.y, radius, ring_stops));
gc->DrawEllipse(0, 0, diameter, diameter);
gc->SetBrush(gc->CreateRadialGradientBrush(start.x, start.y, end.x, end.y, radius, led_stops));
gc->DrawEllipse(diameter / 10, diameter / 10, diameter - (diameter / 5), diameter - (diameter / 5));
delete gc;
}
And only for my interest: do you have any idea, why the way to paint the child's background in the parent's background colour doesn´t work?
Thanks again and best regards,
Cyrano