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 
29 class MFXListItem : public FXListItem {
31  FXDECLARE(MFXListItem)
32 
33 public:
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 
43 protected:
45  MFXListItem();
46 
49 };
50 
51 
53 class MFXIconComboBox : public FXPacker {
55  FXDECLARE(MFXIconComboBox)
56 
57 public:
59  enum {
60  ID_LIST = FXPacker::ID_LAST,
62  ID_LAST
63  };
64 
66  MFXIconComboBox(FXComposite* p, FXint cols, 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 setNumVisible(FXint nvis);
124 
126  FXbool isItemCurrent(FXint index) const;
127 
129  void setCurrentItem(FXint index, FXbool notify = FALSE);
130 
132  FXint getCurrentItem() const;
133 
135  FXString getItem(FXint index) const;
136 
138  FXint setIconItem(FXint index, const FXString& text, FXIcon* icon = nullptr, FXColor bgColor = FXRGB(255, 255, 255), void* ptr = nullptr);
139 
141  FXint insertIconItem(FXint index, const FXString& text, FXIcon* icon = nullptr, FXColor bgColor = FXRGB(255, 255, 255), void* ptr = nullptr);
142 
144  FXint appendIconItem(const FXString& text, FXIcon* icon = nullptr, FXColor bgColor = FXRGB(255, 255, 255), void* ptr = nullptr);
145 
147  bool setItem(const FXString& text, FXIcon* icon);
148 
150  FXint prependItem(const FXString& text, void* ptr = NULL);
151 
153  FXint moveItem(FXint newindex, FXint oldindex);
154 
156  void removeItem(FXint index);
157 
159  void clearItems();
160 
171  FXint findItem(const FXString& text, FXint start = -1, FXuint flags = SEARCH_FORWARD | SEARCH_WRAP) const;
172 
180  FXint findItemByData(const void* ptr, FXint start = -1, FXuint flags = SEARCH_FORWARD | SEARCH_WRAP) const;
181 
183  FXString getItemText(FXint index) const;
184 
186  void setItemData(FXint index, void* ptr) const;
187 
189  void* getItemData(FXint index) const;
190 
192  FXbool isPaneShown() const;
193 
195  void sortItems();
196 
198  void setFont(FXFont* fnt);
199 
201  FXFont* getFont() const;
202 
204  void setComboStyle(FXuint mode);
205 
207  FXuint getComboStyle() const;
208 
210  virtual void setBackColor(FXColor clr);
211 
213  FXColor getBackColor() const;
214 
216  void setTextColor(FXColor clr);
217 
219  FXColor getTextColor() const;
220 
222  void setSelBackColor(FXColor clr);
223 
225  FXColor getSelBackColor() const;
226 
228  void setSelTextColor(FXColor clr);
229 
231  FXColor getSelTextColor() const;
232 
234  FXListSortFunc getSortFunc() const;
235 
237  void setSortFunc(FXListSortFunc func);
238 
240  void setHelpText(const FXString& txt);
241 
243  const FXString& getHelpText() const;
244 
246  void setTipText(const FXString& txt);
247 
249  const FXString& getTipText() const;
250 
253  long onFocusUp(FXObject*, FXSelector, void*);
254  long onFocusDown(FXObject*, FXSelector, void*);
255  long onFocusSelf(FXObject*, FXSelector, void*);
256  long onMouseWheel(FXObject*, FXSelector, void*);
257  long onTextButton(FXObject*, FXSelector, void*);
258  long onTextChanged(FXObject*, FXSelector, void*);
259  long onTextCommand(FXObject*, FXSelector, void*);
260  long onListClicked(FXObject*, FXSelector, void*);
261  long onFwdToText(FXObject*, FXSelector, void*);
262  long onUpdFmText(FXObject*, FXSelector, void*);
264 
265 protected:
267  MFXIconComboBox();
268 
270  FXLabel* myIconLabel = nullptr;
271 
274 
276  FXMenuButton* myButton = nullptr;
277 
279  FXList* myList = nullptr;
280 
282  FXPopup* myPane = nullptr;
283 
284 private:
287 
290 };
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.
MFXIconComboBox & operator=(const MFXIconComboBox &)=delete
invalidate assignment operator
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.
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
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.
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.
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)