Listbox override font function missing

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
Tyn
Posts: 932
Joined: Thu Nov 20, 2003 7:53 pm
Location: England
Contact:

Listbox override font function missing

Post by Tyn »

Well, missing or intendedly missed out I don't know but it seems nonsensible that it isn't there so I'm posting it as a bug. There is no function to set an override font for the IGUIListbox, so I have added this. Here's the diffs:

In CGUIListBox.cpp:

Change the recalculateItemHeight() function to:

Code: Select all

void CGUIListBox::recalculateItemHeight()

{

	IGUISkin* skin = Environment->getSkin();


	if (!Font)
	{
		Font = skin->getFont();

		ItemHeight = 0;



		if (Font)

		{

			ItemHeight = Font->getDimension(L"A").Height + 4;

			Font->grab();

		}
	}
	
	else
		ItemHeight = Font->getDimension(L"A").Height + 4;



	TotalItemHeight = ItemHeight * Items.size();

	ScrollBar->setMax(TotalItemHeight);

}
Add this function:

Code: Select all

//! Sets another skin independent font. 

void CGUIListBox::setOverrideFont(IGUIFont* font)
{
	if (font)
		Font = font;
}


//! Sets the font which should be used as icon font. This font is set to the Irrlicht engine

//! built-in-font by default. Icons can be displayed in front of every list item.

//! An icon is a string, displayed with the icon font. When using the build-in-font of the

//! Irrlicht engine as icon font, the icon strings defined in GUIIcons.h can be used.

void CGUIListBox::setIconFont(IGUIFont* font)

{

	if (IconFont)

		IconFont->drop();



	IconFont = font;

	if (IconFont)

		IconFont->grab();

}
In CGUIListBox.h

Add function to the public declarations:

Code: Select all

//! Sets another skin independent font.
virtual void setOverrideFont(IGUIFont* font);
in IGUIListBox.h

Add function to public declarations:

Code: Select all

		//! Sets another skin independent font.
		virtual void setOverrideFont(IGUIFont* font) = 0;
niko
Site Admin
Posts: 1759
Joined: Fri Aug 22, 2003 4:44 am
Location: Vienna, Austria
Contact:

Post by niko »

Yep, useful, thanks!
Post Reply