/***************************************************************************** FILE : $Source: /projects/higgs1/SNNS/CVS/SNNS/xgui/sources/ui_colEdit.c,v $ SHORTNAME : colEdit.c SNNS VERSION : 4.2 PURPOSE : functions to manipulate the text, background and selection color NOTES : uses the fixed palette defined in ui_color.c AUTHOR : Ralf Huebner DATE : 27.5.1992 CHANGED BY : RCS VERSION : $Revision: 2.9 $ LAST CHANGE : $Date: 1998/03/03 14:10:13 $ Copyright (c) 1990-1995 SNNS Group, IPVR, Univ. Stuttgart, FRG Copyright (c) 1996-1998 SNNS Group, WSI, Univ. Tuebingen, FRG ******************************************************************************/ #include #include #include #include #include #include #include #include #include #include #include #include "ui.h" #include "ui_xWidgets.h" #include "ui_color.h" #include "ui_mainP.h" #include "ui_main.h" #include "ui_colEdit.ph" /***************************************************************************** FUNCTION : ui_cancelColorEditPannel PURPOSE : callback if the cancel button is pressed RETURNS : void NOTES : closes the pannel UPDATE : ******************************************************************************/ static void ui_cancelColorEditPannel (Widget w,Widget pannel,caddr_t call_data) { XtDestroyWidget (pannel); } /***************************************************************************** FUNCTION : ui_closeColorEditPannel PURPOSE : sets the selected colors in the current display RETURNS : void NOTES : UPDATE : ******************************************************************************/ static void ui_closeColorEditPannel (Widget w, Widget pannel, caddr_t call_data) { (ui_set_displayPtr->setup).backgroundColorIndex = ui_currentBackCol; (ui_set_displayPtr->setup).selectionColorIndex = ui_currentSelCol; (ui_set_displayPtr->setup).textColorIndex = ui_currentTextCol; XtDestroyWidget (pannel); } /***************************************************************************** FUNCTION : ui_getDisplayColors PURPOSE : reads the color indices out of the display RETURNS : void NOTES : UPDATE : ******************************************************************************/ static void ui_getDisplayColors (void) { ui_currentBackCol = (ui_set_displayPtr->setup).backgroundColorIndex; ui_currentSelCol = (ui_set_displayPtr->setup).selectionColorIndex; ui_currentTextCol = (ui_set_displayPtr->setup).textColorIndex; } /***************************************************************************** FUNCTION : ui_xCreateColButtonItem PURPOSE : creates a widget for a color button RETURNS : Widget NOTES : the color is defined in pixel UPDATE : ******************************************************************************/ static Widget ui_xCreateColButtonItem (Widget parent, unsigned long pixel, int xsize, int ysize, Widget left, Widget top) { Cardinal n; Widget w; Arg args[15]; n = 0; XtSetArg(args[n], XtNinternalHeight, 1); n++; XtSetArg(args[n], XtNinternalWidth , 1); n++; XtSetArg(args[n], XtNfromVert , top); n++; XtSetArg(args[n], XtNfromHoriz, left); n++; XtSetArg(args[n], XtNleft , XtChainLeft); n++; XtSetArg(args[n], XtNright , XtChainLeft); n++; XtSetArg(args[n], XtNtop , XtChainTop); n++; XtSetArg(args[n], XtNbottom, XtChainTop); n++; XtSetArg(args[n], XtNwidth, xsize); n++; XtSetArg(args[n], XtNheight, ysize); n++; XtSetArg(args[n], XtNbackground, pixel); n++; w = XtCreateManagedWidget("", commandWidgetClass, parent, args, n); return(w); } /***************************************************************************** FUNCTION : ui_createColWidgets PURPOSE : creates the widgets for all colors RETURNS : void NOTES : UPDATE : ******************************************************************************/ static void ui_createColWidgets (Widget parent) { Widget top, left; unsigned long pixel; int i, ix, iy; for (i=0; itype == Expose) AND (event->xexpose.count == 0)) ui_redrawColorWindow(); } /***************************************************************************** FUNCTION : ui_selectColorItemProc PURPOSE : toggles the specified button RETURNS : void NOTES : ******************************************************************************/ static void ui_selectColorItemProc (Widget w, int value, caddr_t call_data) { ui_setToggles(value, ¤tSelection, noOfColToggles, colorToggle); } /***************************************************************************** FUNCTION : ui_createColorEditPannel PURPOSE : creates the color edit pannel RETURNS : void NOTES : UPDATE : ******************************************************************************/ void ui_createColorEditPannel (Widget w, Widget button, caddr_t call_data) { int n, i; Arg arg[10]; Position xPos, yPos; Dimension width, height; Widget colEditPannel, pannel, border, done; Widget cancel, colframe, testPannel; n = 0; XtSetArg (arg[0], XtNwidth, &width); n++; XtSetArg (arg[1], XtNheight, &height); n++; XtGetValues (button, arg, (unsigned int) n); XtTranslateCoords (button, (Position) (width / 2), (Position) (height / 2), &xPos, &yPos); n = 0; XtSetArg(arg[n], XtNx, xPos); n++; XtSetArg(arg[n], XtNy, yPos); n++; colEditPannel = XtCreatePopupShell ("color edit", transientShellWidgetClass, button, arg, (unsigned int) n); border = XtCreateManagedWidget("border", boxWidgetClass, colEditPannel, NULL, ZERO); pannel = XtCreateManagedWidget("pannel", formWidgetClass, border, NULL, ZERO); colframe = XtCreateManagedWidget("colframe", formWidgetClass, pannel, NULL, ZERO); ui_createColWidgets (colframe); done = ui_xCreateButtonItem ("done", border, NULL, NULL); cancel = ui_xCreateButtonItem ("cancel", border, NULL, done); colorToggle[0] = ui_xCreateToggleItem ("text", pannel, NULL, NULL, colframe); colorToggle[1] = ui_xCreateToggleItem ("background", pannel, NULL, NULL, colorToggle[0]); colorToggle[2] = ui_xCreateToggleItem ("selection", pannel, NULL, NULL, colorToggle[1]); ui_getDisplayColors(); testPannel = ui_createTestPannel(pannel, colorToggle[0], colframe); XtAddCallback (done, XtNcallback, (XtCallbackProc) ui_closeColorEditPannel, (caddr_t) colEditPannel); XtAddCallback (cancel, XtNcallback, (XtCallbackProc) ui_cancelColorEditPannel, (caddr_t) colEditPannel); XtAddCallback (colorToggle[0], XtNcallback, (XtCallbackProc) ui_selectColorItemProc, (caddr_t) UI_SELECT_TEXT_COLOR); XtAddCallback (colorToggle[1], XtNcallback, (XtCallbackProc) ui_selectColorItemProc, (caddr_t) UI_SELECT_BACK_COLOR); XtAddCallback (colorToggle[2], XtNcallback, (XtCallbackProc) ui_selectColorItemProc, (caddr_t) UI_SELECT_SEL_COLOR); for (i=0; ifid); XtAppAddTimeOut (ui_appContext, 1000L, (XtTimerCallbackProc) ui_timerProc, NULL); }