Update on Quest for Multi-Column Listbox in FXRuby

Well, I played with FXTable this weekend, and I almost got it working the
way I want. I got it so that when I select a new row, either by clicking or
by using the arrow/Page-Up keys, it deselects the old row, selects the
entire new row, and updates the current cell. I thought I was done, until I
realized that the cells all seem to right-justify their contents. I could
not find any way to set the justification for a cell. Am I missing
something?

The other approach I am going to try tonight is to use an FXIconList
(recommended by Lyle). But the only example I can find is using a
FXFilelist, which is a descendant of FXIconList. The only problem is that
because it is hard-coded to be used listing a directory, it doesn’t show any
of the initialization arguments that would be used with FXIconList. Anyone
have an example of using FXIconList that they could share?

Thanks.

Jamey.

CRIBBSJ wrote:

The other approach I am going to try tonight is to use an FXIconList
(recommended by Lyle). But the only example I can find is using a
FXFileList, which is a descendant of FXIconList. The only problem is that
because it is hard-coded to be used listing a directory, it doesn’t show any
of the initialization arguments that would be used with FXIconList. Anyone
have an example of using FXIconList that they could share?

Jamey,

Sorry for the delay in getting back to you. If you’re looking for the
FOX equivalent of Gtk’s CList widget I’m pretty sure you want the
FXIconList. An icon list can be displayed in several different modes,
but the one you’d want is the “details” mode which presents the list
items in a traditional vertical arrangement. To construct this kind of
icon list pass in the ICONLIST_DETAILED option, e.g.

 iconList = FXIconList.new(contents, nil, 0,
   ICONLIST_DETAILED|LAYOUT_FILL_X|LAYOUT_FILL_Y)

An FXIconList has a built-in FXHeader widget that is displayed when the
list is configured in details mode. To set up the header captions, use
the FXIconList#addHeader method, e.g.

 iconList.appendHeader("Name", nil, 50)
 iconList.appendHeader("Rank", nil, 100)
 iconList.appendHeader("Serial Number", nil, 150)

Finally, to add list items use the FXIconList#appendItem method:

 iconList.appendItem("Gomer Pyle\tSergeant\t12345")

Note the use of tabs (“\t”) to separate the fields in a list item. When
the user clicks on a list item it will generate a SEL_COMMAND message;
to catch that you could do something like this:

 iconList.connect(SEL_COMMAND) do |sender, sel, current|
   puts "user selects item #{current}"
 end

Hope this helps,

Lyle