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 » Menus&Toolbars » Toolbar and gray color in layout
Toolbar and gray color in layout [message #6174] Wed, 01 November 2006 15:36 Go to next message
forlano is currently offline  forlano
Messages: 1105
Registered: March 2006
Location: Italy
Experienced Contributor
Hello,

I've a tabctrl and in one of the pages there is a layout. In this last I've created a toolbar to attach several buttons with icon. The toolbar looks not so nice. In fact it remains gray while I was waiting to see it white after last chamaleon. PErhaps it is normal.

index.php?t=getfile&id=332&private=0
Perhaps I did a mistake with AddFrame, so I post the code that realize it in the layout:

class VegaTab4 : public WithVegaTab4Layout<ParentCtrl> {
ToolBar toolbar;
FontHeight edt;
EditString edts;
public:
String  filename;
	typedef VegaTab4 CLASSNAME;
...
}


and the constructor

VegaTab4::VegaTab4()
{   int i;
    CtrlLayout(*this);
    SizePos();
    AddFrame(toolbar);	 
    toolbar.Set(THISBACK(MainBar));
... // not important           
}
  • Attachment: vega1.png
    (Size: 3.34KB, Downloaded 3869 times)
Re: Toolbar and gray color in layout [message #6178 is a reply to message #6174] Wed, 01 November 2006 19:41 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 12565
Registered: November 2005
Ultimate Member
Well, it is as intended, which does not necessary means it is right...

ToolBar paints itself with the color you see (in future, this might become something else, like gradient). Do you think we should change this? E.g. some ToolBar option?

Mirek
Re: Toolbar and gray color in layout [message #6179 is a reply to message #6178] Wed, 01 November 2006 19:57 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1105
Registered: March 2006
Location: Italy
Experienced Contributor
luzr wrote on Wed, 01 November 2006 19:41

Well, it is as intended, which does not necessary means it is right...
ToolBar paints itself with the color you see (in future, this might become something else, like gradient). Do you think we should change this? E.g. some ToolBar option?

Mirek


I do not know what to suggest. The upper toolbar is OK, but the second one looks a bit ugly.
Perhaps an option to have the same effect of white as are all the other ctrls around could be advisable.

Thank you,
Luigi
Re: Toolbar and gray color in layout [message #6182 is a reply to message #6179] Wed, 01 November 2006 20:33 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 12565
Registered: November 2005
Ultimate Member
Well, I have altered bar code a little, please try in CtrlLib/Bar.cpp

void BarPane::Paint(Draw& w)
{
	Size sz = GetSize();
	Ctrl *q = GetParent();
	if(!q || !q->IsTransparent())
		w.DrawRect(sz, menu ? (GUI_GlobalStyle() >= GUISTYLE_XP ? SColorMenu : SColorFace) : SColorFace);
....


and them make your ToolBar Ctrl transparent (by calling "Transparent" method).

Mirek
Re: Toolbar and gray color in layout [message #6183 is a reply to message #6182] Wed, 01 November 2006 20:45 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1105
Registered: March 2006
Location: Italy
Experienced Contributor
luzr wrote on Wed, 01 November 2006 20:33

Well, I have altered bar code a little, please try in CtrlLib/Bar.cpp

void BarPane::Paint(Draw& w)
{
	Size sz = GetSize();
	Ctrl *q = GetParent();
	if(!q || !q->IsTransparent())
		w.DrawRect(sz, menu ? (GUI_GlobalStyle() >= GUISTYLE_XP ? SColorMenu : SColorFace) : SColorFace);
....


and them make your ToolBar Ctrl transparent (by calling "Transparent" method).

Mirek


Thank you very much! Now looks better.

Luigi
Re: Toolbar and gray color in layout [message #6269 is a reply to message #6183] Sun, 05 November 2006 10:39 Go to previous messageGo to next message
fallingdutch is currently offline  fallingdutch
Messages: 258
Registered: July 2006
Experienced Member
Is this added to the release-code or only a custom fix?

Bas
Re: Toolbar and gray color in layout [message #6270 is a reply to message #6269] Sun, 05 November 2006 11:18 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 12565
Registered: November 2005
Ultimate Member
Sure, it is in main tree. However, it was not part of any dev release yet.

Mirek
Re: Toolbar and gray color in layout [message #6272 is a reply to message #6183] Sun, 05 November 2006 11:27 Go to previous messageGo to next message
fallingdutch is currently offline  fallingdutch
Messages: 258
Registered: July 2006
Experienced Member
Hello Luigi,

forlano wrote on Wed, 01 November 2006 20:45


Thank you very much! Now looks better.



add this to your code, too and it look even better - imho (I use it, too)
file: CtrlLib/ToolBar.cpp
void ToolButton::Paint(Draw& w) 
{
   painted_checked = checked;
   Size sz=GetSize();
   Size isz =image.GetSize();

//insert starts
   Ctrl *q=GetParent()->GetParent();
   if(!q||!q->IsTransparent())
//insert ends
      w.DrawRect(....);
   if(IsEnabled()) {
      bool push = HasMouse() && GetMouseLeft();
      if(IsXpStyle()) {
         [...]
         else
//insert starts
            if(!q||!q->IsTransparent())
//insert ends
               w.DrawRect(...);
         DrawHighlightImage(...);
      }
      else {
          //guess no need to change anything here - hope at least
      }
   }
   else
      w.DrawImage(...);
}


looks like this:
index.php?t=getfile&id=338&private=0
on the left the icons - the first enabled the others disabled, on the right the first with mouse over it, ready to be pressed Smile
Bas
  • Attachment: toolbar.jpg
    (Size: 3.57KB, Downloaded 3766 times)

[Updated on: Sun, 05 November 2006 11:34]

Report message to a moderator

Re: Toolbar and gray color in layout [message #6284 is a reply to message #6272] Sun, 05 November 2006 20:41 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1105
Registered: March 2006
Location: Italy
Experienced Contributor
Hi Bas,

it looks great. Please let me ask you to post the entire ToolButton::Paint(Draw& w) method as I'm having problem to modify it.
Thanks,

Luigi

[Updated on: Sun, 05 November 2006 20:41]

Report message to a moderator

Re: Toolbar and gray color in layout [message #6290 is a reply to message #6284] Sun, 05 November 2006 22:22 Go to previous messageGo to next message
fallingdutch is currently offline  fallingdutch
Messages: 258
Registered: July 2006
Experienced Member
talked to Mirek, he told me that my code is not up to date ... so which version of upp do you use, Luigi?

I use 610-dev2

Bas
Re: Toolbar and gray color in layout [message #6291 is a reply to message #6290] Sun, 05 November 2006 22:26 Go to previous messageGo to next message
fallingdutch is currently offline  fallingdutch
Messages: 258
Registered: July 2006
Experienced Member
Hi Luigi,
just saw in another post, that you use 610-dev3 ... the one without "IsXPStyle()" Wink

will download it and check how to patch it

Bas
Re: Toolbar and gray color in layout [message #6294 is a reply to message #6291] Sun, 05 November 2006 22:58 Go to previous messageGo to next message
fallingdutch is currently offline  fallingdutch
Messages: 258
Registered: July 2006
Experienced Member
Now for Version 610-dev4:

CtrlLib/ToolBar.cpp
void ToolButton::Paint(Draw& w) {
   [...]
   Size isz = image.GetSize()
//insert starts here
   Ctrl *q = GetParent()->GetParent();
   if(!q || !q->IsTransparent())
//insert ends here
      w.DrawRect(...);
   [...]
}


Hope it helps,
Bas
Re: Toolbar and gray color in layout [message #6329 is a reply to message #6294] Mon, 06 November 2006 21:09 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1105
Registered: March 2006
Location: Italy
Experienced Contributor
fallingdutch wrote on Sun, 05 November 2006 22:58

Now for Version 610-dev4:

CtrlLib/ToolBar.cpp
void ToolButton::Paint(Draw& w) {
   [...]
   Size isz = image.GetSize()
//insert starts here
   Ctrl *q = GetParent()->GetParent();
   if(!q || !q->IsTransparent())
//insert ends here
      w.DrawRect(...);
   [...]
}


Hope it helps,
Bas


It works Smile
So the Mirek's modification in BarPane in conjunction with this last one do the job I wanted, just as the previous picture has shown.
Thanks a lot!

Luigi
Re: Toolbar and gray color in layout [message #9938 is a reply to message #6329] Sun, 10 June 2007 00:09 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1105
Registered: March 2006
Location: Italy
Experienced Contributor
Hello,

I continue to post here because it regards the same problem with version 2007.1. Please have a look to the following picture that shows a toolbar with icon of different size
index.php?t=getfile&id=585&private=0
As you see the droplist and the editstring ctrl look gray. The method .Transparent() do not improve the situation. Is there a workaround?

Thanks,
Luigi
  • Attachment: ult1.jpg
    (Size: 5.75KB, Downloaded 878 times)
Re: Toolbar and gray color in layout [message #9948 is a reply to message #9938] Sun, 10 June 2007 19:36 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 12565
Registered: November 2005
Ultimate Member
Another bug, fixed...

Quick patch:

CtrlLib/Bar.cpp 436:
void BarCtrl::AddCtrl(Ctrl *ctrl, Size sz)
{
	SizeCtrl& m = sizer.DoIndex(zii++);
	m.Transparent(IsTransparent());
	LogPos p = ctrl->GetPos();
	if(p.x.IsEmpty())
		if(sz.cx == INT_MAX)
			ctrl->HSizePos();
		else
			ctrl->HCenterPos(sz.cx ? sz.cx : MINSIZE);
	if(p.y.IsEmpty())
		if(sz.cy == INT_MAX)
			ctrl->VSizePos();
		else
			ctrl->VCenterPos(sz.cy ? sz.cy : MINSIZE);
	LLOG("AddCtrl Ctrl::GetSize: " << ctrl->GetSize());
	m.SetSize(sz);
	m.AddChild(ctrl);
	AddNC(m);
	LLOG("AddCtrl2 Ctrl::GetSize: " << ctrl->GetSize());
}

void BarCtrl::SizeCtrl::Paint(Draw& w)
{
	if(!IsTransparent())
		StaticRect::Paint(w);
}


(and add Paint declaration to SizeCtrl..)
Re: Toolbar and gray color in layout [message #9951 is a reply to message #9948] Mon, 11 June 2007 00:35 Go to previous message
forlano is currently offline  forlano
Messages: 1105
Registered: March 2006
Location: Italy
Experienced Contributor
luzr wrote on Sun, 10 June 2007 19:36

Another bug, fixed...

Quick patch:

CtrlLib/Bar.cpp 436:
void BarCtrl::AddCtrl(Ctrl *ctrl, Size sz)
{
	SizeCtrl& m = sizer.DoIndex(zii++);
	m.Transparent(IsTransparent());
	LogPos p = ctrl->GetPos();
	if(p.x.IsEmpty())
		if(sz.cx == INT_MAX)
			ctrl->HSizePos();
		else
			ctrl->HCenterPos(sz.cx ? sz.cx : MINSIZE);
	if(p.y.IsEmpty())
		if(sz.cy == INT_MAX)
			ctrl->VSizePos();
		else
			ctrl->VCenterPos(sz.cy ? sz.cy : MINSIZE);
	LLOG("AddCtrl Ctrl::GetSize: " << ctrl->GetSize());
	m.SetSize(sz);
	m.AddChild(ctrl);
	AddNC(m);
	LLOG("AddCtrl2 Ctrl::GetSize: " << ctrl->GetSize());
}

void BarCtrl::SizeCtrl::Paint(Draw& w)
{
	if(!IsTransparent())
		StaticRect::Paint(w);
}


(and add Paint declaration to SizeCtrl..)


Thanks, it works Very Happy

Just a note. At first my code with the above fix did not work because I had in my constructor
    ...
    toolbar.Set(THISBACK(MainBar));
    toolbar.Transparent();
    ...

instead of the correct order
    ...
    toolbar.Transparent();
    toolbar.Set(THISBACK(MainBar));
    ...

This is because MainBar must know in advance the transparency state of the toolbar.

Luigi
Previous Topic: MenuBar does not show slahses
Next Topic: CtrlImg::new_doc()
Goto Forum:
  


Current Time: Thu Jul 02 20:51:29 CEST 2020

Total time taken to generate the page: 0.01245 seconds