2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /************************************<+>*************************************
24 ****************************************************************************
30 ** Description: Controls the Dtstyle Color dialog
33 ** (c) Copyright Hewlett-Packard Company, 1990.
37 ****************************************************************************
38 ************************************<+>*************************************/
39 /* $TOG: ColorMain.c /main/8 1998/01/12 10:41:53 cshi $ */
40 /*+++++++++++++++++++++++++++++++++++++++*/
42 /*+++++++++++++++++++++++++++++++++++++++*/
48 #include <X11/Intrinsic.h>
50 #include <Xm/MwmUtil.h>
58 #include <Xm/MessageB.h>
59 #include <Xm/Protocols.h>
61 #include <Xm/PushBG.h>
62 #include <Xm/ToggleBG.h>
63 #include <Xm/RowColumn.h>
64 #include <Xm/SelectioB.h>
66 #include <Xm/VendorSEP.h>
68 #include <Dt/DialogBox.h>
70 #include <Dt/TitleBox.h>
72 #include <Dt/HourGlass.h>
76 #include "SaveRestore.h"
77 #include "ColorMain.h"
78 #include "ColorFile.h"
79 #include "ColorEdit.h"
85 /*+++++++++++++++++++++++++++++++++++++++*/
86 /* include extern functions */
87 /*+++++++++++++++++++++++++++++++++++++++*/
90 /*+++++++++++++++++++++++++++++++++++++++*/
92 /*+++++++++++++++++++++++++++++++++++++++*/
93 #define DEFAULT_PALETTE "Default"
94 #define TYPE_OF_MONITOR "Type Of Monitor" /* also in dtsession/SrvPalette.c */
96 #define BORDER_WIDTH 3
97 #define COLOR_BUTTON_WIDTH 35
98 #define COLOR_BUTTON_HEIGHT 35
99 #define ADD_PALETTE_TOP_OFFSET 20
100 #define ADD_PALETTE_LEFT_POSITION 65
101 #define PALETTE_RC_RIGHT_POSITION 60
103 #define DEFAULT_COLOR (XmCO_HIGH_COLOR + 1)
105 #define B_W_STR "B_W"
106 #define LOW_COLOR_STR "LOW_COLOR"
107 #define MEDIUM_COLOR_STR "MEDIUM_COLOR"
108 #define HIGH_COLOR_STR "HIGH_COLOR"
109 #define DEFAULT_COLOR_STR "DEFAULT"
111 #define STR1 ((char *)GETMESSAGE(14, 29, "A palette named '%s' already exists.\nThis new palette will overwrite the old one.\nIs this what you want to do?"))
112 #define STR2 ((char *)GETMESSAGE(14, 23, "Delete palette '%s'?\n"))
113 #define NEXT_SESSION ((char *)GETMESSAGE(14, 28, "The selected palette will take effect\nat your next session."))
114 #define CANT_DELETE ((char *)GETMESSAGE(14, 18, "Can't delete the last palette.\n"))
115 #define COLORUSE_WHEN ((char *)GETMESSAGE(14, 27, "The new Color Use value will take effect\nat your next session."))
117 /*+++++++++++++++++++++++++++++++++++++++*/
119 /*+++++++++++++++++++++++++++++++++++++++*/
125 Widget addPaletteButton;
126 Widget deletePaletteButton;
130 Widget mediumColorTG;
136 char *currentColorUseStr;
140 /*+++++++++++++++++++++++++++++++++++++++*/
141 /* Internal Functions */
142 /*+++++++++++++++++++++++++++++++++++++++*/
144 static int CreateMainWindow( Widget parent) ;
145 static void selectPaletteCB(
147 XtPointer client_data,
148 XtPointer call_data) ;
149 static void selectColorCB(
151 XtPointer client_data,
152 XtPointer call_data) ;
153 static void timeoutCB(
154 XtPointer client_data,
156 static void addPaletteCB(
158 XtPointer client_data,
159 XtPointer call_data) ;
160 static void addCancelCB(
162 XtPointer client_data,
163 XtPointer call_data) ;
166 XtPointer client_data,
167 XtPointer call_data) ;
168 static void setDlgOkCB(
170 XtPointer client_data,
171 XtPointer call_data) ;
172 static void modifyColorCB(
174 XtPointer client_data,
175 XtPointer call_data) ;
176 static void dialogBoxCB(
178 XtPointer client_data,
179 XtPointer call_data) ;
181 palette *newPalette) ;
182 static void deletePaletteCB(
184 XtPointer client_data,
185 XtPointer call_data) ;
186 static void deleteOkCB(
188 XtPointer client_data,
189 XtPointer call_data) ;
190 static void deleteCancelCB(
192 XtPointer client_data,
193 XtPointer call_data) ;
194 static void resourcesCB(
196 XtPointer client_data,
197 XtPointer call_data) ;
198 static void colorUseCB(
200 XtPointer client_data,
201 XtPointer call_data) ;
202 static void colorUseExitCB(
204 XtPointer client_data,
205 XtPointer call_data) ;
206 static void activateCBexitColor(
208 XtPointer client_data,
209 XtPointer call_data) ;
210 static void _DtmapCB(
212 XtPointer client_data,
213 XtPointer call_data) ;
214 static void _DtmapCB_colorUse(
216 XtPointer client_data,
217 XtPointer call_data) ;
218 static void colorEditorCB(
220 XtPointer client_data,
221 XtPointer call_data) ;
223 static void allocNewColors(void);
224 static Boolean ValidName( char *name) ;
229 /*+++++++++++++++++++++++++++++++++++++++*/
230 /* Global Variables */
231 /*+++++++++++++++++++++++++++++++++++++++*/
234 Atom XA_TYPE_MONITOR;
236 /* Palettes exist in a linked list. */
237 palette *pHeadPalette;
238 palette *pCurrentPalette;
239 palette *pOldPalette;
241 Widget modifyColorButton;
251 /*+++++++++++++++++++++++++++++++++++++++*/
252 /* Internal Variables */
253 /*+++++++++++++++++++++++++++++++++++++++*/
255 /* palette names without the .dp */
256 static char *WHITE_BLACK = "WhiteBlack";
257 static char *BLACK_WHITE = "BlackWhite";
258 static char *WHITE_ONLY = "White";
259 static char *BLACK_ONLY = "Black";
261 static char *PALETTEDLG = "paletteDlg";
262 static saveRestore save = {FALSE, 0, };
264 static Widget colorButton[XmCO_MAX_NUM_COLORS];
265 static Widget addDialog;
266 static Widget deleteDialog;
267 static Widget colorUseDialog;
268 static palette OrgPalette;
269 static XtIntervalId timeID;
270 static int dclick_time;
271 static int selected_button;
272 static int selected_position;
273 static Atom XA_WM_DELETE_WINDOW;
274 static char defaultName_restore[50];
275 static palette *loop_palette, *loop_palette2;
276 static int loopcount = 0;
277 static colorWidgets colorDialog;
278 static Widget gParent;
282 * copy of the system palette description file for the
283 * current locale in xrm form
285 XrmDatabase sys_pl_DB = NULL;
288 * copy of the admin palette description file for the
289 * current locale in xrm form
291 XrmDatabase adm_pl_DB = NULL;
294 * final combination of the admin & system dta bases
296 XrmDatabase pl_DB = NULL;
299 * copy of the palette description file from the user's home
300 * directory. This database is locale independent and will always
303 XrmDatabase hm_pl_DB = NULL;
313 /* load the palette description data base for the given locale*/
314 /* from that locale's description file from the system location */
316 lang = setlocale (LC_CTYPE,NULL);
318 #ifdef hpux /* hpux-specific parsing of the locale string */
319 /* The following code is identical to the
320 ExtractLocaleName function in WmResParse.c
323 #define MAXLOCALE 64 /* buffer size of locale name */
328 static char buf[MAXLOCALE];
330 /* If lang has a substring ":<category>;", extract <category>
331 * from the first such occurrence as the locale name.
335 if (start = strchr (lang, ':')) {
337 if (end = strchr (start, ';')) {
339 strncpy(buf, start, len);
347 pl_desc = (char *)XtMalloc(strlen("/usr/dt/palettes/desc.") + strlen(lang) + 1);
348 strcpy (pl_desc,"/usr/dt/palettes/desc.");
349 strcat (pl_desc, lang);
350 if(sys_pl_DB = XrmGetFileDatabase (pl_desc))
351 XrmMergeDatabases(sys_pl_DB, &pl_DB);
354 /* load the palette description data base for the given locale*/
355 /* from that locale's description file from the admin location */
356 pl_desc = (char *)XtMalloc(strlen("/etc/dt/palettes/desc.") + strlen(lang) + 1);
357 strcpy (pl_desc,"/etc/dt/palettes/desc.");
358 strcat (pl_desc, lang);
359 if (adm_pl_DB = XrmGetFileDatabase (pl_desc))
360 XrmMergeDatabases(adm_pl_DB, &pl_DB);
363 /* load the palette description data base regardless of locale*/
364 pl_desc = (char *) XtMalloc(strlen(style.home) +(strlen("/.dt/palettes/desc.palettes") + 1));
365 strcpy (pl_desc, style.home);
366 strcat (pl_desc, "/.dt/palettes/desc.palettes");
367 if (hm_pl_DB = XrmGetFileDatabase (pl_desc))
368 XrmMergeDatabases(hm_pl_DB, &pl_DB);
371 /* load the palette description data base regardless of locale for later use*/
372 pl_desc = (char *) XtMalloc(strlen(style.home) +(strlen("/.dt/palettes/desc.palettes") + 1));
373 strcpy (pl_desc, style.home);
374 strcat (pl_desc, "/.dt/palettes/desc.palettes");
375 if (XrmCombineFileDatabase (pl_desc, &pl_DB, True))
376 /* load a separate home data base to be later saved as a file */
377 /* if any palettes are added */
378 hm_pl_DB = XrmGetFileDatabase (pl_desc);
391 ** Main routine does the following:
392 ** 1. Creates the color dialog shell
393 ** 2. Checks which monitor the customizer is running on
394 ** 3. Initialize color palettes
398 /* can the user access the Color portion of Style? */
400 /* Not if Color Server is not running */
401 if (style.colorSrv == FALSE)
403 ErrDialog(((char *)GETMESSAGE(14, 25, "The color portion of the Style Manager\nwill not operate because the color server\nis not running. Check $HOME/.dt/errorlog.")), style.shell);
407 /* Not if useColorObj resource is False. XmeUseColorObj will return false
408 if color server is not running or if the resource UseColorObj is False.
409 If the color server is not running, that case is caught above so if
410 we get here, the resource UseColorObj must be False. This is an
411 undocumented resource. */
413 if (XmeUseColorObj() == FALSE)
415 ErrDialog(((char *)GETMESSAGE(14, 26, "The color portion of the Style Manager\nwill not operate because the resource\n'useColorObj' is set to False.")), style.shell);
419 if (style.colorDialog == NULL || style.count < 12)
421 _DtTurnOnHourGlass(shell);
423 /* Create Main Color Dialog */
424 if(CreateMainWindow(shell) == -1)
426 _DtTurnOffHourGlass(shell);
429 XtManageChild(style.colorDialog);
431 _DtTurnOffHourGlass(shell);
435 XtManageChild(style.colorDialog);
437 raiseWindow(XtWindow(XtParent(style.colorDialog)));
440 /* also determine if system uses long filenames, used by add palette only */
448 ** This routine creates the Color Customizer Main Window. It is passed
449 ** the top level shell.
456 /* Create the DialogBox dialog */
457 CreateDialogBoxD(parent);
459 /* add some more to the dialog box */
462 /* Create the top part of the color dialog */
466 /* read in palettes */
467 ReadInPalettes(style.xrdb.paletteDir);
469 if (NumOfPalettes == 0)
471 /* error dialog - no palettes */
472 ErrDialog(((char *)GETMESSAGE(14, 38, "The color portion of the Style Manager\n\
473 will not operate because there are no palette\n\
474 files available. Check $HOME/.dt/errorlog.")), style.shell);
478 /* go get the list of palettes of the color dialog */
479 InitializePaletteList(parent,paletteList, False);
481 /* Allocate the pixels for the Current palette.
482 * Will get the pixel values from the color server.
484 AllocatePaletteCells(parent);
486 /* go create the bottom portion of the color dialog */
490 ** Create the color buttons. Have to do it after
491 ** initialize palettes so the correct pixels would be used.
493 CreatePaletteButtons(style.buttonsForm);
501 CreatePaletteButtons(
513 if (TypeOfMonitor == XmCO_BLACK_WHITE) /* create pixmaps for top/bottom shadow */
515 edit.pixmap25 = XmGetPixmap (style.screen, "25_foreground",
516 BlackPixelOfScreen(style.screen),
517 WhitePixelOfScreen(style.screen));
518 edit.pixmap75 = XmGetPixmap (style.screen, "75_foreground",
519 BlackPixelOfScreen(style.screen),
520 WhitePixelOfScreen(style.screen));
522 pixmap100 = XmGetPixmap (style.screen, "background",
523 BlackPixelOfScreen(style.screen),
524 pCurrentPalette->color[pCurrentPalette->active].bg.pixel);
526 XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
527 XtSetArg (args[n], XmNtopOffset, 0); n++;
528 XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
529 XtSetArg (args[n], XmNleftOffset, 0); n++;
530 XtSetArg (args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
531 XtSetArg (args[n], XmNrightPosition, PALETTE_RC_RIGHT_POSITION); n++;
532 XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
533 XtSetArg (args[n], XmNbottomOffset, 0); n++;
534 XtSetArg (args[n], XmNspacing, 0); n++;
535 XtSetArg (args[n], XmNmarginWidth, style.horizontalSpacing); n++;
536 XtSetArg (args[n], XmNmarginHeight, style.verticalSpacing); n++;
537 XtSetArg (args[n], XmNorientation, XmHORIZONTAL); n++;
538 XtSetArg (args[n], XmNpacking, XmPACK_COLUMN); n++;
539 XtSetArg (args[n], XmNadjustLast, False); n++;
540 if(TypeOfMonitor == XmCO_HIGH_COLOR)
542 XtSetArg (args[n], XmNnumColumns, 2); n++;
546 XtSetArg (args[n], XmNnumColumns, 1); n++;
548 paletteRc = XmCreateRowColumn(parent, "paletteRc", args, n);
549 XtManageChild(paletteRc);
551 for (i=0; i<XmCO_MAX_NUM_COLORS; i++)
554 XtSetArg (args[n], XmNrecomputeSize, False); n++;
555 XtSetArg (args[n], XmNwidth, COLOR_BUTTON_WIDTH); n++;
556 XtSetArg (args[n], XmNheight, COLOR_BUTTON_HEIGHT); n++;
557 /* allow traversal only if editing is possible */
558 if (style.dynamicColor || style.visualClass==TrueColor
559 || style.visualClass==DirectColor)
561 XtSetArg (args[n], XmNtraversalOn, False); n++;
563 XtSetArg (args[n], XmNborderWidth, BORDER_WIDTH); n++;
564 XtSetArg (args[n], XmNborderColor,
565 pCurrentPalette->color[pCurrentPalette->secondary].bg.pixel); n++;
566 XtSetArg (args[n], XmNforeground,
567 pCurrentPalette->color[i].fg.pixel); n++;
568 XtSetArg (args[n], XmNbackground,
569 pCurrentPalette->color[i].bg.pixel); n++;
570 XtSetArg (args[n], XmNarmColor, pCurrentPalette->color[i].sc.pixel); n++;
571 XtSetArg (args[n], XmNmultiClick, XmMULTICLICK_KEEP); n++;
572 if (TypeOfMonitor == XmCO_LOW_COLOR)
574 XtSetArg (args[n], XmNhighlightColor,
575 pCurrentPalette->color[pCurrentPalette->secondary].fg.pixel); n++;
579 XtSetArg (args[n], XmNhighlightPixmap, pixmap100); n++;
581 if(UsePixmaps == FALSE && TypeOfMonitor != XmCO_BLACK_WHITE)
583 XtSetArg (args[n], XmNtopShadowColor,
584 pCurrentPalette->color[i].ts.pixel); n++;
585 XtSetArg (args[n], XmNbottomShadowColor,
586 pCurrentPalette->color[i].bs.pixel); n++;
588 else if (TypeOfMonitor == XmCO_BLACK_WHITE)
590 XtSetArg (args[n], XmNtopShadowPixmap, edit.pixmap25); n++;
591 XtSetArg (args[n], XmNbottomShadowPixmap, edit.pixmap75); n++;
593 string = CMPSTR(" ");
594 XtSetArg (args[n], XmNlabelString, string); n++;
595 colorButton[i] = XmCreatePushButton(paletteRc, "colorButton", args, n);
596 /* allow access to modify functionality if available */
597 if (style.dynamicColor || style.visualClass==TrueColor
598 || style.visualClass==DirectColor)
599 XtAddCallback(colorButton[i], XmNactivateCallback, selectColorCB,
600 (XtPointer) (intptr_t) i);
601 XmStringFree(string);
603 XtManageChildren(colorButton,pCurrentPalette->num_of_colors);
605 if(!save.restoreFlag)
608 /* draw selection border if editing is possible */
609 if (style.dynamicColor || style.visualClass==TrueColor
610 || style.visualClass==DirectColor)
613 XtSetArg (args[n], XmNborderColor, BlackPixelOfScreen(style.screen)); n++;
614 XtSetValues(colorButton[selected_button],args,n);
617 if(style.visualClass==TrueColor || style.visualClass==DirectColor)
624 InitializePaletteList(
627 #if NeedWidePrototypes
636 XmStringTable string_table;
639 char *str_type_return;
640 XrmValue value_return;
646 ** Add the palettes read in from ReadInPalettes
649 if (TypeOfMonitor != XmCO_BLACK_WHITE) {
650 loop_palette = pHeadPalette;
651 loop_palette2 = pHeadPalette;
654 loop_palette = pHeadPalette;
655 loop_palette2 = NULL;
656 while(loop_palette != NULL)
657 if(strcmp(loop_palette->name, "Black") == 0) {
658 loop_palette2 = loop_palette;
662 loop_palette = loop_palette->next;
663 loop_palette = pHeadPalette;
664 if(loop_palette2 == NULL)
665 loop_palette2 = pHeadPalette;
668 while( loop_palette != NULL)
672 name_str = (char *) XtMalloc(strlen("palettes.") +
673 strlen(loop_palette->name) +
674 strlen(".desc") + 1);
676 class_str = (char *) XtMalloc(strlen("Palettes.") +
677 strlen(loop_palette->name) +
678 strlen(".Desc") + 1);
679 strcpy(name_str, "palettes.");
680 strcpy(class_str, "Palettes.");
681 strcat(name_str, loop_palette->name);
682 strcat(class_str, loop_palette->name);
683 strcat(name_str, ".desc");
684 strcat(class_str, ".Desc");
686 if (XrmGetResource (pl_DB, name_str, class_str, &str_type_return, &value_return))
688 loop_palette->desc = (char *)XtMalloc(strlen (value_return.addr) + 1 );
689 strcpy(loop_palette->desc, value_return.addr);
693 loop_palette->desc = (char *)XtMalloc(strlen (loop_palette->name) + 1 );
694 strcpy(loop_palette->desc, loop_palette->name);
701 loop_palette->desc = (char *)XtMalloc(strlen (loop_palette->name) + 1 );
702 strcpy(loop_palette->desc, loop_palette->name);
705 XmListAddItem(list, CMPSTR(loop_palette->desc), loop_palette->item_position);
707 /* if the item is the same as the default name provided by the
708 color Server, save it */
709 if(!save.restoreFlag || defaultName_restore == NULL) {
710 if (!(strcmp(loop_palette->name, defaultName)))
711 loop_palette2 = loop_palette;
714 if (!(strcmp(loop_palette->name, defaultName_restore)))
715 loop_palette2 = loop_palette;
717 loop_palette = loop_palette->next;
719 if((loopcount % 5 == 0) && startup)
726 ** Make the palette named by the color Server the selected palette, if the
727 ** palette returned by the color server doesn't match make it the head
732 /* the default name is the name to be selected */
733 if (loop_palette2->name == NULL)
736 string = CMPSTR(loop_palette2->desc);
737 string_table = &string;
740 XtSetArg (args[n], XmNselectedItemCount, 1); n++;
741 XtSetArg (args[n], XmNselectedItems, string_table); n++;
742 XtSetValues (list, args, n);
743 XmStringFree(string);
745 XmListSetPos(list, loop_palette2->item_position);
748 pCurrentPalette = loop_palette2;
749 selected_position = pCurrentPalette->item_position;
756 * Allocate new pixel values and update color palette buttons.
757 * This is needed for screens without dynamicColor.
759 static void allocNewColors(void)
763 static unsigned long pixels[XmCO_MAX_NUM_COLORS*5];
764 static int count = 0;
768 /* free the cells from last selection */
769 XFreeColors(style.display, style.colormap, pixels, count, 0);
773 for (i=0; i<pCurrentPalette->num_of_colors; i++)
776 if (XAllocColor(style.display, style.colormap,
777 &(pCurrentPalette->color[i].fg)) == 0) break;
778 pixels[count++] = pCurrentPalette->color[i].fg.pixel;
780 if (XAllocColor(style.display, style.colormap,
781 &(pCurrentPalette->color[i].bg)) == 0) break;
782 pixels[count++] = pCurrentPalette->color[i].bg.pixel;
783 XtSetArg (args[n], XmNbackground,
784 pCurrentPalette->color[i].bg.pixel); n++;
786 if (XAllocColor(style.display, style.colormap,
787 &(pCurrentPalette->color[i].sc)) == 0) break;
788 pixels[count++] = pCurrentPalette->color[i].sc.pixel;
789 XtSetArg (args[n], XmNarmColor,
790 pCurrentPalette->color[i].sc.pixel); n++;
792 if (UsePixmaps == FALSE)
794 if (XAllocColor(style.display, style.colormap,
795 &(pCurrentPalette->color[i].ts)) == 0) break;
796 pixels[count++] = pCurrentPalette->color[i].ts.pixel;
797 XtSetArg (args[n], XmNtopShadowColor,
798 pCurrentPalette->color[i].ts.pixel); n++;
800 if (XAllocColor(style.display, style.colormap,
801 &(pCurrentPalette->color[i].bs)) == 0) break;
802 pixels[count++] = pCurrentPalette->color[i].bs.pixel;
803 XtSetArg (args[n], XmNbottomShadowColor,
804 pCurrentPalette->color[i].bs.pixel); n++;
806 else /* create pixmaps for top/bottom shadow */
808 XmDestroyPixmap(style.screen, edit.pixmap25);
809 XmDestroyPixmap(style.screen, edit.pixmap75);
811 edit.pixmap25 = XmGetPixmap (style.screen,
812 "50_foreground",pCurrentPalette->color[i].bg.pixel,
813 WhitePixelOfScreen(style.screen));
815 edit.pixmap75 = XmGetPixmap (style.screen,
816 "50_foreground",pCurrentPalette->color[i].bg.pixel,
817 BlackPixelOfScreen(style.screen));
819 XtSetArg (args[n], XmNtopShadowPixmap, edit.pixmap25); n++;
820 XtSetArg (args[n], XmNbottomShadowPixmap, edit.pixmap75); n++;
822 XtSetValues(colorButton[i], args, n);
827 ** This is the selection callback for the Scrolled list.
828 ** The routine finds the item the user selected and changes
829 ** the already allocated pixels to the colors of the selected palette.
834 XtPointer client_data,
835 XtPointer call_data )
839 XmListCallbackStruct *cb = (XmListCallbackStruct *)call_data;
840 palette *tmp_palette;
843 static Boolean First = True;
845 white = WhitePixelOfScreen(style.screen);
846 black = BlackPixelOfScreen(style.screen);
848 if (((edit.DialogShell == NULL) || (!XtIsManaged(edit.DialogShell))) &&
849 selected_position != cb->item_position)
851 selected_position = cb->item_position;
853 tmp_palette = pHeadPalette;
854 while( tmp_palette->item_position != selected_position &&
856 tmp_palette = tmp_palette->next;
858 if(tmp_palette->item_position == selected_position)
860 pOldPalette = pCurrentPalette;
861 pCurrentPalette = tmp_palette;
864 string = CMPSTR(pCurrentPalette->desc);
865 XtSetArg (args[n], XmNtitleString, string); n++;
866 XtSetValues (colorDialog.buttonsTB, args, n);
867 XmStringFree(string);
869 if (style.dynamicColor)
873 if (TypeOfMonitor != XmCO_BLACK_WHITE)
875 /* PUT DIALOG saying can't dynamically change */
878 InfoDialog(NEXT_SESSION, style.colorDialog, False);
883 else /* XmCO_BLACK_WHITE */
885 /* set color buttons for new palette - read only cells */
886 /* primary=color[1] secondary=color[0] */
887 if (strcmp(pCurrentPalette->name, WHITE_BLACK) == 0)
889 n=0; /* secondary color white */
890 XtSetArg (args[n], XmNforeground, black); n++;
891 XtSetArg (args[n], XmNbackground, white); n++;
892 XtSetArg (args[n], XmNarmColor, white); n++;
893 XtSetValues(colorButton[0], args, n);
894 pCurrentPalette->color[0].fg.pixel = black;
895 pCurrentPalette->color[0].bg.pixel = white;
896 pCurrentPalette->color[0].sc.pixel = white;
897 pCurrentPalette->color[0].ts.pixel = black;
898 pCurrentPalette->color[0].bs.pixel = black;
900 n=0; /* primary color black */
901 XtSetArg (args[n], XmNforeground, white); n++;
902 XtSetArg (args[n], XmNbackground, black); n++;
903 XtSetArg (args[n], XmNarmColor, black); n++;
904 XtSetValues(colorButton[1], args, n);
905 pCurrentPalette->color[1].fg.pixel = white;
906 pCurrentPalette->color[1].bg.pixel = black;
907 pCurrentPalette->color[1].sc.pixel = black;
908 pCurrentPalette->color[1].ts.pixel = white;
909 pCurrentPalette->color[1].bs.pixel = white;
911 else if (strcmp(pCurrentPalette->name, BLACK_WHITE) == 0)
913 n=0; /* secondary color black */
914 XtSetArg (args[n], XmNforeground, white); n++;
915 XtSetArg (args[n], XmNbackground, black); n++;
916 XtSetArg (args[n], XmNarmColor, black); n++;
917 XtSetValues(colorButton[0], args, n);
918 pCurrentPalette->color[0].fg.pixel = white;
919 pCurrentPalette->color[0].bg.pixel = black;
920 pCurrentPalette->color[0].sc.pixel = black;
921 pCurrentPalette->color[0].ts.pixel = white;
922 pCurrentPalette->color[0].bs.pixel = white;
924 n=0; /* primary color white */
925 XtSetArg (args[n], XmNforeground, black); n++;
926 XtSetArg (args[n], XmNbackground, white); n++;
927 XtSetArg (args[n], XmNarmColor, white); n++;
928 XtSetValues(colorButton[1], args, n);
929 pCurrentPalette->color[1].fg.pixel = black;
930 pCurrentPalette->color[1].bg.pixel = white;
931 pCurrentPalette->color[1].sc.pixel = white;
932 pCurrentPalette->color[1].ts.pixel = black;
933 pCurrentPalette->color[1].bs.pixel = black;
935 else if (strcmp(pCurrentPalette->name, BLACK_ONLY) == 0)
937 n=0; /* primary and secondary color black */
938 XtSetArg (args[n], XmNforeground, white); n++;
939 XtSetArg (args[n], XmNbackground, black); n++;
940 XtSetArg (args[n], XmNarmColor, black); n++;
941 XtSetValues(colorButton[0], args, n);
942 pCurrentPalette->color[0].fg.pixel = white;
943 pCurrentPalette->color[0].bg.pixel = black;
944 pCurrentPalette->color[0].sc.pixel = black;
945 pCurrentPalette->color[0].ts.pixel = white;
946 pCurrentPalette->color[0].bs.pixel = white;
947 XtSetValues(colorButton[1], args, n);
948 pCurrentPalette->color[1].fg.pixel = white;
949 pCurrentPalette->color[1].bg.pixel = black;
950 pCurrentPalette->color[1].sc.pixel = black;
951 pCurrentPalette->color[1].ts.pixel = white;
952 pCurrentPalette->color[1].bs.pixel = white;
954 else /* WHITE_ONLY */
956 n=0; /* primary and secondary color white */
957 XtSetArg (args[n], XmNforeground, black); n++;
958 XtSetArg (args[n], XmNbackground, white); n++;
959 XtSetArg (args[n], XmNarmColor, white); n++;
960 XtSetValues(colorButton[0], args, n);
961 pCurrentPalette->color[0].fg.pixel = black;
962 pCurrentPalette->color[0].bg.pixel = white;
963 pCurrentPalette->color[0].sc.pixel = white;
964 pCurrentPalette->color[0].ts.pixel = black;
965 pCurrentPalette->color[0].bs.pixel = black;
966 XtSetValues(colorButton[1], args, n);
967 pCurrentPalette->color[1].fg.pixel = black;
968 pCurrentPalette->color[1].bg.pixel = white;
969 pCurrentPalette->color[1].sc.pixel = white;
970 pCurrentPalette->color[1].ts.pixel = black;
971 pCurrentPalette->color[1].bs.pixel = black;
983 XtPointer client_data,
984 XtPointer call_data )
990 XmPushButtonCallbackStruct *cb = (XmPushButtonCallbackStruct *)call_data;
992 i = (intptr_t) client_data;
994 /* if click_count == 1 .. first button press, set time out */
995 if(cb->click_count == 1)
997 timeID = XtAppAddTimeOut(XtWidgetToApplicationContext(gParent),
998 (unsigned long) dclick_time, timeoutCB,
1003 /* else .. second button press, remove the time out */
1004 XtRemoveTimeOut(timeID);
1006 if ((edit.DialogShell == NULL) || (!XtIsManaged(edit.DialogShell)))
1010 /* make the new selected button have a border color */
1012 XtSetArg(args[n],XmNbackground,&bg_pixel); n++;
1013 XtGetValues(colorDialog.colorForm,args,n);
1016 XtSetArg (args[n], XmNborderColor,bg_pixel);
1018 XtSetValues(colorButton[selected_button],args,n);
1021 XtSetArg (args[n], XmNborderColor, BlackPixelOfScreen(style.screen));
1023 XtSetValues(colorButton[i],args,n);
1025 selected_button = i;
1027 color_set = (ColorSet *) &pCurrentPalette->color[selected_button];
1028 ColorEditor(style.colorDialog,color_set);
1030 if(!style.dynamicColor) /* need to update pixels */
1031 XtAddCallback(edit.DialogShell, XmNcallback, colorEditorCB, NULL);
1036 * Color editor callback for screens without dynamicColor.
1038 static void colorEditorCB(Widget w, XtPointer client_data, XtPointer call_data)
1040 static Boolean first = True;
1041 DtDialogBoxCallbackStruct *cb = (DtDialogBoxCallbackStruct *) call_data;
1043 /* show "next session" message if first edit */
1044 if(cb->button_position==OK_BUTTON && first){
1045 InfoDialog(NEXT_SESSION, style.colorDialog, False);
1049 XtRemoveCallback(edit.DialogShell, XmNcallback, colorEditorCB, NULL);
1053 ** This is the double click timeout callback. If this routine is called
1054 ** then there was only a single click on a colorbutton
1058 XtPointer client_data,
1066 if (TypeOfMonitor == XmCO_BLACK_WHITE)
1069 i = (intptr_t) client_data;
1071 if ((edit.DialogShell == NULL) || (!XtIsManaged(edit.DialogShell)))
1073 /* make the new selected button have a border color */
1075 XtSetArg(args[n],XmNbackground,&bg_pixel); n++;
1076 XtGetValues(colorDialog.colorForm,args,n);
1079 XtSetArg (args[n], XmNborderColor,bg_pixel);
1081 XtSetValues(colorButton[selected_button],args,n);
1084 XtSetArg (args[n], XmNborderColor, BlackPixelOfScreen(style.screen));
1086 XtSetValues(colorButton[i],args,n);
1087 selected_button = i;
1094 XtPointer client_data,
1095 XtPointer call_data )
1103 if (addDialog == NULL)
1107 XtSetArg(args[n], XmNokLabelString, CMPSTR((String) _DtOkString)); n++;
1108 XtSetArg(args[n], XmNcancelLabelString, CMPSTR((String) _DtCancelString)); n++;
1109 XtSetArg(args[n], XmNhelpLabelString, CMPSTR((String) _DtHelpString)); n++;
1110 string = CMPSTR(((char *)GETMESSAGE(14, 10, "New palette name:")));
1111 XtSetArg(args[n], XmNselectionLabelString, string); n++;
1112 string1 = CMPSTR("");
1113 XtSetArg(args[n], XmNtextString, string1); n++;
1114 XtSetArg(args[n], XmNborderWidth, 3); n++;
1115 XtSetArg(args[n], XmNautoUnmanage, False); n++;
1116 addDialog = XmCreatePromptDialog(style.colorDialog,"AddDialog",
1118 XmStringFree(string);
1119 XmStringFree(string1);
1121 XtAddCallback(addDialog, XmNokCallback, addOkCB,
1123 XtAddCallback(addDialog, XmNcancelCallback, addCancelCB,
1125 XtAddCallback(addDialog, XmNhelpCallback,
1126 (XtCallbackProc)HelpRequestCB, (XtPointer)HELP_ADD_PALETTE_DIALOG);
1129 XtSetArg (args[n], XmNmwmInputMode,
1130 MWM_INPUT_PRIMARY_APPLICATION_MODAL); n++;
1131 XtSetArg (args[n], XmNuseAsyncGeometry, True); n++;
1132 XtSetArg (args[n], XmNtitle, ((char *)GETMESSAGE(14, 11, "Add Palette"))); n++;
1133 XtSetArg (args[n], XmNmwmFunctions, DIALOG_MWM_FUNC); n++;
1134 XtSetValues (XtParent (addDialog), args, n);
1137 string = CMPSTR("");
1138 XtSetArg(args[n], XmNtextString, string); n++;
1139 XtSetValues(addDialog, args, n);
1140 XmStringFree(string);
1142 XtManageChild(addDialog);
1149 XtPointer client_data,
1150 XtPointer call_data )
1152 XtUnmanageChild(addDialog);
1158 XtPointer client_data,
1159 XtPointer call_data )
1164 char *name, *filename, *tmpstr;
1165 palette *tmpPalette, *newPalette;
1170 /* Get the text from the promp dialog */
1171 name = XmTextFieldGetString( XmSelectionBoxGetChild(addDialog, XmDIALOG_TEXT));
1173 /* see if the user typed in a valid palette name */
1174 if(!ValidName(name)) {
1175 ErrDialog(((char *)GETMESSAGE(14, 12, "The palette name cannot contain\nthese characters:\n\n * : ( ) [ ] { } < > ! | \" / \\")),
1181 /* check the number of characters in name in a locale independent way */
1182 for ( ii = 0, count = 0; name[ii] != '\0'; ii += length ) {
1183 length = mblen( &(name[ii]), MB_CUR_MAX );
1189 /* make sure the length of name is ok, short file names can only be 11 chars */
1190 if(count > 10 && !style.longfilename) {
1191 ErrDialog(((char *)GETMESSAGE(14, 13, "The palette name must be\n10 characters or less.\n")),style.colorDialog);
1196 /* Unmanage the promptDialog */
1197 XtUnmanageChild(addDialog);
1199 /* first search through palette descriptions and make sure the name to */
1200 /* add is not already in the list and go to the end of the palette list */
1201 for(tmpPalette = pHeadPalette; tmpPalette->next != NULL;
1202 tmpPalette = tmpPalette->next)
1204 if((strcmp(tmpPalette->desc, name) == 0)) {
1205 SameName(w, tmpPalette, name);
1211 /* Check the last palette */
1212 if((strcmp(tmpPalette->desc, name) == 0)) {
1213 SameName(w, tmpPalette, name);
1218 /* allocate space for a new palette */
1219 newPalette = (palette *)XtMalloc(sizeof(palette) + 1 );
1221 /* set the previous last palatte to this new one, it is now the last one*/
1222 tmpPalette->next = newPalette;
1223 newPalette->next = NULL;
1225 /* malloc space for the new palette desc */
1226 newPalette->desc = (char *)XtMalloc(strlen(name) + 1);
1227 for(i = 0; i < strlen(name); i++)
1228 newPalette->desc[i] = name[i];
1229 newPalette->desc[i] = '\0';
1231 /* malloc space for the new palette name directory */
1232 newPalette->directory = (char *)XtMalloc(strlen(style.home) +
1233 strlen(DT_PAL_DIR) + 1);
1234 strcpy(newPalette->directory, style.home);
1235 strcat(newPalette->directory, DT_PAL_DIR);
1237 /* makeup a new name for the palette */
1238 tmpstr = (char *)XtMalloc(strlen(style.home) + strlen(DT_PAL_DIR) +
1239 strlen("dtXXXXXX") + 1);
1240 strcpy(tmpstr, newPalette->directory);
1241 len = strlen(tmpstr);
1242 strcat(tmpstr, "dtXXXXXX");
1245 newPalette->name = (char *) XtMalloc(15 * sizeof(char));
1246 strcpy(newPalette->name, tmpstr + len);
1249 /* the new palette is the next palette .. increase NumOfPalettes by one */
1250 newPalette->item_position = NumOfPalettes + 1;
1253 /* set all the new palette's color parameters to the current palette */
1254 newPalette->num_of_colors = pCurrentPalette->num_of_colors;
1255 for(i = 0; i < XmCO_MAX_NUM_COLORS; i++)
1257 newPalette->color[i].fg.pixel = pCurrentPalette->color[i].fg.pixel;
1258 newPalette->color[i].fg.red = pCurrentPalette->color[i].fg.red;
1259 newPalette->color[i].fg.green = pCurrentPalette->color[i].fg.green;
1260 newPalette->color[i].fg.blue = pCurrentPalette->color[i].fg.blue;
1261 newPalette->color[i].fg.flags = pCurrentPalette->color[i].fg.flags;
1263 newPalette->color[i].bg.pixel = pCurrentPalette->color[i].bg.pixel;
1264 newPalette->color[i].bg.red = pCurrentPalette->color[i].bg.red;
1265 newPalette->color[i].bg.green = pCurrentPalette->color[i].bg.green;
1266 newPalette->color[i].bg.blue = pCurrentPalette->color[i].bg.blue;
1267 newPalette->color[i].bg.flags = pCurrentPalette->color[i].bg.flags;
1269 newPalette->color[i].ts.pixel = pCurrentPalette->color[i].ts.pixel;
1270 newPalette->color[i].ts.red = pCurrentPalette->color[i].ts.red;
1271 newPalette->color[i].ts.green = pCurrentPalette->color[i].ts.green;
1272 newPalette->color[i].ts.blue = pCurrentPalette->color[i].ts.blue;
1273 newPalette->color[i].ts.flags = pCurrentPalette->color[i].ts.flags;
1275 newPalette->color[i].bs.pixel = pCurrentPalette->color[i].bs.pixel;
1276 newPalette->color[i].bs.red = pCurrentPalette->color[i].bs.red;
1277 newPalette->color[i].bs.green = pCurrentPalette->color[i].bs.green;
1278 newPalette->color[i].bs.blue = pCurrentPalette->color[i].bs.blue;
1279 newPalette->color[i].bs.flags = pCurrentPalette->color[i].bs.flags;
1281 newPalette->color[i].sc.pixel = pCurrentPalette->color[i].sc.pixel;
1282 newPalette->color[i].sc.red = pCurrentPalette->color[i].sc.red;
1283 newPalette->color[i].sc.green = pCurrentPalette->color[i].sc.green;
1284 newPalette->color[i].sc.blue = pCurrentPalette->color[i].sc.blue;
1285 newPalette->color[i].sc.flags = pCurrentPalette->color[i].sc.flags;
1288 /* Write out the palette */
1289 if ((WriteOutPalette(newPalette->name)) == -1)
1293 /* remove palette from list */
1294 tmpPalette->next = NULL;
1295 XtFree ((char *)newPalette);
1300 WriteOutDesc(newPalette);
1303 /* add the name to the scrolled window list and select it */
1304 AddName(newPalette);
1306 /* now check to see if there is a ~filename .. if there is delete it */
1307 /* use the $HOME environment varible then constuct the full file name */
1308 filename = (char *)XtMalloc(strlen(style.home) + strlen(DT_PAL_DIR) +
1309 strlen(newPalette->name) + strlen(PALETTE_SUFFIX) + 2);
1311 /* create the full path name plus file name */
1312 strcpy(filename, style.home);
1313 strcat(filename, DT_PAL_DIR);
1314 strcat(filename, "~");
1315 strcat(filename, newPalette->name);
1316 strcat(filename, PALETTE_SUFFIX);
1323 /* Go write out the palette */
1324 pCurrentPalette = newPalette;
1331 XtPointer client_data,
1332 XtPointer call_data )
1334 palette *tmpPalette = (palette *)client_data;
1337 /* free the directory */
1338 XtFree(tmpPalette->directory);
1340 /* put the new (users) directory there */
1341 tmpPalette->directory = (char *)XtMalloc(strlen(style.home) +
1342 strlen(DT_PAL_DIR) + 1);
1343 strcpy(tmpPalette->directory, style.home);
1344 strcat(tmpPalette->directory, DT_PAL_DIR);
1346 for(i = 0; i < XmCO_MAX_NUM_COLORS; i++)
1348 tmpPalette->color[i].fg.pixel = pCurrentPalette->color[i].fg.pixel;
1349 tmpPalette->color[i].fg.red = pCurrentPalette->color[i].fg.red;
1350 tmpPalette->color[i].fg.green = pCurrentPalette->color[i].fg.green;
1351 tmpPalette->color[i].fg.blue = pCurrentPalette->color[i].fg.blue;
1352 tmpPalette->color[i].fg.flags = pCurrentPalette->color[i].fg.flags;
1354 tmpPalette->color[i].bg.pixel = pCurrentPalette->color[i].bg.pixel;
1355 tmpPalette->color[i].bg.red = pCurrentPalette->color[i].bg.red;
1356 tmpPalette->color[i].bg.green = pCurrentPalette->color[i].bg.green;
1357 tmpPalette->color[i].bg.blue = pCurrentPalette->color[i].bg.blue;
1358 tmpPalette->color[i].bg.flags = pCurrentPalette->color[i].bg.flags;
1360 tmpPalette->color[i].ts.pixel = pCurrentPalette->color[i].ts.pixel;
1361 tmpPalette->color[i].ts.red = pCurrentPalette->color[i].ts.red;
1362 tmpPalette->color[i].ts.green = pCurrentPalette->color[i].ts.green;
1363 tmpPalette->color[i].ts.blue = pCurrentPalette->color[i].ts.blue;
1364 tmpPalette->color[i].ts.flags = pCurrentPalette->color[i].ts.flags;
1366 tmpPalette->color[i].bs.pixel = pCurrentPalette->color[i].bs.pixel;
1367 tmpPalette->color[i].bs.red = pCurrentPalette->color[i].bs.red;
1368 tmpPalette->color[i].bs.green = pCurrentPalette->color[i].bs.green;
1369 tmpPalette->color[i].bs.blue = pCurrentPalette->color[i].bs.blue;
1370 tmpPalette->color[i].bs.flags = pCurrentPalette->color[i].bs.flags;
1372 tmpPalette->color[i].sc.pixel = pCurrentPalette->color[i].sc.pixel;
1373 tmpPalette->color[i].sc.red = pCurrentPalette->color[i].sc.red;
1374 tmpPalette->color[i].sc.green = pCurrentPalette->color[i].sc.green;
1375 tmpPalette->color[i].sc.blue = pCurrentPalette->color[i].sc.blue;
1376 tmpPalette->color[i].sc.flags = pCurrentPalette->color[i].sc.flags;
1379 /* Write out the palette */
1380 if ((WriteOutPalette(tmpPalette->name)) == -1)
1383 WriteOutDesc(tmpPalette);
1385 pCurrentPalette = tmpPalette;
1387 /* select item in list as if user had selected it */
1388 XmListSelectPos (paletteList, tmpPalette->item_position, TRUE);
1389 XmListSetBottomPos(paletteList, tmpPalette->item_position);
1390 selected_position = tmpPalette->item_position;
1397 XtPointer client_data,
1398 XtPointer call_data )
1400 ColorSet *color_set;
1402 if(TypeOfMonitor == XmCO_BLACK_WHITE)
1405 color_set = (ColorSet *) &pCurrentPalette->color[selected_button];
1406 ColorEditor(style.colorDialog,color_set);
1408 if(!style.dynamicColor) /* need to update pixels */
1409 XtAddCallback(edit.DialogShell, XmNcallback, colorEditorCB, NULL);
1415 ** Process callback from the Ok, Cancel and Help pushButtons in the
1421 XtPointer client_data,
1422 XtPointer call_data )
1424 palette *tmp_palette;
1426 DtDialogBoxCallbackStruct *cb = (DtDialogBoxCallbackStruct *) call_data;
1428 switch (cb->button_position)
1431 if ((edit.DialogShell != NULL) && (XtIsManaged(edit.DialogShell)))
1432 XtUnmanageChild(edit.DialogShell);
1434 XtUnmanageChild(style.colorDialog);
1435 UpdateDefaultPalette();
1439 if ((edit.DialogShell != NULL) && (XtIsManaged(edit.DialogShell)))
1440 XtUnmanageChild(edit.DialogShell);
1442 if ((addDialog != NULL) && (XtIsManaged(addDialog)))
1443 XtCallCallbacks(addDialog, XmNcancelCallback, (XtPointer)NULL);
1445 if ((deleteDialog != NULL) && (XtIsManaged(deleteDialog)))
1446 XtCallCallbacks(deleteDialog, XmNcancelCallback, (XtPointer)NULL);
1448 if ((colorUseDialog != NULL) && (XtIsManaged(colorUseDialog)))
1449 XtCallCallbacks(colorUseDialog, XmNcallback, (XtPointer)NULL);
1451 XtUnmanageChild(style.colorDialog);
1453 tmp_palette = pHeadPalette;
1454 for(tmp_palette = pHeadPalette; tmp_palette != NULL; tmp_palette = tmp_palette->next)
1455 if(!(strcmp(tmp_palette->name, defaultName)))
1461 if(match == FALSE) /* the default palette is no longer valid */
1462 UpdateDefaultPalette();
1464 RestoreOrgPalette();
1469 XtCallCallbacks(style.colorDialog, XmNhelpCallback, (XtPointer)NULL);
1480 palette *newPalette )
1485 ** Add the palette name to the list
1487 string = CMPSTR(newPalette->desc);
1488 XmListAddItem(paletteList, string, newPalette->item_position);
1489 XmListSelectPos(paletteList, newPalette->item_position, TRUE);
1490 XmListSetBottomPos(paletteList, newPalette->item_position);
1491 selected_position = newPalette->item_position;
1492 XSync(style.display, 0);
1493 XmStringFree(string);
1499 XtPointer client_data,
1500 XtPointer call_data )
1505 palette *tmp_palette;
1508 char *str_type_return;
1509 XrmValue value_return;
1511 tmp_palette = pHeadPalette;
1513 while( tmp_palette->item_position != selected_position &&
1514 tmp_palette != NULL)
1515 tmp_palette = tmp_palette->next;
1517 if (deleteDialog == NULL)
1520 XtSetArg(args[n], XmNokLabelString, CMPSTR((String) _DtOkString)); n++;
1521 XtSetArg(args[n], XmNcancelLabelString, CMPSTR((String) _DtCancelString)); n++;
1522 XtSetArg(args[n], XmNhelpLabelString, CMPSTR((String) _DtHelpString)); n++;
1523 XtSetArg(args[n], XmNdialogType, XmDIALOG_INFORMATION); n++;
1524 XtSetArg(args[n], XmNborderWidth, 3); n++;
1525 XtSetArg(args[n], XmNdefaultPosition, False); n++;
1526 deleteDialog = XmCreateQuestionDialog(style.colorDialog,
1527 "deleteDialog", args, n);
1528 XtAddCallback(deleteDialog, XmNmapCallback, CenterMsgCB,
1530 XtAddCallback(deleteDialog, XmNcancelCallback, deleteCancelCB, NULL);
1531 XtAddCallback(deleteDialog, XmNokCallback, deleteOkCB,
1532 (XtPointer)(paletteList));
1533 XtAddCallback(deleteDialog, XmNhelpCallback,
1534 (XtCallbackProc)HelpRequestCB,
1535 (XtPointer)HELP_DELETE_PALETTE_WARNING_DIALOG);
1539 XtSetArg (args[n], XmNmwmInputMode,
1540 MWM_INPUT_PRIMARY_APPLICATION_MODAL); n++;
1541 XtSetArg (args[n], XmNuseAsyncGeometry, True); n++;
1542 XtSetArg (args[n], XmNtitle, ((char *)GETMESSAGE(14, 16, "Delete Palette"))); n++;
1543 XtSetArg (args[n], XmNmwmFunctions, DIALOG_MWM_FUNC); n++;
1544 XtSetValues (XtParent (deleteDialog), args, n);
1549 tmpStr = XtMalloc(strlen(STR2) + strlen(tmp_palette->desc) + 1);
1550 sprintf(tmpStr, STR2, tmp_palette->desc);
1551 XtSetArg(args[n], XmNmessageString, CMPSTR(tmpStr)); n++;
1552 XtSetValues(deleteDialog, args, n);
1555 XtManageChild(deleteDialog);
1561 XtPointer client_data,
1562 XtPointer call_data )
1565 XtUnmanageChild(deleteDialog);
1567 if(NumOfPalettes == 1)
1569 InfoDialog(CANT_DELETE, style.colorDialog, False);
1573 if (RemovePalette() == True)
1574 DeletePaletteFromLinkList((Widget)client_data);
1581 XtPointer client_data,
1582 XtPointer call_data )
1584 XtUnmanageChild(deleteDialog);
1590 XtPointer client_data,
1591 XtPointer call_data )
1596 XmString button_string[NUM_LABELS];
1598 Widget parent = (Widget) client_data;
1601 Widget widget_list[10];
1606 if (colorUseDialog == NULL)
1610 /* Set up DialogBox button labels. */
1611 button_string[0] = CMPSTR((String) _DtOkString);
1612 button_string[1] = CMPSTR((String) _DtCancelString);
1613 button_string[2] = CMPSTR((String) _DtHelpString);
1615 XtSetArg (args[n], XmNchildType, XmWORK_AREA); n++;
1616 XtSetArg (args[n], XmNbuttonCount, NUM_LABELS); n++;
1617 XtSetArg (args[n], XmNbuttonLabelStrings, button_string); n++;
1618 XtSetArg (args[n], XmNdefaultPosition, False); n++;
1619 colorUseDialog = __DtCreateDialogBoxDialog(parent, "colorUseDialog",
1621 XtAddCallback(colorUseDialog, XmNcallback, colorUseExitCB, NULL);
1622 XtAddCallback(colorUseDialog, XmNmapCallback, _DtmapCB_colorUse, NULL);
1623 XtAddCallback(colorUseDialog, XmNhelpCallback,
1624 (XtCallbackProc)HelpRequestCB, (XtPointer)HELP_COLOR_USE_DIALOG);
1626 XmStringFree(button_string[0]);
1627 XmStringFree(button_string[1]);
1628 XmStringFree(button_string[2]);
1630 widget_list[0] = _DtDialogBoxGetButton(colorUseDialog,2);
1632 XtSetArg(args[n], XmNautoUnmanage, False); n++;
1633 XtSetArg(args[n], XmNcancelButton, widget_list[0]); n++;
1634 XtSetValues (colorUseDialog, args, n);
1637 XtSetArg (args[n], XmNuseAsyncGeometry, True); n++;
1638 XtSetArg (args[n], XmNtitle,
1639 ((char *)GETMESSAGE(14, 39, "Number Of Colors To Use:"))); n++;
1640 XtSetArg (args[n], XmNmwmFunctions, DIALOG_MWM_FUNC); n++;
1641 XtSetValues (XtParent(colorUseDialog), args, n);
1644 XtSetArg(args[n], XmNhorizontalSpacing, style.horizontalSpacing); n++;
1645 XtSetArg(args[n], XmNverticalSpacing, style.verticalSpacing); n++;
1646 XtSetArg(args[n], XmNallowOverlap, False); n++;
1647 XtSetArg(args[n], XmNchildType, XmWORK_AREA); n++;
1648 form = XmCreateForm(colorUseDialog, "colorUseForm", args, n);
1649 XtManageChild(form);
1652 XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
1653 XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
1654 XtSetArg (args[n], XmNrightAttachment, XmATTACH_NONE); n++;
1655 XtSetArg (args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
1656 XtSetArg (args[n], XmNbehavior, XmICON_LABEL); n++;
1657 XtSetArg (args[n], XmNshadowThickness, 0); n++;
1658 XtSetArg (args[n], XmNstring, NULL); n++;
1659 XtSetArg (args[n], XmNpixmapForeground, style.primBSCol); n++;
1660 XtSetArg (args[n], XmNpixmapBackground, style.primTSCol); n++;
1661 XtSetArg (args[n], XmNimageName, COLOR_ICON); n++;
1662 XtSetArg (args[n], XmNtraversalOn, False); n++;
1663 pictLabel = _DtCreateIcon(form, "pictLabel", args, n);
1664 XtManageChild(pictLabel);
1667 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
1668 XtSetArg (args[n], XmNtopWidget, pictLabel); n++;
1669 XtSetArg (args[n], XmNtopOffset, style.verticalSpacing); n++;
1670 XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
1671 XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
1672 XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
1674 = XmCreateFrame(form, "colorUseTB", args, n);
1675 XtManageChild(colorUseTB);
1677 /* create a rowColumn for ColorUse selections */
1679 colorUseRC = XmCreateRadioBox(colorUseTB, "colorUseRC", args, n);
1680 XtManageChild(colorUseRC);
1683 string = CMPSTR(((char *)GETMESSAGE(14, 41, "More Colors for Desktop")));
1684 XtSetArg(args[n], XmNlabelString, string); n++;
1685 widget_list[count++] = colorDialog.highColorTG
1686 = XmCreateToggleButtonGadget(colorUseRC,"highColorTG", args, n);
1687 XtAddCallback(colorDialog.highColorTG, XmNvalueChangedCallback,
1688 colorUseCB, (XtPointer)XmCO_HIGH_COLOR);
1689 XmStringFree(string);
1692 string = CMPSTR(((char *)GETMESSAGE(14, 42, "More Colors for Applications")));
1693 XtSetArg(args[n], XmNlabelString, string); n++;
1694 widget_list[count++] = colorDialog.mediumColorTG
1695 = XmCreateToggleButtonGadget(colorUseRC,"mediumColorTG", args, n);
1696 XmStringFree(string);
1697 XtAddCallback(colorDialog.mediumColorTG, XmNvalueChangedCallback,
1698 colorUseCB, (XtPointer)XmCO_MEDIUM_COLOR);
1701 string = CMPSTR(((char *)GETMESSAGE(14, 43, "Most Colors for Applications")));
1702 XtSetArg(args[n], XmNlabelString, string); n++;
1703 widget_list[count++] = colorDialog.lowColorTG
1704 = XmCreateToggleButtonGadget(colorUseRC,"lowColorTG", args, n);
1705 XmStringFree(string);
1706 XtAddCallback(colorDialog.lowColorTG, XmNvalueChangedCallback,
1707 colorUseCB, (XtPointer)XmCO_LOW_COLOR);
1710 string = CMPSTR(((char *)GETMESSAGE(14, 34, "Black and White")));
1711 XtSetArg(args[n], XmNlabelString, string); n++;
1712 widget_list[count++] = colorDialog.blackWhiteTG
1713 = XmCreateToggleButtonGadget(colorUseRC,"blackWhiteTG", args, n);
1714 XmStringFree(string);
1715 XtAddCallback(colorDialog.blackWhiteTG, XmNvalueChangedCallback,
1716 colorUseCB, (XtPointer)XmCO_BLACK_WHITE);
1719 string = CMPSTR(((char *)GETMESSAGE(14, 35, "Default")));
1720 XtSetArg(args[n], XmNlabelString, string); n++;
1721 widget_list[count++] = colorDialog.defaultTG
1722 = XmCreateToggleButtonGadget(colorUseRC,"defaultTG", args, n);
1723 XmStringFree(string);
1724 XtAddCallback(colorDialog.defaultTG, XmNvalueChangedCallback,
1725 colorUseCB, (XtPointer)DEFAULT_COLOR);
1727 XtManageChildren(widget_list,count);
1728 putDialog (XtParent(style.colorDialog), colorUseDialog);
1731 XtManageChild(colorUseDialog);
1736 ** Process new ColorUse selection
1741 XtPointer client_data,
1742 XtPointer call_data )
1745 XmToggleButtonCallbackStruct *cb =
1746 (XmToggleButtonCallbackStruct *)call_data;
1748 colorDialog.currentColorUse = (int) (intptr_t) client_data;
1749 switch (colorDialog.currentColorUse)
1751 case XmCO_HIGH_COLOR:
1752 colorDialog.currentColorUseStr = HIGH_COLOR_STR;
1755 case XmCO_MEDIUM_COLOR:
1756 colorDialog.currentColorUseStr = MEDIUM_COLOR_STR;
1759 case XmCO_LOW_COLOR:
1760 colorDialog.currentColorUseStr = LOW_COLOR_STR;
1763 case XmCO_BLACK_WHITE:
1764 colorDialog.currentColorUseStr = B_W_STR;
1768 colorDialog.currentColorUseStr = DEFAULT_COLOR_STR;
1778 ** Process callback from the Ok, Cancel and Help pushButtons in the
1779 ** Configure DT Colors DialogBox.
1784 XtPointer client_data,
1785 XtPointer call_data )
1788 char colorUseRes[64];
1789 DtDialogBoxCallbackStruct *cb = (DtDialogBoxCallbackStruct *) call_data;
1791 switch (cb->button_position)
1794 XtCallCallbacks(colorUseDialog, XmNhelpCallback, (XtPointer)NULL);
1799 XtUnmanageChild(colorUseDialog);
1801 if (colorDialog.origColorUse != colorDialog.currentColorUse)
1803 InfoDialog(COLORUSE_WHEN, style.colorDialog, False);
1805 /* create the ColorUse resource spec for xrdb */
1806 /* remove ColorUse specification from database for DEFAULT_COLOR */
1808 sprintf(colorUseRes, "*%d*ColorUse: %s\n",
1809 style.screenNum,colorDialog.currentColorUseStr);
1811 switch (colorDialog.currentColorUse)
1813 case XmCO_MEDIUM_COLOR:
1814 sprintf(colorUseRes+strlen(colorUseRes),
1815 "*HelpColorUse: GRAY_SCALE\n");
1819 case XmCO_LOW_COLOR:
1820 case XmCO_BLACK_WHITE:
1821 sprintf(colorUseRes+strlen(colorUseRes),
1822 "*HelpColorUse: B_W\n");
1826 case XmCO_HIGH_COLOR:
1829 sprintf(colorUseRes+strlen(colorUseRes),
1830 "*HelpColorUse: COLOR\n");
1834 _DtAddToResource(style.display, colorUseRes);
1836 colorDialog.origColorUse = colorDialog.currentColorUse;
1844 XtUnmanageChild(colorUseDialog);
1846 switch (colorDialog.origColorUse)
1848 case XmCO_HIGH_COLOR:
1849 XmToggleButtonGadgetSetState(colorDialog.highColorTG, True, True);
1852 case XmCO_MEDIUM_COLOR:
1853 XmToggleButtonGadgetSetState(colorDialog.mediumColorTG, True, True);
1856 case XmCO_LOW_COLOR:
1857 XmToggleButtonGadgetSetState(colorDialog.lowColorTG, True, True);
1860 case XmCO_BLACK_WHITE:
1861 XmToggleButtonGadgetSetState(colorDialog.blackWhiteTG, True, True);
1865 XmToggleButtonGadgetSetState(colorDialog.defaultTG, True, True);
1875 activateCBexitColor(
1877 XtPointer client_data,
1878 XtPointer call_data )
1880 DtDialogBoxCallbackStruct CancelBut;
1882 if(style.colorDialog != NULL && XtIsManaged(style.colorDialog)) {
1883 CancelBut.button_position = CANCEL_BUTTON;
1884 XtCallCallbacks(style.colorDialog, XmNcallback, &CancelBut);
1891 XtPointer client_data,
1893 XtPointer call_data )
1896 DtWsmRemoveWorkspaceFunctions(style.display, XtWindow(XtParent(w)));
1898 if (!save.restoreFlag)
1899 putDialog ((Widget)client_data, XtParent(w));
1901 XtRemoveCallback(style.colorDialog, XmNmapCallback, _DtmapCB, NULL);
1907 XtPointer client_data,
1909 XtPointer call_data )
1912 char *str_type_return;
1913 XrmValue value_return;
1918 char instanceString[24], nameString[24];
1920 DtWsmRemoveWorkspaceFunctions(style.display, XtWindow(XtParent(w)));
1922 db = XtDatabase(style.display);
1924 /* Get ColorUse value */
1925 sprintf (instanceString, "dtsession*%d*colorUse",style.screenNum);
1926 sprintf (nameString, "Dtsession*%d*ColorUse",style.screenNum);
1928 if (status = XrmGetResource (db, instanceString,
1930 &str_type_return, &value_return))
1932 /* make local copy of string */
1933 string = (char *) XtMalloc( value_return.size );
1934 strcpy (string, value_return.addr);
1936 if (strcmp(string, HIGH_COLOR_STR) == 0)
1938 XmToggleButtonGadgetSetState (colorDialog.highColorTG, True, True);
1939 colorDialog.origColorUse = XmCO_HIGH_COLOR;
1941 else if (strcmp(string, MEDIUM_COLOR_STR) == 0)
1943 XmToggleButtonGadgetSetState (colorDialog.mediumColorTG, True, True);
1944 colorDialog.origColorUse = XmCO_MEDIUM_COLOR;
1946 else if (strcmp(string, LOW_COLOR_STR) == 0)
1948 XmToggleButtonGadgetSetState (colorDialog.lowColorTG, True, True);
1949 colorDialog.origColorUse = XmCO_LOW_COLOR;
1951 else if (strcmp(string, B_W_STR) == 0)
1953 XmToggleButtonGadgetSetState (colorDialog.blackWhiteTG, True, True);
1954 colorDialog.origColorUse = XmCO_BLACK_WHITE;
1958 XmToggleButtonGadgetSetState (colorDialog.defaultTG, True, True);
1959 colorDialog.origColorUse = DEFAULT_COLOR;
1964 else /* ColorUse not specified */
1966 XmToggleButtonGadgetSetState (colorDialog.defaultTG, True, True);
1967 colorDialog.origColorUse = DEFAULT_COLOR;
1970 XtRemoveCallback(colorUseDialog, XmNmapCallback, _DtmapCB_colorUse, NULL);
1973 /************************************************************************
1975 * DeletePaletteFromLinkList - routine used to delete a palette from
1976 * the link list of palettes. The palette which is at the current
1977 * selected_position is the palette that is going to be deleted.
1978 * Special things have to happen if the selected palette is at the
1981 ************************************************************************/
1983 DeletePaletteFromLinkList(
1990 palette *tmp_palette, *tmp2_palette;
1991 palette *selected_palette;
1994 selected_palette = pHeadPalette;
1995 while( selected_palette->item_position != selected_position &&
1996 selected_palette != NULL)
1997 selected_palette = selected_palette->next;
1999 XmListDeletePos (list, selected_palette->item_position);
2001 /* delete item from palette list structure */
2003 /* If the palette is at the head .. remove the head and the next
2004 palette becomes the new selected palette */
2005 if (selected_palette->item_position == 1)
2007 pHeadPalette = selected_palette->next;
2008 tmp_palette = pHeadPalette;
2009 tmp_palette->item_position--;
2010 /* new current palette */
2011 pCurrentPalette = tmp_palette;
2013 else /* find the palette just above the palette to be deleted .. it
2014 will become the new selected palette */
2016 tmp_palette = pHeadPalette;
2017 for (i=1; i < selected_palette->item_position-1; i++)
2018 tmp_palette = tmp_palette->next;
2020 tmp_palette->next = selected_palette->next;
2022 /* what is CurrentPalette now? prev or next item?
2023 special case empty list or NULL entry */
2024 if (tmp_palette->next != NULL)
2025 pCurrentPalette = tmp_palette->next;
2027 pCurrentPalette = tmp_palette;
2030 /* decrement item_positions values in remaining palette entries */
2031 tmp2_palette = tmp_palette;
2032 while ((tmp2_palette = tmp2_palette->next) != NULL)
2034 tmp2_palette->item_position--;
2037 /* go copy the pixel numbers to the new palette */
2038 CopyPixel(selected_palette->color, pCurrentPalette->color,
2039 selected_palette->num_of_colors);
2041 /* select item in list as if user had selected it */
2042 XmListSelectPos (list, tmp_palette->item_position, TRUE);
2043 /* Need to check to see if the first palette is being deleted if it is
2044 need to change colors and update title box */
2045 if(selected_position == tmp_palette->item_position) {
2046 pOldPalette = selected_palette;
2049 string = CMPSTR(pCurrentPalette->desc);
2050 XtSetArg (args[n], XmNtitleString, string); n++;
2051 XtSetValues (colorDialog.buttonsTB, args, n);
2052 XmStringFree(string);
2057 XmListSetBottomPos(paletteList, tmp_palette->item_position);
2058 selected_position = tmp_palette->item_position;
2062 /* deallocate the palette structure */
2063 XtFree(selected_palette->name);
2064 XtFree(selected_palette->desc);
2065 XtFree(selected_palette->directory);
2066 XtFree((char *)selected_palette);
2071 ColorSet srcPixels[XmCO_MAX_NUM_COLORS],
2072 ColorSet dstPixels[XmCO_MAX_NUM_COLORS],
2077 for(i=0; i < numOfColors; i++)
2079 dstPixels[i].bg.pixel = srcPixels[i].bg.pixel;
2080 dstPixels[i].fg.pixel = srcPixels[i].fg.pixel;
2081 dstPixels[i].ts.pixel = srcPixels[i].ts.pixel;
2082 dstPixels[i].bs.pixel = srcPixels[i].bs.pixel;
2083 dstPixels[i].sc.pixel = srcPixels[i].sc.pixel;
2088 SaveOrgPalette( void )
2091 palette *tmp_palette, *tmp2_palette;
2093 if(save.restoreFlag && defaultName_restore[0] != 0) {
2094 tmp_palette = pHeadPalette;
2095 while(tmp_palette->next != NULL )
2096 if(strcmp(tmp_palette->name, defaultName))
2098 tmp_palette = tmp_palette->next;
2104 if(!strcmp(tmp_palette->name, defaultName)) {
2105 tmp2_palette = pCurrentPalette;
2106 pCurrentPalette = tmp_palette;
2112 OrgPalette.item_position = pCurrentPalette->item_position;
2113 OrgPalette.num_of_colors = pCurrentPalette->num_of_colors;
2114 for(i = 0; i < XmCO_MAX_NUM_COLORS; i++)
2116 OrgPalette.primary = pCurrentPalette->primary;
2117 OrgPalette.secondary = pCurrentPalette->secondary;
2118 OrgPalette.active = pCurrentPalette->active;
2119 OrgPalette.inactive = pCurrentPalette->inactive;
2121 if(save.restoreFlag && defaultName_restore[0] != 0)
2122 OrgPalette.color[i].bg.pixel = tmp2_palette->color[i].bg.pixel;
2124 OrgPalette.color[i].bg.pixel = pCurrentPalette->color[i].bg.pixel;
2125 OrgPalette.color[i].bg.red = pCurrentPalette->color[i].bg.red;
2126 OrgPalette.color[i].bg.green = pCurrentPalette->color[i].bg.green;
2127 OrgPalette.color[i].bg.blue = pCurrentPalette->color[i].bg.blue;
2129 if(save.restoreFlag && defaultName_restore[0] != 0)
2130 OrgPalette.color[i].fg.pixel = tmp2_palette->color[i].fg.pixel;
2132 OrgPalette.color[i].fg.pixel = pCurrentPalette->color[i].fg.pixel;
2133 OrgPalette.color[i].fg.red = pCurrentPalette->color[i].fg.red;
2134 OrgPalette.color[i].fg.green = pCurrentPalette->color[i].fg.green;
2135 OrgPalette.color[i].fg.blue = pCurrentPalette->color[i].fg.blue;
2137 if(save.restoreFlag && defaultName_restore[0] != 0)
2138 OrgPalette.color[i].ts.pixel = tmp2_palette->color[i].ts.pixel;
2140 OrgPalette.color[i].ts.pixel = pCurrentPalette->color[i].ts.pixel;
2141 OrgPalette.color[i].ts.red = pCurrentPalette->color[i].ts.red;
2142 OrgPalette.color[i].ts.green = pCurrentPalette->color[i].ts.green;
2143 OrgPalette.color[i].ts.blue = pCurrentPalette->color[i].ts.blue;
2145 if(save.restoreFlag && defaultName_restore[0] != 0)
2146 OrgPalette.color[i].bs.pixel = tmp2_palette->color[i].bs.pixel;
2148 OrgPalette.color[i].bs.pixel = pCurrentPalette->color[i].bs.pixel;
2149 OrgPalette.color[i].bs.red = pCurrentPalette->color[i].bs.red;
2150 OrgPalette.color[i].bs.green = pCurrentPalette->color[i].bs.green;
2151 OrgPalette.color[i].bs.blue = pCurrentPalette->color[i].bs.blue;
2153 if(save.restoreFlag && defaultName_restore[0] != 0)
2154 OrgPalette.color[i].sc.pixel = tmp2_palette->color[i].sc.pixel;
2156 OrgPalette.color[i].sc.pixel = pCurrentPalette->color[i].sc.pixel;
2157 OrgPalette.color[i].sc.red = pCurrentPalette->color[i].sc.red;
2158 OrgPalette.color[i].sc.green = pCurrentPalette->color[i].sc.green;
2159 OrgPalette.color[i].sc.blue = pCurrentPalette->color[i].sc.blue;
2162 if(save.restoreFlag && defaultName_restore[0] != 0)
2163 if(tmp_palette != NULL)
2164 pCurrentPalette = tmp2_palette;
2169 RestoreOrgPalette( void )
2172 palette *tmp_palette;
2174 XColor colors[XmCO_MAX_NUM_COLORS * 5];
2176 tmp_palette = pHeadPalette;
2177 while ( tmp_palette != NULL &&
2178 tmp_palette->item_position != OrgPalette.item_position )
2179 tmp_palette = tmp_palette->next;
2181 if ( tmp_palette != NULL &&
2182 tmp_palette->item_position == OrgPalette.item_position)
2184 pCurrentPalette = tmp_palette;
2185 OrgPalette.num_of_colors = pCurrentPalette->num_of_colors;
2186 for(i = 0; i < XmCO_MAX_NUM_COLORS; i++)
2188 pCurrentPalette->primary = OrgPalette.primary;
2189 pCurrentPalette->secondary = OrgPalette.secondary;
2190 pCurrentPalette->inactive = OrgPalette.inactive;
2191 pCurrentPalette->active = OrgPalette.active;
2193 pCurrentPalette->color[i].bg.pixel = OrgPalette.color[i].bg.pixel;
2194 pCurrentPalette->color[i].bg.red = OrgPalette.color[i].bg.red;
2195 pCurrentPalette->color[i].bg.green = OrgPalette.color[i].bg.green;
2196 pCurrentPalette->color[i].bg.blue = OrgPalette.color[i].bg.blue;
2197 if(i < OrgPalette.num_of_colors && TypeOfMonitor != XmCO_BLACK_WHITE)
2198 colors[j++] = pCurrentPalette->color[i].bg;
2200 pCurrentPalette->color[i].sc.pixel = OrgPalette.color[i].sc.pixel;
2201 pCurrentPalette->color[i].sc.red = OrgPalette.color[i].sc.red;
2202 pCurrentPalette->color[i].sc.green = OrgPalette.color[i].sc.green;
2203 pCurrentPalette->color[i].sc.blue = OrgPalette.color[i].sc.blue;
2204 if(i < OrgPalette.num_of_colors && TypeOfMonitor != XmCO_BLACK_WHITE)
2205 colors[j++] = pCurrentPalette->color[i].sc;
2207 pCurrentPalette->color[i].fg.pixel = OrgPalette.color[i].fg.pixel;
2208 pCurrentPalette->color[i].fg.red = OrgPalette.color[i].fg.red;
2209 pCurrentPalette->color[i].fg.green = OrgPalette.color[i].fg.green;
2210 pCurrentPalette->color[i].fg.blue = OrgPalette.color[i].fg.blue;
2211 if(i < OrgPalette.num_of_colors && TypeOfMonitor != XmCO_BLACK_WHITE)
2212 if(FgColor == DYNAMIC)
2213 colors[j++] = pCurrentPalette->color[i].fg;
2215 pCurrentPalette->color[i].ts.pixel = OrgPalette.color[i].ts.pixel;
2216 pCurrentPalette->color[i].ts.red = OrgPalette.color[i].ts.red;
2217 pCurrentPalette->color[i].ts.green = OrgPalette.color[i].ts.green;
2218 pCurrentPalette->color[i].ts.blue = OrgPalette.color[i].ts.blue;
2219 if(i < OrgPalette.num_of_colors && TypeOfMonitor != XmCO_BLACK_WHITE)
2220 if(UsePixmaps == FALSE)
2221 colors[j++] = pCurrentPalette->color[i].ts;
2223 pCurrentPalette->color[i].bs.pixel = OrgPalette.color[i].bs.pixel;
2224 pCurrentPalette->color[i].bs.red = OrgPalette.color[i].bs.red;
2225 pCurrentPalette->color[i].bs.green = OrgPalette.color[i].bs.green;
2226 pCurrentPalette->color[i].bs.blue = OrgPalette.color[i].bs.blue;
2227 if(i < OrgPalette.num_of_colors && TypeOfMonitor != XmCO_BLACK_WHITE)
2228 if(UsePixmaps == FALSE)
2229 colors[j++] = pCurrentPalette->color[i].bs;
2233 if (style.dynamicColor)
2234 XStoreColors (style.display, style.colormap, colors, j);
2236 XmListSelectPos (paletteList, OrgPalette.item_position, TRUE);
2237 XmListSetBottomPos(paletteList, OrgPalette.item_position);
2243 UpdateDefaultPalette( void )
2246 char temp[XmCO_MAX_NUM_COLORS][60];
2247 char xrdb_string[100];
2248 XColor saved_color[2];
2250 for(i = 0; i < XmCO_MAX_NUM_COLORS; i++)
2252 /* put the colors of the palette in the form #RRRRGGGGBBBB */
2253 if(TypeOfMonitor == XmCO_LOW_COLOR && (i == 0 || i == 1))
2254 sprintf(temp[i],"#%04x%04x%04x\n", saved_color[i].red,
2255 saved_color[i].green,
2256 saved_color[i].blue);
2257 else if(TypeOfMonitor == XmCO_LOW_COLOR && i == 2)
2258 sprintf(temp[i],"#%04x%04x%04x\n",pCurrentPalette->color[1].bg.red,
2259 pCurrentPalette->color[1].bg.green,
2260 pCurrentPalette->color[1].bg.blue);
2261 else if(TypeOfMonitor == XmCO_LOW_COLOR && i == 3)
2262 sprintf(temp[i],"#%04x%04x%04x\n",pCurrentPalette->color[0].bg.red,
2263 pCurrentPalette->color[0].bg.green,
2264 pCurrentPalette->color[0].bg.blue);
2266 sprintf(temp[i],"#%04x%04x%04x\n",pCurrentPalette->color[i].bg.red,
2267 pCurrentPalette->color[i].bg.green,
2268 pCurrentPalette->color[i].bg.blue);
2271 /* update the resource manager property with the palette resource */
2272 if (TypeOfMonitor == XmCO_BLACK_WHITE)
2274 sprintf(xrdb_string, "*%d*MonochromePalette: %s%s\n",
2275 style.screenNum, pCurrentPalette->name, PALETTE_SUFFIX);
2279 sprintf(xrdb_string, "*%d*ColorPalette: %s%s\n",
2280 style.screenNum, pCurrentPalette->name, PALETTE_SUFFIX);
2282 _DtAddToResource(style.display, xrdb_string);
2284 /* update the defaultName */
2285 XtFree(defaultName);
2286 defaultName = (char *)XtMalloc(strlen(pCurrentPalette->name)+1);
2287 strcpy(defaultName, pCurrentPalette->name);
2290 /* update Xrdb for non Motif1.1 clients */
2291 if (style.xrdb.writeXrdbColors)
2294 OWsyncColorResources(style.display, TypeOfMonitor,
2295 pCurrentPalette->color);
2297 int chipnum = TypeOfMonitor == XmCO_HIGH_COLOR ? 4 : 1;
2298 sprintf(xrdb_string,
2299 "*background: #%04X%04X%04X\n*foreground: #%04X%04X%04X\n",
2300 pCurrentPalette->color[chipnum].bg.red,
2301 pCurrentPalette->color[chipnum].bg.green,
2302 pCurrentPalette->color[chipnum].bg.blue,
2303 pCurrentPalette->color[chipnum].fg.red,
2304 pCurrentPalette->color[chipnum].fg.green,
2305 pCurrentPalette->color[chipnum].fg.blue);
2306 _DtAddToResource(style.display, xrdb_string);
2316 XtPointer client_data,
2320 unsigned long *length,
2325 style.colorSrv = True;
2328 if((intptr_t) client_data == GET_TYPE_MONITOR)
2330 sscanf ((char *)value, "%x_%x_%x_%x", (unsigned int *) &(TypeOfMonitor),
2331 (unsigned int *) &(UsePixmaps), (unsigned int *) &(FgColor), (unsigned int *) &dynamic_color);
2332 if(dynamic_color == FALSE)
2333 style.dynamicColor = False;
2335 style.dynamicColor = True;
2338 WaitSelection = FALSE;
2341 else /* no response from Color Server - it must not be there */
2343 style.colorSrv = False;
2344 WaitSelection = FALSE;
2348 /************************************************************************
2351 * restore any state information saved with saveBackdrop.
2352 * This is called from restoreSession with the application
2353 * shell and the special xrm database retrieved for restore.
2354 ************************************************************************/
2360 XrmName xrm_name[5];
2361 XrmRepresentation rep_type;
2363 palette *tmp_palette;
2365 /*"paletteDlg" is the resource name of the dialog shell we are saving for.*/
2366 xrm_name [0] = XrmStringToQuark (PALETTEDLG);
2369 /* get x position */
2370 xrm_name [1] = XrmStringToQuark ("x");
2371 if (XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value)){
2372 XtSetArg (save.posArgs[save.poscnt], XmNx, atoi((char *)value.addr)); save.poscnt++;
2375 /* get y position */
2376 xrm_name [1] = XrmStringToQuark ("y");
2377 if (XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value)){
2378 XtSetArg (save.posArgs[save.poscnt], XmNy, atoi((char *)value.addr)); save.poscnt++;
2381 /* get selected palette */
2382 xrm_name [1] = XrmStringToQuark ("selected_palette");
2383 if (XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value)){
2384 strcpy(defaultName_restore, value.addr);
2387 defaultName_restore[0] = 0;
2389 /* get selected button */
2390 xrm_name [1] = XrmStringToQuark ("selected_button");
2391 if (XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value)){
2392 selected_button = atoi((char *)value.addr);
2395 /* need to have some variables initialized before creating the
2396 Color's dialog ... */
2398 CheckMonitor(shell);
2399 GetDefaultPal(shell);
2401 xrm_name [1] = XrmStringToQuark ("ismapped");
2402 XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value);
2403 /* Are we supposed to be mapped? */
2404 if (strcmp(value.addr, "True") == 0) {
2405 save.restoreFlag = True;
2411 /************************************************************************
2414 * This routine will write out to the passed file descriptor any state
2415 * information this dialog needs. It is called from saveSessionCB with the
2416 * file already opened.
2417 * All information is saved in xrm format. There is no restriction
2418 * on what can be saved. It doesn't have to be defined or be part of any
2419 * widget or Xt definition. Just name and save it here and recover it in
2420 * restoreBackdrop. The suggested minimum is whether you are mapped, and your
2422 ************************************************************************/
2428 char *bufr = style.tmpBigStr; /* size=[1024], make bigger if needed */
2429 XmVendorShellExtObject vendorExt;
2430 XmWidgetExtData extData;
2432 if (style.colorDialog != NULL)
2434 if (XtIsManaged(style.colorDialog))
2435 sprintf(bufr, "*paletteDlg.ismapped: True\n");
2437 sprintf(bufr, "*paletteDlg.ismapped: False\n");
2439 /* Get and write out the geometry info for our Window */
2440 x = XtX(XtParent(style.colorDialog));
2441 y = XtY(XtParent(style.colorDialog));
2443 /* Modify x & y to take into account window mgr frames
2444 * This is pretty bogus, but I don't know a better way to do it.
2446 extData = _XmGetWidgetExtData(style.shell, XmSHELL_EXTENSION);
2447 vendorExt = (XmVendorShellExtObject)extData->widget;
2448 x -= vendorExt->vendor.xOffset;
2449 y -= vendorExt->vendor.yOffset;
2451 sprintf(bufr, "%s*paletteDlg.x: %d\n", bufr, x);
2452 sprintf(bufr, "%s*paletteDlg.y: %d\n", bufr, y);
2453 sprintf(bufr, "%s*paletteDlg.selected_palette: %s\n", bufr,
2454 pCurrentPalette->name);
2455 sprintf(bufr, "%s*paletteDlg.selected_button: %d\n", bufr,
2457 if(-1 == write (fd, bufr, strlen(bufr))) {
2458 perror(strerror(errno));
2463 /**************************************************************************
2465 * SameName - procedure used by the Add palette .. if the palette desc the
2466 * user selects is the same name as a palette already in the
2467 * linked list this procedure gets called. It set up a
2468 * Warning dialog asking the user if they really want to add
2469 * a palette with the same name as an existing palette.
2471 **************************************************************************/
2475 palette *tmpPalette,
2482 if (colorDialog.dlg == NULL) {
2483 tmpStr = (char *)XtMalloc(strlen(STR1) + strlen(name) + 1);
2484 sprintf(tmpStr, STR1, name);
2485 XtSetArg(args[n], XmNmessageString, CMPSTR(tmpStr)); n++;
2486 XtSetArg(args[n], XmNokLabelString, CMPSTR((String) _DtOkString)); n++;
2487 XtSetArg(args[n], XmNcancelLabelString, CMPSTR((String) _DtCancelString)); n++;
2488 XtSetArg(args[n], XmNhelpLabelString, CMPSTR((String) _DtHelpString)); n++;
2489 XtSetArg(args[n], XmNmwmFunctions, DIALOG_MWM_FUNC ); n++;
2490 XtSetArg(args[n], XmNdialogTitle, CMPSTR(((char *)GETMESSAGE(14, 21, "Warning")))); n++;
2491 colorDialog.dlg = XmCreateWarningDialog(style.colorDialog, "QNotice", args, n);
2492 XtAddCallback(colorDialog.dlg, XmNokCallback, setDlgOkCB, (XtPointer)tmpPalette);
2493 XtAddCallback(colorDialog.dlg, XmNhelpCallback,
2494 (XtCallbackProc)HelpRequestCB, (XtPointer)HELP_ADD_PALETTE_WARNING_DIALOG);
2497 XtSetArg (args[n], XmNmwmInputMode,
2498 MWM_INPUT_PRIMARY_APPLICATION_MODAL); n++;
2499 XtSetValues (XtParent(colorDialog.dlg), args, n);
2502 XtManageChild(colorDialog.dlg);
2505 /****************************************************************************
2507 * ValidName - procedure which checks to make sure the name being passed
2508 * in is a valid filename. Weeds out many of the non
2509 * alphabit characters.
2511 ***************************************************************************/
2517 Boolean valid = True;
2522 if (!name || strlen(name) == 0)
2528 chlen = mblen (&name[0], MB_CUR_MAX);
2529 for (i = 0; (i < strlen(name)) && chlen && valid; i += chlen)
2531 chlen = mblen (&name[i], MB_CUR_MAX);
2533 ((name[i] == '*') ||
2535 (name[i] == '\\') ||
2553 for (i = 0; (i < strlen(name)) && valid; i++)
2555 if (strchr ("|!(){}[]<>*:\"\\", (int) name[i]))
2565 InitializeAtoms( void )
2569 sprintf(cust_str,"%s%d", XmSCUSTOMIZE_DATA, style.screenNum);
2570 XA_CUSTOMIZE = XInternAtom(style.display, cust_str, FALSE);
2571 XA_TYPE_MONITOR = XInternAtom(style.display, TYPE_OF_MONITOR, FALSE);
2572 XA_WM_DELETE_WINDOW = XInternAtom(style.display, "WM_DELETE_WINDOW", False);
2579 char *str_type_return;
2580 XrmValue value_return;
2585 char instanceName[30], instanceClass[30];
2587 /* get the current default palette from the Reource Manager Property */
2589 db = XtDatabase(style.display);
2591 if (TypeOfMonitor == XmCO_BLACK_WHITE)
2593 sprintf(instanceName,"dtsession.%d.monochromePalette", style.screenNum);
2594 sprintf(instanceClass,"Dtsession.%d.MonochromePalette", style.screenNum);
2598 sprintf(instanceName,"dtsession.%d.colorPalette", style.screenNum);
2599 sprintf(instanceClass,"Dtsession.%d.ColorPalette", style.screenNum);
2602 if (status = XrmGetResource (db, instanceName, instanceClass,
2603 &str_type_return, &value_return))
2605 /* copy string to defaultName */
2606 defaultName = (char *) XtMalloc( value_return.size );
2607 strcpy (defaultName, value_return.addr);
2608 p = strstr (defaultName, PALETTE_SUFFIX);
2613 /* set defaultName to default palette */
2614 defaultName = (char *) XtMalloc( strlen(DEFAULT_PALETTE));
2615 strcpy (defaultName, DEFAULT_PALETTE);
2623 XmString button_string[NUM_LABELS];
2631 /* Get the default value of multiclick */
2632 dclick_time = XtGetMultiClickTime(style.display);
2635 if(!XtIsRealized(parent))
2636 XtRealizeWidget(parent);
2638 /* Set up DialogBox button labels. */
2639 button_string[0] = CMPSTR((String) _DtOkString);
2640 button_string[1] = CMPSTR((String) _DtCancelString);
2641 button_string[2] = CMPSTR((String) _DtHelpString);
2644 * Note that save.poscnt has been initialized elsewhere.
2645 * save.posArgs may contain information from restoreColor().*/
2647 XtSetArg (save.posArgs[save.poscnt], XmNchildType, XmWORK_AREA); save.poscnt++;
2648 XtSetArg (save.posArgs[save.poscnt], XmNbuttonCount, NUM_LABELS); save.poscnt++;
2649 XtSetArg (save.posArgs[save.poscnt], XmNbuttonLabelStrings, button_string); save.poscnt++;
2650 XtSetArg (save.posArgs[save.poscnt], XmNdefaultPosition, False); save.poscnt++;
2651 style.colorDialog = __DtCreateDialogBoxDialog(parent,PALETTEDLG, save.posArgs, save.poscnt);
2652 XtAddCallback(style.colorDialog, XmNcallback, dialogBoxCB, NULL);
2653 XtAddCallback(style.colorDialog, XmNmapCallback, _DtmapCB, parent);
2654 XtAddCallback(style.colorDialog, XmNhelpCallback,
2655 (XtCallbackProc)HelpRequestCB, (XtPointer)HELP_COLOR_DIALOG);
2657 XmStringFree(button_string[0]);
2658 XmStringFree(button_string[1]);
2659 XmStringFree(button_string[2]);
2661 w = _DtDialogBoxGetButton(style.colorDialog,2);
2663 XtSetArg(args[n], XmNautoUnmanage, False); n++;
2664 XtSetArg(args[n], XmNcancelButton, w); n++;
2665 XtSetValues (style.colorDialog, args, n);
2671 AddToDialogBox( void )
2680 XtSetArg (args[n], XmNtitle, ((char *)GETMESSAGE(14, 30, "Style Manager - Color"))); n++;
2681 XtSetArg (args[n], XmNuseAsyncGeometry, True); n++;
2682 XtSetArg (args[n], XmNmwmFunctions, DIALOG_MWM_FUNC); n++;
2683 XtSetValues (XtParent(style.colorDialog), args, n);
2685 /* Add save session property to the main window */
2686 XmAddWMProtocolCallback(XtParent(style.colorDialog),
2687 XA_WM_DELETE_WINDOW, activateCBexitColor, NULL);
2690 ** Create a main form for color dialog
2693 XtSetArg(args[n], XmNhorizontalSpacing, style.horizontalSpacing); n++;
2694 XtSetArg(args[n], XmNverticalSpacing, style.verticalSpacing); n++;
2695 colorDialog.colorForm = XmCreateForm(style.colorDialog, "colorForm", args, n);
2696 XtManageChild(colorDialog.colorForm);
2702 CreateTopColor1( void )
2711 ** titlebox as child of the main form
2714 XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
2715 XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
2716 XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
2717 XtSetArg (args[n], XmNmarginWidth, 0); n++;
2718 XtSetArg (args[n], XmNmarginHeight, 0); n++;
2719 string = CMPSTR(((char *)GETMESSAGE(14, 5, "Palettes")));
2720 XtSetArg (args[n], XmNtitleString, string); n++;
2721 colorDialog.paletteTB = _DtCreateTitleBox(colorDialog.colorForm, "paletteTB", args, n);
2722 XtManageChild(colorDialog.paletteTB);
2723 XmStringFree(string);
2726 ** Create a form inside palette titlebox
2729 XtSetArg(args[n], XmNhorizontalSpacing, style.horizontalSpacing); n++;
2730 XtSetArg(args[n], XmNverticalSpacing, style.verticalSpacing); n++;
2731 colorDialog.palettesForm = XmCreateForm(colorDialog.paletteTB, "palettesForm", args, n);
2732 XtManageChild(colorDialog.palettesForm);
2738 CreateTopColor2( void )
2746 ** Create a scrolled list widget. This widget will contain the list of
2747 ** palettes currently loaded (by ReadPalettes) in the customizer.
2750 XtSetArg (args[n], XmNselectionPolicy, XmBROWSE_SELECT); n++;
2751 XtSetArg (args[n], XmNautomaticSelection, True); n++;
2752 XtSetArg (args[n], XmNvisibleItemCount, 6); n++;
2753 paletteList = XmCreateScrolledList(colorDialog.palettesForm,"paletteList",args,n);
2754 XtAddCallback(paletteList, XmNbrowseSelectionCallback,
2755 selectPaletteCB, NULL);
2758 XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
2759 XtSetArg (args[n], XmNtopOffset, style.horizontalSpacing); n++;
2760 XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
2761 XtSetArg (args[n], XmNleftOffset, style.horizontalSpacing); n++;
2762 XtSetArg (args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
2763 XtSetArg (args[n], XmNrightPosition, 60); n++;
2764 XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
2765 XtSetValues (XtParent(paletteList), args, n);
2771 CreateBottomColor( void )
2776 Widget addDeleteForm;
2779 colorDialog.dlg = NULL;
2781 if(style.count > 10)
2784 if(TypeOfMonitor != XmCO_BLACK_WHITE)
2786 /* Create form for Add and Delete buttons */
2788 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
2789 XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
2790 XtSetArg(args[n], XmNleftWidget, paletteList); n++;
2791 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
2792 XtSetArg(args[n], XmNrightOffset, 0); n++;
2793 XtSetArg(args[n], XmNhorizontalSpacing, style.horizontalSpacing); n++;
2794 XtSetArg(args[n], XmNverticalSpacing, style.verticalSpacing); n++;
2795 XtSetArg(args[n], XmNallowOverlap, False); n++;
2796 XtSetArg(args[n], XmNchildType, XmWORK_AREA); n++;
2798 XmCreateForm(colorDialog.palettesForm, "addDeleteForm", args, n);
2799 XtManageChild(addDeleteForm);
2801 /* Create Add button */
2803 XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
2804 XtSetArg (args[n], XmNtopOffset, ADD_PALETTE_TOP_OFFSET); n++;
2805 XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
2806 XtSetArg (args[n], XmNleftOffset, style.horizontalSpacing); n++;
2807 XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
2808 string = CMPSTR(((char *)GETMESSAGE(14, 6, "Add...")));
2809 XtSetArg (args[n], XmNlabelString, string); n++;
2810 colorDialog.addPaletteButton =
2811 XmCreatePushButtonGadget(addDeleteForm, "addPalette", args, n);
2812 XmStringFree(string);
2813 XtManageChild(colorDialog.addPaletteButton);
2814 XtAddCallback(colorDialog.addPaletteButton, XmNactivateCallback, addPaletteCB,
2817 /* Create Delete button */
2819 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
2820 XtSetArg (args[n], XmNtopWidget, colorDialog.addPaletteButton); n++;
2821 XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
2822 XtSetArg (args[n], XmNleftOffset, style.horizontalSpacing); n++;
2823 XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
2824 string = CMPSTR(((char *)GETMESSAGE(14, 7, "Delete...")));
2825 XtSetArg (args[n], XmNlabelString, string); n++;
2826 colorDialog.deletePaletteButton =
2827 XmCreatePushButtonGadget(addDeleteForm,"deletePalette",args,n);
2828 XmStringFree(string);
2829 XtManageChild(colorDialog.deletePaletteButton);
2830 XtAddCallback(colorDialog.deletePaletteButton, XmNactivateCallback, deletePaletteCB,
2835 ** Create a title box for palette color buttons
2838 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
2839 XtSetArg (args[n], XmNtopWidget, colorDialog.paletteTB); n++;
2840 XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
2841 XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
2842 XtSetArg (args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
2843 XtSetArg (args[n], XmNmarginWidth, 0); n++;
2844 XtSetArg (args[n], XmNmarginHeight, 0); n++;
2845 string = CMPSTR(pCurrentPalette->desc);
2846 XtSetArg (args[n], XmNtitleString, string); n++;
2847 colorDialog.buttonsTB = _DtCreateTitleBox(colorDialog.colorForm, "ButtonsTB", args, n);
2848 XtManageChild(colorDialog.buttonsTB);
2849 XmStringFree(string);
2851 /* Create a form inside palette buttons titlebox */
2853 XtSetArg(args[n], XmNhorizontalSpacing, style.horizontalSpacing); n++;
2854 XtSetArg(args[n], XmNverticalSpacing, style.verticalSpacing); n++;
2855 style.buttonsForm = XmCreateForm(colorDialog.buttonsTB, "buttonsForm", args, n);
2856 XtManageChild(style.buttonsForm);
2858 /* Create Modify... button */
2859 if(TypeOfMonitor != XmCO_BLACK_WHITE)
2862 XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
2863 XtSetArg (args[n], XmNtopOffset, style.horizontalSpacing+BORDER_WIDTH); n++;
2864 XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
2865 XtSetArg (args[n], XmNleftPosition, ADD_PALETTE_LEFT_POSITION); n++;
2866 XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
2867 string = CMPSTR(((char *)GETMESSAGE(14, 8, "Modify...")));
2868 XtSetArg (args[n], XmNlabelString, string); n++;
2870 XmCreatePushButtonGadget(style.buttonsForm, "modifyColorButton", args, n);
2871 XmStringFree(string);
2872 XtManageChild(modifyColorButton);
2873 XtAddCallback(modifyColorButton, XmNactivateCallback, modifyColorCB,
2877 ** Create a pushbutton for configuring DT colors
2880 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
2881 XtSetArg (args[n], XmNtopWidget, colorDialog.buttonsTB); n++;
2882 XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
2883 XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
2884 XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
2885 XtSetArg (args[n], XmNnavigationType, XmTAB_GROUP); n++;
2886 string = CMPSTR(((char *)GETMESSAGE(14, 40, "Number Of Colors...")));
2887 XtSetArg (args[n], XmNlabelString, string); n++;
2888 resourcesPB = XmCreatePushButtonGadget(colorDialog.colorForm, "resourcesPB", args, n);
2889 XtManageChild(resourcesPB);
2890 XtAddCallback(resourcesPB, XmNactivateCallback, resourcesCB,
2891 (XtPointer) style.colorDialog);
2892 XmStringFree(string);