From: Hugo Villeneuve Date: Thu, 12 Sep 2013 23:06:17 +0000 (-0400) Subject: Replace fixed frames with scrollable windows X-Git-Tag: v2.0.0~165 X-Git-Url: http://gitweb.hugovil.com/?a=commitdiff_plain;h=aef9693dac85d48d2c84a3e187a27802c2968181;p=emu8051.git Replace fixed frames with scrollable windows Done for program, register and memory dump windows. --- diff --git a/src/memwin.c b/src/memwin.c index 3c2b73d..baed752 100644 --- a/src/memwin.c +++ b/src/memwin.c @@ -38,15 +38,21 @@ GtkWidget * memwin_init(int width, int height) { int i; - GtkWidget *fixed_frame; + GtkWidget *scrollwin; PangoFontDescription *pango_font; char *memdummy[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - fixed_frame = gtk_frame_new(0); - gtk_frame_set_shadow_type(GTK_FRAME(fixed_frame), - GTK_SHADOW_ETCHED_OUT); - gtk_widget_set_size_request(GTK_WIDGET(fixed_frame), width, height); + scrollwin = gtk_scrolled_window_new(NULL, NULL); + gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrollwin), + GTK_SHADOW_ETCHED_OUT); + + /* Automatically add scrollbars when necessary. */ + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwin), + GTK_POLICY_AUTOMATIC, + GTK_POLICY_AUTOMATIC); + + gtk_widget_set_size_request(GTK_WIDGET(scrollwin), width, height); memclist = gtk_clist_new(18); gtk_clist_set_selection_mode(GTK_CLIST(memclist), GTK_SELECTION_SINGLE); @@ -73,9 +79,9 @@ memwin_init(int width, int height) for (i = 0; i < 16; i++) gtk_clist_append(GTK_CLIST(memclist), memdummy); - gtk_container_add(GTK_CONTAINER(fixed_frame), memclist); + gtk_container_add(GTK_CONTAINER(scrollwin), memclist); - return fixed_frame; + return scrollwin; } /* Dump 16 rows of 16 bytes from Address in Memory (direct addressing) */ diff --git a/src/pgmwin.c b/src/pgmwin.c index cd4cfde..cacc8a3 100644 --- a/src/pgmwin.c +++ b/src/pgmwin.c @@ -83,12 +83,18 @@ GtkWidget * pgmwin_init(int width, int height) { int i; - GtkWidget *fixed_frame; + GtkWidget *scrollwin; - fixed_frame = gtk_frame_new(0); - gtk_frame_set_shadow_type(GTK_FRAME(fixed_frame), - GTK_SHADOW_ETCHED_OUT); - gtk_widget_set_size_request(GTK_WIDGET(fixed_frame), width, height); + scrollwin = gtk_scrolled_window_new(NULL, NULL); + gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrollwin), + GTK_SHADOW_ETCHED_OUT); + + /* Automatically add scrollbars when necessary. */ + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwin), + GTK_POLICY_AUTOMATIC, + GTK_POLICY_AUTOMATIC); + + gtk_widget_set_size_request(GTK_WIDGET(scrollwin), width, height); pgmclist = gtk_clist_new(1); gtk_clist_set_selection_mode(GTK_CLIST(pgmclist), GTK_SELECTION_SINGLE); @@ -105,10 +111,10 @@ pgmwin_init(int width, int height) for (i = 0; i < 24; i++) gtk_clist_append(GTK_CLIST(pgmclist), pgmdummy); - gtk_container_add(GTK_CONTAINER(fixed_frame), pgmclist); + gtk_container_add(GTK_CONTAINER(scrollwin), pgmclist); gtk_signal_connect(GTK_OBJECT(pgmclist), "button-press-event", GTK_SIGNAL_FUNC(pgmwin_ButtonPressEvent), NULL); - return fixed_frame; + return scrollwin; } diff --git a/src/regwin.c b/src/regwin.c index 9817744..0e7a356 100644 --- a/src/regwin.c +++ b/src/regwin.c @@ -36,14 +36,20 @@ GtkWidget * regwin_init(int width, int height) { int i; - GtkWidget *fixed_frame; + GtkWidget *scrollwin; PangoFontDescription *pango_font; char *regdummy[] = { 0 }; - fixed_frame = gtk_frame_new(0); - gtk_frame_set_shadow_type(GTK_FRAME(fixed_frame), - GTK_SHADOW_ETCHED_OUT); - gtk_widget_set_size_request(GTK_WIDGET(fixed_frame), width, height); + scrollwin = gtk_scrolled_window_new(NULL, NULL); + gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrollwin), + GTK_SHADOW_ETCHED_OUT); + + /* Automatically add scrollbars when necessary. */ + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwin), + GTK_POLICY_AUTOMATIC, + GTK_POLICY_AUTOMATIC); + + gtk_widget_set_size_request(GTK_WIDGET(scrollwin), width, height); regclist = gtk_clist_new(1); gtk_clist_set_selection_mode(GTK_CLIST(regclist), GTK_SELECTION_SINGLE); @@ -59,9 +65,9 @@ regwin_init(int width, int height) for (i = 0; i < 24; i++) gtk_clist_append(GTK_CLIST(regclist), regdummy); - gtk_container_add(GTK_CONTAINER(fixed_frame), regclist); + gtk_container_add(GTK_CONTAINER(scrollwin), regclist); - return fixed_frame; + return scrollwin; }