Home » U++ Library support » U++ Widgets - General questions or Mixed problems » Label/StaticText
Re: Label/StaticText [message #3882 is a reply to message #3881] |
Thu, 06 July 2006 07:28  |
fallingdutch
Messages: 258 Registered: July 2006
|
Experienced Member |
|
|
Thanks Luigi,
You are right, that line was wrong!
If you change that line like seen here, the label will also be drawn.
it should be:
#include <CtrlLib/CtrlLib.h>
class BlinkingLabel : public Label {
private:
int currentColor;
Color BackgroundColor[2];
public:
BlinkingLabel();
void blink();
virtual void Paint(Draw& w);
};
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
};
GUI_APP_MAIN
{ TopWindow w;
BlinkingLabel bl;
w.Add(bl);
bl.SetText("my background is switching every second between red and white!");
bl.LeftPosZ(55, 500).TopPosZ(51, 19);
bl.Transparent(false); //so we arent transparent and our background will be seen
w.Run();}
[Updated on: Thu, 06 July 2006 07:32] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Mon Apr 28 01:16:15 CEST 2025
Total time taken to generate the page: 0.02663 seconds
|