Eclipse SUMO - Simulation of Urban MObility
MFXIconComboBox.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3// Copyright (C) 2006-2022 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
19//
20/****************************************************************************/
21
22#pragma once
23#include <config.h>
24
25#include "MFXTextFieldIcon.h"
26
27
29class MFXListItem : public FXListItem {
31 FXDECLARE(MFXListItem)
32
33public:
35 MFXListItem(const FXString& text, FXIcon* ic, FXColor backGroundColor, void* ptr = NULL);
36
38 void draw(const FXList* list, FXDC& dc, FXint x, FXint y, FXint w, FXint h);
39
41 const FXColor& getBackGroundColor() const;
42
43protected:
46
49};
50
51
53class MFXIconComboBox : public FXPacker {
55 FXDECLARE(MFXIconComboBox)
56
57public:
59 enum {
60 ID_LIST = FXPacker::ID_LAST,
63 };
64
66 MFXIconComboBox(FXComposite* p, FXint cols, const bool haveIcons, FXObject* tgt = NULL, FXSelector sel = 0, FXuint opts = COMBOBOX_NORMAL, FXint x = 0, FXint y = 0, FXint w = 0, FXint h = 0, FXint pl = DEFAULT_PAD, FXint pr = DEFAULT_PAD, FXint pt = DEFAULT_PAD, FXint pb = DEFAULT_PAD);
67
69 virtual ~MFXIconComboBox();
70
72 virtual void create();
73
75 virtual void detach();
76
78 virtual void destroy();
79
81 virtual void enable();
82
84 virtual void disable();
85
87 virtual FXint getDefaultWidth();
88
90 virtual FXint getDefaultHeight();
91
93 virtual void layout();
94
96 FXbool isEditable() const;
97
99 void setEditable(FXbool edit = TRUE);
100
102 FXString getText() const;
103
105 void setNumColumns(FXint cols);
106
108 FXint getNumColumns() const;
109
111 void setJustify(FXuint mode);
112
114 FXuint getJustify() const;
115
117 FXint getNumItems() const;
118
120 FXint getNumVisible() const;
121
123 void setText(FXString text);
124
126 void setNumVisible(FXint nvis);
127
129 FXbool isItemCurrent(FXint index) const;
130
132 void setCurrentItem(FXint index, FXbool notify = FALSE);
133
135 FXint getCurrentItem() const;
136
138 FXString getItem(FXint index) const;
139
141 FXint setIconItem(FXint index, const FXString& text, FXIcon* icon = nullptr, FXColor bgColor = FXRGB(255, 255, 255), void* ptr = nullptr);
142
144 FXint insertIconItem(FXint index, const FXString& text, FXIcon* icon = nullptr, FXColor bgColor = FXRGB(255, 255, 255), void* ptr = nullptr);
145
147 FXint appendIconItem(const FXString& text, FXIcon* icon = nullptr, FXColor bgColor = FXRGB(255, 255, 255), void* ptr = nullptr);
148
150 bool setItem(const FXString& text, FXIcon* icon);
151
153 void setCustomText(const FXString text);
154
156 FXint prependItem(const FXString& text, void* ptr = NULL);
157
159 FXint moveItem(FXint newindex, FXint oldindex);
160
162 void removeItem(FXint index);
163
165 void clearItems();
166
177 FXint findItem(const FXString& text, FXint start = -1, FXuint flags = SEARCH_FORWARD | SEARCH_WRAP) const;
178
186 FXint findItemByData(const void* ptr, FXint start = -1, FXuint flags = SEARCH_FORWARD | SEARCH_WRAP) const;
187
189 FXString getItemText(FXint index) const;
190
192 void setItemData(FXint index, void* ptr) const;
193
195 void* getItemData(FXint index) const;
196
198 FXbool isPaneShown() const;
199
201 void sortItems();
202
204 void setFont(FXFont* fnt);
205
207 FXFont* getFont() const;
208
210 void setComboStyle(FXuint mode);
211
213 FXuint getComboStyle() const;
214
216 virtual void setBackColor(FXColor clr);
217
219 FXColor getBackColor() const;
220
222 void setTextColor(FXColor clr);
223
225 FXColor getTextColor() const;
226
228 void setSelBackColor(FXColor clr);
229
231 FXColor getSelBackColor() const;
232
234 void setSelTextColor(FXColor clr);
235
237 FXColor getSelTextColor() const;
238
240 FXListSortFunc getSortFunc() const;
241
243 void setSortFunc(FXListSortFunc func);
244
246 void setHelpText(const FXString& txt);
247
249 const FXString& getHelpText() const;
250
252 void setTipText(const FXString& txt);
253
255 const FXString& getTipText() const;
256
259 long onFocusUp(FXObject*, FXSelector, void*);
260 long onFocusDown(FXObject*, FXSelector, void*);
261 long onFocusSelf(FXObject*, FXSelector, void*);
262 long onMouseWheel(FXObject*, FXSelector, void*);
263 long onTextButton(FXObject*, FXSelector, void*);
264 long onTextChanged(FXObject*, FXSelector, void*);
265 long onTextCommand(FXObject*, FXSelector, void*);
266 long onListClicked(FXObject*, FXSelector, void*);
267 long onFwdToText(FXObject*, FXSelector, void*);
268 long onUpdFmText(FXObject*, FXSelector, void*);
270
271protected:
274
276 FXLabel* myIconLabel = nullptr;
277
280
282 FXMenuButton* myButton = nullptr;
283
285 FXList* myList = nullptr;
286
288 FXPopup* myPane = nullptr;
289
291 const bool myHaveIcons;
292
293private:
296
299};
ComboBox with icon.
void setSelBackColor(FXColor clr)
Change selected background color.
const FXString & getHelpText() const
Get the combobox help text.
FXColor getSelBackColor() const
Return selected background color.
virtual void create()
Create server-side resources.
const FXString & getTipText() const
Get the tool tip message for this combobox.
FXint findItem(const FXString &text, FXint start=-1, FXuint flags=SEARCH_FORWARD|SEARCH_WRAP) const
virtual ~MFXIconComboBox()
Destructor.
FXString getItem(FXint index) const
Return the item at the given index.
long onTextButton(FXObject *, FXSelector, void *)
long onUpdFmText(FXObject *, FXSelector, void *)
FXint getNumColumns() const
Get the number of columns.
virtual void detach()
Detach server-side resources.
MFXTextFieldIcon * myTextFieldIcon
textField with icon
FXbool isEditable() const
Return true if combobox is editable.
void setHelpText(const FXString &txt)
Set the combobox help text.
void setSelTextColor(FXColor clr)
Change selected text color.
FXString getText() const
Get the text.
long onTextCommand(FXObject *, FXSelector, void *)
void setItemData(FXint index, void *ptr) const
Set data pointer for specified item.
FXint getCurrentItem() const
Get the current item's index.
FXMenuButton * myButton
myButton
FXFont * getFont() const
Get text font.
void removeItem(FXint index)
Remove this item from the list.
long onFocusSelf(FXObject *, FXSelector, void *)
MFXIconComboBox(const MFXIconComboBox &)
invalidate copy constructor
void setSortFunc(FXListSortFunc func)
Change sort function.
void setFont(FXFont *fnt)
Set text font.
virtual void enable()
Enable combo box.
long onMouseWheel(FXObject *, FXSelector, void *)
FXLabel * myIconLabel
label for icon
virtual void layout()
Perform layout.
FXint findItemByData(const void *ptr, FXint start=-1, FXuint flags=SEARCH_FORWARD|SEARCH_WRAP) const
FXbool isItemCurrent(FXint index) const
Return true if current item.
void setJustify(FXuint mode)
Change text justification mode; default is JUSTIFY_LEFT.
FXuint getComboStyle() const
Get the combobox style.
FXint insertIconItem(FXint index, const FXString &text, FXIcon *icon=nullptr, FXColor bgColor=FXRGB(255, 255, 255), void *ptr=nullptr)
Insert a new item at index.
FXint moveItem(FXint newindex, FXint oldindex)
Move item from oldindex to newindex.
FXint setIconItem(FXint index, const FXString &text, FXIcon *icon=nullptr, FXColor bgColor=FXRGB(255, 255, 255), void *ptr=nullptr)
Replace the item at index.
MFXIconComboBox & operator=(const MFXIconComboBox &)=delete
invalidate assignment operator
FXColor getSelTextColor() const
Return selected text color.
FXPopup * myPane
popup
void setCurrentItem(FXint index, FXbool notify=FALSE)
Set the current item (index is zero-based)
void * getItemData(FXint index) const
Get data pointer for specified item.
void setTextColor(FXColor clr)
Change text color.
void sortItems()
Sort items using current sort function.
long onTextChanged(FXObject *, FXSelector, void *)
MFXIconComboBox()
FOX need this.
FXint prependItem(const FXString &text, void *ptr=NULL)
Prepend an item to the list.
virtual FXint getDefaultWidth()
Return default width.
FXList * myList
list
const bool myHaveIcons
check if this iconComboBox have icons
long onFocusUp(FXObject *, FXSelector, void *)
Commands.
void clearItems()
Remove all items from the list.
void setComboStyle(FXuint mode)
Set the combobox style.
FXbool isPaneShown() const
Is the pane shown.
void setText(FXString text)
Set text.
FXListSortFunc getSortFunc() const
Return sort function.
FXString getItemText(FXint index) const
Get text for specified item.
long onFwdToText(FXObject *, FXSelector, void *)
FXuint getJustify() const
Return text justification mode.
FXint getNumVisible() const
Return the number of visible items.
virtual void destroy()
Destroy server-side resources.
void setEditable(FXbool edit=TRUE)
Set editable state.
FXint getNumItems() const
Return the number of items in the list.
void setNumVisible(FXint nvis)
Set the number of visible items in the drop down list.
virtual FXint getDefaultHeight()
Return default height.
void setCustomText(const FXString text)
set custom text
long onFocusDown(FXObject *, FXSelector, void *)
FXColor getTextColor() const
Return text color.
long onListClicked(FXObject *, FXSelector, void *)
void setNumColumns(FXint cols)
Set the number of columns.
bool setItem(const FXString &text, FXIcon *icon)
set Item
FXint appendIconItem(const FXString &text, FXIcon *icon=nullptr, FXColor bgColor=FXRGB(255, 255, 255), void *ptr=nullptr)
append icon
virtual void disable()
Disable combo box.
FXColor getBackColor() const
Get background color.
void setTipText(const FXString &txt)
Set the tool tip message for this combobox.
virtual void setBackColor(FXColor clr)
Set window background color.
A list item which allows for custom coloring.
void draw(const FXList *list, FXDC &dc, FXint x, FXint y, FXint w, FXint h)
draw MFXListItem
FXColor myBackGroundColor
backGround color
MFXListItem()
fox need this
const FXColor & getBackGroundColor() const
get background color
FXTextFieldIcon (based on FXTextFieldIcon)