FXIconList Questions

Hi,

I have a class that extends FXIconList; I’m having some trouble with a
few things.

  1. When a user clicks on a header, I’d like to sort that column
    alphabetically. I’ve looked at the sample iconlist.rbw, but sorting
    doesn’t seem to work there.

  2. I’d like to dynamically change the style of the icon list, from
    details to big icons. I need to be able to do this from a method
    because I’d like to do other things when the style changes, so I can’t
    do “FXMenuCommand.new(menuPane, “&Big Icons”, nil, iconlist,
    FXIconList::ID_SHOW_BIG_ICONS)”

Any ideas?

Thanks!

Karl.

Karl wrote:

I have a class that extends FXIconList; I’m having some trouble with a
few things.

  1. When a user clicks on a header, I’d like to sort that column
    alphabetically. I’ve looked at the sample iconlist.rbw, but sorting
    doesn’t seem to work there.

I will send a modified version of the ‘iconlist’ example program to Karl
privately, but the basic steps are to:

  • Subclass FXIconItem to override its <=> method. This gets used
    by FXIconList’s sortItems method to sort the items.

  • Subclass FXIconList to additionally listen for “clicks” on the
    header item buttons, and then change the current sorting method
    used for the icon items and then re-sort by calling
    FXIconList#sortItems.

Will also try to write up a little tutorial or something describing this
in more detail…

  1. I’d like to dynamically change the style of the icon list, from
    details to big icons. I need to be able to do this from a method
    because I’d like to do other things when the style changes, so I can’t
    do “FXMenuCommand.new(menuPane, “&Big Icons”, nil, iconlist,
    FXIconList::ID_SHOW_BIG_ICONS)”

Use the FXIconList#getListStyle and FXIconList#setListStyle methods to
query and set the style flags, e.g.

 style = iconList.getListStyle()
 style &= ~ICONLIST_MINI_ICONS
 style |=  ICONLIST_BIG_ICONS
 iconList.setListStyle(style)

or in a more compact form,

 iconList.listStyle &= ~ICONLIST_MINI_ICONS
 iconList.listStyle |=  ICONLIST_BIG_ICONS

or even shorter,

 iconList.handle(self,
     MKUINT(FXIconList::ID_SHOW_BIG_ICONS, SEL_COMMAND), nil)

The last one is what the menu command button does when you click it.