Improve window sizing
authorHugo Villeneuve <hugo@hugovil.com>
Sat, 29 Oct 2011 19:38:34 +0000 (19:38 +0000)
committerHugo Villeneuve <hugo@hugovil.com>
Sun, 8 Sep 2013 22:54:51 +0000 (18:54 -0400)
Based on suggestions from Pierre Ferrari (piferr4ri at gmail.com).

src/gtksizes.h
src/memwin.c

index ec802e1..fb483ec 100644 (file)
 #ifndef _GTKSIZES_H_
 #define _GTKSIZES_H_
 
+/* Width, in pixels, of a fixed font symbol. */
+#define FIXED_FONT_SYMBOL_WIDTH 10
+
+/* Height, in pixels, of a fixed font symbol. */
+#define FIXED_FONT_SYMBOL_HEIGHT 22
+
 #define NUMBER_OF_BUTTONS  5
 #define BUTTON_WIDTH       60
 #define BUTTON_HEIGHT      60
 #define BUTTONS_BAR_WIDTH  (NUMBER_OF_BUTTONS * BUTTON_WIDTH)
 #define BUTTONS_BAR_HEIGHT BUTTON_HEIGHT
 
-#define REG_WIN_WIDTH      100
-#define REG_WIN_HEIGHT     390
+/* 12 symbols + border. */
+#define REG_WIN_WIDTH      (FIXED_FONT_SYMBOL_WIDTH * 13)
+#define REG_WIN_HEIGHT     (FIXED_FONT_SYMBOL_HEIGHT * 24)
 
-#define PGM_WIN_WIDTH      480
-#define PGM_WIN_HEIGHT     390
+#define MEM_WIN_WIDTH      (FIXED_FONT_SYMBOL_WIDTH * 68) /* 68 symbols. */
+#define MEM_WIN_HEIGHT     (FIXED_FONT_SYMBOL_HEIGHT * 17)
 
-#define MEM_WIN_WIDTH      590
-#define MEM_WIN_HEIGHT     280
+#define PGM_WIN_WIDTH      (MEM_WIN_WIDTH - REG_WIN_WIDTH)
+#define PGM_WIN_HEIGHT     REG_WIN_HEIGHT
 
 #define MENU_BAR_HEIGHT    0
 
-#define MAIN_WIN_WIDTH     (REG_WIN_WIDTH + PGM_WIN_WIDTH)
+#define MAIN_WIN_WIDTH     MEM_WIN_WIDTH
 #define MAIN_WIN_HEIGHT    (BUTTONS_BAR_HEIGHT + REG_WIN_HEIGHT + MEM_WIN_HEIGHT)
 
 #endif /* _GTKSIZES_H_ */
index 37cc8e0..135588a 100644 (file)
@@ -29,6 +29,7 @@
 #include "memory.h"
 #include "hexfile.h"
 #include "cpu8051.h"
+#include "gtksizes.h"
 #include "memwin.h"
 
 static GtkWidget *memclist;
@@ -56,13 +57,15 @@ memwin_init(int width, int height)
                        GTK_CLIST(memclist), i, GTK_JUSTIFY_LEFT);
        }
 
-       gtk_clist_set_column_width(GTK_CLIST(memclist), 0, 5*8);
+       gtk_clist_set_column_width(GTK_CLIST(memclist), 0,
+                                  5 * FIXED_FONT_SYMBOL_WIDTH);
 
        for (i = 1; i < 17; i++)
-               gtk_clist_set_column_width(GTK_CLIST(memclist), i, 2 * 8);
-
-       gtk_clist_set_column_width(GTK_CLIST(memclist), 17, 16 * 8);
+               gtk_clist_set_column_width(GTK_CLIST(memclist), i,
+                                          2 * FIXED_FONT_SYMBOL_WIDTH);
 
+       gtk_clist_set_column_width(GTK_CLIST(memclist), 17,
+                                  16 * FIXED_FONT_SYMBOL_WIDTH);
 
        pango_font = pango_font_description_from_string(FIXED_FONT);
        gtk_widget_modify_font(memclist, pango_font);