Re: Making widgets visible outside their containing window



2011/7/13 Felix H. Dahlke <fhd ubercode de>:
Hi,

I'm fairly new to GTK (using version 2.24), and I'm wondering if I can
move a widget (partly) outside the area of a window and still have it
displayed.

Consider the following code, where I've tried to use a GtkFixed to
position a label partly outside the window:

==========
int main(int argc, char* argv[])
{
 Âgtk_init(&argc, &argv);

 ÂGtkWidget* window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
 Âgtk_window_set_default_size(GTK_WINDOW(window), 320, 240);
 Âgtk_container_border_width(GTK_CONTAINER(window), 10);
 Âgtk_widget_show(window);

 ÂGtkWidget* fixed = gtk_fixed_new();
 Âgtk_widget_set_has_window(fixed, TRUE); // Doesn't help
 Âgtk_container_add(GTK_CONTAINER(window), fixed);
 Âgtk_widget_show(fixed);

 ÂGtkWidget* label = gtk_label_new("Hello World");
 Â// y = 238 should position the label partly outside the window
 Âgtk_fixed_put((GtkFixed*) fixed, label, 0, 238);
 Âgtk_widget_show(label);

 Âgtk_main();
 Âreturn 0;
}
==========

This is how I want it to look:

-----------------------
| Â Â Â Â Â Â Â Â Â Â |
| Â Â Â Â Â Â Â Â Â Â |
| Â Â Â Â Â Â Â Â Â Â |
| Â Â Â Â Â Â Â Â Â Â |
|-------------- Â Â Â |
-| Â Â Â Â Â Â|--------
Â| Â Â Â Â Â Â|
Â--------------

And this is how it actually looks:

-----------------------
| Â Â Â Â Â Â Â Â Â Â |
| Â Â Â Â Â Â Â Â Â Â |
| Â Â Â Â Â Â Â Â Â Â |
|-------------- Â Â Â |
|| Â Â Â Â Â Â| Â Â Â |
|| Â Â Â Â Â Â| Â Â Â |
|-------------- Â Â Â |
-----------------------

As you can see from the comments, I already tried to use
gtk_widget_set_has_window(fixed, TRUE), but it didn't do the
trick. How can I do this?


I can't say I know Gtk+ in any high level of detail, but just using my
basic knowledge of X11 here, I'd say that gtk_widget_set_has_window
(fixed, TRUE); is probably only giving the widget a subwindow of the
toplevel window of your application and not another toplevel window in
and of itself

If you wanted to have that part of your widget appearing outside of
the client window you'd need to create a new GtkWindow which is
override-redirect (I believe the way to do this is to specify
GTK_WINDOW_POPUP on creation) and set the WM_TRANSIENT_FOR hint to be
your client's application window. Then you can draw whatever you want
there and it will be outside of (albeit on top of) the application.


_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list




-- 
Sam Spilsbury



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]