static XawTextProperty * _XawTextSinkAddProperty(XawTextPropertyList *list, XawTextProperty *property, Bool replace) { XawTextProperty *result; XColor color; char identifier[1024]; char foreground[16]; char background[16]; char *foundry, *family, *weight, *slant, *setwidth, *addstyle, *pixel_size, *point_size, *res_x, *res_y, *spacing, *avgwidth, *registry, *encoding; char *xlfd; static char *asterisk = "*", *null = ""; XrmQuark quark; if (list == NULL || property == NULL) return (NULL); if (property->mask & XAW_TPROP_FOREGROUND) { color.pixel = property->foreground; XQueryColor(DisplayOfScreen(list->screen), list->colormap, &color); XmuSnprintf(foreground, sizeof(foreground), "%04x%04x%04x", color.red, color.green, color.blue); } else strcpy(foreground, asterisk); if (property->mask & XAW_TPROP_BACKGROUND) { color.pixel = property->background; XQueryColor(DisplayOfScreen(list->screen), list->colormap, &color); XmuSnprintf(background, sizeof(background), "%04x%04x%04x", color.red, color.green, color.blue); } else strcpy(background, asterisk); if (property->xlfd_mask & XAW_TPROP_FOUNDRY) foundry = XrmQuarkToString(property->foundry); else foundry = asterisk; /* use default, or what was requested */ if (property->family != NULLQUARK) family = XrmQuarkToString(property->family); else family = asterisk; if (property->weight != NULLQUARK) weight = XrmQuarkToString(property->weight); else weight = asterisk; if (property->slant != NULLQUARK) { slant = XrmQuarkToString(property->slant); if (toupper(*slant) != 'R') slant = asterisk; /* X defaults to italics, so, don't care in resolving between `I' and `O' */ } else slant = asterisk; if (property->xlfd_mask & XAW_TPROP_SETWIDTH) setwidth = XrmQuarkToString(property->setwidth); else setwidth = asterisk; if (property->xlfd_mask & XAW_TPROP_ADDSTYLE) addstyle = XrmQuarkToString(property->addstyle); else addstyle = null; /* use default, or what was requested */ if (!(property->mask & XAW_TPROP_POINTSIZE) && property->pixel_size != NULLQUARK) pixel_size = XrmQuarkToString(property->pixel_size); else pixel_size = asterisk; if (property->xlfd_mask & XAW_TPROP_POINTSIZE) point_size = XrmQuarkToString(property->point_size); else point_size = asterisk; if (property->xlfd_mask & XAW_TPROP_RESX) res_x = XrmQuarkToString(property->res_x); else res_x = asterisk; if (property->xlfd_mask & XAW_TPROP_RESY) res_y = XrmQuarkToString(property->res_y); else res_y = asterisk; if (property->xlfd_mask & XAW_TPROP_SPACING) spacing = XrmQuarkToString(property->spacing); else spacing = asterisk; if (property->xlfd_mask & XAW_TPROP_AVGWIDTH) avgwidth = XrmQuarkToString(property->avgwidth); else avgwidth = asterisk; /* use default, or what that was requested */ if (property->registry != NULLQUARK) registry = XrmQuarkToString(property->registry); else registry = asterisk; if (property->encoding != NULLQUARK) encoding = XrmQuarkToString(property->encoding); else encoding = asterisk; if (replace) { result = XtNew(XawTextProperty); memcpy(result, property, sizeof(XawTextProperty)); } else result = property; /* XXX should do the best to load a suitable font here */ if (!(result->mask & XAW_TPROP_FONT)) { XmuSnprintf(identifier, sizeof(identifier), "-%s-%s-%s-%s-%s-%s-%s-%s-%s-%s-%s-%s-%s-%s", foundry, family, weight, slant, setwidth, addstyle, pixel_size, point_size, res_x, res_y, spacing, avgwidth, registry, encoding); if ((result->font = XLoadQueryFont(DisplayOfScreen(list->screen), identifier)) != NULL) { result->mask |= XAW_TPROP_FONT; SetXlfdDefaults(DisplayOfScreen(list->screen), result); } else result->mask &= ~XAW_TPROP_FONT; } if (result->font) xlfd = XrmQuarkToString(result->xlfd); else xlfd = null; XmuSnprintf(identifier, sizeof(identifier), "%08lx%08lx%s%s%d%d%d%d%s", property->mask, property->xlfd_mask, foreground, background, (result->mask & XAW_TPROP_UNDERLINE) != 0, (result->mask & XAW_TPROP_OVERSTRIKE) != 0, (result->mask & XAW_TPROP_SUBSCRIPT) != 0, (result->mask & XAW_TPROP_SUPERSCRIPT) != 0, xlfd); quark = XrmStringToQuark(identifier); if (result->identifier == NULLQUARK) result->identifier = quark; result->code = quark; if ((property = _XawTextSinkGetProperty(list, result->identifier)) != NULL) { if (result->font) XFreeFont(DisplayOfScreen(list->screen), result->font); if (replace) XtFree((XtPointer)result); return (property); } list->properties = (XawTextProperty**) XtRealloc((XtPointer)list->properties, sizeof(XawTextProperty*) * (list->num_properties + 1)); list->properties[list->num_properties++] = result; qsort((void*)list->properties, list->num_properties, sizeof(XawTextProperty*), qcmp_qident); return (result); }
/*********************************************************************** * * restoreSession - gets the valid x and y location of where to put the * Text Edit on the root window. Sets the global varible * dtpad.saveRestore to True so the rest of the program knows that * a session is being restored. * ***********************************************************************/ void restoreSession( Editor *pPad) { XrmDatabase db; char *tmpStr; XrmName xrm_name[5]; XrmRepresentation rep_type; XrmValue value; char *fileName = pPad->xrdb.session; char *path; int numPadsToRestore, i; Boolean foundPad; if(DtSessionRestorePath(topLevelWithWmCommand, &path, fileName) == False) path = fileName; /* Open the file as a resource database */ if ((db = XrmGetFileDatabase (path)) == NULL) { tmpStr = (char *)XtMalloc(strlen(MSG2) + strlen(path)+ 1); sprintf(tmpStr, MSG2, path); _DtSimpleErrnoError(pPad->progname, DtError, MSG1, tmpStr, NULL); XtFree(tmpStr); return; } xrm_name[0] = XrmStringToQuark ("pads"); xrm_name[1] = XrmStringToQuark ("numActivePads"); xrm_name[2] = NULL; XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value); numPadsToRestore = atoi((char *)value.addr); if(numPadsToRestore == 0) { /* * Either it's an old (i.e. 2.01) session file, * or it's bogus. Either way, we'll create one * window, taking whatever mainWindow: resources * we can find. */ xrm_name[0] = XrmStringToQuark ("mainWindow"); xrm_name[2] = NULL; /* get x position */ xrm_name[1] = XrmStringToQuark ("x"); XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value); pPad->x = atoi((char *)value.addr); /* get y position */ xrm_name[1] = XrmStringToQuark ("y"); XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value); pPad->y = atoi((char *)value.addr); pPad->saveRestore = True; return; } RestorePad(pPad, 0, db); for(i = 1; i < numPadsToRestore; i++) { foundPad = FindOrCreatePad(&pPad); RestorePad(pPad, i, db); if(foundPad == False) RealizeNewPad(pPad); else ManageOldPad(pPad, False); } }
static void SetXlfdDefaults(Display *display, XawTextProperty *property) { Atom atom = XInternAtom(display, "FONT", True); unsigned long value; char *str; if (XGetFontProperty(property->font, atom, &value)) { char *xlfd = XGetAtomName(display, value); if (xlfd) { char *sep = xlfd + 1; char *name = sep; property->xlfd = XrmStringToQuark(xlfd); sep = strchr(sep, '-'); *sep++ = '\0'; property->foundry = XrmStringToQuark(name); name = sep; sep = strchr(sep, '-'); *sep++ = '\0'; property->family = XrmStringToQuark(name); name = sep; sep = strchr(sep, '-'); *sep++ = '\0'; property->weight = XrmStringToQuark(name); name = sep; sep = strchr(sep, '-'); *sep++ = '\0'; property->slant = XrmStringToQuark(name); name = sep; sep = strchr(sep, '-'); *sep++ = '\0'; property->setwidth = XrmStringToQuark(name); name = sep; sep = strchr(sep, '-'); *sep++ = '\0'; property->addstyle = XrmStringToQuark(name); name = sep; sep = strchr(sep, '-'); *sep++ = '\0'; property->pixel_size = XrmStringToQuark(name); name = sep; sep = strchr(sep, '-'); *sep++ = '\0'; property->point_size = XrmStringToQuark(name); name = sep; sep = strchr(sep, '-'); *sep++ = '\0'; property->res_x = XrmStringToQuark(name); name = sep; sep = strchr(sep, '-'); *sep++ = '\0'; property->res_y = XrmStringToQuark(name); name = sep; sep = strchr(sep, '-'); *sep++ = '\0'; property->spacing = XrmStringToQuark(name); name = sep; sep = strchr(sep, '-'); *sep++ = '\0'; property->avgwidth = XrmStringToQuark(name); name = sep; sep = strchr(sep, '-'); *sep++ = '\0'; property->registry = XrmStringToQuark(name); name = sep; property->encoding = XrmStringToQuark(name); XFree(xlfd); } } atom = XInternAtom(display, "UNDERLINE_THICKNESS", True); if (XGetFontProperty(property->font, atom, &value) && (str = XGetAtomName(display, value)) != NULL) { property->underline_thickness = atoi(str); XFree(str); } else { /* XLFD says: * CapStemWidth = average width of the stems of capitals * if (UNDERLINE_THICKNESS undefined) then * UNDERLINE_THICKNESS = CapStemWidth * * How do I know the value of CapStemWidth?? */ if (property->pixel_size != NULLQUARK) { property->underline_thickness = atoi(XrmQuarkToString(property->pixel_size)) / 10; property->underline_thickness = XawMax(1, property->underline_thickness); } else property->underline_thickness = 1; } atom = XInternAtom(display, "UNDERLINE_POSITION", True); if (XGetFontProperty(property->font, atom, &value) && (str = XGetAtomName(display, value)) != NULL) { property->underline_position = atoi(str); XFree(str); } else /* XLFD says: * if (UNDERLINE_POSITION undefined) then * UNDERLINE_POSITION = ROUND((maximum_descent) / 2) */ property->underline_position = property->font->max_bounds.descent >> 1; /* I am assuming xlfd does not consider that lines are * centered in the path */ property->underline_position += property->underline_thickness >> 1; }
/* * ------------------------------------------------------------------------ * Name: PdmShellCreate * * Description: * * This function creates a top level application shell. * * Return value: * * 0 if successful; a PDM_EXIT code if not. * */ static int PdmShellCreate(PdmShell* me, const String* fallback_resources, int* argc_in_out, String* argv_in_out) { String app_class; String app_name; XmPixelSet pixelSets[XmCO_NUM_COLORS]; XrmClass class_list[3]; XrmDatabase db; XrmName name_list[3]; XrmRepresentation rep_type; XrmValue value; int decor; int funcs; short secondary_id; /* * create the application context and open the video display */ XtToolkitInitialize(); XtSetLanguageProc((XtAppContext)NULL, (XtLanguageProc)NULL, (XtPointer)NULL); me->app_context = XtCreateApplicationContext(); XtAppSetFallbackResources(me->app_context, (String*)fallback_resources); me->display = XtOpenDisplay(me->app_context, (String)NULL, (String)NULL, "Dtpdm", PdmOptions, XtNumber(PdmOptions), argc_in_out, argv_in_out); if((Display*)NULL == me->display) return PDM_EXIT_VXAUTH; XtGetApplicationNameAndClass(me->display, &app_name, &app_class); /* * the fallback resources are only intended for the video display, so * remove them from the application context */ XtAppSetFallbackResources(me->app_context, (String*)NULL); /* * get the parent video window id from the display's resource database */ db = XtDatabase(me->display); name_list[0] = XrmStringToQuark(app_name); name_list[1] = XrmStringToQuark("parentWindowStr"); name_list[2] = NULLQUARK; class_list[0] = XrmStringToQuark(app_class); class_list[1] = XrmStringToQuark("ParentWindowStr"); class_list[2] = NULLQUARK; XrmQGetResource(db, name_list, class_list, &rep_type, &value); if(!value.addr) return PDM_EXIT_ERROR; me->parent_window = (Window)strtoul((char*)value.addr, (char**)NULL, 0); /* * obtain the parent video window's attributes */ if(!XGetWindowAttributes(me->display, me->parent_window, &me->parent_attr)) return PDM_EXIT_ERROR; /* * register interest in the DestroyNotify event for the parent window */ XSelectInput(me->display, me->parent_window, StructureNotifyMask); /* * create the application shell */ decor = MWM_DECOR_ALL | MWM_DECOR_RESIZEH | MWM_DECOR_MINIMIZE | MWM_DECOR_MAXIMIZE; funcs = MWM_FUNC_ALL | MWM_FUNC_RESIZE | MWM_FUNC_MINIMIZE | MWM_FUNC_MAXIMIZE; me->widget = XtVaAppCreateShell(app_name, app_class, applicationShellWidgetClass, me->display, XmNdeleteResponse, XmDESTROY, XmNmappedWhenManaged, False, XmNmwmDecorations, decor, XmNmwmFunctions, funcs, XmNmwmInputMode,MWM_INPUT_PRIMARY_APPLICATION_MODAL, XmNscreen, me->parent_attr.screen, XmNtransient, True, NULL); /* * pick up the secondary color set, so that the PDM presents the same * colors as a secondary window. (the XmColorObj is created by the * the XmDisplay object, which is created when the app shell is * created) */ if(XmeGetColorObjData(XtScreen(me->widget), (int*)NULL, pixelSets, XmCO_NUM_COLORS, (short*)NULL, (short*)NULL, (short*)NULL, &secondary_id, (short*)NULL)) { /* * In the Xrm database, reassign primary color resource values * with the corresponding secondary color values. This will cause * subsequently created widgets that utilize colors from the * primary set to actually present secondary colors. */ db = XtScreenDatabase(XtScreen(me->widget)); value.size = sizeof(Pixel); value.addr = (char*)&pixelSets[secondary_id].bg; XrmPutResource (&db, "*background", "Pixel", &value); XrmPutResource (&db, "*frameBackground", "Pixel", &value); value.addr = (char*)&pixelSets[secondary_id].fg; XrmPutResource (&db, "*foreground", "Pixel", &value); XrmPutResource (&db, "*backPageForeground", "Pixel", &value); value.addr = (char*)&pixelSets[secondary_id].bs; XrmPutResource (&db, "*bottomShadowColor", "Pixel", &value); value.addr = (char*)&pixelSets[secondary_id].ts; XrmPutResource (&db, "*topShadowColor", "Pixel", &value); } /* * get the application resources */ XtGetApplicationResources(me->widget, me, PdmResources, XtNumber(PdmResources), NULL, 0); /* * return */ return 0; }
LayYYlex(){ int nstr; extern int LayYYprevious; while((nstr = LayYYlook()) >= 0) LayYYfussy: switch(nstr){ case 0: if(LayYYwrap()) return(0); break; case 1: # line 19 "laylex.l" return VERTICAL; break; case 2: # line 20 "laylex.l" return HORIZONTAL; break; case 3: # line 21 "laylex.l" return OC; break; case 4: # line 22 "laylex.l" return CC; break; case 5: # line 23 "laylex.l" return OP; break; case 6: # line 24 "laylex.l" return CP; break; case 7: # line 25 "laylex.l" return OA; break; case 8: # line 26 "laylex.l" return CA; break; case 9: # line 27 "laylex.l" { LayYYlval.ival = 1; return INFINITY; } break; case 10: # line 28 "laylex.l" { LayYYlval.ival = count(LayYYtext, 'f'); return INFINITY; } break; case 11: # line 29 "laylex.l" { LayYYlval.ival = atoi(LayYYtext); return NUMBER; } break; case 12: # line 30 "laylex.l" { return EQUAL; } break; case 13: # line 31 "laylex.l" { return DOLLAR; } break; case 14: # line 32 "laylex.l" { LayYYlval.oval = Plus; return PLUS; } break; case 15: # line 33 "laylex.l" { LayYYlval.oval = Minus; return MINUS; } break; case 16: # line 34 "laylex.l" { LayYYlval.oval = Times; return TIMES; } break; case 17: # line 35 "laylex.l" { LayYYlval.oval = Divide; return DIVIDE; } break; case 18: # line 36 "laylex.l" { LayYYlval.oval = Percent; return PERCENT; } break; case 19: # line 37 "laylex.l" { LayYYlval.oval = Percent; return PERCENTOF; } break; case 20: # line 38 "laylex.l" return WIDTH; break; case 21: # line 39 "laylex.l" return HEIGHT; break; case 22: # line 40 "laylex.l" { LayYYtext[LayYYleng - 1] = '\0'; LayYYlval.qval = XrmStringToQuark (LayYYtext+1); return NAME; } break; case 23: # line 46 "laylex.l" { LayYYtext[LayYYleng - 1] = '\0'; LayYYlval.qval = XrmStringToQuark (LayYYtext); return NAME; } break; case 24: # line 51 "laylex.l" ; break; case 25: # line 52 "laylex.l" ; break; case 26: # line 53 "laylex.l" ; break; case 27: # line 54 "laylex.l" fprintf (stderr, "ignoring %c\n", *LayYYtext); break; case -1: break; default: (void)fprintf(LayYYout,"bad switch LayYYlook %d",nstr); } return(0); }
/* * makeScreenQuarks -- set up quarks for screen resources */ static void makeScreenQuarks() { screenClassQ = XrmStringToQuark("Screen"); visdepthCQ = XrmStringToQuark("Depth"); visdepthIQ = XrmStringToQuark("depth"); visclassCQ = XrmStringToQuark("Visual"); visclassIQ = XrmStringToQuark("visual"); visidCQ = XrmStringToQuark("VisualID"); visidIQ = XrmStringToQuark("visualID"); cmapCQ = XrmStringToQuark("Colormap"); cmapIQ = XrmStringToQuark("colormap"); workspaceColorCQ = XrmStringToQuark("WorkspaceColor"); workspaceColorIQ = XrmStringToQuark("workspaceColor"); windowColorCQ = XrmStringToQuark("WindowColor"); windowColorIQ = XrmStringToQuark("windowColor"); foregroundColorCQ = XrmStringToQuark("Foreground"); foregroundColorIQ = XrmStringToQuark("foreground"); backgroundColorCQ = XrmStringToQuark("Background"); backgroundColorIQ = XrmStringToQuark("background"); borderColorCQ = XrmStringToQuark("BorderColor"); borderColorIQ = XrmStringToQuark("borderColor"); foregroundColorIQ = XrmStringToQuark("foreground"); reverseVideoCQ = XrmStringToQuark("ReverseVideo"); reverseVideoIQ = XrmStringToQuark("reverseVideo"); stippledRubberBandsCQ = XrmStringToQuark("StippledRubberBands"); stippledRubberBandsIQ = XrmStringToQuark("stippledRubberBands"); }
/*ARGSUSED*/ void _WSMUnpackReply(Display *dpy, int screen_num, MessageData data, unsigned long len, WSMRequestType type, WSMReply *reply) { register int i; reply->any.type = type; /* Save the type. */ reply->any.allocated = False; switch (reply->any.type) { case WSM_CONNECT: if (data != NULL) reply->connect.version = (short) UnpackCARD8(&data); else fprintf(stderr, "Error - Connection request reply data is empty!\n"); break; case WSM_EXTENSIONS: { register int num; register String *ptr; num = reply->extensions.num_extensions = UnpackListNum(&data); ptr = (String *) XtMalloc(sizeof(String) * num); reply->extensions.allocated = True; reply->extensions.extensions = ptr; for (i = 0; i < num; i++, ptr++) *ptr = UnpackString(&data); } break; case WSM_CONFIG_FMT: { register int types; WSMConfigFormatReply * config_format = &(reply->config_format); WSMConfigFormatData *fmt; WSMScreenInfo *scr_info = _WSMGetScreenInfo(dpy, screen_num); config_format->accepts_diffs = UnpackBoolean(&data); for (types = 0; types < 3; types++) { switch(types) { case WSM_GLOBAL_FMT: fmt = &(scr_info->global); break; case WSM_WINDOW_FMT: fmt = &(scr_info->window); break; case WSM_ICON_FMT: fmt = &(scr_info->icon); break; } fmt->num_attrs = UnpackListNum(&data); fmt->attr_list = (WSMAttribute *) XtMalloc(sizeof(WSMAttribute) * fmt->num_attrs); for (i = 0; i < fmt->num_attrs; i++) { String str = UnpackString(&data); fmt->attr_list[i].nameq = XrmStringToQuark(str); XtFree(str); fmt->attr_list[i].size = UnpackCARD8(&data); fmt->attr_list[i].is_list = UnpackCARD8(&data); } } /* * No need to allocate this, since they are just pointers * back to global data. */ config_format->global_formats = scr_info->global.attr_list; config_format->num_global_formats = scr_info->global.num_attrs; config_format->window_formats = scr_info->window.attr_list; config_format->num_window_formats = scr_info->window.num_attrs; config_format->icon_formats = scr_info->icon.attr_list; config_format->num_icon_formats = scr_info->icon.num_attrs; } break; case WSM_GET_STATE: { int num =reply->get_state.num_win_info_list = UnpackListNum(&data); reply->get_state.win_info_list = (WSMWinInfo *) XtMalloc(sizeof(WSMWinInfo) * num); reply->get_state.allocated = True; for (i = 0; i < num; i++) UnpackWinInfo(&data, dpy, screen_num, reply->get_state.win_info_list + i); } break; case WSM_SET_STATE: break; case WSM_REG_WINDOW: if (data != NULL) { UnpackWinData(&data, dpy, screen_num, WSM_WINDOW_FMT, &(reply->register_window.window_data), &(reply->register_window.num_window_data)); reply->register_window.allocated = True; } else fprintf(stderr, "Error - Register Window reply data is empty!\n"); break; case WSM_WM_GET_BACKGROUND_WINDOW: reply->get_background.window = UnpackWindow(&data); break; case WSM_WM_SET_BACKGROUND_WINDOW: reply->set_background.window = UnpackWindow(&data); break; case WSM_WM_WINDOWS: { int num; num = reply->wm_windows.num_win_entry_list = UnpackListNum(&data); reply->wm_windows.win_entry_list = (WSMWinEntry *) XtMalloc(sizeof(WSMWinEntry) * num); reply->wm_windows.allocated = True; for (i = 0; i < num; i++) UnpackWinEntry(&data, dpy, screen_num, reply->wm_windows.win_entry_list + i); } break; case WSM_WM_FOCUS: reply->wm_focus.window = UnpackWindow(&data); break; case WSM_WM_POINTER: reply->wm_pointer.location_flag = UnpackCARD32(&data); break; default: break; } } /* _WSMUnpackReply */