Does every widget have a generic implementation? My point would
be that the widgets should be supporting background/foreground
colors and falling back to generic implementations to do so if
necessary.
The point of wrapping native widgets is that they are native and behave the same way in all applications that use them. Exactly the same things is done in wxWidgets all widget types for things like SetBackgroundColour and it is up to the native control whether it will do anything with that or not, and if not then at least you can be reasonably sure that it is also not doing it in other applications too.
Falling back to generic implementations opens its own can of worms that you as the user of wx would probably not want to deal with, and the developers of wx certainly don't want to do it either. For example it is possible that the same native widget on different versions of the same platform (say, win2k and win7) may be different, where one would support setting the bg color and the other would not. There is no way for us to tell at runtime if it does or not, so maintaining the code that decides when to switch to generic would be a nightmare. It's also possible that different GTK themes on the same machine would have differences, so it would be impossible there. Secondly, there would be a very real risk that doing a very simple thing like setting the background color could change the behavior of the application, because a totally different widget would be used and it would be very difficult to keep the generic version 100% in sync with the native version, especially since there can be some differences between the platforms or versions of a platform.
For example the wx.Notebook should fill the area behind its
tabs in the background color otherwise you could not put a
notebook in a panel that isn't grey.
In addition to that I'm looking for someone to refute my statement
that given 3-5 colors ( background/foreground/highlight etc ) many
of the widgets could draw themselves in completely customizable
colors with a simple 5 lines of code setting those colors on the top
level frame.
If I wanted to implement this would there be a problem with me
adding a few new SetXXXColour functions in the wx.Window base
class?
It doesn't hurt to try, but in order to be accepted it would probably need to have implementations for the major platforms, and there would have to be a platform API that would work with any kind of widget. For example, a single API that could change the selection color in a listbox, listctrl, and textctrl. (Otherwise you would have to provide implementations of the method for every class that needs to do it differently.) On the other hand, does it make sense to allow calling SetSelectionColour on a button or a checkbox?
···
On 4/1/10 8:56 AM, Mark wrote:
--
Robin Dunn
Software Craftsman