X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=cde%2Fprograms%2Fdtstyle%2FColorEdit.c;h=9ba5ded7ac1241b72044088f69286c48f37a89ee;hb=3503243d14aabccf09337dfd6b0133513d14d846;hp=9e0676333b3046260843dafac6df2b3664e3a41b;hpb=735bdff39232a29392ee9e2c8eb66d2a285bfb58;p=oweals%2Fcde.git diff --git a/cde/programs/dtstyle/ColorEdit.c b/cde/programs/dtstyle/ColorEdit.c index 9e067633..9ba5ded7 100644 --- a/cde/programs/dtstyle/ColorEdit.c +++ b/cde/programs/dtstyle/ColorEdit.c @@ -16,7 +16,7 @@ * details. * * You should have received a copy of the GNU Lesser General Public - * License along with these librararies and programs; if not, write + * License along with these libraries and programs; if not, write * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth * Floor, Boston, MA 02110-1301 USA */ @@ -44,6 +44,7 @@ #include #include +#include #include #include @@ -187,6 +188,16 @@ ColorEditor( { edit.color_set = color_set; CopyPixelSet(&edit.oldButtonColor,edit.color_set); + + /* update "old" button if necessary */ + if(style.visualClass==TrueColor || style.visualClass==DirectColor){ + XtVaSetValues(edit.oldButton, + XmNbackground,edit.color_set->bg.pixel, + XmNarmColor,edit.color_set->bg.pixel, + XmNforeground,edit.color_set->fg.pixel, + XmNtopShadowColor,edit.color_set->ts.pixel, + XmNbottomShadowColor,edit.color_set->bs.pixel,NULL); + } InitializeNewButton(); SetScales(&edit.color_set->bg); XtManageChild(edit.DialogShell); @@ -225,9 +236,9 @@ CreateColorEditor( edit.current_scale = NONE; /* Set up DialogBox button labels. */ - button_string[0] = CMPSTR(_DtOkString); - button_string[1] = CMPSTR(_DtCancelString); - button_string[2] = CMPSTR(_DtHelpString); + button_string[0] = CMPSTR((String) _DtOkString); + button_string[1] = CMPSTR((String) _DtCancelString); + button_string[2] = CMPSTR((String) _DtHelpString); /* Note that save.poscnt has been initialized elsewhere. * save.posArgs may contain information from restoreColorEdit(). */ @@ -287,8 +298,17 @@ CreateColorEditor( XtSetArg(args[n], XmNverticalSpacing, style.verticalSpacing); n++; sampleForm = XmCreateForm(sampleTB, "sampleForm", args, n); - /* Create Old and New Buttons */ - InitializeOldButton(); + /* Create Old and New Buttons */ + if(style.visualClass==TrueColor || style.visualClass==DirectColor){ + edit.oldButtonColor.bg.pixel = edit.color_set->bg.pixel; + edit.oldButtonColor.fg.pixel = edit.color_set->fg.pixel; + edit.oldButtonColor.sc.pixel = edit.color_set->sc.pixel; + edit.oldButtonColor.bs.pixel = edit.color_set->bs.pixel; + edit.oldButtonColor.ts.pixel = edit.color_set->ts.pixel; + CopyPixelSet(&edit.oldButtonColor,edit.color_set); + }else{ + InitializeOldButton(); + } if(!OldNewSame) { n=0; @@ -973,7 +993,36 @@ GenerateColors( void ) edit.color_set->bs.blue = 0; } - XStoreColors(style.display, style.colormap, colors, j ); + if(style.visualClass==PseudoColor || style.visualClass==StaticColor) + { + XStoreColors(style.display, style.colormap, colors, j ); + } + else if(style.visualClass==TrueColor || style.visualClass==DirectColor) + { + static unsigned long pixels[4]; + static int count=0; + + if(count){ + XFreeColors(style.display,style.colormap,pixels,count,0); + count=0; + } + + if(XAllocColor(style.display,style.colormap,&edit.color_set->fg)) + pixels[count++]=edit.color_set->fg.pixel; + if(XAllocColor(style.display,style.colormap,&edit.color_set->bg)) + pixels[count++]=edit.color_set->bg.pixel; + if(XAllocColor(style.display,style.colormap,&edit.color_set->ts)) + pixels[count++]=edit.color_set->ts.pixel; + if(XAllocColor(style.display,style.colormap,&edit.color_set->bs)) + pixels[count++]=edit.color_set->bs.pixel; + + XtVaSetValues(edit.newButton, + XmNbackground,edit.color_set->bg.pixel, + XmNarmColor,edit.color_set->bg.pixel, + XmNforeground,edit.color_set->fg.pixel, + XmNtopShadowColor,edit.color_set->ts.pixel, + XmNbottomShadowColor,edit.color_set->bs.pixel,NULL); + } } /************************************************************************ @@ -993,7 +1042,7 @@ changRGB_CB( reason_code = ((XmAnyCallbackStruct *)call_data)->reason; if ( reason_code == XmCR_VALUE_CHANGED || reason_code == XmCR_DRAG ) { - color = (int) client_data; + color = (int) (intptr_t) client_data; value = ((XmScaleCallbackStruct *)call_data)->value; if (edit.current_scale == NONE) @@ -1045,7 +1094,7 @@ changHSV_CB( reason_code = ((XmAnyCallbackStruct *)call_data)->reason; if ( reason_code == XmCR_VALUE_CHANGED || reason_code == XmCR_DRAG ) { - scale = (int) client_data; + scale = (int) (intptr_t) client_data; value = ((XmScaleCallbackStruct *)call_data)->value; if (edit.current_scale == NONE) @@ -1187,8 +1236,8 @@ CopyPixelSet( XtSetValues(edit.oldButton, args, n); } - - XStoreColors(style.display, style.colormap, colors, j ); + if(style.visualClass == PseudoColor || style.visualClass == GrayScale) + XStoreColors(style.display, style.colormap, colors, j ); } @@ -1682,7 +1731,9 @@ saveColorEdit( sprintf(bufr, "%s*colorEditDlg.x: %d\n", bufr, x); sprintf(bufr, "%s*colorEditDlg.y: %d\n", bufr, y); /*any other parameter you want to save goes here*/ - write (fd, bufr, strlen(bufr)); + if(-1 == write (fd, bufr, strlen(bufr))) { + perror(strerror(errno)); + } } }