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

📄 decorate.c

📁 安装DDD之前
💻 C
📖 第 1 页 / 共 4 页
字号:
/*****************************************************************************//**       Copyright 1988 by Evans & Sutherland Computer Corporation,        **//**                          Salt Lake City, Utah                           **//**  Portions Copyright 1989 by the Massachusetts Institute of Technology   **//**                        Cambridge, Massachusetts                         **//**                                                                         **//**                           All Rights Reserved                           **//**                                                                         **//**    Permission to use, copy, modify, and distribute this software and    **//**    its documentation  for  any  purpose  and  without  fee is hereby    **//**    granted, provided that the above copyright notice appear  in  all    **//**    copies and that both  that  copyright  notice  and  this  permis-    **//**    sion  notice appear in supporting  documentation,  and  that  the    **//**    names of Evans & Sutherland and M.I.T. not be used in advertising    **//**    in publicity pertaining to distribution of the  software  without    **//**    specific, written prior permission.                                  **//**                                                                         **//**    EVANS & SUTHERLAND AND M.I.T. DISCLAIM ALL WARRANTIES WITH REGARD    **//**    TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES  OF  MERCHANT-    **//**    ABILITY  AND  FITNESS,  IN  NO  EVENT SHALL EVANS & SUTHERLAND OR    **//**    M.I.T. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL  DAM-    **//**    AGES OR  ANY DAMAGES WHATSOEVER  RESULTING FROM LOSS OF USE, DATA    **//**    OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER    **//**    TORTIOUS ACTION, ARISING OUT OF OR IN  CONNECTION  WITH  THE  USE    **//**    OR PERFORMANCE OF THIS SOFTWARE.                                     **//*****************************************************************************//**************************************************************************** * This module is based on Twm, but has been siginificantly modified  * by Rob Nation  ****************************************************************************//*********************************************************************** * The rest of it is all my fault -- MLM * mwm - "LessTif Window Manager" ***********************************************************************/#include <LTconfig.h>#include <string.h>#include <Xm/Xm.h>#include <Xm/MwmUtil.h>#include "mwm.h"#include <X11/extensions/shape.h>/* * button dimensions */static int lbut_styles[2] ={    22,    55};static int rbut_style_min[2] ={    22,    22};static int rbut_style_max[2] ={    55,    55};/* * change some window attributes */static voidset_value_attributes(ScreenInfo *scr, MwmWindow *t, unsigned long *valuemask,		     XSetWindowAttributes *attributes, ComponentInfo *comp){    *valuemask = CWBorderPixel;    if (scr->mwm_highlight == t)    {	attributes->border_pixel = comp->active_background;	if (comp->active_background_pixmap != XmUNSPECIFIED_PIXMAP)	{	    attributes->background_pixmap = comp->active_background_pixmap;	    *valuemask |= CWBackPixmap;	}	else	{	    attributes->background_pixel = comp->active_background;	    *valuemask |= CWBackPixel;	}    }    else    {	attributes->border_pixel = comp->background;	if (comp->background_pixmap != XmUNSPECIFIED_PIXMAP)	{	    attributes->background_pixmap = comp->background_pixmap;	    *valuemask |= CWBackPixmap;	}	else	{	    attributes->background_pixel = comp->background;	    *valuemask |= CWBackPixel;	}    }}static voiddraw_corners(MwmWindow *t, int i, GC hor, GC vert){    XSegment seg[2];    int n = 0;    switch (i)    {    case 0:	seg[0].x1 = t->boundary_width - 1;	seg[0].x2 = t->corner_width;	seg[0].y1 = t->boundary_width - 1;	seg[0].y2 = t->boundary_width - 1;	n = 1;	break;    case 1:	seg[0].x1 = 0;	seg[0].x2 = t->corner_width - t->boundary_width;	seg[0].y1 = t->boundary_width - 1;	seg[0].y2 = t->boundary_width - 1;	n = 1;	break;    case 2:	seg[0].x1 = t->boundary_width - 1;	seg[0].x2 = t->corner_width - 2;	seg[0].y1 = t->corner_width - t->boundary_width + t->bw;	seg[0].y2 = t->corner_width - t->boundary_width + t->bw;	n = 1;	break;    case 3:	seg[0].x1 = 0;	seg[0].x2 = t->corner_width - t->boundary_width;	seg[0].y1 = t->corner_width - t->boundary_width + t->bw;	seg[0].y2 = t->corner_width - t->boundary_width + t->bw;	n = 1;	break;    }    XDrawSegments(dpy, t->corners[i], hor, seg, n);    switch (i)    {    case 0:	seg[0].y1 = t->boundary_width - 1;	seg[0].y2 = t->corner_width;	seg[0].x1 = t->boundary_width - 1;	seg[0].x2 = t->boundary_width - 1;	n = 1;	break;    case 1:	seg[0].y1 = t->boundary_width - 1;	seg[0].y2 = t->corner_width - 2;	seg[0].x1 = t->corner_width - t->boundary_width;	seg[0].x2 = t->corner_width - t->boundary_width;	n = 1;	break;    case 2:	seg[0].y1 = 0;	seg[0].y2 = t->corner_width - t->boundary_width;	seg[0].x1 = t->boundary_width - 1;	seg[0].x2 = t->boundary_width - 1;	n = 1;	break;    case 3:	seg[0].y1 = 0;	seg[0].y2 = t->corner_width - t->boundary_width + t->bw;	seg[0].x1 = t->corner_width - t->boundary_width;	seg[0].x2 = t->corner_width - t->boundary_width;	n = 1;	break;    }    XDrawSegments(dpy, t->corners[i], vert, seg, 1);}/* * draws a pattern within a window */static voiddraw_pattern(Window win, GC ShadowGC, GC ReliefGC, int h1, int w1, int t1){    XSegment seg[2];    int i, h, b, u, w, r, l;    h = t1 * h1 / 200;    b = (t1 >> 1) + h;    u = t1 - b - 1;    w = t1 * w1 / 200;    r = (t1 >> 1) + w;    l = t1 - r - 1;    i = 0;    seg[i].x1 = l;    seg[i].y1 = u;    seg[i].x2 = r;    seg[i++].y2 = u;    seg[i].x1 = l;    seg[i].y1 = u;    seg[i].x2 = l;    seg[i++].y2 = b;    XDrawSegments(dpy, win, ShadowGC, seg, i);    i = 0;    seg[i].x1 = l;    seg[i].y1 = b;    seg[i].x2 = r;    seg[i++].y2 = b;    seg[i].x1 = r;    seg[i].y1 = u;    seg[i].x2 = r;    seg[i++].y2 = b;    XDrawSegments(dpy, win, ReliefGC, seg, i);}/* * relieve a rectangle */static voidrelieve_rectangle(Window win, int x, int y, int w, int h, GC Hilite, GC Shadow){    XDrawLine(dpy, win, Hilite, x, y, w + x - 1, y);    XDrawLine(dpy, win, Hilite, x, y, x, h + y - 1);    XDrawLine(dpy, win, Hilite, x, y + 1, w + x - 2, y + 1);    XDrawLine(dpy, win, Hilite, x + 1, y + 1, x + 1, h + y - 2);    XDrawLine(dpy, win, Shadow, x, h + y - 1, w + x - 1, h + y - 1);    XDrawLine(dpy, win, Shadow, w + x - 1, y, w + x - 1, h + y - 1);    XDrawLine(dpy, win, Shadow, x + 1, h + y - 2, w + x - 2, h + y - 2);    XDrawLine(dpy, win, Shadow, w + x - 2, y + 1, w + x - 2, h + y - 2);}/* * draw border windows */voidDEC_DrawBorder(MwmWindow *t, Window win, int x, int y, int w, int h,	       GC ReliefGC, GC ShadowGC){    XSegment seg[4];    int i;    /* top */    if (win == t->sides[0])    {	i = 0;	seg[i].x1 = x;	seg[i].y1 = y;	seg[i].x2 = w + x - 1;	seg[i++].y2 = y;	seg[i].x1 = x;	seg[i].y1 = y;	seg[i].x2 = x;	seg[i++].y2 = h + y - 1;	XDrawSegments(dpy, win, ReliefGC, seg, i);	i = 0;	seg[i].x1 = x + t->boundary_width;	seg[i].y1 = y + h - 1;	seg[i].x2 = w + x - 1 - t->boundary_width;	seg[i++].y2 = y + h - 1;	seg[i].x1 = x + w - 1;	seg[i].y1 = y;	seg[i].x2 = x + w - 1;	seg[i++].y2 = y + h - 1;	XDrawSegments(dpy, win, ShadowGC, seg, i);    }    /* right */    else if (win == t->sides[1])    {	i = 0;	seg[i].x1 = x;	seg[i].y1 = y;	seg[i].x2 = w + x - 1;	seg[i++].y2 = y;	seg[i].x1 = x;	seg[i].y1 = y + t->boundary_width - 1;	seg[i].x2 = x;	seg[i++].y2 = h + y - 1 - t->boundary_width;	XDrawSegments(dpy, win, ReliefGC, seg, i);	i = 0;	seg[i].x1 = x;	seg[i].y1 = y + h - 1;	seg[i].x2 = w + x - 1;	seg[i++].y2 = y + h - 1;	seg[i].x1 = x + w - 1;	seg[i].y1 = y;	seg[i].x2 = x + w - 1;	seg[i++].y2 = y + h - 1;	XDrawSegments(dpy, win, ShadowGC, seg, i);    }    /* bottom */    else if (win == t->sides[2])    {	i = 0;	seg[i].x1 = x + t->boundary_width;	seg[i].y1 = y;	seg[i].x2 = w + x - t->boundary_width;	seg[i++].y2 = y;	seg[i].x1 = x;	seg[i].y1 = y;	seg[i].x2 = x;	seg[i++].y2 = h + y - 1;	XDrawSegments(dpy, win, ReliefGC, seg, i);	i = 0;	seg[i].x1 = x;	seg[i].y1 = y + h - 1;	seg[i].x2 = w + x - 1;	seg[i++].y2 = y + h - 1;	seg[i].x1 = x + w - 1;	seg[i].y1 = y;	seg[i].x2 = x + w - 1;	seg[i++].y2 = y + h - 1;	XDrawSegments(dpy, win, ShadowGC, seg, i);    }    /* left */    else    {	i = 0;	seg[i].x1 = x;	seg[i].y1 = y;	seg[i].x2 = w + x - 1;	seg[i++].y2 = y;	seg[i].x1 = x;	seg[i].y1 = y;	seg[i].x2 = x;	seg[i++].y2 = h + y - 1;	XDrawSegments(dpy, win, ReliefGC, seg, i);	i = 0;	seg[i].x1 = x;	seg[i].y1 = y + h - 1;	seg[i].x2 = w + x - 1;	seg[i++].y2 = y + h - 1;	seg[i].x1 = x + w - 1;	seg[i].y1 = y + t->boundary_width - 1;	seg[i].x2 = x + w - 1;	seg[i++].y2 = y + h - t->boundary_width;	XDrawSegments(dpy, win, ShadowGC, seg, i);    }}/* * draws the relief pattern around a window */voidDEC_DrawShadows(MwmWindow *t, Window win, int x, int y, int w, int h,		GC ReliefGC, GC ShadowGC){    XSegment seg[4];    int i;    i = 0;    seg[i].x1 = x;    seg[i].y1 = y;    seg[i].x2 = w + x - 1;    seg[i++].y2 = y;    seg[i].x1 = x;    seg[i].y1 = y;    seg[i].x2 = x;    seg[i++].y2 = h + y - 1;    XDrawSegments(dpy, win, ReliefGC, seg, i);    i = 0;    seg[i].x1 = x;    seg[i].y1 = y + h - 1;    seg[i].x2 = w + x - 1;    seg[i++].y2 = y + h - 1;    seg[i].x1 = x + w - 1;    seg[i].y1 = y;    seg[i].x2 = x + w - 1;    seg[i++].y2 = y + h - 1;    XDrawSegments(dpy, win, ShadowGC, seg, i);}/* * Interprets the property MOTIF_WM_HINTS, sets decoration and functions * accordingly */voidDEC_SelectDecorations(ScreenInfo *scr, MwmWindow *t){    int border_width, resize_width;    border_width = scr->frame_border_width;    resize_width = scr->resize_border_width;    if (t->mwm_hints && (t->mwm_hints->flags & MWM_HINTS_FUNCTIONS))    {	t->functions = t->mwm_hints->functions;	/*	 * functions affect the decorations! if the user says no iconify	 * function, then the iconify button doesn't show up.  So do functions	 * first.	 */	if (t->functions & MWM_FUNC_ALL)	{	    /* If we get ALL + some other things, that means to use ALL except	     * the other things... */	    t->functions &= ~MWM_FUNC_ALL;	    t->functions = (MWM_FUNC_RESIZE | MWM_FUNC_MOVE | MWM_FUNC_MINIMIZE |			    MWM_FUNC_MAXIMIZE | MWM_FUNC_CLOSE)		& (~(t->functions));	}	if (t->flags & TRANSIENT)	    t->functions &= scr->transient_functions;	else	    t->functions &= t->client_functions;    }    else if (t->flags & TRANSIENT)	t->functions = scr->transient_functions;    else	t->functions = t->client_functions;    if (t->mwm_hints && (t->mwm_hints->flags & MWM_HINTS_DECORATIONS))    {	t->decorations = t->mwm_hints->decorations;	/*	 * next, figure out the decorations	 */	if (t->decorations & MWM_DECOR_ALL)	{	    /* If we get ALL + some other things, that means to use ALL except	     * the other things... */	    t->decorations &= ~MWM_DECOR_ALL;	    t->decorations = (MWM_DECOR_BORDER | MWM_DECOR_RESIZEH |			      MWM_DECOR_TITLE | MWM_DECOR_MENU |			      MWM_DECOR_MINIMIZE | MWM_DECOR_MAXIMIZE)		& (~t->decorations);	}	if (t->flags & TRANSIENT)	    t->decorations &= scr->transient_decoration;	else	    t->decorations &= t->client_decoration;    }    else if (t->flags & TRANSIENT)	t->decorations = scr->transient_decoration;    else	t->decorations = t->client_decoration;    /*     * Now I have the un-altered decor and functions, but with the ALL     * attribute cleared and interpreted. I need to modify the decorations     * that are affected by the functions     */    if (!(t->functions & MWM_FUNC_RESIZE))	t->decorations &= ~MWM_DECOR_RESIZEH;    /* MWM_FUNC_MOVE has no impact on decorations. */    if (!(t->functions & MWM_FUNC_MINIMIZE))	t->decorations &= ~MWM_DECOR_MINIMIZE;    if (!(t->functions & MWM_FUNC_MAXIMIZE))	t->decorations &= ~MWM_DECOR_MAXIMIZE;    /* MWM_FUNC_CLOSE has no impact on decorations. */    /*     * This rule is implicit, but its easier to deal with if I take care of      * it now     */    if (t->decorations & (MWM_DECOR_MENU | MWM_DECOR_MINIMIZE | MWM_DECOR_MAXIMIZE))	t->decorations |= MWM_DECOR_TITLE;    if (t->decorations & (MWM_DECOR_TITLE | MWM_DECOR_RESIZEH))	t->decorations |= MWM_DECOR_BORDER;    if (t->wShaped)	t->decorations &= ~(MWM_DECOR_BORDER | MWM_DECOR_RESIZEH);    /*     * Assume no decorations, and build up     */    t->boundary_width = 0;    t->corner_width = 0;    t->title_height = 0;    if (t->decorations & MWM_DECOR_BORDER)    {	/* A narrow border is displayed (5 pixels - 2 relief, 1 top, 2	 * shadow) */	t->boundary_width = border_width;    }    if (t->decorations & MWM_DECOR_TITLE)    {	/* A title barm with no buttons in it - window gets a 1 pixel wide	 * black border. */	t->title_height = scr->components[MWM_TITLE_A].f_height + 3;    }    if (t->decorations & MWM_DECOR_RESIZEH)    {	/* A wide border, with corner tiles is desplayed (10 pixels - 2	 * relief, 2 shadow) */	t->boundary_width = resize_width;	t->corner_width = scr->components[MWM_TITLE_A].f_height + 3 +	    t->boundary_width;    }    t->bw = 0;    if (t->title_height > 0)	t->title_height += t->bw;}/* * Interprets the property MOTIF_WM_HINTS, sets decoration and functions * accordingly */voidDEC_ReselectDecorations(ScreenInfo *scr, MwmWindow *t){    int border_width, resize_width, i;    unsigned long valuemask;	/* mask for create windows */    XSetWindowAttributes attributes;	/* attributes for create windows */    border_width = scr->frame_border_width;    resize_width = scr->resize_border_width;    if (t->mwm_hints && (t->mwm_hints->flags & MWM_HINTS_FUNCTIONS))

⌨️ 快捷键说明

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