58FXIMPLEMENT(
MFXComboBoxIcon, FXPacker, MFXComboBoxIconMap, ARRAYNUMBER(MFXComboBoxIconMap))
65 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 flags |= FLAG_ENABLED;
71 myTextFieldIcon =
new MFXTextFieldIcon(
this, staticToolTip,
GUIIcon::EMPTY,
this,
MFXComboBoxIcon::ID_TEXT, 0, 0, 0, 0, 0, pl, pr, pt, pb);
72 if (options & COMBOBOX_STATIC) {
76 myPane =
new FXPopup(
this, FRAME_LINE);
79 myTextFieldSearch =
new MFXTextFieldSearch(
myPane, staticToolTip,
this,
ID_SEARCH, FRAME_THICK | LAYOUT_FIX_WIDTH | LAYOUT_FIX_HEIGHT, 0, 0, 0, 0, 2, 2, 2, 2);
81 myNoItemsLabel =
new FXLabel(
myPane,
TL(
"No matches found"),
nullptr, FRAME_THICK | LAYOUT_FIX_WIDTH | LAYOUT_FIX_HEIGHT, 0, 0, 0, 0, 2, 2, 2, 2);
87 if (options & COMBOBOX_STATIC) {
88 myList->setScrollStyle(SCROLLERS_TRACK | HSCROLLING_OFF);
90 myList->setNumVisible(visibleItems);
92 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);
95 flags &= ~(FXuint)FLAG_UPDATE;
157 FXint pw =
myPane->getDefaultWidth();
158 return FXMAX(ww, pw);
167 return FXMAX(th, bh) + (border << 1);
173 const FXint itemHeight = height - (border << 1);
174 const FXint buttonWidth =
myButton->getDefaultWidth();
175 const FXint textWidth = width - buttonWidth - (border << 1);
177 myButton->position(border + textWidth, border, buttonWidth, itemHeight);
183 flags &= ~(FXuint)FLAG_DIRTY;
195 return myList->getNumItems();
201 myList->setNumVisible(nvis);
213 return myList->isItemCurrent(index);
219 if (index >= 0 && index <= myList->
getNumItems()) {
223 myList->setCurrentItem(item);
224 myList->makeItemVisible(index);
230 if (notify && target) {
231 return target->tryHandle(
this, FXSEL(SEL_COMMAND, message), (
void*)item);
234 fxerror(
"%s::setItem: index out of range.\n", getClassName());
243 for (
int i = 0; i <
myList->getNumItems(); i++) {
244 const auto itemText =
myList->tolowerString(
myList->getItem(i)->getText());
245 if (
myList->tolowerString(text) == itemText) {
256 return myList->getCurrentItemIndex();
263 fxerror(
"%s::setItem: index out of range.\n", getClassName());
265 myList->editItem(index, text, NULL, ptr);
304 const auto isCurrent =
myList->isItemCurrent(index);
305 if (isCurrent == TRUE) {
306 if ((index > 0) && (index < (
int)
myList->getNumItems())) {
308 }
else if (
myList->getNumItems() > 0) {
312 myList->removeItem(index);
327 return myList->findItem(text);
333 return myList->getItem(index)->getText().text();
340 myList->setBackColor(clr);
347 myList->setTextColor(clr);
371 return (target && !
myPane->shown()) ? target->tryHandle(
this, FXSEL(SEL_UPDATE, message), NULL) : 0;
380 myPane->onPaint(0, 0, ptr);
394 myButton->handle(
this, FXSEL(SEL_COMMAND, ID_UNPOST), NULL);
395 if (FXSELTYPE(sel) == SEL_COMMAND) {
403 if (!(options & COMBOBOX_STATIC)) {
407 target->tryHandle(
this, FXSEL(SEL_COMMAND, message), (
void*)
getText().text());
416 if (options & COMBOBOX_STATIC) {
418 myButton->handle(
this, FXSEL(SEL_COMMAND, ID_POST), NULL);
427 return target ? target->tryHandle(
this, FXSEL(SEL_CHANGED, message), ptr) : 0;
436 for (
int i = 0; i <
myList->getNumItems(); i++) {
437 const auto itemText =
myList->tolowerString(
myList->getItem(i)->getText());
445 return target ? target->tryHandle(
this, FXSEL(SEL_COMMAND, message), ptr) : 0;
461 }
else if (0 < index) {
492 FXEvent*
event = (FXEvent*)ptr;
495 if (event->code < 0) {
501 }
else if (event->code > 0) {
504 }
else if (0 < index) {
@ MID_MTEXTFIELDSEARCH_UPDATED
callback for MFXTextFieldSearch
#define GUIDesignTextColorRed
red color (for invalid text)
#define GUIDesignBackgroundColorWhite
white background color (for valid text)
FXDEFMAP(MFXComboBoxIcon) MFXComboBoxIconMap[]
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
FXbool isItemCurrent(FXint index) const
Return true if current item.
FXint insertIconItem(FXint index, const FXString &text, FXIcon *icon=nullptr, FXColor bgColor=FXRGB(255, 255, 255), void *ptr=nullptr)
insert icon item in the given position
long setCurrentItem(const FXint index, FXbool notify=FALSE)
Set the current item (index is zero-based).
void layout()
Perform layout.
FXint getCurrentItem() const
Get the current item's index.
void destroy()
Destroy server-side resources.
FXint findItem(const FXString &text) const
find item
long onTextChanged(FXObject *, FXSelector, void *)
void removeItem(FXint index)
Remove this item from the list.
long onFwdToText(FXObject *, FXSelector, void *)
FXint getNumItems() const
Return the number of items in the list.
FXLabel * myNoItemsLabel
no items label
const FXString & getTipText() const
Get the tool tip message for this combobox.
long onMouseWheel(FXObject *, FXSelector, void *)
FXint getDefaultWidth()
Return default width.
MFXTextFieldSearch * myTextFieldSearch
text field search
void setBackColor(FXColor clr)
Set window background color.
long onListClicked(FXObject *, FXSelector, void *)
FXMenuButton * myButton
myButton
MFXListIcon * myList
list with all items
FXString getText() const
Get the text.
long onCmdFilter(FXObject *, FXSelector, void *)
void setTextColor(FXColor clr)
Change text color.
FXPopup * myPane
popup in which place search label and list
void setNumVisible(FXint nvis)
Set the number of visible items in the drop down list.
~MFXComboBoxIcon()
Destructor.
virtual void clearItems()
Remove all items from the list.
FXint updateIconItem(FXint index, const FXString &text, FXIcon *icon=nullptr, FXColor bgColor=FXRGB(255, 255, 255), void *ptr=nullptr)
Replace the item at index.
FXint getDefaultHeight()
Return default height.
long onTextButton(FXObject *, FXSelector, void *)
void setTipText(const FXString &txt)
Set the tool tip message for this combobox.
MFXComboBoxIcon(FXComposite *p, MFXStaticToolTip *staticToolTip, const bool canSearch, const int visibleItems, FXObject *tgt, FXSelector sel, FXuint opts, 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)
Construct a Combo Box widget with room to display cols columns of text.
std::string getItemText(FXint index) const
Get text for specified item.
void disable()
Disable combo box.
MFXComboBoxIcon()
FOX need this.
FXColor getTextColor() const
Return text color.
long onUpdFmText(FXObject *, FXSelector, void *)
FXint appendIconItem(const FXString &text, FXIcon *icon=nullptr, FXColor bgColor=FXRGB(255, 255, 255), void *ptr=nullptr)
append icon item in the last position
void enable()
Enable combo box.
MFXTextFieldIcon * myTextFieldIcon
textField icon
long onTextCommand(FXObject *, FXSelector, void *)
void detach()
Detach server-side resources.
void create()
Create server-side resources.
long onFocusDown(FXObject *, FXSelector, void *)
long onFocusSelf(FXObject *, FXSelector, void *)
void setText(const FXString &text, FXbool notify=FALSE)
Set the text in the textField.
long onFocusUp(FXObject *, FXSelector, void *)
Commands.
A list item which allows for custom coloring.
const FXString & getText() const
Return item's text label.
FXIcon * getIcon() const
Return item's icon.
const FXColor & getBackGroundColor() const
get background color
FXTextFieldIcon (based on FXTextFieldIcon).