2011/7/13 Felix H. Dahlke <f...@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
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to