diff options
author | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2001-04-21 21:30:09 +0000 |
---|---|---|
committer | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2001-04-21 21:30:09 +0000 |
commit | b7a8727c51fffc5ca6d5b8631ab38cce6f68f97b (patch) | |
tree | c982849b1c84affb73be44a04dc1d8b9cc9343a6 /mixgtk | |
parent | 7504ac44ecdfd4ad80d3b4755270f9f748979971 (diff) | |
download | mdk-b7a8727c51fffc5ca6d5b8631ab38cce6f68f97b.tar.gz mdk-b7a8727c51fffc5ca6d5b8631ab38cce6f68f97b.tar.bz2 |
(on_mixal_select_row) set/unset breakpoints on location line
Diffstat (limited to 'mixgtk')
-rw-r--r-- | mixgtk/mixgtk_mixal.c | 65 |
1 files changed, 48 insertions, 17 deletions
diff --git a/mixgtk/mixgtk_mixal.c b/mixgtk/mixgtk_mixal.c index 2cfb428..21c83e9 100644 --- a/mixgtk/mixgtk_mixal.c +++ b/mixgtk/mixgtk_mixal.c @@ -1,7 +1,7 @@ /* -*-c-*- -------------- mixgtk_mixal.c : * Implementation of the functions declared in mixgtk_mixal.h * ------------------------------------------------------------------ - * Last change: Time-stamp: "01/04/01 15:23:18 jose" + * Last change: Time-stamp: "2001-04-21 23:19:05 jao" * ------------------------------------------------------------------ * Copyright (C) 2001 Free Software Foundation, Inc. * @@ -31,41 +31,67 @@ static mix_vm_t *vm_; static GtkCList *clist_; -static GdkColor sel_color_; -static GdkColor break_color_; -static GdkColor plain_color_; static gulong lineno_; +static GdkColor colors_[3][2]; +static GdkColormap *colormap_ = NULL; +static const char* default_colors_[3][2] = { + {"red", "black"}, + {"lightgrey", "black"}, + {"white", "black"} +}; -#define SEL_COLOR_ "lightgrey" -#define BREAK_COLOR_ "red" -#define PLAIN_COLOR_ "white" static gboolean init_color_ (GdkColor *c, const gchar *name) { - static GdkColormap *cmap = NULL; - if (!cmap) cmap = gtk_widget_get_colormap (GTK_WIDGET (clist_)); + if (!colormap_) + colormap_ = gtk_widget_get_colormap (GTK_WIDGET (clist_)); return (gdk_color_parse (name, c) && - gdk_colormap_alloc_color (cmap, c, FALSE, TRUE)); + gdk_colormap_alloc_color (colormap_, c, FALSE, TRUE)); } /* initialise the mixal widgets */ gboolean mixgtk_mixal_init (mix_vm_t *vm) { + int i,j; + g_return_val_if_fail (vm != NULL, FALSE); vm_ = vm; clist_ = GTK_CLIST (mixgtk_widget_factory_get (MIXGTK_WIDGET_MIXAL)); g_return_val_if_fail (clist_ != NULL, FALSE); /* allocate colors */ - g_return_val_if_fail (init_color_ (&sel_color_, SEL_COLOR_), FALSE); - g_return_val_if_fail (init_color_ (&break_color_, BREAK_COLOR_), FALSE); - g_return_val_if_fail (init_color_ (&plain_color_, PLAIN_COLOR_), FALSE); - + for (i = 0; i < 3; ++i) + for (j = 0; j < 2; ++j) + g_return_val_if_fail (init_color_ (&colors_[i][j], default_colors_[i][j]), + FALSE); return TRUE; } +/* set the plain, location pointer and break colors */ +void +mixgtk_mixal_set_color (mixal_line_t line, mixal_line_zone_t zone, + guint16 color[3]) +{ + g_return_if_fail (color != NULL); + g_return_if_fail (line > MIXAL_LINE_PLAIN); + g_return_if_fail (zone > MIXAL_LINE_FG); + colors_[line][zone].red = color[0]; + colors_[line][zone].green = color[1]; + colors_[line][zone].blue = color[2]; + gdk_colormap_alloc_color (colormap_, &colors_[line][zone], FALSE, TRUE); + mixgtk_mixal_update_bp_all (); +} + +const GdkColor * +mixgtk_mixal_get_color (mixal_line_t line, mixal_line_zone_t zone) +{ + g_return_val_if_fail (line > MIXAL_LINE_PLAIN, FALSE); + g_return_val_if_fail (zone > MIXAL_LINE_FG, FALSE); + return &colors_[line][zone]; +} + /* load the corresponding mixal file */ void mixgtk_mixal_load_file (void) @@ -125,7 +151,11 @@ reset_bg_ (gint row) gint addr = GPOINTER_TO_INT (gtk_clist_get_row_data (clist_, row)); gboolean isset = mix_vm_has_breakpoint_at_address (vm_, addr); gtk_clist_set_background (clist_, row, - isset ? &break_color_ : &plain_color_); + isset ? &colors_[MIXAL_LINE_BREAK][MIXAL_LINE_BG]: + &colors_[MIXAL_LINE_PLAIN][MIXAL_LINE_BG]); + gtk_clist_set_foreground (clist_, row, + isset ? &colors_[MIXAL_LINE_BREAK][MIXAL_LINE_FG]: + &colors_[MIXAL_LINE_PLAIN][MIXAL_LINE_FG]); } static void @@ -133,7 +163,8 @@ select_row_ (gint row) { static gint last = -1; - gtk_clist_set_background (clist_, row, &sel_color_); + gtk_clist_set_background (clist_, row, &colors_[MIXAL_LINE_LOC][MIXAL_LINE_BG]); + gtk_clist_set_foreground (clist_, row, &colors_[MIXAL_LINE_LOC][MIXAL_LINE_FG]); if (gtk_clist_row_is_visible (clist_, row) != GTK_VISIBILITY_FULL) gtk_clist_moveto (clist_, row, 0, 0.25, 0); if (last != -1 && last != row) reset_bg_ (last); @@ -202,7 +233,7 @@ on_mixal_select_row (GtkWidget *w, gint row, gint col, GdkEventButton *e, gtk_clist_unselect_row (clist_, row, col); addr = GPOINTER_TO_INT (gtk_clist_get_row_data (clist_, row)); pc = mix_vm_get_prog_count (vm_); - if (addr < MIX_VM_CELL_NO && addr != pc) + if (addr < MIX_VM_CELL_NO) { isset = mix_vm_has_breakpoint_at_address (vm_, addr); if (isset) |