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 » DropList in Toolbar
DropList in Toolbar [message #19522] Thu, 11 December 2008 00:18 Go to next message
sapiency is currently offline  sapiency
Messages: 56
Registered: September 2008
Member
Hi,

I just tried to include a DropList in a Toolbar and started with the example on the page and modified it.

It place the Droplist in the bar, but it's only shown as a small line.
struct MyApp : TopWindow {

typedef MyApp CLASSNAME;
    DropList dl;
    ToolBar  tb;
 
    MyApp()
    {
	AddFrame(tb);
	tb.Set(THISBACK(createTool));

        //Add(dl.HSizePos().TopPos(5, Ctrl::STDSIZE));

        dl.SetDisplay(Single<FontFaceDisplay>());

        for(int i = 0; i < Font::GetFaceCount(); i++)

            dl.Add(i);

        SetRect(0, 150, 200, 170);

    }

    void createTool(Bar & bar){
        bar.Add(dl.HSizePos().TopPos(5, Ctrl::STDSIZE));
    }

};


where is my mistake?

reinhard
Re: DropList in Toolbar [message #19525 is a reply to message #19522] Thu, 11 December 2008 10:38 Go to previous messageGo to next message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
Well, this is partly your mistake and partly a Upp bug.

Your mistake:
When you add Ctrls to a ToolBar it manages the layout internally and you just tell it a size. Instead of:
bar.Add(dl.HSizePos().TopPos(5, Ctrl::STDSIZE));
You use:
bar.Add(dl, dl.StdSize());
And you can change the StdSize() to Size(100, 20) or whatever.

The Upp bug:
The StdSize() shouldn't be necessary, as the default size used should be at least more-or-less correct. The problem is that the default Add function in CtrlLib/Bar.h:
	void   Add(Ctrl& ctrl)                          { AddCtrl(&ctrl, ctrl.GetMinSize()); }
Should be using StdSize():
	void   Add(Ctrl& ctrl)                          { AddCtrl(&ctrl, ctrl.GetStdSize()); }
In most cases this makes no difference, but for DropList it does.

Additionally DropList::GetMinSize() is clearly too small.
Re: DropList in Toolbar [message #19526 is a reply to message #19525] Thu, 11 December 2008 15:03 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
mrjt wrote on Thu, 11 December 2008 04:38


The Upp bug:
The StdSize() shouldn't be necessary, as the default size used should be at least more-or-less correct. The problem is that the default Add function in CtrlLib/Bar.h:
	void   Add(Ctrl& ctrl)                          { AddCtrl(&ctrl, ctrl.GetMinSize()); }
Should be using StdSize():
	void   Add(Ctrl& ctrl)                          { AddCtrl(&ctrl, ctrl.GetStdSize()); }
In most cases this makes no difference, but for DropList it does.

Additionally DropList::GetMinSize() is clearly too small.



Debatable.

I think when puttin DropList to ToolBar, you need to set the width anyway. That is why there is

void Add(Ctrl& ctrl, int cx, int cy = 0);

variant. cy is minsize, you just need to put cx.

BTW, the REAL problem there is that I am undecided whether cx, cy should be altered by font zoom...

Mirek
Re: DropList in Toolbar [message #19527 is a reply to message #19526] Thu, 11 December 2008 16:38 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

[quote title=luzr wrote on Thu, 11 December 2008 09:03]
mrjt wrote on Thu, 11 December 2008 04:38


BTW, the REAL problem there is that I am undecided whether cx, cy should be altered by font zoom...

Mirek


They should be. I do so when I put DropGrid on the toolbar. Otherwise it's too small when font is larger.
Re: DropList in Toolbar [message #19530 is a reply to message #19527] Thu, 11 December 2008 23:43 Go to previous messageGo to next message
sapiency is currently offline  sapiency
Messages: 56
Registered: September 2008
Member
thanks,

that works for me at the moment ...


regards

reinhard
Re: DropList in Toolbar [message #19534 is a reply to message #19526] Fri, 12 December 2008 11:08 Go to previous messageGo to next message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
luzr wrote on Thu, 11 December 2008 14:03


Debatable.

I think when puttin DropList to ToolBar, you need to set the width anyway. That is why there is

void Add(Ctrl& ctrl, int cx, int cy = 0);

variant. cy is minsize, you just need to put cx.

BTW, the REAL problem there is that I am undecided whether cx, cy should be altered by font zoom...

Mirek


While it's true that getting the best result will require setting the size yourself, you should at least be able to get something useable without it.

At the moment DropList::MinSize may as well return cx = 0 for all the use it is. And I'm personally convinced that the default should be StdSize anyway, which as I understand it is supposed to be a Ctrl's best guess as to the correct size. Most Ctrl's simply return MinSize but for those that implement it the result will be much better.

This isn't really a major issue in this case, but I have some issues with the general inconsistency in the use of MinSize/StdSize, and the missing implementations of the latter. At the end of the day I could fix most of this myself and submit a patch though.
Re: DropList in Toolbar [message #19577 is a reply to message #19527] Thu, 18 December 2008 11:22 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
[quote title=unodgs wrote on Thu, 11 December 2008 10:38]
luzr wrote on Thu, 11 December 2008 09:03

mrjt wrote on Thu, 11 December 2008 04:38


BTW, the REAL problem there is that I am undecided whether cx, cy should be altered by font zoom...

Mirek


They should be. I do so when I put DropGrid on the toolbar. Otherwise it's too small when font is larger.


Well, maybe we should have both variants. Add, working as now, and AddZ, zooming.

It is not unlikely that client wants to do some more magic with the width and needs real pixels.. And 'Z' class of methods is already established.

Mirek
Re: DropList in Toolbar [message #19578 is a reply to message #19534] Thu, 18 December 2008 11:26 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
mrjt wrote on Fri, 12 December 2008 05:08

luzr wrote on Thu, 11 December 2008 14:03


Debatable.

I think when puttin DropList to ToolBar, you need to set the width anyway. That is why there is

void Add(Ctrl& ctrl, int cx, int cy = 0);

variant. cy is minsize, you just need to put cx.

BTW, the REAL problem there is that I am undecided whether cx, cy should be altered by font zoom...

Mirek


While it's true that getting the best result will require setting the size yourself, you should at least be able to get something useable without it.

At the moment DropList::MinSize may as well return cx = 0 for all the use it is. And I'm personally convinced that the default should be StdSize anyway, which as I understand it is supposed to be a Ctrl's best guess as to the correct size. Most Ctrl's simply return MinSize but for those that implement it the result will be much better.

This isn't really a major issue in this case, but I have some issues with the general inconsistency in the use of MinSize/StdSize, and the missing implementations of the latter. At the end of the day I could fix most of this myself and submit a patch though.


I definitely agree about MinSize/StdSize issue. I think this should be addressed.

BTW, one nice method for "complex cases" is to use NilDraw and copy Paint to DoPaint, adding max size gathering - you do not have to duplicate all the placement logic then.

Mirek
Previous Topic: images as menu
Next Topic: right-click menu
Goto Forum:
  


Current Time: Fri Mar 29 06:33:59 CET 2024

Total time taken to generate the page: 0.01133 seconds