TreeView and Horizontal Scroll bar?


#1

Is there a quick way to add the Horizontal Scroll bar to the TreeView? I need this for my new file/directory Treeview component I’m doing. Which I will make it open-source once its done. 8)

Wk


#2

It appears automatically if any of your items are too wide to fit.


#3

Got it, I have to check now how I’m adding the itens to the list, as I just took your code for the FileTreeComponent component, and I’m doing my own. :wink:

Wk


#4

Got it, I need to implement:

Now, I will check if I could do this in a way that is not fixed, but it takes the current directory/filename lenght in account.

Wk


#5

Its working, but I need to determinate a fixed size.

Now, is there a way to know how much space it would take a text to be drawn? That way I could tell each item its correct size.

Wk


#6

Font::getStringWidth


#7

:oops:

I looked everywhere. :wink:

Thanks Jules, as always.

Wk


#8

That did the trick. :mrgreen:

[code] virtual int getItemWidth() const
{
String fFile;
if (owner.showExtensions) { if (file == file.getLinkedTarget()) fFile = file.getFileName(); else fFile = file.getFileNameWithoutExtension(); }
else { if (file == file.getLinkedTarget()) fFile = file.getFileNameWithoutExtension(); else fFile = File(file.getFileNameWithoutExtension()).getFileNameWithoutExtension(); }

		return Font(getItemHeight() * 0.7f).getStringWidth(fFile) + treeImageWidth;
}[/code]

#9