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 /*+++++++++++++++++++++++++++++++++++++++*/
44 #include "/sys5/usr/include/limits.h"
45 #else /* common default */
52 #include <X11/Intrinsic.h>
54 #include <Xm/MwmUtil.h>
62 #include <Xm/MessageB.h>
63 #include <Xm/Protocols.h>
65 #include <Xm/PushBG.h>
66 #include <Xm/ToggleBG.h>
67 #include <Xm/RowColumn.h>
68 #include <Xm/SelectioB.h>
70 #include <Xm/VendorSEP.h>
72 #include <Dt/DialogBox.h>
74 #include <Dt/TitleBox.h>
76 #include <Dt/HourGlass.h>
80 #include "SaveRestore.h"
81 #include "ColorMain.h"
82 #include "ColorFile.h"
83 #include "ColorEdit.h"
89 /*+++++++++++++++++++++++++++++++++++++++*/
90 /* include extern functions */
91 /*+++++++++++++++++++++++++++++++++++++++*/
94 /*+++++++++++++++++++++++++++++++++++++++*/
96 /*+++++++++++++++++++++++++++++++++++++++*/
97 #define DEFAULT_PALETTE "Default"
98 #define TYPE_OF_MONITOR "Type Of Monitor" /* also in dtsession/SrvPalette.c */
100 #define BORDER_WIDTH 3
101 #define COLOR_BUTTON_WIDTH 35
102 #define COLOR_BUTTON_HEIGHT 35
103 #define ADD_PALETTE_TOP_OFFSET 20
104 #define ADD_PALETTE_LEFT_POSITION 65
105 #define PALETTE_RC_RIGHT_POSITION 60
107 #define DEFAULT_COLOR (XmCO_HIGH_COLOR + 1)
109 #define B_W_STR "B_W"
110 #define LOW_COLOR_STR "LOW_COLOR"
111 #define MEDIUM_COLOR_STR "MEDIUM_COLOR"
112 #define HIGH_COLOR_STR "HIGH_COLOR"
113 #define DEFAULT_COLOR_STR "DEFAULT"
115 #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?"))
116 #define STR2 ((char *)GETMESSAGE(14, 23, "Delete palette '%s'?\n"))
117 #define NEXT_SESSION ((char *)GETMESSAGE(14, 28, "The selected palette will take effect\nat your next session."))
118 #define CANT_DELETE ((char *)GETMESSAGE(14, 18, "Can't delete the last palette.\n"))
119 #define COLORUSE_WHEN ((char *)GETMESSAGE(14, 27, "The new Color Use value will take effect\nat your next session."))
121 /*+++++++++++++++++++++++++++++++++++++++*/
123 /*+++++++++++++++++++++++++++++++++++++++*/
129 Widget addPaletteButton;
130 Widget deletePaletteButton;
134 Widget mediumColorTG;
140 char *currentColorUseStr;
144 /*+++++++++++++++++++++++++++++++++++++++*/
145 /* Internal Functions */
146 /*+++++++++++++++++++++++++++++++++++++++*/
148 static int CreateMainWindow( Widget parent) ;
149 static void selectPaletteCB(
151 XtPointer client_data,
152 XtPointer call_data) ;
153 static void selectColorCB(
155 XtPointer client_data,
156 XtPointer call_data) ;
157 static void timeoutCB(
158 XtPointer client_data,
160 static void addPaletteCB(
162 XtPointer client_data,
163 XtPointer call_data) ;
164 static void addCancelCB(
166 XtPointer client_data,
167 XtPointer call_data) ;
170 XtPointer client_data,
171 XtPointer call_data) ;
172 static void setDlgOkCB(
174 XtPointer client_data,
175 XtPointer call_data) ;
176 static void modifyColorCB(
178 XtPointer client_data,
179 XtPointer call_data) ;
180 static void dialogBoxCB(
182 XtPointer client_data,
183 XtPointer call_data) ;
185 palette *newPalette) ;
186 static void deletePaletteCB(
188 XtPointer client_data,
189 XtPointer call_data) ;
190 static void deleteOkCB(
192 XtPointer client_data,
193 XtPointer call_data) ;
194 static void deleteCancelCB(
196 XtPointer client_data,
197 XtPointer call_data) ;
198 static void resourcesCB(
200 XtPointer client_data,
201 XtPointer call_data) ;
202 static void colorUseCB(
204 XtPointer client_data,
205 XtPointer call_data) ;
206 static void colorUseExitCB(
208 XtPointer client_data,
209 XtPointer call_data) ;
210 static void activateCBexitColor(
212 XtPointer client_data,
213 XtPointer call_data) ;
214 static void _DtmapCB(
216 XtPointer client_data,
217 XtPointer call_data) ;
218 static void _DtmapCB_colorUse(
220 XtPointer client_data,
221 XtPointer call_data) ;
222 static void colorEditorCB(
224 XtPointer client_data,
225 XtPointer call_data) ;
227 static void allocNewColors(void);
228 static Boolean ValidName( char *name) ;
233 /*+++++++++++++++++++++++++++++++++++++++*/
234 /* Global Variables */
235 /*+++++++++++++++++++++++++++++++++++++++*/
238 Atom XA_TYPE_MONITOR;
240 /* Palettes exist in a linked list. */
241 palette *pHeadPalette;
242 palette *pCurrentPalette;
243 palette *pOldPalette;
245 Widget modifyColorButton;
255 /*+++++++++++++++++++++++++++++++++++++++*/
256 /* Internal Variables */
257 /*+++++++++++++++++++++++++++++++++++++++*/
259 /* palette names without the .dp */
260 static char *WHITE_BLACK = "WhiteBlack";
261 static char *BLACK_WHITE = "BlackWhite";
262 static char *WHITE_ONLY = "White";
263 static char *BLACK_ONLY = "Black";
265 static char *PALETTEDLG = "paletteDlg";
266 static saveRestore save = {FALSE, 0, };
268 static Widget colorButton[XmCO_MAX_NUM_COLORS];
269 static Widget addDialog;
270 static Widget deleteDialog;
271 static Widget colorUseDialog;
272 static palette OrgPalette;
273 static XtIntervalId timeID;
274 static int dclick_time;
275 static int selected_button;
276 static int selected_position;
277 static Atom XA_WM_DELETE_WINDOW;
278 static char defaultName_restore[50];
279 static palette *loop_palette, *loop_palette2;
280 static int loopcount = 0;
281 static colorWidgets colorDialog;
282 static Widget gParent;
286 * copy of the system palette description file for the
287 * current locale in xrm form
289 XrmDatabase sys_pl_DB = NULL;
292 * copy of the admin palette description file for the
293 * current locale in xrm form
295 XrmDatabase adm_pl_DB = NULL;
298 * final combination of the admin & system dta bases
300 XrmDatabase pl_DB = NULL;
303 * copy of the palette description file from the user's home
304 * directory. This database is locale independent and will always
307 XrmDatabase hm_pl_DB = NULL;
317 /* load the palette description data base for the given locale*/
318 /* from that locale's description file from the system location */
320 lang = setlocale (LC_CTYPE,NULL);
322 #ifdef hpux /* hpux-specific parsing of the locale string */
323 /* The following code is identical to the
324 ExtractLocaleName function in WmResParse.c
327 #define MAXLOCALE 64 /* buffer size of locale name */
332 static char buf[MAXLOCALE];
334 /* If lang has a substring ":<category>;", extract <category>
335 * from the first such occurrence as the locale name.
339 if (start = strchr (lang, ':')) {
341 if (end = strchr (start, ';')) {
343 strncpy(buf, start, len);
351 pl_desc = (char *)XtMalloc(strlen("/usr/dt/palettes/desc.") + strlen(lang) + 1);
352 strcpy (pl_desc,"/usr/dt/palettes/desc.");
353 strcat (pl_desc, lang);
354 if(sys_pl_DB = XrmGetFileDatabase (pl_desc))
355 XrmMergeDatabases(sys_pl_DB, &pl_DB);
358 /* load the palette description data base for the given locale*/
359 /* from that locale's description file from the admin location */
360 pl_desc = (char *)XtMalloc(strlen("/etc/dt/palettes/desc.") + strlen(lang) + 1);
361 strcpy (pl_desc,"/etc/dt/palettes/desc.");
362 strcat (pl_desc, lang);
363 if (adm_pl_DB = XrmGetFileDatabase (pl_desc))
364 XrmMergeDatabases(adm_pl_DB, &pl_DB);
367 /* load the palette description data base regardless of locale*/
368 pl_desc = (char *) XtMalloc(strlen(style.home) +(strlen("/.dt/palettes/desc.palettes") + 1));
369 strcpy (pl_desc, style.home);
370 strcat (pl_desc, "/.dt/palettes/desc.palettes");
371 if (hm_pl_DB = XrmGetFileDatabase (pl_desc))
372 XrmMergeDatabases(hm_pl_DB, &pl_DB);
375 /* load the palette description data base regardless of locale for later use*/
376 pl_desc = (char *) XtMalloc(strlen(style.home) +(strlen("/.dt/palettes/desc.palettes") + 1));
377 strcpy (pl_desc, style.home);
378 strcat (pl_desc, "/.dt/palettes/desc.palettes");
379 if (XrmCombineFileDatabase (pl_desc, &pl_DB, True))
380 /* load a separate home data base to be later saved as a file */
381 /* if any palettes are added */
382 hm_pl_DB = XrmGetFileDatabase (pl_desc);
395 ** Main routine does the following:
396 ** 1. Creates the color dialog shell
397 ** 2. Checks which monitor the customizer is running on
398 ** 3. Initialize color palettes
402 /* can the user access the Color portion of Style? */
404 /* Not if Color Server is not running */
405 if (style.colorSrv == FALSE)
407 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);
411 /* Not if useColorObj resource is False. XmeUseColorObj will return false
412 if color server is not running or if the resource UseColorObj is False.
413 If the color server is not running, that case is caught above so if
414 we get here, the resource UseColorObj must be False. This is an
415 undocumented resource. */
417 if (XmeUseColorObj() == FALSE)
419 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);
423 if (style.colorDialog == NULL || style.count < 12)
425 _DtTurnOnHourGlass(shell);
427 /* Create Main Color Dialog */
428 if(CreateMainWindow(shell) == -1)
430 _DtTurnOffHourGlass(shell);
433 XtManageChild(style.colorDialog);
435 _DtTurnOffHourGlass(shell);
439 XtManageChild(style.colorDialog);
441 raiseWindow(XtWindow(XtParent(style.colorDialog)));
444 /* also determine if system uses long filenames, used by add palette only */
452 ** This routine creates the Color Customizer Main Window. It is passed
453 ** the top level shell.
460 /* Create the DialogBox dialog */
461 CreateDialogBoxD(parent);
463 /* add some more to the dialog box */
466 /* Create the top part of the color dialog */
470 /* read in palettes */
471 ReadInPalettes(style.xrdb.paletteDir);
473 if (NumOfPalettes == 0)
475 /* error dialog - no palettes */
476 ErrDialog(((char *)GETMESSAGE(14, 38, "The color portion of the Style Manager\n\
477 will not operate because there are no palette\n\
478 files available. Check $HOME/.dt/errorlog.")), style.shell);
482 /* go get the list of palettes of the color dialog */
483 InitializePaletteList(parent,paletteList, False);
485 /* Allocate the pixels for the Current palette.
486 * Will get the pixel values from the color server.
488 AllocatePaletteCells(parent);
490 /* go create the bottom portion of the color dialog */
494 ** Create the color buttons. Have to do it after
495 ** initialize palettes so the correct pixels would be used.
497 CreatePaletteButtons(style.buttonsForm);
505 CreatePaletteButtons(
517 if (TypeOfMonitor == XmCO_BLACK_WHITE) /* create pixmaps for top/bottom shadow */
519 edit.pixmap25 = XmGetPixmap (style.screen, "25_foreground",
520 BlackPixelOfScreen(style.screen),
521 WhitePixelOfScreen(style.screen));
522 edit.pixmap75 = XmGetPixmap (style.screen, "75_foreground",
523 BlackPixelOfScreen(style.screen),
524 WhitePixelOfScreen(style.screen));
526 pixmap100 = XmGetPixmap (style.screen, "background",
527 BlackPixelOfScreen(style.screen),
528 pCurrentPalette->color[pCurrentPalette->active].bg.pixel);
530 XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
531 XtSetArg (args[n], XmNtopOffset, 0); n++;
532 XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
533 XtSetArg (args[n], XmNleftOffset, 0); n++;
534 XtSetArg (args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
535 XtSetArg (args[n], XmNrightPosition, PALETTE_RC_RIGHT_POSITION); n++;
536 XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
537 XtSetArg (args[n], XmNbottomOffset, 0); n++;
538 XtSetArg (args[n], XmNspacing, 0); n++;
539 XtSetArg (args[n], XmNmarginWidth, style.horizontalSpacing); n++;
540 XtSetArg (args[n], XmNmarginHeight, style.verticalSpacing); n++;
541 XtSetArg (args[n], XmNorientation, XmHORIZONTAL); n++;
542 XtSetArg (args[n], XmNpacking, XmPACK_COLUMN); n++;
543 XtSetArg (args[n], XmNadjustLast, False); n++;
544 if(TypeOfMonitor == XmCO_HIGH_COLOR)
546 XtSetArg (args[n], XmNnumColumns, 2); n++;
550 XtSetArg (args[n], XmNnumColumns, 1); n++;
552 paletteRc = XmCreateRowColumn(parent, "paletteRc", args, n);
553 XtManageChild(paletteRc);
555 for (i=0; i<XmCO_MAX_NUM_COLORS; i++)
558 XtSetArg (args[n], XmNrecomputeSize, False); n++;
559 XtSetArg (args[n], XmNwidth, COLOR_BUTTON_WIDTH); n++;
560 XtSetArg (args[n], XmNheight, COLOR_BUTTON_HEIGHT); n++;
561 /* allow traversal only if editing is possible */
562 if (style.dynamicColor || style.visualClass==TrueColor
563 || style.visualClass==DirectColor)
565 XtSetArg (args[n], XmNtraversalOn, False); n++;
567 XtSetArg (args[n], XmNborderWidth, BORDER_WIDTH); n++;
568 XtSetArg (args[n], XmNborderColor,
569 pCurrentPalette->color[pCurrentPalette->secondary].bg.pixel); n++;
570 XtSetArg (args[n], XmNforeground,
571 pCurrentPalette->color[i].fg.pixel); n++;
572 XtSetArg (args[n], XmNbackground,
573 pCurrentPalette->color[i].bg.pixel); n++;
574 XtSetArg (args[n], XmNarmColor, pCurrentPalette->color[i].sc.pixel); n++;
575 XtSetArg (args[n], XmNmultiClick, XmMULTICLICK_KEEP); n++;
576 if (TypeOfMonitor == XmCO_LOW_COLOR)
578 XtSetArg (args[n], XmNhighlightColor,
579 pCurrentPalette->color[pCurrentPalette->secondary].fg.pixel); n++;
583 XtSetArg (args[n], XmNhighlightPixmap, pixmap100); n++;
585 if(UsePixmaps == FALSE && TypeOfMonitor != XmCO_BLACK_WHITE)
587 XtSetArg (args[n], XmNtopShadowColor,
588 pCurrentPalette->color[i].ts.pixel); n++;
589 XtSetArg (args[n], XmNbottomShadowColor,
590 pCurrentPalette->color[i].bs.pixel); n++;
592 else if (TypeOfMonitor == XmCO_BLACK_WHITE)
594 XtSetArg (args[n], XmNtopShadowPixmap, edit.pixmap25); n++;
595 XtSetArg (args[n], XmNbottomShadowPixmap, edit.pixmap75); n++;
597 string = CMPSTR(" ");
598 XtSetArg (args[n], XmNlabelString, string); n++;
599 colorButton[i] = XmCreatePushButton(paletteRc, "colorButton", args, n);
600 /* allow access to modify functionality if available */
601 if (style.dynamicColor || style.visualClass==TrueColor
602 || style.visualClass==DirectColor)
603 XtAddCallback(colorButton[i], XmNactivateCallback, selectColorCB,
604 (XtPointer) (intptr_t) i);
605 XmStringFree(string);
607 XtManageChildren(colorButton,pCurrentPalette->num_of_colors);
609 if(!save.restoreFlag)
612 /* draw selection border if editing is possible */
613 if (style.dynamicColor || style.visualClass==TrueColor
614 || style.visualClass==DirectColor)
617 XtSetArg (args[n], XmNborderColor, BlackPixelOfScreen(style.screen)); n++;
618 XtSetValues(colorButton[selected_button],args,n);
621 if(style.visualClass==TrueColor || style.visualClass==DirectColor)
628 InitializePaletteList(
631 #if NeedWidePrototypes
640 XmStringTable string_table;
643 char *str_type_return;
644 XrmValue value_return;
650 ** Add the palettes read in from ReadInPalettes
653 if (TypeOfMonitor != XmCO_BLACK_WHITE) {
654 loop_palette = pHeadPalette;
655 loop_palette2 = pHeadPalette;
658 loop_palette = pHeadPalette;
659 loop_palette2 = NULL;
660 while(loop_palette != NULL)
661 if(strcmp(loop_palette->name, "Black") == 0) {
662 loop_palette2 = loop_palette;
666 loop_palette = loop_palette->next;
667 loop_palette = pHeadPalette;
668 if(loop_palette2 == NULL)
669 loop_palette2 = pHeadPalette;
672 while( loop_palette != NULL)
676 name_str = (char *) XtMalloc(strlen("palettes.") +
677 strlen(loop_palette->name) +
678 strlen(".desc") + 1);
680 class_str = (char *) XtMalloc(strlen("Palettes.") +
681 strlen(loop_palette->name) +
682 strlen(".Desc") + 1);
683 strcpy(name_str, "palettes.");
684 strcpy(class_str, "Palettes.");
685 strcat(name_str, loop_palette->name);
686 strcat(class_str, loop_palette->name);
687 strcat(name_str, ".desc");
688 strcat(class_str, ".Desc");
690 if (XrmGetResource (pl_DB, name_str, class_str, &str_type_return, &value_return))
692 loop_palette->desc = (char *)XtMalloc(strlen (value_return.addr) + 1 );
693 strcpy(loop_palette->desc, value_return.addr);
697 loop_palette->desc = (char *)XtMalloc(strlen (loop_palette->name) + 1 );
698 strcpy(loop_palette->desc, loop_palette->name);
705 loop_palette->desc = (char *)XtMalloc(strlen (loop_palette->name) + 1 );
706 strcpy(loop_palette->desc, loop_palette->name);
709 XmListAddItem(list, CMPSTR(loop_palette->desc), loop_palette->item_position);
711 /* if the item is the same as the default name provided by the
712 color Server, save it */
713 if(!save.restoreFlag || defaultName_restore == NULL) {
714 if (!(strcmp(loop_palette->name, defaultName)))
715 loop_palette2 = loop_palette;
718 if (!(strcmp(loop_palette->name, defaultName_restore)))
719 loop_palette2 = loop_palette;
721 loop_palette = loop_palette->next;
723 if((loopcount % 5 == 0) && startup)
730 ** Make the palette named by the color Server the selected palette, if the
731 ** palette returned by the color server doesn't match make it the head
736 /* the default name is the name to be selected */
737 if (loop_palette2->name == NULL)
740 string = CMPSTR(loop_palette2->desc);
741 string_table = &string;
744 XtSetArg (args[n], XmNselectedItemCount, 1); n++;
745 XtSetArg (args[n], XmNselectedItems, string_table); n++;
746 XtSetValues (list, args, n);
747 XmStringFree(string);
749 XmListSetPos(list, loop_palette2->item_position);
752 pCurrentPalette = loop_palette2;
753 selected_position = pCurrentPalette->item_position;
760 * Allocate new pixel values and update color palette buttons.
761 * This is needed for screens without dynamicColor.
763 static void allocNewColors(void)
767 static unsigned long pixels[XmCO_MAX_NUM_COLORS*5];
768 static int count = 0;
772 /* free the cells from last selection */
773 XFreeColors(style.display, style.colormap, pixels, count, 0);
777 for (i=0; i<pCurrentPalette->num_of_colors; i++)
780 if (XAllocColor(style.display, style.colormap,
781 &(pCurrentPalette->color[i].fg)) == 0) break;
782 pixels[count++] = pCurrentPalette->color[i].fg.pixel;
784 if (XAllocColor(style.display, style.colormap,
785 &(pCurrentPalette->color[i].bg)) == 0) break;
786 pixels[count++] = pCurrentPalette->color[i].bg.pixel;
787 XtSetArg (args[n], XmNbackground,
788 pCurrentPalette->color[i].bg.pixel); n++;
790 if (XAllocColor(style.display, style.colormap,
791 &(pCurrentPalette->color[i].sc)) == 0) break;
792 pixels[count++] = pCurrentPalette->color[i].sc.pixel;
793 XtSetArg (args[n], XmNarmColor,
794 pCurrentPalette->color[i].sc.pixel); n++;
796 if (UsePixmaps == FALSE)
798 if (XAllocColor(style.display, style.colormap,
799 &(pCurrentPalette->color[i].ts)) == 0) break;
800 pixels[count++] = pCurrentPalette->color[i].ts.pixel;
801 XtSetArg (args[n], XmNtopShadowColor,
802 pCurrentPalette->color[i].ts.pixel); n++;
804 if (XAllocColor(style.display, style.colormap,
805 &(pCurrentPalette->color[i].bs)) == 0) break;
806 pixels[count++] = pCurrentPalette->color[i].bs.pixel;
807 XtSetArg (args[n], XmNbottomShadowColor,
808 pCurrentPalette->color[i].bs.pixel); n++;
810 else /* create pixmaps for top/bottom shadow */
812 XmDestroyPixmap(style.screen, edit.pixmap25);
813 XmDestroyPixmap(style.screen, edit.pixmap75);
815 edit.pixmap25 = XmGetPixmap (style.screen,
816 "50_foreground",pCurrentPalette->color[i].bg.pixel,
817 WhitePixelOfScreen(style.screen));
819 edit.pixmap75 = XmGetPixmap (style.screen,
820 "50_foreground",pCurrentPalette->color[i].bg.pixel,
821 BlackPixelOfScreen(style.screen));
823 XtSetArg (args[n], XmNtopShadowPixmap, edit.pixmap25); n++;
824 XtSetArg (args[n], XmNbottomShadowPixmap, edit.pixmap75); n++;
826 XtSetValues(colorButton[i], args, n);
831 ** This is the selection callback for the Scrolled list.
832 ** The routine finds the item the user selected and changes
833 ** the already allocated pixels to the colors of the selected palette.
838 XtPointer client_data,
839 XtPointer call_data )
843 XmListCallbackStruct *cb = (XmListCallbackStruct *)call_data;
844 palette *tmp_palette;
847 static Boolean First = True;
849 white = WhitePixelOfScreen(style.screen);
850 black = BlackPixelOfScreen(style.screen);
852 if (((edit.DialogShell == NULL) || (!XtIsManaged(edit.DialogShell))) &&
853 selected_position != cb->item_position)
855 selected_position = cb->item_position;
857 tmp_palette = pHeadPalette;
858 while( tmp_palette->item_position != selected_position &&
860 tmp_palette = tmp_palette->next;
862 if(tmp_palette->item_position == selected_position)
864 pOldPalette = pCurrentPalette;
865 pCurrentPalette = tmp_palette;
868 string = CMPSTR(pCurrentPalette->desc);
869 XtSetArg (args[n], XmNtitleString, string); n++;
870 XtSetValues (colorDialog.buttonsTB, args, n);
871 XmStringFree(string);
873 if (style.dynamicColor)
877 if (TypeOfMonitor != XmCO_BLACK_WHITE)
879 /* PUT DIALOG saying can't dynamically change */
882 InfoDialog(NEXT_SESSION, style.colorDialog, False);
887 else /* XmCO_BLACK_WHITE */
889 /* set color buttons for new palette - read only cells */
890 /* primary=color[1] secondary=color[0] */
891 if (strcmp(pCurrentPalette->name, WHITE_BLACK) == 0)
893 n=0; /* secondary color white */
894 XtSetArg (args[n], XmNforeground, black); n++;
895 XtSetArg (args[n], XmNbackground, white); n++;
896 XtSetArg (args[n], XmNarmColor, white); n++;
897 XtSetValues(colorButton[0], args, n);
898 pCurrentPalette->color[0].fg.pixel = black;
899 pCurrentPalette->color[0].bg.pixel = white;
900 pCurrentPalette->color[0].sc.pixel = white;
901 pCurrentPalette->color[0].ts.pixel = black;
902 pCurrentPalette->color[0].bs.pixel = black;
904 n=0; /* primary color black */
905 XtSetArg (args[n], XmNforeground, white); n++;
906 XtSetArg (args[n], XmNbackground, black); n++;
907 XtSetArg (args[n], XmNarmColor, black); n++;
908 XtSetValues(colorButton[1], args, n);
909 pCurrentPalette->color[1].fg.pixel = white;
910 pCurrentPalette->color[1].bg.pixel = black;
911 pCurrentPalette->color[1].sc.pixel = black;
912 pCurrentPalette->color[1].ts.pixel = white;
913 pCurrentPalette->color[1].bs.pixel = white;
915 else if (strcmp(pCurrentPalette->name, BLACK_WHITE) == 0)
917 n=0; /* secondary color black */
918 XtSetArg (args[n], XmNforeground, white); n++;
919 XtSetArg (args[n], XmNbackground, black); n++;
920 XtSetArg (args[n], XmNarmColor, black); n++;
921 XtSetValues(colorButton[0], args, n);
922 pCurrentPalette->color[0].fg.pixel = white;
923 pCurrentPalette->color[0].bg.pixel = black;
924 pCurrentPalette->color[0].sc.pixel = black;
925 pCurrentPalette->color[0].ts.pixel = white;
926 pCurrentPalette->color[0].bs.pixel = white;
928 n=0; /* primary color white */
929 XtSetArg (args[n], XmNforeground, black); n++;
930 XtSetArg (args[n], XmNbackground, white); n++;
931 XtSetArg (args[n], XmNarmColor, white); n++;
932 XtSetValues(colorButton[1], args, n);
933 pCurrentPalette->color[1].fg.pixel = black;
934 pCurrentPalette->color[1].bg.pixel = white;
935 pCurrentPalette->color[1].sc.pixel = white;
936 pCurrentPalette->color[1].ts.pixel = black;
937 pCurrentPalette->color[1].bs.pixel = black;
939 else if (strcmp(pCurrentPalette->name, BLACK_ONLY) == 0)
941 n=0; /* primary and secondary color black */
942 XtSetArg (args[n], XmNforeground, white); n++;
943 XtSetArg (args[n], XmNbackground, black); n++;
944 XtSetArg (args[n], XmNarmColor, black); n++;
945 XtSetValues(colorButton[0], args, n);
946 pCurrentPalette->color[0].fg.pixel = white;
947 pCurrentPalette->color[0].bg.pixel = black;
948 pCurrentPalette->color[0].sc.pixel = black;
949 pCurrentPalette->color[0].ts.pixel = white;
950 pCurrentPalette->color[0].bs.pixel = white;
951 XtSetValues(colorButton[1], args, n);
952 pCurrentPalette->color[1].fg.pixel = white;
953 pCurrentPalette->color[1].bg.pixel = black;
954 pCurrentPalette->color[1].sc.pixel = black;
955 pCurrentPalette->color[1].ts.pixel = white;
956 pCurrentPalette->color[1].bs.pixel = white;
958 else /* WHITE_ONLY */
960 n=0; /* primary and secondary color white */
961 XtSetArg (args[n], XmNforeground, black); n++;
962 XtSetArg (args[n], XmNbackground, white); n++;
963 XtSetArg (args[n], XmNarmColor, white); n++;
964 XtSetValues(colorButton[0], args, n);
965 pCurrentPalette->color[0].fg.pixel = black;
966 pCurrentPalette->color[0].bg.pixel = white;
967 pCurrentPalette->color[0].sc.pixel = white;
968 pCurrentPalette->color[0].ts.pixel = black;
969 pCurrentPalette->color[0].bs.pixel = black;
970 XtSetValues(colorButton[1], args, n);
971 pCurrentPalette->color[1].fg.pixel = black;
972 pCurrentPalette->color[1].bg.pixel = white;
973 pCurrentPalette->color[1].sc.pixel = white;
974 pCurrentPalette->color[1].ts.pixel = black;
975 pCurrentPalette->color[1].bs.pixel = black;
987 XtPointer client_data,
988 XtPointer call_data )
994 XmPushButtonCallbackStruct *cb = (XmPushButtonCallbackStruct *)call_data;
996 i = (intptr_t) client_data;
998 /* if click_count == 1 .. first button press, set time out */
999 if(cb->click_count == 1)
1001 timeID = XtAppAddTimeOut(XtWidgetToApplicationContext(gParent),
1002 (unsigned long) dclick_time, timeoutCB,
1007 /* else .. second button press, remove the time out */
1008 XtRemoveTimeOut(timeID);
1010 if ((edit.DialogShell == NULL) || (!XtIsManaged(edit.DialogShell)))
1014 /* make the new selected button have a border color */
1016 XtSetArg(args[n],XmNbackground,&bg_pixel); n++;
1017 XtGetValues(colorDialog.colorForm,args,n);
1020 XtSetArg (args[n], XmNborderColor,bg_pixel);
1022 XtSetValues(colorButton[selected_button],args,n);
1025 XtSetArg (args[n], XmNborderColor, BlackPixelOfScreen(style.screen));
1027 XtSetValues(colorButton[i],args,n);
1029 selected_button = i;
1031 color_set = (ColorSet *) &pCurrentPalette->color[selected_button];
1032 ColorEditor(style.colorDialog,color_set);
1034 if(!style.dynamicColor) /* need to update pixels */
1035 XtAddCallback(edit.DialogShell, XmNcallback, colorEditorCB, NULL);
1040 * Color editor callback for screens without dynamicColor.
1042 static void colorEditorCB(Widget w, XtPointer client_data, XtPointer call_data)
1044 static Boolean first = True;
1045 DtDialogBoxCallbackStruct *cb = (DtDialogBoxCallbackStruct *) call_data;
1047 /* show "next session" message if first edit */
1048 if(cb->button_position==OK_BUTTON && first){
1049 InfoDialog(NEXT_SESSION, style.colorDialog, False);
1053 XtRemoveCallback(edit.DialogShell, XmNcallback, colorEditorCB, NULL);
1057 ** This is the double click timeout callback. If this routine is called
1058 ** then there was only a single click on a colorbutton
1062 XtPointer client_data,
1070 if (TypeOfMonitor == XmCO_BLACK_WHITE)
1073 i = (intptr_t) client_data;
1075 if ((edit.DialogShell == NULL) || (!XtIsManaged(edit.DialogShell)))
1077 /* make the new selected button have a border color */
1079 XtSetArg(args[n],XmNbackground,&bg_pixel); n++;
1080 XtGetValues(colorDialog.colorForm,args,n);
1083 XtSetArg (args[n], XmNborderColor,bg_pixel);
1085 XtSetValues(colorButton[selected_button],args,n);
1088 XtSetArg (args[n], XmNborderColor, BlackPixelOfScreen(style.screen));
1090 XtSetValues(colorButton[i],args,n);
1091 selected_button = i;
1098 XtPointer client_data,
1099 XtPointer call_data )
1107 if (addDialog == NULL)
1111 XtSetArg(args[n], XmNokLabelString, CMPSTR((String) _DtOkString)); n++;
1112 XtSetArg(args[n], XmNcancelLabelString, CMPSTR((String) _DtCancelString)); n++;
1113 XtSetArg(args[n], XmNhelpLabelString, CMPSTR((String) _DtHelpString)); n++;
1114 string = CMPSTR(((char *)GETMESSAGE(14, 10, "New palette name:")));
1115 XtSetArg(args[n], XmNselectionLabelString, string); n++;
1116 string1 = CMPSTR("");
1117 XtSetArg(args[n], XmNtextString, string1); n++;
1118 XtSetArg(args[n], XmNborderWidth, 3); n++;
1119 XtSetArg(args[n], XmNautoUnmanage, False); n++;
1120 addDialog = XmCreatePromptDialog(style.colorDialog,"AddDialog",
1122 XmStringFree(string);
1123 XmStringFree(string1);
1125 XtAddCallback(addDialog, XmNokCallback, addOkCB,
1127 XtAddCallback(addDialog, XmNcancelCallback, addCancelCB,
1129 XtAddCallback(addDialog, XmNhelpCallback,
1130 (XtCallbackProc)HelpRequestCB, (XtPointer)HELP_ADD_PALETTE_DIALOG);
1133 XtSetArg (args[n], XmNmwmInputMode,
1134 MWM_INPUT_PRIMARY_APPLICATION_MODAL); n++;
1135 XtSetArg (args[n], XmNuseAsyncGeometry, True); n++;
1136 XtSetArg (args[n], XmNtitle, ((char *)GETMESSAGE(14, 11, "Add Palette"))); n++;
1137 XtSetArg (args[n], XmNmwmFunctions, DIALOG_MWM_FUNC); n++;
1138 XtSetValues (XtParent (addDialog), args, n);
1141 string = CMPSTR("");
1142 XtSetArg(args[n], XmNtextString, string); n++;
1143 XtSetValues(addDialog, args, n);
1144 XmStringFree(string);
1146 XtManageChild(addDialog);
1153 XtPointer client_data,
1154 XtPointer call_data )
1156 XtUnmanageChild(addDialog);
1162 XtPointer client_data,
1163 XtPointer call_data )
1168 char *name, *filename, *tmpstr;
1169 palette *tmpPalette, *newPalette;
1174 /* Get the text from the promp dialog */
1175 name = XmTextFieldGetString( XmSelectionBoxGetChild(addDialog, XmDIALOG_TEXT));
1177 /* see if the user typed in a valid palette name */
1178 if(!ValidName(name)) {
1179 ErrDialog(((char *)GETMESSAGE(14, 12, "The palette name cannot contain\nthese characters:\n\n * : ( ) [ ] { } < > ! | \" / \\")),
1185 /* check the number of characters in name in a locale independent way */
1186 for ( ii = 0, count = 0; name[ii] != '\0'; ii += length ) {
1187 length = mblen( &(name[ii]), MB_CUR_MAX );
1193 /* make sure the length of name is ok, short file names can only be 11 chars */
1194 if(count > 10 && !style.longfilename) {
1195 ErrDialog(((char *)GETMESSAGE(14, 13, "The palette name must be\n10 characters or less.\n")),style.colorDialog);
1200 /* Unmanage the promptDialog */
1201 XtUnmanageChild(addDialog);
1203 /* first search through palette descriptions and make sure the name to */
1204 /* add is not already in the list and go to the end of the palette list */
1205 for(tmpPalette = pHeadPalette; tmpPalette->next != NULL;
1206 tmpPalette = tmpPalette->next)
1208 if((strcmp(tmpPalette->desc, name) == 0)) {
1209 SameName(w, tmpPalette, name);
1215 /* Check the last palette */
1216 if((strcmp(tmpPalette->desc, name) == 0)) {
1217 SameName(w, tmpPalette, name);
1222 /* allocate space for a new palette */
1223 newPalette = (palette *)XtMalloc(sizeof(palette) + 1 );
1225 /* set the previous last palatte to this new one, it is now the last one*/
1226 tmpPalette->next = newPalette;
1227 newPalette->next = NULL;
1229 /* malloc space for the new palette desc */
1230 newPalette->desc = (char *)XtMalloc(strlen(name) + 1);
1231 for(i = 0; i < strlen(name); i++)
1232 newPalette->desc[i] = name[i];
1233 newPalette->desc[i] = '\0';
1235 /* malloc space for the new palette name directory */
1236 newPalette->directory = (char *)XtMalloc(strlen(style.home) +
1237 strlen(DT_PAL_DIR) + 1);
1238 strcpy(newPalette->directory, style.home);
1239 strcat(newPalette->directory, DT_PAL_DIR);
1241 /* makeup a new name for the palette */
1242 tmpstr = (char *)XtMalloc(strlen(style.home) + strlen(DT_PAL_DIR) +
1243 strlen("dtXXXXXX") + 1);
1244 strcpy(tmpstr, newPalette->directory);
1245 len = strlen(tmpstr);
1246 strcat(tmpstr, "dtXXXXXX");
1249 newPalette->name = (char *) XtMalloc(15 * sizeof(char));
1250 strcpy(newPalette->name, tmpstr + len);
1253 /* the new palette is the next palette .. increase NumOfPalettes by one */
1254 newPalette->item_position = NumOfPalettes + 1;
1257 /* set all the new palette's color parameters to the current palette */
1258 newPalette->num_of_colors = pCurrentPalette->num_of_colors;
1259 for(i = 0; i < XmCO_MAX_NUM_COLORS; i++)
1261 newPalette->color[i].fg.pixel = pCurrentPalette->color[i].fg.pixel;
1262 newPalette->color[i].fg.red = pCurrentPalette->color[i].fg.red;
1263 newPalette->color[i].fg.green = pCurrentPalette->color[i].fg.green;
1264 newPalette->color[i].fg.blue = pCurrentPalette->color[i].fg.blue;
1265 newPalette->color[i].fg.flags = pCurrentPalette->color[i].fg.flags;
1267 newPalette->color[i].bg.pixel = pCurrentPalette->color[i].bg.pixel;
1268 newPalette->color[i].bg.red = pCurrentPalette->color[i].bg.red;
1269 newPalette->color[i].bg.green = pCurrentPalette->color[i].bg.green;
1270 newPalette->color[i].bg.blue = pCurrentPalette->color[i].bg.blue;
1271 newPalette->color[i].bg.flags = pCurrentPalette->color[i].bg.flags;
1273 newPalette->color[i].ts.pixel = pCurrentPalette->color[i].ts.pixel;
1274 newPalette->color[i].ts.red = pCurrentPalette->color[i].ts.red;
1275 newPalette->color[i].ts.green = pCurrentPalette->color[i].ts.green;
1276 newPalette->color[i].ts.blue = pCurrentPalette->color[i].ts.blue;
1277 newPalette->color[i].ts.flags = pCurrentPalette->color[i].ts.flags;
1279 newPalette->color[i].bs.pixel = pCurrentPalette->color[i].bs.pixel;
1280 newPalette->color[i].bs.red = pCurrentPalette->color[i].bs.red;
1281 newPalette->color[i].bs.green = pCurrentPalette->color[i].bs.green;
1282 newPalette->color[i].bs.blue = pCurrentPalette->color[i].bs.blue;
1283 newPalette->color[i].bs.flags = pCurrentPalette->color[i].bs.flags;
1285 newPalette->color[i].sc.pixel = pCurrentPalette->color[i].sc.pixel;
1286 newPalette->color[i].sc.red = pCurrentPalette->color[i].sc.red;
1287 newPalette->color[i].sc.green = pCurrentPalette->color[i].sc.green;
1288 newPalette->color[i].sc.blue = pCurrentPalette->color[i].sc.blue;
1289 newPalette->color[i].sc.flags = pCurrentPalette->color[i].sc.flags;
1292 /* Write out the palette */
1293 if ((WriteOutPalette(newPalette->name)) == -1)
1297 /* remove palette from list */
1298 tmpPalette->next = NULL;
1299 XtFree ((char *)newPalette);
1304 WriteOutDesc(newPalette);
1307 /* add the name to the scrolled window list and select it */
1308 AddName(newPalette);
1310 /* now check to see if there is a ~filename .. if there is delete it */
1311 /* use the $HOME environment varible then constuct the full file name */
1312 filename = (char *)XtMalloc(strlen(style.home) + strlen(DT_PAL_DIR) +
1313 strlen(newPalette->name) + strlen(PALETTE_SUFFIX) + 2);
1315 /* create the full path name plus file name */
1316 strcpy(filename, style.home);
1317 strcat(filename, DT_PAL_DIR);
1318 strcat(filename, "~");
1319 strcat(filename, newPalette->name);
1320 strcat(filename, PALETTE_SUFFIX);
1327 /* Go write out the palette */
1328 pCurrentPalette = newPalette;
1335 XtPointer client_data,
1336 XtPointer call_data )
1338 palette *tmpPalette = (palette *)client_data;
1341 /* free the directory */
1342 XtFree(tmpPalette->directory);
1344 /* put the new (users) directory there */
1345 tmpPalette->directory = (char *)XtMalloc(strlen(style.home) +
1346 strlen(DT_PAL_DIR) + 1);
1347 strcpy(tmpPalette->directory, style.home);
1348 strcat(tmpPalette->directory, DT_PAL_DIR);
1350 for(i = 0; i < XmCO_MAX_NUM_COLORS; i++)
1352 tmpPalette->color[i].fg.pixel = pCurrentPalette->color[i].fg.pixel;
1353 tmpPalette->color[i].fg.red = pCurrentPalette->color[i].fg.red;
1354 tmpPalette->color[i].fg.green = pCurrentPalette->color[i].fg.green;
1355 tmpPalette->color[i].fg.blue = pCurrentPalette->color[i].fg.blue;
1356 tmpPalette->color[i].fg.flags = pCurrentPalette->color[i].fg.flags;
1358 tmpPalette->color[i].bg.pixel = pCurrentPalette->color[i].bg.pixel;
1359 tmpPalette->color[i].bg.red = pCurrentPalette->color[i].bg.red;
1360 tmpPalette->color[i].bg.green = pCurrentPalette->color[i].bg.green;
1361 tmpPalette->color[i].bg.blue = pCurrentPalette->color[i].bg.blue;
1362 tmpPalette->color[i].bg.flags = pCurrentPalette->color[i].bg.flags;
1364 tmpPalette->color[i].ts.pixel = pCurrentPalette->color[i].ts.pixel;
1365 tmpPalette->color[i].ts.red = pCurrentPalette->color[i].ts.red;
1366 tmpPalette->color[i].ts.green = pCurrentPalette->color[i].ts.green;
1367 tmpPalette->color[i].ts.blue = pCurrentPalette->color[i].ts.blue;
1368 tmpPalette->color[i].ts.flags = pCurrentPalette->color[i].ts.flags;
1370 tmpPalette->color[i].bs.pixel = pCurrentPalette->color[i].bs.pixel;
1371 tmpPalette->color[i].bs.red = pCurrentPalette->color[i].bs.red;
1372 tmpPalette->color[i].bs.green = pCurrentPalette->color[i].bs.green;
1373 tmpPalette->color[i].bs.blue = pCurrentPalette->color[i].bs.blue;
1374 tmpPalette->color[i].bs.flags = pCurrentPalette->color[i].bs.flags;
1376 tmpPalette->color[i].sc.pixel = pCurrentPalette->color[i].sc.pixel;
1377 tmpPalette->color[i].sc.red = pCurrentPalette->color[i].sc.red;
1378 tmpPalette->color[i].sc.green = pCurrentPalette->color[i].sc.green;
1379 tmpPalette->color[i].sc.blue = pCurrentPalette->color[i].sc.blue;
1380 tmpPalette->color[i].sc.flags = pCurrentPalette->color[i].sc.flags;
1383 /* Write out the palette */
1384 if ((WriteOutPalette(tmpPalette->name)) == -1)
1387 WriteOutDesc(tmpPalette);
1389 pCurrentPalette = tmpPalette;
1391 /* select item in list as if user had selected it */
1392 XmListSelectPos (paletteList, tmpPalette->item_position, TRUE);
1393 XmListSetBottomPos(paletteList, tmpPalette->item_position);
1394 selected_position = tmpPalette->item_position;
1401 XtPointer client_data,
1402 XtPointer call_data )
1404 ColorSet *color_set;
1406 if(TypeOfMonitor == XmCO_BLACK_WHITE)
1409 color_set = (ColorSet *) &pCurrentPalette->color[selected_button];
1410 ColorEditor(style.colorDialog,color_set);
1412 if(!style.dynamicColor) /* need to update pixels */
1413 XtAddCallback(edit.DialogShell, XmNcallback, colorEditorCB, NULL);
1419 ** Process callback from the Ok, Cancel and Help pushButtons in the
1425 XtPointer client_data,
1426 XtPointer call_data )
1428 palette *tmp_palette;
1430 DtDialogBoxCallbackStruct *cb = (DtDialogBoxCallbackStruct *) call_data;
1432 switch (cb->button_position)
1435 if ((edit.DialogShell != NULL) && (XtIsManaged(edit.DialogShell)))
1436 XtUnmanageChild(edit.DialogShell);
1438 XtUnmanageChild(style.colorDialog);
1439 UpdateDefaultPalette();
1443 if ((edit.DialogShell != NULL) && (XtIsManaged(edit.DialogShell)))
1444 XtUnmanageChild(edit.DialogShell);
1446 if ((addDialog != NULL) && (XtIsManaged(addDialog)))
1447 XtCallCallbacks(addDialog, XmNcancelCallback, (XtPointer)NULL);
1449 if ((deleteDialog != NULL) && (XtIsManaged(deleteDialog)))
1450 XtCallCallbacks(deleteDialog, XmNcancelCallback, (XtPointer)NULL);
1452 if ((colorUseDialog != NULL) && (XtIsManaged(colorUseDialog)))
1453 XtCallCallbacks(colorUseDialog, XmNcallback, (XtPointer)NULL);
1455 XtUnmanageChild(style.colorDialog);
1457 tmp_palette = pHeadPalette;
1458 for(tmp_palette = pHeadPalette; tmp_palette != NULL; tmp_palette = tmp_palette->next)
1459 if(!(strcmp(tmp_palette->name, defaultName)))
1465 if(match == FALSE) /* the default palette is no longer valid */
1466 UpdateDefaultPalette();
1468 RestoreOrgPalette();
1473 XtCallCallbacks(style.colorDialog, XmNhelpCallback, (XtPointer)NULL);
1484 palette *newPalette )
1489 ** Add the palette name to the list
1491 string = CMPSTR(newPalette->desc);
1492 XmListAddItem(paletteList, string, newPalette->item_position);
1493 XmListSelectPos(paletteList, newPalette->item_position, TRUE);
1494 XmListSetBottomPos(paletteList, newPalette->item_position);
1495 selected_position = newPalette->item_position;
1496 XSync(style.display, 0);
1497 XmStringFree(string);
1503 XtPointer client_data,
1504 XtPointer call_data )
1509 palette *tmp_palette;
1512 char *str_type_return;
1513 XrmValue value_return;
1515 tmp_palette = pHeadPalette;
1517 while( tmp_palette->item_position != selected_position &&
1518 tmp_palette != NULL)
1519 tmp_palette = tmp_palette->next;
1521 if (deleteDialog == NULL)
1524 XtSetArg(args[n], XmNokLabelString, CMPSTR((String) _DtOkString)); n++;
1525 XtSetArg(args[n], XmNcancelLabelString, CMPSTR((String) _DtCancelString)); n++;
1526 XtSetArg(args[n], XmNhelpLabelString, CMPSTR((String) _DtHelpString)); n++;
1527 XtSetArg(args[n], XmNdialogType, XmDIALOG_INFORMATION); n++;
1528 XtSetArg(args[n], XmNborderWidth, 3); n++;
1529 XtSetArg(args[n], XmNdefaultPosition, False); n++;
1530 deleteDialog = XmCreateQuestionDialog(style.colorDialog,
1531 "deleteDialog", args, n);
1532 XtAddCallback(deleteDialog, XmNmapCallback, CenterMsgCB,
1534 XtAddCallback(deleteDialog, XmNcancelCallback, deleteCancelCB, NULL);
1535 XtAddCallback(deleteDialog, XmNokCallback, deleteOkCB,
1536 (XtPointer)(paletteList));
1537 XtAddCallback(deleteDialog, XmNhelpCallback,
1538 (XtCallbackProc)HelpRequestCB,
1539 (XtPointer)HELP_DELETE_PALETTE_WARNING_DIALOG);
1543 XtSetArg (args[n], XmNmwmInputMode,
1544 MWM_INPUT_PRIMARY_APPLICATION_MODAL); n++;
1545 XtSetArg (args[n], XmNuseAsyncGeometry, True); n++;
1546 XtSetArg (args[n], XmNtitle, ((char *)GETMESSAGE(14, 16, "Delete Palette"))); n++;
1547 XtSetArg (args[n], XmNmwmFunctions, DIALOG_MWM_FUNC); n++;
1548 XtSetValues (XtParent (deleteDialog), args, n);
1553 tmpStr = XtMalloc(strlen(STR2) + strlen(tmp_palette->desc) + 1);
1554 sprintf(tmpStr, STR2, tmp_palette->desc);
1555 XtSetArg(args[n], XmNmessageString, CMPSTR(tmpStr)); n++;
1556 XtSetValues(deleteDialog, args, n);
1559 XtManageChild(deleteDialog);
1565 XtPointer client_data,
1566 XtPointer call_data )
1569 XtUnmanageChild(deleteDialog);
1571 if(NumOfPalettes == 1)
1573 InfoDialog(CANT_DELETE, style.colorDialog, False);
1577 if (RemovePalette() == True)
1578 DeletePaletteFromLinkList((Widget)client_data);
1585 XtPointer client_data,
1586 XtPointer call_data )
1588 XtUnmanageChild(deleteDialog);
1594 XtPointer client_data,
1595 XtPointer call_data )
1600 XmString button_string[NUM_LABELS];
1602 Widget parent = (Widget) client_data;
1605 Widget widget_list[10];
1610 if (colorUseDialog == NULL)
1614 /* Set up DialogBox button labels. */
1615 button_string[0] = CMPSTR((String) _DtOkString);
1616 button_string[1] = CMPSTR((String) _DtCancelString);
1617 button_string[2] = CMPSTR((String) _DtHelpString);
1619 XtSetArg (args[n], XmNchildType, XmWORK_AREA); n++;
1620 XtSetArg (args[n], XmNbuttonCount, NUM_LABELS); n++;
1621 XtSetArg (args[n], XmNbuttonLabelStrings, button_string); n++;
1622 XtSetArg (args[n], XmNdefaultPosition, False); n++;
1623 colorUseDialog = __DtCreateDialogBoxDialog(parent, "colorUseDialog",
1625 XtAddCallback(colorUseDialog, XmNcallback, colorUseExitCB, NULL);
1626 XtAddCallback(colorUseDialog, XmNmapCallback, _DtmapCB_colorUse, NULL);
1627 XtAddCallback(colorUseDialog, XmNhelpCallback,
1628 (XtCallbackProc)HelpRequestCB, (XtPointer)HELP_COLOR_USE_DIALOG);
1630 XmStringFree(button_string[0]);
1631 XmStringFree(button_string[1]);
1632 XmStringFree(button_string[2]);
1634 widget_list[0] = _DtDialogBoxGetButton(colorUseDialog,2);
1636 XtSetArg(args[n], XmNautoUnmanage, False); n++;
1637 XtSetArg(args[n], XmNcancelButton, widget_list[0]); n++;
1638 XtSetValues (colorUseDialog, args, n);
1641 XtSetArg (args[n], XmNuseAsyncGeometry, True); n++;
1642 XtSetArg (args[n], XmNtitle,
1643 ((char *)GETMESSAGE(14, 39, "Number Of Colors To Use:"))); n++;
1644 XtSetArg (args[n], XmNmwmFunctions, DIALOG_MWM_FUNC); n++;
1645 XtSetValues (XtParent(colorUseDialog), args, n);
1648 XtSetArg(args[n], XmNhorizontalSpacing, style.horizontalSpacing); n++;
1649 XtSetArg(args[n], XmNverticalSpacing, style.verticalSpacing); n++;
1650 XtSetArg(args[n], XmNallowOverlap, False); n++;
1651 XtSetArg(args[n], XmNchildType, XmWORK_AREA); n++;
1652 form = XmCreateForm(colorUseDialog, "colorUseForm", args, n);
1653 XtManageChild(form);
1656 XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
1657 XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
1658 XtSetArg (args[n], XmNrightAttachment, XmATTACH_NONE); n++;
1659 XtSetArg (args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
1660 XtSetArg (args[n], XmNbehavior, XmICON_LABEL); n++;
1661 XtSetArg (args[n], XmNshadowThickness, 0); n++;
1662 XtSetArg (args[n], XmNstring, NULL); n++;
1663 XtSetArg (args[n], XmNpixmapForeground, style.primBSCol); n++;
1664 XtSetArg (args[n], XmNpixmapBackground, style.primTSCol); n++;
1665 XtSetArg (args[n], XmNimageName, COLOR_ICON); n++;
1666 XtSetArg (args[n], XmNtraversalOn, False); n++;
1667 pictLabel = _DtCreateIcon(form, "pictLabel", args, n);
1668 XtManageChild(pictLabel);
1671 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
1672 XtSetArg (args[n], XmNtopWidget, pictLabel); n++;
1673 XtSetArg (args[n], XmNtopOffset, style.verticalSpacing); n++;
1674 XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
1675 XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
1676 XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
1678 = XmCreateFrame(form, "colorUseTB", args, n);
1679 XtManageChild(colorUseTB);
1681 /* create a rowColumn for ColorUse selections */
1683 colorUseRC = XmCreateRadioBox(colorUseTB, "colorUseRC", args, n);
1684 XtManageChild(colorUseRC);
1687 string = CMPSTR(((char *)GETMESSAGE(14, 41, "More Colors for Desktop")));
1688 XtSetArg(args[n], XmNlabelString, string); n++;
1689 widget_list[count++] = colorDialog.highColorTG
1690 = XmCreateToggleButtonGadget(colorUseRC,"highColorTG", args, n);
1691 XtAddCallback(colorDialog.highColorTG, XmNvalueChangedCallback,
1692 colorUseCB, (XtPointer)XmCO_HIGH_COLOR);
1693 XmStringFree(string);
1696 string = CMPSTR(((char *)GETMESSAGE(14, 42, "More Colors for Applications")));
1697 XtSetArg(args[n], XmNlabelString, string); n++;
1698 widget_list[count++] = colorDialog.mediumColorTG
1699 = XmCreateToggleButtonGadget(colorUseRC,"mediumColorTG", args, n);
1700 XmStringFree(string);
1701 XtAddCallback(colorDialog.mediumColorTG, XmNvalueChangedCallback,
1702 colorUseCB, (XtPointer)XmCO_MEDIUM_COLOR);
1705 string = CMPSTR(((char *)GETMESSAGE(14, 43, "Most Colors for Applications")));
1706 XtSetArg(args[n], XmNlabelString, string); n++;
1707 widget_list[count++] = colorDialog.lowColorTG
1708 = XmCreateToggleButtonGadget(colorUseRC,"lowColorTG", args, n);
1709 XmStringFree(string);
1710 XtAddCallback(colorDialog.lowColorTG, XmNvalueChangedCallback,
1711 colorUseCB, (XtPointer)XmCO_LOW_COLOR);
1714 string = CMPSTR(((char *)GETMESSAGE(14, 34, "Black and White")));
1715 XtSetArg(args[n], XmNlabelString, string); n++;
1716 widget_list[count++] = colorDialog.blackWhiteTG
1717 = XmCreateToggleButtonGadget(colorUseRC,"blackWhiteTG", args, n);
1718 XmStringFree(string);
1719 XtAddCallback(colorDialog.blackWhiteTG, XmNvalueChangedCallback,
1720 colorUseCB, (XtPointer)XmCO_BLACK_WHITE);
1723 string = CMPSTR(((char *)GETMESSAGE(14, 35, "Default")));
1724 XtSetArg(args[n], XmNlabelString, string); n++;
1725 widget_list[count++] = colorDialog.defaultTG
1726 = XmCreateToggleButtonGadget(colorUseRC,"defaultTG", args, n);
1727 XmStringFree(string);
1728 XtAddCallback(colorDialog.defaultTG, XmNvalueChangedCallback,
1729 colorUseCB, (XtPointer)DEFAULT_COLOR);
1731 XtManageChildren(widget_list,count);
1732 putDialog (XtParent(style.colorDialog), colorUseDialog);
1735 XtManageChild(colorUseDialog);
1740 ** Process new ColorUse selection
1745 XtPointer client_data,
1746 XtPointer call_data )
1749 XmToggleButtonCallbackStruct *cb =
1750 (XmToggleButtonCallbackStruct *)call_data;
1752 colorDialog.currentColorUse = (int) (intptr_t) client_data;
1753 switch (colorDialog.currentColorUse)
1755 case XmCO_HIGH_COLOR:
1756 colorDialog.currentColorUseStr = HIGH_COLOR_STR;
1759 case XmCO_MEDIUM_COLOR:
1760 colorDialog.currentColorUseStr = MEDIUM_COLOR_STR;
1763 case XmCO_LOW_COLOR:
1764 colorDialog.currentColorUseStr = LOW_COLOR_STR;
1767 case XmCO_BLACK_WHITE:
1768 colorDialog.currentColorUseStr = B_W_STR;
1772 colorDialog.currentColorUseStr = DEFAULT_COLOR_STR;
1782 ** Process callback from the Ok, Cancel and Help pushButtons in the
1783 ** Configure DT Colors DialogBox.
1788 XtPointer client_data,
1789 XtPointer call_data )
1792 char colorUseRes[64];
1793 DtDialogBoxCallbackStruct *cb = (DtDialogBoxCallbackStruct *) call_data;
1795 switch (cb->button_position)
1798 XtCallCallbacks(colorUseDialog, XmNhelpCallback, (XtPointer)NULL);
1803 XtUnmanageChild(colorUseDialog);
1805 if (colorDialog.origColorUse != colorDialog.currentColorUse)
1807 InfoDialog(COLORUSE_WHEN, style.colorDialog, False);
1809 /* create the ColorUse resource spec for xrdb */
1810 /* remove ColorUse specification from database for DEFAULT_COLOR */
1812 sprintf(colorUseRes, "*%d*ColorUse: %s\n",
1813 style.screenNum,colorDialog.currentColorUseStr);
1815 switch (colorDialog.currentColorUse)
1817 case XmCO_MEDIUM_COLOR:
1818 sprintf(colorUseRes+strlen(colorUseRes),
1819 "*HelpColorUse: GRAY_SCALE\n");
1823 case XmCO_LOW_COLOR:
1824 case XmCO_BLACK_WHITE:
1825 sprintf(colorUseRes+strlen(colorUseRes),
1826 "*HelpColorUse: B_W\n");
1830 case XmCO_HIGH_COLOR:
1833 sprintf(colorUseRes+strlen(colorUseRes),
1834 "*HelpColorUse: COLOR\n");
1838 _DtAddToResource(style.display, colorUseRes);
1840 colorDialog.origColorUse = colorDialog.currentColorUse;
1848 XtUnmanageChild(colorUseDialog);
1850 switch (colorDialog.origColorUse)
1852 case XmCO_HIGH_COLOR:
1853 XmToggleButtonGadgetSetState(colorDialog.highColorTG, True, True);
1856 case XmCO_MEDIUM_COLOR:
1857 XmToggleButtonGadgetSetState(colorDialog.mediumColorTG, True, True);
1860 case XmCO_LOW_COLOR:
1861 XmToggleButtonGadgetSetState(colorDialog.lowColorTG, True, True);
1864 case XmCO_BLACK_WHITE:
1865 XmToggleButtonGadgetSetState(colorDialog.blackWhiteTG, True, True);
1869 XmToggleButtonGadgetSetState(colorDialog.defaultTG, True, True);
1879 activateCBexitColor(
1881 XtPointer client_data,
1882 XtPointer call_data )
1884 DtDialogBoxCallbackStruct CancelBut;
1886 if(style.colorDialog != NULL && XtIsManaged(style.colorDialog)) {
1887 CancelBut.button_position = CANCEL_BUTTON;
1888 XtCallCallbacks(style.colorDialog, XmNcallback, &CancelBut);
1895 XtPointer client_data,
1897 XtPointer call_data )
1900 DtWsmRemoveWorkspaceFunctions(style.display, XtWindow(XtParent(w)));
1902 if (!save.restoreFlag)
1903 putDialog ((Widget)client_data, XtParent(w));
1905 XtRemoveCallback(style.colorDialog, XmNmapCallback, _DtmapCB, NULL);
1911 XtPointer client_data,
1913 XtPointer call_data )
1916 char *str_type_return;
1917 XrmValue value_return;
1922 char instanceString[24], nameString[24];
1924 DtWsmRemoveWorkspaceFunctions(style.display, XtWindow(XtParent(w)));
1926 db = XtDatabase(style.display);
1928 /* Get ColorUse value */
1929 sprintf (instanceString, "dtsession*%d*colorUse",style.screenNum);
1930 sprintf (nameString, "Dtsession*%d*ColorUse",style.screenNum);
1932 if (status = XrmGetResource (db, instanceString,
1934 &str_type_return, &value_return))
1936 /* make local copy of string */
1937 string = (char *) XtMalloc( value_return.size );
1938 strcpy (string, value_return.addr);
1940 if (strcmp(string, HIGH_COLOR_STR) == 0)
1942 XmToggleButtonGadgetSetState (colorDialog.highColorTG, True, True);
1943 colorDialog.origColorUse = XmCO_HIGH_COLOR;
1945 else if (strcmp(string, MEDIUM_COLOR_STR) == 0)
1947 XmToggleButtonGadgetSetState (colorDialog.mediumColorTG, True, True);
1948 colorDialog.origColorUse = XmCO_MEDIUM_COLOR;
1950 else if (strcmp(string, LOW_COLOR_STR) == 0)
1952 XmToggleButtonGadgetSetState (colorDialog.lowColorTG, True, True);
1953 colorDialog.origColorUse = XmCO_LOW_COLOR;
1955 else if (strcmp(string, B_W_STR) == 0)
1957 XmToggleButtonGadgetSetState (colorDialog.blackWhiteTG, True, True);
1958 colorDialog.origColorUse = XmCO_BLACK_WHITE;
1962 XmToggleButtonGadgetSetState (colorDialog.defaultTG, True, True);
1963 colorDialog.origColorUse = DEFAULT_COLOR;
1968 else /* ColorUse not specified */
1970 XmToggleButtonGadgetSetState (colorDialog.defaultTG, True, True);
1971 colorDialog.origColorUse = DEFAULT_COLOR;
1974 XtRemoveCallback(colorUseDialog, XmNmapCallback, _DtmapCB_colorUse, NULL);
1977 /************************************************************************
1979 * DeletePaletteFromLinkList - routine used to delete a palette from
1980 * the link list of palettes. The palette which is at the current
1981 * selected_position is the palette that is going to be deleted.
1982 * Special things have to happen if the selected palette is at the
1985 ************************************************************************/
1987 DeletePaletteFromLinkList(
1994 palette *tmp_palette, *tmp2_palette;
1995 palette *selected_palette;
1998 selected_palette = pHeadPalette;
1999 while( selected_palette->item_position != selected_position &&
2000 selected_palette != NULL)
2001 selected_palette = selected_palette->next;
2003 XmListDeletePos (list, selected_palette->item_position);
2005 /* delete item from palette list structure */
2007 /* If the palette is at the head .. remove the head and the next
2008 palette becomes the new selected palette */
2009 if (selected_palette->item_position == 1)
2011 pHeadPalette = selected_palette->next;
2012 tmp_palette = pHeadPalette;
2013 tmp_palette->item_position--;
2014 /* new current palette */
2015 pCurrentPalette = tmp_palette;
2017 else /* find the palette just above the palette to be deleted .. it
2018 will become the new selected palette */
2020 tmp_palette = pHeadPalette;
2021 for (i=1; i < selected_palette->item_position-1; i++)
2022 tmp_palette = tmp_palette->next;
2024 tmp_palette->next = selected_palette->next;
2026 /* what is CurrentPalette now? prev or next item?
2027 special case empty list or NULL entry */
2028 if (tmp_palette->next != NULL)
2029 pCurrentPalette = tmp_palette->next;
2031 pCurrentPalette = tmp_palette;
2034 /* decrement item_positions values in remaining palette entries */
2035 tmp2_palette = tmp_palette;
2036 while ((tmp2_palette = tmp2_palette->next) != NULL)
2038 tmp2_palette->item_position--;
2041 /* go copy the pixel numbers to the new palette */
2042 CopyPixel(selected_palette->color, pCurrentPalette->color,
2043 selected_palette->num_of_colors);
2045 /* select item in list as if user had selected it */
2046 XmListSelectPos (list, tmp_palette->item_position, TRUE);
2047 /* Need to check to see if the first palette is being deleted if it is
2048 need to change colors and update title box */
2049 if(selected_position == tmp_palette->item_position) {
2050 pOldPalette = selected_palette;
2053 string = CMPSTR(pCurrentPalette->desc);
2054 XtSetArg (args[n], XmNtitleString, string); n++;
2055 XtSetValues (colorDialog.buttonsTB, args, n);
2056 XmStringFree(string);
2061 XmListSetBottomPos(paletteList, tmp_palette->item_position);
2062 selected_position = tmp_palette->item_position;
2066 /* deallocate the palette structure */
2067 XtFree(selected_palette->name);
2068 XtFree(selected_palette->desc);
2069 XtFree(selected_palette->directory);
2070 XtFree((char *)selected_palette);
2075 ColorSet srcPixels[XmCO_MAX_NUM_COLORS],
2076 ColorSet dstPixels[XmCO_MAX_NUM_COLORS],
2081 for(i=0; i < numOfColors; i++)
2083 dstPixels[i].bg.pixel = srcPixels[i].bg.pixel;
2084 dstPixels[i].fg.pixel = srcPixels[i].fg.pixel;
2085 dstPixels[i].ts.pixel = srcPixels[i].ts.pixel;
2086 dstPixels[i].bs.pixel = srcPixels[i].bs.pixel;
2087 dstPixels[i].sc.pixel = srcPixels[i].sc.pixel;
2092 SaveOrgPalette( void )
2095 palette *tmp_palette, *tmp2_palette;
2097 if(save.restoreFlag && defaultName_restore[0] != 0) {
2098 tmp_palette = pHeadPalette;
2099 while(tmp_palette->next != NULL )
2100 if(strcmp(tmp_palette->name, defaultName))
2102 tmp_palette = tmp_palette->next;
2108 if(!strcmp(tmp_palette->name, defaultName)) {
2109 tmp2_palette = pCurrentPalette;
2110 pCurrentPalette = tmp_palette;
2116 OrgPalette.item_position = pCurrentPalette->item_position;
2117 OrgPalette.num_of_colors = pCurrentPalette->num_of_colors;
2118 for(i = 0; i < XmCO_MAX_NUM_COLORS; i++)
2120 OrgPalette.primary = pCurrentPalette->primary;
2121 OrgPalette.secondary = pCurrentPalette->secondary;
2122 OrgPalette.active = pCurrentPalette->active;
2123 OrgPalette.inactive = pCurrentPalette->inactive;
2125 if(save.restoreFlag && defaultName_restore[0] != 0)
2126 OrgPalette.color[i].bg.pixel = tmp2_palette->color[i].bg.pixel;
2128 OrgPalette.color[i].bg.pixel = pCurrentPalette->color[i].bg.pixel;
2129 OrgPalette.color[i].bg.red = pCurrentPalette->color[i].bg.red;
2130 OrgPalette.color[i].bg.green = pCurrentPalette->color[i].bg.green;
2131 OrgPalette.color[i].bg.blue = pCurrentPalette->color[i].bg.blue;
2133 if(save.restoreFlag && defaultName_restore[0] != 0)
2134 OrgPalette.color[i].fg.pixel = tmp2_palette->color[i].fg.pixel;
2136 OrgPalette.color[i].fg.pixel = pCurrentPalette->color[i].fg.pixel;
2137 OrgPalette.color[i].fg.red = pCurrentPalette->color[i].fg.red;
2138 OrgPalette.color[i].fg.green = pCurrentPalette->color[i].fg.green;
2139 OrgPalette.color[i].fg.blue = pCurrentPalette->color[i].fg.blue;
2141 if(save.restoreFlag && defaultName_restore[0] != 0)
2142 OrgPalette.color[i].ts.pixel = tmp2_palette->color[i].ts.pixel;
2144 OrgPalette.color[i].ts.pixel = pCurrentPalette->color[i].ts.pixel;
2145 OrgPalette.color[i].ts.red = pCurrentPalette->color[i].ts.red;
2146 OrgPalette.color[i].ts.green = pCurrentPalette->color[i].ts.green;
2147 OrgPalette.color[i].ts.blue = pCurrentPalette->color[i].ts.blue;
2149 if(save.restoreFlag && defaultName_restore[0] != 0)
2150 OrgPalette.color[i].bs.pixel = tmp2_palette->color[i].bs.pixel;
2152 OrgPalette.color[i].bs.pixel = pCurrentPalette->color[i].bs.pixel;
2153 OrgPalette.color[i].bs.red = pCurrentPalette->color[i].bs.red;
2154 OrgPalette.color[i].bs.green = pCurrentPalette->color[i].bs.green;
2155 OrgPalette.color[i].bs.blue = pCurrentPalette->color[i].bs.blue;
2157 if(save.restoreFlag && defaultName_restore[0] != 0)
2158 OrgPalette.color[i].sc.pixel = tmp2_palette->color[i].sc.pixel;
2160 OrgPalette.color[i].sc.pixel = pCurrentPalette->color[i].sc.pixel;
2161 OrgPalette.color[i].sc.red = pCurrentPalette->color[i].sc.red;
2162 OrgPalette.color[i].sc.green = pCurrentPalette->color[i].sc.green;
2163 OrgPalette.color[i].sc.blue = pCurrentPalette->color[i].sc.blue;
2166 if(save.restoreFlag && defaultName_restore[0] != 0)
2167 if(tmp_palette != NULL)
2168 pCurrentPalette = tmp2_palette;
2173 RestoreOrgPalette( void )
2176 palette *tmp_palette;
2178 XColor colors[XmCO_MAX_NUM_COLORS * 5];
2180 tmp_palette = pHeadPalette;
2181 while ( tmp_palette != NULL &&
2182 tmp_palette->item_position != OrgPalette.item_position )
2183 tmp_palette = tmp_palette->next;
2185 if ( tmp_palette != NULL &&
2186 tmp_palette->item_position == OrgPalette.item_position)
2188 pCurrentPalette = tmp_palette;
2189 OrgPalette.num_of_colors = pCurrentPalette->num_of_colors;
2190 for(i = 0; i < XmCO_MAX_NUM_COLORS; i++)
2192 pCurrentPalette->primary = OrgPalette.primary;
2193 pCurrentPalette->secondary = OrgPalette.secondary;
2194 pCurrentPalette->inactive = OrgPalette.inactive;
2195 pCurrentPalette->active = OrgPalette.active;
2197 pCurrentPalette->color[i].bg.pixel = OrgPalette.color[i].bg.pixel;
2198 pCurrentPalette->color[i].bg.red = OrgPalette.color[i].bg.red;
2199 pCurrentPalette->color[i].bg.green = OrgPalette.color[i].bg.green;
2200 pCurrentPalette->color[i].bg.blue = OrgPalette.color[i].bg.blue;
2201 if(i < OrgPalette.num_of_colors && TypeOfMonitor != XmCO_BLACK_WHITE)
2202 colors[j++] = pCurrentPalette->color[i].bg;
2204 pCurrentPalette->color[i].sc.pixel = OrgPalette.color[i].sc.pixel;
2205 pCurrentPalette->color[i].sc.red = OrgPalette.color[i].sc.red;
2206 pCurrentPalette->color[i].sc.green = OrgPalette.color[i].sc.green;
2207 pCurrentPalette->color[i].sc.blue = OrgPalette.color[i].sc.blue;
2208 if(i < OrgPalette.num_of_colors && TypeOfMonitor != XmCO_BLACK_WHITE)
2209 colors[j++] = pCurrentPalette->color[i].sc;
2211 pCurrentPalette->color[i].fg.pixel = OrgPalette.color[i].fg.pixel;
2212 pCurrentPalette->color[i].fg.red = OrgPalette.color[i].fg.red;
2213 pCurrentPalette->color[i].fg.green = OrgPalette.color[i].fg.green;
2214 pCurrentPalette->color[i].fg.blue = OrgPalette.color[i].fg.blue;
2215 if(i < OrgPalette.num_of_colors && TypeOfMonitor != XmCO_BLACK_WHITE)
2216 if(FgColor == DYNAMIC)
2217 colors[j++] = pCurrentPalette->color[i].fg;
2219 pCurrentPalette->color[i].ts.pixel = OrgPalette.color[i].ts.pixel;
2220 pCurrentPalette->color[i].ts.red = OrgPalette.color[i].ts.red;
2221 pCurrentPalette->color[i].ts.green = OrgPalette.color[i].ts.green;
2222 pCurrentPalette->color[i].ts.blue = OrgPalette.color[i].ts.blue;
2223 if(i < OrgPalette.num_of_colors && TypeOfMonitor != XmCO_BLACK_WHITE)
2224 if(UsePixmaps == FALSE)
2225 colors[j++] = pCurrentPalette->color[i].ts;
2227 pCurrentPalette->color[i].bs.pixel = OrgPalette.color[i].bs.pixel;
2228 pCurrentPalette->color[i].bs.red = OrgPalette.color[i].bs.red;
2229 pCurrentPalette->color[i].bs.green = OrgPalette.color[i].bs.green;
2230 pCurrentPalette->color[i].bs.blue = OrgPalette.color[i].bs.blue;
2231 if(i < OrgPalette.num_of_colors && TypeOfMonitor != XmCO_BLACK_WHITE)
2232 if(UsePixmaps == FALSE)
2233 colors[j++] = pCurrentPalette->color[i].bs;
2237 if (style.dynamicColor)
2238 XStoreColors (style.display, style.colormap, colors, j);
2240 XmListSelectPos (paletteList, OrgPalette.item_position, TRUE);
2241 XmListSetBottomPos(paletteList, OrgPalette.item_position);
2247 UpdateDefaultPalette( void )
2250 char temp[XmCO_MAX_NUM_COLORS][60];
2251 char xrdb_string[100];
2252 XColor saved_color[2];
2254 for(i = 0; i < XmCO_MAX_NUM_COLORS; i++)
2256 /* put the colors of the palette in the form #RRRRGGGGBBBB */
2257 if(TypeOfMonitor == XmCO_LOW_COLOR && (i == 0 || i == 1))
2258 sprintf(temp[i],"#%04x%04x%04x\n", saved_color[i].red,
2259 saved_color[i].green,
2260 saved_color[i].blue);
2261 else if(TypeOfMonitor == XmCO_LOW_COLOR && i == 2)
2262 sprintf(temp[i],"#%04x%04x%04x\n",pCurrentPalette->color[1].bg.red,
2263 pCurrentPalette->color[1].bg.green,
2264 pCurrentPalette->color[1].bg.blue);
2265 else if(TypeOfMonitor == XmCO_LOW_COLOR && i == 3)
2266 sprintf(temp[i],"#%04x%04x%04x\n",pCurrentPalette->color[0].bg.red,
2267 pCurrentPalette->color[0].bg.green,
2268 pCurrentPalette->color[0].bg.blue);
2270 sprintf(temp[i],"#%04x%04x%04x\n",pCurrentPalette->color[i].bg.red,
2271 pCurrentPalette->color[i].bg.green,
2272 pCurrentPalette->color[i].bg.blue);
2275 /* update the resource manager property with the palette resource */
2276 if (TypeOfMonitor == XmCO_BLACK_WHITE)
2278 sprintf(xrdb_string, "*%d*MonochromePalette: %s%s\n",
2279 style.screenNum, pCurrentPalette->name, PALETTE_SUFFIX);
2283 sprintf(xrdb_string, "*%d*ColorPalette: %s%s\n",
2284 style.screenNum, pCurrentPalette->name, PALETTE_SUFFIX);
2286 _DtAddToResource(style.display, xrdb_string);
2288 /* update the defaultName */
2289 XtFree(defaultName);
2290 defaultName = (char *)XtMalloc(strlen(pCurrentPalette->name)+1);
2291 strcpy(defaultName, pCurrentPalette->name);
2294 /* update Xrdb for non Motif1.1 clients */
2295 if (style.xrdb.writeXrdbColors)
2298 OWsyncColorResources(style.display, TypeOfMonitor,
2299 pCurrentPalette->color);
2301 int chipnum = TypeOfMonitor == XmCO_HIGH_COLOR ? 4 : 1;
2302 sprintf(xrdb_string,
2303 "*background: #%04X%04X%04X\n*foreground: #%04X%04X%04X\n",
2304 pCurrentPalette->color[chipnum].bg.red,
2305 pCurrentPalette->color[chipnum].bg.green,
2306 pCurrentPalette->color[chipnum].bg.blue,
2307 pCurrentPalette->color[chipnum].fg.red,
2308 pCurrentPalette->color[chipnum].fg.green,
2309 pCurrentPalette->color[chipnum].fg.blue);
2310 _DtAddToResource(style.display, xrdb_string);
2320 XtPointer client_data,
2324 unsigned long *length,
2329 style.colorSrv = True;
2332 if((intptr_t) client_data == GET_TYPE_MONITOR)
2334 sscanf ((char *)value, "%x_%x_%x_%x", (unsigned int *) &(TypeOfMonitor),
2335 (unsigned int *) &(UsePixmaps), (unsigned int *) &(FgColor), (unsigned int *) &dynamic_color);
2336 if(dynamic_color == FALSE)
2337 style.dynamicColor = False;
2339 style.dynamicColor = True;
2342 WaitSelection = FALSE;
2345 else /* no response from Color Server - it must not be there */
2347 style.colorSrv = False;
2348 WaitSelection = FALSE;
2352 /************************************************************************
2355 * restore any state information saved with saveBackdrop.
2356 * This is called from restoreSession with the application
2357 * shell and the special xrm database retrieved for restore.
2358 ************************************************************************/
2364 XrmName xrm_name[5];
2365 XrmRepresentation rep_type;
2367 palette *tmp_palette;
2369 /*"paletteDlg" is the resource name of the dialog shell we are saving for.*/
2370 xrm_name [0] = XrmStringToQuark (PALETTEDLG);
2373 /* get x position */
2374 xrm_name [1] = XrmStringToQuark ("x");
2375 if (XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value)){
2376 XtSetArg (save.posArgs[save.poscnt], XmNx, atoi((char *)value.addr)); save.poscnt++;
2379 /* get y position */
2380 xrm_name [1] = XrmStringToQuark ("y");
2381 if (XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value)){
2382 XtSetArg (save.posArgs[save.poscnt], XmNy, atoi((char *)value.addr)); save.poscnt++;
2385 /* get selected palette */
2386 xrm_name [1] = XrmStringToQuark ("selected_palette");
2387 if (XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value)){
2388 strcpy(defaultName_restore, value.addr);
2391 defaultName_restore[0] = 0;
2393 /* get selected button */
2394 xrm_name [1] = XrmStringToQuark ("selected_button");
2395 if (XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value)){
2396 selected_button = atoi((char *)value.addr);
2399 /* need to have some variables initialized before creating the
2400 Color's dialog ... */
2402 CheckMonitor(shell);
2403 GetDefaultPal(shell);
2405 xrm_name [1] = XrmStringToQuark ("ismapped");
2406 XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value);
2407 /* Are we supposed to be mapped? */
2408 if (strcmp(value.addr, "True") == 0) {
2409 save.restoreFlag = True;
2415 /************************************************************************
2418 * This routine will write out to the passed file descriptor any state
2419 * information this dialog needs. It is called from saveSessionCB with the
2420 * file already opened.
2421 * All information is saved in xrm format. There is no restriction
2422 * on what can be saved. It doesn't have to be defined or be part of any
2423 * widget or Xt definition. Just name and save it here and recover it in
2424 * restoreBackdrop. The suggested minimum is whether you are mapped, and your
2426 ************************************************************************/
2432 char *bufr = style.tmpBigStr; /* size=[1024], make bigger if needed */
2433 XmVendorShellExtObject vendorExt;
2434 XmWidgetExtData extData;
2436 if (style.colorDialog != NULL)
2438 if (XtIsManaged(style.colorDialog))
2439 sprintf(bufr, "*paletteDlg.ismapped: True\n");
2441 sprintf(bufr, "*paletteDlg.ismapped: False\n");
2443 /* Get and write out the geometry info for our Window */
2444 x = XtX(XtParent(style.colorDialog));
2445 y = XtY(XtParent(style.colorDialog));
2447 /* Modify x & y to take into account window mgr frames
2448 * This is pretty bogus, but I don't know a better way to do it.
2450 extData = _XmGetWidgetExtData(style.shell, XmSHELL_EXTENSION);
2451 vendorExt = (XmVendorShellExtObject)extData->widget;
2452 x -= vendorExt->vendor.xOffset;
2453 y -= vendorExt->vendor.yOffset;
2455 sprintf(bufr, "%s*paletteDlg.x: %d\n", bufr, x);
2456 sprintf(bufr, "%s*paletteDlg.y: %d\n", bufr, y);
2457 sprintf(bufr, "%s*paletteDlg.selected_palette: %s\n", bufr,
2458 pCurrentPalette->name);
2459 sprintf(bufr, "%s*paletteDlg.selected_button: %d\n", bufr,
2461 if(-1 == write (fd, bufr, strlen(bufr))) {
2462 perror(strerror(errno));
2467 /**************************************************************************
2469 * SameName - procedure used by the Add palette .. if the palette desc the
2470 * user selects is the same name as a palette already in the
2471 * linked list this procedure gets called. It set up a
2472 * Warning dialog asking the user if they really want to add
2473 * a palette with the same name as an existing palette.
2475 **************************************************************************/
2479 palette *tmpPalette,
2486 if (colorDialog.dlg == NULL) {
2487 tmpStr = (char *)XtMalloc(strlen(STR1) + strlen(name) + 1);
2488 sprintf(tmpStr, STR1, name);
2489 XtSetArg(args[n], XmNmessageString, CMPSTR(tmpStr)); n++;
2490 XtSetArg(args[n], XmNokLabelString, CMPSTR((String) _DtOkString)); n++;
2491 XtSetArg(args[n], XmNcancelLabelString, CMPSTR((String) _DtCancelString)); n++;
2492 XtSetArg(args[n], XmNhelpLabelString, CMPSTR((String) _DtHelpString)); n++;
2493 XtSetArg(args[n], XmNmwmFunctions, DIALOG_MWM_FUNC ); n++;
2494 XtSetArg(args[n], XmNdialogTitle, CMPSTR(((char *)GETMESSAGE(14, 21, "Warning")))); n++;
2495 colorDialog.dlg = XmCreateWarningDialog(style.colorDialog, "QNotice", args, n);
2496 XtAddCallback(colorDialog.dlg, XmNokCallback, setDlgOkCB, (XtPointer)tmpPalette);
2497 XtAddCallback(colorDialog.dlg, XmNhelpCallback,
2498 (XtCallbackProc)HelpRequestCB, (XtPointer)HELP_ADD_PALETTE_WARNING_DIALOG);
2501 XtSetArg (args[n], XmNmwmInputMode,
2502 MWM_INPUT_PRIMARY_APPLICATION_MODAL); n++;
2503 XtSetValues (XtParent(colorDialog.dlg), args, n);
2506 XtManageChild(colorDialog.dlg);
2509 /****************************************************************************
2511 * ValidName - procedure which checks to make sure the name being passed
2512 * in is a valid filename. Weeds out many of the non
2513 * alphabit characters.
2515 ***************************************************************************/
2521 Boolean valid = True;
2526 if (!name || strlen(name) == 0)
2532 chlen = mblen (&name[0], MB_CUR_MAX);
2533 for (i = 0; (i < strlen(name)) && chlen && valid; i += chlen)
2535 chlen = mblen (&name[i], MB_CUR_MAX);
2537 ((name[i] == '*') ||
2539 (name[i] == '\\') ||
2557 for (i = 0; (i < strlen(name)) && valid; i++)
2559 if (strchr ("|!(){}[]<>*:\"\\", (int) name[i]))
2569 InitializeAtoms( void )
2573 sprintf(cust_str,"%s%d", XmSCUSTOMIZE_DATA, style.screenNum);
2574 XA_CUSTOMIZE = XInternAtom(style.display, cust_str, FALSE);
2575 XA_TYPE_MONITOR = XInternAtom(style.display, TYPE_OF_MONITOR, FALSE);
2576 XA_WM_DELETE_WINDOW = XInternAtom(style.display, "WM_DELETE_WINDOW", False);
2583 char *str_type_return;
2584 XrmValue value_return;
2589 char instanceName[30], instanceClass[30];
2591 /* get the current default palette from the Reource Manager Property */
2593 db = XtDatabase(style.display);
2595 if (TypeOfMonitor == XmCO_BLACK_WHITE)
2597 sprintf(instanceName,"dtsession.%d.monochromePalette", style.screenNum);
2598 sprintf(instanceClass,"Dtsession.%d.MonochromePalette", style.screenNum);
2602 sprintf(instanceName,"dtsession.%d.colorPalette", style.screenNum);
2603 sprintf(instanceClass,"Dtsession.%d.ColorPalette", style.screenNum);
2606 if (status = XrmGetResource (db, instanceName, instanceClass,
2607 &str_type_return, &value_return))
2609 /* copy string to defaultName */
2610 defaultName = (char *) XtMalloc( value_return.size );
2611 strcpy (defaultName, value_return.addr);
2612 p = strstr (defaultName, PALETTE_SUFFIX);
2617 /* set defaultName to default palette */
2618 defaultName = (char *) XtMalloc( strlen(DEFAULT_PALETTE));
2619 strcpy (defaultName, DEFAULT_PALETTE);
2627 XmString button_string[NUM_LABELS];
2635 /* Get the default value of multiclick */
2636 dclick_time = XtGetMultiClickTime(style.display);
2639 if(!XtIsRealized(parent))
2640 XtRealizeWidget(parent);
2642 /* Set up DialogBox button labels. */
2643 button_string[0] = CMPSTR((String) _DtOkString);
2644 button_string[1] = CMPSTR((String) _DtCancelString);
2645 button_string[2] = CMPSTR((String) _DtHelpString);
2648 * Note that save.poscnt has been initialized elsewhere.
2649 * save.posArgs may contain information from restoreColor().*/
2651 XtSetArg (save.posArgs[save.poscnt], XmNchildType, XmWORK_AREA); save.poscnt++;
2652 XtSetArg (save.posArgs[save.poscnt], XmNbuttonCount, NUM_LABELS); save.poscnt++;
2653 XtSetArg (save.posArgs[save.poscnt], XmNbuttonLabelStrings, button_string); save.poscnt++;
2654 XtSetArg (save.posArgs[save.poscnt], XmNdefaultPosition, False); save.poscnt++;
2655 style.colorDialog = __DtCreateDialogBoxDialog(parent,PALETTEDLG, save.posArgs, save.poscnt);
2656 XtAddCallback(style.colorDialog, XmNcallback, dialogBoxCB, NULL);
2657 XtAddCallback(style.colorDialog, XmNmapCallback, _DtmapCB, parent);
2658 XtAddCallback(style.colorDialog, XmNhelpCallback,
2659 (XtCallbackProc)HelpRequestCB, (XtPointer)HELP_COLOR_DIALOG);
2661 XmStringFree(button_string[0]);
2662 XmStringFree(button_string[1]);
2663 XmStringFree(button_string[2]);
2665 w = _DtDialogBoxGetButton(style.colorDialog,2);
2667 XtSetArg(args[n], XmNautoUnmanage, False); n++;
2668 XtSetArg(args[n], XmNcancelButton, w); n++;
2669 XtSetValues (style.colorDialog, args, n);
2675 AddToDialogBox( void )
2684 XtSetArg (args[n], XmNtitle, ((char *)GETMESSAGE(14, 30, "Style Manager - Color"))); n++;
2685 XtSetArg (args[n], XmNuseAsyncGeometry, True); n++;
2686 XtSetArg (args[n], XmNmwmFunctions, DIALOG_MWM_FUNC); n++;
2687 XtSetValues (XtParent(style.colorDialog), args, n);
2689 /* Add save session property to the main window */
2690 XmAddWMProtocolCallback(XtParent(style.colorDialog),
2691 XA_WM_DELETE_WINDOW, activateCBexitColor, NULL);
2694 ** Create a main form for color dialog
2697 XtSetArg(args[n], XmNhorizontalSpacing, style.horizontalSpacing); n++;
2698 XtSetArg(args[n], XmNverticalSpacing, style.verticalSpacing); n++;
2699 colorDialog.colorForm = XmCreateForm(style.colorDialog, "colorForm", args, n);
2700 XtManageChild(colorDialog.colorForm);
2706 CreateTopColor1( void )
2715 ** titlebox as child of the main form
2718 XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
2719 XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
2720 XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
2721 XtSetArg (args[n], XmNmarginWidth, 0); n++;
2722 XtSetArg (args[n], XmNmarginHeight, 0); n++;
2723 string = CMPSTR(((char *)GETMESSAGE(14, 5, "Palettes")));
2724 XtSetArg (args[n], XmNtitleString, string); n++;
2725 colorDialog.paletteTB = _DtCreateTitleBox(colorDialog.colorForm, "paletteTB", args, n);
2726 XtManageChild(colorDialog.paletteTB);
2727 XmStringFree(string);
2730 ** Create a form inside palette titlebox
2733 XtSetArg(args[n], XmNhorizontalSpacing, style.horizontalSpacing); n++;
2734 XtSetArg(args[n], XmNverticalSpacing, style.verticalSpacing); n++;
2735 colorDialog.palettesForm = XmCreateForm(colorDialog.paletteTB, "palettesForm", args, n);
2736 XtManageChild(colorDialog.palettesForm);
2742 CreateTopColor2( void )
2750 ** Create a scrolled list widget. This widget will contain the list of
2751 ** palettes currently loaded (by ReadPalettes) in the customizer.
2754 XtSetArg (args[n], XmNselectionPolicy, XmBROWSE_SELECT); n++;
2755 XtSetArg (args[n], XmNautomaticSelection, True); n++;
2756 XtSetArg (args[n], XmNvisibleItemCount, 6); n++;
2757 paletteList = XmCreateScrolledList(colorDialog.palettesForm,"paletteList",args,n);
2758 XtAddCallback(paletteList, XmNbrowseSelectionCallback,
2759 selectPaletteCB, NULL);
2762 XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
2763 XtSetArg (args[n], XmNtopOffset, style.horizontalSpacing); n++;
2764 XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
2765 XtSetArg (args[n], XmNleftOffset, style.horizontalSpacing); n++;
2766 XtSetArg (args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
2767 XtSetArg (args[n], XmNrightPosition, 60); n++;
2768 XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
2769 XtSetValues (XtParent(paletteList), args, n);
2775 CreateBottomColor( void )
2780 Widget addDeleteForm;
2783 colorDialog.dlg = NULL;
2785 if(style.count > 10)
2788 if(TypeOfMonitor != XmCO_BLACK_WHITE)
2790 /* Create form for Add and Delete buttons */
2792 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
2793 XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
2794 XtSetArg(args[n], XmNleftWidget, paletteList); n++;
2795 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
2796 XtSetArg(args[n], XmNrightOffset, 0); n++;
2797 XtSetArg(args[n], XmNhorizontalSpacing, style.horizontalSpacing); n++;
2798 XtSetArg(args[n], XmNverticalSpacing, style.verticalSpacing); n++;
2799 XtSetArg(args[n], XmNallowOverlap, False); n++;
2800 XtSetArg(args[n], XmNchildType, XmWORK_AREA); n++;
2802 XmCreateForm(colorDialog.palettesForm, "addDeleteForm", args, n);
2803 XtManageChild(addDeleteForm);
2805 /* Create Add button */
2807 XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
2808 XtSetArg (args[n], XmNtopOffset, ADD_PALETTE_TOP_OFFSET); n++;
2809 XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
2810 XtSetArg (args[n], XmNleftOffset, style.horizontalSpacing); n++;
2811 XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
2812 string = CMPSTR(((char *)GETMESSAGE(14, 6, "Add...")));
2813 XtSetArg (args[n], XmNlabelString, string); n++;
2814 colorDialog.addPaletteButton =
2815 XmCreatePushButtonGadget(addDeleteForm, "addPalette", args, n);
2816 XmStringFree(string);
2817 XtManageChild(colorDialog.addPaletteButton);
2818 XtAddCallback(colorDialog.addPaletteButton, XmNactivateCallback, addPaletteCB,
2821 /* Create Delete button */
2823 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
2824 XtSetArg (args[n], XmNtopWidget, colorDialog.addPaletteButton); n++;
2825 XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
2826 XtSetArg (args[n], XmNleftOffset, style.horizontalSpacing); n++;
2827 XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
2828 string = CMPSTR(((char *)GETMESSAGE(14, 7, "Delete...")));
2829 XtSetArg (args[n], XmNlabelString, string); n++;
2830 colorDialog.deletePaletteButton =
2831 XmCreatePushButtonGadget(addDeleteForm,"deletePalette",args,n);
2832 XmStringFree(string);
2833 XtManageChild(colorDialog.deletePaletteButton);
2834 XtAddCallback(colorDialog.deletePaletteButton, XmNactivateCallback, deletePaletteCB,
2839 ** Create a title box for palette color buttons
2842 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
2843 XtSetArg (args[n], XmNtopWidget, colorDialog.paletteTB); n++;
2844 XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
2845 XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
2846 XtSetArg (args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
2847 XtSetArg (args[n], XmNmarginWidth, 0); n++;
2848 XtSetArg (args[n], XmNmarginHeight, 0); n++;
2849 string = CMPSTR(pCurrentPalette->desc);
2850 XtSetArg (args[n], XmNtitleString, string); n++;
2851 colorDialog.buttonsTB = _DtCreateTitleBox(colorDialog.colorForm, "ButtonsTB", args, n);
2852 XtManageChild(colorDialog.buttonsTB);
2853 XmStringFree(string);
2855 /* Create a form inside palette buttons titlebox */
2857 XtSetArg(args[n], XmNhorizontalSpacing, style.horizontalSpacing); n++;
2858 XtSetArg(args[n], XmNverticalSpacing, style.verticalSpacing); n++;
2859 style.buttonsForm = XmCreateForm(colorDialog.buttonsTB, "buttonsForm", args, n);
2860 XtManageChild(style.buttonsForm);
2862 /* Create Modify... button */
2863 if(TypeOfMonitor != XmCO_BLACK_WHITE)
2866 XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
2867 XtSetArg (args[n], XmNtopOffset, style.horizontalSpacing+BORDER_WIDTH); n++;
2868 XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
2869 XtSetArg (args[n], XmNleftPosition, ADD_PALETTE_LEFT_POSITION); n++;
2870 XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
2871 string = CMPSTR(((char *)GETMESSAGE(14, 8, "Modify...")));
2872 XtSetArg (args[n], XmNlabelString, string); n++;
2874 XmCreatePushButtonGadget(style.buttonsForm, "modifyColorButton", args, n);
2875 XmStringFree(string);
2876 XtManageChild(modifyColorButton);
2877 XtAddCallback(modifyColorButton, XmNactivateCallback, modifyColorCB,
2881 ** Create a pushbutton for configuring DT colors
2884 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
2885 XtSetArg (args[n], XmNtopWidget, colorDialog.buttonsTB); n++;
2886 XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
2887 XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
2888 XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
2889 XtSetArg (args[n], XmNnavigationType, XmTAB_GROUP); n++;
2890 string = CMPSTR(((char *)GETMESSAGE(14, 40, "Number Of Colors...")));
2891 XtSetArg (args[n], XmNlabelString, string); n++;
2892 resourcesPB = XmCreatePushButtonGadget(colorDialog.colorForm, "resourcesPB", args, n);
2893 XtManageChild(resourcesPB);
2894 XtAddCallback(resourcesPB, XmNactivateCallback, resourcesCB,
2895 (XtPointer) style.colorDialog);
2896 XmStringFree(string);