Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MFXComboBoxIcon.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2006-2023 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/* =========================================================================
23 * included modules
24 * ======================================================================= */
25#include "MFXComboBoxIcon.h"
26#include "MFXListItemIcon.h"
27
28
29#define ICON_SPACING 4 // Spacing between icon and label (2 + 2)
30#define ICON_SIZE 16
31#define COMBOBOX_INS_MASK (COMBOBOX_REPLACE | COMBOBOX_INSERT_BEFORE | COMBOBOX_INSERT_AFTER | COMBOBOX_INSERT_FIRST | COMBOBOX_INSERT_LAST)
32#define COMBOBOX_MASK (COMBOBOX_STATIC | COMBOBOX_INS_MASK)
33
34// ===========================================================================
35// FOX callback mapping
36// ===========================================================================
37
38FXDEFMAP(MFXComboBoxIcon) MFXComboBoxIconMap[] = {
39 FXMAPFUNC(SEL_FOCUS_UP, 0, MFXComboBoxIcon::onFocusUp),
40 FXMAPFUNC(SEL_FOCUS_DOWN, 0, MFXComboBoxIcon::onFocusDown),
41 FXMAPFUNC(SEL_FOCUS_SELF, 0, MFXComboBoxIcon::onFocusSelf),
45 FXMAPFUNC(SEL_LEFTBUTTONPRESS, MFXComboBoxIcon::ID_TEXT, MFXComboBoxIcon::onTextButton),
49 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_SETVALUE, MFXComboBoxIcon::onFwdToText),
50 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_SETINTVALUE, MFXComboBoxIcon::onFwdToText),
51 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_SETREALVALUE, MFXComboBoxIcon::onFwdToText),
52 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_SETSTRINGVALUE, MFXComboBoxIcon::onFwdToText),
53 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_GETINTVALUE, MFXComboBoxIcon::onFwdToText),
54 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_GETREALVALUE, MFXComboBoxIcon::onFwdToText),
55 FXMAPFUNC(SEL_COMMAND, FXWindow::ID_GETSTRINGVALUE, MFXComboBoxIcon::onFwdToText),
56};
57
58// Object implementation
59FXIMPLEMENT(MFXComboBoxIcon, FXPacker, MFXComboBoxIconMap, ARRAYNUMBER(MFXComboBoxIconMap))
60
61// ===========================================================================
62// member method definitions
63// ===========================================================================
64
65MFXComboBoxIcon::MFXComboBoxIcon(FXComposite* p, FXint cols, const bool haveIcons, FXObject* tgt, FXSelector sel, FXuint opts, FXint x, FXint y, FXint w, FXint h, FXint pl, FXint pr, FXint pt, FXint pb):
66 FXPacker(p, opts, x, y, w, h, 0, 0, 0, 0, 0, 0),
67 myHaveIcons(haveIcons) {
68 flags |= FLAG_ENABLED;
69 target = tgt;
70 message = sel;
71 myIconLabel = new FXLabel(this, "", nullptr, 0, 0, 0, 0, 0, pl, pr, pt, pb);
72 if (!myHaveIcons) {
73 myIconLabel->hide();
74 }
75 myTextFieldIcon = new MFXTextFieldIcon(this, cols, this, MFXComboBoxIcon::ID_TEXT, 0, 0, 0, 0, 0, pl, pr, pt, pb);
76 if (options & COMBOBOX_STATIC) {
77 myTextFieldIcon->setEditable(FALSE);
78 }
79 myPane = new FXPopup(this, FRAME_LINE);
80 myList = new MFXListIcon(myPane, this, MFXComboBoxIcon::ID_LIST, LIST_BROWSESELECT | LIST_AUTOSELECT | LAYOUT_FILL_X | LAYOUT_FILL_Y | SCROLLERS_TRACK | HSCROLLER_NEVER);
81 if (options & COMBOBOX_STATIC) {
82 myList->setScrollStyle(SCROLLERS_TRACK | HSCROLLING_OFF);
83 }
84 myButton = new FXMenuButton(this, FXString::null, NULL, myPane, FRAME_RAISED | FRAME_THICK | MENUBUTTON_DOWN | MENUBUTTON_ATTACH_RIGHT, 0, 0, 0, 0, 0, 0, 0, 0);
85 myButton->setXOffset(border);
86 myButton->setYOffset(border);
87 flags &= ~FLAG_UPDATE; // Never GUI update
88}
89
90
92 delete myPane;
93 myPane = (FXPopup*) - 1L;
94 myIconLabel = (FXLabel*) - 1L;
96 myButton = (FXMenuButton*) - 1L;
97 myList = (MFXListIcon*) - 1L;
98}
99
100
101void
103 FXPacker::create();
104 myPane->create();
105}
106
107
108void
110 FXPacker::detach();
111 myPane->detach();
112}
113
114
115void
117 myPane->destroy();
118 FXPacker::destroy();
119}
120
121
122void
124 if (!isEnabled()) {
125 FXPacker::enable();
126 myIconLabel->enable();
127 myTextFieldIcon->enable();
128 myButton->enable();
129 }
130}
131
132
133void
135 if (isEnabled()) {
136 FXPacker::disable();
137 myIconLabel->disable();
138 myTextFieldIcon->disable();
139 myButton->disable();
140 }
141}
142
143
144FXint
146 FXint ww, pw;
147 if (myIconLabel->shown()) {
148 ww = myIconLabel->getDefaultWidth() + myTextFieldIcon->getDefaultWidth() + myButton->getDefaultWidth() + (border << 1);
149 } else {
150 ww = myTextFieldIcon->getDefaultWidth() + myButton->getDefaultWidth() + (border << 1);
151 }
152 pw = myPane->getDefaultWidth();
153 return FXMAX(ww, pw);
154}
155
156
157FXint
159 FXint th, bh;
160 th = myTextFieldIcon->getDefaultHeight();
161 bh = myButton->getDefaultHeight();
162 return FXMAX(th, bh) + (border << 1);
163}
164
165
166void
168 const FXint itemHeight = height - (border << 1);
169 const FXint iconSize = myHaveIcons ? itemHeight : 0;
170 const FXint buttonWidth = myButton->getDefaultWidth();
171 const FXint textWidth = width - buttonWidth - iconSize - (border << 1);
172 myIconLabel->position(border, border, iconSize, iconSize);
173 myTextFieldIcon->position(border + iconSize, border, textWidth, itemHeight);
174 myButton->position(border + textWidth + iconSize, border, buttonWidth, itemHeight);
175
176 int size = -1;
177 for (int i = 0; i < myList->getNumItems(); i++) {
178 if (myList->getItemWidth(i) > size) {
179 size = myList->getItemWidth(i);
180 }
181 }
182 myPane->resize(size + 17, myPane->getDefaultHeight());
183 flags &= ~FLAG_DIRTY;
184}
185
186
187FXbool
189 return myTextFieldIcon->isEditable();
190}
191
192
193void
195 myTextFieldIcon->setEditable(edit);
196}
197
198
199FXString
201 return myTextFieldIcon->getText();
202}
203
204
205void
207 myTextFieldIcon->setNumColumns(cols);
208}
209
210
211FXint
213 return myTextFieldIcon->getNumColumns();
214}
215
216
217FXint
219 return myList->getNumItems();
220}
221
222
223FXint
225 return myList->getNumVisible();
226}
227
228
229void
231 myTextFieldIcon->setText(text);
232}
233
234
235void
237 myList->setNumVisible(nvis);
238}
239
240
241FXbool
243 return myList->isItemCurrent(index);
244}
245
246
247void
248MFXComboBoxIcon::setCurrentItem(FXint index, FXbool notify) {
249 FXint current = myList->getCurrentItem();
250 if (current != index) {
251 myList->setCurrentItem(index);
252 myList->makeItemVisible(index);
253 if (0 <= index) {
254 // cast MFXListItemIcon
255 const MFXListItemIcon* item = dynamic_cast<MFXListItemIcon*>(myList->getItem(index));
256 // set icon and background color
257 if (item) {
258 myTextFieldIcon->setText(item->getText());
259 myTextFieldIcon->setBackColor(item->getBackGroundColor());
260 myIconLabel->setIcon(item->getIcon());
261 myIconLabel->setBackColor(item->getBackGroundColor());
262 } else {
264 myTextFieldIcon->setBackColor(FXRGB(255, 255, 255));
265 myIconLabel->setIcon(nullptr);
266 myIconLabel->setBackColor(FXRGB(255, 255, 255));
267 }
268 } else {
270 }
271 if (notify && target) {
272 target->tryHandle(this, FXSEL(SEL_COMMAND, message), (void*)getText().text());
273 }
274 }
275}
276
277
278FXint
280 return myList->getCurrentItem();
281}
282
283
284FXString
285MFXComboBoxIcon::getItem(FXint index) const {
286 return myList->getItem(index)->getText();
287}
288
289
290FXint
291MFXComboBoxIcon::setIconItem(FXint index, const FXString& text, FXIcon* icon, FXColor bgColor, void* ptr) {
292 if (index < 0 || myList->getNumItems() <= index) {
293 fxerror("%s::setItem: index out of range.\n", getClassName());
294 }
295 myList->setItem(index, text, NULL, ptr);
296 if (isItemCurrent(index)) {
297 myTextFieldIcon->setText(text);
298 myTextFieldIcon->setBackColor(bgColor);
299 myIconLabel->setIcon(icon);
300 myIconLabel->setBackColor(bgColor);
301 }
302 recalc();
303 return index;
304}
305
306
307FXint
308MFXComboBoxIcon::insertIconItem(FXint index, const FXString& text, FXIcon* icon, FXColor bgColor, void* ptr) {
309 if (index < 0 || myList->getNumItems() < index) {
310 fxerror("%s::insertItem: index out of range.\n", getClassName());
311 }
312 myList->insertItem(index, text, NULL, ptr);
313 if (isItemCurrent(index)) {
314 myTextFieldIcon->setText(text);
315 myTextFieldIcon->setBackColor(bgColor);
316 myIconLabel->setIcon(icon);
317 myIconLabel->setBackColor(bgColor);
318 }
319 recalc();
320 return index;
321}
322
323
324FXint
325MFXComboBoxIcon::appendIconItem(const FXString& text, FXIcon* icon, FXColor bgColor, void* ptr) {
326 FXint index = myList->appendItem(new MFXListItemIcon(text, icon, bgColor, ptr));
327 if (isItemCurrent(getNumItems() - 1)) {
328 myTextFieldIcon->setText(text);
329 myTextFieldIcon->setBackColor(bgColor);
330 myIconLabel->setIcon(icon);
331 myIconLabel->setBackColor(bgColor);
332 }
333 recalc();
334 return index;
335}
336
337
338bool
339MFXComboBoxIcon::setItem(const FXString& text, FXIcon* icon) {
340 for (int i = 0; i < myList->getNumItems(); i++) {
341 // cast MFXListItemIcon
342 const MFXListItemIcon* item = dynamic_cast<MFXListItemIcon*>(myList->getItem(i));
343 // set icon and background color
344 if (item && (item->getText() == text) && (item->getIcon() == icon)) {
345 myTextFieldIcon->setText(item->getText());
346 myTextFieldIcon->setBackColor(item->getBackGroundColor());
347 myIconLabel->setIcon(item->getIcon());
348 myIconLabel->setBackColor(item->getBackGroundColor());
349 myTextFieldIcon->setTextColor(FXRGB(0, 0, 0));
350 return true;
351 }
352 }
353 return false;
354}
355
356
357void
358MFXComboBoxIcon::setCustomText(const FXString text) {
359 myTextFieldIcon->setText(text);
360 myTextFieldIcon->setTextColor(FXRGB(128, 128, 128));
361}
362
363
364FXint
365MFXComboBoxIcon::prependItem(const FXString& text, void* ptr) {
366 FXint index = myList->prependItem(text, NULL, ptr);
367 if (isItemCurrent(0)) {
368 myTextFieldIcon->setText(text);
369 myTextFieldIcon->setBackColor(FXRGB(255, 255, 255));
370 myIconLabel->setIcon(nullptr);
371 myIconLabel->setBackColor(FXRGB(255, 255, 255));
372 }
373 recalc();
374 return index;
375}
376
377
378FXint
379MFXComboBoxIcon::moveItem(FXint newindex, FXint oldindex) {
380 if (newindex < 0 || myList->getNumItems() <= newindex || oldindex < 0 || myList->getNumItems() <= oldindex) {
381 fxerror("%s::moveItem: index out of range.\n", getClassName());
382 }
383 FXint current = myList->getCurrentItem();
384 myList->moveItem(newindex, oldindex);
385 if (current != myList->getCurrentItem()) {
386 current = myList->getCurrentItem();
387 if (0 <= current) {
388 myTextFieldIcon->setText(myList->getItemText(current));
389 } else {
390 myTextFieldIcon->setText(" ");
391 }
392 myIconLabel->setIcon(nullptr);
393 myIconLabel->setBackColor(FXRGB(255, 255, 255));
394 }
395 recalc();
396 return newindex;
397}
398
399
400void
402 FXint current = myList->getCurrentItem();
403 myList->removeItem(index);
404 if (index == current) {
405 current = myList->getCurrentItem();
406 if (0 <= current) {
407 myTextFieldIcon->setText(myList->getItemText(current));
408 } else {
409 myTextFieldIcon->setText(FXString::null);
410 }
411 myIconLabel->setIcon(nullptr);
412 myIconLabel->setBackColor(FXRGB(255, 255, 255));
413 }
414 recalc();
415}
416
417
418void
421 myList->clearItems();
422 recalc();
423}
424
425
426FXint
427MFXComboBoxIcon::findItem(const FXString& text, FXint start, FXuint flgs) const {
428 return myList->findItem(text, start, flgs);
429}
430
431
432FXint
433MFXComboBoxIcon::findItemByData(const void* ptr, FXint start, FXuint flgs) const {
434 return myList->findItemByData(ptr, start, flgs);
435}
436
437
438FXString
440 return myList->getItemText(index);
441}
442
443
444void
445MFXComboBoxIcon::setItemData(FXint index, void* ptr) const {
446 myList->setItemData(index, ptr);
447}
448
449
450void*
452 return myList->getItemData(index);
453}
454
455
456FXbool
458 return myPane->shown();
459}
460
461
462void
464 if (!fnt) {
465 fxerror("%s::setFont: NULL font specified.\n", getClassName());
466 }
467 myTextFieldIcon->setFont(fnt);
468 myList->setFont(fnt);
469 recalc();
470}
471
472
473FXFont*
475 return myTextFieldIcon->getFont();
476}
477
478
479void
481 FXuint opts = (options & ~COMBOBOX_MASK) | (mode & COMBOBOX_MASK);
482 if (opts != options) {
483 options = opts;
484 if (options & COMBOBOX_STATIC) {
485 myTextFieldIcon->setEditable(FALSE); // Non-editable
486 myList->setScrollStyle(SCROLLERS_TRACK | HSCROLLING_OFF); // No scrolling
487 } else {
488 myTextFieldIcon->setEditable(TRUE); // Editable
489 myList->setScrollStyle(SCROLLERS_TRACK | HSCROLLER_NEVER); // Scrollable, but no scrollbar
490 }
491 recalc();
492 }
493}
494
495
496FXuint
498 return (options & COMBOBOX_MASK);
499}
500
501
502void
504 myTextFieldIcon->setJustify(style);
505}
506
507
508FXuint
510 return myTextFieldIcon->getJustify();
511}
512
513
514void
516 myTextFieldIcon->setBackColor(clr);
517 myIconLabel->setBackColor(clr);
518 myList->setBackColor(clr);
519}
520
521
522FXColor
524 return myTextFieldIcon->getBackColor();
525}
526
527
528void
530 myTextFieldIcon->setTextColor(clr);
531 myList->setTextColor(clr);
532}
533
534
535FXColor
537 return myTextFieldIcon->getTextColor();
538}
539
540
541void
543 myTextFieldIcon->setSelBackColor(clr);
544 myList->setSelBackColor(clr);
545}
546
547
548FXColor
550 return myTextFieldIcon->getSelBackColor();
551}
552
553
554void
556 myTextFieldIcon->setSelTextColor(clr);
557 myList->setSelTextColor(clr);
558}
559
560
561FXColor
563 return myTextFieldIcon->getSelTextColor();
564}
565
566
567void
569 myList->sortItems();
570}
571
572
573FXListSortFunc
575 return myList->getSortFunc();
576}
577
578
579void
580MFXComboBoxIcon::setSortFunc(FXListSortFunc func) {
581 myList->setSortFunc(func);
582}
583
584
585void
586MFXComboBoxIcon::setHelpText(const FXString& txt) {
587 myTextFieldIcon->setHelpText(txt);
588}
589
590
591const FXString&
593 return myTextFieldIcon->getHelpText();
594}
595
596
597void
598MFXComboBoxIcon::setTipText(const FXString& txt) {
599 myTextFieldIcon->setTipText(txt);
600}
601
602
603const FXString&
605 return myTextFieldIcon->getTipText();
606}
607
608
609long
610MFXComboBoxIcon::onUpdFmText(FXObject*, FXSelector, void*) {
611 return target && !isPaneShown() && target->tryHandle(this, FXSEL(SEL_UPDATE, message), NULL);
612}
613
614
615long
616MFXComboBoxIcon::onFwdToText(FXObject* sender, FXSelector sel, void* ptr) {
617 return myTextFieldIcon->handle(sender, sel, ptr);
618}
619
620
621long
622MFXComboBoxIcon::onListClicked(FXObject*, FXSelector sel, void* ptr) {
623 myButton->handle(this, FXSEL(SEL_COMMAND, ID_UNPOST), NULL);
624 if (FXSELTYPE(sel) == SEL_COMMAND) {
625 // cast MFXListItemIcon
626 const MFXListItemIcon* item = dynamic_cast<MFXListItemIcon*>(myList->getItem((FXint)(FXival)ptr));
627 // set icon and background color
628 if (item) {
629 myTextFieldIcon->setText(item->getText());
630 myTextFieldIcon->setBackColor(item->getBackGroundColor());
631 myIconLabel->setIcon(item->getIcon());
632 myIconLabel->setBackColor(item->getBackGroundColor());
633 }
634 if (!(options & COMBOBOX_STATIC)) {
635 // Select if editable
636 myTextFieldIcon->selectAll();
637 }
638 if (target) {
639 target->tryHandle(this, FXSEL(SEL_COMMAND, message), (void*)getText().text());
640 }
641 }
642 return 1;
643}
644
645
646long
647MFXComboBoxIcon::onTextButton(FXObject*, FXSelector, void*) {
648 if (options & COMBOBOX_STATIC) {
649 // Post the myList
650 myButton->handle(this, FXSEL(SEL_COMMAND, ID_POST), NULL);
651 return 1;
652 }
653 return 0;
654}
655
656
657long
658MFXComboBoxIcon::onTextChanged(FXObject*, FXSelector, void* ptr) {
659 return target && target->tryHandle(this, FXSEL(SEL_CHANGED, message), ptr);
660}
661
662
663long
664MFXComboBoxIcon::onTextCommand(FXObject*, FXSelector, void* ptr) {
665 FXint index = myList->getCurrentItem();
666 if (!(options & COMBOBOX_STATIC)) {
667 switch (options & COMBOBOX_INS_MASK) {
668 case COMBOBOX_REPLACE:
669 if (0 <= index) {
670 setIconItem(index, (FXchar*)ptr, nullptr, FXRGB(255, 255, 255), getItemData(index));
671 }
672 break;
673 case COMBOBOX_INSERT_BEFORE:
674 if (0 <= index) {
675 insertIconItem(index, (FXchar*)ptr);
676 }
677 break;
678 case COMBOBOX_INSERT_AFTER:
679 if (0 <= index) {
680 insertIconItem(index + 1, (FXchar*)ptr);
681 }
682 break;
683 case COMBOBOX_INSERT_FIRST:
684 insertIconItem(0, (FXchar*)ptr);
685 break;
686 case COMBOBOX_INSERT_LAST:
687 appendIconItem((FXchar*)ptr);
688 break;
689 }
690 }
691 // reset icon and color
692 myTextFieldIcon->setBackColor(FXRGB(255, 255, 255));
693 myIconLabel->setIcon(nullptr);
694 myIconLabel->setBackColor(FXRGB(255, 255, 255));
695 return target && target->tryHandle(this, FXSEL(SEL_COMMAND, message), ptr);
696}
697
698
699long
700MFXComboBoxIcon::onFocusSelf(FXObject* sender, FXSelector, void* ptr) {
701 return myTextFieldIcon->handle(sender, FXSEL(SEL_FOCUS_SELF, 0), ptr);
702}
703
704
705long
706MFXComboBoxIcon::onFocusUp(FXObject*, FXSelector, void*) {
707 if (isEnabled()) {
708 FXint index = getCurrentItem();
709 if (index < 0) {
710 index = getNumItems() - 1;
711 } else if (0 < index) {
712 index--;
713 }
714 if (0 <= index && index < getNumItems()) {
715 setCurrentItem(index, TRUE);
716 }
717 return 1;
718 }
719 return 0;
720}
721
722
723long
724MFXComboBoxIcon::onFocusDown(FXObject*, FXSelector, void*) {
725 if (isEnabled()) {
726 FXint index = getCurrentItem();
727 if (index < 0) {
728 index = 0;
729 } else if (index < getNumItems() - 1) {
730 index++;
731 }
732 if (0 <= index && index < getNumItems()) {
733 setCurrentItem(index, TRUE);
734 }
735 return 1;
736 }
737 return 0;
738}
739
740
741long MFXComboBoxIcon::onMouseWheel(FXObject*, FXSelector, void* ptr) {
742 FXEvent* event = (FXEvent*)ptr;
743 if (isEnabled()) {
744 FXint index = getCurrentItem();
745 if (event->code < 0) {
746 if (index < 0) {
747 index = 0;
748 } else if (index < getNumItems() - 1) {
749 index++;
750 }
751 } else if (event->code > 0) {
752 if (index < 0) {
753 index = getNumItems() - 1;
754 } else if (0 < index) {
755 index--;
756 }
757 }
758 if (0 <= index && index < getNumItems()) {
759 setCurrentItem(index, TRUE);
760 }
761 return 1;
762 }
763 return 0;
764}
765
766
768 myHaveIcons(false) {}
#define COMBOBOX_MASK
#define COMBOBOX_INS_MASK
FXDEFMAP(MFXComboBoxIcon) MFXComboBoxIconMap[]
ComboBox with icon.
FXbool isItemCurrent(FXint index) const
Return true if current item.
FXint findItemByData(const void *ptr, FXint start=-1, FXuint flags=SEARCH_FORWARD|SEARCH_WRAP) const
void setSelTextColor(FXColor clr)
Change selected text color.
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.
virtual void layout()
Perform layout.
FXuint getJustify() const
Return text justification mode.
FXint getCurrentItem() const
Get the current item's index.
void setItemData(FXint index, void *ptr) const
Set data pointer for specified item.
virtual void destroy()
Destroy server-side resources.
FXint getNumVisible() const
Return the number of visible items.
FXuint getComboStyle() const
Get the combobox style.
FXint findItem(const FXString &text, FXint start=-1, FXuint flags=SEARCH_FORWARD|SEARCH_WRAP) const
long onTextChanged(FXObject *, FXSelector, void *)
const FXString & getHelpText() const
Get the combobox help text.
void removeItem(FXint index)
Remove this item from the list.
long onFwdToText(FXObject *, FXSelector, void *)
void setCurrentItem(FXint index, FXbool notify=FALSE)
Set the current item (index is zero-based)
FXint getNumItems() const
Return the number of items in the list.
const FXString & getTipText() const
Get the tool tip message for this combobox.
long onMouseWheel(FXObject *, FXSelector, void *)
virtual FXint getDefaultWidth()
Return default width.
FXbool isEditable() const
Return true if combobox is editable.
FXString getItemText(FXint index) const
Get text for specified item.
void * getItemData(FXint index) const
Get data pointer for specified item.
virtual void setBackColor(FXColor clr)
Set window background color.
long onListClicked(FXObject *, FXSelector, void *)
FXFont * getFont() const
Get text font.
void setHelpText(const FXString &txt)
Set the combobox help text.
FXLabel * myIconLabel
label for icon
FXMenuButton * myButton
myButton
MFXListIcon * myList
list
FXString getText() const
Get the text.
void setText(FXString text)
Set text.
FXColor getSelBackColor() const
Return selected background color.
void setNumColumns(FXint cols)
Set the number of columns.
void setTextColor(FXColor clr)
Change text color.
FXPopup * myPane
popup
FXColor getSelTextColor() const
Return selected text color.
void setNumVisible(FXint nvis)
Set the number of visible items in the drop down list.
virtual ~MFXComboBoxIcon()
Destructor.
void clearItems()
Remove all items from the list.
void setSortFunc(FXListSortFunc func)
Change sort function.
virtual FXint getDefaultHeight()
Return default height.
FXString getItem(FXint index) const
Return the item at the given index.
long onTextButton(FXObject *, FXSelector, void *)
FXint prependItem(const FXString &text, void *ptr=NULL)
Prepend an item to the list.
void setTipText(const FXString &txt)
Set the tool tip message for this combobox.
void sortItems()
Sort items using current sort function.
FXbool isPaneShown() const
Is the pane shown.
FXint moveItem(FXint newindex, FXint oldindex)
Move item from oldindex to newindex.
virtual void disable()
Disable combo box.
FXColor getBackColor() const
Get background color.
void setSelBackColor(FXColor clr)
Change selected background color.
void setJustify(FXuint mode)
Change text justification mode; default is JUSTIFY_LEFT.
const bool myHaveIcons
check if this iconComboBox have icons
MFXComboBoxIcon()
FOX need this.
FXColor getTextColor() const
Return text color.
long onUpdFmText(FXObject *, FXSelector, void *)
FXint getNumColumns() const
Get the number of columns.
FXListSortFunc getSortFunc() const
Return sort function.
FXint appendIconItem(const FXString &text, FXIcon *icon=nullptr, FXColor bgColor=FXRGB(255, 255, 255), void *ptr=nullptr)
append icon
bool setItem(const FXString &text, FXIcon *icon)
set Item
virtual void enable()
Enable combo box.
MFXTextFieldIcon * myTextFieldIcon
textField with icon
void setComboStyle(FXuint mode)
Set the combobox style.
FXint setIconItem(FXint index, const FXString &text, FXIcon *icon=nullptr, FXColor bgColor=FXRGB(255, 255, 255), void *ptr=nullptr)
Replace the item at index.
long onTextCommand(FXObject *, FXSelector, void *)
void setEditable(FXbool edit=TRUE)
Set editable state.
void setFont(FXFont *fnt)
Set text font.
virtual void detach()
Detach server-side resources.
virtual void create()
Create server-side resources.
long onFocusDown(FXObject *, FXSelector, void *)
long onFocusSelf(FXObject *, FXSelector, void *)
void setCustomText(const FXString text)
set custom text
long onFocusUp(FXObject *, FXSelector, void *)
Commands.
A list item which allows for custom coloring.
Definition MFXListIcon.h:28
A list item which allows for custom coloring.
const FXColor & getBackGroundColor() const
get background color
FXTextFieldIcon (based on FXTextFieldIcon)
void resetTextField()
reset textField
void setIcon(FXIcon *icon)
set icon