From 8a302da3e84a2d054af33b6e329684ebb3510b69 Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Mon, 22 Oct 2012 22:41:14 +0200 Subject: [PATCH] Make board sizing work through subtracting fixed height There is now no attempt to give a size to the board drawing area, so it can later be sized as small as we want. The frame width is determined by subtracting the nominal board size from the actual window size, (because the clocks will have that width, and the board will startas 1x1), while the vertical margin is determined as the difference between the bactual window height, the drawing-area height minus a fudge of 25 pixels to compesate for the erroneously allocated blank space below the board. --- dialogs.c | 4 +--- gtk/xboard.c | 19 +++++++++++-------- gtk/xoptions.c | 19 ++++++++++++++----- 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/dialogs.c b/dialogs.c index e95518f..0e15867 100644 --- a/dialogs.c +++ b/dialogs.c @@ -939,7 +939,7 @@ NewComCallback (int n) } Option commentOptions[] = { -{ 200, T_VSCRL | T_FILL | T_WRAP | T_TOP, 250, NULL, (void*) &commentText, "", (MemoCallback *) &CommentClick, TextBox, "" }, +{ 200, T_VSCRL | T_FILL | T_WRAP | T_TOP, 250, NULL, (void*) &commentText, "", (char **) &CommentClick, TextBox, "" }, { 0, 0, 50, NULL, (void*) &ClearComment, NULL, NULL, Button, N_("clear") }, { 0, SAME_ROW, 100, NULL, (void*) &SaveChanges, NULL, NULL, Button, N_("save changes") }, { 0, SAME_ROW, 0, NULL, (void*) &NewComCallback, "", NULL, EndMark , "" } @@ -2084,8 +2084,6 @@ Option mainOptions[] = { // description of main window in terms of generic dialo { 2, COMBO_CALLBACK, 0, NULL, (void*) &PMSelect, NULL, pieceMenuStrings[0], PopUp, "menuW" }, { 2, COMBO_CALLBACK, 0, NULL, (void*) &PMSelect, NULL, pieceMenuStrings[1], PopUp, "menuB" }, { -1, COMBO_CALLBACK, 0, NULL, (void*) &PMSelect, NULL, dropMenuStrings, PopUp, "menuD" }, -{ 0, 0, 0, NULL, (void*) &appData.saveGameFile, ".pgn .game", NULL, FileName, N_("Save Tourney Games on:") }, -//{ 0, 0, 0, NULL, NULL, "", NULL, EndMark , "" }, { 0, NO_OK, 0, NULL, NULL, "", NULL, EndMark , "" } }; diff --git a/gtk/xboard.c b/gtk/xboard.c index 77eef84..c4c97a8 100644 --- a/gtk/xboard.c +++ b/gtk/xboard.c @@ -647,7 +647,7 @@ ResizeBoardWindow (int w, int h, int inhibit) { w += marginW + 1; // [HGM] not sure why the +1 is (sometimes) needed... h += marginH; -// gtk_window_resize(GTK_WINDOW(shellWidget), w, h); + gtk_window_resize(GTK_WINDOW(shellWidget), w, h); #ifdef TODO_GTK w += marginW + 1; // [HGM] not sure why the +1 is (sometimes) needed... h += marginH; @@ -1058,10 +1058,13 @@ main (int argc, char **argv) GtkAllocation a; gtk_widget_get_allocation(shells[BoardWindow], &a); w = a.width; h = a.height; -printf("start size (%d,%d), %dx%d\n", a.x, a.y, w, h); +//printf("start size (%d,%d), %dx%d\n", a.x, a.y, w, h); + gtk_widget_get_allocation(boardWidget, &a); + marginW = w - boardWidth; // [HGM] needed to set new shellWidget size when we resize board + marginH = h - a.height - 25; // subtract 25, because GTK seems to insert this amount of extra empty space + gtk_window_resize(GTK_WINDOW(shellWidget), marginW + boardWidth, marginH + boardHeight); +//printf("margins h=%d v=%d\n", marginW, marginH); } - marginW = w - boardWidth; // [HGM] needed to set new shellWidget size when we resize board - marginH = h - boardHeight; CreateAnyPieces(); CreateGrid(); @@ -1501,7 +1504,7 @@ DragProc () busy = 1; // GetActualPlacement(shellWidget, &wpNew); -printf("drag proc (%d,%d) %dx%d\n", wpNew.x, wpNew.y, wpNew.width, wpNew.height); +//printf("drag proc (%d,%d) %dx%d\n", wpNew.x, wpNew.y, wpNew.width, wpNew.height); if(wpNew.x == wpMain.x && wpNew.y == wpMain.y && // not moved wpNew.width == wpMain.width && wpNew.height == wpMain.height) { // not sized busy = 0; return; // false alarm @@ -1521,16 +1524,16 @@ printf("drag proc (%d,%d) %dx%d\n", wpNew.x, wpNew.y, wpNew.width, wpNew.height) void DelayedDrag () { -printf("old timr = %d\n", delayedDragTag); +//printf("old timr = %d\n", delayedDragTag); if(delayedDragTag) g_source_remove(delayedDragTag); delayedDragTag = g_timeout_add( 200, (GSourceFunc) DragProc, NULL); -printf("new timr = %d\n", delayedDragTag); +//printf("new timr = %d\n", delayedDragTag); } static gboolean EventProc (GtkWidget *widget, GdkEvent *event, gpointer g) { -printf("event proc (%d,%d) %dx%d\n", event->configure.x, event->configure.y, event->configure.width, event->configure.height); +//printf("event proc (%d,%d) %dx%d\n", event->configure.x, event->configure.y, event->configure.width, event->configure.height); // immediately wpNew.x = event->configure.x; wpNew.y = event->configure.y; diff --git a/gtk/xoptions.c b/gtk/xoptions.c index afc82a6..877bf02 100644 --- a/gtk/xoptions.c +++ b/gtk/xoptions.c @@ -829,16 +829,15 @@ GraphEventProc(GtkWidget *widget, GdkEvent *event, gpointer gdata) // to give drawing routines opportunity to use it before first expose event // (which are only processed when main gets to the event loop, so after all init!) // so only change when size is no longer good -#ifdef TODO_GTK if(graph->choice) cairo_surface_destroy((cairo_surface_t *) graph->choice); graph->choice = (char**) cairo_image_surface_create (CAIRO_FORMAT_ARGB32, w, h); -#endif break; } w = eevent->area.width; if(eevent->area.x + w > graph->max) w--; // cut off fudge pixel cr = gdk_cairo_create(((GtkWidget *) (graph->handle))->window); cairo_set_source_surface(cr, (cairo_surface_t *) graph->choice, 0, 0); +//cairo_set_source_rgb(cr, 1, 0, 0); cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE); cairo_rectangle(cr, eevent->area.x, eevent->area.y, w, eevent->area.height); cairo_fill(cr); @@ -1168,7 +1167,7 @@ printf("n=%d, h=%d, w=%d\n",n,height,width); for (i=0;option[i].type != EndMark;i++) { if(option[i].type == -1) continue; top++; -printf("option =%2d, top =%2d\n", i, top); +//printf("option =%2d, top =%2d\n", i, top); if (top >= height) { gtk_table_resize(GTK_TABLE(table), height, r); if(!pane) { // multi-column: put tables in intermediate hbox @@ -1406,13 +1405,23 @@ printf("option =%2d, top =%2d\n", i, top); break; case Graph: option[i].handle = (void*) (graph = gtk_drawing_area_new()); - gtk_widget_set_size_request(graph, option[i].max, option[i].value); - Pack(hbox, table, graph, left, left+r, top, GTK_EXPAND); +// gtk_widget_set_size_request(graph, option[i].max, option[i].value); + if(0){ GtkAllocation a; + a.x = 0; a.y = 0; a.width = option[i].max, a.height = option[i].value; + gtk_widget_set_allocation(graph, &a); + } g_signal_connect (graph, "expose-event", G_CALLBACK (GraphEventProc), (gpointer) &option[i]); gtk_widget_add_events(GTK_WIDGET(graph), GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK); g_signal_connect (graph, "button-press-event", G_CALLBACK (GraphEventProc), (gpointer) &option[i]); g_signal_connect (graph, "button-release-event", G_CALLBACK (GraphEventProc), (gpointer) &option[i]); g_signal_connect (graph, "motion-notify-event", G_CALLBACK (GraphEventProc), (gpointer) &option[i]); + if(0) { + GtkWidget *frame = gtk_aspect_frame_new(NULL, 0, 0, 1, FALSE); +// gtk_frame_set_shadow_type(frame, GTK_SHADOW_NONE); + gtk_container_add(GTK_CONTAINER(frame), graph); + graph = frame; + } + Pack(hbox, table, graph, left, left+r, top, GTK_EXPAND); #ifdef TODO_GTK if(option[i].min & SAME_ROW) last = forelast, forelast = lastrow; -- 1.7.0.4