?? tkwin3d.c
字號:
/* * tkWin3d.c -- * * This file contains the platform specific routines for * drawing 3d borders in the Windows 95 style. * * Copyright (c) 1996 by Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * * SCCS: @(#) tkWin3d.c 1.6 97/08/12 14:28:54 */#include <tk3d.h>#include <tkWinInt.h>/* * This structure is used to keep track of the extra colors used by * Windows 3d borders. */typedef struct { TkBorder info; XColor *light2ColorPtr; /* System3dLight */ XColor *dark2ColorPtr; /* System3dDarkShadow */} WinBorder;/* *---------------------------------------------------------------------- * * TkpGetBorder -- * * This function allocates a new TkBorder structure. * * Results: * Returns a newly allocated TkBorder. * * Side effects: * None. * *---------------------------------------------------------------------- */TkBorder *TkpGetBorder(){ WinBorder *borderPtr = (WinBorder *) ckalloc(sizeof(WinBorder)); borderPtr->light2ColorPtr = NULL; borderPtr->dark2ColorPtr = NULL; return (TkBorder *) borderPtr;}/* *---------------------------------------------------------------------- * * TkpFreeBorder -- * * This function frees any colors allocated by the platform * specific part of this module. * * Results: * None. * * Side effects: * May deallocate some colors. * *---------------------------------------------------------------------- */voidTkpFreeBorder(borderPtr) TkBorder *borderPtr;{ WinBorder *winBorderPtr = (WinBorder *) borderPtr; if (winBorderPtr->light2ColorPtr) { Tk_FreeColor(winBorderPtr->light2ColorPtr); } if (winBorderPtr->dark2ColorPtr) { Tk_FreeColor(winBorderPtr->dark2ColorPtr); }}/* *-------------------------------------------------------------- * * Tk_3DVerticalBevel -- * * This procedure draws a vertical bevel along one side of * an object. The bevel is always rectangular in shape: * ||| * ||| * ||| * ||| * ||| * ||| * An appropriate shadow color is chosen for the bevel based * on the leftBevel and relief arguments. Normally this * procedure is called first, then Tk_3DHorizontalBevel is * called next to draw neat corners. * * Results: * None. * * Side effects: * Graphics are drawn in drawable. * *-------------------------------------------------------------- */voidTk_3DVerticalBevel(tkwin, drawable, border, x, y, width, height, leftBevel, relief) Tk_Window tkwin; /* Window for which border was allocated. */ Drawable drawable; /* X window or pixmap in which to draw. */ Tk_3DBorder border; /* Token for border to draw. */ int x, y, width, height; /* Area of vertical bevel. */ int leftBevel; /* Non-zero means this bevel forms the * left side of the object; 0 means it * forms the right side. */ int relief; /* Kind of bevel to draw. For example, * TK_RELIEF_RAISED means interior of * object should appear higher than * exterior. */{ TkBorder *borderPtr = (TkBorder *) border; int left, right; Display *display = Tk_Display(tkwin); TkWinDCState state; HDC dc = TkWinGetDrawableDC(display, drawable, &state); int half; if ((borderPtr->lightGC == None) && (relief != TK_RELIEF_FLAT)) { TkpGetShadows(borderPtr, tkwin); } switch (relief) { case TK_RELIEF_RAISED: left = (leftBevel) ? borderPtr->lightGC->foreground : borderPtr->darkGC->foreground; right = (leftBevel) ? ((WinBorder *)borderPtr)->light2ColorPtr->pixel : ((WinBorder *)borderPtr)->dark2ColorPtr->pixel; break; case TK_RELIEF_SUNKEN: left = (leftBevel) ? ((WinBorder *)borderPtr)->dark2ColorPtr->pixel : ((WinBorder *)borderPtr)->light2ColorPtr->pixel; right = (leftBevel) ? borderPtr->darkGC->foreground : borderPtr->lightGC->foreground; break; case TK_RELIEF_RIDGE: left = borderPtr->lightGC->foreground; right = borderPtr->darkGC->foreground; break; case TK_RELIEF_GROOVE: left = borderPtr->darkGC->foreground; right = borderPtr->lightGC->foreground; break; case TK_RELIEF_FLAT: left = right = borderPtr->bgGC->foreground; break; case TK_RELIEF_SOLID: left = right = RGB(0,0,0); break; } half = width/2; if (leftBevel && (width & 1)) { half++; } TkWinFillRect(dc, x, y, half, height, left); TkWinFillRect(dc, x+half, y, width-half, height, right); TkWinReleaseDrawableDC(drawable, dc, &state);}/* *-------------------------------------------------------------- * * Tk_3DHorizontalBevel -- * * This procedure draws a horizontal bevel along one side of * an object. The bevel has mitered corners (depending on * leftIn and rightIn arguments). * * Results: * None. * * Side effects: * None. * *-------------------------------------------------------------- */voidTk_3DHorizontalBevel(tkwin, drawable, border, x, y, width, height, leftIn, rightIn, topBevel, relief) Tk_Window tkwin; /* Window for which border was allocated. */ Drawable drawable; /* X window or pixmap in which to draw. */ Tk_3DBorder border; /* Token for border to draw. */ int x, y, width, height; /* Bounding box of area of bevel. Height * gives width of border. */ int leftIn, rightIn; /* Describes whether the left and right * edges of the bevel angle in or out as * they go down. For example, if "leftIn" * is true, the left side of the bevel * looks like this: * ___________ * __________ * _________ * ________ */ int topBevel; /* Non-zero means this bevel forms the * top side of the object; 0 means it * forms the bottom side. */ int relief; /* Kind of bevel to draw. For example, * TK_RELIEF_RAISED means interior of * object should appear higher than * exterior. */{ TkBorder *borderPtr = (TkBorder *) border; Display *display = Tk_Display(tkwin); int bottom, halfway, x1, x2, x1Delta, x2Delta; TkWinDCState state; HDC dc = TkWinGetDrawableDC(display, drawable, &state); int topColor, bottomColor; if ((borderPtr->lightGC == None) && (relief != TK_RELIEF_FLAT)) { TkpGetShadows(borderPtr, tkwin); } /* * Compute a GC for the top half of the bevel and a GC for the * bottom half (they're the same in many cases). */ switch (relief) { case TK_RELIEF_RAISED: topColor = (topBevel) ? borderPtr->lightGC->foreground : borderPtr->darkGC->foreground; bottomColor = (topBevel) ? ((WinBorder *)borderPtr)->light2ColorPtr->pixel : ((WinBorder *)borderPtr)->dark2ColorPtr->pixel; break; case TK_RELIEF_SUNKEN: topColor = (topBevel) ? ((WinBorder *)borderPtr)->dark2ColorPtr->pixel : ((WinBorder *)borderPtr)->light2ColorPtr->pixel; bottomColor = (topBevel) ? borderPtr->darkGC->foreground : borderPtr->lightGC->foreground; break; case TK_RELIEF_RIDGE: topColor = borderPtr->lightGC->foreground; bottomColor = borderPtr->darkGC->foreground; break; case TK_RELIEF_GROOVE: topColor = borderPtr->darkGC->foreground; bottomColor = borderPtr->lightGC->foreground; break; case TK_RELIEF_FLAT: topColor = bottomColor = borderPtr->bgGC->foreground; break; case TK_RELIEF_SOLID: topColor = bottomColor = RGB(0,0,0);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -