Home » Community » Newbie corner » Problem with transparent label and menubar
Problem with transparent label and menubar [message #35322] |
Wed, 01 February 2012 17:39  |
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

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 511 times)
|
|
|
|
Goto Forum:
Current Time: Sat Apr 26 18:32:34 CEST 2025
Total time taken to generate the page: 0.02573 seconds
|