how to create a window containing a drawing area of a specific size?




I want to create a window containing a drawing area of a specific size
in pixels.  I have the following widget tree:

    window
      | 
      +--Table (2x2)
           |
           +--DrawingArea
           +--vscale
           +--hscale

I don't want to use
gtk_window_set_default_size, because its the drawing area
I care about and tyring to do things like subtract off the
anticipated size of the scroll bars seems very messy.

At the moment I'm using sequence:

  const gint desired_width = 600;
  const gint desired_height = 800;
  gtk_widget_set_size_request (drawing_area, desired_width,
  desired_height);
  gtk_widget_show_all (window);
  g_message ("drawing_area allocation: %d, %d",
  drawing_area->allocation.width,
             drawing_area->allocation.height);
  g_message ("window allocation: %d, %d", window->allocation.width,
             window->allocation.height);
  gtk_widget_set_size_request (drawing_area, -1, -1);
    
My thought is to set the size request for the initial window
placement, and then restore default behavior so the user can
actually resize the window.
    
Is this the right approach?  The output of the above g_message
calls is:
   
  ViewerWindow-Message: drawing_area allocation: 600, 800
  ViewerWindow-Message: window allocation: 615, 633
    
How can the height of the drawing area be greater than the height of
the window that contains it?
    
This code doesn't work consistently: the above output is always the
same, but sometimes the window appears to have the correct size, and
other
times not.
    
Any help or advice greatly appreciated,
Britton





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