Child widget sizing issues(DrawingArea). How to resize *now*, no waiting.



I have a  GUI encapsulation library and I am doing and MDI model using a
frame window that contains a GtkNotebook and the Mdi child windows are
within the notebook.

My issue is getting the child widget(s) sized, specifically a
GtkDrawingArea, after I add the child to the GtkNotebook. The GtkDrawingArea
has a non specific size and therefore starts out with no size, and then
expands to fill the unused space in the window. My encapsulation defines a
model like Windows uses in that a "create" message means the window is
"fully
created", but not yet visible.

I realize the widget(s) to get the gdk windows created, but I need to
get them to their terminal size, before I send my "create" message. I have
tried the following. This code is Modula-2 but should be readable.

"Window" = my encapsulation window.
"parent" = the frame window (TopLevel) with the notebook.
"w" is this case is the new MDI child window, just a vbox with stuff packed,
specifically I am interested in the GtkDrawingArea widget.

PROCEDURE ShowMdiChild(w : Window);
BEGIN
    IF w^.notePage < 0 THEN

        gtk_notebook_append_page(w^.parent^.notebook,
                                 GTK_WIDGET(w^.vbox),
                                 GTK_WIDGET(w^.tabLabel));
        w^.notePage := gtk_notebook_page_num(w^.parent^.notebook,
                                             GTK_WIDGET(w^.vbox));

        DebugS("After Add, Before force");
        DebugSI("Width", w^.drawingArea^.allocation.width);

        (* try to get the notebook to size our child *now*, specifically
           the drawing area which currently has no size, and always
           accepts the size given it
        *)
        gtk_widget_queue_resize(w^.drawingArea);
        (*gtk_drawing_area_size(GTK_DRAWING_AREA(w^.drawingArea), 10, 10);*)
        gtk_container_resize_children(GTK_CONTAINER(w^.parent^.wnd));
        gtk_container_check_resize(GTK_CONTAINER(w^.parent^.wnd));
        (*
        WHILE gtk_events_pending() DO
            gtk_main_iteration();
        END;
        *)
        DebugS("After Add, After force");
        DebugSI("Width", w^.drawingArea^.allocation.width);

I have tried various combinations of all of the above. I have tried
resize_children and check_resize, on the main window  and notebook. I have
tried giving the drawing area a "fudge" size. Doing the events loop
surprisingly did not help but it may have other unwanted effects. All I want
is the child to be given its terminal size, *now*, rather than later which
does occur.


Best Regards,
Norman Black
Stony Brook Software






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