⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 decorate.c

📁 安装DDD之前
💻 C
📖 第 1 页 / 共 4 页
字号:
    else    {	Forecolor = scr->components[MWM_TITLE_A].foreground;	BackColor = scr->components[MWM_TITLE_A].background;	ReliefGC = scr->pressed_win == t->title	    ? scr->components[MWM_TITLE_A].bot_GC	    : scr->components[MWM_TITLE_A].top_GC;	ShadowGC = scr->pressed_win == t->title	    ? scr->components[MWM_TITLE_A].top_GC	    : scr->components[MWM_TITLE_A].bot_GC;    }    MISC_FlushExpose(t->title);    if (t->name != (char *)NULL)    {	w = XTextWidth(scr->components[MWM_TITLE_A].font,		       t->name, strlen(t->name));	if (w > t->title_width - 12)	    w = t->title_width - 4;	if (w < 0)	    w = 0;    }    else	w = 0;    hor_off = (t->title_width - w) / 2;    if (NewTitle)	XClearWindow(dpy, t->title);    if (t->name != (char *)NULL)    {	if (scr->clean_text)	{	    XClearArea(dpy, t->title,		       hor_off - 2, 0, w + 4, t->title_height, False);	}	XDrawImageString(dpy, t->title,			 onoroff			 ? scr->components[MWM_TITLE_A].active_GC			 : scr->components[MWM_TITLE_A].normal_GC,			 hor_off,			 scr->components[MWM_TITLE_A].f_y + 2,			 t->name, strlen(t->name));	DEC_DrawShadows(t, t->title, 0, 0, t->title_width, t->title_height,			ReliefGC, ShadowGC);    }    XFlush(dpy);}/* * draws the windows decorations */voidDEC_DrawDecorations(ScreenInfo *scr, MwmWindow *t,		    Bool onoroff, Bool force, Bool Mapped, Window expose_win){    Window w = None;    int y, x;    Bool NewColor = False;    XSetWindowAttributes attributes;    unsigned long valuemask;    GC top_GC, bot_GC;    if (!t)	return;    if (onoroff)    {	/* don't re-draw just for kicks */	if ((!force) && (scr->mwm_highlight == t))	    return;	if (scr->mwm_highlight != t)	    NewColor = True;	/* make sure that the previously highlighted window got unhighlighted */	if ((scr->mwm_highlight != t) && (scr->mwm_highlight != NULL))	    DEC_DrawDecorations(scr, scr->mwm_highlight, False, False, True, None);	/* set the keyboard focus */	if ((Mapped) && (t->flags & MAPPED) && (scr->mwm_highlight != t))	    w = t->w;	else if ((t->flags & ICONIFIED) && scr->mwm_highlight != t)	    w = t->icon_w;	scr->mwm_highlight = t;    }    else    {	/* don't re-draw just for kicks */	if ((!force) && (scr->mwm_highlight != t))	    return;	if (scr->mwm_highlight == t)	{	    scr->mwm_highlight = NULL;	    NewColor = True;	}    }    if ((scr->pager_win) && !(t->flags & STICKY))    {	if (NewColor)	{	    if (scr->components[MWM_PAGER].background_pixmap		!= XmUNSPECIFIED_PIXMAP)		XSetWindowBackgroundPixmap(dpy,					   t->pager_view,				 scr->components[MWM_PAGER].background_pixmap);	    else		XSetWindowBackground(dpy, t->pager_view,				     scr->components[MWM_PAGER].background);	    XClearWindow(dpy, t->pager_view);	}	if ((t->icon_image != NULL) &&	    (scr->components[MWM_PAGER].f_height > 0))	{	    XDrawImageString(dpy, t->pager_view,			     scr->components[MWM_PAGER].normal_GC,			     2, scr->components[MWM_PAGER].f_y + 2,			     t->icon_image, strlen(t->icon_image));	}    }    if (t->flags & ICONIFIED)    {	ICON_DrawWindow(scr, t);	return;    }    set_value_attributes(scr, t, &valuemask, &attributes, &scr->components[MWM_BORDER]);    if (t->decorations & (MWM_DECOR_TITLE | MWM_DECOR_BORDER))    {	XSetWindowBorder(dpy, t->parent, attributes.background_pixel);	XSetWindowBorder(dpy, t->frame, attributes.background_pixel);    }    if (t->decorations & MWM_DECOR_TITLE)    {	set_value_attributes(scr, t, &valuemask, &attributes, &scr->components[MWM_TITLE_A]);	if (NewColor)	{	    XChangeWindowAttributes(dpy, t->title, valuemask, &attributes);	    XClearWindow(dpy, t->title);	}    }    if (t->decorations & MWM_DECOR_MENU)    {	if (t->menub != None)	{	    set_value_attributes(scr, t, &valuemask, &attributes, &scr->components[MWM_MENU_B]);	    if (scr->mwm_highlight == t)	    {		top_GC = scr->components[MWM_MENU_B].active_top_GC;		bot_GC = scr->components[MWM_MENU_B].active_bot_GC;	    }	    else	    {		top_GC = scr->components[MWM_MENU_B].top_GC;		bot_GC = scr->components[MWM_MENU_B].bot_GC;	    }	    if (NewColor)	    {		XChangeWindowAttributes(dpy, t->menub, valuemask, &attributes);		XClearWindow(dpy, t->menub);	    }	    if (MISC_FlushExpose(t->menub) || (expose_win == t->menub) ||		(expose_win == None))	    {		DEC_DrawShadows(t, t->menub, 0, 0, t->title_height,				t->title_height,				(scr->pressed_win == t->menub				 ? bot_GC				 : top_GC),				(scr->pressed_win == t->menub				 ? top_GC				 : bot_GC));		draw_pattern(t->menub, top_GC, bot_GC,			     lbut_styles[0],			     lbut_styles[1],			     t->title_height);	    }	}    }    if (t->decorations & MWM_DECOR_MAXIMIZE)    {	if (t->maximizeb != None)	{	    set_value_attributes(scr, t, &valuemask, &attributes,				 &scr->components[MWM_MAXIMIZE_B]);	    if (NewColor)	    {		XChangeWindowAttributes(dpy, t->maximizeb, valuemask, &attributes);		XClearWindow(dpy, t->maximizeb);	    }	    if (scr->mwm_highlight == t)	    {		top_GC = scr->components[MWM_MAXIMIZE_B].active_top_GC;		bot_GC = scr->components[MWM_MAXIMIZE_B].active_bot_GC;	    }	    else	    {		top_GC = scr->components[MWM_MAXIMIZE_B].top_GC;		bot_GC = scr->components[MWM_MAXIMIZE_B].bot_GC;	    }	    if (MISC_FlushExpose(t->maximizeb) || (expose_win == t->maximizeb) ||		(expose_win == None))	    {		DEC_DrawShadows(t, t->maximizeb, 0, 0, t->title_height,				t->title_height,				(scr->pressed_win == t->maximizeb				 ? bot_GC				 : top_GC),				(scr->pressed_win == t->maximizeb				 ? top_GC				 : bot_GC));		draw_pattern(t->maximizeb, top_GC, bot_GC,			     rbut_style_max[0],			     rbut_style_max[1],			     t->title_height);	    }	}    }    if (t->decorations & MWM_DECOR_MINIMIZE)    {	if (t->minimizeb != None)	{	    set_value_attributes(scr, t, &valuemask, &attributes, &scr->components[MWM_MINIMIZE_B]);	    if (NewColor)	    {		XChangeWindowAttributes(dpy, t->minimizeb, valuemask, &attributes);		XClearWindow(dpy, t->minimizeb);	    }	    if (scr->mwm_highlight == t)	    {		top_GC = scr->components[MWM_MINIMIZE_B].active_top_GC;		bot_GC = scr->components[MWM_MINIMIZE_B].active_bot_GC;	    }	    else	    {		top_GC = scr->components[MWM_MINIMIZE_B].top_GC;		bot_GC = scr->components[MWM_MINIMIZE_B].bot_GC;	    }	    if (MISC_FlushExpose(t->minimizeb) || (expose_win == t->minimizeb) ||		(expose_win == None))	    {		DEC_DrawShadows(t, t->minimizeb, 0, 0, t->title_height,				t->title_height,				(scr->pressed_win == t->minimizeb				 ? bot_GC				 : top_GC),				(scr->pressed_win == t->minimizeb				 ? top_GC				 : bot_GC));		draw_pattern(t->minimizeb, top_GC, bot_GC,			     rbut_style_min[0],			     rbut_style_min[1],			     t->title_height);	    }	}    }    if (t->decorations & MWM_DECOR_TITLE)	DEC_DrawTitleBar(scr, t, onoroff, False);    if (t->decorations & MWM_DECOR_BORDER)    {	int i;	/* draw relief lines */	y = t->frame_height - 2 * t->corner_width;	x = t->frame_width - 2 * t->corner_width + t->bw;	for (i = 0; i < 4; i++)	{	    set_value_attributes(scr, t, &valuemask, &attributes, &scr->components[MWM_BORDER]);	    if (NewColor)	    {		XChangeWindowAttributes(dpy, t->sides[i], valuemask, &attributes);		XClearWindow(dpy, t->sides[i]);	    }	    if (scr->mwm_highlight == t)	    {		top_GC = scr->components[MWM_BORDER].active_top_GC;		bot_GC = scr->components[MWM_BORDER].active_bot_GC;	    }	    else	    {		top_GC = scr->components[MWM_BORDER].top_GC;		bot_GC = scr->components[MWM_BORDER].bot_GC;	    }	    if ((MISC_FlushExpose(t->sides[i])) || (expose_win == t->sides[i]) ||		(expose_win == None))	    {		GC sgc, rgc;		sgc = bot_GC;		rgc = top_GC;		/* index    side		 * 0        TOP		 * 1        RIGHT		 * 2        BOTTOM		 * 3        LEFT		 */		if (t->decorations & MWM_DECOR_RESIZEH)		    DEC_DrawShadows(t, t->sides[i], 0, 0,				    ((i % 2) ? t->boundary_width : x),				    ((i % 2) ? y : t->boundary_width),				    rgc, sgc);		else		    DEC_DrawBorder(t, t->sides[i], 0, 0,				   ((i % 2) ? t->boundary_width : x),				   ((i % 2) ? y : t->boundary_width),				   rgc, sgc);	    }	}    }    if (t->decorations & MWM_DECOR_RESIZEH)    {	int i;	/* draw relief lines */	y = t->frame_height - 2 * t->corner_width;	x = t->frame_width - 2 * t->corner_width + t->bw;	for (i = 0; i < 4; i++)	{	    set_value_attributes(scr, t, &valuemask, &attributes, &scr->components[MWM_RESIZE_H]);	    if (NewColor)	    {		XChangeWindowAttributes(dpy, t->corners[i], valuemask, &attributes);		XClearWindow(dpy, t->corners[i]);	    }	    if (scr->mwm_highlight == t)	    {		top_GC = scr->components[MWM_RESIZE_H].active_top_GC;		bot_GC = scr->components[MWM_RESIZE_H].active_bot_GC;	    }	    else	    {		top_GC = scr->components[MWM_RESIZE_H].top_GC;		bot_GC = scr->components[MWM_RESIZE_H].bot_GC;	    }	    if ((MISC_FlushExpose(t->corners[i])) ||		(expose_win == t->corners[i]) || (expose_win == None))	    {		GC rgc, sgc;		rgc = top_GC;		sgc = bot_GC;		DEC_DrawShadows(t, t->corners[i], 0, 0, t->corner_width,				(i / 2)				? t->corner_width + t->bw				: t->corner_width,				rgc, sgc);		if (t->boundary_width > 1)		    draw_corners(t, i, ((i / 2) ? rgc : sgc), ((i % 2) ? rgc : sgc));		else		    draw_corners(t, i, ((i / 2) ? sgc : sgc), ((i % 2) ? sgc : sgc));	    }	}    }    if (t->matte_width > 1)    {	if (MISC_FlushExpose(t->parent) || expose_win == t->parent ||	    expose_win == None)	{	    XGCValues gcv;	    unsigned long gcm;	    if (t->matte_bottom_shadow_pixmap != None &&		t->matte_bottom_shadow_pixmap != XmUNSPECIFIED_PIXMAP)	    {		gcm = GCTile | GCFillStyle;		gcv.tile = t->matte_bottom_shadow_pixmap;		gcv.fill_style = FillTiled;	    }	    else	    {		gcm = GCForeground | GCBackground;		gcv.foreground = t->matte_bottom_shadow_color;		gcv.background = t->matte_background;	    }	    gcm |= GCLineWidth | GCLineStyle | GCCapStyle | GCGraphicsExposures;	    gcv.line_width = 0;	    gcv.line_style = LineSolid;	    gcv.cap_style = CapButt;	    gcv.graphics_exposures = False;	    XChangeGC(dpy, scr->matte_bs_GC, gcm, &gcv);	    if (t->matte_top_shadow_pixmap != None &&		t->matte_top_shadow_pixmap != XmUNSPECIFIED_PIXMAP)	    {		gcm = GCTile | GCFillStyle;		gcv.tile = t->matte_top_shadow_pixmap;		gcv.fill_style = FillTiled;	    }	    else	    {		gcm = GCForeground | GCBackground;		gcv.foreground = t->matte_top_shadow_color;		gcv.background = t->matte_background;	    }	    gcm |= GCLineWidth | GCLineStyle | GCCapStyle | GCGraphicsExposures;	    gcv.line_width = 0;	    gcv.line_style = LineSolid;	    gcv.cap_style = CapButt;	    gcv.graphics_exposures = False;	    XChangeGC(dpy, scr->matte_ts_GC, gcm, &gcv);	    if (t->matte_width > 3)	    {		DEC_DrawShadows(t, t->parent, 0, 0,				t->attr.width + 2 * t->matte_width,				t->attr.height + 2 * t->matte_width,				scr->matte_ts_GC, scr->matte_bs_GC);		relieve_rectangle(t->parent,				  t->matte_width - 2, t->matte_width - 2,				  t->attr.width + 4, t->attr.height + 4,				  scr->matte_bs_GC, scr->matte_ts_GC);	    }	    else	    {		DEC_DrawShadows(t, t->parent,				t->matte_width - 2, t->matte_width - 2,				t->attr.width + 3, t->attr.height + 3,				scr->matte_bs_GC, scr->matte_ts_GC);	    }	}    }    if (!(t->decorations & MWM_DECOR_BORDER))    {				/* no decorative border */	/* for mono - put a black border on 	 * for color, make it the color of the decoration background */	if (t->boundary_width < 2)	{	    MISC_FlushExpose(t->frame);	    XSetWindowBorder(dpy, t->frame, scr->components[MWM_BORDER].background);	    XSetWindowBorder(dpy, t->parent, scr->components[MWM_BORDER].background);	    if (scr->components[MWM_BORDER].background_pixmap)		XSetWindowBackgroundPixmap(dpy, t->frame, scr->components[MWM_BORDER].background_pixmap);	    XClearWindow(dpy, t->frame);	    if (scr->components[MWM_BORDER].background_pixmap)		XSetWindowBackgroundPixmap(dpy, t->parent, scr->components[MWM_BORDER].background_pixmap);	    XClearWindow(dpy, t->parent);	}	else	{	    GC rgc, sgc;	    if (scr->mwm_highlight == t)	    {		top_GC = scr->components[MWM_BORDER].active_top_GC;		bot_GC = scr->components[MWM_BORDER].active_bot_GC;	    }	    else	    {		top_GC = scr->components[MWM_BORDER].top_GC;		bot_GC = scr->components[MWM_BORDER].bot_GC;	    }	    XSetWindowBorder(dpy, t->parent, scr->components[MWM_BORDER].background);	    XSetWindowBorder(dpy, t->frame, scr->components[MWM_BORDER].background);	    rgc = top_GC;	    sgc = bot_GC;	    if (NewColor)	    {		XChangeWindowAttributes(dpy, t->frame, valuemask, &attributes);		XClearWindow(dpy, t->frame);	    }	    if ((MISC_FlushExpose(t->frame)) || (expose_win == t->frame) ||		(expose_win == None))	    {		if (t->boundary_width > 2)		{		    DEC_DrawShadows(t, t->frame, t->boundary_width - 1 - t->bw,				    t->boundary_width - 1 - t->bw,				    t->frame_width -				    (t->boundary_width << 1) + 2 + 3 * t->bw,				    t->frame_height -				    (t->boundary_width << 1) + 2 + 3 * t->bw,				    sgc, rgc);		    DEC_DrawShadows(t, t->frame, 0, 0, t->frame_width + t->bw,				    t->frame_height + t->bw, rgc, sgc);		}		else		{		    DEC_DrawShadows(t, t->frame, 0, 0, t->frame_width + t->bw,				    t->frame_height + t->bw, rgc, rgc);		}	    }	    else	    {		XSetWindowBackground(dpy, t->parent, scr->components[MWM_BORDER].background);	    }	}    }}/* * set up the shaped window borders  */voidDEC_SetShape(MwmWindow *tmp_win, int w){    XRectangle rect;    XShapeCombineShape(dpy, tmp_win->frame, ShapeBounding,		       tmp_win->boundary_width,		       tmp_win->title_height + tmp_win->boundary_width,		       tmp_win->w,		       ShapeBounding, ShapeSet);    if (tmp_win->title)    {	/* windows w/ titles */	rect.x = tmp_win->boundary_width;	rect.y = tmp_win->title_y;	rect.width = w - 2 * tmp_win->boundary_width + tmp_win->bw;	rect.height = tmp_win->title_height;	XShapeCombineRectangles(dpy, tmp_win->frame, ShapeBounding,				0, 0, &rect, 1, ShapeUnion, Unsorted);    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -