I used this NativeMacOSXToolbarSelection - wxPyWiki in a
program quite a while ago and didn't look at the code too closely at the
time.
I just came across it again and was quite surprised to see how it works
(the PrepareMacNativeToolBar method). I've never really seen anything
like this before. From what I understand it loads and gets a handle from
an OS library to get the native toolbar look and behaviour into a wx
frame. I guess this is how a lot of wx is working under the hood? Just
this is 'raw' and hasn't been wrapped yet for the version I'm in? or is
it because there's no equivalent for linux/windows when wrapping it up
as a frame method?
It got me thinking though what other native features and behaviours
could you potentially get working this way?
Calling a few APIs with ctypes is not too bad, but creating new widgets and getting them properly integrated into wxWidgets, its events, tracking of parent/children, etc. would be rather tricky. Plus there are the issues dealing with differences in Carbon and Cocoa and using the right APIs based on which version of wxPython is running...
A few that I had in mind:
- The different looks of buttons that you get in tool bars, like the
ones along the top of Finder.
These are called capsule buttons (I think) and are a separate widget type than the existing button widgets.
- The window animations that you get on some mac apps, like when a
window animates and flips around so you can see a different view on the
back of the window (not sure how to explain this properly, or the
correct name/term).
Look at the CoreAnimation APIs, and also look at the wx.Window.ShowWithEffect method in 2.9 where some animation effects are already implemented.
- The drop down shutter from a frame that drops down just below the
title bar
They are called sheets. In 2.9 you can get this by showing a dialog with ShowWindowModal instead of ShowModal.
- The grey footer that you see on some apps that you can drag the
window around by, I think Finder had this before Lion.
This is essentially the native statusbar, however (IIRC) since it could not provide all the features that the wxStatusBar provides it was not used and it is implemented generically instead. You could simulate the draggability without too much trouble, if you want that feature, by adding some mouse event handlers.
Could these kind of features potentially be exposed in wx?
In general, using ctypes or other mechanisms to get to the native API is doable, the tricky part as I mentioned is making things fit properly with wx, and preventing memory/resource leaks or not leaving dangling pointers.
What kinda
work would be involved?
Anywhere from not too bad, to terribly difficult. It just depends on what you are trying to do. You would need to have a good understanding of the internal wx C++ and ObjC code, and also of the native APIs.
···
On 6/26/12 7:21 AM, Paul wrote:
--
Robin Dunn
Software Craftsman