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!

Comments

RichB said…
Is the vertical scrollbar supposed to extend to the bottom edge of the ListView? It looks like a bug to me.
Alex said…
Hello
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
Jonathan Pobst said…
@richb:

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.
knocte said…
Weren't you also planning on theming MWF to look like the default Gtk theme in Linux? This would be cool.
Jonathan Pobst said…
@knocte:

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.
Ciprian Khlud said…
His name is George Giofan :) hope was a misspelling problem
George Giolfan said…
Please fix this typo: "George Giolfin". My name is George Giolfan. Also, if you apply the remaining patches I think the GTK+ theme would support the controls used by MoMA (based on what I can see in the screenshot). If you do it and find bugs post them and I will try to fix them.
Anonymous said…
Doesn't work.
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().
Jonathan Pobst said…
"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."

The VMWare image and bash are both Linux, therefore...

Hopefully we'll get there in a bit!

;)
Makenshi said…
Great work! Is there any possibility of support for Qt being added?

Popular posts from this blog

Introducing Pinta

Hack Week 3

Mono in Visual Studio 2010