36 #define SIDE_SPACING        6    
   37 #define ICON_SPACING        4    
   39 #define COMBOBOX_INS_MASK   (COMBOBOX_REPLACE | COMBOBOX_INSERT_BEFORE | COMBOBOX_INSERT_AFTER | COMBOBOX_INSERT_FIRST | COMBOBOX_INSERT_LAST) 
   40 #define COMBOBOX_MASK       (COMBOBOX_STATIC | COMBOBOX_INS_MASK) 
   65 FXIMPLEMENT(
MFXIconComboBox,    FXPacker,   MFXIconComboBoxMap, ARRAYNUMBER(MFXIconComboBoxMap))
 
   70     FXListItem(text, ic, ptr),
 
   71     myBackGroundColor(backGroundColor) {
 
   77     register FXFont *font = myList->getFont();
 
   78     register FXint ih = 0, th = 0;
 
   81         th = font->getFontHeight();
 
   84         dc.setForeground(myList->getSelBackColor());
 
   88     dc.fillRectangle(xx, yy, ww, hh);
 
   90         dc.drawFocusRectangle(xx + 1, yy + 1, ww - 2, hh - 2);
 
   94         dc.drawIcon(icon, xx, yy + (hh - ih) / 2);
 
  100             dc.setForeground(makeShadowColor(myList->getBackColor()));
 
  101         } 
else if (isSelected()) {
 
  102             dc.setForeground(myList->getSelTextColor());
 
  104             dc.setForeground(myList->getTextColor());
 
  106         dc.drawText(xx, yy + (hh - th) / 2 + font->getFontAscent(), label);
 
  117     FXListItem(
"", nullptr),
 
  118     myBackGroundColor(FXRGB(0, 0, 0)) {
 
  122 MFXIconComboBox::MFXIconComboBox(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):
 
  123     FXPacker(p, opts, x, y, w, h, 0, 0, 0, 0, 0, 0),
 
  124     myHaveIcons(haveIcons) {
 
  125     flags |= FLAG_ENABLED;
 
  128     myIconLabel = 
new FXLabel(
this, 
"", 
nullptr, 0, 0, 0, 0, 0, pl, pr, pt, pb);
 
  132     myTextFieldIcon = 
new MFXTextFieldIcon(
this, cols, 
this, 
MFXIconComboBox::ID_TEXT, 0, 0, 0, 0, 0, pl, pr, pt, pb);
 
  133     if (options & COMBOBOX_STATIC) {
 
  136     myPane = 
new FXPopup(
this, FRAME_LINE);
 
  138     if (options & COMBOBOX_STATIC) {
 
  139         myList->setScrollStyle(SCROLLERS_TRACK | HSCROLLING_OFF);
 
  141     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);
 
  144     flags &= ~FLAG_UPDATE;  
 
  209     pw = 
myPane->getDefaultWidth();
 
  210     return FXMAX(ww, pw);
 
  219     return FXMAX(th, bh) + (border << 1);
 
  225     const FXint itemHeight = height - (border << 1);
 
  226     const FXint iconSize = 
myHaveIcons ? itemHeight : 0;
 
  227     const FXint buttonWidth = 
myButton->getDefaultWidth();
 
  228     const FXint textWidth = width - buttonWidth - iconSize - (border << 1);
 
  229     myIconLabel->position(border, border, iconSize, iconSize);
 
  230     myTextFieldIcon->position(border + iconSize, border, textWidth, itemHeight);
 
  231     myButton->position(border + textWidth + iconSize, border, buttonWidth, itemHeight);
 
  234     for (
int i = 0; i < 
myList->getNumItems(); i++) {
 
  235         if (
myList->getItemWidth(i) > size) {
 
  236             size = 
myList->getItemWidth(i);
 
  240     flags &= ~FLAG_DIRTY;
 
  276     return myList->getNumItems();
 
  282     return myList->getNumVisible();
 
  294     myList->setNumVisible(nvis);
 
  301     return myList->isItemCurrent(index);
 
  307     FXint current = 
myList->getCurrentItem();
 
  308     if (current != index) {
 
  309         myList->setCurrentItem(index);
 
  310         myList->makeItemVisible(index);
 
  329         if (notify && target) {
 
  330             target->tryHandle(
this, FXSEL(SEL_COMMAND, message), (
void*)
getText().text());
 
  338     return myList->getCurrentItem();
 
  344     return myList->getItem(index)->getText();
 
  351         fxerror(
"%s::setItem: index out of range.\n", getClassName());
 
  353     myList->setItem(index, text, NULL, ptr);
 
  368         fxerror(
"%s::insertItem: index out of range.\n", getClassName());
 
  370     myList->insertItem(index, text, NULL, ptr);
 
  398     for (
int i = 0; i < 
myList->getNumItems(); i++) {
 
  402         if (item && (item->getText() == text) && (item->getIcon() == icon)) {
 
  424     FXint index = 
myList->prependItem(text, NULL, ptr);
 
  438     if (newindex < 0 || myList->
getNumItems() <= newindex || oldindex < 0 || myList->
getNumItems() <= oldindex) {
 
  439         fxerror(
"%s::moveItem: index out of range.\n", getClassName());
 
  441     FXint current = 
myList->getCurrentItem();
 
  442     myList->moveItem(newindex, oldindex);
 
  443     if (current != 
myList->getCurrentItem()) {
 
  444         current = 
myList->getCurrentItem();
 
  460     FXint current = 
myList->getCurrentItem();
 
  461     myList->removeItem(index);
 
  462     if (index == current) {
 
  463         current = 
myList->getCurrentItem();
 
  486     return myList->findItem(text, start, flgs);
 
  492     return myList->findItemByData(ptr, start, flgs);
 
  498     return myList->getItemText(index);
 
  504     myList->setItemData(index, ptr);
 
  510     return myList->getItemData(index);
 
  523         fxerror(
"%s::setFont: NULL font specified.\n", getClassName());
 
  540     if (opts != options) {
 
  542         if (options & COMBOBOX_STATIC) {
 
  544             myList->setScrollStyle(SCROLLERS_TRACK | HSCROLLING_OFF);   
 
  547             myList->setScrollStyle(SCROLLERS_TRACK | HSCROLLER_NEVER);  
 
  576     myList->setBackColor(clr);
 
  589     myList->setTextColor(clr);
 
  602     myList->setSelBackColor(clr);
 
  615     myList->setSelTextColor(clr);
 
  633     return myList->getSortFunc();
 
  639     myList->setSortFunc(func);
 
  669     return target && !
isPaneShown() && target->tryHandle(
this, FXSEL(SEL_UPDATE, message), NULL);
 
  681     myButton->handle(
this, FXSEL(SEL_COMMAND, ID_UNPOST), NULL);
 
  682     if (FXSELTYPE(sel) == SEL_COMMAND) {
 
  692         if (!(options & COMBOBOX_STATIC)) {
 
  697             target->tryHandle(
this, FXSEL(SEL_COMMAND, message), (
void*)
getText().text());
 
  706     if (options & COMBOBOX_STATIC) {
 
  708         myButton->handle(
this, FXSEL(SEL_COMMAND, ID_POST), NULL);
 
  717     return target && target->tryHandle(
this, FXSEL(SEL_CHANGED, message), ptr);
 
  723     FXint index = 
myList->getCurrentItem();
 
  724     if (!(options & COMBOBOX_STATIC)) {
 
  726             case COMBOBOX_REPLACE:
 
  731             case COMBOBOX_INSERT_BEFORE:
 
  736             case COMBOBOX_INSERT_AFTER:
 
  741             case COMBOBOX_INSERT_FIRST:
 
  744             case COMBOBOX_INSERT_LAST:
 
  753     return target && target->tryHandle(
this, FXSEL(SEL_COMMAND, message), ptr);
 
  769         } 
else if (0 < index) {
 
  800     FXEvent* 
event = (FXEvent*)ptr;
 
  803         if (event->code < 0) {
 
  809         } 
else if (event->code > 0) {
 
  812             } 
else if (0 < index) {
 
  826     myHaveIcons(false) {}
 
#define COMBOBOX_INS_MASK
FXDEFMAP(MFXIconComboBox) MFXIconComboBoxMap[]
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.
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 *)
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.
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.
const bool myHaveIcons
check if this iconComboBox have icons
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.
void setText(FXString text)
Set text.
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.
void setCustomText(const FXString text)
set custom text
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)
void resetTextField()
reset textField