Search
lxdream.org :: lxdream/src/gui/gui.c
lxdream 0.9.1
released Jun 29
Download Now
filename src/gui/gui.c
changeset 9:2784c7660165
prev2:42349f6ea216
next18:9a1b5d75703f
author nkeynes
date Mon Dec 12 10:37:41 2005 +0000 (15 years ago)
permissions -rw-r--r--
last change Use cpu-specific is_valid_page function
view annotate diff log raw
     1 #include <stdlib.h>
     2 #include <stdarg.h>
     3 #include <gnome.h>
     4 #include <math.h>
     5 #include "gui.h"
     6 #include "mem.h"
     7 #include "sh4dasm.h"
     8 #include "sh4core.h"
    10 #define REGISTER_FONT "-*-fixed-medium-r-normal--12-*-*-*-*-*-iso8859-1"
    12 GdkColor clrNormal, clrChanged, clrError, clrWarn, clrPC, clrDebug, clrTrace;
    13 PangoFontDescription *fixed_list_font;
    15 void open_file_callback(GtkWidget *btn, gpointer user_data);
    16 void open_file_canceled(GtkWidget *btn, gpointer user_data);
    17 void open_file( char *filename );
    19 void init_gui() {
    20     GdkColormap *map;
    22     clrNormal.red = clrNormal.green = clrNormal.blue = 0;
    23     clrChanged.red = clrChanged.green = 64*256;
    24     clrChanged.blue = 154*256;
    25     clrError.red = 65535;
    26     clrError.green = clrError.blue = 64*256;
    27     clrPC.red = 32*256;
    28     clrPC.green = 170*256;
    29     clrPC.blue = 52*256;
    30     clrWarn = clrChanged;
    31     clrTrace.red = 156*256;
    32     clrTrace.green = 78*256;
    33     clrTrace.blue = 201*256;
    34     clrDebug = clrPC;
    36     map = gdk_colormap_new(gdk_visual_get_best(), TRUE);
    37     gdk_colormap_alloc_color(map, &clrNormal, TRUE, TRUE);
    38     gdk_colormap_alloc_color(map, &clrChanged, TRUE, TRUE);
    39     gdk_colormap_alloc_color(map, &clrError, TRUE, TRUE);
    40     gdk_colormap_alloc_color(map, &clrWarn, TRUE, TRUE);
    41     gdk_colormap_alloc_color(map, &clrPC, TRUE, TRUE);
    42     gdk_colormap_alloc_color(map, &clrDebug, TRUE, TRUE);
    43     gdk_colormap_alloc_color(map, &clrTrace, TRUE, TRUE);
    44     fixed_list_font = pango_font_description_from_string("Courier 10");
    45 }
    47 void update_gui(void) {
    48     update_registers(main_debug);
    49     update_icount(main_debug);
    50     update_mmr_win();
    51     dump_win_update_all();
    52 }
    55 void open_file_callback(GtkWidget *btn, gpointer user_data) {
    56     GtkFileSelection *file = GTK_FILE_SELECTION(user_data);
    57     gchar *filename = strdup( gtk_file_selection_get_filename(
    58         GTK_FILE_SELECTION(file) ) );
    59     gtk_widget_destroy(GTK_WIDGET(file));
    60     open_file( filename );
    61     free(filename);
    62 }
    64 void open_file_canceled(GtkWidget *btn, gpointer user_data) {
    65     gtk_widget_destroy(GTK_WIDGET(user_data));
    66 }
    68 void open_file_dialog( void )
    69 {
    70     GtkWidget *file;
    72     file = gtk_file_selection_new( "Open..." );
    73     gtk_signal_connect( GTK_OBJECT(GTK_FILE_SELECTION(file)->ok_button),
    74                         "clicked", GTK_SIGNAL_FUNC(open_file_callback), file );
    75     gtk_signal_connect( GTK_OBJECT(GTK_FILE_SELECTION(file)->cancel_button),
    76                         "clicked", GTK_SIGNAL_FUNC(open_file_canceled), file );
    77     gtk_widget_show( file );
    78 }
    80 uint32_t gtk_entry_get_hex_value( GtkEntry *entry, uint32_t defaultValue )
    81 {
    82     gchar *text = gtk_entry_get_text(entry);
    83     if( text == NULL )
    84         return defaultValue;
    85     gchar *endptr;
    86     uint32_t value = strtoul( text, &endptr, 16 );
    87     if( text == endptr ) { /* invalid input */
    88         value = defaultValue;
    89         gtk_entry_set_hex_value( entry, value );
    90     }
    91     return value;
    92 }
    94 void gtk_entry_set_hex_value( GtkEntry *entry, uint32_t value )
    95 {
    96     char buf[10];
    97     sprintf( buf, "%08X", value );
    98     gtk_entry_set_text( entry, buf );
    99 }
.