From 49254d2c6abc5586805adb5186172fabefcad7d9 Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Wed, 20 Feb 2013 11:56:12 +0100 Subject: [PATCH] Fix sizing of slave board GTK For lack of a known method to specify a default size for Graph widgets, we have to use the same system as for the main board: create with 0x0 size, and measure the size of the outer window to determine margins. After every popup we then resize to the required board size plus these margins. (Awful...) --- dialogs.c | 1 + dialogs.h | 1 + gtk/xboard.c | 15 +++++++++++++++ xaw/xboard.c | 5 +++++ 4 files changed, 22 insertions(+), 0 deletions(-) diff --git a/dialogs.c b/dialogs.c index ffaad6d..0e76041 100644 --- a/dialogs.c +++ b/dialogs.c @@ -2233,6 +2233,7 @@ SlavePopUp () dualOptions[3].max = dualOptions[2].max = size; // board width dualOptions[0].max = dualOptions[1].max = size/2 - 3; // clock width GenericPopUp(dualOptions, "XBoard", DummyDlg, BoardWindow, NONMODAL, 1); + SlaveResize(dualOptions+3); } void diff --git a/dialogs.h b/dialogs.h index 6d7e2b5..3329e76 100644 --- a/dialogs.h +++ b/dialogs.h @@ -180,6 +180,7 @@ void DisplayTimerLabel P((Option *opt, char *color, long timer, int highlight)); void SetWindowTitle P((char *text, char *title, char *icon)); void SetupDropMenu P((void)); Option *BoardPopUp P((int squareSize, int lineGap, void *clockFontThingy)); +void SlaveResize P((Option *opt)); int SetCurrentComboSelection P((Option *opt)); void BoxAutoPopUp P((char *buf)); diff --git a/gtk/xboard.c b/gtk/xboard.c index e4c62c4..a5b015c 100644 --- a/gtk/xboard.c +++ b/gtk/xboard.c @@ -691,6 +691,21 @@ PrintOptions () if(len) buf[len] = NULLCHAR, printf("%s\n", buf); } +void +SlaveResize (Option *opt) +{ + static int slaveW, slaveH, w, h; + GtkAllocation a; + if(!slaveH) { + gtk_widget_get_allocation(shells[DummyDlg], &a); + w = a.width; h = a.height; + gtk_widget_get_allocation(opt->handle, &a); + slaveW = w - opt->max; // [HGM] needed to set new shellWidget size when we resize board + slaveH = h - a.height + 13; + } + gtk_window_resize(GTK_WINDOW(shells[DummyDlg]), slaveW + opt->max, slaveH + opt->value); +} + int main (int argc, char **argv) { diff --git a/xaw/xboard.c b/xaw/xboard.c index a083e7c..e162be7 100644 --- a/xaw/xboard.c +++ b/xaw/xboard.c @@ -1084,6 +1084,11 @@ PrintOptions () if(len) buf[len] = NULLCHAR, printf("%s\n", buf); } +void +SlaveResize (Option *opt) +{ +} + int main (int argc, char **argv) { -- 1.7.0.4