Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Widgets - General questions or Mixed problems » Label/StaticText
Re: Label/StaticText [message #3881 is a reply to message #3880] Thu, 06 July 2006 00:48 Go to previous messageGo to previous message
forlano is currently offline  forlano
Messages: 1207
Registered: March 2006
Location: Italy
Senior Contributor
fallingdutch wrote on Wed, 05 July 2006 18:20

...
have fun


Hello,

thank you for the nice code. I post here your example ready to run. Please note that one line was not recognised by the compiler. I commented it and it works the same. Please check if it is necessary. Moreover the text on the label doesn't appear.

Luigi

#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]);
// w.DrawRect(0,0,sz.cx,sz.cy,!IsShowEnabled(),false,false,VisibleAccessKeys()); // --- problem---
};

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();}
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: OpenGL, SDL
Next Topic: Mapping button to CALLBACK
Goto Forum:
  


Current Time: Mon Apr 28 01:20:10 CEST 2025

Total time taken to generate the page: 0.03950 seconds