From 0678e05afa1ef3f87858b3ea3eed1d0257eff0fa Mon Sep 17 00:00:00 2001
From: Ivica Ico Bukvic <ico@vt.edu>
Date: Wed, 8 Oct 2014 15:00:39 -0400
Subject: [PATCH] *fixed regression where iemguis with custom foreground color
 tainted the border color

---
 pd/src/g_all_guis.c | 4 ++--
 pd/src/g_all_guis.h | 1 +
 pd/src/g_radio.c    | 8 ++++----
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/pd/src/g_all_guis.c b/pd/src/g_all_guis.c
index 0cf62ce20..2194b67c8 100644
--- a/pd/src/g_all_guis.c
+++ b/pd/src/g_all_guis.c
@@ -502,9 +502,8 @@ void iemgui_select(t_gobj *z, t_glist *glist, int selected)
         x->x_selected = canvas;
     else
         x->x_selected = NULL;
-    char fcol[8]; sprintf(fcol,"#%6.6x", x->x_fcol);
     sys_vgui(".x%lx.c itemconfigure {x%lx&&border} -stroke %s\n", canvas, x,
-        x->x_selected && x->x_glist == canvas ? selection_color : fcol);
+        x->x_selected && x->x_glist == canvas ? selection_color : border_color);
     x->x_draw((void *)z, glist, IEM_GUI_DRAW_MODE_SELECT);
     if (selected < 2)
     {
@@ -1184,6 +1183,7 @@ void g_iemgui_setup (void) {
 }
 
 const char *selection_color = "$pd_colors(selection)";
+const char *border_color = "$pd_colors(iemgui_border)";
 
 #define GET_OUTLET t_outlet *out = x->x_obj.ob_outlet; /* can't use int o because there's not obj_nth_outlet function */
 #define SEND_BY_SYMBOL (iemgui_has_snd(x) && x->x_snd->s_thing && (!chk_putin || x->x_put_in2out))
diff --git a/pd/src/g_all_guis.h b/pd/src/g_all_guis.h
index 9f8dd9659..3a065e21f 100644
--- a/pd/src/g_all_guis.h
+++ b/pd/src/g_all_guis.h
@@ -267,6 +267,7 @@ EXTERN void wb_init(t_widgetbehavior *wb, t_getrectfn gr, t_clickfn cl); // rena
 
 extern t_symbol *s_empty;
 EXTERN const char *selection_color;
+EXTERN const char *border_color;
 
 static inline int iemgui_has_snd (t_iemgui *x) {return x->x_snd!=s_empty;}
 static inline int iemgui_has_rcv (t_iemgui *x) {return x->x_rcv!=s_empty;}
diff --git a/pd/src/g_radio.c b/pd/src/g_radio.c
index cf7cd690e..ca476b526 100644
--- a/pd/src/g_radio.c
+++ b/pd/src/g_radio.c
@@ -44,9 +44,9 @@ void radio_draw_new(t_radio *x, t_glist *glist)
     iemgui_base_draw_new(&x->x_gui);
 
     for(i=0; i<n; i++) if (x->x_orient) {
-        if (i) sys_vgui(".x%lx.c create pline %d %d %d %d "
+        if (i) sys_vgui(".x%lx.c create prect %d %d %d %d "
             "-stroke $pd_colors(iemgui_border) "
-            "-tags {%lxBASE%d %lxBASEL x%lx text iemgui border}\n",
+            "-tags {%lxBASE%d %lxBASE x%lx text iemgui border}\n",
             canvas, x1, yi, x1+d, yi, x, i, x, x);
         sys_vgui(".x%lx.c create prect %d %d %d %d -fill #%6.6x "
             "-stroke #%6.6x -tags {%lxBUT%d x%lx text iemgui}\n",
@@ -57,9 +57,9 @@ void radio_draw_new(t_radio *x, t_glist *glist)
         yi += d;
         x->x_drawn = x->x_on;
     } else {
-        if (i) sys_vgui(".x%lx.c create pline %d %d %d %d "
+        if (i) sys_vgui(".x%lx.c create prect %d %d %d %d "
             "-stroke $pd_colors(iemgui_border) "
-            "-tags {%lxBASE%d %lxBASEL x%lx text iemgui border}\n",
+            "-tags {%lxBASE%d %lxBASE x%lx text iemgui border}\n",
             canvas, xi, y1, xi, y1+d, x, i, x, x);
         sys_vgui(".x%lx.c create prect %d %d %d %d -fill #%6.6x "
             "-stroke #%6.6x -tags {%lxBUT%d x%lx text iemgui}\n",
-- 
GitLab