Replace fixed frames with scrollable windows
authorHugo Villeneuve <hugo@hugovil.com>
Thu, 12 Sep 2013 23:06:17 +0000 (19:06 -0400)
committerHugo Villeneuve <hugo@hugovil.com>
Tue, 1 Oct 2013 02:17:54 +0000 (22:17 -0400)
Done for program, register and memory dump windows.

src/memwin.c
src/pgmwin.c
src/regwin.c

index 3c2b73d..baed752 100644 (file)
@@ -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) */
index cd4cfde..cacc8a3 100644 (file)
@@ -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;
 }
index 9817744..0e7a356 100644 (file)
@@ -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;
 }