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 » Community » Newbie corner » Problem with transparent label and menubar
Problem with transparent label and menubar [message #35322] Wed, 01 February 2012 17:39 Go to next message
jerson is currently offline  jerson
Messages: 202
Registered: June 2010
Location: Bombay, India
Experienced Member

Hello everyone

After a while, I got back to coding an app in UPP. I managed to get my screen drawn with a vertical label(quite an exercise for me)

Now, the problem. When I add a menubar to the topwindow, the label which is transparent shows through the topwindow. Either this is a bug or I am missing something. Setting the troubled label to NOT transparent, it works OK.

This is the label class that I am using

class VerticalLabel : public Ctrl {
 	protected:
  		
  	private:
  		Size	sz,textsize;
  		Color	mPaper, mInk;
  		String	Caption;
  		int		mAngle;
  		Font	mFont;
		bool    mTransparent;
	
	public:
		typedef	VerticalLabel	CLASSNAME;
		
		virtual void Paint(Draw& w) {
			sz 	= GetSize();
			textsize = GetTextSize(Caption, mFont);
			if (!mTransparent)	w.DrawRect(sz, mPaper);
			switch (mAngle){
				case 0:
					w.DrawText((sz.cx-textsize.cx)/2, (sz.cy-textsize.cy)/2, mAngle, Caption, mFont, mInk);
					break;
				case 900:
					w.DrawText((sz.cx-textsize.cy)/2, (sz.cy+textsize.cx)/2, mAngle, Caption, mFont, mInk);
					break;
				case 1800:
					w.DrawText((sz.cx+textsize.cx)/2, (sz.cy+textsize.cy)/2, mAngle, Caption, mFont, mInk);
					break;
				case 2700:
					w.DrawText((sz.cx+textsize.cy)/2, (sz.cy-textsize.cx)/2, mAngle, Caption, mFont, mInk);
					break;
			}
		}
	
		VerticalLabel()	// constructor
		{
			mAngle = 900;
			Caption = "Vertical Label";
			mTransparent = true;
		};
		
		
		VerticalLabel&	Transparent(const bool transp)	{mTransparent = transp; return *this;};
		VerticalLabel&	TextAngle(const int angle)		{mAngle = angle; return *this;};
		VerticalLabel&	SetText(const char *text)		{Caption = text; return *this;};
		VerticalLabel&	SetPaper(const Color Paper)		{mPaper = Paper; return *this;};
		VerticalLabel&	SetInk(const Color Ink)			{mInk = Ink; return *this;};
		VerticalLabel&	SetFont(const Font font)		{mFont = font; return *this;};
};


All labels are transparent, so I expect to see the window background. However, when the menu bar is displayed, the circled label shows the image of what is behind it in the Z order of the display. Moving the top window around gives the display you see.

There is a static image above the circled label. Maybe this image gets resized etc and leaves the background visible.

Please see this image
index.php?t=getfile&id=3630&private=0

The main.cpp has this (only relevant part is shown)
void DiaGuage::MainMenu(Bar& bar) 
{
	bar.Add("File", THISBACK(mnuFile));
	bar.Add("Settings",THISBACK(mnuSettings));
	bar.Add("View",THISBACK(mnuView));
	bar.Add("About",THISBACK(mnuAbout));
}

DiaGuage::DiaGuage()
{
	CtrlLayout(*this, "Laser Diameter Guage");
	Icon(Images::Icon());										// window icon
	AddFrame(menu);   /**** commenting out this solves problem,but, I need it there */
	menu.Set(THISBACK(MainMenu));
}

GUI_APP_MAIN
{
	DiaGuage().Run();
}



Any ideas are welcome.

Regards
Jerson
  • Attachment: LDG.jpg
    (Size: 108.37KB, Downloaded 433 times)
Re: Problem with transparent label and menubar [message #35325 is a reply to message #35322] Fri, 03 February 2012 06:07 Go to previous message
jerson is currently offline  jerson
Messages: 202
Registered: June 2010
Location: Bombay, India
Experienced Member

Please don't bother. I managed to find that calling BackPaint() method seems to solve the problem. Why?
Previous Topic: [Solved]JSON question
Next Topic: X Window System error
Goto Forum:
  


Current Time: Sat Apr 20 12:30:55 CEST 2024

Total time taken to generate the page: 0.02493 seconds