class DropList : public MultiButton, public Convert
This widget provides the selection of values from the drop-down list. List is organized in key-value pairs; when item is selected, the key of items becomes the new DropList value (as used by SetData/GetData interface). The value of DropList does not necessarily have to be in the list as key, you can e.g. assign a value to DropList with empty list and fill the list later.
Both key and value are of generic Value type. You can associate specific Display and Convert with the list and that way use DropList to represent any type of value (colors, line width, fonts etc..).
DropList also implements the single-direction Convert interface, where Format is defined as key->value translation. When DisplayAll() mode is on, Format returns key values for keys missing in the key / value table; when DisplayAll() mode is off, such values are considered invalid and Format returns Value().
Note: DropBox is implementation helper class used to share some code between DropList and similar classes. DropBox is derived from Ctrl.
typedef MultiButton::Style Style
The chameleon style of DropList is in fact the Style of MultiButton base class.
Callback WhenDrop
This callback is called before the list is displayed. Client code can (re)create the list in the callback.
DropList& Add(const Value& key, const Value& value, bool enable = true)
Adds a new item to the list, key determines the value of item, value is displayed in the value area and in the list. If enable is false, DropList can be assigned this keyand displays corresponding value, but does not include it in drop list popup.
DropList& Add(std::initializer_list<std::pair<Value, Value>> init)
Adds init to the list.
DropList& Add(const Value& value)
Same as Add(value, value).
void Remove(int i)
Removes drop list item i.
void ClearList()
Clears the list.
void Clear()
Clears the list and sets DropList to Null.
DropList& AddSeparator()
Adds horizontal ruler separator item. This item cannot be selected.
void Drop()
Forces the list to "drop".
void SetIndex(int i)
Sets the value of list item i to be the current value.
int GetIndex() const
Returns the index of current value of DropList in the list. Note that the current value is not required to be in the list, in that case -1 is returned.
void GoBegin()
If there are any items, selects the first one.
void GoEnd()
If there are any items, selects the last one.
bool HasKey(const Value& k) const
Tests whether key k is in the list. The search is fast (Index based).
int FindKey(const Value& k) const
Returns the index of key k in the list; returns -1 if not found. The search is fast (Index based).
int Find(const Value& k) const
Same as FindKey(k).
int FindValue(const Value& v) const
Finds the index of item with value v. If there is none, returns -1.
int GetCount() const
Returns the count of items in the list.
void Trim(int n)
Trims the count of items in the list to n.
const Value& GetKey(int i) const
Returns the key at index i.
Value GetValue(int i) const
Returns the value at index i.
Value GetValue() const
Returns the first value from the list that has the key equal to the current value of DropList. (Note that the GetData/SetData interface of DropList uses the key).
void SetValue(int i, const Value& v)
Replaces the value at index i.
void SetValue(const Value& v)
Sets the first value in the list that has the key equal to the current value of DropList.
Value operator[](int i) const
Same as GetValue(i).
void Adjust()
Checks whether the current DropList value is present as key in the list. If it is not and list is not empty, first list item is selected.
void Adjust(const Value& k)
Checks whether the current DropList value is present as key in the list. If it is not and list is not empty, DropList is assigned k.
DropList& SetDropLines(int d)
Sets the number of lines in dropped list.
DropList& SetValueConvert(const Convert& cv)
Sets the converting object for the value in view area.
DropList& SetConvert(const Convert& cv)
Sets the converting object for list values - list values are converted first before being displayed in either view area of DropList or in list. Returns *this.
DropList& SetDisplay(int i, const Display& d)
Sets the display for item i in the list. Returns *this.
DropList& SetDisplay(const Display& d)
Sets the common display d for items in the list and view area. Returns *this. If specific displays for list items (SetDisplay(int i, const Display& d)) or view area (ValueDisplay(const Display& d)) are defined, they take the precedence.
DropList& SetLineCy(int lcy)
Sets the line height of the list item in pixels. Returns *this.
DropList& SetDisplay(const Display& d, int lcy)
Same as SetDisplay(d), SetLineCy(lcy). Returns *this.
DropList& ValueDisplay(const Display& d)
Sets the display object to be used in view area of DropList. Returns *this.
DropList& DisplayAll(bool b = true)
In this mode, if the current value of DropList is not present as the key in the list, the value itself is used to be displayed in the view area. Default is off. Returns *this. When DisplayAll() mode is on, Convert::Format returns key value when a given key is missing in the key / value table; when DisplayAll() mode is off, Convert::Format returns Value() for unknown key values.
DropList& DropFocus(bool b = true)
In this mode, dropping down the list and closing it (either by selecting the item or canceling the selection) brings the keyboard focus to the widget. Default is on. Returns *this.
DropList& NoDropFocus()
Same as DropFocus(false).
DropList& AlwaysDrop(bool e = true)
If this mode is active, drop button is enabled even when the list is empty, allowing the client code to deffer the list creation until the WhenDrop callback.
DropList& SetStyle(const Style& s)
Sets the chameleon style of DropList.
DropList& NotNull(bool b = true)
Specifies that Null value is illegal for DropList. If active, Null value is not accepted.
DropList& DropWidth(int w)
Override the with of dropped PopUpTable drop-down list (which by default is the same as the width of DropList).
DropList& DropWidthZ(int w)
Same as DropWidth(HorzLayoutZoom(w)) - this adjusts the width according to current standard GUI font zooming.
DropList& Wheel(bool b = true)
If active, the value of DropList can be changed by the mouse wheel. Default is active.
DropList& NoWheel()
Same as Wheel(false).
DropList& SetScrollBarStyle(const ScrollBar::Style& s)
Sets the chameleon style of Scrollbar of PopUpTable drop-down list.
const Value& operator=(const Value& v)
operator Value() const
These methods are deprecated in favor of operator~ and operator<<=.
DropList Related Global Functions
|
|
These are simple utility function for filling DropList's list and MapConvert.
void Append(DropList& list, const VectorMap<Value, Value>& values)
void Append(DropList& list, const VectorMap<int, String>& values)
Fills the DropList from VectorMap.
void Append(MapConvert& convert, const VectorMap<Value, Value>& values)
void Append(MapConvert& convert, const VectorMap<int, String>& values)
Fills the MapConvert from VectorMap.
void Append(DropList& list, const MapConvert& convert)
Fills the DropList from MapConvert.
void operator*=(DropList& list, const VectorMap<Value, Value>& values)
void operator*=(DropList& list, const VectorMap<int, String>& values)
Clears and fills the DropList from VectorMap.
void operator*=(MapConvert& convert, const VectorMap<Value, Value>& values)
void operator*=(MapConvert& convert, const VectorMap<int, String>& values)
Clears and fills the MapConvert from VectorMap.
void operator*=(DropList& list, const MapConvert& convert)
Clears and fills the DropList from MapConvert.
|