Home » U++ Library support » U++ Widgets - General questions or Mixed problems » Label/StaticText
Re: Label/StaticText [message #3880 is a reply to message #3879] |
Wed, 05 July 2006 18:20   |
fallingdutch
Messages: 258 Registered: July 2006
|
Experienced Member |
|
|
your welcome!
for all of you who need some code:
header:
class BlinkingLabel : public Label {
private:
Color BackgroundColor[2];
int currentColor;
public:
BlinkingLabel();
void blink();
virtual void Paint(Draw& w);
};
source:
BlinkingLabel::BlinkingLabel() {
currentColor=0;
//the two Backgrounds between wich is switched
BackgroundColor[0] = Color(255,0,0) //red
BackgroundColor[1] = Color(255,255,255) //white
SetTimeCallback(1000,callback(this,&BlinkingLabel::blink)); //start blinking every second
};
void BlinkingLabel::Paint(Draw& w) {
Size sz = GetSize();
if(!IsTransparent())
w.DrawRect(0,0,sz.cx,sz.cy,BackgroundColor[currentColor]);
PaintLabel(w,0,0,sz.cx,sz.cy,!IsShowEnabled(),false,false,VisibleAccessKeys());
};
void BlinkingLabel::blink() {
currentColor=1 & ++currentColor; //toggle between 0 and 1
Refresh();
SetTimeCallback(1000,callback(this,&BlinkingLabel::blink)); //continue blinking every second
};
and the main:
...
BlinkingLabel bl;
bl.Transparent(false); //so we arent transparent and our background will be seen
bl.SetText("my background ist switching every second between red and white!");
...
*EDIT: The Error, wich Luigi posted was removed in the Code
have fun
[Updated on: Thu, 06 July 2006 07:38] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Sun Apr 27 16:00:02 CEST 2025
Total time taken to generate the page: 0.03677 seconds
|