void DisplayPosition (FvwmWindow *tmp_win, int x, int y,int Init) { char str [100]; int offset; (void) sprintf (str, " %+-4d %+-4d ", x, y); if(Init) { XClearWindow(dpy,Scr.SizeWindow); if(Scr.d_depth >= 2) RelieveWindow(tmp_win,Scr.SizeWindow,0,0, Scr.SizeStringWidth+ SIZE_HINDENT*2, Scr.StdFont.height + SIZE_VINDENT*2, Scr.StdReliefGC,Scr.StdShadowGC, FULL_HILITE); } else { XClearArea(dpy,Scr.SizeWindow,SIZE_HINDENT,SIZE_VINDENT,Scr.SizeStringWidth, Scr.StdFont.height,False); } offset = (Scr.SizeStringWidth + SIZE_HINDENT*2 - XTextWidth(Scr.StdFont.font,str,strlen(str)))/2; XDrawString (dpy, Scr.SizeWindow, Scr.NormalGC, offset, Scr.StdFont.font->ascent + SIZE_VINDENT, str, strlen(str)); }
/** *** RedrawButton() *** Writes out title, if any, and displays the bevel right, by calling *** RelieveWindow. If clean is nonzero, also clears background. **/ void RedrawButton(button_info *b,int clean) { int i,j,k,BH,BW; int f,x,y,px,py; int ix,iy,iw,ih; XFontStruct *font=buttonFont(b); XGCValues gcv; unsigned long gcm=0; int rev=0; int justify=buttonJustify(b); BW = buttonWidth(b); BH = buttonHeight(b); buttonInfo(b,&x,&y,&px,&py,&f); GetInternalSize(b,&ix,&iy,&iw,&ih); /* This probably isn't the place for this, but it seems to work here and not elsewhere, so... */ if((buttonSwallowCount(b)==3) && b->IconWin!=None) XSetWindowBorderWidth(Dpy,b->IconWin,0); /* ----------------------------------------------------------------------- */ if(b->flags&b_Hangon || b==CurrentButton) /* Hanging or held down by user */ rev=1; if(b->flags&b_Action) /* If this is a Desk button that takes you to here.. */ { int n=0; while(n<4 && (!b->action[n] || strncasecmp(b->action[n],"Desk",4))) n++; if(n<4) { k=sscanf(&b->action[n][4],"%d%d",&i,&j); if(k==2 && i==0 && j==new_desk) rev=1; } } RelieveWindow(MyWindow,f,x,y,BW,BH,buttonHilite(b),buttonShadow(b),rev); /* ----------------------------------------------------------------------- */ f=abs(f); if(clean && BW>2*f && BH>2*f) { gcm = GCForeground; gcv.foreground=buttonBack(b); XChangeGC(Dpy,NormalGC,gcm,&gcv); if(b->flags&b_Container) { int x1=x+f,y1=y+f; int w1=px,h1=py,w2=w1,h2=h1; int w=BW-2*f,h=BH-2*f; w2+=iw - b->c->num_columns*b->c->ButtonWidth; h2+=ih - b->c->num_rows*b->c->ButtonHeight; if(w1)XFillRectangle(Dpy,MyWindow,NormalGC,x1,y1,w1,h); if(w2)XFillRectangle(Dpy,MyWindow,NormalGC,x1+w-w2,y1,w2,h); if(h1)XFillRectangle(Dpy,MyWindow,NormalGC,x1,y1,w,h1); if(h2)XFillRectangle(Dpy,MyWindow,NormalGC,x1,y1+h-h2,w,h2); } else XFillRectangle(Dpy,MyWindow,NormalGC,x+f,y+f,BW-2*f,BH-2*f); } /* ----------------------------------------------------------------------- */ /* If a title is to be shown, truncate it until it fits */ if(b->flags&b_Title && font) { int l,i,xpos; char *s; int just=justify&b_TitleHoriz; /* Left, center, right */ gcm = GCForeground | GCFont; gcv.foreground=buttonFore(b); gcv.font = font->fid; XChangeGC(Dpy,NormalGC,gcm,&gcv); if(justify&b_Horizontal) { if(b->flags&b_Icon) { ix+=b->icon->width+buttonXPad(b); iw-=b->icon->width+buttonXPad(b); } else if (buttonSwallowCount(b)==3) { ix+=b->icon_w+buttonXPad(b); iw-=b->icon_w+buttonXPad(b); } } s=b->title; l=strlen(s); i=XTextWidth(font,s,l); if(i>iw) { if(just==2) { while(i>iw && *s) i=XTextWidth(font,++s,--l); } else /* Left or center - cut off its tail */ { while(i>iw && l>0) i=XTextWidth(font,s,--l); } } if(just==0) /* Left */ xpos=ix; else if(just==2) /* Right */ xpos=max(ix,ix+iw-i); else /* Centered, I guess */ xpos=ix+(iw-i)/2; if(*s && l>0 && BH>=font->descent+font->ascent) /* Clip it somehow? */ { /* If there is more than the title, put it at the bottom */ /* Unless stack flag is set, put it to the right of icon */ if((b->flags&b_Icon || (buttonSwallowCount(b)==3)) && !(justify&b_Horizontal)) { XDrawString(Dpy,MyWindow,NormalGC,xpos, iy+ih-font->descent,s,l); /* Shrink the space available for icon/window */ ih-=font->descent+font->ascent; } /* Or else center vertically */ else { XDrawString(Dpy,MyWindow,NormalGC,xpos, iy+(ih+font->ascent-font->descent)/2,s,l); } } } }
/************************************************************************ * * Draw the window * ***********************************************************************/ void RedrawWindow(Window target) { static int xv= 0,yv= 0,hv=0,wv=0; static int xh=0,yh=0,hh=0,wh=0; int x,y,w,h; XEvent dummy; while (XCheckTypedWindowEvent (dpy, main_win, Expose, &dummy)) exposed |= 1; XSetWindowBorderWidth(dpy,target,0); RelieveWindow(main_win,PAD_WIDTH3-2,PAD_WIDTH3-2, Width-BAR_WIDTH-PAD_WIDTH3+4, Height-BAR_WIDTH-PAD_WIDTH3+4,ShadowGC,ReliefGC); y = (Height-BAR_WIDTH-PAD_WIDTH3-2*SCROLL_BAR_WIDTH)* target_y_offset/target_height + PAD_WIDTH2 + 2 + SCROLL_BAR_WIDTH; x = Width-SCROLL_BAR_WIDTH- PAD_WIDTH2-2; w = SCROLL_BAR_WIDTH; h = (Height-BAR_WIDTH-PAD_WIDTH3-2*SCROLL_BAR_WIDTH)* (Height-BAR_WIDTH-PAD_WIDTH3)/ target_height; if((y!=yv)||(x != xv)||(w != wv)||(h != hv)||(exposed & 1)) { yv = y; xv = x; wv = w; hv = h; XClearArea(dpy,main_win,x,PAD_WIDTH3+SCROLL_BAR_WIDTH, w,Height-BAR_WIDTH-PAD_WIDTH3-2*SCROLL_BAR_WIDTH,False); RelieveWindow(main_win,x,y,w,h,ReliefGC,ShadowGC); } if(exposed & 1) RelieveWindow(main_win,x-2,PAD_WIDTH2, w+4,Height-BAR_WIDTH-PAD_WIDTH2+2,ShadowGC,ReliefGC); if(exposed) { if(motion == TOP) RedrawTopButton(ShadowGC,ReliefGC,x,PAD_WIDTH3); else RedrawTopButton(ReliefGC,ShadowGC,x,PAD_WIDTH3); if(motion == BOTTOM) RedrawBottomButton(ShadowGC,ReliefGC,x, Height-BAR_WIDTH-SCROLL_BAR_WIDTH); else RedrawBottomButton(ReliefGC,ShadowGC,x, Height-BAR_WIDTH-SCROLL_BAR_WIDTH); } x = (Width-BAR_WIDTH-PAD_WIDTH3-2*SCROLL_BAR_WIDTH)*target_x_offset/ target_width+PAD_WIDTH2+2 + SCROLL_BAR_WIDTH; y = Height-SCROLL_BAR_WIDTH-PAD_WIDTH2-2; w = (Width-BAR_WIDTH-PAD_WIDTH3-2*SCROLL_BAR_WIDTH)* (Width-BAR_WIDTH-PAD_WIDTH3)/target_width; h = SCROLL_BAR_WIDTH; if((y!=yh)||(x != xh)||(w != wh)||(h != hh)||(exposed & 1)) { yh = y; xh = x; wh = w; hh = h; XClearArea(dpy,main_win,PAD_WIDTH3+SCROLL_BAR_WIDTH,y, Width-BAR_WIDTH-PAD_WIDTH3-2*SCROLL_BAR_WIDTH,h,False); RelieveWindow(main_win,x,y,w,h,ReliefGC,ShadowGC); } if(exposed& 1) { RelieveWindow(main_win,PAD_WIDTH2,y-2,Width-BAR_WIDTH-PAD_WIDTH2+2,h+4, ShadowGC,ReliefGC); } if(exposed) { if(motion == LEFT) RedrawLeftButton(ShadowGC,ReliefGC,PAD_WIDTH3,y); else RedrawLeftButton(ReliefGC,ShadowGC,PAD_WIDTH3,y); if(motion ==RIGHT) RedrawRightButton(ShadowGC,ReliefGC, Width-BAR_WIDTH-SCROLL_BAR_WIDTH,y); else RedrawRightButton(ReliefGC,ShadowGC, Width-BAR_WIDTH-SCROLL_BAR_WIDTH,y); } if(exposed) { XClearArea(dpy,main_win,Width-BAR_WIDTH+2, Height-BAR_WIDTH+2,BAR_WIDTH-3,BAR_WIDTH-3,False); if(motion == QUIT) RelieveWindow(main_win,Width-SCROLL_BAR_WIDTH-PAD_WIDTH2-4, Height-SCROLL_BAR_WIDTH-PAD_WIDTH2-4, SCROLL_BAR_WIDTH+4,SCROLL_BAR_WIDTH+4, ShadowGC,ReliefGC); else RelieveWindow(main_win,Width-SCROLL_BAR_WIDTH-PAD_WIDTH2-4, Height-SCROLL_BAR_WIDTH-PAD_WIDTH2-4, SCROLL_BAR_WIDTH+4,SCROLL_BAR_WIDTH+4, ReliefGC,ShadowGC); } exposed = 0; }