📄 ceguilistbox.h
字号:
/***********************************************************************
filename: CEGUIListbox.h
created: 13/4/2004
author: Paul D Turner
purpose: Interface to base class for Listbox widget
*************************************************************************/
/***************************************************************************
* Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
***************************************************************************/
#ifndef _CEGUIListbox_h_
#define _CEGUIListbox_h_
#include "CEGUIBase.h"
#include "CEGUIWindow.h"
#include "elements/CEGUIListboxProperties.h"
#include <vector>
#if defined(_MSC_VER)
# pragma warning(push)
# pragma warning(disable : 4251)
#endif
// Start of CEGUI namespace section
namespace CEGUI
{
/*!
\brief
Base class for Listbox window renderer.
*/
class CEGUIEXPORT ListboxWindowRenderer : public WindowRenderer
{
public:
/*!
\brief
Constructor
*/
ListboxWindowRenderer(const String& name);
/*!
\brief
Return a Rect object describing, in un-clipped pixels, the window relative area
that is to be used for rendering list items.
\return
Rect object describing the area of the Window to be used for rendering
list box items.
*/
virtual Rect getListRenderArea(void) const = 0;
};
/*!
\brief
Base class for standard Listbox widget.
*/
class CEGUIEXPORT Listbox : public Window
{
public:
static const String EventNamespace; //!< Namespace for global events
static const String WidgetTypeName; //!< Window factory name
/*************************************************************************
Constants
*************************************************************************/
// event names
static const String EventListContentsChanged; //!< Event triggered when the contents of the list is changed.
static const String EventSelectionChanged; //!< Event triggered when there is a change to the currently selected item(s).
static const String EventSortModeChanged; //!< Event triggered when the sort mode setting changes.
static const String EventMultiselectModeChanged; //!< Event triggered when the multi-select mode setting changes.
static const String EventVertScrollbarModeChanged; //!< Event triggered when the vertical scroll bar 'force' setting changes.
static const String EventHorzScrollbarModeChanged; //!< Event triggered when the horizontal scroll bar 'force' setting changes.
/*************************************************************************
Child Widget name suffix constants
*************************************************************************/
static const String VertScrollbarNameSuffix; //!< Widget name suffix for the vertical scrollbar component.
static const String HorzScrollbarNameSuffix; //!< Widget name suffix for the horizontal scrollbar component.
/*************************************************************************
Accessor Methods
*************************************************************************/
/*!
\brief
Return number of items attached to the list box
\return
the number of items currently attached to this list box.
*/
size_t getItemCount(void) const {return d_listItems.size();}
/*!
\brief
Return the number of selected items in the list box.
\return
Total number of attached items that are in the selected state.
*/
size_t getSelectedCount(void) const;
/*!
\brief
Return a pointer to the first selected item.
\return
Pointer to a ListboxItem based object that is the first selected item in the list. will return NULL if
no item is selected.
*/
ListboxItem* getFirstSelectedItem(void) const;
/*!
\brief
Return a pointer to the next selected item after item \a start_item
\param start_item
Pointer to the ListboxItem where the search for the next selected item is to begin. If this
parameter is NULL, the search will begin with the first item in the list box.
\return
Pointer to a ListboxItem based object that is the next selected item in the list after
the item specified by \a start_item. Will return NULL if no further items were selected.
\exception InvalidRequestException thrown if \a start_item is not attached to this list box.
*/
ListboxItem* getNextSelected(const ListboxItem* start_item) const;
/*!
\brief
Return the item at index position \a index.
\param index
Zero based index of the item to be returned.
\return
Pointer to the ListboxItem at index position \a index in the list box.
\exception InvalidRequestException thrown if \a index is out of range.
*/
ListboxItem* getListboxItemFromIndex(size_t index) const;
/*!
\brief
Return the index of ListboxItem \a item
\param item
Pointer to a ListboxItem whos zero based index is to be returned.
\return
Zero based index indicating the position of ListboxItem \a item in the list box.
\exception InvalidRequestException thrown if \a item is not attached to this list box.
*/
size_t getItemIndex(const ListboxItem* item) const;
/*!
\brief
return whether list sorting is enabled
\return
true if the list is sorted, false if the list is not sorted
*/
bool isSortEnabled(void) const {return d_sorted;}
/*!
\brief
return whether multi-select is enabled
\return
true if multi-select is enabled, false if multi-select is not enabled.
*/
bool isMultiselectEnabled(void) const {return d_multiselect;}
bool isItemTooltipsEnabled(void) const {return d_itemTooltips;}
/*!
\brief
return whether the string at index position \a index is selected
\param index
Zero based index of the item to be examined.
\return
true if the item at \a index is selected, false if the item at \a index is not selected.
\exception InvalidRequestException thrown if \a index is out of range.
*/
bool isItemSelected(size_t index) const;
/*!
\brief
Search the list for an item with the specified text
\param text
String object containing the text to be searched for.
\param start_item
ListboxItem where the search is to begin, the search will not include \a item. If \a item is
NULL, the search will begin from the first item in the list.
\return
Pointer to the first ListboxItem in the list after \a item that has text matching \a text. If
no item matches the criteria NULL is returned.
\exception InvalidRequestException thrown if \a item is not attached to this list box.
*/
ListboxItem* findItemWithText(const String& text, const ListboxItem* start_item);
/*!
\brief
Return whether the specified ListboxItem is in the List
\return
true if ListboxItem \a item is in the list, false if ListboxItem \a item is not in the list.
*/
bool isListboxItemInList(const ListboxItem* item) const;
/*!
\brief
Return whether the vertical scroll bar is always shown.
\return
- true if the scroll bar will always be shown even if it is not required.
- false if the scroll bar will only be shown when it is required.
*/
bool isVertScrollbarAlwaysShown(void) const;
/*!
\brief
Return whether the horizontal scroll bar is always shown.
\return
- true if the scroll bar will always be shown even if it is not required.
- false if the scroll bar will only be shown when it is required.
*/
bool isHorzScrollbarAlwaysShown(void) const;
/*************************************************************************
Manipulator Methods
*************************************************************************/
/*!
\brief
Initialise the Window based object ready for use.
\note
This must be called for every window created. Normally this is handled automatically by the WindowFactory for each Window type.
\return
Nothing
*/
virtual void initialiseComponents(void);
/*!
\brief
Remove all items from the list.
Note that this will cause 'AutoDelete' items to be deleted.
*/
void resetList(void);
/*!
\brief
Add the given ListboxItem to the list.
\param item
Pointer to the ListboxItem to be added to the list. Note that it is the passed object that is added to the
list, a copy is not made. If this parameter is NULL, nothing happens.
\return
Nothing.
*/
void addItem(ListboxItem* item);
/*!
\brief
Insert an item into the list box after a specified item already in the list.
Note that if the list is sorted, the item may not end up in the requested position.
\param item
Pointer to the ListboxItem to be inserted. Note that it is the passed object that is added to the
list, a copy is not made. If this parameter is NULL, nothing happens.
\param position
Pointer to a ListboxItem that \a item is to be inserted after. If this parameter is NULL, the item is
inserted at the start of the list.
\return
Nothing.
\exception InvalidRequestException thrown if no ListboxItem \a position is attached to this list box.
*/
void insertItem(ListboxItem* item, const ListboxItem* position);
/*!
\brief
Removes the given item from the list box. If the item is has the auto delete state set, the item will be deleted.
\param item
Pointer to the ListboxItem that is to be removed. If \a item is not attached to this list box then nothing
will happen.
\return
Nothing.
*/
void removeItem(const ListboxItem* item);
/*!
\brief
Clear the selected state for all items.
\return
Nothing.
*/
void clearAllSelections(void);
/*!
\brief
Set whether the list should be sorted.
\param setting
true if the list should be sorted, false if the list should not be sorted.
\return
Nothing.
*/
void setSortingEnabled(bool setting);
/*!
\brief
Set whether the list should allow multiple selections or just a single selection
\param setting
true if the widget should allow multiple items to be selected, false if the widget should only allow
a single selection.
\return
Nothing.
*/
void setMultiselectEnabled(bool setting);
/*!
\brief
Set whether the vertical scroll bar should always be shown.
\param setting
true if the vertical scroll bar should be shown even when it is not required. false if the vertical
scroll bar should only be shown when it is required.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -