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 librararies 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 /*+++++++++++++++++++++++++++++++++++++++*/
44 #include "/sys5/usr/include/limits.h"
45 #else /* common default */
51 #include <X11/Intrinsic.h>
53 #include <Xm/MwmUtil.h>
61 #include <Xm/MessageB.h>
62 #include <Xm/Protocols.h>
64 #include <Xm/PushBG.h>
65 #include <Xm/ToggleBG.h>
66 #include <Xm/RowColumn.h>
67 #include <Xm/SelectioB.h>
69 #include <Xm/VendorSEP.h>
71 #include <Dt/DialogBox.h>
73 #include <Dt/TitleBox.h>
75 #include <Dt/HourGlass.h>
79 #include "SaveRestore.h"
80 #include "ColorMain.h"
81 #include "ColorFile.h"
82 #include "ColorEdit.h"
88 /*+++++++++++++++++++++++++++++++++++++++*/
89 /* include extern functions */
90 /*+++++++++++++++++++++++++++++++++++++++*/
93 /*+++++++++++++++++++++++++++++++++++++++*/
95 /*+++++++++++++++++++++++++++++++++++++++*/
96 #define DEFAULT_PALETTE "Default"
97 #define TYPE_OF_MONITOR "Type Of Monitor" /* also in dtsession/SrvPalette.c */
99 #define BORDER_WIDTH 3
100 #define COLOR_BUTTON_WIDTH 35
101 #define COLOR_BUTTON_HEIGHT 35
102 #define ADD_PALETTE_TOP_OFFSET 20
103 #define ADD_PALETTE_LEFT_POSITION 65
104 #define PALETTE_RC_RIGHT_POSITION 60
106 #define DEFAULT_COLOR (XmCO_HIGH_COLOR + 1)
108 #define B_W_STR "B_W"
109 #define LOW_COLOR_STR "LOW_COLOR"
110 #define MEDIUM_COLOR_STR "MEDIUM_COLOR"
111 #define HIGH_COLOR_STR "HIGH_COLOR"
112 #define DEFAULT_COLOR_STR "DEFAULT"
114 #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?"))
115 #define STR2 ((char *)GETMESSAGE(14, 23, "Delete palette '%s'?\n"))
116 #define NEXT_SESSION ((char *)GETMESSAGE(14, 28, "The selected palette will take effect\nat your next session."))
117 #define CANT_DELETE ((char *)GETMESSAGE(14, 18, "Can't delete the last palette.\n"))
118 #define COLORUSE_WHEN ((char *)GETMESSAGE(14, 27, "The new Color Use value will take effect\nat your next session."))
120 /*+++++++++++++++++++++++++++++++++++++++*/
122 /*+++++++++++++++++++++++++++++++++++++++*/
128 Widget addPaletteButton;
129 Widget deletePaletteButton;
133 Widget mediumColorTG;
139 char *currentColorUseStr;
143 /*+++++++++++++++++++++++++++++++++++++++*/
144 /* Internal Functions */
145 /*+++++++++++++++++++++++++++++++++++++++*/
147 static int CreateMainWindow( Widget parent) ;
148 static void selectPaletteCB(
150 XtPointer client_data,
151 XtPointer call_data) ;
152 static void selectColorCB(
154 XtPointer client_data,
155 XtPointer call_data) ;
156 static void timeoutCB(
157 XtPointer client_data,
159 static void addPaletteCB(
161 XtPointer client_data,
162 XtPointer call_data) ;
163 static void addCancelCB(
165 XtPointer client_data,
166 XtPointer call_data) ;
169 XtPointer client_data,
170 XtPointer call_data) ;
171 static void setDlgOkCB(
173 XtPointer client_data,
174 XtPointer call_data) ;
175 static void modifyColorCB(
177 XtPointer client_data,
178 XtPointer call_data) ;
179 static void dialogBoxCB(
181 XtPointer client_data,
182 XtPointer call_data) ;
184 palette *newPalette) ;
185 static void deletePaletteCB(
187 XtPointer client_data,
188 XtPointer call_data) ;
189 static void deleteOkCB(
191 XtPointer client_data,
192 XtPointer call_data) ;
193 static void deleteCancelCB(
195 XtPointer client_data,
196 XtPointer call_data) ;
197 static void resourcesCB(
199 XtPointer client_data,
200 XtPointer call_data) ;
201 static void colorUseCB(
203 XtPointer client_data,
204 XtPointer call_data) ;
205 static void colorUseExitCB(
207 XtPointer client_data,
208 XtPointer call_data) ;
209 static void activateCBexitColor(
211 XtPointer client_data,
212 XtPointer call_data) ;
213 static void _DtmapCB(
215 XtPointer client_data,
216 XtPointer call_data) ;
217 static void _DtmapCB_colorUse(
219 XtPointer client_data,
220 XtPointer call_data) ;
221 static void colorEditorCB(
223 XtPointer client_data,
224 XtPointer call_data) ;
226 static void allocNewColors(void);
227 static Boolean ValidName( char *name) ;
232 /*+++++++++++++++++++++++++++++++++++++++*/
233 /* Global Variables */
234 /*+++++++++++++++++++++++++++++++++++++++*/
237 Atom XA_TYPE_MONITOR;
239 /* Palettes exist in a linked list. */
240 palette *pHeadPalette;
241 palette *pCurrentPalette;
242 palette *pOldPalette;
244 Widget modifyColorButton;
254 /*+++++++++++++++++++++++++++++++++++++++*/
255 /* Internal Variables */
256 /*+++++++++++++++++++++++++++++++++++++++*/
258 /* palette names without the .dp */
259 static char *WHITE_BLACK = "WhiteBlack";
260 static char *BLACK_WHITE = "BlackWhite";
261 static char *WHITE_ONLY = "White";
262 static char *BLACK_ONLY = "Black";
264 static char *PALETTEDLG = "paletteDlg";
265 static saveRestore save = {FALSE, 0, };
267 static Widget colorButton[XmCO_MAX_NUM_COLORS];
268 static Widget addDialog;
269 static Widget deleteDialog;
270 static Widget colorUseDialog;
271 static palette OrgPalette;
272 static XtIntervalId timeID;
273 static int dclick_time;
274 static int selected_button;
275 static int selected_position;
276 static Atom XA_WM_DELETE_WINDOW;
277 static char defaultName_restore[50];
278 static palette *loop_palette, *loop_palette2;
279 static int loopcount = 0;
280 static colorWidgets colorDialog;
281 static Widget gParent;
285 * copy of the system palette description file for the
286 * current locale in xrm form
288 XrmDatabase sys_pl_DB = NULL;
291 * copy of the admin palette description file for the
292 * current locale in xrm form
294 XrmDatabase adm_pl_DB = NULL;
297 * final combination of the admin & system dta bases
299 XrmDatabase pl_DB = NULL;
302 * copy of the palette description file from the user's home
303 * directory. This database is locale independent and will always
306 XrmDatabase hm_pl_DB = NULL;
316 /* load the palette description data base for the given locale*/
317 /* from that locale's description file from the system location */
319 lang = setlocale (LC_CTYPE,NULL);
321 #ifdef hpux /* hpux-specific parsing of the locale string */
322 /* The following code is identical to the
323 ExtractLocaleName function in WmResParse.c
326 #define MAXLOCALE 64 /* buffer size of locale name */
331 static char buf[MAXLOCALE];
333 /* If lang has a substring ":<category>;", extract <category>
334 * from the first such occurrence as the locale name.
338 if (start = strchr (lang, ':')) {
340 if (end = strchr (start, ';')) {
342 strncpy(buf, start, len);
350 pl_desc = (char *)XtMalloc(strlen("/usr/dt/palettes/desc.") + strlen(lang) + 1);
351 strcpy (pl_desc,"/usr/dt/palettes/desc.");
352 strcat (pl_desc, lang);
353 if(sys_pl_DB = XrmGetFileDatabase (pl_desc))
354 XrmMergeDatabases(sys_pl_DB, &pl_DB);
357 /* load the palette description data base for the given locale*/
358 /* from that locale's description file from the admin location */
359 pl_desc = (char *)XtMalloc(strlen("/etc/dt/palettes/desc.") + strlen(lang) + 1);
360 strcpy (pl_desc,"/etc/dt/palettes/desc.");
361 strcat (pl_desc, lang);
362 if (adm_pl_DB = XrmGetFileDatabase (pl_desc))
363 XrmMergeDatabases(adm_pl_DB, &pl_DB);
366 /* load the palette description data base regardless of locale*/
367 pl_desc = (char *) XtMalloc(strlen(style.home) +(strlen("/.dt/palettes/desc.palettes") + 1));
368 strcpy (pl_desc, style.home);
369 strcat (pl_desc, "/.dt/palettes/desc.palettes");
370 if (hm_pl_DB = XrmGetFileDatabase (pl_desc))
371 XrmMergeDatabases(hm_pl_DB, &pl_DB);
374 /* load the palette description data base regardless of locale for later use*/
375 pl_desc = (char *) XtMalloc(strlen(style.home) +(strlen("/.dt/palettes/desc.palettes") + 1));
376 strcpy (pl_desc, style.home);
377 strcat (pl_desc, "/.dt/palettes/desc.palettes");
378 if (XrmCombineFileDatabase (pl_desc, &pl_DB, True))
379 /* load a separate home data base to be later saved as a file */
380 /* if any palettes are added */
381 hm_pl_DB = XrmGetFileDatabase (pl_desc);
394 ** Main routine does the following:
395 ** 1. Creates the color dialog shell
396 ** 2. Checks which monitor the customizer is running on
397 ** 3. Initialize color palettes
401 /* can the user access the Color portion of Style? */
403 /* Not if Color Server is not running */
404 if (style.colorSrv == FALSE)
406 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);
410 /* Not if useColorObj resource is False. XmeUseColorObj will return false
411 if color server is not running or if the resource UseColorObj is False.
412 If the color server is not running, that case is caught above so if
413 we get here, the resource UseColorObj must be False. This is an
414 undocumented resource. */
416 if (XmeUseColorObj() == FALSE)
418 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);
422 if (style.colorDialog == NULL || style.count < 12)
424 _DtTurnOnHourGlass(shell);
426 /* Create Main Color Dialog */
427 if(CreateMainWindow(shell) == -1)
429 _DtTurnOffHourGlass(shell);
432 XtManageChild(style.colorDialog);
434 _DtTurnOffHourGlass(shell);
438 XtManageChild(style.colorDialog);
440 raiseWindow(XtWindow(XtParent(style.colorDialog)));
443 /* also determine if system uses long filenames, used by add palette only */
451 ** This routine creates the Color Customizer Main Window. It is passed
452 ** the top level shell.
459 /* Create the DialogBox dialog */
460 CreateDialogBoxD(parent);
462 /* add some more to the dialog box */
465 /* Create the top part of the color dialog */
469 /* read in palettes */
470 ReadInPalettes(style.xrdb.paletteDir);
472 if (NumOfPalettes == 0)
474 /* error dialog - no palettes */
475 ErrDialog(((char *)GETMESSAGE(14, 38, "The color portion of the Style Manager\n\
476 will not operate because there are no palette\n\
477 files available. Check $HOME/.dt/errorlog.")), style.shell);
481 /* go get the list of palettes of the color dialog */
482 InitializePaletteList(parent,paletteList, False);
484 /* Allocate the pixels for the Current palette.
485 * Will get the pixel values from the color server.
487 AllocatePaletteCells(parent);
489 /* go create the bottom portion of the color dialog */
493 ** Create the color buttons. Have to do it after
494 ** initialize palettes so the correct pixels would be used.
496 CreatePaletteButtons(style.buttonsForm);
504 CreatePaletteButtons(
516 if (TypeOfMonitor == XmCO_BLACK_WHITE) /* create pixmaps for top/bottom shadow */
518 edit.pixmap25 = XmGetPixmap (style.screen, "25_foreground",
519 BlackPixelOfScreen(style.screen),
520 WhitePixelOfScreen(style.screen));
521 edit.pixmap75 = XmGetPixmap (style.screen, "75_foreground",
522 BlackPixelOfScreen(style.screen),
523 WhitePixelOfScreen(style.screen));
525 pixmap100 = XmGetPixmap (style.screen, "background",
526 BlackPixelOfScreen(style.screen),
527 pCurrentPalette->color[pCurrentPalette->active].bg.pixel);
529 XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
530 XtSetArg (args[n], XmNtopOffset, 0); n++;
531 XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
532 XtSetArg (args[n], XmNleftOffset, 0); n++;
533 XtSetArg (args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
534 XtSetArg (args[n], XmNrightPosition, PALETTE_RC_RIGHT_POSITION); n++;
535 XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
536 XtSetArg (args[n], XmNbottomOffset, 0); n++;
537 XtSetArg (args[n], XmNspacing, 0); n++;
538 XtSetArg (args[n], XmNmarginWidth, style.horizontalSpacing); n++;
539 XtSetArg (args[n], XmNmarginHeight, style.verticalSpacing); n++;
540 XtSetArg (args[n], XmNorientation, XmHORIZONTAL); n++;
541 XtSetArg (args[n], XmNpacking, XmPACK_COLUMN); n++;
542 XtSetArg (args[n], XmNadjustLast, False); n++;
543 if(TypeOfMonitor == XmCO_HIGH_COLOR)
545 XtSetArg (args[n], XmNnumColumns, 2); n++;
549 XtSetArg (args[n], XmNnumColumns, 1); n++;
551 paletteRc = XmCreateRowColumn(parent, "paletteRc", args, n);
552 XtManageChild(paletteRc);
554 for (i=0; i<XmCO_MAX_NUM_COLORS; i++)
557 XtSetArg (args[n], XmNrecomputeSize, False); n++;
558 XtSetArg (args[n], XmNwidth, COLOR_BUTTON_WIDTH); n++;
559 XtSetArg (args[n], XmNheight, COLOR_BUTTON_HEIGHT); n++;
560 /* allow traversal only if editing is possible */
561 if (style.dynamicColor || style.visualClass==TrueColor
562 || style.visualClass==DirectColor)
564 XtSetArg (args[n], XmNtraversalOn, False); n++;
566 XtSetArg (args[n], XmNborderWidth, BORDER_WIDTH); n++;
567 XtSetArg (args[n], XmNborderColor,
568 pCurrentPalette->color[pCurrentPalette->secondary].bg.pixel); n++;
569 XtSetArg (args[n], XmNforeground,
570 pCurrentPalette->color[i].fg.pixel); n++;
571 XtSetArg (args[n], XmNbackground,
572 pCurrentPalette->color[i].bg.pixel); n++;
573 XtSetArg (args[n], XmNarmColor, pCurrentPalette->color[i].sc.pixel); n++;
574 XtSetArg (args[n], XmNmultiClick, XmMULTICLICK_KEEP); n++;
575 if (TypeOfMonitor == XmCO_LOW_COLOR)
577 XtSetArg (args[n], XmNhighlightColor,
578 pCurrentPalette->color[pCurrentPalette->secondary].fg.pixel); n++;
582 XtSetArg (args[n], XmNhighlightPixmap, pixmap100); n++;
584 if(UsePixmaps == FALSE && TypeOfMonitor != XmCO_BLACK_WHITE)
586 XtSetArg (args[n], XmNtopShadowColor,
587 pCurrentPalette->color[i].ts.pixel); n++;
588 XtSetArg (args[n], XmNbottomShadowColor,
589 pCurrentPalette->color[i].bs.pixel); n++;
591 else if (TypeOfMonitor == XmCO_BLACK_WHITE)
593 XtSetArg (args[n], XmNtopShadowPixmap, edit.pixmap25); n++;
594 XtSetArg (args[n], XmNbottomShadowPixmap, edit.pixmap75); n++;
596 string = CMPSTR(" ");
597 XtSetArg (args[n], XmNlabelString, string); n++;
598 colorButton[i] = XmCreatePushButton(paletteRc, "colorButton", args, n);
599 /* allow access to modify functionality if available */
600 if (style.dynamicColor || style.visualClass==TrueColor
601 || style.visualClass==DirectColor)
602 XtAddCallback(colorButton[i], XmNactivateCallback, selectColorCB,
604 XmStringFree(string);
606 XtManageChildren(colorButton,pCurrentPalette->num_of_colors);
608 if(!save.restoreFlag)
611 /* draw selection border if editing is possible */
612 if (style.dynamicColor || style.visualClass==TrueColor
613 || style.visualClass==DirectColor)
616 XtSetArg (args[n], XmNborderColor, BlackPixelOfScreen(style.screen)); n++;
617 XtSetValues(colorButton[selected_button],args,n);
620 if(style.visualClass==TrueColor || style.visualClass==DirectColor)
627 InitializePaletteList(
630 #if NeedWidePrototypes
639 XmStringTable string_table;
642 char *str_type_return;
643 XrmValue value_return;
649 ** Add the palettes read in from ReadInPalettes
652 if (TypeOfMonitor != XmCO_BLACK_WHITE) {
653 loop_palette = pHeadPalette;
654 loop_palette2 = pHeadPalette;
657 loop_palette = pHeadPalette;
658 loop_palette2 = NULL;
659 while(loop_palette != NULL)
660 if(strcmp(loop_palette->name, "Black") == 0) {
661 loop_palette2 = loop_palette;
665 loop_palette = loop_palette->next;
666 loop_palette = pHeadPalette;
667 if(loop_palette2 == NULL)
668 loop_palette2 = pHeadPalette;
671 while( loop_palette != NULL)
675 name_str = (char *) XtMalloc(strlen("palettes.") +
676 strlen(loop_palette->name) +
677 strlen(".desc") + 1);
679 class_str = (char *) XtMalloc(strlen("Palettes.") +
680 strlen(loop_palette->name) +
681 strlen(".Desc") + 1);
682 strcpy(name_str, "palettes.");
683 strcpy(class_str, "Palettes.");
684 strcat(name_str, loop_palette->name);
685 strcat(class_str, loop_palette->name);
686 strcat(name_str, ".desc");
687 strcat(class_str, ".Desc");
689 if (XrmGetResource (pl_DB, name_str, class_str, &str_type_return, &value_return))
691 loop_palette->desc = (char *)XtMalloc(strlen (value_return.addr) + 1 );
692 strcpy(loop_palette->desc, value_return.addr);
696 loop_palette->desc = (char *)XtMalloc(strlen (loop_palette->name) + 1 );
697 strcpy(loop_palette->desc, loop_palette->name);
704 loop_palette->desc = (char *)XtMalloc(strlen (loop_palette->name) + 1 );
705 strcpy(loop_palette->desc, loop_palette->name);
708 XmListAddItem(list, CMPSTR(loop_palette->desc), loop_palette->item_position);
710 /* if the item is the same as the default name provided by the
711 color Server, save it */
712 if(!save.restoreFlag || defaultName_restore == NULL) {
713 if (!(strcmp(loop_palette->name, defaultName)))
714 loop_palette2 = loop_palette;
717 if (!(strcmp(loop_palette->name, defaultName_restore)))
718 loop_palette2 = loop_palette;
720 loop_palette = loop_palette->next;
722 if((loopcount % 5 == 0) && startup)
729 ** Make the palette named by the color Server the selected palette, if the
730 ** palette returned by the color server doesn't match make it the head
735 /* the default name is the name to be selected */
736 if (loop_palette2->name == NULL)
739 string = CMPSTR(loop_palette2->desc);
740 string_table = &string;
743 XtSetArg (args[n], XmNselectedItemCount, 1); n++;
744 XtSetArg (args[n], XmNselectedItems, string_table); n++;
745 XtSetValues (list, args, n);
746 XmStringFree(string);
748 XmListSetPos(list, loop_palette2->item_position);
751 pCurrentPalette = loop_palette2;
752 selected_position = pCurrentPalette->item_position;
759 * Allocate new pixel values and update color palette buttons.
760 * This is needed for screens without dynamicColor.
762 static void allocNewColors(void)
766 static unsigned long pixels[XmCO_MAX_NUM_COLORS*5];
767 static int count = 0;
771 /* free the cells from last selection */
772 XFreeColors(style.display, style.colormap, pixels, count, 0);
776 for (i=0; i<pCurrentPalette->num_of_colors; i++)
779 if (XAllocColor(style.display, style.colormap,
780 &(pCurrentPalette->color[i].fg)) == 0) break;
781 pixels[count++] = pCurrentPalette->color[i].fg.pixel;
783 if (XAllocColor(style.display, style.colormap,
784 &(pCurrentPalette->color[i].bg)) == 0) break;
785 pixels[count++] = pCurrentPalette->color[i].bg.pixel;
786 XtSetArg (args[n], XmNbackground,
787 pCurrentPalette->color[i].bg.pixel); n++;
789 if (XAllocColor(style.display, style.colormap,
790 &(pCurrentPalette->color[i].sc)) == 0) break;
791 pixels[count++] = pCurrentPalette->color[i].sc.pixel;
792 XtSetArg (args[n], XmNarmColor,
793 pCurrentPalette->color[i].sc.pixel); n++;
795 if (UsePixmaps == FALSE)
797 if (XAllocColor(style.display, style.colormap,
798 &(pCurrentPalette->color[i].ts)) == 0) break;
799 pixels[count++] = pCurrentPalette->color[i].ts.pixel;
800 XtSetArg (args[n], XmNtopShadowColor,
801 pCurrentPalette->color[i].ts.pixel); n++;
803 if (XAllocColor(style.display, style.colormap,
804 &(pCurrentPalette->color[i].bs)) == 0) break;
805 pixels[count++] = pCurrentPalette->color[i].bs.pixel;
806 XtSetArg (args[n], XmNbottomShadowColor,
807 pCurrentPalette->color[i].bs.pixel); n++;
809 else /* create pixmaps for top/bottom shadow */
811 XmDestroyPixmap(style.screen, edit.pixmap25);
812 XmDestroyPixmap(style.screen, edit.pixmap75);
814 edit.pixmap25 = XmGetPixmap (style.screen,
815 "50_foreground",pCurrentPalette->color[i].bg.pixel,
816 WhitePixelOfScreen(style.screen));
818 edit.pixmap75 = XmGetPixmap (style.screen,
819 "50_foreground",pCurrentPalette->color[i].bg.pixel,
820 BlackPixelOfScreen(style.screen));
822 XtSetArg (args[n], XmNtopShadowPixmap, edit.pixmap25); n++;
823 XtSetArg (args[n], XmNbottomShadowPixmap, edit.pixmap75); n++;
825 XtSetValues(colorButton[i], args, n);
830 ** This is the selection callback for the Scrolled list.
831 ** The routine finds the item the user selected and changes
832 ** the already allocated pixels to the colors of the selected palette.
837 XtPointer client_data,
838 XtPointer call_data )
842 XmListCallbackStruct *cb = (XmListCallbackStruct *)call_data;
843 palette *tmp_palette;
846 static Boolean First = True;
848 white = WhitePixelOfScreen(style.screen);
849 black = BlackPixelOfScreen(style.screen);
851 if (((edit.DialogShell == NULL) || (!XtIsManaged(edit.DialogShell))) &&
852 selected_position != cb->item_position)
854 selected_position = cb->item_position;
856 tmp_palette = pHeadPalette;
857 while( tmp_palette->item_position != selected_position &&
859 tmp_palette = tmp_palette->next;
861 if(tmp_palette->item_position == selected_position)
863 pOldPalette = pCurrentPalette;
864 pCurrentPalette = tmp_palette;
867 string = CMPSTR(pCurrentPalette->desc);
868 XtSetArg (args[n], XmNtitleString, string); n++;
869 XtSetValues (colorDialog.buttonsTB, args, n);
870 XmStringFree(string);
872 if (style.dynamicColor)
876 if (TypeOfMonitor != XmCO_BLACK_WHITE)
878 /* PUT DIALOG saying can't dynamically change */
881 InfoDialog(NEXT_SESSION, style.colorDialog, False);
886 else /* XmCO_BLACK_WHITE */
888 /* set color buttons for new palette - read only cells */
889 /* primary=color[1] secondary=color[0] */
890 if (strcmp(pCurrentPalette->name, WHITE_BLACK) == 0)
892 n=0; /* secondary color white */
893 XtSetArg (args[n], XmNforeground, black); n++;
894 XtSetArg (args[n], XmNbackground, white); n++;
895 XtSetArg (args[n], XmNarmColor, white); n++;
896 XtSetValues(colorButton[0], args, n);
897 pCurrentPalette->color[0].fg.pixel = black;
898 pCurrentPalette->color[0].bg.pixel = white;
899 pCurrentPalette->color[0].sc.pixel = white;
900 pCurrentPalette->color[0].ts.pixel = black;
901 pCurrentPalette->color[0].bs.pixel = black;
903 n=0; /* primary color black */
904 XtSetArg (args[n], XmNforeground, white); n++;
905 XtSetArg (args[n], XmNbackground, black); n++;
906 XtSetArg (args[n], XmNarmColor, black); n++;
907 XtSetValues(colorButton[1], args, n);
908 pCurrentPalette->color[1].fg.pixel = white;
909 pCurrentPalette->color[1].bg.pixel = black;
910 pCurrentPalette->color[1].sc.pixel = black;
911 pCurrentPalette->color[1].ts.pixel = white;
912 pCurrentPalette->color[1].bs.pixel = white;
914 else if (strcmp(pCurrentPalette->name, BLACK_WHITE) == 0)
916 n=0; /* secondary color black */
917 XtSetArg (args[n], XmNforeground, white); n++;
918 XtSetArg (args[n], XmNbackground, black); n++;
919 XtSetArg (args[n], XmNarmColor, black); n++;
920 XtSetValues(colorButton[0], args, n);
921 pCurrentPalette->color[0].fg.pixel = white;
922 pCurrentPalette->color[0].bg.pixel = black;
923 pCurrentPalette->color[0].sc.pixel = black;
924 pCurrentPalette->color[0].ts.pixel = white;
925 pCurrentPalette->color[0].bs.pixel = white;
927 n=0; /* primary color white */
928 XtSetArg (args[n], XmNforeground, black); n++;
929 XtSetArg (args[n], XmNbackground, white); n++;
930 XtSetArg (args[n], XmNarmColor, white); n++;
931 XtSetValues(colorButton[1], args, n);
932 pCurrentPalette->color[1].fg.pixel = black;
933 pCurrentPalette->color[1].bg.pixel = white;
934 pCurrentPalette->color[1].sc.pixel = white;
935 pCurrentPalette->color[1].ts.pixel = black;
936 pCurrentPalette->color[1].bs.pixel = black;
938 else if (strcmp(pCurrentPalette->name, BLACK_ONLY) == 0)
940 n=0; /* primary and secondary color black */
941 XtSetArg (args[n], XmNforeground, white); n++;
942 XtSetArg (args[n], XmNbackground, black); n++;
943 XtSetArg (args[n], XmNarmColor, black); n++;
944 XtSetValues(colorButton[0], args, n);
945 pCurrentPalette->color[0].fg.pixel = white;
946 pCurrentPalette->color[0].bg.pixel = black;
947 pCurrentPalette->color[0].sc.pixel = black;
948 pCurrentPalette->color[0].ts.pixel = white;
949 pCurrentPalette->color[0].bs.pixel = white;
950 XtSetValues(colorButton[1], args, n);
951 pCurrentPalette->color[1].fg.pixel = white;
952 pCurrentPalette->color[1].bg.pixel = black;
953 pCurrentPalette->color[1].sc.pixel = black;
954 pCurrentPalette->color[1].ts.pixel = white;
955 pCurrentPalette->color[1].bs.pixel = white;
957 else /* WHITE_ONLY */
959 n=0; /* primary and secondary color white */
960 XtSetArg (args[n], XmNforeground, black); n++;
961 XtSetArg (args[n], XmNbackground, white); n++;
962 XtSetArg (args[n], XmNarmColor, white); n++;
963 XtSetValues(colorButton[0], args, n);
964 pCurrentPalette->color[0].fg.pixel = black;
965 pCurrentPalette->color[0].bg.pixel = white;
966 pCurrentPalette->color[0].sc.pixel = white;
967 pCurrentPalette->color[0].ts.pixel = black;
968 pCurrentPalette->color[0].bs.pixel = black;
969 XtSetValues(colorButton[1], args, n);
970 pCurrentPalette->color[1].fg.pixel = black;
971 pCurrentPalette->color[1].bg.pixel = white;
972 pCurrentPalette->color[1].sc.pixel = white;
973 pCurrentPalette->color[1].ts.pixel = black;
974 pCurrentPalette->color[1].bs.pixel = black;
986 XtPointer client_data,
987 XtPointer call_data )
992 XmPushButtonCallbackStruct *cb = (XmPushButtonCallbackStruct *)call_data;
994 i = (int) client_data;
996 /* if click_count == 1 .. first button press, set time out */
997 if(cb->click_count == 1)
999 timeID = XtAppAddTimeOut(XtWidgetToApplicationContext(gParent),
1000 (unsigned long) dclick_time, timeoutCB,
1005 /* else .. second button press, remove the time out */
1006 XtRemoveTimeOut(timeID);
1008 if ((edit.DialogShell == NULL) || (!XtIsManaged(edit.DialogShell)))
1012 /* make the new selected button have a border color */
1014 XtSetArg(args[n],XmNbackground,&bg_pixel); n++;
1015 XtGetValues(colorDialog.colorForm,args,n);
1018 XtSetArg (args[n], XmNborderColor,bg_pixel);
1020 XtSetValues(colorButton[selected_button],args,n);
1023 XtSetArg (args[n], XmNborderColor, BlackPixelOfScreen(style.screen));
1025 XtSetValues(colorButton[i],args,n);
1027 selected_button = i;
1029 color_set = (ColorSet *) &pCurrentPalette->color[selected_button];
1030 ColorEditor(style.colorDialog,color_set);
1032 if(!style.dynamicColor) /* need to update pixels */
1033 XtAddCallback(edit.DialogShell, XmNcallback, colorEditorCB, NULL);
1038 * Color editor callback for screens without dynamicColor.
1040 static void colorEditorCB(Widget w, XtPointer client_data, XtPointer call_data)
1042 static Boolean first = True;
1043 DtDialogBoxCallbackStruct *cb = (DtDialogBoxCallbackStruct *) call_data;
1045 /* show "next session" message if first edit */
1046 if(cb->button_position==OK_BUTTON && first){
1047 InfoDialog(NEXT_SESSION, style.colorDialog, False);
1051 XtRemoveCallback(edit.DialogShell, XmNcallback, colorEditorCB, NULL);
1055 ** This is the double click timeout callback. If this routine is called
1056 ** then there was only a single click on a colorbutton
1060 XtPointer client_data,
1068 if (TypeOfMonitor == XmCO_BLACK_WHITE)
1071 i = (int)client_data;
1073 if ((edit.DialogShell == NULL) || (!XtIsManaged(edit.DialogShell)))
1075 /* make the new selected button have a border color */
1077 XtSetArg(args[n],XmNbackground,&bg_pixel); n++;
1078 XtGetValues(colorDialog.colorForm,args,n);
1081 XtSetArg (args[n], XmNborderColor,bg_pixel);
1083 XtSetValues(colorButton[selected_button],args,n);
1086 XtSetArg (args[n], XmNborderColor, BlackPixelOfScreen(style.screen));
1088 XtSetValues(colorButton[i],args,n);
1089 selected_button = i;
1096 XtPointer client_data,
1097 XtPointer call_data )
1105 if (addDialog == NULL)
1109 XtSetArg(args[n], XmNokLabelString, CMPSTR((String) _DtOkString)); n++;
1110 XtSetArg(args[n], XmNcancelLabelString, CMPSTR((String) _DtCancelString)); n++;
1111 XtSetArg(args[n], XmNhelpLabelString, CMPSTR((String) _DtHelpString)); n++;
1112 string = CMPSTR(((char *)GETMESSAGE(14, 10, "New palette name:")));
1113 XtSetArg(args[n], XmNselectionLabelString, string); n++;
1114 string1 = CMPSTR("");
1115 XtSetArg(args[n], XmNtextString, string1); n++;
1116 XtSetArg(args[n], XmNborderWidth, 3); n++;
1117 XtSetArg(args[n], XmNautoUnmanage, False); n++;
1118 addDialog = XmCreatePromptDialog(style.colorDialog,"AddDialog",
1120 XmStringFree(string);
1121 XmStringFree(string1);
1123 XtAddCallback(addDialog, XmNokCallback, addOkCB,
1125 XtAddCallback(addDialog, XmNcancelCallback, addCancelCB,
1127 XtAddCallback(addDialog, XmNhelpCallback,
1128 (XtCallbackProc)HelpRequestCB, (XtPointer)HELP_ADD_PALETTE_DIALOG);
1131 XtSetArg (args[n], XmNmwmInputMode,
1132 MWM_INPUT_PRIMARY_APPLICATION_MODAL); n++;
1133 XtSetArg (args[n], XmNuseAsyncGeometry, True); n++;
1134 XtSetArg (args[n], XmNtitle, ((char *)GETMESSAGE(14, 11, "Add Palette"))); n++;
1135 XtSetArg (args[n], XmNmwmFunctions, DIALOG_MWM_FUNC); n++;
1136 XtSetValues (XtParent (addDialog), args, n);
1139 string = CMPSTR("");
1140 XtSetArg(args[n], XmNtextString, string); n++;
1141 XtSetValues(addDialog, args, n);
1142 XmStringFree(string);
1144 XtManageChild(addDialog);
1151 XtPointer client_data,
1152 XtPointer call_data )
1154 XtUnmanageChild(addDialog);
1160 XtPointer client_data,
1161 XtPointer call_data )
1166 char *name, *filename, *tmpstr;
1167 palette *tmpPalette, *newPalette;
1172 /* Get the text from the promp dialog */
1173 name = XmTextFieldGetString( XmSelectionBoxGetChild(addDialog, XmDIALOG_TEXT));
1175 /* see if the user typed in a valid palette name */
1176 if(!ValidName(name)) {
1177 ErrDialog(((char *)GETMESSAGE(14, 12, "The palette name cannot contain\nthese characters:\n\n * : ( ) [ ] { } < > ! | \" / \\")),
1183 /* check the number of characters in name in a locale independent way */
1184 for ( ii = 0, count = 0; name[ii] != '\0'; ii += length ) {
1185 length = mblen( &(name[ii]), MB_CUR_MAX );
1191 /* make sure the length of name is ok, short file names can only be 11 chars */
1192 if(count > 10 && !style.longfilename) {
1193 ErrDialog(((char *)GETMESSAGE(14, 13, "The palette name must be\n10 characters or less.\n")),style.colorDialog);
1198 /* Unmanage the promptDialog */
1199 XtUnmanageChild(addDialog);
1201 /* first search through palette descriptions and make sure the name to */
1202 /* add is not already in the list and go to the end of the palette list */
1203 for(tmpPalette = pHeadPalette; tmpPalette->next != NULL;
1204 tmpPalette = tmpPalette->next)
1206 if((strcmp(tmpPalette->desc, name) == 0)) {
1207 SameName(w, tmpPalette, name);
1213 /* Check the last palette */
1214 if((strcmp(tmpPalette->desc, name) == 0)) {
1215 SameName(w, tmpPalette, name);
1220 /* allocate space for a new palette */
1221 newPalette = (palette *)XtMalloc(sizeof(palette) + 1 );
1223 /* set the previous last palatte to this new one, it is now the last one*/
1224 tmpPalette->next = newPalette;
1225 newPalette->next = NULL;
1227 /* malloc space for the new palette desc */
1228 newPalette->desc = (char *)XtMalloc(strlen(name) + 1);
1229 for(i = 0; i < strlen(name); i++)
1230 newPalette->desc[i] = name[i];
1231 newPalette->desc[i] = '\0';
1233 /* malloc space for the new palette name directory */
1234 newPalette->directory = (char *)XtMalloc(strlen(style.home) +
1235 strlen(DT_PAL_DIR) + 1);
1236 strcpy(newPalette->directory, style.home);
1237 strcat(newPalette->directory, DT_PAL_DIR);
1239 /* makeup a new name for the palette */
1240 tmpstr = (char *)XtMalloc(strlen(style.home) + strlen(DT_PAL_DIR) +
1241 strlen("dtXXXXXX") + 1);
1242 strcpy(tmpstr, newPalette->directory);
1243 len = strlen(tmpstr);
1244 strcat(tmpstr, "dtXXXXXX");
1247 newPalette->name = (char *) XtMalloc(15 * sizeof(char));
1248 strcpy(newPalette->name, tmpstr + len);
1251 /* the new palette is the next palette .. increase NumOfPalettes by one */
1252 newPalette->item_position = NumOfPalettes + 1;
1255 /* set all the new palette's color parameters to the current palette */
1256 newPalette->num_of_colors = pCurrentPalette->num_of_colors;
1257 for(i = 0; i < XmCO_MAX_NUM_COLORS; i++)
1259 newPalette->color[i].fg.pixel = pCurrentPalette->color[i].fg.pixel;
1260 newPalette->color[i].fg.red = pCurrentPalette->color[i].fg.red;
1261 newPalette->color[i].fg.green = pCurrentPalette->color[i].fg.green;
1262 newPalette->color[i].fg.blue = pCurrentPalette->color[i].fg.blue;
1263 newPalette->color[i].fg.flags = pCurrentPalette->color[i].fg.flags;
1265 newPalette->color[i].bg.pixel = pCurrentPalette->color[i].bg.pixel;
1266 newPalette->color[i].bg.red = pCurrentPalette->color[i].bg.red;
1267 newPalette->color[i].bg.green = pCurrentPalette->color[i].bg.green;
1268 newPalette->color[i].bg.blue = pCurrentPalette->color[i].bg.blue;
1269 newPalette->color[i].bg.flags = pCurrentPalette->color[i].bg.flags;
1271 newPalette->color[i].ts.pixel = pCurrentPalette->color[i].ts.pixel;
1272 newPalette->color[i].ts.red = pCurrentPalette->color[i].ts.red;
1273 newPalette->color[i].ts.green = pCurrentPalette->color[i].ts.green;
1274 newPalette->color[i].ts.blue = pCurrentPalette->color[i].ts.blue;
1275 newPalette->color[i].ts.flags = pCurrentPalette->color[i].ts.flags;
1277 newPalette->color[i].bs.pixel = pCurrentPalette->color[i].bs.pixel;
1278 newPalette->color[i].bs.red = pCurrentPalette->color[i].bs.red;
1279 newPalette->color[i].bs.green = pCurrentPalette->color[i].bs.green;
1280 newPalette->color[i].bs.blue = pCurrentPalette->color[i].bs.blue;
1281 newPalette->color[i].bs.flags = pCurrentPalette->color[i].bs.flags;
1283 newPalette->color[i].sc.pixel = pCurrentPalette->color[i].sc.pixel;
1284 newPalette->color[i].sc.red = pCurrentPalette->color[i].sc.red;
1285 newPalette->color[i].sc.green = pCurrentPalette->color[i].sc.green;
1286 newPalette->color[i].sc.blue = pCurrentPalette->color[i].sc.blue;
1287 newPalette->color[i].sc.flags = pCurrentPalette->color[i].sc.flags;
1290 /* Write out the palette */
1291 if ((WriteOutPalette(newPalette->name)) == -1)
1295 /* remove palette from list */
1296 tmpPalette->next = NULL;
1297 XtFree ((char *)newPalette);
1302 WriteOutDesc(newPalette);
1305 /* add the name to the scrolled window list and select it */
1306 AddName(newPalette);
1308 /* now check to see if there is a ~filename .. if there is delete it */
1309 /* use the $HOME environment varible then constuct the full file name */
1310 filename = (char *)XtMalloc(strlen(style.home) + strlen(DT_PAL_DIR) +
1311 strlen(newPalette->name) + strlen(PALETTE_SUFFIX) + 2);
1313 /* create the full path name plus file name */
1314 strcpy(filename, style.home);
1315 strcat(filename, DT_PAL_DIR);
1316 strcat(filename, "~");
1317 strcat(filename, newPalette->name);
1318 strcat(filename, PALETTE_SUFFIX);
1325 /* Go write out the palette */
1326 pCurrentPalette = newPalette;
1333 XtPointer client_data,
1334 XtPointer call_data )
1336 palette *tmpPalette = (palette *)client_data;
1339 /* free the directory */
1340 XtFree(tmpPalette->directory);
1342 /* put the new (users) directory there */
1343 tmpPalette->directory = (char *)XtMalloc(strlen(style.home) +
1344 strlen(DT_PAL_DIR) + 1);
1345 strcpy(tmpPalette->directory, style.home);
1346 strcat(tmpPalette->directory, DT_PAL_DIR);
1348 for(i = 0; i < XmCO_MAX_NUM_COLORS; i++)
1350 tmpPalette->color[i].fg.pixel = pCurrentPalette->color[i].fg.pixel;
1351 tmpPalette->color[i].fg.red = pCurrentPalette->color[i].fg.red;
1352 tmpPalette->color[i].fg.green = pCurrentPalette->color[i].fg.green;
1353 tmpPalette->color[i].fg.blue = pCurrentPalette->color[i].fg.blue;
1354 tmpPalette->color[i].fg.flags = pCurrentPalette->color[i].fg.flags;
1356 tmpPalette->color[i].bg.pixel = pCurrentPalette->color[i].bg.pixel;
1357 tmpPalette->color[i].bg.red = pCurrentPalette->color[i].bg.red;
1358 tmpPalette->color[i].bg.green = pCurrentPalette->color[i].bg.green;
1359 tmpPalette->color[i].bg.blue = pCurrentPalette->color[i].bg.blue;
1360 tmpPalette->color[i].bg.flags = pCurrentPalette->color[i].bg.flags;
1362 tmpPalette->color[i].ts.pixel = pCurrentPalette->color[i].ts.pixel;
1363 tmpPalette->color[i].ts.red = pCurrentPalette->color[i].ts.red;
1364 tmpPalette->color[i].ts.green = pCurrentPalette->color[i].ts.green;
1365 tmpPalette->color[i].ts.blue = pCurrentPalette->color[i].ts.blue;
1366 tmpPalette->color[i].ts.flags = pCurrentPalette->color[i].ts.flags;
1368 tmpPalette->color[i].bs.pixel = pCurrentPalette->color[i].bs.pixel;
1369 tmpPalette->color[i].bs.red = pCurrentPalette->color[i].bs.red;
1370 tmpPalette->color[i].bs.green = pCurrentPalette->color[i].bs.green;
1371 tmpPalette->color[i].bs.blue = pCurrentPalette->color[i].bs.blue;
1372 tmpPalette->color[i].bs.flags = pCurrentPalette->color[i].bs.flags;
1374 tmpPalette->color[i].sc.pixel = pCurrentPalette->color[i].sc.pixel;
1375 tmpPalette->color[i].sc.red = pCurrentPalette->color[i].sc.red;
1376 tmpPalette->color[i].sc.green = pCurrentPalette->color[i].sc.green;
1377 tmpPalette->color[i].sc.blue = pCurrentPalette->color[i].sc.blue;
1378 tmpPalette->color[i].sc.flags = pCurrentPalette->color[i].sc.flags;
1381 /* Write out the palette */
1382 if ((WriteOutPalette(tmpPalette->name)) == -1)
1385 WriteOutDesc(tmpPalette);
1387 pCurrentPalette = tmpPalette;
1389 /* select item in list as if user had selected it */
1390 XmListSelectPos (paletteList, tmpPalette->item_position, TRUE);
1391 XmListSetBottomPos(paletteList, tmpPalette->item_position);
1392 selected_position = tmpPalette->item_position;
1399 XtPointer client_data,
1400 XtPointer call_data )
1402 ColorSet *color_set;
1404 if(TypeOfMonitor == XmCO_BLACK_WHITE)
1407 color_set = (ColorSet *) &pCurrentPalette->color[selected_button];
1408 ColorEditor(style.colorDialog,color_set);
1410 if(!style.dynamicColor) /* need to update pixels */
1411 XtAddCallback(edit.DialogShell, XmNcallback, colorEditorCB, NULL);
1417 ** Process callback from the Ok, Cancel and Help pushButtons in the
1423 XtPointer client_data,
1424 XtPointer call_data )
1426 palette *tmp_palette;
1428 DtDialogBoxCallbackStruct *cb = (DtDialogBoxCallbackStruct *) call_data;
1430 switch (cb->button_position)
1433 if ((edit.DialogShell != NULL) && (XtIsManaged(edit.DialogShell)))
1434 XtUnmanageChild(edit.DialogShell);
1436 XtUnmanageChild(style.colorDialog);
1437 UpdateDefaultPalette();
1441 if ((edit.DialogShell != NULL) && (XtIsManaged(edit.DialogShell)))
1442 XtUnmanageChild(edit.DialogShell);
1444 if ((addDialog != NULL) && (XtIsManaged(addDialog)))
1445 XtCallCallbacks(addDialog, XmNcancelCallback, (XtPointer)NULL);
1447 if ((deleteDialog != NULL) && (XtIsManaged(deleteDialog)))
1448 XtCallCallbacks(deleteDialog, XmNcancelCallback, (XtPointer)NULL);
1450 if ((colorUseDialog != NULL) && (XtIsManaged(colorUseDialog)))
1451 XtCallCallbacks(colorUseDialog, XmNcallback, (XtPointer)NULL);
1453 XtUnmanageChild(style.colorDialog);
1455 tmp_palette = pHeadPalette;
1456 for(tmp_palette = pHeadPalette; tmp_palette != NULL; tmp_palette = tmp_palette->next)
1457 if(!(strcmp(tmp_palette->name, defaultName)))
1463 if(match == FALSE) /* the default palette is no longer valid */
1464 UpdateDefaultPalette();
1466 RestoreOrgPalette();
1471 XtCallCallbacks(style.colorDialog, XmNhelpCallback, (XtPointer)NULL);
1482 palette *newPalette )
1487 ** Add the palette name to the list
1489 string = CMPSTR(newPalette->desc);
1490 XmListAddItem(paletteList, string, newPalette->item_position);
1491 XmListSelectPos(paletteList, newPalette->item_position, TRUE);
1492 XmListSetBottomPos(paletteList, newPalette->item_position);
1493 selected_position = newPalette->item_position;
1494 XSync(style.display, 0);
1495 XmStringFree(string);
1501 XtPointer client_data,
1502 XtPointer call_data )
1507 palette *tmp_palette;
1510 char *str_type_return;
1511 XrmValue value_return;
1513 tmp_palette = pHeadPalette;
1515 while( tmp_palette->item_position != selected_position &&
1516 tmp_palette != NULL)
1517 tmp_palette = tmp_palette->next;
1519 if (deleteDialog == NULL)
1522 XtSetArg(args[n], XmNokLabelString, CMPSTR((String) _DtOkString)); n++;
1523 XtSetArg(args[n], XmNcancelLabelString, CMPSTR((String) _DtCancelString)); n++;
1524 XtSetArg(args[n], XmNhelpLabelString, CMPSTR((String) _DtHelpString)); n++;
1525 XtSetArg(args[n], XmNdialogType, XmDIALOG_INFORMATION); n++;
1526 XtSetArg(args[n], XmNborderWidth, 3); n++;
1527 XtSetArg(args[n], XmNdefaultPosition, False); n++;
1528 deleteDialog = XmCreateQuestionDialog(style.colorDialog,
1529 "deleteDialog", args, n);
1530 XtAddCallback(deleteDialog, XmNmapCallback, CenterMsgCB,
1532 XtAddCallback(deleteDialog, XmNcancelCallback, deleteCancelCB, NULL);
1533 XtAddCallback(deleteDialog, XmNokCallback, deleteOkCB,
1534 (XtPointer)(paletteList));
1535 XtAddCallback(deleteDialog, XmNhelpCallback,
1536 (XtCallbackProc)HelpRequestCB,
1537 (XtPointer)HELP_DELETE_PALETTE_WARNING_DIALOG);
1541 XtSetArg (args[n], XmNmwmInputMode,
1542 MWM_INPUT_PRIMARY_APPLICATION_MODAL); n++;
1543 XtSetArg (args[n], XmNuseAsyncGeometry, True); n++;
1544 XtSetArg (args[n], XmNtitle, ((char *)GETMESSAGE(14, 16, "Delete Palette"))); n++;
1545 XtSetArg (args[n], XmNmwmFunctions, DIALOG_MWM_FUNC); n++;
1546 XtSetValues (XtParent (deleteDialog), args, n);
1551 tmpStr = XtMalloc(strlen(STR2) + strlen(tmp_palette->desc) + 1);
1552 sprintf(tmpStr, STR2, tmp_palette->desc);
1553 XtSetArg(args[n], XmNmessageString, CMPSTR(tmpStr)); n++;
1554 XtSetValues(deleteDialog, args, n);
1557 XtManageChild(deleteDialog);
1563 XtPointer client_data,
1564 XtPointer call_data )
1567 XtUnmanageChild(deleteDialog);
1569 if(NumOfPalettes == 1)
1571 InfoDialog(CANT_DELETE, style.colorDialog, False);
1575 if (RemovePalette() == True)
1576 DeletePaletteFromLinkList((Widget)client_data);
1583 XtPointer client_data,
1584 XtPointer call_data )
1586 XtUnmanageChild(deleteDialog);
1592 XtPointer client_data,
1593 XtPointer call_data )
1598 XmString button_string[NUM_LABELS];
1600 Widget parent = (Widget) client_data;
1603 Widget widget_list[10];
1608 if (colorUseDialog == NULL)
1612 /* Set up DialogBox button labels. */
1613 button_string[0] = CMPSTR((String) _DtOkString);
1614 button_string[1] = CMPSTR((String) _DtCancelString);
1615 button_string[2] = CMPSTR((String) _DtHelpString);
1617 XtSetArg (args[n], XmNchildType, XmWORK_AREA); n++;
1618 XtSetArg (args[n], XmNbuttonCount, NUM_LABELS); n++;
1619 XtSetArg (args[n], XmNbuttonLabelStrings, button_string); n++;
1620 XtSetArg (args[n], XmNdefaultPosition, False); n++;
1621 colorUseDialog = __DtCreateDialogBoxDialog(parent, "colorUseDialog",
1623 XtAddCallback(colorUseDialog, XmNcallback, colorUseExitCB, NULL);
1624 XtAddCallback(colorUseDialog, XmNmapCallback, _DtmapCB_colorUse, NULL);
1625 XtAddCallback(colorUseDialog, XmNhelpCallback,
1626 (XtCallbackProc)HelpRequestCB, (XtPointer)HELP_COLOR_USE_DIALOG);
1628 XmStringFree(button_string[0]);
1629 XmStringFree(button_string[1]);
1630 XmStringFree(button_string[2]);
1632 widget_list[0] = _DtDialogBoxGetButton(colorUseDialog,2);
1634 XtSetArg(args[n], XmNautoUnmanage, False); n++;
1635 XtSetArg(args[n], XmNcancelButton, widget_list[0]); n++;
1636 XtSetValues (colorUseDialog, args, n);
1639 XtSetArg (args[n], XmNuseAsyncGeometry, True); n++;
1640 XtSetArg (args[n], XmNtitle,
1641 ((char *)GETMESSAGE(14, 39, "Number Of Colors To Use:"))); n++;
1642 XtSetArg (args[n], XmNmwmFunctions, DIALOG_MWM_FUNC); n++;
1643 XtSetValues (XtParent(colorUseDialog), args, n);
1646 XtSetArg(args[n], XmNhorizontalSpacing, style.horizontalSpacing); n++;
1647 XtSetArg(args[n], XmNverticalSpacing, style.verticalSpacing); n++;
1648 XtSetArg(args[n], XmNallowOverlap, False); n++;
1649 XtSetArg(args[n], XmNchildType, XmWORK_AREA); n++;
1650 form = XmCreateForm(colorUseDialog, "colorUseForm", args, n);
1651 XtManageChild(form);
1654 XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
1655 XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
1656 XtSetArg (args[n], XmNrightAttachment, XmATTACH_NONE); n++;
1657 XtSetArg (args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
1658 XtSetArg (args[n], XmNbehavior, XmICON_LABEL); n++;
1659 XtSetArg (args[n], XmNshadowThickness, 0); n++;
1660 XtSetArg (args[n], XmNstring, NULL); n++;
1661 XtSetArg (args[n], XmNpixmapForeground, style.primBSCol); n++;
1662 XtSetArg (args[n], XmNpixmapBackground, style.primTSCol); n++;
1663 XtSetArg (args[n], XmNimageName, COLOR_ICON); n++;
1664 XtSetArg (args[n], XmNtraversalOn, False); n++;
1665 pictLabel = _DtCreateIcon(form, "pictLabel", args, n);
1666 XtManageChild(pictLabel);
1669 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
1670 XtSetArg (args[n], XmNtopWidget, pictLabel); n++;
1671 XtSetArg (args[n], XmNtopOffset, style.verticalSpacing); n++;
1672 XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
1673 XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
1674 XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
1676 = XmCreateFrame(form, "colorUseTB", args, n);
1677 XtManageChild(colorUseTB);
1679 /* create a rowColumn for ColorUse selections */
1681 colorUseRC = XmCreateRadioBox(colorUseTB, "colorUseRC", args, n);
1682 XtManageChild(colorUseRC);
1685 string = CMPSTR(((char *)GETMESSAGE(14, 41, "More Colors for Desktop")));
1686 XtSetArg(args[n], XmNlabelString, string); n++;
1687 widget_list[count++] = colorDialog.highColorTG
1688 = XmCreateToggleButtonGadget(colorUseRC,"highColorTG", args, n);
1689 XtAddCallback(colorDialog.highColorTG, XmNvalueChangedCallback,
1690 colorUseCB, (XtPointer)XmCO_HIGH_COLOR);
1691 XmStringFree(string);
1694 string = CMPSTR(((char *)GETMESSAGE(14, 42, "More Colors for Applications")));
1695 XtSetArg(args[n], XmNlabelString, string); n++;
1696 widget_list[count++] = colorDialog.mediumColorTG
1697 = XmCreateToggleButtonGadget(colorUseRC,"mediumColorTG", args, n);
1698 XmStringFree(string);
1699 XtAddCallback(colorDialog.mediumColorTG, XmNvalueChangedCallback,
1700 colorUseCB, (XtPointer)XmCO_MEDIUM_COLOR);
1703 string = CMPSTR(((char *)GETMESSAGE(14, 43, "Most Colors for Applications")));
1704 XtSetArg(args[n], XmNlabelString, string); n++;
1705 widget_list[count++] = colorDialog.lowColorTG
1706 = XmCreateToggleButtonGadget(colorUseRC,"lowColorTG", args, n);
1707 XmStringFree(string);
1708 XtAddCallback(colorDialog.lowColorTG, XmNvalueChangedCallback,
1709 colorUseCB, (XtPointer)XmCO_LOW_COLOR);
1712 string = CMPSTR(((char *)GETMESSAGE(14, 34, "Black and White")));
1713 XtSetArg(args[n], XmNlabelString, string); n++;
1714 widget_list[count++] = colorDialog.blackWhiteTG
1715 = XmCreateToggleButtonGadget(colorUseRC,"blackWhiteTG", args, n);
1716 XmStringFree(string);
1717 XtAddCallback(colorDialog.blackWhiteTG, XmNvalueChangedCallback,
1718 colorUseCB, (XtPointer)XmCO_BLACK_WHITE);
1721 string = CMPSTR(((char *)GETMESSAGE(14, 35, "Default")));
1722 XtSetArg(args[n], XmNlabelString, string); n++;
1723 widget_list[count++] = colorDialog.defaultTG
1724 = XmCreateToggleButtonGadget(colorUseRC,"defaultTG", args, n);
1725 XmStringFree(string);
1726 XtAddCallback(colorDialog.defaultTG, XmNvalueChangedCallback,
1727 colorUseCB, (XtPointer)DEFAULT_COLOR);
1729 XtManageChildren(widget_list,count);
1730 putDialog (XtParent(style.colorDialog), colorUseDialog);
1733 XtManageChild(colorUseDialog);
1738 ** Process new ColorUse selection
1743 XtPointer client_data,
1744 XtPointer call_data )
1747 XmToggleButtonCallbackStruct *cb =
1748 (XmToggleButtonCallbackStruct *)call_data;
1750 colorDialog.currentColorUse = (int) client_data;
1751 switch (colorDialog.currentColorUse)
1753 case XmCO_HIGH_COLOR:
1754 colorDialog.currentColorUseStr = HIGH_COLOR_STR;
1757 case XmCO_MEDIUM_COLOR:
1758 colorDialog.currentColorUseStr = MEDIUM_COLOR_STR;
1761 case XmCO_LOW_COLOR:
1762 colorDialog.currentColorUseStr = LOW_COLOR_STR;
1765 case XmCO_BLACK_WHITE:
1766 colorDialog.currentColorUseStr = B_W_STR;
1770 colorDialog.currentColorUseStr = DEFAULT_COLOR_STR;
1780 ** Process callback from the Ok, Cancel and Help pushButtons in the
1781 ** Configure DT Colors DialogBox.
1786 XtPointer client_data,
1787 XtPointer call_data )
1790 char colorUseRes[64];
1791 DtDialogBoxCallbackStruct *cb = (DtDialogBoxCallbackStruct *) call_data;
1793 switch (cb->button_position)
1796 XtCallCallbacks(colorUseDialog, XmNhelpCallback, (XtPointer)NULL);
1801 XtUnmanageChild(colorUseDialog);
1803 if (colorDialog.origColorUse != colorDialog.currentColorUse)
1805 InfoDialog(COLORUSE_WHEN, style.colorDialog, False);
1807 /* create the ColorUse resource spec for xrdb */
1808 /* remove ColorUse specification from database for DEFAULT_COLOR */
1810 sprintf(colorUseRes, "*%d*ColorUse: %s\n",
1811 style.screenNum,colorDialog.currentColorUseStr);
1813 switch (colorDialog.currentColorUse)
1815 case XmCO_MEDIUM_COLOR:
1816 sprintf(colorUseRes+strlen(colorUseRes),
1817 "*HelpColorUse: GRAY_SCALE\n");
1821 case XmCO_LOW_COLOR:
1822 case XmCO_BLACK_WHITE:
1823 sprintf(colorUseRes+strlen(colorUseRes),
1824 "*HelpColorUse: B_W\n");
1828 case XmCO_HIGH_COLOR:
1831 sprintf(colorUseRes+strlen(colorUseRes),
1832 "*HelpColorUse: COLOR\n");
1836 _DtAddToResource(style.display, colorUseRes);
1838 colorDialog.origColorUse = colorDialog.currentColorUse;
1846 XtUnmanageChild(colorUseDialog);
1848 switch (colorDialog.origColorUse)
1850 case XmCO_HIGH_COLOR:
1851 XmToggleButtonGadgetSetState(colorDialog.highColorTG, True, True);
1854 case XmCO_MEDIUM_COLOR:
1855 XmToggleButtonGadgetSetState(colorDialog.mediumColorTG, True, True);
1858 case XmCO_LOW_COLOR:
1859 XmToggleButtonGadgetSetState(colorDialog.lowColorTG, True, True);
1862 case XmCO_BLACK_WHITE:
1863 XmToggleButtonGadgetSetState(colorDialog.blackWhiteTG, True, True);
1867 XmToggleButtonGadgetSetState(colorDialog.defaultTG, True, True);
1877 activateCBexitColor(
1879 XtPointer client_data,
1880 XtPointer call_data )
1882 DtDialogBoxCallbackStruct CancelBut;
1884 if(style.colorDialog != NULL && XtIsManaged(style.colorDialog)) {
1885 CancelBut.button_position = CANCEL_BUTTON;
1886 XtCallCallbacks(style.colorDialog, XmNcallback, &CancelBut);
1893 XtPointer client_data,
1895 XtPointer call_data )
1898 DtWsmRemoveWorkspaceFunctions(style.display, XtWindow(XtParent(w)));
1900 if (!save.restoreFlag)
1901 putDialog ((Widget)client_data, XtParent(w));
1903 XtRemoveCallback(style.colorDialog, XmNmapCallback, _DtmapCB, NULL);
1909 XtPointer client_data,
1911 XtPointer call_data )
1914 char *str_type_return;
1915 XrmValue value_return;
1920 char instanceString[24], nameString[24];
1922 DtWsmRemoveWorkspaceFunctions(style.display, XtWindow(XtParent(w)));
1924 db = XtDatabase(style.display);
1926 /* Get ColorUse value */
1927 sprintf (instanceString, "dtsession*%d*colorUse",style.screenNum);
1928 sprintf (nameString, "Dtsession*%d*ColorUse",style.screenNum);
1930 if (status = XrmGetResource (db, instanceString,
1932 &str_type_return, &value_return))
1934 /* make local copy of string */
1935 string = (char *) XtMalloc( value_return.size );
1936 strcpy (string, value_return.addr);
1938 if (strcmp(string, HIGH_COLOR_STR) == 0)
1940 XmToggleButtonGadgetSetState (colorDialog.highColorTG, True, True);
1941 colorDialog.origColorUse = XmCO_HIGH_COLOR;
1943 else if (strcmp(string, MEDIUM_COLOR_STR) == 0)
1945 XmToggleButtonGadgetSetState (colorDialog.mediumColorTG, True, True);
1946 colorDialog.origColorUse = XmCO_MEDIUM_COLOR;
1948 else if (strcmp(string, LOW_COLOR_STR) == 0)
1950 XmToggleButtonGadgetSetState (colorDialog.lowColorTG, True, True);
1951 colorDialog.origColorUse = XmCO_LOW_COLOR;
1953 else if (strcmp(string, B_W_STR) == 0)
1955 XmToggleButtonGadgetSetState (colorDialog.blackWhiteTG, True, True);
1956 colorDialog.origColorUse = XmCO_BLACK_WHITE;
1960 XmToggleButtonGadgetSetState (colorDialog.defaultTG, True, True);
1961 colorDialog.origColorUse = DEFAULT_COLOR;
1966 else /* ColorUse not specified */
1968 XmToggleButtonGadgetSetState (colorDialog.defaultTG, True, True);
1969 colorDialog.origColorUse = DEFAULT_COLOR;
1972 XtRemoveCallback(colorUseDialog, XmNmapCallback, _DtmapCB_colorUse, NULL);
1975 /************************************************************************
1977 * DeletePaletteFromLinkList - routine used to delete a palette from
1978 * the link list of palettes. The palette which is at the current
1979 * selected_position is the palette that is going to be deleted.
1980 * Special things have to happen if the selected palette is at the
1983 ************************************************************************/
1985 DeletePaletteFromLinkList(
1992 palette *tmp_palette, *tmp2_palette;
1993 palette *selected_palette;
1996 selected_palette = pHeadPalette;
1997 while( selected_palette->item_position != selected_position &&
1998 selected_palette != NULL)
1999 selected_palette = selected_palette->next;
2001 XmListDeletePos (list, selected_palette->item_position);
2003 /* delete item from palette list structure */
2005 /* If the palette is at the head .. remove the head and the next
2006 palette becomes the new selected palette */
2007 if (selected_palette->item_position == 1)
2009 pHeadPalette = selected_palette->next;
2010 tmp_palette = pHeadPalette;
2011 tmp_palette->item_position--;
2012 /* new current palette */
2013 pCurrentPalette = tmp_palette;
2015 else /* find the palette just above the palette to be deleted .. it
2016 will become the new selected palette */
2018 tmp_palette = pHeadPalette;
2019 for (i=1; i < selected_palette->item_position-1; i++)
2020 tmp_palette = tmp_palette->next;
2022 tmp_palette->next = selected_palette->next;
2024 /* what is CurrentPalette now? prev or next item?
2025 special case empty list or NULL entry */
2026 if (tmp_palette->next != NULL)
2027 pCurrentPalette = tmp_palette->next;
2029 pCurrentPalette = tmp_palette;
2032 /* decrement item_positions values in remaining palette entries */
2033 tmp2_palette = tmp_palette;
2034 while ((tmp2_palette = tmp2_palette->next) != NULL)
2036 tmp2_palette->item_position--;
2039 /* go copy the pixel numbers to the new palette */
2040 CopyPixel(selected_palette->color, pCurrentPalette->color,
2041 selected_palette->num_of_colors);
2043 /* select item in list as if user had selected it */
2044 XmListSelectPos (list, tmp_palette->item_position, TRUE);
2045 /* Need to check to see if the first palette is being deleted if it is
2046 need to change colors and update title box */
2047 if(selected_position == tmp_palette->item_position) {
2048 pOldPalette = selected_palette;
2051 string = CMPSTR(pCurrentPalette->desc);
2052 XtSetArg (args[n], XmNtitleString, string); n++;
2053 XtSetValues (colorDialog.buttonsTB, args, n);
2054 XmStringFree(string);
2059 XmListSetBottomPos(paletteList, tmp_palette->item_position);
2060 selected_position = tmp_palette->item_position;
2064 /* deallocate the palette structure */
2065 XtFree(selected_palette->name);
2066 XtFree(selected_palette->desc);
2067 XtFree(selected_palette->directory);
2068 XtFree((char *)selected_palette);
2073 ColorSet srcPixels[XmCO_MAX_NUM_COLORS],
2074 ColorSet dstPixels[XmCO_MAX_NUM_COLORS],
2079 for(i=0; i < numOfColors; i++)
2081 dstPixels[i].bg.pixel = srcPixels[i].bg.pixel;
2082 dstPixels[i].fg.pixel = srcPixels[i].fg.pixel;
2083 dstPixels[i].ts.pixel = srcPixels[i].ts.pixel;
2084 dstPixels[i].bs.pixel = srcPixels[i].bs.pixel;
2085 dstPixels[i].sc.pixel = srcPixels[i].sc.pixel;
2090 SaveOrgPalette( void )
2093 palette *tmp_palette, *tmp2_palette;
2095 if(save.restoreFlag && defaultName_restore[0] != 0) {
2096 tmp_palette = pHeadPalette;
2097 while(tmp_palette->next != NULL )
2098 if(strcmp(tmp_palette->name, defaultName))
2100 tmp_palette = tmp_palette->next;
2106 if(!strcmp(tmp_palette->name, defaultName)) {
2107 tmp2_palette = pCurrentPalette;
2108 pCurrentPalette = tmp_palette;
2114 OrgPalette.item_position = pCurrentPalette->item_position;
2115 OrgPalette.num_of_colors = pCurrentPalette->num_of_colors;
2116 for(i = 0; i < XmCO_MAX_NUM_COLORS; i++)
2118 OrgPalette.primary = pCurrentPalette->primary;
2119 OrgPalette.secondary = pCurrentPalette->secondary;
2120 OrgPalette.active = pCurrentPalette->active;
2121 OrgPalette.inactive = pCurrentPalette->inactive;
2123 if(save.restoreFlag && defaultName_restore[0] != 0)
2124 OrgPalette.color[i].bg.pixel = tmp2_palette->color[i].bg.pixel;
2126 OrgPalette.color[i].bg.pixel = pCurrentPalette->color[i].bg.pixel;
2127 OrgPalette.color[i].bg.red = pCurrentPalette->color[i].bg.red;
2128 OrgPalette.color[i].bg.green = pCurrentPalette->color[i].bg.green;
2129 OrgPalette.color[i].bg.blue = pCurrentPalette->color[i].bg.blue;
2131 if(save.restoreFlag && defaultName_restore[0] != 0)
2132 OrgPalette.color[i].fg.pixel = tmp2_palette->color[i].fg.pixel;
2134 OrgPalette.color[i].fg.pixel = pCurrentPalette->color[i].fg.pixel;
2135 OrgPalette.color[i].fg.red = pCurrentPalette->color[i].fg.red;
2136 OrgPalette.color[i].fg.green = pCurrentPalette->color[i].fg.green;
2137 OrgPalette.color[i].fg.blue = pCurrentPalette->color[i].fg.blue;
2139 if(save.restoreFlag && defaultName_restore[0] != 0)
2140 OrgPalette.color[i].ts.pixel = tmp2_palette->color[i].ts.pixel;
2142 OrgPalette.color[i].ts.pixel = pCurrentPalette->color[i].ts.pixel;
2143 OrgPalette.color[i].ts.red = pCurrentPalette->color[i].ts.red;
2144 OrgPalette.color[i].ts.green = pCurrentPalette->color[i].ts.green;
2145 OrgPalette.color[i].ts.blue = pCurrentPalette->color[i].ts.blue;
2147 if(save.restoreFlag && defaultName_restore[0] != 0)
2148 OrgPalette.color[i].bs.pixel = tmp2_palette->color[i].bs.pixel;
2150 OrgPalette.color[i].bs.pixel = pCurrentPalette->color[i].bs.pixel;
2151 OrgPalette.color[i].bs.red = pCurrentPalette->color[i].bs.red;
2152 OrgPalette.color[i].bs.green = pCurrentPalette->color[i].bs.green;
2153 OrgPalette.color[i].bs.blue = pCurrentPalette->color[i].bs.blue;
2155 if(save.restoreFlag && defaultName_restore[0] != 0)
2156 OrgPalette.color[i].sc.pixel = tmp2_palette->color[i].sc.pixel;
2158 OrgPalette.color[i].sc.pixel = pCurrentPalette->color[i].sc.pixel;
2159 OrgPalette.color[i].sc.red = pCurrentPalette->color[i].sc.red;
2160 OrgPalette.color[i].sc.green = pCurrentPalette->color[i].sc.green;
2161 OrgPalette.color[i].sc.blue = pCurrentPalette->color[i].sc.blue;
2164 if(save.restoreFlag && defaultName_restore[0] != 0)
2165 if(tmp_palette != NULL)
2166 pCurrentPalette = tmp2_palette;
2171 RestoreOrgPalette( void )
2174 palette *tmp_palette;
2176 XColor colors[XmCO_MAX_NUM_COLORS * 5];
2178 tmp_palette = pHeadPalette;
2179 while ( tmp_palette != NULL &&
2180 tmp_palette->item_position != OrgPalette.item_position )
2181 tmp_palette = tmp_palette->next;
2183 if ( tmp_palette != NULL &&
2184 tmp_palette->item_position == OrgPalette.item_position)
2186 pCurrentPalette = tmp_palette;
2187 OrgPalette.num_of_colors = pCurrentPalette->num_of_colors;
2188 for(i = 0; i < XmCO_MAX_NUM_COLORS; i++)
2190 pCurrentPalette->primary = OrgPalette.primary;
2191 pCurrentPalette->secondary = OrgPalette.secondary;
2192 pCurrentPalette->inactive = OrgPalette.inactive;
2193 pCurrentPalette->active = OrgPalette.active;
2195 pCurrentPalette->color[i].bg.pixel = OrgPalette.color[i].bg.pixel;
2196 pCurrentPalette->color[i].bg.red = OrgPalette.color[i].bg.red;
2197 pCurrentPalette->color[i].bg.green = OrgPalette.color[i].bg.green;
2198 pCurrentPalette->color[i].bg.blue = OrgPalette.color[i].bg.blue;
2199 if(i < OrgPalette.num_of_colors && TypeOfMonitor != XmCO_BLACK_WHITE)
2200 colors[j++] = pCurrentPalette->color[i].bg;
2202 pCurrentPalette->color[i].sc.pixel = OrgPalette.color[i].sc.pixel;
2203 pCurrentPalette->color[i].sc.red = OrgPalette.color[i].sc.red;
2204 pCurrentPalette->color[i].sc.green = OrgPalette.color[i].sc.green;
2205 pCurrentPalette->color[i].sc.blue = OrgPalette.color[i].sc.blue;
2206 if(i < OrgPalette.num_of_colors && TypeOfMonitor != XmCO_BLACK_WHITE)
2207 colors[j++] = pCurrentPalette->color[i].sc;
2209 pCurrentPalette->color[i].fg.pixel = OrgPalette.color[i].fg.pixel;
2210 pCurrentPalette->color[i].fg.red = OrgPalette.color[i].fg.red;
2211 pCurrentPalette->color[i].fg.green = OrgPalette.color[i].fg.green;
2212 pCurrentPalette->color[i].fg.blue = OrgPalette.color[i].fg.blue;
2213 if(i < OrgPalette.num_of_colors && TypeOfMonitor != XmCO_BLACK_WHITE)
2214 if(FgColor == DYNAMIC)
2215 colors[j++] = pCurrentPalette->color[i].fg;
2217 pCurrentPalette->color[i].ts.pixel = OrgPalette.color[i].ts.pixel;
2218 pCurrentPalette->color[i].ts.red = OrgPalette.color[i].ts.red;
2219 pCurrentPalette->color[i].ts.green = OrgPalette.color[i].ts.green;
2220 pCurrentPalette->color[i].ts.blue = OrgPalette.color[i].ts.blue;
2221 if(i < OrgPalette.num_of_colors && TypeOfMonitor != XmCO_BLACK_WHITE)
2222 if(UsePixmaps == FALSE)
2223 colors[j++] = pCurrentPalette->color[i].ts;
2225 pCurrentPalette->color[i].bs.pixel = OrgPalette.color[i].bs.pixel;
2226 pCurrentPalette->color[i].bs.red = OrgPalette.color[i].bs.red;
2227 pCurrentPalette->color[i].bs.green = OrgPalette.color[i].bs.green;
2228 pCurrentPalette->color[i].bs.blue = OrgPalette.color[i].bs.blue;
2229 if(i < OrgPalette.num_of_colors && TypeOfMonitor != XmCO_BLACK_WHITE)
2230 if(UsePixmaps == FALSE)
2231 colors[j++] = pCurrentPalette->color[i].bs;
2235 if (style.dynamicColor)
2236 XStoreColors (style.display, style.colormap, colors, j);
2238 XmListSelectPos (paletteList, OrgPalette.item_position, TRUE);
2239 XmListSetBottomPos(paletteList, OrgPalette.item_position);
2245 UpdateDefaultPalette( void )
2248 char temp[XmCO_MAX_NUM_COLORS][60];
2249 char xrdb_string[100];
2250 XColor saved_color[2];
2252 for(i = 0; i < XmCO_MAX_NUM_COLORS; i++)
2254 /* put the colors of the palette in the form #RRRRGGGGBBBB */
2255 if(TypeOfMonitor == XmCO_LOW_COLOR && (i == 0 || i == 1))
2256 sprintf(temp[i],"#%04x%04x%04x\n", saved_color[i].red,
2257 saved_color[i].green,
2258 saved_color[i].blue);
2259 else if(TypeOfMonitor == XmCO_LOW_COLOR && i == 2)
2260 sprintf(temp[i],"#%04x%04x%04x\n",pCurrentPalette->color[1].bg.red,
2261 pCurrentPalette->color[1].bg.green,
2262 pCurrentPalette->color[1].bg.blue);
2263 else if(TypeOfMonitor == XmCO_LOW_COLOR && i == 3)
2264 sprintf(temp[i],"#%04x%04x%04x\n",pCurrentPalette->color[0].bg.red,
2265 pCurrentPalette->color[0].bg.green,
2266 pCurrentPalette->color[0].bg.blue);
2268 sprintf(temp[i],"#%04x%04x%04x\n",pCurrentPalette->color[i].bg.red,
2269 pCurrentPalette->color[i].bg.green,
2270 pCurrentPalette->color[i].bg.blue);
2273 /* update the resource manager property with the palette resource */
2274 if (TypeOfMonitor == XmCO_BLACK_WHITE)
2276 sprintf(xrdb_string, "*%d*MonochromePalette: %s%s\n",
2277 style.screenNum, pCurrentPalette->name, PALETTE_SUFFIX);
2281 sprintf(xrdb_string, "*%d*ColorPalette: %s%s\n",
2282 style.screenNum, pCurrentPalette->name, PALETTE_SUFFIX);
2284 _DtAddToResource(style.display, xrdb_string);
2286 /* update the defaultName */
2287 XtFree(defaultName);
2288 defaultName = (char *)XtMalloc(strlen(pCurrentPalette->name)+1);
2289 strcpy(defaultName, pCurrentPalette->name);
2292 /* update Xrdb for non Motif1.1 clients */
2293 if (style.xrdb.writeXrdbColors)
2296 OWsyncColorResources(style.display, TypeOfMonitor,
2297 pCurrentPalette->color);
2299 int chipnum = TypeOfMonitor == XmCO_HIGH_COLOR ? 4 : 1;
2300 sprintf(xrdb_string,
2301 "*background: #%04X%04X%04X\n*foreground: #%04X%04X%04X\n",
2302 pCurrentPalette->color[chipnum].bg.red,
2303 pCurrentPalette->color[chipnum].bg.green,
2304 pCurrentPalette->color[chipnum].bg.blue,
2305 pCurrentPalette->color[chipnum].fg.red,
2306 pCurrentPalette->color[chipnum].fg.green,
2307 pCurrentPalette->color[chipnum].fg.blue);
2308 _DtAddToResource(style.display, xrdb_string);
2318 XtPointer client_data,
2322 unsigned long *length,
2327 style.colorSrv = True;
2330 if((int)client_data == GET_TYPE_MONITOR)
2332 sscanf ((char *)value, "%x_%x_%x_%x", (unsigned int *) &(TypeOfMonitor),
2333 (unsigned int *) &(UsePixmaps), (unsigned int *) &(FgColor), (unsigned int *) &dynamic_color);
2334 if(dynamic_color == FALSE)
2335 style.dynamicColor = False;
2337 style.dynamicColor = True;
2340 WaitSelection = FALSE;
2343 else /* no response from Color Server - it must not be there */
2345 style.colorSrv = False;
2346 WaitSelection = FALSE;
2350 /************************************************************************
2353 * restore any state information saved with saveBackdrop.
2354 * This is called from restoreSession with the application
2355 * shell and the special xrm database retrieved for restore.
2356 ************************************************************************/
2362 XrmName xrm_name[5];
2363 XrmRepresentation rep_type;
2365 palette *tmp_palette;
2367 /*"paletteDlg" is the resource name of the dialog shell we are saving for.*/
2368 xrm_name [0] = XrmStringToQuark (PALETTEDLG);
2371 /* get x position */
2372 xrm_name [1] = XrmStringToQuark ("x");
2373 if (XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value)){
2374 XtSetArg (save.posArgs[save.poscnt], XmNx, atoi((char *)value.addr)); save.poscnt++;
2377 /* get y position */
2378 xrm_name [1] = XrmStringToQuark ("y");
2379 if (XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value)){
2380 XtSetArg (save.posArgs[save.poscnt], XmNy, atoi((char *)value.addr)); save.poscnt++;
2383 /* get selected palette */
2384 xrm_name [1] = XrmStringToQuark ("selected_palette");
2385 if (XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value)){
2386 strcpy(defaultName_restore, value.addr);
2389 defaultName_restore[0] = 0;
2391 /* get selected button */
2392 xrm_name [1] = XrmStringToQuark ("selected_button");
2393 if (XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value)){
2394 selected_button = atoi((char *)value.addr);
2397 /* need to have some variables initialized before creating the
2398 Color's dialog ... */
2400 CheckMonitor(shell);
2401 GetDefaultPal(shell);
2403 xrm_name [1] = XrmStringToQuark ("ismapped");
2404 XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value);
2405 /* Are we supposed to be mapped? */
2406 if (strcmp(value.addr, "True") == 0) {
2407 save.restoreFlag = True;
2413 /************************************************************************
2416 * This routine will write out to the passed file descriptor any state
2417 * information this dialog needs. It is called from saveSessionCB with the
2418 * file already opened.
2419 * All information is saved in xrm format. There is no restriction
2420 * on what can be saved. It doesn't have to be defined or be part of any
2421 * widget or Xt definition. Just name and save it here and recover it in
2422 * restoreBackdrop. The suggested minimum is whether you are mapped, and your
2424 ************************************************************************/
2430 char *bufr = style.tmpBigStr; /* size=[1024], make bigger if needed */
2431 XmVendorShellExtObject vendorExt;
2432 XmWidgetExtData extData;
2434 if (style.colorDialog != NULL)
2436 if (XtIsManaged(style.colorDialog))
2437 sprintf(bufr, "*paletteDlg.ismapped: True\n");
2439 sprintf(bufr, "*paletteDlg.ismapped: False\n");
2441 /* Get and write out the geometry info for our Window */
2442 x = XtX(XtParent(style.colorDialog));
2443 y = XtY(XtParent(style.colorDialog));
2445 /* Modify x & y to take into account window mgr frames
2446 * This is pretty bogus, but I don't know a better way to do it.
2448 extData = _XmGetWidgetExtData(style.shell, XmSHELL_EXTENSION);
2449 vendorExt = (XmVendorShellExtObject)extData->widget;
2450 x -= vendorExt->vendor.xOffset;
2451 y -= vendorExt->vendor.yOffset;
2453 sprintf(bufr, "%s*paletteDlg.x: %d\n", bufr, x);
2454 sprintf(bufr, "%s*paletteDlg.y: %d\n", bufr, y);
2455 sprintf(bufr, "%s*paletteDlg.selected_palette: %s\n", bufr,
2456 pCurrentPalette->name);
2457 sprintf(bufr, "%s*paletteDlg.selected_button: %d\n", bufr,
2459 write (fd, bufr, strlen(bufr));
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);