/* * Kreslení */ static void expose(XExposeEvent *event) { static char dash_list1[] = {15, 20, 15, 5}; /* Sudý poèet polo¾ek */ static char dash_list2[] = {5, 10, 15}; /* Lichý poèet polo¾ek */ if(event->count > 0) return; /* Kreslit jen po poslední události v øadì */ XSetLineAttributes(display, my_gc, 10, LineSolid, CapButt, JoinRound); XDrawLine(display, topwin, my_gc, 10, 20, 310, 20); XDrawString(display, topwin, def_gc, 320, 20, "LineSolid", 9); XSetLineAttributes(display, my_gc, 10, LineOnOffDash, CapButt, JoinRound); XSetDashes(display, my_gc, 0, dash_list1, 4); XDrawLine(display, topwin, my_gc, 10, 50, 310, 50); XDrawString(display, topwin, def_gc, 320, 50, "LineOnOffDash", 13); XSetDashes(display, my_gc, 10, dash_list1, 4); XSetLineAttributes(display, my_gc, 10, LineDoubleDash, CapButt, JoinRound); XDrawLine(display, topwin, my_gc, 10, 80, 310, 80); XDrawString(display, topwin, def_gc, 320, 80, "LineDoubleDash", 14); XSetLineAttributes(display, my_gc, 10, LineOnOffDash, CapButt, JoinRound); XSetDashes(display, my_gc, 0, dash_list2, 3); XDrawLine(display, topwin, my_gc, 10, 110, 310, 110); XDrawString(display, topwin, def_gc, 320, 110, "LineOnOffDash", 13); }
void setlinestyle(int linestyle, unsigned upattern, int thickness) { XGCValues values; int dash_offset; dash_offset = 0; switch (linestyle) { case SOLID_LINE: values.line_style = LineSolid; break; case DOTTED_LINE: values.line_style = LineOnOffDash; XSetDashes(dpy, gc, dash_offset, dash_list[0], dash_list_length[0]); break; case CENTER_LINE: values.line_style = LineOnOffDash; XSetDashes(dpy, gc, dash_offset, dash_list[1], dash_list_length[1]); break; case DASHED_LINE: values.line_style = LineOnOffDash; XSetDashes(dpy, gc, dash_offset, dash_list[2], dash_list_length[2]); break; default: return; } values.line_width = thickness; XChangeGC(dpy, gc, GCLineWidth | GCLineStyle, &values); }
int InitDoubleDashedEllipses(XParms xp, Parms p, int reps) { char dashes[2]; GenerateEllipses(xp, p, False, True); /* Modify GCs to draw dashed */ XSetLineAttributes(xp->d, xp->ddbggc, 0, LineDoubleDash, CapButt, JoinMiter); XSetLineAttributes(xp->d, xp->ddfggc, 0, LineDoubleDash, CapButt, JoinMiter); dashes[0] = 3; dashes[1] = 2; XSetDashes(xp->d, xp->ddfggc, 0, dashes, 2); XSetDashes(xp->d, xp->ddbggc, 0, dashes, 2); return reps; }
int InitDashedCircles(XParms xp, Parms p, int reps) { char dashes[2]; GenerateCircles(xp, p, False, False); /* Modify GCs to draw dashed */ XSetLineAttributes(xp->d, xp->bggc, 0, LineOnOffDash, CapButt, JoinMiter); XSetLineAttributes(xp->d, xp->fggc, 0, LineOnOffDash, CapButt, JoinMiter); dashes[0] = 3; dashes[1] = 2; XSetDashes(xp->d, xp->fggc, 0, dashes, 2); XSetDashes(xp->d, xp->bggc, 0, dashes, 2); return reps; }
int X11_SetLinestyle(int linestyleid) { XGCValues values; if (currentgraph->linestyle != linestyleid) { if ((linestyleid == 0 || numdispplanes > 1) && linestyleid != 1) { /* solid if linestyle 0 or if has color, allow only one * dashed linestyle */ values.line_style = LineSolid; } else { values.line_style = LineOnOffDash; } XChangeGC(display, DEVDEP(currentgraph).gc, GCLineStyle, &values); currentgraph->linestyle = linestyleid; XSetDashes(display, DEVDEP(currentgraph).gc, 0, xlinestyles[linestyleid], 4); } return 0; }
int InitWideDoubleDashedEllipses(XParms xp, Parms p, int reps) { int size; XGCValues gcv; char dashes[2]; GenerateWideEllipses(xp, p, False, True); size = p->special; size = (size + 9) / 10; /* Modify GCs to draw dashed */ dashes[0] = 2*size; dashes[1] = 2*size; gcv.line_style = LineDoubleDash; XChangeGC(xp->d, xp->ddfggc, GCLineStyle, &gcv); XChangeGC(xp->d, xp->ddbggc, GCLineStyle, &gcv); XSetDashes(xp->d, xp->ddfggc, 0, dashes, 2); XSetDashes(xp->d, xp->ddbggc, 0, dashes, 2); return reps; }
void PainterRep::PrepareDash(const Brush* b) { BrushRep& br = *(b->rep(display)); XDisplay* dpy = display->rep()->display_; if (br.dash_list_ == nil) { XSetLineAttributes( dpy, dashgc, br.width_, LineSolid, CapButt, JoinMiter ); } else { XSetLineAttributes( dpy, dashgc, br.width_, LineOnOffDash, CapButt, JoinMiter ); XSetDashes(dpy, dashgc, 0, br.dash_list_, br.dash_count_); } }
void p_pen(p_win *w, int width, int type) { p_scr *s = w->s; GC gc = s->gc; int disjoint = (type & P_SQUARE); int same_type = (s->gc_type == type); if (width<2) width = 0; else if (width>100) width = 100; if (s->gc_width==width && same_type) return; type ^= disjoint; if (type>4 || type<0) type = 0; XSetLineAttributes(s->xdpy->dpy, gc, width, type? LineOnOffDash : LineSolid, disjoint? CapProjecting : CapRound, disjoint? JoinMiter : JoinRound); if (!same_type) s->gc_type = (type | disjoint); s->gc_width = width; if (type) { /* dash pattern depends on linestyle */ int n = x_ndash[type]; if (width<2) { XSetDashes(s->xdpy->dpy, gc, 0, x_dash[type], n); } else { /* dash pattern must scale with line thickness */ int i; char dash[6]; for (i=0 ; i<n ; i++) dash[i] = x_dash[type][i]>1? width*x_dash[type][i] : 1; XSetDashes(s->xdpy->dpy, gc, 0, dash, n); } } }
static void bgi_set_dash (unsigned short rp) { int i,j,k,offset,dn; unsigned short p; char bgi_dashes[16]; p=0; for(i=0;i<16;i++) { p = p << 1; if( ( rp & 1 ) == 1) p|=1; rp = rp >> 1; } i=0; while((p&1)==1 && i<16) { i++; p = p >> 1; } offset=i; dn=0; while(i<16) { j=0; k=0; while((p&1) == 0 && (i<16)) { i++; j++; p = p >> 1; }; while((p&1) == 1 && (i<16)) { i++; k++; p = p >> 1; }; if(i==16) k+=offset; bgi_dashes[dn++]=j; bgi_dashes[dn++]=k; } XSetDashes(display,gc, offset==0 ? offset : 16-offset ,bgi_dashes,dn); }
static int line_type(int w) { int dash_offset = 0; if (w == 0) line_style = LineSolid; else if (w > 0 && w < 12) line_style = LineOnOffDash; else return (0); XSetLineAttributes(display, gc, line_width, line_style, CapButt, join_style); if (w > 0) { XSetDashes(display, gc, dash_offset, l_style[w].list, l_style[w].no); } return (0); }
void Scale_dashes(void) { if (dpy == NULL) return; dashes[0] = WINSCALE(8); if (dashes[0] < 1) dashes[0] = 1; dashes[1] = WINSCALE(4); if (dashes[1] < 1) dashes[1] = 1; cdashes[0] = WINSCALE(3); if (cdashes[0] < 1) cdashes[0] = 1; cdashes[1] = WINSCALE(9); if (cdashes[1] < 1) cdashes[1] = 1; XSetDashes(dpy, gameGC, 0, dashes, NUM_DASHES); }
void JXGC::SetDashList ( const JArray<JSize>& dashList, const JSize offset ) { const JSize dashCount = dashList.GetElementCount(); char* xDashList = new char [ dashCount ]; assert( xDashList != NULL ); for (JIndex i=1; i<=dashCount; i++) { xDashList[i-1] = dashList.GetElement(i); } XSetDashes(*itsDisplay, itsXGC, offset, xDashList, dashCount); delete [] xDashList; }
void PlotArea::plot_linetype(const char *buf) { int assignments = sscanf(buf, "L%4d", &line_type); if (assignments != 1) { plot_unknown(buf); return; } line_type = (line_type % 8) + 2; width = widths[line_type]; if (dashes[line_type][0]) { type = LineOnOffDash; XSetDashes(dpy, gc, 0, dashes[line_type], strlen(dashes[line_type])); } else { type = LineSolid; } XSetForeground(dpy, gc, colors[line_type + 3]); XSetLineAttributes(dpy, gc, width, type, CapButt, JoinBevel); }
/* * Vytvoøení grafického kontextu */ static void getGC(Window win, GC *gc, XFontStruct *font_info) { unsigned long valuemask = 0; /* Ignorovat XGCValues a pou¾ít default */ XGCValues values; /* Nastavení grafického kontextu */ /* Atributy pro kreslení èar (daly by se nastavit i pøi XCreateGC) */ unsigned int line_width = 6; int line_style = LineOnOffDash; int cap_style = CapRound; int join_style = JoinRound; int dash_offset = 0; static char dash_list[] = {12, 24}; int list_length = 2; /* Vytvoøit defaultní graphics context */ *gc = XCreateGC(display, win, valuemask, &values); /* Nastavit font pro kreslení textu */ XSetFont(display, *gc, font_info->fid); /* Nastavit foreground na èernou, proto¾e default background je bílý */ XSetForeground(display, *gc, BlackPixel(display, screen_num)); /* Nastavit parametry pro kreslení èar */ XSetLineAttributes(display, *gc, line_width, line_style, cap_style, join_style); XSetDashes(display, *gc, dash_offset, dash_list, list_length); }
void MP_LineStyle (Scene& scene, short linestyle, short thickness) { char pattern[8]; unsigned thick; // use same formula as in image.cpp thick = 1 + (thickness-1)/2; strcpy(pattern, (linestyle == Dotted) ? "\2\1" : (linestyle == Dashed) ? "\6\3" : (linestyle == LongDashed) ? "\10\5" : (linestyle == DotDashed) ? "\6\2\1\2" : (linestyle == DotDotDashed) ? "\6\2\1\2\1\2" : "\1\3"); if (linestyle != Solid) XSetDashes(Mp.theDisplay,scene.mpwindow->DrawGC,0,pattern,strlen(pattern)); XSetLineAttributes(Mp.theDisplay,scene.mpwindow->DrawGC, thick, (linestyle != Solid) ? LineOnOffDash : LineSolid, CapButt, JoinBevel); }
/***************************************************************************** FUNCTION : ui_map_grid PURPOSE : draws a grid over the MAP squares and the axis NOTES : type == 1 for color display; == 0 for B/W RETURNS : UPDATE : 20.05.1994 ******************************************************************************/ static void ui_map_grid(int type) { char x_String[40], y_String[40]; int x_steps,y_steps; int n = 0; float x_no,y_no,x_foo=0,y_foo=0; int actual_sizeX,actual_sizeY; XPoint p1,p2,p3,p4; static char dash[]={6,6,6}; /* do nothing, if no network defined */ if(type == 0){ if( krui_getNoOfUnits() == 0 || (MAP_BW_squaresizeX == 0) || (MAP_BW_squaresizeY == 0) )return; }else{ if( krui_getNoOfUnits() == 0 || (MAP_squaresizeX == 0) || (MAP_squaresizeY == 0) )return; } /* set the square size */ if(type == 0){ actual_sizeX = MAP_BW_squaresizeX; actual_sizeY = MAP_BW_squaresizeY; }else{ actual_sizeX = MAP_squaresizeX; actual_sizeY = MAP_squaresizeY; } /* set output grid of units */ dash[0] = dash[1] = (int)(actual_sizeX*0.5 +0.5); XSetDashes(ui_display,MAP_GRAPH_gc[20*type], (int)(actual_sizeX*0.5 +0.5)+20*type,dash,2); XSetLineAttributes(ui_display,MAP_GRAPH_gc[20*type],0,LineOnOffDash, CapButt,JoinMiter); x_steps = (int)((MAP_xMax - MAP_xMin)/MAP_scaleX); y_steps = (int)((MAP_yMax - MAP_yMin)/MAP_scaleY); x_no = MAP_xMin; y_no = MAP_yMin; while(n <= 10){ sprintf(x_String,"%1.1f",x_no); sprintf(y_String,"%1.1f",y_no); p1.x = (int)(x_foo)+20; p1.y = 10; p2.x = (x_steps)*actual_sizeX+30; p2.y = (int)(y_foo)+20; p3.x = 0; p3.y = p2.y; p4.x = p1.x; p4.y = (y_steps)*actual_sizeY+20; XDrawString(ui_display,MAP_GRAPH_win,MAP_GRAPH_gc[20*type], p1.x,p1.y,x_String,(int)strlen(x_String)); XDrawString(ui_display,MAP_GRAPH_win,MAP_GRAPH_gc[20*type], p2.x,p2.y,y_String,(int)strlen(y_String)); XDrawString(ui_display,MAP_GRAPH_win,MAP_GRAPH_gc[20*type], p3.x,p3.y,y_String,(int)strlen(y_String)); XDrawString(ui_display,MAP_GRAPH_win,MAP_GRAPH_gc[20*type], p4.x,p4.y+20,x_String,(int)strlen(x_String)); XDrawLine(ui_display,MAP_GRAPH_win,MAP_GRAPH_gc[20*type], p1.x,p1.y,p4.x,p4.y); XDrawLine(ui_display,MAP_GRAPH_win,MAP_GRAPH_gc[20*type], p2.x,p2.y,p3.x+10,p3.y); n ++; x_foo = (type==0)?x_foo+(float)(x_steps*MAP_BW_squaresizeX)/10.0: x_foo+(float)(x_steps*MAP_squaresizeX)/10.0; y_foo = (type==0)?y_foo+(float)(y_steps*MAP_BW_squaresizeY)/10.0: y_foo+(float)(y_steps*MAP_squaresizeY)/10.0; x_no += (MAP_xMax-MAP_xMin)/10.0; y_no += (MAP_yMax-MAP_yMin)/10.0; } XSetLineAttributes(ui_display,MAP_GRAPH_gc[20*type],0, LineSolid,CapButt,JoinMiter); }
void xnestChangeGC(GCPtr pGC, unsigned long mask) { XGCValues values; if (mask & GCFunction) values.function = pGC->alu; if (mask & GCPlaneMask) values.plane_mask = pGC->planemask; if (mask & GCForeground) values.foreground = xnestPixel(pGC->fgPixel); if (mask & GCBackground) values.background = xnestPixel(pGC->bgPixel); if (mask & GCLineWidth) values.line_width = pGC->lineWidth; if (mask & GCLineStyle) values.line_style = pGC->lineStyle; if (mask & GCCapStyle) values.cap_style = pGC->capStyle; if (mask & GCJoinStyle) values.join_style = pGC->joinStyle; if (mask & GCFillStyle) values.fill_style = pGC->fillStyle; if (mask & GCFillRule) values.fill_rule = pGC->fillRule; if (mask & GCTile) { if (pGC->tileIsPixel) mask &= ~GCTile; else values.tile = xnestPixmap(pGC->tile.pixmap); } if (mask & GCStipple) values.stipple = xnestPixmap(pGC->stipple); if (mask & GCTileStipXOrigin) values.ts_x_origin = pGC->patOrg.x; if (mask & GCTileStipYOrigin) values.ts_y_origin = pGC->patOrg.y; if (mask & GCFont) values.font = xnestFont(pGC->font); if (mask & GCSubwindowMode) values.subwindow_mode = pGC->subWindowMode; if (mask & GCGraphicsExposures) values.graphics_exposures = pGC->graphicsExposures; if (mask & GCClipXOrigin) values.clip_x_origin = pGC->clipOrg.x; if (mask & GCClipYOrigin) values.clip_y_origin = pGC->clipOrg.y; if (mask & GCClipMask) /* this is handled in change clip */ mask &= ~GCClipMask; if (mask & GCDashOffset) values.dash_offset = pGC->dashOffset; if (mask & GCDashList) { mask &= ~GCDashList; XSetDashes(xnestDisplay, xnestGC(pGC), pGC->dashOffset, (char *)pGC->dash, pGC->numInDashList); } if (mask & GCArcMode) values.arc_mode = pGC->arcMode; if (mask) XChangeGC(xnestDisplay, xnestGC(pGC), mask, &values); }
void CreateGCs(void) { static ScreenInfo *prevScr = NULL; XGCValues gcv; unsigned long gcm; static unsigned char greypattern [] = {0x0f, 0x05, 0x0f, 0x0a}; Pixmap greypixmap; static char dashlist [2] = {1, 1}; if (!Scr->FirstTime || prevScr == Scr) return; prevScr = Scr; /* create GC's */ gcm = 0; gcm |= GCFunction; gcv.function = GXxor; gcm |= GCLineWidth; gcv.line_width = 0; gcm |= GCForeground; gcv.foreground = Scr->XORvalue; gcm |= GCSubwindowMode; gcv.subwindow_mode = IncludeInferiors; Scr->DrawGC = XCreateGC(dpy, Scr->Root, gcm, &gcv); gcm = 0; gcm |= GCForeground; gcv.foreground = Scr->MenuC.fore; gcm |= GCBackground; gcv.background = Scr->MenuC.back; Scr->MenuGC = XCreateGC(dpy, Scr->Root, gcm, &gcv); gcm = 0; gcm |= GCPlaneMask; gcv.plane_mask = AllPlanes; /* * Prevent GraphicsExpose and NoExpose events. We'd only get NoExpose * events anyway; they cause BadWindow errors from XGetWindowAttributes * call in FindScreenInfo (events.c) (since drawable is a pixmap). */ gcm |= GCGraphicsExposures; gcv.graphics_exposures = False; gcm |= GCLineWidth; gcv.line_width = 0; Scr->NormalGC = XCreateGC(dpy, Scr->Root, gcm, &gcv); greypixmap = XCreatePixmapFromBitmapData(dpy, Scr->Root, (char *) greypattern, 4, 4, 1, 0, 1); if (Scr->Monochrome != COLOR) { gcm = 0; gcm |= GCStipple; gcv.stipple = greypixmap; gcm |= GCFillStyle; gcv.fill_style = FillOpaqueStippled; gcm |= GCForeground; gcv.foreground = Scr->Black; gcm |= GCBackground; gcv.background = Scr->White; Scr->BorderGC = XCreateGC (dpy, Scr->Root, gcm, &gcv); XSetDashes (dpy, Scr->BorderGC, 1, dashlist, 2); } else if (Scr->BeNiceToColormap) { gcm = 0; gcm |= GCLineStyle; gcv.line_style = LineDoubleDash; Scr->BorderGC = XCreateGC (dpy, Scr->Root, gcm, &gcv); XSetDashes (dpy, Scr->BorderGC, 0, dashlist, 2); } else { Scr->BorderGC = XCreateGC (dpy, Scr->Root, 0, (XGCValues*) 0); } }
/* Create our GC's to draw colored lines and such */ struct Colors * setGCs(Drawable d) { struct Colors *colors; XGCValues gcv; unsigned long origColor; char dashList[2] = {3, 1}; colors = malloc(sizeof(struct Colors)); if (colors == NULL) return NULL; /* Get the GC-values of the default GC */ XGetGCValues(DADisplay, DAGC, GCForeground | GCBackground | GCGraphicsExposures, &gcv); origColor = gcv.foreground; /* don't send expose events */ gcv.graphics_exposures = False; /* GC for white color */ gcv.foreground = WhitePixel(DADisplay, DefaultScreen(DADisplay)); colors->white = XCreateGC(DADisplay, d, GCForeground | GCGraphicsExposures, &gcv); /* GC for dark blue color */ #if 1 gcv.foreground = DAGetColor("navy"); #else gcv.foreground = 0; #endif colors->black = XCreateGC(DADisplay, d, GCForeground | GCGraphicsExposures, &gcv); /* GC for light borders */ gcv.foreground = DAGetColor("lightGray"); colors->lightGray = XCreateGC(DADisplay, d, GCForeground | GCGraphicsExposures, &gcv); /* GC for dark borders (note re-use of gcv-values) */ gcv.foreground = DAGetColor("#222222"); colors->darkGray = XCreateGC(DADisplay, d, GCForeground | GCGraphicsExposures, &gcv); /* GC for the un-/highlighted colors and dashed line of the slider */ gcv.foreground = origColor; gcv.line_width = 9; gcv.line_style = LineOnOffDash; colors->slider = XCreateGC(DADisplay, d, GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCLineStyle, &gcv); XSetDashes(DADisplay, colors->slider, 1, dashList, 2); /* light slider GC */ gcv.foreground = adjustColor(origColor, +0x40); colors->sliderLight = XCreateGC(DADisplay, d, GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCLineStyle, &gcv); XSetDashes(DADisplay, colors->sliderLight, 1, dashList, 2); /* dark slider GC */ gcv.foreground = adjustColor(origColor, -0x40); colors->sliderDark = XCreateGC(DADisplay, d, GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCLineStyle, &gcv); XSetDashes(DADisplay, colors->sliderDark, 1, dashList, 2); return colors; }
void draw3DQuestionMark2( Display *display, GC gc, Pixmap pixmap, Widget widget, int x, int y, int w, int h, Pixel background) { Drawable drawable = XtWindow(widget); Pixel tsc, bsc, bgc, fgc, slc; Dimension qmh, qmw, qmlw; /* qmh = height of the drawing area for the question mark * qmw = width of the drawing area for the question mark * qmlw = line width of the question mark */ int ax, ay; unsigned int aw, ah; int lx1, lx2, ly1, ly2; int dx, dy; unsigned int dw, dh; char dotted[] = { 1, 1 }; bgc = background; XmGetColors(XtScreen(widget),cmap,bgc,&fgc,&tsc,&bsc,&slc); qmlw = (h > w) ? (w / 10) : (h / 10); /* calculate the line width */ if (qmlw != (qmlw/2*2)) qmlw = qmlw + 1; /* if odd, make it even */ qmh = h - qmlw * 4; if (qmh != (qmh/2*2)) qmh = qmh + 1; /* if odd, make it even */ qmw = w - qmlw * 4; if (qmw != (qmw/2*2)) qmw = qmw + 1; /* if odd, make it even */ if (qmh < qmw) { qmw = qmh; } /* calculate the size of the top arc of the question mark */ ax = x + w / 2 - qmw / 2; ay = y + qmlw * 2; ah = qmh / 2; aw = qmw; /* calculate the size and position of the middle stroke */ lx1 = x + w / 2; ly1 = y + h/ 2 - qmlw/2; lx2 = lx1; ly2 = ly1 + qmh / 4; if (lx1 > lx2) lx2 = lx1; if (ly1 > ly2) ly2 = ly1; /* calculate the size and position of the bottom circle */ dx = lx1 - qmw / 8; dy = ly2 + qmlw; dw = qmw / 4; dh = qmh / 4; if (dw <= 0) dw = 1; if (dh <= 0) dh = 1; /* draw the foreground of the question mark */ XSetForeground(display, gc, bgc); XSetLineAttributes(display,gc, qmlw,LineSolid,CapButt,JoinMiter); /* draw mirror image */ XDrawArc(display,drawable,gc, ax,ay,aw,ah,180*64,-270*64); XDrawLine(display,drawable, gc, lx1, ly1, lx2, ly2); XFillArc(display, drawable, gc, dx,dy,dw,dh,0,360*64); XDrawArc(display, pixmap,gc, ax,ay,aw,ah,180*64,-270*64); XDrawLine(display,pixmap, gc, lx1, ly1, lx2, ly2); XFillArc(display, pixmap, gc, dx,dy,dw,dh,0,360*64); /* draw the top shadow */ XSetDashes(display, gc, 0, dotted, 2); XSetForeground(display, gc, tsc); XSetLineAttributes(display,gc, qmlw/5,LineSolid,CapButt,JoinMiter); /* XSetLineAttributes(display,gc, qmlw/5,LineOnOffDash, * CapButt,JoinMiter,FillSolid); */ /* draw mirror image */ XDrawArc(display,drawable,gc, ax-qmlw/2,ay-qmlw/2,aw+qmlw,ah+qmlw,180*64,-135*64); XDrawArc(display,drawable,gc, ax+qmlw/2,ay+qmlw/2,aw-qmlw,ah-qmlw,45*64,-128*64); XDrawLine(display,drawable, gc, lx1-qmlw/2, ly1, lx2-qmlw/2, ly2); XDrawLine(display,drawable, gc, lx1-qmlw/2, ly1, lx2+qmlw/2, ly1); XDrawArc(display, drawable, gc, dx,dy,dw,dh,45*64,180*64); XDrawArc(display,pixmap,gc, ax-qmlw/2,ay-qmlw/2,aw+qmlw,ah+qmlw,180*64,-135*64); XDrawArc(display,pixmap,gc, ax+qmlw/2,ay+qmlw/2,aw-qmlw,ah-qmlw,45*64,-128*64); XDrawLine(display,pixmap, gc, lx1-qmlw/2, ly1, lx2-qmlw/2, ly2); XDrawLine(display,pixmap, gc, lx1-qmlw/2, ly1, lx2+qmlw/2, ly1); XDrawArc(display, pixmap, gc, dx,dy,dw,dh,45*64,180*64); /* draw the bottom shadow */ XSetForeground(display, gc, bsc); XSetLineAttributes(display,gc, qmlw/5,LineSolid,CapButt,JoinMiter); /* XSetLineAttributes(display,gc, * qmlw/5,LineOnOffDash,CapButt,JoinMiter,FillSolid); */ /* draw mirror image */ XDrawArc(display,drawable,gc, ax-qmlw/2,ay-qmlw/2,aw+qmlw,ah+qmlw,45*64,-128*64); XDrawArc(display,drawable,gc, ax+qmlw/2,ay+qmlw/2,aw-qmlw,ah-qmlw,180*64,-135*64); XDrawLine(display,drawable, gc, ax-qmlw/2, ay+ah/2, ax+qmlw/2, ay+ah/2); XDrawLine(display,drawable, gc, lx1+qmlw/2, ly1+qmlw, lx2+qmlw/2, ly2); XDrawLine(display,drawable, gc, lx1-qmlw/2, ly2, lx2+qmlw/2, ly2); XDrawArc(display, drawable, gc, dx,dy,dw,dh,225*64,180*64); XDrawArc(display,pixmap,gc, ax-qmlw/2,ay-qmlw/2,aw+qmlw,ah+qmlw,45*64,-128*64); XDrawArc(display,pixmap,gc, ax+qmlw/2,ay+qmlw/2,aw-qmlw,ah-qmlw,180*64,-135*64); XDrawLine(display,pixmap, gc, ax-qmlw/2, ay+ah/2, ax+qmlw/2, ay+ah/2); XDrawLine(display,pixmap, gc, lx1+qmlw/2, ly1+qmlw, lx2+qmlw/2, ly2); XDrawLine(display,pixmap, gc, lx1-qmlw/2, ly2, lx2+qmlw/2, ly2); XDrawArc(display, pixmap, gc, dx,dy,dw,dh,225*64,180*64); }
static void setupGC(Display * dpy, GC gc, unsigned long valuemask, XGCValues * values) { if (valuemask & GCFunction) XSetFunction(dpy, gc, values->function); if (valuemask & GCForeground) XSetForeground(dpy, gc, values->foreground); if (valuemask & GCBackground) XSetBackground(dpy, gc, values->background); //FIXME add save gc->ext_data values for each of these... if (valuemask & GCFont) XSetFont(dpy, gc, values->font); if (valuemask & GCGraphicsExposures) XSetGraphicsExposures(dpy, gc, values->graphics_exposures); if ((valuemask & GCClipXOrigin) && (valuemask & GCClipYOrigin)) XSetClipOrigin(dpy, gc, values->clip_x_origin, values->clip_y_origin); if (valuemask & GCClipMask) XSetClipMask(dpy, gc, values->clip_mask); if (valuemask & GCFillStyle) XSetFillStyle(dpy, gc, values->fill_style); if ((valuemask & GCTileStipXOrigin) && (valuemask & GCTileStipYOrigin)) XSetTSOrigin(dpy, gc, values->ts_x_origin, values->ts_y_origin); // FIXME if (valuemask & (GCLineWidth | GCLineStyle | GCCapStyle | GCJoinStyle)) XSetLineAttributes(dpy, gc, values->line_width, values->line_style, values->cap_style, values->join_style); if (valuemask & GCFillRule) XSetFillStyle(dpy, gc, values->fill_rule); if (valuemask & GCTile) XSetTile(dpy, gc, values->tile); if (valuemask & GCStipple) XSetStipple(dpy, gc, values->stipple); if (valuemask & (GCDashOffset | GCDashList)) { // FIXME is this correct for values->dashes? if (values->dashes) { char d[2]; d[0] = d[1] = values->dashes; XSetDashes(dpy, gc, values->dash_offset, d, 2); } } if (valuemask & GCSubwindowMode) XSetSubwindowMode(dpy, gc, values->subwindow_mode); if (valuemask & GCPlaneMask) DPRINTF("XCreateGC: GCPlaneMask not implemented\n"); if (valuemask & GCArcMode) DPRINTF("XCreateGC: GCArcMode not implemented\n"); }
void EZX_SetDashes(unsigned char l, unsigned char h) { unsigned char dotted[2] = { l,h }; XSetDashes(theDisplay, theGC, 0, dotted, 2); }
/** Set the values in the graphics context on the back-end server * associated with \a pGC's screen. */ void dmxChangeGC(GCPtr pGC, unsigned long mask) { ScreenPtr pScreen = pGC->pScreen; DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum]; dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC); XGCValues v; DMX_GC_FUNC_PROLOGUE(pGC); #if 0 pGC->funcs->ChangeGC(pGC, mask); #endif /* Handle "magic special case" from CreateGC */ if (pGCPriv->msc) { /* The "magic special case" is used to handle the case where a * foreground pixel is set when the GC is created so that a * "pseudo default-tile" can be created and used in case the * fillstyle was set to FillTiled. This specific case is tested * in xtest (XCreateGC test #3). What has happened in dix by * the time it reaches here is (1) the pGC->tile.pixel has been * set to pGC->fgPixel and pGC->tileIsPixel is set, (2) if a * tile has also been set, then pGC->tileIsPixel is unset and * pGC->tile.pixmap is initialized; else, the default tile is * created and pGC->tileIsPixel is unset and pGC->tile.pixmap is * initialized to the "pseudo default-tile". In either case, * pGC->tile.pixmap is set; however, in the "magic special case" * the mask is not updated to allow us to detect that we should * initialize the GCTile in the back-end server. Thus, we catch * this case in dmxCreateGC and add GCTile to the mask here. * Are there any cases that I've missed? */ /* Make sure that the tile.pixmap is set, just in case the user * set GCTile in the mask but forgot to set vals.pixmap */ if (pGC->tile.pixmap) mask |= GCTile; /* This only happens once when the GC is created */ pGCPriv->msc = FALSE; } /* Update back-end server's gc */ if (mask & GCFunction) v.function = pGC->alu; if (mask & GCPlaneMask) v.plane_mask = pGC->planemask; if (mask & GCForeground) v.foreground = pGC->fgPixel; if (mask & GCBackground) v.background = pGC->bgPixel; if (mask & GCLineWidth) v.line_width = pGC->lineWidth; if (mask & GCLineStyle) v.line_style = pGC->lineStyle; if (mask & GCCapStyle) v.cap_style = pGC->capStyle; if (mask & GCJoinStyle) v.join_style = pGC->joinStyle; if (mask & GCFillStyle) v.fill_style = pGC->fillStyle; if (mask & GCFillRule) v.fill_rule = pGC->fillRule; if (mask & GCTile) { if (pGC->tileIsPixel) { mask &= ~GCTile; } else { dmxPixPrivPtr pPixPriv = DMX_GET_PIXMAP_PRIV(pGC->tile.pixmap); v.tile = (Drawable) pPixPriv->pixmap; } } if (mask & GCStipple) { dmxPixPrivPtr pPixPriv = DMX_GET_PIXMAP_PRIV(pGC->stipple); v.stipple = (Drawable) pPixPriv->pixmap; } if (mask & GCTileStipXOrigin) v.ts_x_origin = pGC->patOrg.x; if (mask & GCTileStipYOrigin) v.ts_y_origin = pGC->patOrg.y; if (mask & GCFont) { if (dmxScreen->beDisplay) { dmxFontPrivPtr pFontPriv; pFontPriv = FontGetPrivate(pGC->font, dmxFontPrivateIndex); v.font = pFontPriv->font[pScreen->myNum]->fid; } else { mask &= ~GCFont; } } if (mask & GCSubwindowMode) v.subwindow_mode = pGC->subWindowMode; /* Graphics exposures are not needed on the back-ends since they can be generated on the front-end thereby saving bandwidth. */ if (mask & GCGraphicsExposures) mask &= ~GCGraphicsExposures; if (mask & GCClipXOrigin) v.clip_x_origin = pGC->clipOrg.x; if (mask & GCClipYOrigin) v.clip_y_origin = pGC->clipOrg.y; if (mask & GCClipMask) mask &= ~GCClipMask; /* See ChangeClip */ if (mask & GCDashOffset) v.dash_offset = pGC->dashOffset; if (mask & GCDashList) { mask &= ~GCDashList; if (dmxScreen->beDisplay) XSetDashes(dmxScreen->beDisplay, pGCPriv->gc, pGC->dashOffset, (char *) pGC->dash, pGC->numInDashList); } if (mask & GCArcMode) v.arc_mode = pGC->arcMode; if (mask && dmxScreen->beDisplay) { XChangeGC(dmxScreen->beDisplay, pGCPriv->gc, mask, &v); dmxSync(dmxScreen, FALSE); } DMX_GC_FUNC_EPILOGUE(pGC); }
main() { Window w2; Display *dpy = XOpenDisplay(NIL); assert(dpy); Screen *scr = DefaultScreenOfDisplay(dpy); // CreateWindow Window w = XCreateWindow(dpy, RootWindowOfScreen(scr), 10, 100, 200, 300, 0, CopyFromParent, CopyFromParent, CopyFromParent, 0, NIL); XDestroyWindow(dpy, w); // CreateWindow with arguments XSetWindowAttributes swa; swa.background_pixel = WhitePixelOfScreen(scr); swa.bit_gravity = NorthWestGravity; swa.border_pixel = BlackPixelOfScreen(scr); swa.colormap = DefaultColormapOfScreen(scr); swa.cursor = None; swa.win_gravity = NorthGravity; w = XCreateWindow(dpy, RootWindowOfScreen(scr), 10, 100, 200, 300, 0, CopyFromParent, CopyFromParent, CopyFromParent, CWBackPixel | CWBitGravity | CWBorderPixel | CWColormap | CWCursor | CWWinGravity, &swa); // CreateWindow with other arguments XDestroyWindow(dpy, w); Pixmap pixmap = XCreatePixmap(dpy, RootWindowOfScreen(scr), 45, 25, DefaultDepthOfScreen(scr)); assert(pixmap); swa.background_pixmap = pixmap; swa.border_pixmap = pixmap; w = XCreateWindow(dpy, RootWindowOfScreen(scr), 10, 100, 200, 300, 0, CopyFromParent, CopyFromParent, CopyFromParent, CWBackPixmap | CWBorderPixmap, &swa); // ChangeWindowAttributes swa.backing_planes = 0x1; swa.backing_pixel = WhitePixelOfScreen(scr); swa.save_under = True; swa.event_mask = KeyPressMask | KeyReleaseMask; swa.do_not_propagate_mask = ButtonPressMask | Button4MotionMask; swa.override_redirect = False; XChangeWindowAttributes(dpy, w, CWBackingPlanes | CWBackingPixel | CWSaveUnder | CWEventMask | CWDontPropagate | CWOverrideRedirect, &swa); // GetWindowAttributes XWindowAttributes wa; Status success = XGetWindowAttributes(dpy, w, &wa); // DestroyWindow (done) // DestroySubwindows w2 = XCreateWindow(dpy, w, 20, 30, 40, 50, 3, CopyFromParent, CopyFromParent, CopyFromParent, 0, NIL); XDestroySubwindows(dpy, w); // ChangeSaveSet // Display *dpy2 = XOpenDisplay(NIL); // assert(dpy2); // XAddToSaveSet(dpy2, w); // XCloseDisplay(dpy2); // ReparentWindow w2 = XCreateWindow(dpy, RootWindowOfScreen(scr), 20, 30, 40, 50, 3, CopyFromParent, CopyFromParent, CopyFromParent, 0, NIL); XReparentWindow(dpy, w2, w, 10, 5); // MapWindow XMapWindow(dpy, w); // MapSubwindows XMapSubwindows(dpy, w); // UnmapWindow XUnmapWindow(dpy, w); // UnmapSubwindows XMapWindow(dpy, w); XUnmapSubwindows(dpy, w2); XMapSubwindows(dpy, w); // ConfigureWindow Window w3 = XCreateWindow(dpy, w, 10, 50, 100, 10, 2, CopyFromParent, CopyFromParent, CopyFromParent, 0, NIL); XMapWindow(dpy, w3); XWindowChanges wc; wc.x = -5; wc.y = -10; wc.width = 50; wc.height = 40; wc.border_width = 7; wc.sibling = w2; wc.stack_mode = Opposite; XConfigureWindow(dpy, w3, CWX | CWY | CWWidth | CWHeight | CWBorderWidth | CWSibling | CWStackMode, &wc); // CirculateWindow XCirculateSubwindows(dpy, w, RaiseLowest); // GetGeometry Window root; int x, y; unsigned width, height, border_width, depth; XGetGeometry(dpy, w, &root, &x, &y, &width, &height, &border_width, &depth); // QueryTree Window parent; Window *children; unsigned nchildren; success = XQueryTree(dpy, w, &root, &parent, &children, &nchildren); XFree(children); // InternAtom Atom a = XInternAtom(dpy, "WM_PROTOCOLS", True); // GetAtomName char *string = XGetAtomName(dpy, XA_PRIMARY); XFree(string); // ChangeProperty XStoreName(dpy, w, "test window"); // DeleteProperty XDeleteProperty(dpy, w, XA_WM_NAME); // GetProperty // TODO // ListProperties int num_prop; Atom *list = XListProperties(dpy, w, &num_prop); XFree(list); // SetSelectionOwner XSetSelectionOwner(dpy, XA_PRIMARY, w, 12000); XSetSelectionOwner(dpy, XA_SECONDARY, w, CurrentTime); // GetSelectionOwner Window wx = XGetSelectionOwner(dpy, XA_PRIMARY); // ConvertSelection XConvertSelection(dpy, XA_SECONDARY, XA_CURSOR, XA_POINT, w, CurrentTime); // SendEvent // GrabPointer std::cerr << "Grabbing" << std::endl; int res = XGrabPointer(dpy, w, False, Button5MotionMask | PointerMotionHintMask, GrabModeSync, GrabModeAsync, w, None, CurrentTime); XSync(dpy, False); // sleep(5); // UngrabPointer std::cerr << "Ungrabbing" << std::endl; XUngrabPointer(dpy, CurrentTime); // GrabButton XGrabButton(dpy, 3, ShiftMask | ControlMask, w, False, PointerMotionHintMask | Button2MotionMask, GrabModeAsync, GrabModeSync, None, None); XGrabButton(dpy, 2, AnyModifier, w, False, PointerMotionHintMask | Button2MotionMask, GrabModeAsync, GrabModeSync, None, None); // UngrabButton XUngrabButton(dpy, 2, LockMask, w); // ChangeActivePointerGrab XChangeActivePointerGrab(dpy, ButtonPressMask, None, CurrentTime); // GrabKeyboard XGrabKeyboard(dpy, w, True, GrabModeSync, GrabModeSync, 12000); // UngrabKeyboard XUngrabKeyboard(dpy, 13000); // GrabKey XGrabKey(dpy, XKeysymToKeycode(dpy, XK_Tab), ShiftMask | Mod3Mask, w, True, GrabModeSync, GrabModeSync); // UngrabKey XUngrabKey(dpy, AnyKey, AnyModifier, w); // AllowEvents XAllowEvents(dpy, AsyncPointer, 14000); // GrabServer XGrabServer(dpy); // UngrabServer XUngrabServer(dpy); // QueryPointer Window child; int root_x, root_y, win_x, win_y; unsigned mask; Bool bres = XQueryPointer(dpy, w, &root, &child, &root_x, &root_y, &win_x, &win_y, &mask); // GetMotionEvents int nevents; XGetMotionEvents(dpy, w, 15000, 16000, &nevents); // TranslateCoordinates int dest_x, dest_y; XTranslateCoordinates(dpy, w, w2, 10, 20, &dest_x, &dest_y, &child); // WarpPointer XWarpPointer(dpy, w, w2, 0, 0, 100, 100, 20, 30); // SetInputFocus XSetInputFocus(dpy,w, RevertToPointerRoot, 17000); XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, 17000); // GetInputFocus Window focus; int revert_to; XGetInputFocus(dpy, &focus, &revert_to); // QueryKeymap char keys_return[32]; XQueryKeymap(dpy, keys_return); // OpenFont Font fid = XLoadFont(dpy, "cursor"); // CloseFont XUnloadFont(dpy, fid); // QueryFont XFontStruct *fs = XLoadQueryFont(dpy, "cursor"); assert(fs); // QueryTextExtents int direction, font_ascent, font_descent; XCharStruct overall; XQueryTextExtents(dpy, fs -> fid, "toto", 4, &direction, &font_ascent, &font_descent, &overall); XQueryTextExtents(dpy, fs -> fid, "odd__length", 11, &direction, &font_ascent, &font_descent, &overall); XChar2b c2bs; c2bs.byte1 = '$'; c2bs.byte2 = 'B'; XQueryTextExtents16(dpy, fs -> fid, &c2bs, 1, &direction, &font_ascent, &font_descent, &overall); XQueryTextExtents(dpy, fs -> fid, longString, strlen(longString), &direction, &font_ascent, &font_descent, &overall); // ListFonts int actual_count; char **fontList = XListFonts(dpy, "*", 100, &actual_count); XFree((char *)fontList); // ListFontsWithInfo int count; XFontStruct *info; char **names = XListFontsWithInfo(dpy, "*", 100, &count, &info); XFreeFontInfo(names, info, count); // SetFontPath // GetFontPath int npaths; char **charList = XGetFontPath(dpy, &npaths); char **charList2 = new char *[npaths + 1]; memcpy(charList2, charList, npaths * sizeof(char *)); charList2[npaths] = charList2[0]; XSetFontPath(dpy, charList2, npaths + 1); XSetFontPath(dpy, charList, npaths); // Reset to some reasonnable value XFreeFontPath(charList); delete [] charList2; // CreatePixmap Pixmap pix2 = XCreatePixmap(dpy, w, 100, 200, DefaultDepthOfScreen(scr)); // FreePixmap XFreePixmap(dpy, pix2); // CreateGC Pixmap bitmap = XCreateBitmapFromData(dpy, RootWindowOfScreen(scr), "\000\000\001\000\000\001\000\000\001\377\377\377", 3, 4); XGCValues gcv; gcv.function = GXand; gcv.plane_mask = 0x1; gcv.foreground = WhitePixelOfScreen(scr); gcv.background = BlackPixelOfScreen(scr); gcv.line_width = 2; gcv.line_style = LineDoubleDash; gcv.cap_style = CapProjecting; gcv.join_style = JoinRound; gcv.fill_style = FillStippled; gcv.fill_rule = EvenOddRule; gcv.arc_mode = ArcPieSlice; gcv.tile = pixmap; gcv.stipple = bitmap; gcv.ts_x_origin = 3; gcv.ts_y_origin = 4; gcv.font = fs -> fid; gcv.subwindow_mode = ClipByChildren; gcv.graphics_exposures = True; gcv.clip_x_origin = 5; gcv.clip_y_origin = 6; gcv.clip_mask = bitmap; gcv.dash_offset = 1; gcv.dashes = 0xc2; GC gc = XCreateGC(dpy, w, GCFunction | GCPlaneMask | GCForeground | GCBackground | GCLineWidth | GCLineStyle | GCCapStyle | GCJoinStyle | GCFillStyle | GCFillRule | GCTile | GCStipple | GCTileStipXOrigin | GCTileStipYOrigin | GCFont | GCSubwindowMode | GCGraphicsExposures | GCClipXOrigin | GCClipYOrigin | GCClipMask | GCDashOffset | GCDashList | GCArcMode, &gcv); // ChangeGC gcv.function = GXandReverse; // Only a few of these should appear, since the values are cached on the client side by the Xlib. XChangeGC(dpy, gc, GCFunction | GCLineStyle | GCStipple | GCGraphicsExposures | GCDashList, &gcv); // CopyGC GC gc2 = XCreateGC(dpy, w, 0, NIL); XCopyGC(dpy, gc, GCFunction | GCLineStyle | GCStipple | GCGraphicsExposures | GCDashList, gc2); // SetDashes XSetDashes(dpy, gc, 3, "\001\377\001", 3); // SetClipRectangles XRectangle rectangles[] = { { 10, 20, 30, 40 }, { 100, 200, 5, 3 }, { -5, 1, 12, 24 } }; XSetClipRectangles(dpy, gc, 12, 9, rectangles, SIZEOF(rectangles), Unsorted); // FreeGC // done already // ClearArea XClearArea(dpy, w, 30, 10, 10, 100, False); // CopyArea XCopyArea(dpy, w, pixmap, gc, 0, 0, 100, 100, 10, 10); // CopyPlane // This won't work if the Screen doesn't have at least 3 planes XCopyPlane(dpy, pixmap, w, gc, 20, 10, 40, 30, 0, 0, 0x4); // PolyPoint XDrawPoint(dpy, w, gc, 1, 2); XPoint points[] = { { 3, 4 }, { 5, 6 } }; XDrawPoints(dpy, w, gc, points, SIZEOF(points), CoordModeOrigin); // PolyLine XDrawLines(dpy, w, gc, points, SIZEOF(points), CoordModePrevious); // PolySegment XSegment segments[] = { { 7, 8, 9, 10 }, { 11, 12, 13, 14 }, { 15, 16, 17, 18 } }; XDrawSegments(dpy, w, gc, segments, SIZEOF(segments)); // PolyRectangle XDrawRectangles(dpy, w, gc, rectangles, SIZEOF(rectangles)); // PolyArc XArc arcs[] = { { 10, 20, 30, 40, 50, 60 }, { -70, 80, 90, 100, 110, 120 }, { 10, 20, 30, 40, 50, -30 } }; XDrawArcs(dpy, w, gc, arcs, SIZEOF(arcs)); // FillPoly XFillPolygon(dpy, w, gc, points, SIZEOF(points), Convex, CoordModePrevious); // PolyFillRectangle XFillRectangles(dpy, w, gc, rectangles, SIZEOF(rectangles)); // PolyFillArc XFillArcs(dpy, w, gc, arcs, SIZEOF(arcs)); // PutImage // GetImage XImage *image = XGetImage(dpy, w, 10, 20, 40, 30, AllPlanes, ZPixmap); XPutImage(dpy, w, gc, image, 0, 0, 50, 60, 40, 30); XSync(dpy, False); // Make the next request starts at the beginning of a packet // PolyText8 XTextItem textItems[3]; textItems[0].chars = "toto"; textItems[0].nchars = strlen(textItems[0].chars); textItems[0].delta = -3; textItems[0].font = fs->fid; textItems[1].chars = "titi"; textItems[1].nchars = strlen(textItems[1].chars); textItems[1].delta = 3; textItems[1].font = None; textItems[2].chars = "tutu"; textItems[2].nchars = strlen(textItems[2].chars); textItems[2].delta = 0; textItems[2].font = fs->fid; XDrawText(dpy, w, gc, 10, 10, textItems, 3); XTextItem textItems2[3]; textItems2[0].chars = "totox"; textItems2[0].nchars = strlen(textItems2[0].chars); textItems2[0].delta = -3; textItems2[0].font = fs->fid; textItems2[1].chars = "titi"; textItems2[1].nchars = strlen(textItems2[1].chars); textItems2[1].delta = 3; textItems2[1].font = None; textItems2[2].chars = "tutu"; textItems2[2].nchars = strlen(textItems2[2].chars); textItems2[2].delta = 0; textItems2[2].font = fs->fid; XDrawText(dpy, w, gc, 10, 10, textItems2, 3); // PolyText16 XChar2b c2b2[] = { 0, 't', 0, 'x' }; XTextItem16 items16[] = { { &c2bs, 1, -5, None }, { NULL, 0, 0, None }, { c2b2, 2, 0, fs -> fid } }; XDrawText16(dpy, w, gc, 10, 0, items16, SIZEOF(items16)); // ImageText8 XDrawImageString(dpy, w, gc, 10, 10, "toto", 4); // ImageText16 XDrawImageString16(dpy, w, gc, 10, 10, &c2bs, 1); XDrawImageString16(dpy, w, gc, 10, 20, c2b2, 2); // CreateColormap // Don't forget to tell the kids how it was when we had only 8 bits per pixel. Colormap colormap = XCreateColormap(dpy, w, DefaultVisualOfScreen(scr), None); // FreeColormap XFreeColormap(dpy, colormap); colormap = XCreateColormap(dpy, w, DefaultVisualOfScreen(scr), None); // CopyColormapAndFree Colormap colormap2 = XCopyColormapAndFree(dpy, colormap); // InstallColormap XInstallColormap(dpy, colormap2); // UninstallColormap XUninstallColormap(dpy, colormap2); // ListInstalledColormaps int num; Colormap *colormapList = XListInstalledColormaps(dpy, w, &num); // AllocColor XColor screen; screen.red = 0; screen.green = 32767; screen.blue = 65535; screen.flags = DoRed | DoGreen | DoBlue; success = XAllocColor(dpy, colormap, &screen); // AllocNamedColor XColor screen2, exact; success = XAllocNamedColor(dpy, colormap, "Wheat", &screen2, &exact); // AllocColorCells unsigned long plane_masks, pixels; success = XAllocColorCells(dpy, colormap, False, &plane_masks, 1, &pixels, 1); // AllocColorPlanes unsigned long rmask, gmask, bmask; success = XAllocColorPlanes(dpy, colormap, False, &pixels, 1, 0, 0, 0, &rmask, &gmask, &bmask); // FreeColors unsigned long pixels2[2] = { screen.pixel, screen2.pixel }; XFreeColors(dpy, colormap, pixels2, 2, 0); // StoreColors success = XAllocColorCells(dpy, colormap, False, NIL, 0, pixels2, 2); // On many contemporary (that is, year 2000) video cards, you can't allocate read / write cells // I want my requests to be sent, however. if (!success) { XSetErrorHandler(errorHandler); } XColor colors[2]; colors[0] = screen; colors[0].pixel = pixels2[0]; colors[1] = screen2; colors[1].pixel = pixels2[1]; XStoreColors(dpy, colormap, colors, 2); // StoreNamedColor XStoreNamedColor(dpy, colormap, "Wheat", colors[0].pixel, DoBlue); XSync(dpy, False); XSetErrorHandler(NIL); // Restore the default handler // QueryColors screen2.pixel = WhitePixelOfScreen(scr); XQueryColor(dpy, colormap, &screen2); // LookupColor success = XLookupColor(dpy, colormap, "DarkCyan", &exact, &screen); // CreateCursor Cursor cursor = XCreatePixmapCursor(dpy, pixmap, None, &exact, colors, 10, 10); // CreateGlyphCursor Cursor cursor2 = XCreateGlyphCursor(dpy, fs -> fid, fs -> fid, 'X', 0, &exact, colors); // FreeCursor XFreeCursor(dpy, cursor2); // RecolorCursor XRecolorCursor(dpy, cursor, colors, &exact); // QueryBestSize success = XQueryBestSize(dpy, CursorShape, RootWindowOfScreen(scr), 100, 20, &width, &height); // QueryExtension int major_opcode, first_event, first_error; XQueryExtension(dpy, "toto", &major_opcode, &first_event, &first_error); // ListExtensions int nextensions; char **extensionList = XListExtensions(dpy, &nextensions); for(char **p = extensionList; nextensions; nextensions--, p++) std::cout << *p << std::endl; XFree(extensionList); // ChangeKeyboardMapping // GetKeyboardMapping int min_keycodes, max_keycodes; XDisplayKeycodes(dpy, &min_keycodes, &max_keycodes); int keysyms_per_keycode; KeySym *keysyms = XGetKeyboardMapping(dpy, min_keycodes, max_keycodes - min_keycodes + 1, &keysyms_per_keycode); XChangeKeyboardMapping(dpy, min_keycodes, keysyms_per_keycode, keysyms, max_keycodes - min_keycodes + 1); // ChangeKeyboardControl // GetKeyboardControl XKeyboardState keyboardState; XGetKeyboardControl(dpy, &keyboardState); XKeyboardControl keyboardValues; keyboardValues.key_click_percent = keyboardState.key_click_percent; keyboardValues.bell_percent = keyboardState.bell_percent; keyboardValues.bell_pitch = keyboardState.bell_pitch; keyboardValues.bell_duration = keyboardState.bell_duration; keyboardValues.led = 1; keyboardValues.led_mode = LedModeOn; keyboardValues.key = min_keycodes; keyboardValues.auto_repeat_mode = AutoRepeatModeDefault; XChangeKeyboardControl(dpy, KBKeyClickPercent | KBBellPercent | KBBellPitch | KBBellDuration | KBLed | KBLedMode | KBKey | KBAutoRepeatMode, &keyboardValues); // Bell XBell(dpy, 90); // ChangePointerControl // GetPointerControl int accel_numerator, accel_denominator, threshold; XGetPointerControl(dpy, &accel_numerator, &accel_denominator, &threshold); XChangePointerControl(dpy, True, True, accel_numerator, accel_denominator, threshold); // SetScreenSaver // GetScreenSaver int timeout, interval, prefer_blanking, allow_exposures; XGetScreenSaver(dpy, &timeout, &interval, &prefer_blanking, &allow_exposures); XSetScreenSaver(dpy, timeout, interval, prefer_blanking, allow_exposures); // ChangeHosts // ListHosts int nhosts; Bool state; XHostAddress *hostList = XListHosts(dpy, &nhosts, &state); XHostAddress host; host.family = FamilyInternet; host.length = 4; host.address = "\001\002\003\004"; XAddHost(dpy, &host); // SetAccessControl XSetAccessControl(dpy, EnableAccess); // SetCloseDownMode XSetCloseDownMode(dpy, RetainTemporary); // KillClient XKillClient(dpy, AllTemporary); // RotateProperties Atom properties[] = { XInternAtom(dpy, "CUT_BUFFER0", False), XInternAtom(dpy, "CUT_BUFFER1", False), XInternAtom(dpy, "CUT_BUFFER2", False) }; XRotateWindowProperties(dpy, RootWindowOfScreen(scr), properties, SIZEOF(properties), -1); // ForceScreenSaver XForceScreenSaver(dpy, ScreenSaverReset); // SetPointerMapping // GetPointerMapping unsigned char map[64]; int map_length = XGetPointerMapping(dpy, map, 64); XSetPointerMapping(dpy, map, map_length); // SetModifierMapping // GetModifierMapping XModifierKeymap *modmap = XGetModifierMapping(dpy); XSetModifierMapping(dpy, modmap); // NoOperation XNoOp(dpy); for(;;) { XEvent e; XNextEvent(dpy, &e); std::cout << "Got an event of type " << e.type << std::endl; } }
static void setlinestyle (wmfAPI* API,wmfDC* dc) { wmf_x_t* ddata = WMF_X_GetData (API); wmfPen* pen = 0; unsigned long color; char* dashes = 0; int dash_len; XGCValues values; pen = WMF_DC_PEN (dc); color = get_color (API,WMF_PEN_COLOR (pen)); switch (WMF_DC_ROP (dc)) { case R2_BLACK: values.foreground = ddata->black; values.function = GXcopy; break; case R2_WHITE: values.foreground = ddata->white; values.function = GXcopy; break; case R2_XORPEN: values.foreground = color; /* It is very unlikely someone wants to XOR with 0 */ /* This fixes the rubber-drawings in paintbrush */ if (values.foreground == 0) { values.foreground = ((ddata->white) ? ddata->white : ddata->black); } values.function = GXxor; break; default: values.foreground = color; values.function = Our_XROPfunction[WMF_DC_ROP (dc) - 1]; break; } switch (WMF_PEN_STYLE (pen)) { case PS_DASH: dashes = (char*) PEN_dash; dash_len = 2; values.line_style = ((WMF_DC_OPAQUE (dc)) ? LineDoubleDash : LineOnOffDash); break; case PS_DOT: dashes = (char*) PEN_dot; dash_len = 2; values.line_style = ((WMF_DC_OPAQUE (dc)) ? LineDoubleDash : LineOnOffDash); break; case PS_DASHDOT: dashes = (char*) PEN_dashdot; dash_len = 4; values.line_style = ((WMF_DC_OPAQUE (dc)) ? LineDoubleDash : LineOnOffDash); break; case PS_DASHDOTDOT: dashes = (char*) PEN_dashdotdot; dash_len = 6; values.line_style = ((WMF_DC_OPAQUE (dc)) ? LineDoubleDash : LineOnOffDash); break; case PS_ALTERNATE: /* FIXME: should be alternating _pixels_ that are set */ dashes = (char*) PEN_alternate; dash_len = 2; values.line_style = ((WMF_DC_OPAQUE (dc)) ? LineDoubleDash : LineOnOffDash); break; case PS_USERSTYLE: /* FIXME */ default: dashes = 0; dash_len = 2; values.line_style = LineSolid; break; } values.fill_style = FillSolid; values.line_width = (int) ceil ( (double) x_width (API,WMF_PEN_WIDTH (pen)) + (double) x_height (API,WMF_PEN_HEIGHT (pen)) ); if (values.line_width < 1) values.line_width = 1; switch (WMF_PEN_ENDCAP (pen)) { case PS_ENDCAP_SQUARE: values.cap_style = CapProjecting; break; case PS_ENDCAP_FLAT: values.cap_style = CapButt; break; case PS_ENDCAP_ROUND: default: values.cap_style = CapRound; break; } switch (WMF_PEN_JOIN (pen)) { case PS_JOIN_BEVEL: values.join_style = JoinBevel; break; case PS_JOIN_MITER: values.join_style = JoinMiter; break; case PS_JOIN_ROUND: default: values.join_style = JoinRound; break; } if (dashes) XSetDashes (ddata->display,ddata->gc,0,dashes,dash_len); values.background = get_color (API,WMF_DC_BACKGROUND (dc)); XChangeGC (ddata->display,ddata->gc, GCFunction | GCForeground | GCLineStyle | GCLineWidth | GCCapStyle | GCBackground | GCJoinStyle | GCFillStyle, &values); }
void medmInit(char *displayFont) { XmFontListEntry entry; int i; char dashList[2]; Boolean useDefaultFont; char *sizePosition; #if 0 /* KE: This doesn't appear in the Motif documentation. * Assume it is not needed any more. */ XmRegisterConverters(); #endif #if 0 /* Register action table */ XtAppAddActions(appContext,actions,XtNumber(actions)); #endif /* Register a warning handler */ XtSetWarningHandler((XtErrorHandler)trapExtraneousWarningsHandler); /* Initialize alarm color array */ alarmColorPixel[NO_ALARM]=getPixelFromColormapByString(display, screenNum,cmap,alarmColorString[NO_ALARM]); alarmColorPixel[MINOR_ALARM]=getPixelFromColormapByString(display, screenNum,cmap,alarmColorString[MINOR_ALARM]); alarmColorPixel[MAJOR_ALARM]=getPixelFromColormapByString(display, screenNum,cmap,alarmColorString[MAJOR_ALARM]); alarmColorPixel[INVALID_ALARM]=getPixelFromColormapByString(display, screenNum,cmap,alarmColorString[INVALID_ALARM]); alarmColorPixel[ALARM_MAX-1]=getPixelFromColormapByString(display, screenNum,cmap,alarmColorString[ALARM_MAX-1]); /* Initialize Channel Access */ medmCAInitialize(); /* Initialize DisplayInfo structures list */ displayInfoListHead = (DisplayInfo *)malloc(sizeof(DisplayInfo)); displayInfoListHead->next = NULL; displayInfoListTail = displayInfoListHead; /* Initialize DisplayInfoSave structures list */ displayInfoSaveListHead = (DisplayInfo *)malloc(sizeof(DisplayInfo)); displayInfoSaveListHead->next = NULL; displayInfoSaveListTail = displayInfoSaveListHead; /* Initialize common XmStrings */ dlXmStringMoreToComeSymbol = XmStringCreateLocalized(MORE_TO_COME_SYMBOL); /* Create the highlight GC */ highlightGC = XCreateGC(display,rootWindow,0,NULL); /* Eliminate events that we do not handle anyway */ XSetGraphicsExposures(display,highlightGC,False); /* Set the function to invert */ XSetFunction(display,highlightGC,GXinvert); /* Pick a color which XOR-ing with makes reasonable sense for most colors */ /* KE: Forground is irrelevant for GXinvert */ XSetForeground(display,highlightGC,WhitePixel(display,screenNum)); #if 0 XSetForeground(display,highlightGC,getPixelFromColormapByString(display, screenNum,cmap,"grey50")); #endif XSetLineAttributes(display,highlightGC,HIGHLIGHT_LINE_THICKNESS, LineOnOffDash,CapButt,JoinMiter); dashList[0] = 3; dashList[1] = 3; XSetDashes(display,highlightGC,0,dashList,2); /* Initialize the execute popup menu stuff for all shells. Must be consistent with medmWidget.h definitions. */ executePopupMenuButtonType[0] = XmPUSHBUTTON; executePopupMenuButtons[0] = XmStringCreateLocalized(EXECUTE_POPUP_MENU_PRINT); executePopupMenuButtonType[1] = XmPUSHBUTTON; executePopupMenuButtons[1] = XmStringCreateLocalized(EXECUTE_POPUP_MENU_CLOSE); executePopupMenuButtonType[2] = XmPUSHBUTTON; executePopupMenuButtons[2] = XmStringCreateLocalized(EXECUTE_POPUP_MENU_PVINFO); executePopupMenuButtonType[3] = XmPUSHBUTTON; executePopupMenuButtons[3] = XmStringCreateLocalized(EXECUTE_POPUP_MENU_PVLIMITS); executePopupMenuButtonType[4] = XmPUSHBUTTON; executePopupMenuButtons[4] = XmStringCreateLocalized(EXECUTE_POPUP_MENU_MAIN); executePopupMenuButtonType[5] = XmPUSHBUTTON; executePopupMenuButtons[5] = XmStringCreateLocalized(EXECUTE_POPUP_MENU_DISPLAY_LIST); executePopupMenuButtonType[6] = XmPUSHBUTTON; executePopupMenuButtons[6] = XmStringCreateLocalized(EXECUTE_POPUP_MENU_FLASH_HIDDEN); executePopupMenuButtonType[7] = XmPUSHBUTTON; executePopupMenuButtons[7] = XmStringCreateLocalized(EXECUTE_POPUP_MENU_REFRESH); executePopupMenuButtonType[8] = XmPUSHBUTTON; executePopupMenuButtons[8] = XmStringCreateLocalized(EXECUTE_POPUP_MENU_RETRY); /* Note that the Execute Menu is a cascade button */ executePopupMenuButtonType[9] = XmCASCADEBUTTON; executePopupMenuButtons[9] = XmStringCreateLocalized(EXECUTE_POPUP_MENU_EXECUTE); /* Load font and fontList tables (but only once) */ if(!strcmp(displayFont,FONT_ALIASES_STRING)) { /* Use the ALIAS fonts if possible */ strcpy(displayFont,ALIAS_FONT_PREFIX); sizePosition = strstr(displayFont,"_"); printf("\n%s: Loading aliased fonts.",MEDM_VERSION_STRING); for(i = 0; i < MAX_FONTS; i++) { sprintf(sizePosition,"_%d",fontSizeTable[i]); fontTable[i] = XLoadQueryFont(display,displayFont); printf("."); if(fontTable[i] == NULL) { medmPrintf(1,"\nmedmInit: Unable to load font %s\n" " Trying default (fixed) instead\n", displayFont); /* one last attempt: try a common default font */ fontTable[i] = XLoadQueryFont(display,LAST_CHANCE_FONT); if(fontTable[i] == NULL) { medmCATerminate(); dmTerminateX(); exit(-1); } } /* Load the XmFontList table for Motif font sizing */ entry = XmFontListEntryCreate(XmFONTLIST_DEFAULT_TAG, XmFONT_IS_FONT, (XtPointer)fontTable[i]); fontListTable[i] = XmFontListAppendEntry(NULL, entry); XmFontListEntryFree(&entry); } } else { /* Try using scalable font - either default or passed in one */ /* User requested default scalable, copy that name into string and proceed */ if(!strcmp(displayFont,DEFAULT_SCALABLE_STRING)) strcpy(displayFont,DEFAULT_SCALABLE_DISPLAY_FONT); useDefaultFont = !isScalableFont(displayFont); if(useDefaultFont) { /* This name wasn't in XLFD format */ medmPrintf(1,"\nmedmInit:" " Invalid scalable display font selected (Not in XLFD format)\n" " font: %s\n" " Using fixed font\n",displayFont); } else { printf("\n%s: Loading scalable fonts.",MEDM_VERSION_STRING); } for(i = 0; i < MAX_FONTS; i++) { if(!useDefaultFont) { fontTable[i] = loadQueryScalableFont(display, screenNum, displayFont, fontSizeTable[i]); printf("."); } else { fontTable[i] = XLoadQueryFont(display,LAST_CHANCE_FONT); } if(fontTable[i] == NULL) { medmCATerminate(); dmTerminateX(); exit(-1); } /* Load the XmFontList table for Motif font sizing */ entry = XmFontListEntryCreate(XmFONTLIST_DEFAULT_TAG, XmFONT_IS_FONT, (XtPointer)fontTable[i]); fontListTable[i] = XmFontListAppendEntry(NULL, entry); XmFontListEntryFree(&entry); } } printf("\n"); }
static void Redisplay (XtcwpAxesWidget w, XEvent *event, Region region) { Display *dpy=XtDisplay(w); Window win=XtWindow(w); int x=w->axes.x; int y=w->axes.y; int width=w->axes.width; int height=w->axes.height; float x1beg=w->axes.x1beg; float x1end=w->axes.x1end; float x2beg=w->axes.x2beg; float x2end=w->axes.x2end; float p1beg=w->axes.p1beg; float p1end=w->axes.p1end; float p2beg=w->axes.p2beg; float p2end=w->axes.p2end; int n1tic=w->axes.n1tic; int n2tic=w->axes.n2tic; int grid1=w->axes.grid1; int grid2=w->axes.grid2; char *label1=w->axes.label1; char *label2=w->axes.label2; char *title=w->axes.title; Font labelfont=w->axes.labelfont; Font titlefont=w->axes.titlefont; Pixel axescolor=w->axes.axescolor; Pixel gridcolor=w->axes.gridcolor; Pixel titlecolor=w->axes.titlecolor; int style=w->axes.style; XGCValues values; GC gca,gcg,gct; XtcwpAxesCallbackStruct cb; XFontStruct *fa,*ft; XCharStruct cs; int labelca,labelcd,labelch,labelcw,titleca,titlech, ntic,xa,ya,tw,ticsize,ticb,numb,labelb,grided,grid, n1num,n2num,dummy; size_t lstr; float dnum,fnum,dtic,amin,amax,base,scale,anum,atic,azero; float d1num=0.0,f1num=0.0,d2num=0.0,f2num=0.0; char str[256],dash[2],*label; /* if not visible, then simply return */ if (!w->core.visible) return; /* call callbacks before drawing axes (so grid will be on top) */ fillCallbackStruct(w,XtcwpCR_EXPOSE,event,region,&cb); XtCallCallbacks ((Widget) w,XtNexposeCallback,&cb); /* create GCs */ gca = XCreateGC(dpy,win,0,&values); gcg = XCreateGC(dpy,win,0,&values); gct = XCreateGC(dpy,win,0,&values); /* set colors */ XSetForeground(dpy,gca,axescolor); XSetForeground(dpy,gcg,gridcolor); XSetForeground(dpy,gct,titlecolor); /* set fonts and determine character dimensions */ XSetFont(dpy,gca,labelfont); XSetFont(dpy,gct,titlefont); fa = XQueryFont(dpy,labelfont); XTextExtents(fa,"2",1,&dummy,&dummy,&dummy,&cs); labelca = cs.ascent; labelcd = cs.descent; labelch = labelca+labelcd; labelcw = cs.width; ft = XQueryFont(dpy,titlefont); titleca = ft->max_bounds.ascent; titlech = ft->max_bounds.ascent+ft->max_bounds.descent; /* determine tic size */ ticsize = labelcw; /* determine numbered tic intervals */ n1num = (style==XtcwpNORMAL ? width : height)/(8*labelcw); scaxis(x1beg,x1end,&n1num,&d1num,&f1num); n2num = (style==XtcwpNORMAL ? height : width)/(8*labelcw); scaxis(x2beg,x2end,&n2num,&d2num,&f2num); /* draw horizontal axis */ if (style==XtcwpNORMAL) { amin = (x1beg<x1end)?x1beg:x1end; amax = (x1beg>x1end)?x1beg:x1end; dnum = d1num; fnum = f1num; ntic = n1tic; scale = width/(x1end+p1end-x1beg-p1beg); base = x-scale*(x1beg+p1beg); ya = y+height; ticb = ticsize; numb = ticb+labelca+ticsize/4; labelb = numb+labelch+ticsize/4; grid = grid1; label = label1; } else { amin = (x2beg<x2end)?x2beg:x2end; amax = (x2beg>x2end)?x2beg:x2end; dnum = d2num; fnum = f2num; ntic = n2tic; scale = width/(x2end+p2end-x2beg-p2beg); base = x-scale*(x2beg+p2beg); ya = y; ticb = -ticsize; numb = ticb-labelcd-ticsize/4; labelb = numb-labelch-ticsize/4; grid = grid2; label = label2; } if (grid==XtcwpSOLID) { XSetLineAttributes(dpy,gcg,1L,LineSolid,CapButt,JoinMiter); grided = True; } else if (grid==XtcwpDASH) { grided = True; XSetLineAttributes(dpy,gcg,1L,LineOnOffDash,CapButt,JoinMiter); dash[0] = 8; dash[1] = 4; XSetDashes(dpy,gcg,0,dash,2); } else if (grid==XtcwpDOT) { grided = True; XSetLineAttributes(dpy,gcg,1L,LineOnOffDash,CapButt,JoinMiter); dash[0] = 1; dash[1] = 4; XSetDashes(dpy,gcg,0,dash,2); } else grided = False; azero = 0.0001*(amax-amin); for (anum=fnum; anum<=amax; anum+=dnum) { if (anum<amin) continue; xa = base+scale*anum; if (grided) XDrawLine(dpy,win,gcg,xa,y,xa,y+height); XDrawLine(dpy,win,gca,xa,ya,xa,ya+ticb); if (anum>-azero && anum<azero) sprintf(str,"%1.5g",0.0); else sprintf(str,"%1.5g",anum); lstr = strlen(str); tw = XTextWidth(fa,str,(int)lstr); XDrawString(dpy,win,gca,xa-tw/2,ya+numb,str,(int)lstr); } dtic = dnum/ntic; for (atic=fnum-ntic*dtic-dtic; atic<=amax; atic+=dtic) { if (atic<amin) continue; xa = base+scale*atic; XDrawLine(dpy,win,gca,xa,ya,xa,ya+ticb/2); } lstr = strlen(label); tw = XTextWidth(fa,label,(int)lstr); XDrawString(dpy,win,gca,x+width/2-tw/2,ya+labelb,label,(int)lstr); /* draw vertical axis */ if (style==XtcwpNORMAL) { amin = (x2beg<x2end)?x2beg:x2end; amax = (x2beg>x2end)?x2beg:x2end; dnum = d2num; fnum = f2num; ntic = n2tic; scale = -height/(x2end+p2end-x2beg-p2beg); base = y+height-scale*(x2beg+p2beg); grid = grid2; label = label2; } else { amin = (x1beg<x1end)?x1beg:x1end; amax = (x1beg>x1end)?x1beg:x1end; dnum = d1num; fnum = f1num; ntic = n1tic; scale = height/(x1end+p1end-x1beg-p1beg); base = y-scale*(x1beg+p1beg); grid = grid1; label = label1; } xa = x; ticb = -ticsize; numb = ticb-ticsize/4; if (grid==XtcwpSOLID) { XSetLineAttributes(dpy,gcg,1L,LineSolid,CapButt,JoinMiter); grided = True; } else if (grid==XtcwpDASH) { grided = True; XSetLineAttributes(dpy,gcg,1L,LineOnOffDash,CapButt,JoinMiter); dash[0] = 8; dash[1] = 4; XSetDashes(dpy,gcg,0,dash,2); } else if (grid==XtcwpDOT) { grided = True; XSetLineAttributes(dpy,gcg,1L,LineOnOffDash,CapButt,JoinMiter); dash[0] = 1; dash[1] = 4; XSetDashes(dpy,gcg,0,dash,2); } else grided = False; azero = 0.0001*(amax-amin); for (anum=fnum; anum<=amax; anum+=dnum) { if (anum<amin) continue; ya = base+scale*anum; if (grided) XDrawLine(dpy,win,gcg,x,ya,x+width,ya); XDrawLine(dpy,win,gca,xa,ya,xa+ticb,ya); if (anum>-azero && anum<azero) sprintf(str,"%1.5g",0.0); else sprintf(str,"%1.5g",anum); lstr = strlen(str); tw = XTextWidth(fa,str,(int)lstr); XDrawString(dpy,win,gca,xa+numb-tw,ya+labelca/4,str,(int)lstr); } dtic = dnum/ntic; for (atic=fnum-ntic*dtic-dtic; atic<=amax; atic+=dtic) { if (atic<amin) continue; ya = base+scale*atic; XDrawLine(dpy,win,gca,xa,ya,xa+ticb/2,ya); } lstr = strlen(label); tw = XTextWidth(fa,label,(int)lstr); xa = x+ticb-5*labelcw-ticsize/2; if (xa<labelch+1) xa = labelch+1; XtcwpDrawString90(dpy,win,gca,xa,y+height/2+tw/2,label,(int)lstr); /* draw title */ lstr = strlen(title); tw = XTextWidth(ft,title,(int)lstr); if (style==XtcwpNORMAL) { XClearArea(dpy,win,0,y+labelca/4-labelch-labelch-titleca, w->core.width,titlech,False); XDrawString(dpy,win,gct, x+width/2-tw/2, y+labelca/4-labelch-labelch,title,(int)lstr); } else { XClearArea(dpy,win,0,y+height+labelca/4+labelch, w->core.width,titlech,False); XDrawString(dpy,win,gct, x+width/2-tw/2, y+height+labelca/4+labelch+titleca,title,(int)lstr); } /* draw axes box */ XDrawRectangle(dpy,win,gca,x,y,width,height); /* free GCs and font info */ XFreeGC(dpy,gca); XFreeGC(dpy,gcg); XFreeGC(dpy,gct); XFreeFontInfo(NULL,fa,1); XFreeFontInfo(NULL,ft,1); }
static void InitXSpctrmFrame() { Panel panel; Menu menu; char dash_list[2]; xspctrm_frame= xv_create(tracesFrame, FRAME, XV_HEIGHT, xspctrmwin_h+40, XV_WIDTH, xspctrmwin_w, NULL); xspctrm_cvs= xv_create(xspctrm_frame, CANVAS, XV_X, 0, XV_Y, 40, CANVAS_RETAINED, TRUE, CANVAS_REPAINT_PROC, redrawXSpctrm, CANVAS_RESIZE_PROC, resizeXSpctrm, NULL); xspc_win= xv_get(canvas_paint_window(xspctrm_cvs), XV_XID); createGC( xspc_win, &xspc_gc); createGC( xspc_win, &xspc_dot_gc); dash_list[0]= 1; dash_list[1]= 5; XSetLineAttributes(theDisp, xspc_dot_gc, 1, LineOnOffDash, CapRound, JoinRound); createGC( xspc_win, &xspc_smdot_gc); XSetLineAttributes(theDisp, xspc_smdot_gc, 1, LineOnOffDash, CapRound, JoinRound); XSetDashes(theDisp, xspc_smdot_gc,2,dash_list,2); panel= (Panel)xv_create(xspctrm_frame, PANEL, XV_X, 0, XV_Y, 0, XV_HEIGHT, 40, NULL); (void)xv_create(panel, PANEL_BUTTON, PANEL_LABEL_STRING, "Quit", PANEL_NOTIFY_PROC, close_xspctrm_win, NULL); (void)xv_create(panel, PANEL_BUTTON, PANEL_LABEL_STRING, "Redo", PANEL_NOTIFY_PROC, redo_xspctrm, NULL); (void)xv_create(panel, PANEL_BUTTON, PANEL_LABEL_STRING, "Next", PANEL_NOTIFY_PROC, next_xspctrm, NULL); menu= (Menu)xv_create(NULL,MENU, MENU_STRINGS, "Linear Scale", "Log-Linear Sc", "Log Scale", NULL, MENU_NOTIFY_PROC, scale_menu_proc, NULL); (void)xv_create(panel, PANEL_BUTTON, PANEL_LABEL_STRING, "Scale", PANEL_ITEM_MENU, menu, NULL); menu= (Menu)xv_create(NULL,MENU, MENU_STRINGS, "trace portion", "no trace", "taper etc.", "no taper", "grid on", "grid off", NULL, MENU_NOTIFY_PROC, options_menu_proc, NULL); (void)xv_create(panel, PANEL_BUTTON, PANEL_LABEL_STRING, "Options", PANEL_ITEM_MENU, menu, NULL); itrc_txt= (Panel_item)xv_create(panel, PANEL_NUMERIC_TEXT, PANEL_LABEL_STRING, "Trc No.", PANEL_VALUE_DISPLAY_WIDTH, 60, NULL); itrc2_txt= (Panel_item)xv_create(panel, PANEL_NUMERIC_TEXT, PANEL_LABEL_STRING, "Trc No.", PANEL_VALUE_DISPLAY_WIDTH, 60, NULL); }