Wednesday, June 17, 2009

Hints for Editing XRC with Vim

If you are one of those strange people who prefer to write XRC files manually instead of using one of the many GUI editors, and also one of the enlightened people using Vim as their text editor you may be interested in this hint: although Vim is smart enough to detect that XRC files are XML without any extra prodding (as the presence of header at start of each XRC file is enough for XML file type detection to work), things can be made more comfortable with a little extra effort.

Before doing anything else you need to modify your .vimrc or _vimrc (under Windows) file to detect XRC files as a separate file type. For this simply add the following line to it:

au BufNewFile,BufReadPost *.xrc set ft=xrc

I also like to start with XML boilerplate already filled in when I create a new file so I additionally have

au BufNewFile *.xrc read ~/vim/template.xrc

where the file template.xrc contains

<?xml version="1.0"?>
<resource>
<object class="" name="">
</object>
</resource>


Now, I'd like to do spell checking in the XRC elements which contain user visible text. For this I create the file ~/vim/syntax/xrc.vim (this works under Windows too, just use whatever Vim considers to be your home directory instead of ~) with the following contents:

runtime syntax/xml.vim

syn region xmlString start="\(<title>\)\@<=[A-Z0-9]" end="\(</title>\)\@=" contains=xmlEntity,@Spell
syn region xmlString start="\(<text>\)\@<=[A-Z0-9]" end="\(</text>\)\@=" contains=xmlEntity,@Spell
syn region xmlString start="\(<label>\n\?\)\@<=[A-Z0-9]" end="\(</label>\)\@=" contains=xmlEntity,@Spell

and enjoy Vim help with correcting your mipsellings (how did you notice I wasn't writing this post in Vim?). Notice that the region definition is not very elegant but this was the best way I could find to make it work: using \zs unfortunately didn't work.


Next, I also defined a couple of helpful macros to insert the common constructions into XRC. This is done in ~/vim/ftplugin/xrc.vim (which will be sourced automatically by Vim thanks to our file type autocommand):

runtime! ftplugin/xml.vim

nmap <Leader>o o<object class=""><C-M><Esc>kf"a
nmap <Leader>v o<object class="wxBoxSizer"><C-M><Esc>O<Tab><orient>wxVERTICAL<Esc>o
nmap <Leader>h o<object class="wxBoxSizer"><C-M><Esc>O<Tab><orient>wxHORIZONTAL<Esc>o
nmap <Leader>i o<object class="sizeritem"><C-M><Esc>O<Tab><flag>wxALL<Esc>o<border>5

Notice that this supposes that you have the XML editing plugin installed, notably it relies on it to close all the tags. But surely you don't edit XML in Vim without it anyhow, right?


Much more could probably be done but I find that the above already makes editing XRC much more comfortable. And I definitely can do it much faster in Vim than using any GUI I tried so far.

Thursday, June 04, 2009

Spring News

Unfortunately I didn't have time to write the April summary until the second week of May and by then it seemed too late so I decided to postpone it and write a combined April-May one. As usual, postponing things doesn't make them easier however and now I find myself unable (due to all the usual reasons of lack of time, partly due to real life getting into the way) to write the May summary properly neither. But better something than nothing so let me just make a very short one.

Most of the activity in wx development community during this time was centred around 2.9.0 release. It still didn't happen but we're now at release candidate 4 and it looks good -- or at least good enough to not justify postponing 2.9.0 any more -- so the final release should be expected very soon. Of course, if you haven't tried 2.9.0-RC4 (or bz2 version if you prefer a much smaller download) yet you're strongly encouraged to do it and post your feedback to wx-users mailing list.

Speaking of the mailing lists, this was the most important administrative change in our recent history: all the lists (including wx-users and wx-dev) have migrated to Google Groups as the current (virtual) server didn't hold the charge any more resulting not only in disruptions to the mailing list traffic but also to frequent Trac outages as everything on that machine slowed down to a crawl due to Postfix bogging all the disk bandwidth. Some people disliked this change but from our point of view there was simply no other solution as switching to Google Groups was much easier than paying for a better server and administering it ourselves.

The only drawback of switching (so far) is that we still don't have any solution for the gateway between wx-users and comp.soft-sys.wxwindows USENET group. Unfortunately Google Groups don't provide this feature and so someone still needs to host this gateway -- if anybody reading this can volunteer either resources or at least information about how to do it, it would be great.


Other than that the usual cycle of adding new features and fixing old bugs continued. Among the features I can remember the following additions:

  • Status bar tool tips shown when the text is truncated.

  • Better integration with the standard streams (thanks to Jonathan Liu): now you can wrap any wxStream as a std::stream and/or std::streambuf (we still need a way to wrap any std::streambuf as a wxStream to achieve perfect interoperability).

  • XRC improvements: wxListCtrl columns and item can now be defined directly in the resource files which is very convenient, especially for the columns (thanks go to Kinaou HervĂ©). And wxImageList support which was added to allow this is also available for the other controls using it such as wxTreeCtrl and various wxBookCtrl-derived classes.

  • A new wxMouseEventsManager class was added to abstract mouse handling in controls with items -- it doesn't seem like much but actually handling the mouse events properly, including respecting users mouse sensitivity options, is not that trivial. It still remains to modify the existing code in generic wxListCtrl, wxTreeCtrl and wxDataViewCtrl implementations to use it.

  • An already existing but private until then wxTextWrapper was promoted to a public class status.

  • More wxGrid tweaks: it's now possible to selectively disable resizing of individual rows or columns (despite the incredible (and confusing) richness of wxGrid API you couldn't do it before: it was all or nothing only).

  • Laurent Humbertclaude has submitted a patch adding table border width support to wxHtmlWindow which allows to have visually nicer tables in wx applications.




Finally, the GSoC projects seem to be all getting into their stride nicely. I don't know much about the other two ones but I'm very satisfied with the progress of the one I'm mentoring. Moreover, it seems that Bartosz is going to add some important enhancements to wxEventLoop which are not part of file system events notification project strictly speaking but which would be very useful to any wx applications which need to monitor anything at all (to be more precise, any file descriptor, HANDLE or CFRunLoopSource depending on the platform) while running.


That's all for today -- and I'll try to find time to write more about June changes and also to finally finish my long promised and long overdue post about Bind() soon.

Monday, April 27, 2009

Accepted Projects for Google Summer of Code 2009

This is a follow up to the previous post about wx acceptance into GSoC 2009. We have had many great proposals this year -- it was the best year for us so far from this point of view IMO -- and the only regret is that only 3 of them could have been accepted, I really feel sorry for some students who have clearly put a good effort in making their application. Nevertheless I can't really be sad about it because the 3 that were accepted look pretty exciting to me. There are:
I'm mentoring the first one of those so I'm naturally quite interested in it but the wxAUI project is clearly very much needed too and in spite of my initial opposition to the idea of including ribbon bar into wx, it turned out to be the most popular proposal among both students and wx users so it definitely will be great to have too.

Finally, just as during the last year GSoC, even if wx itself has only received 3 slots, there is also at least one other wx-related project in a different organization: Perl has one slot for creating Perl bindings for wxWebKit. And Audacity is participating in GSoC again as well and while their projects don't seem to be especially wx-related it is still nice to see wx applications being part of GSoC. OTOH it's a pity that none 30 Python projects seem to be wxPython related, especially as wxPython itself is not part of the GSoC this year but well, like this we have something to hope for the next year :-)

In the meanwhile good luck to Bartosz, Malcolm and Peter and looking forward to their contributions to wx!

Saturday, April 04, 2009

Marching Forward

Here is a brief and late report of changes in wxWidgets in March. Somehow it looks that once again not that much happened, although it certainly seemed like a busy month. But most of the effort was spent on not very sexy activities such as bug fixing and release preparation -- and 2.9.0 was finally postponed to mid-April in spite of all that so I can't even boast about a new release this month. This was a bit of disappointment but OTOH we'd like 2.9.0 to be usable in production, the ominous zero at the end notwithstanding, and so we decided to release it slightly later but with less problems.

Personally I was also upset by not managing to finish my work on debug/release builds unification before 2.9.0. I did check in the changes introducing wxDEBUG_LEVEL which allows us to more flexibly configure the presence of assertions and other debugging helpers in your build, but the default behaviour didn't change yet, it will now have to wait for 2.9.1 as we didn't want to postpone 2.9.0 for that long neither.

A lot of time was also taken by preparation for GSoC 2009 and discussion of proposal ideas first and the proposals themselves later. This is definitely not time wasted though as we have more proposals this year than the last one (although about the same as the years before) and, most importantly, their average quality is much higher so I'm really looking forward to working with students this year.

Anyhow, in short here is what happened at wxWidgets code level:

  • Added wxTextEntry::SetHint() which can be used to show a hint string (e.g. "Search") in an empty text control or combobox. This uses native XP/Vista support if available or a generic fallback otherwise.

  • Made wxFTP logging more flexible with wxProtocolLog (thanks to troelsk). We also should extend this to wxHTTP in the future.

  • wxSP_WRAP support was added to wxSpinCtrlDouble and wxSP_ARROW_KEYS was fixed too; alignment flags are now honoured for both it and plain wxSpinCtrl (thanks Andrew Radke).

  • wxImageHandler can now have more than one associated extension making it finally possible to use both .jpg and .jpeg (Ivan Krestinin).

  • Events for wxComboBox popup drop-down and close-up were added (Igor Korot).

  • wxString::ToCLong(), ToCULong() and ToCDouble() were added.

  • Many fixes to wxDateTime parsing methods which were broken in variously entertaining ways after rewriting them to use iterators instead of string pointers some time ago. wxLocale::GetInfo() was extended to return various date and time formats in the process and as the result all our wxDateTime unit tests finally pass in all locales.

  • A bad and long standing bug 9638 introduced by Unicode-related changes was finally fixed. Several other bugs related to handling of embedded NULs in wxString were fixed as well. And all string unit tests pass too in all builds (wchar_t, UTF-8, ...) now.

  • XRC error reporting was significantly improved, now the line number is given in error messages.

  • wxDocView code was streamlined a bit more and made less surprising to an unsuspecting application programmer.

  • Several wxAUI bugs were fixed as Ben had some time to work on it recently.

  • Many OS X enhancements/fixes from Stefan and Kevin Ollivier.

  • And some wxDataViewCtrl improvements from Robert, as usual.


The previously mentioned Bind() function was finally finished and documented and I'll describe it in more details in a separate post soon.

The usual monthly stats: 732 commits, 137 new tickets and 101 closed ones (oops, no bragging about moving in the right direction this time).

And that's all for now, hopefully we'll have more meaty news next month with a flurry of commits which habitually accompany the end of release freeze period.

Thursday, March 19, 2009

Google Summer of Code 2009

Excellent news: wxWidgets has been accepted to participate in Google Summer of Code 2009 again! Congratulations to the other 149 accepted organizations but I'm especially glad about this one :-) I admit that I was rather worried about it as we already were lucky enough to be part of GSoC during the last 3 years and it was mentioned that some previously selected organizations couldn't be accepted this year to make place for new ones. But all is well that ends well.

Now we need to attract enough good students applications before the April 3 deadline to be able to choose the best ones of them. And while we also have a list of proposed projects we also are always looking for more so please update the Wiki page or post to our mailing lists if you think you have an interesting idea.

So if you are a wxWidgets user or a user of any wxWidgets application please tell any students around you about the possibility to work on wxWidgets during this summer. And, of course, if you are a student yourself, consider applying!

Monday, March 09, 2009

wx Sightings in the Wild

I've just discovered (please don't laugh as apparently everyone else made this discovery a year or at least half a year ago but better late than never) a nice solution for synchronizing files between different machines called Dropbox. For those of you who are as ignorant as me, it's basically a way to transparently rsync files (up to 2GB for free) with Amazon S3 storage. The transparent part is nice as it means that you just run a daemon monitoring the dropbox directory in an efficient way (using inotify under Linux and, my guess would be, using ReadDirectoryChangesW() under Windows) and don't have to manually commit and update your files as I was doing so far, using a central CVS server (from which I'm slowly moving to an hg one). And, unlike CVS, Dropbox also provides a nice way to access your files from any JavaScript-enabled browser (which is more convenient than hg web interface but then it's not at all meant to do the same thing).


The only problem with Dropbox is that the daemon part of their product is not open source. This is really a pity but it also explains why I started looking at its internals at all -- only to discover that it is written using wx, more precisely wxPython. It's not the most demanding GUI application in existence but it's still nice to see that an application used by many (how many? I don't know but judging from amount of stuff written about it on the web this must be one of the most widely used wx applications in existence) people is written in wx and apparently nobody complains about its GUI.

So while I'll probably mostly continue to use hg myself, I'll certainly recommend it to my less DVCS-inclined friends and relatives. And if any of the readers of this blog want to try it out, don't hesitate to use my affiliate link to register and get extra 250MB of space for both you and me.

Saturday, February 28, 2009

February 2009 News

Maybe it's because February is so short or, more likely, because we started a lot of things in January, but not that many exciting things have happened in wx land during this month. To continue from the last month summary, we did move closer to finalizing the new event handling code, although we had to introduce a new Bind() method (which I'm going to describe in another post soon) as trying to introduce new features while keeping backwards compatibility with the existing code using Connect() proved to be too hard. And the wxYield-related changes were mostly finished too.

Unfortunately not much has been done for the remaining big item for 2.9.0 release: unification of the debug and release builds. This is something which would be really useful for both the library users and developers and actually doing it will probably be not that difficult -- but deciding what exactly should be done proves to be more agonizing than expected. I still hope to do it in March but then I said the same thing about February at the end of January, of course...

There were also some discussions about releases: both 2.8.10 and 2.9.0. Please help us with testing them if you can!

The only new features of note implemented in this month were, AFAICS, the new wxTaskBarIcon implementation for wxGTK by Paul which should look much better in modern desktop environments and support for hints (a.k.a. cue banners or placeholder strings) to wxTextEntry (and hence wxTextCtrl and wxComboBox).

As usual, several bugs were fixed. The most important one was arguably #626 which is a problem with wxTreeCtrl selection events in wxTR_MULTIPLE mode. As can be seen from its number, it was a very long-standing ticket and while the fix hasn't been checked in just yet, it's going to be done very soon -- thanks a lot to Jonathan Liu who spent a lot of time working on this (and several other bugs as well).

Finally, some statistics for February: there were 632 commits in the repository, 67 new tickets were created, 84 were modified and 61 were closed. We'll try to do better in the next month (and preferably not by making Trac crash with internal server error and thus making it impossible for people to enter new tickets... I do love Trac UI and workflow but it's still amazing that it's the only ticketing system which I ever saw crashing -- but then I saw it do this all the time).

That's all for this month folks and have a nice March!