tags:

views:

289

answers:

2

Hello good people,

Let's say the widget in question is a VBox containing a Label and two Buttons.

Furthermore, let's say the degree of rotation desired is 90°.

How does one go about rotating it? I do not think this is possible by default but I do think it is possible.

However, I have no idea how to get started. Do I write a custom widget? What do I subclass?

+1  A: 

Firstly, if your widget does not have its own X window (VBox doesn't), put it inside EventBox.

Secondly, assuming that you've got X composite extension enabled in your X server, you will be able to do that by manually tweaking your widget's X window using Xlib or an equivalent one. Warning, this is a hacky solution and will not work if your user does not have compositing extensions enabled.

I don't see any way to do this without compositing extensions... well, other than drawing everything by hand. GTK uses Cairo graphics library to draw widgets, and theoretically it would be enough to set transformation matrix inside Cairo... but I see no practical possibility of doing that.

liori
+3  A: 

You can fake it like this:

label.set_angle(90)
button1.get_child().set_angle(90) # assuming it's not a stock button
button2.get_child().set_angle(90)
vbox.set_orientation(gtk.ORIENTATION_HORIZONTAL)
ptomato
Hmm... This is pretty interesting. :) I'll try it and see if it works for my purposes. Thanks!
Fake Code Monkey Rashid
Okay, this solution is really interesting and for the example I gave, it certainly (more or less) works.I'd still like to know if true (ie: via a custom widget) rotation is possible (and if so, how to start on that venue), failing that, I'll mark this as the accepted answer (since it does answer the question I posed). Edit: Actually, can you fake the rotation of a Fixed container too?
Fake Code Monkey Rashid
You can fake the rotation of a Fixed container by resizing it, interchanging the x and y coordinates of all the child widgets, and rotating all the child widgets separately -- if they can be rotated. Widgets that can be rotated are pretty much limited to Labels and Images.
ptomato
As to the real question, try reading up on the documentation of Gdk.Drawable and Gdk.Window; maybe there's some trick with client-side windows and redirection that you can do. You might also check out Clutter (http://library.gnome.org/devel/clutter/stable/) but I know nothing about it.
ptomato
Thanks for your input! :)
Fake Code Monkey Rashid