subtitle: fun with Wx::AuiNotebook
In the German clean dev site they teach you how to write good code. One of the first rules is Kiss of course. Maybe thatswhy I never will be a superhacker, but sometimes its too temping to me to spit out something thats more complicated. But for a good reason.
As we are approaching the release of Kephra 0.4.2 i do polish and therefore want to reduce flicker were I can. If you know browser with tabs in a tabbar you have the idea of Wx::Notebook. I switched from Wx::Notebook to Wx::AuiNotebook, because the second looks more pro and the tabs can be moved my mouse. they can't be moved by keyboard, but thats not too hard to implement. The hardest part is to hack the Accelerator table with Wx::AcceleratorEntry or just disturb the expected object hierarchy so that the keyevent will not delegated to the notebook. this sounds first hilarious but it will later become clear, why thats necessary. if you get the key event,
just store the label and panelobject. remove the page and insert it on a new position. if you do this you have a new order of docs, so you need an translation-array to keep track of those changes.
but
If you drag the tabs per mouse events are fired. one when starting, many during and one after you finished draging. With the begin and end event you can catch the visual position of the tab but the mean thing is that the index of the moved tab will not change. So I had 2 choices. a) build another translator between visual position and doc number or b) just remove and reinsert the tab so that the indices are again in sync with the visual order. Of course I took a) because I dont like the flicker, even if that solution is not Kiss. But maybe i kiss a nice girl instead.
Now you know why I need to hack the accelerator table. because naturally the notebook grabs the key event for the expected key kombination to make tab switches with. and will be switched in the tab index order and not the visual order, wich is annoying. also the key combination for tab move will be blocked, because for comfort you need something similar (I choose the tab switch keys + shift). So I really needed to hack it this way.