00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
#ifndef ULISTBOX_HPP
00029
#define ULISTBOX_HPP
00030
00031
#include "uscrollablewidget.hpp"
00032
00033
#include "../util/ucolor.hpp"
00034
00035
namespace ufo {
00036
00037
class UItem;
00038
class UIcon;
00039
class UColor;
00040
00048 class UFO_EXPORT UListBox :
public UScrollableWidget {
00049 UFO_DECLARE_DYNAMIC_CLASS(UListBox)
00050 UFO_UI_CLASS(UListBoxUI)
00051 UFO_STYLE_TYPE(UStyle::CE_ListBox)
00052
public:
00057 enum SelectionMode {
00058 SingleSelection,
00059 MultipleSelection,
00060 NoSelection
00061 };
00062
public:
00063 UListBox();
00064 UListBox(
const std::vector<UString> & listDataA);
00065
00066
public:
00067
virtual int getUnitIncrement(Orientation orientation = Horizontal)
const;
00068
virtual int getBlockIncrement(Orientation orientation = Horizontal)
const;
00069
00070
virtual UDimension getPreferredViewportSize() const;
00071
00072 public:
00077
void addList(const std::vector<
UString> & listData);
00080
void addItem(
UItem * itemA,
int index = -1);
00083
void addItem(const
UString & itemA,
int index = -1);
00086
void addItem(
UIcon * itemA,
int index = -1);
00087
00089
void removeItem(
unsigned int index);
00090
void removeAllItems();
00091
00092
UItem * getItemAt(
unsigned int n) const;
00093 const std::vector<
UItem *> & getItems() const;
00094
00095
unsigned int getItemCount() const;
00096
00097 public:
00098 SelectionMode getSelectionMode() const;
00099
void setSelectionMode(SelectionMode modeA);
00100
00101
int getSelectedIndex() const;
00102
void setSelectedIndex(
int indexA);
00103
00104
void invertSelection();
00105
void selectAll();
00106
00107 std::vector<
unsigned int> getSelectedIndices() const;
00108
void setSelectedIndices(const std::vector<
unsigned int> & indicesA);
00109
00110
bool isSelectedIndex(
unsigned int indexA);
00111
00112
UItem * getSelectedItem();
00113 std::vector<
UItem*> getSelectedItems();
00114
00115 public:
00119
void setVisibleRowCount(
int visibleRowCountA);
00120
int getVisibleRowCount() const;
00121
00123
UPoint indexToLocation(
unsigned int indexA);
00126
int locationToIndex(const
UPoint & locationA);
00127
00128 protected:
00129 virtual
void paintWidget(
UGraphics * g);
00130 virtual
UDimension getContentsSize(const
UDimension & maxSize) const;
00131 virtual
void processMouseEvent(
UMouseEvent * e);
00132 virtual
void processKeyEvent(
UKeyEvent * e);
00133 virtual
void processWidgetEvent(
UWidgetEvent * e);
00134
00135 public:
00137 typedef USignal3<UListBox*,
int,
int>
sig_selection_change_t;
00138 sig_selection_change_t & sigSelectionChanged();
00139
00140 protected:
00141
void addItemImpl(
UItem * itemA,
int index);
00142
00143
void fireSelectionEvent(
int firstIndexA,
int lastIndexA);
00144
00145 private:
00146 SelectionMode m_selectionMode;
00147
00148 std::vector<
UItem *> m_items;
00149 std::vector<
unsigned int> m_indices;
00150
00151
int m_visRowCount;
00152 private:
00153 sig_selection_change_t m_sigSelectionChanged;
00154 };
00155
00156
00157
00158
00159 inline UListBox::sig_selection_change_t &
00160 UListBox::sigSelectionChanged() {
00161
return m_sigSelectionChanged;
00162 }
00163
00167
00168
00169
00170
00171
00172
00173
00174
00180
00181
00182
00183
00184
00185 }
00186
00187
#endif // ULISTBOX_HPP