[Gtk-sharp-list] Buttons & Cairo graphics

Andy Selvig ajselvig at gmail.com
Sat Apr 25 10:08:35 EDT 2009


Yes, these things are certainly possible using Mono and Cairo. For simple
buttons and controls, I would recommend simply using Gtk#.

For doing more complicated rendering, Cairo is certainly a good option. You
can perform the rendering just like it's shown in the cookbook. To do the
UI, you need to hook your rendering widget into the Gtk# event system.
Here's an older post about setting up a basic custom control:


Basically, you intercept the mouse events and adjust you rendering
accordingly. So, to do #2, you check to see if the cursor is inside each
shape on the motion notify event, then change the color used to render if it

As far as #4 goes, you should actually be able to use the same executable on
all platforms without recompiling, as long as you have Gtk# installed.

Hope this helps get you started.

On Fri, Apr 24, 2009 at 8:11 AM, Shinka <shinka.suugaku at gmail.com> wrote:

> Hello,
> I have a fairly good background in programming (scientific computing) but
> I'm completely ignorant when it comes to writing GUIs and I wondered if it
> was easy to draw a shape with Cairo and use it as a button. That is;
> 1. I draw a shape, e.g.; the rectangle in the cookbook
> (http://www.mono-project.com/Mono.Cairo_Cookbook)
> 2. The color of the shape change when the mouse pointer is moved over it.
> 3. You can click on the shape to do an event X.
> Also I wondered if it was possible;
> 4. To write a GUI with Mono/Cairo and using the code for Linux/Mac
> versions,
> but creating a windows .exe using Visual C# Express without modification to
> the code (that is, I take the mono project, open it with visual C# express
> and try to compile it).
> 5. To create complex shapes like regions in a map, and still to be able to
> click in one of these complex regions to do an event X.
> I only need to know these things are possible. If a better option than
> Cairo
> is available I'm also interested, but I really like the idea of using a
> vector-based library as it allows to resize images easily (well, in
> theory).
> The other alternative is using C++ with Qt, but I'm not a big fan of C++
> and
> if Mono can do what Qt can do, I'd prefer Mono !
> Thank you
> --
> View this message in context:
> http://www.nabble.com/Buttons---Cairo-graphics-tp23216207p23216207.html
> Sent from the Mono - Gtk# mailing list archive at Nabble.com.
> _______________________________________________
> Gtk-sharp-list maillist  -  Gtk-sharp-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/gtk-sharp-list
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/gtk-sharp-list/attachments/20090425/2972d90f/attachment.html 

More information about the Gtk-sharp-list mailing list