26 #ifndef TGUI_LIST_BOX_HPP 27 #define TGUI_LIST_BOX_HPP 30 #include <TGUI/Widgets/Scrollbar.hpp> 37 class ListBoxRenderer;
70 typedef std::shared_ptr<ListBox>
Ptr;
71 typedef std::shared_ptr<const ListBox>
ConstPtr;
144 virtual void setPosition(
const Layout2d& position)
override;
154 void setSize(
const Layout2d& size)
override;
166 virtual sf::Vector2f getFullSize()
const override;
177 virtual void setFont(
const Font& font)
override;
194 bool addItem(
const sf::String& itemName,
const sf::String&
id =
"");
211 bool setSelectedItem(
const sf::String& itemName);
228 bool setSelectedItemById(
const sf::String&
id);
244 bool setSelectedItemByIndex(std::size_t index);
266 bool removeItem(
const sf::String& itemName);
281 bool removeItemById(
const sf::String&
id);
297 bool removeItemByIndex(std::size_t index);
304 void removeAllItems();
317 sf::String getItemById(
const sf::String&
id)
const;
327 sf::String getSelectedItem()
const;
337 sf::String getSelectedItemId()
const;
346 int getSelectedItemIndex()
const;
362 bool changeItem(
const sf::String& originalValue,
const sf::String& newValue);
378 bool changeItemById(
const sf::String&
id,
const sf::String& newValue);
392 bool changeItemByIndex(std::size_t index,
const sf::String& newValue);
403 return m_items.size();
413 std::vector<sf::String> getItems();
424 const std::vector<sf::String>& getItemIds();
464 void setItemHeight(
unsigned int itemHeight);
473 unsigned int getItemHeight()
const;
487 void setTextSize(
unsigned int textSize);
496 unsigned int getTextSize()
const;
508 void setMaximumItems(std::size_t maximumItems = 0);
532 void setAutoScroll(
bool autoScroll);
554 virtual void setOpacity(
float opacity)
override;
565 virtual sf::Vector2f getWidgetOffset()
const override;
571 virtual bool mouseOnWidget(
float x,
float y)
const override;
576 virtual void leftMousePressed(
float x,
float y)
override;
581 virtual void leftMouseReleased(
float x,
float y)
override;
586 virtual void mouseMoved(
float x,
float y)
override;
591 virtual void mouseWheelMoved(
int delta,
int x,
int y)
override;
596 virtual void mouseNoLongerOnWidget()
override;
601 virtual void mouseNoLongerDown()
override;
610 void updateItemColors();
625 virtual void reload(
const std::string& primary =
"",
const std::string& secondary =
"",
bool force =
false)
override;
633 return std::make_shared<ListBox>(*this);
640 virtual void update(sf::Time elapsedTime)
override;
646 virtual void draw(sf::RenderTarget& target, sf::RenderStates states)
const override;
653 std::vector<Label> m_items;
654 std::vector<sf::String> m_itemIds;
658 int m_selectedItem = -1;
660 int m_hoveringItem = -1;
663 unsigned int m_itemHeight = 22;
664 unsigned int m_requestedTextSize = 0;
665 unsigned int m_textSize = 18;
668 std::size_t m_maxItems = 0;
674 bool m_possibleDoubleClick =
false;
676 bool m_autoScroll =
true;
711 virtual void setProperty(std::string property,
const std::string& value)
override;
725 virtual void setProperty(std::string property, ObjectConverter&& value)
override;
737 virtual ObjectConverter getProperty(std::string property)
const override;
746 virtual std::map<std::string, ObjectConverter> getPropertyValuePairs()
const override;
755 void setBackgroundColor(
const Color& backgroundColor);
769 void setTextColor(
const Color& textColor);
778 void setTextColorNormal(
const Color& color);
787 void setTextColorHover(
const Color& color);
796 void setHoverBackgroundColor(
const Color& hoverBackgroundColor);
805 void setSelectedBackgroundColor(
const Color& selectedBackgroundColor);
814 void setSelectedTextColor(
const Color& selectedTextColor);
823 void setBorderColor(
const Color& borderColor);
835 void setBackgroundTexture(
const Texture& texture);
847 virtual void setPadding(
const Padding& padding)
override;
854 void draw(sf::RenderTarget& target, sf::RenderStates states)
const;
863 Padding getScaledPadding()
const;
869 virtual std::shared_ptr<WidgetRenderer> clone(Widget* widget)
override;
877 Texture m_backgroundTexture;
879 sf::Color m_backgroundColor;
880 sf::Color m_textColor;
881 sf::Color m_hoverBackgroundColor;
882 sf::Color m_hoverTextColor;
883 sf::Color m_selectedBackgroundColor;
884 sf::Color m_selectedTextColor;
885 sf::Color m_borderColor;
887 friend class ListBox;
888 friend class ComboBox;
889 friend class ComboBoxRenderer;
899 #endif // TGUI_LIST_BOX_HPP Namespace that contains all TGUI functions and classes.
Definition: Animation.hpp:33
ListBoxRenderer(ListBox *listBox)
Constructor.
Definition: ListBox.hpp:698
Class to store the position or size of a widget.
Definition: Layout.hpp:254
Combo box widget.
Definition: ComboBox.hpp:51
std::shared_ptr< ListBoxRenderer > getRenderer() const
Returns the renderer, which gives access to functions that determine how the widget is displayed...
Definition: ListBox.hpp:126
std::shared_ptr< ListBox > Ptr
Shared widget pointer.
Definition: ListBox.hpp:70
std::size_t getItemCount()
Returns the amount of items in the list box.
Definition: ListBox.hpp:401
std::shared_ptr< const ListBox > ConstPtr
Shared constant widget pointer.
Definition: ListBox.hpp:71
std::size_t getMaximumItems() const
Returns the maximum items that the list box can contain.
Definition: ListBox.hpp:518
virtual Widget::Ptr clone() const override
Makes a copy of the widget if you don't know its exact type.
Definition: ListBox.hpp:631
List box widget.
Definition: ListBox.hpp:66
Definition: ListBox.hpp:688
bool getAutoScroll() const
Returns the maximum items that the list box can contain.
Definition: ListBox.hpp:542