Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MFXListIcon.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2006-2024 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/****************************************************************************/
18//
19/****************************************************************************/
20
21#pragma once
22#include <config.h>
23
24#include <string>
25#include <vector>
26
27#include "MFXListIconItem.h"
28
30class MFXListIcon : public FXScrollArea {
32 FXDECLARE(MFXListIcon)
33
34public:
35 enum {
36 ID_LOOKUPTIMER = FXScrollArea::ID_LAST,
38 };
39
41 MFXListIcon(FXComposite* p, FXObject* tgt = NULL, FXSelector sel = 0, FXuint opts = LIST_NORMAL, FXint x = 0, FXint y = 0, FXint w = 0, FXint h = 0);
42
45
47 void create();
48
50 void detach();
51
53 void layout();
54
56 FXint getDefaultWidth();
57
59 FXint getDefaultHeight();
60
62 FXint getContentWidth();
63
65 FXint getContentHeight();
66
68 void recalc();
69
71 bool canFocus() const;
72
74 void setFocus();
75
77 void killFocus();
78
80 FXint getNumItems() const {
81 return (int)items.size();
82 }
83
85 FXint getNumVisible() const {
86 return visible;
87 }
88
90 void setNumVisible(FXint nvis);
91
93 MFXListIconItem* getItem(FXint index) const;
94
96 FXint setItem(FXint index, MFXListIconItem* item, FXbool notify = FALSE);
97
99 FXint editItem(FXint index, const FXString& text, FXIcon* icon = NULL, void* ptr = NULL, FXbool notify = FALSE);
100
102 FXint insertItem(FXint index, MFXListIconItem* item, FXbool notify = FALSE);
103
105 FXint insertItem(FXint index, const FXString& text, FXIcon* icon = NULL, void* ptr = NULL, FXbool notify = FALSE);
106
108 FXint appendItem(MFXListIconItem* item, FXbool notify = FALSE);
109
111 FXint appendItem(const FXString& text, FXIcon* icon = NULL, void* ptr = NULL, FXbool notify = FALSE);
112
114 void removeItem(FXint index, FXbool notify = FALSE);
115
117 void clearItems(FXbool notify = FALSE);
118
120 void setFilter(const FXString& value, FXLabel* label);
121
123 FXint getItemWidth(FXint index) const;
124
126 FXint getItemHeight(FXint index) const;
127
129 MFXListIconItem* getItemAt(FXint y) const;
130
132 int findItem(const FXString& text) const;
133
135 FXint hitItem(MFXListIconItem* item, FXint x, FXint y) const;
136
139
141 void makeItemVisible(FXint index);
142
144 FXbool isItemCurrent(FXint index) const;
145
147 FXbool isItemVisible(MFXListIconItem* item) const;
148
150 void updateItem(MFXListIconItem* item) const;
151
153 FXbool selectItem(MFXListIconItem* item, FXbool notify = FALSE);
154
156 FXbool deselectItem(MFXListIconItem* item, FXbool notify = FALSE);
157
159 FXbool toggleItem(MFXListIconItem* item, FXbool notify = FALSE);
160
162 FXbool killSelection(FXbool notify = FALSE);
163
165 void setCurrentItem(MFXListIconItem* item, FXbool notify = FALSE);
166
168 FXint getCurrentItemIndex() const;
169
171 FXint getViewableItem() const;
172
174 void setAnchorItem(MFXListIconItem* item);
175
177 FXint getAnchorItem() const;
178
181
183 FXFont* getFont() const {
184 return font;
185 }
186
188 FXColor getTextColor() const {
189 return textColor;
190 }
191
193 void setTextColor(FXColor clr);
194
196 FXColor getSelBackColor() const {
197 return selbackColor;
198 }
199
201 FXColor getSelTextColor() const {
202 return seltextColor;
203 }
204
206 void setHelpText(const FXString& text);
207
209 const FXString& getHelpText() const {
210 return help;
211 }
212
214 FXString tolowerString(const FXString& str) const;
215
218 long onPaint(FXObject*, FXSelector, void*);
219 long onEnter(FXObject*, FXSelector, void*);
220 long onLeave(FXObject*, FXSelector, void*);
221 long onUngrabbed(FXObject*, FXSelector, void*);
222 long onKeyPress(FXObject*, FXSelector, void*);
223 long onKeyRelease(FXObject*, FXSelector, void*);
224 long onLeftBtnPress(FXObject*, FXSelector, void*);
225 long onLeftBtnRelease(FXObject*, FXSelector, void*);
226 long onRightBtnPress(FXObject*, FXSelector, void*);
227 long onRightBtnRelease(FXObject*, FXSelector, void*);
228 long onMotion(FXObject*, FXSelector, void*);
229 long onFocusIn(FXObject*, FXSelector, void*);
230 long onFocusOut(FXObject*, FXSelector, void*);
231 long onAutoScroll(FXObject*, FXSelector, void*);
232 long onClicked(FXObject*, FXSelector, void*);
233 long onDoubleClicked(FXObject*, FXSelector, void*);
234 long onTripleClicked(FXObject*, FXSelector, void*);
235 long onCommand(FXObject*, FXSelector, void*);
236 long onQueryTip(FXObject*, FXSelector, void*);
237 long onQueryHelp(FXObject*, FXSelector, void*);
238 long onTipTimer(FXObject*, FXSelector, void*);
239 long onLookupTimer(FXObject*, FXSelector, void*);
241
242protected:
244 MFXListIcon();
245
247 void recompute();
248
250 MFXListIconItem* createItem(const FXString& text, FXIcon* icon, void* ptr);
251
253 std::vector<MFXListIconItem*> items;
254
256 std::vector<MFXListIconItem*> itemFiltered;
257
259 FXint anchor = -1;
260
263
265 FXint extent = -1;
266
269
272
274 FXFont* font = nullptr;
275
277 FXColor textColor = 0;
278
280 FXColor selbackColor = 0;
281
283 FXColor seltextColor = 0;
284
286 FXint listWidth = 0;
287
289 FXint listHeight = 0;
290
292 FXint visible = 0;
293
295 FXString help;
296
298 FXint grabx = 0;
299
301 FXint graby = 0;
302
304 FXString lookup;
305
307 FXbool state = FALSE;
308
310 FXString filter;
311
312private:
314 typedef FXint(*FXCompareFunc)(const FXString&, const FXString&, FXint);
315
317 bool showItem(const FXString& itemName) const;
318
320 MFXListIcon(const FXList&) = delete;
321
323 MFXListIcon& operator = (const FXList&) = delete;
324};
A list item which allows for custom coloring.
Definition MFXListIcon.h:30
long onDoubleClicked(FXObject *, FXSelector, void *)
FXint listWidth
List width.
FXint getDefaultWidth()
Return default width.
void recalc()
Recalculate layout.
MFXListIcon(const FXList &)=delete
invalidate copy constructor
long onKeyRelease(FXObject *, FXSelector, void *)
long onRightBtnPress(FXObject *, FXSelector, void *)
long onCommand(FXObject *, FXSelector, void *)
FXint getNumVisible() const
Return number of visible items.
Definition MFXListIcon.h:85
FXint setItem(FXint index, MFXListIconItem *item, FXbool notify=FALSE)
Replace the item with a [possibly subclassed] item.
long onQueryTip(FXObject *, FXSelector, void *)
void setNumVisible(FXint nvis)
Change the number of visible items.
void makeItemVisible(MFXListIconItem *item)
Scroll to bring item into view.
long onAutoScroll(FXObject *, FXSelector, void *)
FXbool state
State of item.
long onClicked(FXObject *, FXSelector, void *)
FXint getDefaultHeight()
Return default height.
long onTripleClicked(FXObject *, FXSelector, void *)
FXint editItem(FXint index, const FXString &text, FXIcon *icon=NULL, void *ptr=NULL, FXbool notify=FALSE)
Replace items text, icon, and user-data pointer.
int findItem(const FXString &text) const
Search items by name (In all items)
MFXListIconItem * getCursorItem() const
Get item under the cursor, if any.
void updateItem(MFXListIconItem *item) const
Repaint item.
FXint getItemHeight(FXint index) const
Return item height.
FXString tolowerString(const FXString &str) const
tolower string
FXint getContentWidth()
Compute and return content width.
FXint getNumItems() const
Return the number of items in the list.
Definition MFXListIcon.h:80
MFXListIconItem * cursor
Cursor item.
FXbool selectItem(MFXListIconItem *item, FXbool notify=FALSE)
Select item by index.
FXbool killSelection(FXbool notify=FALSE)
Deselect all items.
FXint appendItem(MFXListIconItem *item, FXbool notify=FALSE)
Append a [possibly subclassed] item to the list.
FXint getItemWidth(FXint index) const
Return item width.
std::vector< MFXListIconItem * > itemFiltered
Selected item list.
long onUngrabbed(FXObject *, FXSelector, void *)
FXColor seltextColor
Selected text color.
bool canFocus() const
List widget can receive focus.
MFXListIconItem * createItem(const FXString &text, FXIcon *icon, void *ptr)
create item
void setFocus()
Move the focus to this window.
FXFont * getFont() const
Return text font.
FXFont * font
Font.
FXbool isItemCurrent(FXint index) const
Return TRUE if item is current.
void killFocus()
Remove the focus from this window.
long onLeftBtnPress(FXObject *, FXSelector, void *)
FXint hitItem(MFXListIconItem *item, FXint x, FXint y) const
Return item hit code: 0 no hit; 1 hit the icon; 2 hit the text.
long onEnter(FXObject *, FXSelector, void *)
FXint getCurrentItemIndex() const
Return current item, if any.
bool showItem(const FXString &itemName) const
check if filter element
FXColor selbackColor
Selected back color.
long onLookupTimer(FXObject *, FXSelector, void *)
FXint grabx
Grab point x.
FXint getContentHeight()
Return content height.
const FXString & getHelpText() const
Get the status line help text for this list.
long onLeave(FXObject *, FXSelector, void *)
FXString help
Help text.
long onTipTimer(FXObject *, FXSelector, void *)
FXint listHeight
List height.
FXint getAnchorItem() const
Return anchor item, if any.
MFXListIconItem * currentItem
Current item.
void recompute()
recompute list
FXint visible
Number of rows high.
void setHelpText(const FXString &text)
Set the status line help text for this list.
FXint extent
Extent item.
FXColor getTextColor() const
Return normal text color.
FXString lookup
Lookup string.
FXbool toggleItem(MFXListIconItem *item, FXbool notify=FALSE)
Toggle item selection state.
MFXListIconItem * viewable
Viewable item.
void setAnchorItem(MFXListIconItem *item)
Change anchor item.
void setFilter(const FXString &value, FXLabel *label)
filter items in list
FXint(* FXCompareFunc)(const FXString &, const FXString &, FXint)
typedef used for comparing elements
MFXListIconItem * getItem(FXint index) const
Return the item at the given index.
FXbool deselectItem(MFXListIconItem *item, FXbool notify=FALSE)
Deselect item.
MFXListIcon()
FOX need this.
std::vector< MFXListIconItem * > items
Item list.
FXString filter
filter
void detach()
Detach server-side resources.
long onPaint(FXObject *, FXSelector, void *)
long onRightBtnRelease(FXObject *, FXSelector, void *)
FXColor getSelBackColor() const
Return selected text background.
void setTextColor(FXColor clr)
Change normal text color.
void layout()
Perform layout.
~MFXListIcon()
Destructor.
long onKeyPress(FXObject *, FXSelector, void *)
void clearItems(FXbool notify=FALSE)
Remove all items from list.
FXbool isItemVisible(MFXListIconItem *item) const
Return TRUE if item is visible.
MFXListIcon & operator=(const FXList &)=delete
invalidate assignement operator
long onFocusOut(FXObject *, FXSelector, void *)
void removeItem(FXint index, FXbool notify=FALSE)
Remove node from list.
FXint anchor
Anchor item.
MFXListIconItem * getItemAt(FXint y) const
Return index of item at y, if any.
FXColor getSelTextColor() const
Return selected text color.
long onQueryHelp(FXObject *, FXSelector, void *)
FXint graby
Grab point y.
void create()
Create server-side resources.
void setCurrentItem(MFXListIconItem *item, FXbool notify=FALSE)
Change current item.
long onLeftBtnRelease(FXObject *, FXSelector, void *)
FXint getViewableItem() const
Return viewable item, if any.
FXint insertItem(FXint index, MFXListIconItem *item, FXbool notify=FALSE)
Insert a new [possibly subclassed] item at the give index.
long onMotion(FXObject *, FXSelector, void *)
long onFocusIn(FXObject *, FXSelector, void *)
FXColor textColor
Text color.