From 0d5d30acaff88a7b89f5aa543d026e1850941d99 Mon Sep 17 00:00:00 2001 From: cutealien Date: Wed, 20 Jul 2011 09:16:34 +0000 Subject: [PATCH] Add IGUIComboBox::setMaxSelectionRows and IGUIComboBox::getMaxSelectionRows git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3883 dfc29bdd-3216-0410-991c-e03cc46cb475 --- changes.txt | 2 ++ include/IGUIComboBox.h | 6 ++++++ source/Irrlicht/CGUIComboBox.cpp | 26 +++++++++++++++++++++++--- source/Irrlicht/CGUIComboBox.h | 7 +++++++ 4 files changed, 38 insertions(+), 3 deletions(-) diff --git a/changes.txt b/changes.txt index 2f9a5524..75f9098c 100644 --- a/changes.txt +++ b/changes.txt @@ -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 diff --git a/include/IGUIComboBox.h b/include/IGUIComboBox.h index 3d818d98..b04f35d4 100644 --- a/include/IGUIComboBox.h +++ b/include/IGUIComboBox.h @@ -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; }; diff --git a/source/Irrlicht/CGUIComboBox.cpp b/source/Irrlicht/CGUIComboBox.cpp index 3ab01eca..ce7590c5 100644 --- a/source/Irrlicht/CGUIComboBox.cpp +++ b/source/Irrlicht/CGUIComboBox.cpp @@ -24,7 +24,7 @@ CGUIComboBox::CGUIComboBox(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect 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; diff --git a/source/Irrlicht/CGUIComboBox.h b/source/Irrlicht/CGUIComboBox.h index 1c656d8d..77e8a0ff 100644 --- a/source/Irrlicht/CGUIComboBox.h +++ b/source/Irrlicht/CGUIComboBox.h @@ -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; };