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 != NULL &&
855 tmp_palette->item_position != selected_position ) {
856 tmp_palette = tmp_palette->next;
859 if(tmp_palette->item_position == selected_position)
861 pOldPalette = pCurrentPalette;
862 pCurrentPalette = tmp_palette;
865 string = CMPSTR(pCurrentPalette->desc);
866 XtSetArg (args[n], XmNtitleString, string); n++;
867 XtSetValues (colorDialog.buttonsTB, args, n);
868 XmStringFree(string);
870 if (style.dynamicColor)
874 if (TypeOfMonitor != XmCO_BLACK_WHITE)
876 /* PUT DIALOG saying can't dynamically change */
879 InfoDialog(NEXT_SESSION, style.colorDialog, False);
884 else /* XmCO_BLACK_WHITE */
886 /* set color buttons for new palette - read only cells */
887 /* primary=color[1] secondary=color[0] */
888 if (strcmp(pCurrentPalette->name, WHITE_BLACK) == 0)
890 n=0; /* secondary color white */
891 XtSetArg (args[n], XmNforeground, black); n++;
892 XtSetArg (args[n], XmNbackground, white); n++;
893 XtSetArg (args[n], XmNarmColor, white); n++;
894 XtSetValues(colorButton[0], args, n);
895 pCurrentPalette->color[0].fg.pixel = black;
896 pCurrentPalette->color[0].bg.pixel = white;
897 pCurrentPalette->color[0].sc.pixel = white;
898 pCurrentPalette->color[0].ts.pixel = black;
899 pCurrentPalette->color[0].bs.pixel = black;
901 n=0; /* primary color black */
902 XtSetArg (args[n], XmNforeground, white); n++;
903 XtSetArg (args[n], XmNbackground, black); n++;
904 XtSetArg (args[n], XmNarmColor, black); n++;
905 XtSetValues(colorButton[1], args, n);
906 pCurrentPalette->color[1].fg.pixel = white;
907 pCurrentPalette->color[1].bg.pixel = black;
908 pCurrentPalette->color[1].sc.pixel = black;
909 pCurrentPalette->color[1].ts.pixel = white;
910 pCurrentPalette->color[1].bs.pixel = white;
912 else if (strcmp(pCurrentPalette->name, BLACK_WHITE) == 0)
914 n=0; /* secondary color black */
915 XtSetArg (args[n], XmNforeground, white); n++;
916 XtSetArg (args[n], XmNbackground, black); n++;
917 XtSetArg (args[n], XmNarmColor, black); n++;
918 XtSetValues(colorButton[0], args, n);
919 pCurrentPalette->color[0].fg.pixel = white;
920 pCurrentPalette->color[0].bg.pixel = black;
921 pCurrentPalette->color[0].sc.pixel = black;
922 pCurrentPalette->color[0].ts.pixel = white;
923 pCurrentPalette->color[0].bs.pixel = white;
925 n=0; /* primary color white */
926 XtSetArg (args[n], XmNforeground, black); n++;
927 XtSetArg (args[n], XmNbackground, white); n++;
928 XtSetArg (args[n], XmNarmColor, white); n++;
929 XtSetValues(colorButton[1], args, n);
930 pCurrentPalette->color[1].fg.pixel = black;
931 pCurrentPalette->color[1].bg.pixel = white;
932 pCurrentPalette->color[1].sc.pixel = white;
933 pCurrentPalette->color[1].ts.pixel = black;
934 pCurrentPalette->color[1].bs.pixel = black;
936 else if (strcmp(pCurrentPalette->name, BLACK_ONLY) == 0)
938 n=0; /* primary and secondary color black */
939 XtSetArg (args[n], XmNforeground, white); n++;
940 XtSetArg (args[n], XmNbackground, black); n++;
941 XtSetArg (args[n], XmNarmColor, black); n++;
942 XtSetValues(colorButton[0], args, n);
943 pCurrentPalette->color[0].fg.pixel = white;
944 pCurrentPalette->color[0].bg.pixel = black;
945 pCurrentPalette->color[0].sc.pixel = black;
946 pCurrentPalette->color[0].ts.pixel = white;
947 pCurrentPalette->color[0].bs.pixel = white;
948 XtSetValues(colorButton[1], args, n);
949 pCurrentPalette->color[1].fg.pixel = white;
950 pCurrentPalette->color[1].bg.pixel = black;
951 pCurrentPalette->color[1].sc.pixel = black;
952 pCurrentPalette->color[1].ts.pixel = white;
953 pCurrentPalette->color[1].bs.pixel = white;
955 else /* WHITE_ONLY */
957 n=0; /* primary and secondary color white */
958 XtSetArg (args[n], XmNforeground, black); n++;
959 XtSetArg (args[n], XmNbackground, white); n++;
960 XtSetArg (args[n], XmNarmColor, white); n++;
961 XtSetValues(colorButton[0], args, n);
962 pCurrentPalette->color[0].fg.pixel = black;
963 pCurrentPalette->color[0].bg.pixel = white;
964 pCurrentPalette->color[0].sc.pixel = white;
965 pCurrentPalette->color[0].ts.pixel = black;
966 pCurrentPalette->color[0].bs.pixel = black;
967 XtSetValues(colorButton[1], args, n);
968 pCurrentPalette->color[1].fg.pixel = black;
969 pCurrentPalette->color[1].bg.pixel = white;
970 pCurrentPalette->color[1].sc.pixel = white;
971 pCurrentPalette->color[1].ts.pixel = black;
972 pCurrentPalette->color[1].bs.pixel = black;
984 XtPointer client_data,
985 XtPointer call_data )
991 XmPushButtonCallbackStruct *cb = (XmPushButtonCallbackStruct *)call_data;
993 i = (intptr_t) client_data;
995 /* if click_count == 1 .. first button press, set time out */
996 if(cb->click_count == 1)
998 timeID = XtAppAddTimeOut(XtWidgetToApplicationContext(gParent),
999 (unsigned long) dclick_time, timeoutCB,
1004 /* else .. second button press, remove the time out */
1005 XtRemoveTimeOut(timeID);
1007 if ((edit.DialogShell == NULL) || (!XtIsManaged(edit.DialogShell)))
1011 /* make the new selected button have a border color */
1013 XtSetArg(args[n],XmNbackground,&bg_pixel); n++;
1014 XtGetValues(colorDialog.colorForm,args,n);
1017 XtSetArg (args[n], XmNborderColor,bg_pixel);
1019 XtSetValues(colorButton[selected_button],args,n);
1022 XtSetArg (args[n], XmNborderColor, BlackPixelOfScreen(style.screen));
1024 XtSetValues(colorButton[i],args,n);
1026 selected_button = i;
1028 color_set = (ColorSet *) &pCurrentPalette->color[selected_button];
1029 ColorEditor(style.colorDialog,color_set);
1031 if(!style.dynamicColor) /* need to update pixels */
1032 XtAddCallback(edit.DialogShell, XmNcallback, colorEditorCB, NULL);
1037 * Color editor callback for screens without dynamicColor.
1039 static void colorEditorCB(Widget w, XtPointer client_data, XtPointer call_data)
1041 static Boolean first = True;
1042 DtDialogBoxCallbackStruct *cb = (DtDialogBoxCallbackStruct *) call_data;
1044 /* show "next session" message if first edit */
1045 if(cb->button_position==OK_BUTTON && first){
1046 InfoDialog(NEXT_SESSION, style.colorDialog, False);
1050 XtRemoveCallback(edit.DialogShell, XmNcallback, colorEditorCB, NULL);
1054 ** This is the double click timeout callback. If this routine is called
1055 ** then there was only a single click on a colorbutton
1059 XtPointer client_data,
1067 if (TypeOfMonitor == XmCO_BLACK_WHITE)
1070 i = (intptr_t) client_data;
1072 if ((edit.DialogShell == NULL) || (!XtIsManaged(edit.DialogShell)))
1074 /* make the new selected button have a border color */
1076 XtSetArg(args[n],XmNbackground,&bg_pixel); n++;
1077 XtGetValues(colorDialog.colorForm,args,n);
1080 XtSetArg (args[n], XmNborderColor,bg_pixel);
1082 XtSetValues(colorButton[selected_button],args,n);
1085 XtSetArg (args[n], XmNborderColor, BlackPixelOfScreen(style.screen));
1087 XtSetValues(colorButton[i],args,n);
1088 selected_button = i;
1095 XtPointer client_data,
1096 XtPointer call_data )
1104 if (addDialog == NULL)
1108 XtSetArg(args[n], XmNokLabelString, CMPSTR((String) _DtOkString)); n++;
1109 XtSetArg(args[n], XmNcancelLabelString, CMPSTR((String) _DtCancelString)); n++;
1110 XtSetArg(args[n], XmNhelpLabelString, CMPSTR((String) _DtHelpString)); n++;
1111 string = CMPSTR(((char *)GETMESSAGE(14, 10, "New palette name:")));
1112 XtSetArg(args[n], XmNselectionLabelString, string); n++;
1113 string1 = CMPSTR("");
1114 XtSetArg(args[n], XmNtextString, string1); n++;
1115 XtSetArg(args[n], XmNborderWidth, 3); n++;
1116 XtSetArg(args[n], XmNautoUnmanage, False); n++;
1117 addDialog = XmCreatePromptDialog(style.colorDialog,"AddDialog",
1119 XmStringFree(string);
1120 XmStringFree(string1);
1122 XtAddCallback(addDialog, XmNokCallback, addOkCB,
1124 XtAddCallback(addDialog, XmNcancelCallback, addCancelCB,
1126 XtAddCallback(addDialog, XmNhelpCallback,
1127 (XtCallbackProc)HelpRequestCB, (XtPointer)HELP_ADD_PALETTE_DIALOG);
1130 XtSetArg (args[n], XmNmwmInputMode,
1131 MWM_INPUT_PRIMARY_APPLICATION_MODAL); n++;
1132 XtSetArg (args[n], XmNuseAsyncGeometry, True); n++;
1133 XtSetArg (args[n], XmNtitle, ((char *)GETMESSAGE(14, 11, "Add Palette"))); n++;
1134 XtSetArg (args[n], XmNmwmFunctions, DIALOG_MWM_FUNC); n++;
1135 XtSetValues (XtParent (addDialog), args, n);
1138 string = CMPSTR("");
1139 XtSetArg(args[n], XmNtextString, string); n++;
1140 XtSetValues(addDialog, args, n);
1141 XmStringFree(string);
1143 XtManageChild(addDialog);
1150 XtPointer client_data,
1151 XtPointer call_data )
1153 XtUnmanageChild(addDialog);
1159 XtPointer client_data,
1160 XtPointer call_data )
1165 char *name, *filename, *tmpstr;
1166 palette *tmpPalette, *newPalette;
1171 /* Get the text from the promp dialog */
1172 name = XmTextFieldGetString( XmSelectionBoxGetChild(addDialog, XmDIALOG_TEXT));
1174 /* see if the user typed in a valid palette name */
1175 if(!ValidName(name)) {
1176 ErrDialog(((char *)GETMESSAGE(14, 12, "The palette name cannot contain\nthese characters:\n\n * : ( ) [ ] { } < > ! | \" / \\")),
1182 /* check the number of characters in name in a locale independent way */
1183 for ( ii = 0, count = 0; name[ii] != '\0'; ii += length ) {
1184 length = mblen( &(name[ii]), MB_CUR_MAX );
1190 /* make sure the length of name is ok, short file names can only be 11 chars */
1191 if(count > 10 && !style.longfilename) {
1192 ErrDialog(((char *)GETMESSAGE(14, 13, "The palette name must be\n10 characters or less.\n")),style.colorDialog);
1197 /* Unmanage the promptDialog */
1198 XtUnmanageChild(addDialog);
1200 /* first search through palette descriptions and make sure the name to */
1201 /* add is not already in the list and go to the end of the palette list */
1202 for(tmpPalette = pHeadPalette; tmpPalette->next != NULL;
1203 tmpPalette = tmpPalette->next)
1205 if((strcmp(tmpPalette->desc, name) == 0)) {
1206 SameName(w, tmpPalette, name);
1212 /* Check the last palette */
1213 if((strcmp(tmpPalette->desc, name) == 0)) {
1214 SameName(w, tmpPalette, name);
1219 /* allocate space for a new palette */
1220 newPalette = (palette *)XtMalloc(sizeof(palette) + 1 );
1222 /* set the previous last palatte to this new one, it is now the last one*/
1223 tmpPalette->next = newPalette;
1224 newPalette->next = NULL;
1226 /* malloc space for the new palette desc */
1227 newPalette->desc = (char *)XtMalloc(strlen(name) + 1);
1228 for(i = 0; i < strlen(name); i++)
1229 newPalette->desc[i] = name[i];
1230 newPalette->desc[i] = '\0';
1232 /* malloc space for the new palette name directory */
1233 newPalette->directory = (char *)XtMalloc(strlen(style.home) +
1234 strlen(DT_PAL_DIR) + 1);
1235 strcpy(newPalette->directory, style.home);
1236 strcat(newPalette->directory, DT_PAL_DIR);
1238 /* makeup a new name for the palette */
1239 tmpstr = (char *)XtMalloc(strlen(style.home) + strlen(DT_PAL_DIR) +
1240 strlen("dtXXXXXX") + 1);
1241 strcpy(tmpstr, newPalette->directory);
1242 len = strlen(tmpstr);
1243 strcat(tmpstr, "dtXXXXXX");
1246 newPalette->name = (char *) XtMalloc(15 * sizeof(char));
1247 strcpy(newPalette->name, tmpstr + len);
1250 /* the new palette is the next palette .. increase NumOfPalettes by one */
1251 newPalette->item_position = NumOfPalettes + 1;
1254 /* set all the new palette's color parameters to the current palette */
1255 newPalette->num_of_colors = pCurrentPalette->num_of_colors;
1256 for(i = 0; i < XmCO_MAX_NUM_COLORS; i++)
1258 newPalette->color[i].fg.pixel = pCurrentPalette->color[i].fg.pixel;
1259 newPalette->color[i].fg.red = pCurrentPalette->color[i].fg.red;
1260 newPalette->color[i].fg.green = pCurrentPalette->color[i].fg.green;
1261 newPalette->color[i].fg.blue = pCurrentPalette->color[i].fg.blue;
1262 newPalette->color[i].fg.flags = pCurrentPalette->color[i].fg.flags;
1264 newPalette->color[i].bg.pixel = pCurrentPalette->color[i].bg.pixel;
1265 newPalette->color[i].bg.red = pCurrentPalette->color[i].bg.red;
1266 newPalette->color[i].bg.green = pCurrentPalette->color[i].bg.green;
1267 newPalette->color[i].bg.blue = pCurrentPalette->color[i].bg.blue;
1268 newPalette->color[i].bg.flags = pCurrentPalette->color[i].bg.flags;
1270 newPalette->color[i].ts.pixel = pCurrentPalette->color[i].ts.pixel;
1271 newPalette->color[i].ts.red = pCurrentPalette->color[i].ts.red;
1272 newPalette->color[i].ts.green = pCurrentPalette->color[i].ts.green;
1273 newPalette->color[i].ts.blue = pCurrentPalette->color[i].ts.blue;
1274 newPalette->color[i].ts.flags = pCurrentPalette->color[i].ts.flags;
1276 newPalette->color[i].bs.pixel = pCurrentPalette->color[i].bs.pixel;
1277 newPalette->color[i].bs.red = pCurrentPalette->color[i].bs.red;
1278 newPalette->color[i].bs.green = pCurrentPalette->color[i].bs.green;
1279 newPalette->color[i].bs.blue = pCurrentPalette->color[i].bs.blue;
1280 newPalette->color[i].bs.flags = pCurrentPalette->color[i].bs.flags;
1282 newPalette->color[i].sc.pixel = pCurrentPalette->color[i].sc.pixel;
1283 newPalette->color[i].sc.red = pCurrentPalette->color[i].sc.red;
1284 newPalette->color[i].sc.green = pCurrentPalette->color[i].sc.green;
1285 newPalette->color[i].sc.blue = pCurrentPalette->color[i].sc.blue;
1286 newPalette->color[i].sc.flags = pCurrentPalette->color[i].sc.flags;
1289 /* Write out the palette */
1290 if ((WriteOutPalette(newPalette->name)) == -1)
1294 /* remove palette from list */
1295 tmpPalette->next = NULL;
1296 XtFree ((char *)newPalette);
1301 WriteOutDesc(newPalette);
1304 /* add the name to the scrolled window list and select it */
1305 AddName(newPalette);
1307 /* now check to see if there is a ~filename .. if there is delete it */
1308 /* use the $HOME environment varible then constuct the full file name */
1309 filename = (char *)XtMalloc(strlen(style.home) + strlen(DT_PAL_DIR) +
1310 strlen(newPalette->name) + strlen(PALETTE_SUFFIX) + 2);
1312 /* create the full path name plus file name */
1313 strcpy(filename, style.home);
1314 strcat(filename, DT_PAL_DIR);
1315 strcat(filename, "~");
1316 strcat(filename, newPalette->name);
1317 strcat(filename, PALETTE_SUFFIX);
1324 /* Go write out the palette */
1325 pCurrentPalette = newPalette;
1332 XtPointer client_data,
1333 XtPointer call_data )
1335 palette *tmpPalette = (palette *)client_data;
1338 /* free the directory */
1339 XtFree(tmpPalette->directory);
1341 /* put the new (users) directory there */
1342 tmpPalette->directory = (char *)XtMalloc(strlen(style.home) +
1343 strlen(DT_PAL_DIR) + 1);
1344 strcpy(tmpPalette->directory, style.home);
1345 strcat(tmpPalette->directory, DT_PAL_DIR);
1347 for(i = 0; i < XmCO_MAX_NUM_COLORS; i++)
1349 tmpPalette->color[i].fg.pixel = pCurrentPalette->color[i].fg.pixel;
1350 tmpPalette->color[i].fg.red = pCurrentPalette->color[i].fg.red;
1351 tmpPalette->color[i].fg.green = pCurrentPalette->color[i].fg.green;
1352 tmpPalette->color[i].fg.blue = pCurrentPalette->color[i].fg.blue;
1353 tmpPalette->color[i].fg.flags = pCurrentPalette->color[i].fg.flags;
1355 tmpPalette->color[i].bg.pixel = pCurrentPalette->color[i].bg.pixel;
1356 tmpPalette->color[i].bg.red = pCurrentPalette->color[i].bg.red;
1357 tmpPalette->color[i].bg.green = pCurrentPalette->color[i].bg.green;
1358 tmpPalette->color[i].bg.blue = pCurrentPalette->color[i].bg.blue;
1359 tmpPalette->color[i].bg.flags = pCurrentPalette->color[i].bg.flags;
1361 tmpPalette->color[i].ts.pixel = pCurrentPalette->color[i].ts.pixel;
1362 tmpPalette->color[i].ts.red = pCurrentPalette->color[i].ts.red;
1363 tmpPalette->color[i].ts.green = pCurrentPalette->color[i].ts.green;
1364 tmpPalette->color[i].ts.blue = pCurrentPalette->color[i].ts.blue;
1365 tmpPalette->color[i].ts.flags = pCurrentPalette->color[i].ts.flags;
1367 tmpPalette->color[i].bs.pixel = pCurrentPalette->color[i].bs.pixel;
1368 tmpPalette->color[i].bs.red = pCurrentPalette->color[i].bs.red;
1369 tmpPalette->color[i].bs.green = pCurrentPalette->color[i].bs.green;
1370 tmpPalette->color[i].bs.blue = pCurrentPalette->color[i].bs.blue;
1371 tmpPalette->color[i].bs.flags = pCurrentPalette->color[i].bs.flags;
1373 tmpPalette->color[i].sc.pixel = pCurrentPalette->color[i].sc.pixel;
1374 tmpPalette->color[i].sc.red = pCurrentPalette->color[i].sc.red;
1375 tmpPalette->color[i].sc.green = pCurrentPalette->color[i].sc.green;
1376 tmpPalette->color[i].sc.blue = pCurrentPalette->color[i].sc.blue;
1377 tmpPalette->color[i].sc.flags = pCurrentPalette->color[i].sc.flags;
1380 /* Write out the palette */
1381 if ((WriteOutPalette(tmpPalette->name)) == -1)
1384 WriteOutDesc(tmpPalette);
1386 pCurrentPalette = tmpPalette;
1388 /* select item in list as if user had selected it */
1389 XmListSelectPos (paletteList, tmpPalette->item_position, TRUE);
1390 XmListSetBottomPos(paletteList, tmpPalette->item_position);
1391 selected_position = tmpPalette->item_position;
1398 XtPointer client_data,
1399 XtPointer call_data )
1401 ColorSet *color_set;
1403 if(TypeOfMonitor == XmCO_BLACK_WHITE)
1406 color_set = (ColorSet *) &pCurrentPalette->color[selected_button];
1407 ColorEditor(style.colorDialog,color_set);
1409 if(!style.dynamicColor) /* need to update pixels */
1410 XtAddCallback(edit.DialogShell, XmNcallback, colorEditorCB, NULL);
1416 ** Process callback from the Ok, Cancel and Help pushButtons in the
1422 XtPointer client_data,
1423 XtPointer call_data )
1425 palette *tmp_palette;
1427 DtDialogBoxCallbackStruct *cb = (DtDialogBoxCallbackStruct *) call_data;
1429 switch (cb->button_position)
1432 if ((edit.DialogShell != NULL) && (XtIsManaged(edit.DialogShell)))
1433 XtUnmanageChild(edit.DialogShell);
1435 XtUnmanageChild(style.colorDialog);
1436 UpdateDefaultPalette();
1440 if ((edit.DialogShell != NULL) && (XtIsManaged(edit.DialogShell)))
1441 XtUnmanageChild(edit.DialogShell);
1443 if ((addDialog != NULL) && (XtIsManaged(addDialog)))
1444 XtCallCallbacks(addDialog, XmNcancelCallback, (XtPointer)NULL);
1446 if ((deleteDialog != NULL) && (XtIsManaged(deleteDialog)))
1447 XtCallCallbacks(deleteDialog, XmNcancelCallback, (XtPointer)NULL);
1449 if ((colorUseDialog != NULL) && (XtIsManaged(colorUseDialog)))
1450 XtCallCallbacks(colorUseDialog, XmNcallback, (XtPointer)NULL);
1452 XtUnmanageChild(style.colorDialog);
1454 tmp_palette = pHeadPalette;
1455 for(tmp_palette = pHeadPalette; tmp_palette != NULL; tmp_palette = tmp_palette->next)
1456 if(!(strcmp(tmp_palette->name, defaultName)))
1462 if(match == FALSE) /* the default palette is no longer valid */
1463 UpdateDefaultPalette();
1465 RestoreOrgPalette();
1470 XtCallCallbacks(style.colorDialog, XmNhelpCallback, (XtPointer)NULL);
1481 palette *newPalette )
1486 ** Add the palette name to the list
1488 string = CMPSTR(newPalette->desc);
1489 XmListAddItem(paletteList, string, newPalette->item_position);
1490 XmListSelectPos(paletteList, newPalette->item_position, TRUE);
1491 XmListSetBottomPos(paletteList, newPalette->item_position);
1492 selected_position = newPalette->item_position;
1493 XSync(style.display, 0);
1494 XmStringFree(string);
1500 XtPointer client_data,
1501 XtPointer call_data )
1506 palette *tmp_palette;
1509 char *str_type_return;
1510 XrmValue value_return;
1512 tmp_palette = pHeadPalette;
1514 while( tmp_palette != NULL
1515 && tmp_palette->item_position != selected_position ) {
1516 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) (intptr_t) 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 != NULL
1998 && selected_palette->item_position != selected_position ) {
1999 selected_palette = selected_palette->next;
2002 XmListDeletePos (list, selected_palette->item_position);
2004 /* delete item from palette list structure */
2006 /* If the palette is at the head .. remove the head and the next
2007 palette becomes the new selected palette */
2008 if (selected_palette->item_position == 1)
2010 pHeadPalette = selected_palette->next;
2011 tmp_palette = pHeadPalette;
2012 tmp_palette->item_position--;
2013 /* new current palette */
2014 pCurrentPalette = tmp_palette;
2016 else /* find the palette just above the palette to be deleted .. it
2017 will become the new selected palette */
2019 tmp_palette = pHeadPalette;
2020 for (i=1; i < selected_palette->item_position-1; i++)
2021 tmp_palette = tmp_palette->next;
2023 tmp_palette->next = selected_palette->next;
2025 /* what is CurrentPalette now? prev or next item?
2026 special case empty list or NULL entry */
2027 if (tmp_palette->next != NULL)
2028 pCurrentPalette = tmp_palette->next;
2030 pCurrentPalette = tmp_palette;
2033 /* decrement item_positions values in remaining palette entries */
2034 tmp2_palette = tmp_palette;
2035 while ((tmp2_palette = tmp2_palette->next) != NULL)
2037 tmp2_palette->item_position--;
2040 /* go copy the pixel numbers to the new palette */
2041 CopyPixel(selected_palette->color, pCurrentPalette->color,
2042 selected_palette->num_of_colors);
2044 /* select item in list as if user had selected it */
2045 XmListSelectPos (list, tmp_palette->item_position, TRUE);
2046 /* Need to check to see if the first palette is being deleted if it is
2047 need to change colors and update title box */
2048 if(selected_position == tmp_palette->item_position) {
2049 pOldPalette = selected_palette;
2052 string = CMPSTR(pCurrentPalette->desc);
2053 XtSetArg (args[n], XmNtitleString, string); n++;
2054 XtSetValues (colorDialog.buttonsTB, args, n);
2055 XmStringFree(string);
2060 XmListSetBottomPos(paletteList, tmp_palette->item_position);
2061 selected_position = tmp_palette->item_position;
2065 /* deallocate the palette structure */
2066 XtFree(selected_palette->name);
2067 XtFree(selected_palette->desc);
2068 XtFree(selected_palette->directory);
2069 XtFree((char *)selected_palette);
2074 ColorSet srcPixels[XmCO_MAX_NUM_COLORS],
2075 ColorSet dstPixels[XmCO_MAX_NUM_COLORS],
2080 for(i=0; i < numOfColors; i++)
2082 dstPixels[i].bg.pixel = srcPixels[i].bg.pixel;
2083 dstPixels[i].fg.pixel = srcPixels[i].fg.pixel;
2084 dstPixels[i].ts.pixel = srcPixels[i].ts.pixel;
2085 dstPixels[i].bs.pixel = srcPixels[i].bs.pixel;
2086 dstPixels[i].sc.pixel = srcPixels[i].sc.pixel;
2091 SaveOrgPalette( void )
2094 palette *tmp_palette, *tmp2_palette;
2096 if(save.restoreFlag && defaultName_restore[0] != 0) {
2097 tmp_palette = pHeadPalette;
2098 while(tmp_palette->next != NULL )
2099 if(strcmp(tmp_palette->name, defaultName))
2101 tmp_palette = tmp_palette->next;
2107 if(!strcmp(tmp_palette->name, defaultName)) {
2108 tmp2_palette = pCurrentPalette;
2109 pCurrentPalette = tmp_palette;
2115 OrgPalette.item_position = pCurrentPalette->item_position;
2116 OrgPalette.num_of_colors = pCurrentPalette->num_of_colors;
2117 for(i = 0; i < XmCO_MAX_NUM_COLORS; i++)
2119 OrgPalette.primary = pCurrentPalette->primary;
2120 OrgPalette.secondary = pCurrentPalette->secondary;
2121 OrgPalette.active = pCurrentPalette->active;
2122 OrgPalette.inactive = pCurrentPalette->inactive;
2124 if(save.restoreFlag && defaultName_restore[0] != 0)
2125 OrgPalette.color[i].bg.pixel = tmp2_palette->color[i].bg.pixel;
2127 OrgPalette.color[i].bg.pixel = pCurrentPalette->color[i].bg.pixel;
2128 OrgPalette.color[i].bg.red = pCurrentPalette->color[i].bg.red;
2129 OrgPalette.color[i].bg.green = pCurrentPalette->color[i].bg.green;
2130 OrgPalette.color[i].bg.blue = pCurrentPalette->color[i].bg.blue;
2132 if(save.restoreFlag && defaultName_restore[0] != 0)
2133 OrgPalette.color[i].fg.pixel = tmp2_palette->color[i].fg.pixel;
2135 OrgPalette.color[i].fg.pixel = pCurrentPalette->color[i].fg.pixel;
2136 OrgPalette.color[i].fg.red = pCurrentPalette->color[i].fg.red;
2137 OrgPalette.color[i].fg.green = pCurrentPalette->color[i].fg.green;
2138 OrgPalette.color[i].fg.blue = pCurrentPalette->color[i].fg.blue;
2140 if(save.restoreFlag && defaultName_restore[0] != 0)
2141 OrgPalette.color[i].ts.pixel = tmp2_palette->color[i].ts.pixel;
2143 OrgPalette.color[i].ts.pixel = pCurrentPalette->color[i].ts.pixel;
2144 OrgPalette.color[i].ts.red = pCurrentPalette->color[i].ts.red;
2145 OrgPalette.color[i].ts.green = pCurrentPalette->color[i].ts.green;
2146 OrgPalette.color[i].ts.blue = pCurrentPalette->color[i].ts.blue;
2148 if(save.restoreFlag && defaultName_restore[0] != 0)
2149 OrgPalette.color[i].bs.pixel = tmp2_palette->color[i].bs.pixel;
2151 OrgPalette.color[i].bs.pixel = pCurrentPalette->color[i].bs.pixel;
2152 OrgPalette.color[i].bs.red = pCurrentPalette->color[i].bs.red;
2153 OrgPalette.color[i].bs.green = pCurrentPalette->color[i].bs.green;
2154 OrgPalette.color[i].bs.blue = pCurrentPalette->color[i].bs.blue;
2156 if(save.restoreFlag && defaultName_restore[0] != 0)
2157 OrgPalette.color[i].sc.pixel = tmp2_palette->color[i].sc.pixel;
2159 OrgPalette.color[i].sc.pixel = pCurrentPalette->color[i].sc.pixel;
2160 OrgPalette.color[i].sc.red = pCurrentPalette->color[i].sc.red;
2161 OrgPalette.color[i].sc.green = pCurrentPalette->color[i].sc.green;
2162 OrgPalette.color[i].sc.blue = pCurrentPalette->color[i].sc.blue;
2165 if(save.restoreFlag && defaultName_restore[0] != 0)
2166 if(tmp_palette != NULL)
2167 pCurrentPalette = tmp2_palette;
2172 RestoreOrgPalette( void )
2175 palette *tmp_palette;
2177 XColor colors[XmCO_MAX_NUM_COLORS * 5];
2179 tmp_palette = pHeadPalette;
2180 while ( tmp_palette != NULL &&
2181 tmp_palette->item_position != OrgPalette.item_position )
2182 tmp_palette = tmp_palette->next;
2184 if ( tmp_palette != NULL &&
2185 tmp_palette->item_position == OrgPalette.item_position)
2187 pCurrentPalette = tmp_palette;
2188 OrgPalette.num_of_colors = pCurrentPalette->num_of_colors;
2189 for(i = 0; i < XmCO_MAX_NUM_COLORS; i++)
2191 pCurrentPalette->primary = OrgPalette.primary;
2192 pCurrentPalette->secondary = OrgPalette.secondary;
2193 pCurrentPalette->inactive = OrgPalette.inactive;
2194 pCurrentPalette->active = OrgPalette.active;
2196 pCurrentPalette->color[i].bg.pixel = OrgPalette.color[i].bg.pixel;
2197 pCurrentPalette->color[i].bg.red = OrgPalette.color[i].bg.red;
2198 pCurrentPalette->color[i].bg.green = OrgPalette.color[i].bg.green;
2199 pCurrentPalette->color[i].bg.blue = OrgPalette.color[i].bg.blue;
2200 if(i < OrgPalette.num_of_colors && TypeOfMonitor != XmCO_BLACK_WHITE)
2201 colors[j++] = pCurrentPalette->color[i].bg;
2203 pCurrentPalette->color[i].sc.pixel = OrgPalette.color[i].sc.pixel;
2204 pCurrentPalette->color[i].sc.red = OrgPalette.color[i].sc.red;
2205 pCurrentPalette->color[i].sc.green = OrgPalette.color[i].sc.green;
2206 pCurrentPalette->color[i].sc.blue = OrgPalette.color[i].sc.blue;
2207 if(i < OrgPalette.num_of_colors && TypeOfMonitor != XmCO_BLACK_WHITE)
2208 colors[j++] = pCurrentPalette->color[i].sc;
2210 pCurrentPalette->color[i].fg.pixel = OrgPalette.color[i].fg.pixel;
2211 pCurrentPalette->color[i].fg.red = OrgPalette.color[i].fg.red;
2212 pCurrentPalette->color[i].fg.green = OrgPalette.color[i].fg.green;
2213 pCurrentPalette->color[i].fg.blue = OrgPalette.color[i].fg.blue;
2214 if(i < OrgPalette.num_of_colors && TypeOfMonitor != XmCO_BLACK_WHITE)
2215 if(FgColor == DYNAMIC)
2216 colors[j++] = pCurrentPalette->color[i].fg;
2218 pCurrentPalette->color[i].ts.pixel = OrgPalette.color[i].ts.pixel;
2219 pCurrentPalette->color[i].ts.red = OrgPalette.color[i].ts.red;
2220 pCurrentPalette->color[i].ts.green = OrgPalette.color[i].ts.green;
2221 pCurrentPalette->color[i].ts.blue = OrgPalette.color[i].ts.blue;
2222 if(i < OrgPalette.num_of_colors && TypeOfMonitor != XmCO_BLACK_WHITE)
2223 if(UsePixmaps == FALSE)
2224 colors[j++] = pCurrentPalette->color[i].ts;
2226 pCurrentPalette->color[i].bs.pixel = OrgPalette.color[i].bs.pixel;
2227 pCurrentPalette->color[i].bs.red = OrgPalette.color[i].bs.red;
2228 pCurrentPalette->color[i].bs.green = OrgPalette.color[i].bs.green;
2229 pCurrentPalette->color[i].bs.blue = OrgPalette.color[i].bs.blue;
2230 if(i < OrgPalette.num_of_colors && TypeOfMonitor != XmCO_BLACK_WHITE)
2231 if(UsePixmaps == FALSE)
2232 colors[j++] = pCurrentPalette->color[i].bs;
2236 if (style.dynamicColor)
2237 XStoreColors (style.display, style.colormap, colors, j);
2239 XmListSelectPos (paletteList, OrgPalette.item_position, TRUE);
2240 XmListSetBottomPos(paletteList, OrgPalette.item_position);
2246 UpdateDefaultPalette( void )
2249 char temp[XmCO_MAX_NUM_COLORS][60];
2250 char xrdb_string[100];
2251 XColor saved_color[2] = { { 0, 0, 0 }, { 0, 0, 0 } };
2253 for(i = 0; i < XmCO_MAX_NUM_COLORS; i++)
2255 /* put the colors of the palette in the form #RRRRGGGGBBBB */
2256 if(TypeOfMonitor == XmCO_LOW_COLOR && (i == 0 || i == 1))
2257 sprintf(temp[i],"#%04x%04x%04x\n", saved_color[i].red,
2258 saved_color[i].green,
2259 saved_color[i].blue);
2260 else if(TypeOfMonitor == XmCO_LOW_COLOR && i == 2)
2261 sprintf(temp[i],"#%04x%04x%04x\n",pCurrentPalette->color[1].bg.red,
2262 pCurrentPalette->color[1].bg.green,
2263 pCurrentPalette->color[1].bg.blue);
2264 else if(TypeOfMonitor == XmCO_LOW_COLOR && i == 3)
2265 sprintf(temp[i],"#%04x%04x%04x\n",pCurrentPalette->color[0].bg.red,
2266 pCurrentPalette->color[0].bg.green,
2267 pCurrentPalette->color[0].bg.blue);
2269 sprintf(temp[i],"#%04x%04x%04x\n",pCurrentPalette->color[i].bg.red,
2270 pCurrentPalette->color[i].bg.green,
2271 pCurrentPalette->color[i].bg.blue);
2274 /* update the resource manager property with the palette resource */
2275 if (TypeOfMonitor == XmCO_BLACK_WHITE)
2277 sprintf(xrdb_string, "*%d*MonochromePalette: %s%s\n",
2278 style.screenNum, pCurrentPalette->name, PALETTE_SUFFIX);
2282 sprintf(xrdb_string, "*%d*ColorPalette: %s%s\n",
2283 style.screenNum, pCurrentPalette->name, PALETTE_SUFFIX);
2285 _DtAddToResource(style.display, xrdb_string);
2287 /* update the defaultName */
2288 XtFree(defaultName);
2289 defaultName = (char *)XtMalloc(strlen(pCurrentPalette->name)+1);
2290 strcpy(defaultName, pCurrentPalette->name);
2293 /* update Xrdb for non Motif1.1 clients */
2294 if (style.xrdb.writeXrdbColors)
2297 OWsyncColorResources(style.display, TypeOfMonitor,
2298 pCurrentPalette->color);
2300 int chipnum = TypeOfMonitor == XmCO_HIGH_COLOR ? 4 : 1;
2301 sprintf(xrdb_string,
2302 "*background: #%04X%04X%04X\n*foreground: #%04X%04X%04X\n",
2303 pCurrentPalette->color[chipnum].bg.red,
2304 pCurrentPalette->color[chipnum].bg.green,
2305 pCurrentPalette->color[chipnum].bg.blue,
2306 pCurrentPalette->color[chipnum].fg.red,
2307 pCurrentPalette->color[chipnum].fg.green,
2308 pCurrentPalette->color[chipnum].fg.blue);
2309 _DtAddToResource(style.display, xrdb_string);
2319 XtPointer client_data,
2323 unsigned long *length,
2328 style.colorSrv = True;
2331 if((intptr_t) client_data == GET_TYPE_MONITOR)
2333 sscanf ((char *)value, "%x_%x_%x_%x", (unsigned int *) &(TypeOfMonitor),
2334 (unsigned int *) &(UsePixmaps), (unsigned int *) &(FgColor), (unsigned int *) &dynamic_color);
2335 if(dynamic_color == FALSE)
2336 style.dynamicColor = False;
2338 style.dynamicColor = True;
2341 WaitSelection = FALSE;
2344 else /* no response from Color Server - it must not be there */
2346 style.colorSrv = False;
2347 WaitSelection = FALSE;
2351 /************************************************************************
2354 * restore any state information saved with saveBackdrop.
2355 * This is called from restoreSession with the application
2356 * shell and the special xrm database retrieved for restore.
2357 ************************************************************************/
2363 XrmName xrm_name[5];
2364 XrmRepresentation rep_type;
2366 palette *tmp_palette;
2368 /*"paletteDlg" is the resource name of the dialog shell we are saving for.*/
2369 xrm_name [0] = XrmStringToQuark (PALETTEDLG);
2372 /* get x position */
2373 xrm_name [1] = XrmStringToQuark ("x");
2374 if (XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value)){
2375 XtSetArg (save.posArgs[save.poscnt], XmNx, atoi((char *)value.addr)); save.poscnt++;
2378 /* get y position */
2379 xrm_name [1] = XrmStringToQuark ("y");
2380 if (XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value)){
2381 XtSetArg (save.posArgs[save.poscnt], XmNy, atoi((char *)value.addr)); save.poscnt++;
2384 /* get selected palette */
2385 xrm_name [1] = XrmStringToQuark ("selected_palette");
2386 if (XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value)){
2387 strcpy(defaultName_restore, value.addr);
2390 defaultName_restore[0] = 0;
2392 /* get selected button */
2393 xrm_name [1] = XrmStringToQuark ("selected_button");
2394 if (XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value)){
2395 selected_button = atoi((char *)value.addr);
2398 /* need to have some variables initialized before creating the
2399 Color's dialog ... */
2401 CheckMonitor(shell);
2402 GetDefaultPal(shell);
2404 xrm_name [1] = XrmStringToQuark ("ismapped");
2405 XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value);
2406 /* Are we supposed to be mapped? */
2407 if (strcmp(value.addr, "True") == 0) {
2408 save.restoreFlag = True;
2414 /************************************************************************
2417 * This routine will write out to the passed file descriptor any state
2418 * information this dialog needs. It is called from saveSessionCB with the
2419 * file already opened.
2420 * All information is saved in xrm format. There is no restriction
2421 * on what can be saved. It doesn't have to be defined or be part of any
2422 * widget or Xt definition. Just name and save it here and recover it in
2423 * restoreBackdrop. The suggested minimum is whether you are mapped, and your
2425 ************************************************************************/
2431 char *bufr = style.tmpBigStr; /* size=[1024], make bigger if needed */
2432 XmVendorShellExtObject vendorExt;
2433 XmWidgetExtData extData;
2435 if (style.colorDialog != NULL)
2437 if (XtIsManaged(style.colorDialog))
2438 sprintf(bufr, "*paletteDlg.ismapped: True\n");
2440 sprintf(bufr, "*paletteDlg.ismapped: False\n");
2442 /* Get and write out the geometry info for our Window */
2443 x = XtX(XtParent(style.colorDialog));
2444 y = XtY(XtParent(style.colorDialog));
2446 /* Modify x & y to take into account window mgr frames
2447 * This is pretty bogus, but I don't know a better way to do it.
2449 extData = _XmGetWidgetExtData(style.shell, XmSHELL_EXTENSION);
2450 vendorExt = (XmVendorShellExtObject)extData->widget;
2451 x -= vendorExt->vendor.xOffset;
2452 y -= vendorExt->vendor.yOffset;
2454 sprintf(bufr, "%s*paletteDlg.x: %d\n", bufr, x);
2455 sprintf(bufr, "%s*paletteDlg.y: %d\n", bufr, y);
2456 sprintf(bufr, "%s*paletteDlg.selected_palette: %s\n", bufr,
2457 pCurrentPalette->name);
2458 sprintf(bufr, "%s*paletteDlg.selected_button: %d\n", bufr,
2460 if(-1 == write (fd, bufr, strlen(bufr))) {
2461 perror(strerror(errno));
2466 /**************************************************************************
2468 * SameName - procedure used by the Add palette .. if the palette desc the
2469 * user selects is the same name as a palette already in the
2470 * linked list this procedure gets called. It set up a
2471 * Warning dialog asking the user if they really want to add
2472 * a palette with the same name as an existing palette.
2474 **************************************************************************/
2478 palette *tmpPalette,
2485 if (colorDialog.dlg == NULL) {
2486 tmpStr = (char *)XtMalloc(strlen(STR1) + strlen(name) + 1);
2487 sprintf(tmpStr, STR1, name);
2488 XtSetArg(args[n], XmNmessageString, CMPSTR(tmpStr)); n++;
2489 XtSetArg(args[n], XmNokLabelString, CMPSTR((String) _DtOkString)); n++;
2490 XtSetArg(args[n], XmNcancelLabelString, CMPSTR((String) _DtCancelString)); n++;
2491 XtSetArg(args[n], XmNhelpLabelString, CMPSTR((String) _DtHelpString)); n++;
2492 XtSetArg(args[n], XmNmwmFunctions, DIALOG_MWM_FUNC ); n++;
2493 XtSetArg(args[n], XmNdialogTitle, CMPSTR(((char *)GETMESSAGE(14, 21, "Warning")))); n++;
2494 colorDialog.dlg = XmCreateWarningDialog(style.colorDialog, "QNotice", args, n);
2495 XtAddCallback(colorDialog.dlg, XmNokCallback, setDlgOkCB, (XtPointer)tmpPalette);
2496 XtAddCallback(colorDialog.dlg, XmNhelpCallback,
2497 (XtCallbackProc)HelpRequestCB, (XtPointer)HELP_ADD_PALETTE_WARNING_DIALOG);
2500 XtSetArg (args[n], XmNmwmInputMode,
2501 MWM_INPUT_PRIMARY_APPLICATION_MODAL); n++;
2502 XtSetValues (XtParent(colorDialog.dlg), args, n);
2505 XtManageChild(colorDialog.dlg);
2508 /****************************************************************************
2510 * ValidName - procedure which checks to make sure the name being passed
2511 * in is a valid filename. Weeds out many of the non
2512 * alphabit characters.
2514 ***************************************************************************/
2520 Boolean valid = True;
2525 if (!name || strlen(name) == 0)
2531 chlen = mblen (&name[0], MB_CUR_MAX);
2532 for (i = 0; (i < strlen(name)) && chlen && valid; i += chlen)
2534 chlen = mblen (&name[i], MB_CUR_MAX);
2536 ((name[i] == '*') ||
2538 (name[i] == '\\') ||
2556 for (i = 0; (i < strlen(name)) && valid; i++)
2558 if (strchr ("|!(){}[]<>*:\"\\", (int) name[i]))
2568 InitializeAtoms( void )
2572 sprintf(cust_str,"%s%d", XmSCUSTOMIZE_DATA, style.screenNum);
2573 XA_CUSTOMIZE = XInternAtom(style.display, cust_str, FALSE);
2574 XA_TYPE_MONITOR = XInternAtom(style.display, TYPE_OF_MONITOR, FALSE);
2575 XA_WM_DELETE_WINDOW = XInternAtom(style.display, "WM_DELETE_WINDOW", False);
2582 char *str_type_return;
2583 XrmValue value_return;
2588 char instanceName[30], instanceClass[30];
2590 /* get the current default palette from the Reource Manager Property */
2592 db = XtDatabase(style.display);
2594 if (TypeOfMonitor == XmCO_BLACK_WHITE)
2596 sprintf(instanceName,"dtsession.%d.monochromePalette", style.screenNum);
2597 sprintf(instanceClass,"Dtsession.%d.MonochromePalette", style.screenNum);
2601 sprintf(instanceName,"dtsession.%d.colorPalette", style.screenNum);
2602 sprintf(instanceClass,"Dtsession.%d.ColorPalette", style.screenNum);
2605 if (status = XrmGetResource (db, instanceName, instanceClass,
2606 &str_type_return, &value_return))
2608 /* copy string to defaultName */
2609 defaultName = (char *) XtMalloc( value_return.size );
2610 strcpy (defaultName, value_return.addr);
2611 p = strstr (defaultName, PALETTE_SUFFIX);
2616 /* set defaultName to default palette */
2617 defaultName = (char *) XtMalloc( strlen(DEFAULT_PALETTE));
2618 strcpy (defaultName, DEFAULT_PALETTE);
2626 XmString button_string[NUM_LABELS];
2634 /* Get the default value of multiclick */
2635 dclick_time = XtGetMultiClickTime(style.display);
2638 if(!XtIsRealized(parent))
2639 XtRealizeWidget(parent);
2641 /* Set up DialogBox button labels. */
2642 button_string[0] = CMPSTR((String) _DtOkString);
2643 button_string[1] = CMPSTR((String) _DtCancelString);
2644 button_string[2] = CMPSTR((String) _DtHelpString);
2647 * Note that save.poscnt has been initialized elsewhere.
2648 * save.posArgs may contain information from restoreColor().*/
2650 XtSetArg (save.posArgs[save.poscnt], XmNchildType, XmWORK_AREA); save.poscnt++;
2651 XtSetArg (save.posArgs[save.poscnt], XmNbuttonCount, NUM_LABELS); save.poscnt++;
2652 XtSetArg (save.posArgs[save.poscnt], XmNbuttonLabelStrings, button_string); save.poscnt++;
2653 XtSetArg (save.posArgs[save.poscnt], XmNdefaultPosition, False); save.poscnt++;
2654 style.colorDialog = __DtCreateDialogBoxDialog(parent,PALETTEDLG, save.posArgs, save.poscnt);
2655 XtAddCallback(style.colorDialog, XmNcallback, dialogBoxCB, NULL);
2656 XtAddCallback(style.colorDialog, XmNmapCallback, _DtmapCB, parent);
2657 XtAddCallback(style.colorDialog, XmNhelpCallback,
2658 (XtCallbackProc)HelpRequestCB, (XtPointer)HELP_COLOR_DIALOG);
2660 XmStringFree(button_string[0]);
2661 XmStringFree(button_string[1]);
2662 XmStringFree(button_string[2]);
2664 w = _DtDialogBoxGetButton(style.colorDialog,2);
2666 XtSetArg(args[n], XmNautoUnmanage, False); n++;
2667 XtSetArg(args[n], XmNcancelButton, w); n++;
2668 XtSetValues (style.colorDialog, args, n);
2674 AddToDialogBox( void )
2683 XtSetArg (args[n], XmNtitle, ((char *)GETMESSAGE(14, 30, "Style Manager - Color"))); n++;
2684 XtSetArg (args[n], XmNuseAsyncGeometry, True); n++;
2685 XtSetArg (args[n], XmNmwmFunctions, DIALOG_MWM_FUNC); n++;
2686 XtSetValues (XtParent(style.colorDialog), args, n);
2688 /* Add save session property to the main window */
2689 XmAddWMProtocolCallback(XtParent(style.colorDialog),
2690 XA_WM_DELETE_WINDOW, activateCBexitColor, NULL);
2693 ** Create a main form for color dialog
2696 XtSetArg(args[n], XmNhorizontalSpacing, style.horizontalSpacing); n++;
2697 XtSetArg(args[n], XmNverticalSpacing, style.verticalSpacing); n++;
2698 colorDialog.colorForm = XmCreateForm(style.colorDialog, "colorForm", args, n);
2699 XtManageChild(colorDialog.colorForm);
2705 CreateTopColor1( void )
2714 ** titlebox as child of the main form
2717 XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
2718 XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
2719 XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
2720 XtSetArg (args[n], XmNmarginWidth, 0); n++;
2721 XtSetArg (args[n], XmNmarginHeight, 0); n++;
2722 string = CMPSTR(((char *)GETMESSAGE(14, 5, "Palettes")));
2723 XtSetArg (args[n], XmNtitleString, string); n++;
2724 colorDialog.paletteTB = _DtCreateTitleBox(colorDialog.colorForm, "paletteTB", args, n);
2725 XtManageChild(colorDialog.paletteTB);
2726 XmStringFree(string);
2729 ** Create a form inside palette titlebox
2732 XtSetArg(args[n], XmNhorizontalSpacing, style.horizontalSpacing); n++;
2733 XtSetArg(args[n], XmNverticalSpacing, style.verticalSpacing); n++;
2734 colorDialog.palettesForm = XmCreateForm(colorDialog.paletteTB, "palettesForm", args, n);
2735 XtManageChild(colorDialog.palettesForm);
2741 CreateTopColor2( void )
2749 ** Create a scrolled list widget. This widget will contain the list of
2750 ** palettes currently loaded (by ReadPalettes) in the customizer.
2753 XtSetArg (args[n], XmNselectionPolicy, XmBROWSE_SELECT); n++;
2754 XtSetArg (args[n], XmNautomaticSelection, True); n++;
2755 XtSetArg (args[n], XmNvisibleItemCount, 6); n++;
2756 paletteList = XmCreateScrolledList(colorDialog.palettesForm,"paletteList",args,n);
2757 XtAddCallback(paletteList, XmNbrowseSelectionCallback,
2758 selectPaletteCB, NULL);
2761 XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
2762 XtSetArg (args[n], XmNtopOffset, style.horizontalSpacing); n++;
2763 XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
2764 XtSetArg (args[n], XmNleftOffset, style.horizontalSpacing); n++;
2765 XtSetArg (args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
2766 XtSetArg (args[n], XmNrightPosition, 60); n++;
2767 XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
2768 XtSetValues (XtParent(paletteList), args, n);
2774 CreateBottomColor( void )
2779 Widget addDeleteForm;
2782 colorDialog.dlg = NULL;
2784 if(style.count > 10)
2787 if(TypeOfMonitor != XmCO_BLACK_WHITE)
2789 /* Create form for Add and Delete buttons */
2791 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
2792 XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
2793 XtSetArg(args[n], XmNleftWidget, paletteList); n++;
2794 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
2795 XtSetArg(args[n], XmNrightOffset, 0); n++;
2796 XtSetArg(args[n], XmNhorizontalSpacing, style.horizontalSpacing); n++;
2797 XtSetArg(args[n], XmNverticalSpacing, style.verticalSpacing); n++;
2798 XtSetArg(args[n], XmNallowOverlap, False); n++;
2799 XtSetArg(args[n], XmNchildType, XmWORK_AREA); n++;
2801 XmCreateForm(colorDialog.palettesForm, "addDeleteForm", args, n);
2802 XtManageChild(addDeleteForm);
2804 /* Create Add button */
2806 XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
2807 XtSetArg (args[n], XmNtopOffset, ADD_PALETTE_TOP_OFFSET); n++;
2808 XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
2809 XtSetArg (args[n], XmNleftOffset, style.horizontalSpacing); n++;
2810 XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
2811 string = CMPSTR(((char *)GETMESSAGE(14, 6, "Add...")));
2812 XtSetArg (args[n], XmNlabelString, string); n++;
2813 colorDialog.addPaletteButton =
2814 XmCreatePushButtonGadget(addDeleteForm, "addPalette", args, n);
2815 XmStringFree(string);
2816 XtManageChild(colorDialog.addPaletteButton);
2817 XtAddCallback(colorDialog.addPaletteButton, XmNactivateCallback, addPaletteCB,
2820 /* Create Delete button */
2822 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
2823 XtSetArg (args[n], XmNtopWidget, colorDialog.addPaletteButton); n++;
2824 XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
2825 XtSetArg (args[n], XmNleftOffset, style.horizontalSpacing); n++;
2826 XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
2827 string = CMPSTR(((char *)GETMESSAGE(14, 7, "Delete...")));
2828 XtSetArg (args[n], XmNlabelString, string); n++;
2829 colorDialog.deletePaletteButton =
2830 XmCreatePushButtonGadget(addDeleteForm,"deletePalette",args,n);
2831 XmStringFree(string);
2832 XtManageChild(colorDialog.deletePaletteButton);
2833 XtAddCallback(colorDialog.deletePaletteButton, XmNactivateCallback, deletePaletteCB,
2838 ** Create a title box for palette color buttons
2841 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
2842 XtSetArg (args[n], XmNtopWidget, colorDialog.paletteTB); n++;
2843 XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
2844 XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
2845 XtSetArg (args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
2846 XtSetArg (args[n], XmNmarginWidth, 0); n++;
2847 XtSetArg (args[n], XmNmarginHeight, 0); n++;
2848 string = CMPSTR(pCurrentPalette->desc);
2849 XtSetArg (args[n], XmNtitleString, string); n++;
2850 colorDialog.buttonsTB = _DtCreateTitleBox(colorDialog.colorForm, "ButtonsTB", args, n);
2851 XtManageChild(colorDialog.buttonsTB);
2852 XmStringFree(string);
2854 /* Create a form inside palette buttons titlebox */
2856 XtSetArg(args[n], XmNhorizontalSpacing, style.horizontalSpacing); n++;
2857 XtSetArg(args[n], XmNverticalSpacing, style.verticalSpacing); n++;
2858 style.buttonsForm = XmCreateForm(colorDialog.buttonsTB, "buttonsForm", args, n);
2859 XtManageChild(style.buttonsForm);
2861 /* Create Modify... button */
2862 if(TypeOfMonitor != XmCO_BLACK_WHITE)
2865 XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
2866 XtSetArg (args[n], XmNtopOffset, style.horizontalSpacing+BORDER_WIDTH); n++;
2867 XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
2868 XtSetArg (args[n], XmNleftPosition, ADD_PALETTE_LEFT_POSITION); n++;
2869 XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
2870 string = CMPSTR(((char *)GETMESSAGE(14, 8, "Modify...")));
2871 XtSetArg (args[n], XmNlabelString, string); n++;
2873 XmCreatePushButtonGadget(style.buttonsForm, "modifyColorButton", args, n);
2874 XmStringFree(string);
2875 XtManageChild(modifyColorButton);
2876 XtAddCallback(modifyColorButton, XmNactivateCallback, modifyColorCB,
2880 ** Create a pushbutton for configuring DT colors
2883 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
2884 XtSetArg (args[n], XmNtopWidget, colorDialog.buttonsTB); n++;
2885 XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
2886 XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
2887 XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
2888 XtSetArg (args[n], XmNnavigationType, XmTAB_GROUP); n++;
2889 string = CMPSTR(((char *)GETMESSAGE(14, 40, "Number Of Colors...")));
2890 XtSetArg (args[n], XmNlabelString, string); n++;
2891 resourcesPB = XmCreatePushButtonGadget(colorDialog.colorForm, "resourcesPB", args, n);
2892 XtManageChild(resourcesPB);
2893 XtAddCallback(resourcesPB, XmNactivateCallback, resourcesCB,
2894 (XtPointer) style.colorDialog);
2895 XmStringFree(string);