* 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
*/
#include <X11/keysym.h>
#include <math.h>
+#include <errno.h>
#include <X11/Xlib.h>
#include <Xm/MwmUtil.h>
{
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);
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;
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);
+ }
}
/************************************************************************
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)
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)
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 );
}
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));
+ }
}
}