X-Git-Url: http://gitweb.hugovil.com/?a=blobdiff_plain;f=src%2Fregwin.c;h=68b7593164ea5f5bc41a029ec9c3ea089ea2e275;hb=fc4dd8fa3aab94a5f63c097ed9809c75560abd7d;hp=91f156adda56be6644ce8281929fb5d671c8859f;hpb=4c305c73f8110d03b99cec045b3c5741867fd46b;p=emu8051.git diff --git a/src/regwin.c b/src/regwin.c index 91f156a..68b7593 100644 --- a/src/regwin.c +++ b/src/regwin.c @@ -1,5 +1,23 @@ -/* regwin.cpp */ - +/* + * regwin.cpp + * + * Copyright (C) 1999 Jonathan St-André + * Copyright (C) 1999 Hugo Villeneuve + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. + */ #if HAVE_CONFIG_H # include "config.h" @@ -7,61 +25,60 @@ #include +#include "common.h" #include "reg8051.h" #include "cpu8051.h" #include "regwin.h" -/* private */ -/*GtkWidget *regwin;*/ -GtkWidget *regclist; - - -/* in cpu8051.c */ -extern unsigned int PC; +static GtkWidget *regclist; -////////////////////////////////////////////////////////////////////////////// -// RegWin constructor -////////////////////////////////////////////////////////////////////////////// -void -regwin_init( GtkWidget *parentwin ) +GtkWidget * +regwin_init( int width, int height ) { int i; - GtkStyle *style; - GdkFont *fixedfont; - fixedfont = gdk_font_load( "-adobe-courier-medium-r-normal--12-120-75-75-m-70-iso8859-1" ); - + GtkWidget *fixed_frame; + + fixed_frame = gtk_frame_new(0); + gtk_frame_set_shadow_type( GTK_FRAME( fixed_frame ), GTK_SHADOW_ETCHED_OUT ); + gtk_widget_set_usize( GTK_WIDGET( fixed_frame ), width, height ); + regclist = gtk_clist_new( 1 ); gtk_clist_set_selection_mode( GTK_CLIST( regclist ), GTK_SELECTION_SINGLE ); - gtk_widget_set_usize( GTK_WIDGET( regclist ), REG_WIN_WIDTH, REG_WIN_HEIGHT ); + gtk_widget_set_usize( GTK_WIDGET( regclist ), width, height ); gtk_clist_set_column_justification( GTK_CLIST( regclist ), 0, GTK_JUSTIFY_LEFT ); - gtk_clist_set_column_width( GTK_CLIST( regclist ), 0, REG_WIN_WIDTH ); + gtk_clist_set_column_width( GTK_CLIST( regclist ), 0, width ); - style = gtk_widget_get_style( GTK_WIDGET( regclist ) ); - -#ifdef USE_GTK2 - gtk_style_set_font( style, fixedfont ); +#if ( GTK_MAJOR_VERSION == 2) + PangoFontDescription *pango_font; + pango_font = pango_font_description_from_string( FIXED_FONT ); + gtk_widget_modify_font( regclist, pango_font ); #else - style->font = fixedfont; + { + GtkStyle *style; + /* Setting font for the widget. */ + style = gtk_style_new(); + gdk_font_unref( style->font ); + + /* Load a fixed font */ + style->font = gdk_font_load( FIXED_FONT ); + gtk_widget_set_style( GTK_WIDGET( regclist ), style ); + } #endif - gtk_widget_set_style( GTK_WIDGET( regclist ), style ); - char *regdummy[] = { 0 }; - for ( i = 0; i < 24; i++ ) + for ( i = 0; i < 24; i++ ) { gtk_clist_append( GTK_CLIST( regclist ), regdummy ); + } - gtk_container_add( GTK_CONTAINER( parentwin ), regclist ); + gtk_container_add( GTK_CONTAINER( fixed_frame ), regclist ); - gtk_widget_show( regclist ); + return fixed_frame; } -////////////////////////////////////////////////////////////////////////////// -// void regwin_Show( CPU8051 *CPU ) -// Show registers -////////////////////////////////////////////////////////////////////////////// +/* Show registers. */ void regwin_Show( void ) { @@ -73,7 +90,7 @@ regwin_Show( void ) gtk_clist_freeze( GTK_CLIST( regclist ) ); // Main registers - sprintf( TextTmp , "PC = %.4X", PC ); + sprintf( TextTmp , "PC = %.4X", cpu8051.pc ); gtk_clist_set_text( GTK_CLIST( regclist ), row++, 0, TextTmp ); sprintf( TextTmp , "SP = %.2X", cpu8051_ReadD( _SP_ ) ); gtk_clist_set_text( GTK_CLIST( regclist ), row++, 0, TextTmp ); @@ -89,13 +106,13 @@ regwin_Show( void ) gtk_clist_set_text( GTK_CLIST( regclist ), row++, 0, TextTmp ); // Ports registers - sprintf( TextTmp , "P0 = %.2X", cpu8051_ReadD( _P0_ ) ); + sprintf( TextTmp , "P0 = %.2X", cpu8051_ReadD( _P0_ ) ); gtk_clist_set_text( GTK_CLIST( regclist ), row++, 0, TextTmp ); - sprintf( TextTmp , "P1 = %.2X", cpu8051_ReadD( _P1_ ) ); + sprintf( TextTmp , "P1 = %.2X", cpu8051_ReadD( _P1_ ) ); gtk_clist_set_text( GTK_CLIST( regclist ), row++, 0, TextTmp ); - sprintf( TextTmp , "P2 = %.2X", cpu8051_ReadD( _P2_ ) ); + sprintf( TextTmp , "P2 = %.2X", cpu8051_ReadD( _P2_ ) ); gtk_clist_set_text( GTK_CLIST( regclist ), row++, 0, TextTmp ); - sprintf( TextTmp , "P3 = %.2X", cpu8051_ReadD( _P3_ ) ); + sprintf( TextTmp , "P3 = %.2X", cpu8051_ReadD( _P3_ ) ); gtk_clist_set_text( GTK_CLIST( regclist ), row++, 0, TextTmp ); // Misc Registers