/*--------------------------/ 初期化 /--------------------------*/ bool StageSelectActionLayer::init(){ if(!Layer::init()){ return false; } buttonBack(); buttonStage(); return true; }
/**************************************************************************** * * Creates an Icon Window * ****************************************************************************/ void CreateIconWindow(button_info *b) { #ifndef NO_ICONS unsigned long valuemask; /* mask for create windows */ XSetWindowAttributes attributes; /* attributes for create windows */ if(!(b->flags&b_Icon)) return; if(b->IconWin != None) { fprintf(stderr,"%s: BUG: Iconwindow already created for 0x%lx!\n", MyName,(unsigned long)b); exit(2); } attributes.background_pixel = buttonBack(b); attributes.event_mask = ExposureMask; valuemask = CWEventMask | CWBackPixel; if(b->icon->width<1 || b->icon->height<1) { fprintf(stderr,"%s: BUG: Illegal iconwindow tried created\n",MyName); exit(2); } b->IconWin=XCreateWindow(Dpy,MyWindow,0,0,b->icon->width,b->icon->height, 0, CopyFromParent, CopyFromParent,CopyFromParent, valuemask,&attributes); #ifdef XPM #ifdef SHAPE if (b->icon->mask!=None) XShapeCombineMask(Dpy,b->IconWin,ShapeBounding,0,0, b->icon->mask,ShapeSet); #endif #endif if(b->icon->depth==0) { XGCValues gcv; unsigned long gcm=0; Pixmap temp; gcm = GCForeground | GCBackground; gcv.background=buttonBack(b); gcv.foreground=buttonFore(b); XChangeGC(Dpy,NormalGC,gcm,&gcv); #ifdef SHAPE XShapeCombineMask(Dpy,b->IconWin,ShapeBounding,0,0, b->icon->picture,ShapeSet); #endif temp = XCreatePixmap(Dpy,Root,b->icon->width, b->icon->height,d_depth); XCopyPlane(Dpy,b->icon->picture,temp,NormalGC, 0,0,b->icon->width,b->icon->height,0,0,1); XSetWindowBackgroundPixmap(Dpy,b->IconWin,temp); XFreePixmap(Dpy,temp); /* We won't use the icon pixmap anymore... but we still need it for width/height etc. so we can't destroy it. */ } else XSetWindowBackgroundPixmap(Dpy,b->IconWin,b->icon->picture); return; #endif }
/** *** 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); } } } }