A Little Bit of Style
Previously, I had mentioned that there were two SoC projects for Mono this year that I was particularly interested in. The second project was the one I mentored: George Giolfan's work to bring native rendering to Winforms.
Currently, our Winforms implementation mimics the "Win32 Classic" look, also known as looking like "ass". It has been important to support this default .Net look, and has provided us with a consistent target, but now George has provided us with something better.
Winforms has the System.Windows.Forms.VisualStyles namespace, that provides access to native rendering on Windows. George has implemented a theme that uses this namespace, to achieve much better looking applications. His work initially focused on writing this for Windows, as the VisualStyles namespace is already implemented for Windows. Although this currently doesn't work on Linux/OSX, the massive amounts of refactoring that George had to do will make it much, much easier to implement this on those platforms as well.
George's code shipped with Mono 2.0, however it is turned off by default. To turn it on, run:
SET MONO_THEME=visualstyles
mono MyApplication.exe
As with .Net, your application will need to call Application.EnableVisualStyles, or it will not use the native look. Please test this feature, as I intend to enable it by default for Mono 2.2. Since the 2.0 release, I have fixed bugs with DataGridView headers always painted as focused, and tooltips not drawing their background. If you find any other issues, please file them in our bugzilla so I can fix them before 2.2.
For a taste of what this looks like, here is MoMA with classic rendering:
And here is MoMA with native rendering:
Finally, a big thanks to George for his awesome work this summer to make this possible!
Edit: Blah, I can't even spell George's name. Terribly sorry!
Currently, our Winforms implementation mimics the "Win32 Classic" look, also known as looking like "ass". It has been important to support this default .Net look, and has provided us with a consistent target, but now George has provided us with something better.
Winforms has the System.Windows.Forms.VisualStyles namespace, that provides access to native rendering on Windows. George has implemented a theme that uses this namespace, to achieve much better looking applications. His work initially focused on writing this for Windows, as the VisualStyles namespace is already implemented for Windows. Although this currently doesn't work on Linux/OSX, the massive amounts of refactoring that George had to do will make it much, much easier to implement this on those platforms as well.
George's code shipped with Mono 2.0, however it is turned off by default. To turn it on, run:
SET MONO_THEME=visualstyles
mono MyApplication.exe
As with .Net, your application will need to call Application.EnableVisualStyles, or it will not use the native look. Please test this feature, as I intend to enable it by default for Mono 2.2. Since the 2.0 release, I have fixed bugs with DataGridView headers always painted as focused, and tooltips not drawing their background. If you find any other issues, please file them in our bugzilla so I can fix them before 2.2.
For a taste of what this looks like, here is MoMA with classic rendering:
And here is MoMA with native rendering:
Finally, a big thanks to George for his awesome work this summer to make this possible!
Edit: Blah, I can't even spell George's name. Terribly sorry!
Comments
Please, can you specify more about the location of code line:
Application.EnableVisualStyles()
Is correct?:
Public Sub New()
Application.EnableVisualStyles()
End Sub
Please tell more about mono command set mono_theme=visualstyles
Thanks a lot
Yep, I'll file that.
@alex:
You have to place it before Application.Run () is called. It looks like you are using VB, just go to the properties page of your project and click "Enable XP visual styles".
set MONO_THEME=visualstyles isn't a mono command, it sets a windows environment variable called MONO_THEME with the value visualstyles.
Yeah, George wrote some code that integrates with Gtk, but it isn't complete. (It's on the winforms list.)
The other option is to just write a theme that mimics Clearlooks instead of actually integrating with Gtk.
At this point, I do not know what route we will take.
I'm using the Mono 2.0.0 VMWare image.
linux@linux:~/Desktop> mono_themes=visualstyles
linux@linux:~/Desktop> MONO_THEMES=visualstyles
linux@linux:~/Desktop> moma
linux@linux:~/Desktop> mono WindowsFormsApplication1.exe
no need for "set" by bash. (also with set it doesn't work).
And Yes, my own Application run Application.EnableVisualStyles().
The VMWare image and bash are both Linux, therefore...
Hopefully we'll get there in a bit!
;)