Monday, April 18, 2011

Using dynamic auto-completion in text controls

wxTextEntry supports auto-completion of a fixed of strings in wxWidgets 2.9 since quite some time however so far you had to specify the full of set of strings to complete and, incidentally, this didn't work under OS X meaning that one of three major platforms didn't support auto-completion at all.

Lack of support of OS X aside, this is a useful feature which helps the users a lot with the data entry. For example, it is typically used to keep the history of previous entries in a text control and auto-complete the entries used in the past automatically. And for this the existing AutoComplete() worked fine. Sometimes, however, using a fixed set of strings is impractical. A typical example is trying to complete the results of some database queries: there can be a lot of them and it can be wasteful to get all the results from the database. It would be much better to be able to dynamically retrieve just the completions for the prefix already entered by user.

And this is exactly what the newly added wxTextCompleter class and wxTextEntry::AutoComplete() overload taking it allows to do. A text completer object can dynamically generate the completions using the prefix already by the user, either by overriding Start() and GetNext() methods of wxTextCompleter itself or by overriding the single GetCompletions() method of wxTextCompleterSimple class. The widgets sample was updated to show how to do it and the documentation of wxTextCompleterSimple also contains a simple example and hopefully the new API should be clear enough to be used without problems.

As usual, things could be improved further: for one, even though the new dynamic auto-completion is implemented under MSW and OS X, it is not implemented under GTK yet. It shouldn't be difficult to do it by defining a GtkTreeModel forwarding to wxTextCompleter and using it with GtkEntryCompletion but this still remains to be done. Also, under OS X the completion currently needs to be triggered manually by pressing F5 and doesn't appear automatically. This is the native behaviour but it doesn't seem to be particularly useful so we'd need to make it appear automatically. As usual, any contributions implementing either of those improvements would be gratefully received by wxWidgets project so don't hesitate to help if you'd like to use the missing features in your programs.

But even in the current state, you can easily define custom dynamic text completers and also use fixed lists of completion strings under all of the major platforms now.

Wednesday, April 06, 2011

Help with attracting students for GSoC 2011

This year we have surprisingly few proposals from the students willing to work on wxWidgets during this year Google Summer of Code. All the previous times when we participated in the GSoC we had more proposals than the slots allocated to wxWidgets but this year it looks like the reverse might happen for the very first time as two days before the proposal submission deadline we only have two worthy proposals and a couple more of more or less junk ones while, for comparison, the last year we had 7 or 8 interesting proposals and 5-6 or more of lesser quality but still not quite worthless.

And as we always had enough good proposals to take all the slots we were assigned, we never really did much advertisement for it. However this year it looks like it was a bad mistake to not do it so, considering that later is still better than never (even if it's really very late -- again, there are only 2 days left before the deadline), I'd like to ask for the help of the readers of this blog with spreading the word about SGoC in general and wxWidgets participation in it in particular among any students (and maybe also professors) you might know.

Personally I'm convinced that for any student interested in working on a real life yet fun and interesting project during the summer vacation, learning both more about the technical subject and also about how to work in an open source community in general and, moreover, be paid on successful completion of the project, participating in GSoC is really a great opportunity -- so please let know anybody who might be concerned about it.

Thanks in advance!