Add IGUIComboBox::setMaxSelectionRows and IGUIComboBox::getMaxSelectionRows

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3883 dfc29bdd-3216-0410-991c-e03cc46cb475
master
cutealien 2011-07-20 09:16:34 +00:00
parent 029b18658b
commit 0d5d30acaf
4 changed files with 38 additions and 3 deletions

View File

@ -1,5 +1,7 @@
Changes in 1.8 (??.??.2011)
- Add IGUIComboBox::setMaxSelectionRows and IGUIComboBox::getMaxSelectionRows
- Scenemanager switches from type ESNT_UNKNOWN to type ESNT_SCENE_MANAGER.
- Add getActiveFont to all elements which have setOverrideFont for cleaner code

View File

@ -55,6 +55,12 @@ namespace gui
\param vertical: EGUIA_UPPERLEFT to align with top edge,
EGUIA_LOWEERRIGHT for bottom edge, or EGUIA_CENTER for centered text (default). */
virtual void setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT vertical) = 0;
//! Set the maximal number of rows for the selection listbox
virtual void setMaxSelectionRows(u32 max) = 0;
//! Get the maximimal number of rows for the selection listbox
virtual u32 getMaxSelectionRows() const = 0;
};

View File

@ -24,7 +24,7 @@ CGUIComboBox::CGUIComboBox(IGUIEnvironment* environment, IGUIElement* parent,
s32 id, core::rect<s32> rectangle)
: IGUIComboBox(environment, parent, id, rectangle),
ListButton(0), SelectedText(0), ListBox(0), LastFocus(0),
Selected(-1), HAlign(EGUIA_UPPERLEFT), VAlign(EGUIA_CENTER), HasFocus(false)
Selected(-1), HAlign(EGUIA_UPPERLEFT), VAlign(EGUIA_CENTER), MaxSelectionRows(5), HasFocus(false)
{
#ifdef _DEBUG
setDebugName("CGUIComboBox");
@ -81,6 +81,26 @@ void CGUIComboBox::setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT ve
}
//! Set the maximal number of rows for the selection listbox
void CGUIComboBox::setMaxSelectionRows(u32 max)
{
MaxSelectionRows = max;
// force recalculation of open listbox
if (ListBox)
{
openCloseMenu();
openCloseMenu();
}
}
//! Get the maximimal number of rows for the selection listbox
u32 CGUIComboBox::getMaxSelectionRows() const
{
return MaxSelectionRows;
}
//! Returns amount of items in box
u32 CGUIComboBox::getItemCount() const
{
@ -410,8 +430,8 @@ void CGUIComboBox::openCloseMenu()
IGUISkin* skin = Environment->getSkin();
s32 h = Items.size();
if (h > 5)
h = 5;
if (h > getMaxSelectionRows())
h = getMaxSelectionRows();
if (h == 0)
h = 1;

View File

@ -62,6 +62,12 @@ namespace gui
//! sets the text alignment of the text part
virtual void setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT vertical);
//! Set the maximal number of rows for the selection listbox
virtual void setMaxSelectionRows(u32 max);
//! Get the maximimal number of rows for the selection listbox
virtual u32 getMaxSelectionRows() const;
//! called if an event happened.
virtual bool OnEvent(const SEvent& event);
@ -97,6 +103,7 @@ namespace gui
s32 Selected;
EGUI_ALIGNMENT HAlign, VAlign;
u32 MaxSelectionRows;
bool HasFocus;
};