Update of /cvsroot/htoolkit/port/src/cbits/GTK
In directory sc8-pr-cvs1:/tmp/cvs-serv10870/src/cbits/GTK
Modified Files:
Window.c
Log Message:
Better implementation for osGetWindowViewSize and osSetWindowViewSize
Index: Window.c
===================================================================
RCS file: /cvsroot/htoolkit/port/src/cbits/GTK/Window.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** Window.c 13 Jul 2003 10:21:27 -0000 1.21
--- Window.c 15 Jul 2003 18:24:33 -0000 1.22
***************
*** 4,7 ****
--- 4,10 ----
#include <gdk/gdkkeysyms.h>
+ #define EDGE_SIZE 3
+ #define TITLE_SIZE 13
+
char *gWindowName = NULL;
***************
*** 567,570 ****
--- 570,577 ----
};
+ // The implementation for osGetWindowViewSize and osSetWindowViewSize functions
+ // is inspired from implementation for DoGetClientSize and DoSetClientSize functions from
+ // wxWindows. The trouble here is the asume that the window frame borders are
+ // with constant sizes (see EDGE_SIZE and TITLE_SIZE constants). This is not true at all.
void osGetWindowViewSize(WindowHandle window, int *res)
{
***************
*** 573,578 ****
--- 580,601 ----
if (toplevel != gFrameWidget || gDocumentInterface == 1)
{
+ GtkRequisition req;
+
res[0] = toplevel->allocation.width-4;
res[1] = toplevel->allocation.height-4;
+
+ if (GNOME_IS_APP(toplevel))
+ {
+ GtkWidget *menubar = GNOME_APP(toplevel)->menubar;
+
+ if (menubar != NULL)
+ {
+ req.width = 2;
+ req.height = 2;
+ (* GTK_WIDGET_CLASS( GTK_OBJECT_GET_CLASS(menubar) )->size_request )
+ (menubar, &req);
+ res[1] -= req.height;
+ }
+ }
}
else
***************
*** 587,591 ****
GtkWidget *toplevel = gtk_widget_get_toplevel(window);
if (toplevel != gFrameWidget || gDocumentInterface == 1)
! gtk_window_resize(GTK_WINDOW(toplevel), w+4, h+4);
}
--- 610,655 ----
GtkWidget *toplevel = gtk_widget_get_toplevel(window);
if (toplevel != gFrameWidget || gDocumentInterface == 1)
! {
! GtkRequisition req;
! GtkScrolledWindow *scroll_window = GTK_SCROLLED_WINDOW(window);
! GtkScrolledWindowClass *scroll_class = GTK_SCROLLED_WINDOW_CLASS(GTK_OBJECT_GET_CLASS(window));
!
! if (scroll_window->vscrollbar_visible)
! {
! req.width = 2;
! req.height = 2;
! (* GTK_WIDGET_CLASS( GTK_OBJECT_GET_CLASS(scroll_window->vscrollbar) )->size_request )
! (scroll_window->vscrollbar, &req );
! w += req.width + scroll_class->scrollbar_spacing;
! }
!
! if (scroll_window->hscrollbar_visible)
! {
! req.width = 2;
! req.height = 2;
! (* GTK_WIDGET_CLASS( GTK_OBJECT_GET_CLASS(scroll_window->hscrollbar) )->size_request )
! (scroll_window->hscrollbar, &req );
! h += req.height + scroll_class->scrollbar_spacing;
! }
!
! if (GNOME_IS_APP(toplevel))
! {
! GtkWidget *menubar = GNOME_APP(toplevel)->menubar;
!
! if (menubar != NULL)
! {
! req.width = 2;
! req.height = 2;
! (* GTK_WIDGET_CLASS( GTK_OBJECT_GET_CLASS(menubar) )->size_request )
! (menubar, &req);
! h += req.height;
! }
! }
!
! w += EDGE_SIZE*2;
! h += EDGE_SIZE*2 + TITLE_SIZE;
!
! gtk_window_resize(GTK_WINDOW(toplevel), w, h);
! }
}
|