Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/utils/foxtools/MFXComboBoxIcon.h
169678 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2006-2025 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
/****************************************************************************/
14
/// @file MFXComboBoxIcon.h
15
/// @author Jakob Erdmann
16
/// @author Pablo Alvarez Lopez
17
/// @date 2018-12-19
18
///
19
// ComboBox with search field and icons
20
/****************************************************************************/
21
#pragma once
22
#include <config.h>
23
24
#include "fxheader.h"
25
26
// ===========================================================================
27
// class declaration
28
// ===========================================================================
29
30
class MFXListIcon;
31
class MFXStaticToolTip;
32
class MFXTextFieldIcon;
33
class MFXTextFieldSearch;
34
35
// ===========================================================================
36
// class definitions
37
// ===========================================================================
38
39
class MFXComboBoxIcon : public FXPacker {
40
/// @brief FOX declaration
41
FXDECLARE(MFXComboBoxIcon)
42
43
public:
44
/// @brief enum for ID
45
enum {
46
ID_LIST = FXPacker::ID_LAST,
47
ID_TEXT,
48
ID_SEARCH,
49
ID_LAST
50
};
51
52
/// @brief Construct a Combo Box widget with room to display cols columns of text
53
MFXComboBoxIcon(FXComposite* p, MFXStaticToolTip* staticToolTip, const bool canSearch,
54
const int visibleItems, FXObject* tgt, FXSelector sel, FXuint opts,
55
FXint x = 0, FXint y = 0, FXint w = 0, FXint h = 0,
56
FXint pl = DEFAULT_PAD, FXint pr = DEFAULT_PAD, FXint pt = DEFAULT_PAD, FXint pb = DEFAULT_PAD);
57
58
/// @brief Destructor
59
~MFXComboBoxIcon();
60
61
/// @brief Create server-side resources
62
void create();
63
64
/// @brief Detach server-side resources
65
void detach();
66
67
/// @brief Destroy server-side resources
68
void destroy();
69
70
/// @brief Enable combo box
71
void enable();
72
73
/// @brief Disable combo box
74
void disable();
75
76
/// @brief Return default width
77
FXint getDefaultWidth();
78
79
/// @brief Return default height
80
FXint getDefaultHeight();
81
82
/// @brief Perform layout
83
void layout();
84
85
/// @brief Get the text
86
FXString getText() const;
87
88
/// @brief Return the number of items in the list
89
FXint getNumItems() const;
90
91
/// @brief Set the number of visible items in the drop down list
92
void setNumVisible(FXint nvis);
93
94
/// @brief Set the text in the textField
95
void setText(const FXString& text, FXbool notify = FALSE);
96
97
/// @brief Return true if current item
98
FXbool isItemCurrent(FXint index) const;
99
100
/// @brief Set the current item (index is zero-based)
101
long setCurrentItem(const FXint index, FXbool notify = FALSE);
102
103
/// @brief Set the current item
104
long setCurrentItem(const FXString& text, FXbool notify = FALSE);
105
106
/// @brief Get the current item's index
107
FXint getCurrentItem() const;
108
109
/// @brief Replace the item at index
110
FXint updateIconItem(FXint index, const FXString& text, FXIcon* icon = nullptr, FXColor bgColor = FXRGB(255, 255, 255), void* ptr = nullptr);
111
112
/// @brief insert icon item in the given position
113
FXint insertIconItem(FXint index, const FXString& text, FXIcon* icon = nullptr, FXColor bgColor = FXRGB(255, 255, 255), void* ptr = nullptr);
114
115
/// @brief append icon item in the last position
116
FXint appendIconItem(const FXString& text, FXIcon* icon = nullptr, FXColor bgColor = FXRGB(255, 255, 255), void* ptr = nullptr);
117
118
/// @brief Remove this item from the list
119
void removeItem(FXint index);
120
121
/// @brief Remove all items from the list
122
virtual void clearItems();
123
124
/// @brief find item
125
FXint findItem(const FXString& text) const;
126
127
/// @brief Get text for specified item
128
std::string getItemText(FXint index) const;
129
130
/// @brief Set window background color
131
void setBackColor(FXColor clr);
132
133
/// @brief Change text color
134
void setTextColor(FXColor clr);
135
136
/// @brief Return text color
137
FXColor getTextColor() const;
138
139
/// @brief Set the tool tip message for this combobox
140
void setTipText(const FXString& txt);
141
142
/// @brief Get the tool tip message for this combobox
143
const FXString& getTipText() const;
144
145
/// @brief Commands
146
/// @{
147
148
long onFocusUp(FXObject*, FXSelector, void*);
149
long onFocusDown(FXObject*, FXSelector, void*);
150
long onFocusSelf(FXObject*, FXSelector, void*);
151
long onMouseWheel(FXObject*, FXSelector, void*);
152
long onTextButton(FXObject*, FXSelector, void*);
153
long onTextChanged(FXObject*, FXSelector, void*);
154
long onTextCommand(FXObject*, FXSelector, void*);
155
long onListClicked(FXObject*, FXSelector, void*);
156
long onFwdToText(FXObject*, FXSelector, void*);
157
long onUpdFmText(FXObject*, FXSelector, void*);
158
long onCmdFilter(FXObject*, FXSelector, void*);
159
160
/// @}
161
162
protected:
163
/// @brief FOX need this
164
MFXComboBoxIcon();
165
166
/// @brief textField icon
167
MFXTextFieldIcon* myTextFieldIcon = nullptr;
168
169
/// @brief myButton
170
FXMenuButton* myButton = nullptr;
171
172
/// @brief list with all items
173
MFXListIcon* myList = nullptr;
174
175
/// @brief text field search
176
MFXTextFieldSearch* myTextFieldSearch = nullptr;
177
178
/// @brief popup in which place search label and list
179
FXPopup* myPane = nullptr;
180
181
/// @brief no items label
182
FXLabel* myNoItemsLabel = nullptr;
183
184
private:
185
/// @brief invalidate copy constructor
186
MFXComboBoxIcon(const MFXComboBoxIcon&) = delete;
187
188
/// @brief invalidate assignment operator
189
MFXComboBoxIcon& operator=(const MFXComboBoxIcon&) = delete;
190
};
191
192