I'm trying to make a custom LED, so I drew a green LED, both on and off, and saved it as two transparent background PNG files, GreenLedOn.png and GreenLedOff.png. I then added both images as 30x30 pixels static bitmaps, GreenLedOn and GreenLedOff. Later, i defined a method to "switch" the LED on and off:
Code: Select all
void LedStatus(bool x)
{
if(x)
{
GreenLedOn->Show();
GreenLedOff->Hide();
}
else
{
GreenLedOn->Hide();
GreenLedOff->Show();
}
}
Code: Select all
void LedPosition(int x, int y)
{
GreenLedOn->SetPosition(wxPoint(x,y));
GreenLedOff->SetPosition(wxPoint(x,y));
}
My question is, how can i encapsulate this, like a class, for example, so i can declare a new LED, each one with the same methods, instead of having to duplicate everything if i need a new LED? I'm fairly new to GUI and C++ (main experience in C for microcontrollers), so i have no idea on how to do this.
Thanks in advance for your help.
Best regards,
Fenhasan