I am having trouble with the GtkFixed model in Gtk3 on MS Windows 8.1. I am using the GtkFixed model because I have a main window where the a bitmap is displayed and need a 'floating' widget or stacked widget on top of the bitmap that shows a zoomed in portion of it. I have scroll bars for the bitmap view and need to know how to get an accurate height of the drawing area so I can resize the scroll area when the window is resized. How do I get the size of the window without the borders and title bar - the window client area height? I captured the window height in the 'configure-event' and 'size-allocate' signals, and also used gtk_widget_get_allocation but the height that is returned is bigger than the actual pixel height of the window, so when I go to resize the scroll bar area it gets stuck in an infinite loop because the main window is enlarged each time. How do I get the correct height of the drawing area so I can resize the scroll area and position the floating zoom widget correctly?
SlideWindow::SlideWindow()
{
// other init stuff here not related...
zoomWidgetWidth=320;
zoomWidgetHeight=240;
zoomGap=100;
}
// below function is static so safe for callback
void SlideWindow::sizeAllocateCallback(GtkWidget *mainWidget, GdkRectangle *allocation, gpointer data)
{
SlideWindow *slideWindow=(SlideWindow*) data;
int moveX=allocation->width - zoomWidgetWidth - zoomGap
int moveY=allocation->height - zoomWidgetHeight - zoomGap;
if (moveX < 100) moveX=100;
if (moveY < 100) moveY=100;
std::cout << "Main window width=" << allocation->width << " height=" << allocation->height << std::endl; // this just loops and gets bigger and bigger
gtk_fixed_move(slideWindow->fixedWidget, slideWindow->zoomWidget, moveX, moveY);
gtk_widget_set_size_request(slideWindow->scrollWidget, allocation->width, allocation->height); // this causes an infinite loop because the main window is then resized to fit the enlarged scroll area
}
Someone on stackoverflow mentioned using the function gdk_window_get_origin y coordinate minus the gdk_window_get_frame_extents function's y coordinate to get the total size of the title bar but both functions are returning the same Y position:
// In size allocate callback:
GdkRectangle rect;
GdkWindow *gdkWindow = gtk_widget_get_window(mainWidget);
gdk_window_get_frame_extents(gdkWindow, &rect);
gint originX, originY;
gdk_window_get_origin(gdkWindow, &originX, &originY);
std::cout << " Window frame extents: x=" << rect.x << " width=" <<
rect.width << " y=" << rect.y << " height=" << rect.height;
std::cout << " originX=" << originX << " originY=" << originY << std::endl;
// Here originY==rect.y on Windows