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