/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2006-2025 German Aerospace Center (DLR) and others.3// This program and the accompanying materials are made available under the4// terms of the Eclipse Public License 2.0 which is available at5// https://www.eclipse.org/legal/epl-2.0/6// This Source Code may also be made available under the following Secondary7// Licenses when the conditions for such availability set forth in the Eclipse8// Public License 2.0 are satisfied: GNU General Public License, version 29// or later which is available at10// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later12/****************************************************************************/13/// @file MFXListIcon.h14/// @author Pablo Alvarez Lopez15/// @date Feb 202316///17//18/****************************************************************************/19#pragma once20#include <config.h>2122#include <vector>2324#include "fxheader.h"2526// ===========================================================================27// class declaration28// ===========================================================================2930class MFXListIconItem;3132// ===========================================================================33// class definitions34// ===========================================================================3536/// @brief A list item which allows for custom coloring37class MFXListIcon : public FXScrollArea {38/// @brief FOX declaration39FXDECLARE(MFXListIcon)4041public:42enum {43ID_LOOKUPTIMER = FXScrollArea::ID_LAST,44ID_LAST45};4647/// @brief Construct a list with initially no items in it48MFXListIcon(FXComposite* p, FXObject* tgt = NULL, FXSelector sel = 0, FXuint opts = LIST_NORMAL, FXint x = 0, FXint y = 0, FXint w = 0, FXint h = 0);4950/// @brief Destructor51~MFXListIcon();5253/// @brief Create server-side resources54void create();5556/// @brief Detach server-side resources57void detach();5859/// @brief Perform layout60void layout();6162/// @brief Return default width63FXint getDefaultWidth();6465/// @brief Return default height66FXint getDefaultHeight();6768/// @brief Compute and return content width69FXint getContentWidth();7071/// @brief Return content height72FXint getContentHeight();7374/// @brief Recalculate layout75void recalc();7677/// @brief List widget can receive focus78bool canFocus() const;7980/// @brief Move the focus to this window81void setFocus();8283/// @brief Remove the focus from this window84void killFocus();8586/// @brief Return the number of items in the list87FXint getNumItems() const {88return (int)items.size();89}9091/// @brief Return number of visible items92FXint getNumVisible() const {93return visible;94}9596/// @brief Change the number of visible items97void setNumVisible(FXint nvis);9899/// @brief Return the item at the given index100MFXListIconItem* getItem(FXint index) const;101102/// @brief Replace the item with a [possibly subclassed] item103FXint setItem(FXint index, MFXListIconItem* item, FXbool notify = FALSE);104105/// @brief Replace items text, icon, and user-data pointer106FXint editItem(FXint index, const FXString& text, FXIcon* icon = NULL, void* ptr = NULL, FXbool notify = FALSE);107108/// @brief Insert a new [possibly subclassed] item at the give index109FXint insertItem(FXint index, MFXListIconItem* item, FXbool notify = FALSE);110111/// @brief Insert item at index with given text, icon, and user-data pointer112FXint insertItem(FXint index, const FXString& text, FXIcon* icon = NULL, void* ptr = NULL, FXbool notify = FALSE);113114/// @brief Append a [possibly subclassed] item to the list115FXint appendItem(MFXListIconItem* item, FXbool notify = FALSE);116117/// @brief Append new item with given text and optional icon, and user-data pointer118FXint appendItem(const FXString& text, FXIcon* icon = NULL, void* ptr = NULL, FXbool notify = FALSE);119120/// @brief Remove node from list121void removeItem(FXint index, FXbool notify = FALSE);122123/// @brief Remove all items from list124void clearItems(FXbool notify = FALSE);125126/// @brief filter items in list127void setFilter(const FXString& value, FXLabel* label);128129/// @brief Return item width130FXint getItemWidth(FXint index) const;131132/// @brief Return item height133FXint getItemHeight(FXint index) const;134135/// @brief Return index of item at y, if any136MFXListIconItem* getItemAt(FXint y) const;137138/// @brief Search items by name (In all items)139int findItem(const FXString& text) const;140141/// @brief Return item hit code: 0 no hit; 1 hit the icon; 2 hit the text142FXint hitItem(MFXListIconItem* item, FXint x, FXint y) const;143144/// @brief Scroll to bring item into view145void makeItemVisible(MFXListIconItem* item);146147/// @brief Scroll to bring item into view148void makeItemVisible(FXint index);149150/// @brief Return TRUE if item is current151FXbool isItemCurrent(FXint index) const;152153/// @brief Return TRUE if item is visible154FXbool isItemVisible(MFXListIconItem* item) const;155156/// @brief Repaint item157void updateItem(MFXListIconItem* item) const;158159/// @brief Select item by index160FXbool selectItem(MFXListIconItem* item, FXbool notify = FALSE);161162/// @brief Deselect item163FXbool deselectItem(MFXListIconItem* item, FXbool notify = FALSE);164165/// @brief Toggle item selection state166FXbool toggleItem(MFXListIconItem* item, FXbool notify = FALSE);167168/// @brief Deselect all items169FXbool killSelection(FXbool notify = FALSE);170171/// @brief Change current item172void setCurrentItem(MFXListIconItem* item, FXbool notify = FALSE);173174/// @brief Return current item, if any175FXint getCurrentItemIndex() const;176177/// @brief Return viewable item, if any178FXint getViewableItem() const;179180/// @brief Change anchor item181void setAnchorItem(MFXListIconItem* item);182183/// @brief Return anchor item, if any184FXint getAnchorItem() const;185186/// @brief Get item under the cursor, if any187MFXListIconItem* getCursorItem() const;188189/// @brief Return text font190FXFont* getFont() const {191return font;192}193194/// @brief Return normal text color195FXColor getTextColor() const {196return textColor;197}198199/// @brief Change normal text color200void setTextColor(FXColor clr);201202/// @brief Return selected text background203FXColor getSelBackColor() const {204return selbackColor;205}206207/// @brief Return selected text color208FXColor getSelTextColor() const {209return seltextColor;210}211212/// @brief Set the status line help text for this list213void setHelpText(const FXString& text);214215/// @brief Get the status line help text for this list216const FXString& getHelpText() const {217return help;218}219220/// @brief tolower string221FXString tolowerString(const FXString& str) const;222223/// @name call functions224/// @{225long onPaint(FXObject*, FXSelector, void*);226long onEnter(FXObject*, FXSelector, void*);227long onLeave(FXObject*, FXSelector, void*);228long onUngrabbed(FXObject*, FXSelector, void*);229long onKeyPress(FXObject*, FXSelector, void*);230long onKeyRelease(FXObject*, FXSelector, void*);231long onLeftBtnPress(FXObject*, FXSelector, void*);232long onLeftBtnRelease(FXObject*, FXSelector, void*);233long onRightBtnPress(FXObject*, FXSelector, void*);234long onRightBtnRelease(FXObject*, FXSelector, void*);235long onMotion(FXObject*, FXSelector, void*);236long onFocusIn(FXObject*, FXSelector, void*);237long onFocusOut(FXObject*, FXSelector, void*);238long onAutoScroll(FXObject*, FXSelector, void*);239long onClicked(FXObject*, FXSelector, void*);240long onDoubleClicked(FXObject*, FXSelector, void*);241long onTripleClicked(FXObject*, FXSelector, void*);242long onCommand(FXObject*, FXSelector, void*);243long onQueryTip(FXObject*, FXSelector, void*);244long onQueryHelp(FXObject*, FXSelector, void*);245long onTipTimer(FXObject*, FXSelector, void*);246long onLookupTimer(FXObject*, FXSelector, void*);247/// @}248249protected:250/// @brief @brief FOX need this251MFXListIcon();252253/// @brief @brief recompute list254void recompute();255256/// @brief @brief create item257MFXListIconItem* createItem(const FXString& text, FXIcon* icon, void* ptr);258259/// @brief Item list260std::vector<MFXListIconItem*> items;261262/// @brief Selected item list263std::vector<MFXListIconItem*> itemFiltered;264265/// @brief Anchor item266FXint anchor = -1;267268/// @brief Current item269MFXListIconItem* currentItem = nullptr;270271/// @brief Extent item272FXint extent = -1;273274/// @brief Cursor item275MFXListIconItem* cursor = nullptr;276277/// @brief Viewable item278MFXListIconItem* viewable = nullptr;279280/// @brief Font281FXFont* font = nullptr;282283/// @brief Text color284FXColor textColor = 0;285286/// @brief Selected back color287FXColor selbackColor = 0;288289/// @brief Selected text color290FXColor seltextColor = 0;291292/// @brief List width293FXint listWidth = 0;294295/// @brief List height296FXint listHeight = 0;297298/// @brief Number of rows high299FXint visible = 0;300301/// @brief Help text302FXString help;303304/// @brief Grab point x305FXint grabx = 0;306307/// @brief Grab point y308FXint graby = 0;309310/// @brief Lookup string311FXString lookup;312313/// @brief State of item314FXbool state = FALSE;315316/// @brief filter317FXString filter;318319private:320/// @brief typedef used for comparing elements321typedef FXint(*FXCompareFunc)(const FXString&, const FXString&, FXint);322323/// @brief check if filter element324bool showItem(const FXString& itemName) const;325326/// @brief @brief invalidate copy constructor327MFXListIcon(const FXList&) = delete;328329/// @brief @brief invalidate assignement operator330MFXListIcon& operator = (const FXList&) = delete;331};332333334