Re: Custom container widget - childs drawn in top-left corner of window



On Dec 15, 2007 8:46 AM, Stephan Arts <stephan xfce org> wrote:

Hi,

I am having an issue with a new container widget I am writing. I have
overridden the size_request and size_allocate methods.[0]

For some reason, the children are all rendered in the top-left corner
of the main window. Not even near the container.

[...]

   child_allocation.x = allocation->x + border_width;
   child_allocation.y = allocation->y + border_width;
   child_allocation.width = 70 - border_width;
   child_allocation.height = 70 - border_width;


Looks like you ignored the allocation here and just assigned 70...

   /*
   if (GTK_WIDGET_REALIZED (widget))
   {
       gdk_window_move_resize (widget->window,
                             allocation->x + border_width,
                             allocation->y + border_width,
                             allocation->width - border_width * 2,
                             allocation->height - border_width * 2);
 }
   */


And your problem is here, since you never moved your GdkWindow to
where it is supposed to be, it is infact still at its default location at
the
top-left corner of its parent window.

Cheers,
                 -Tristan



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