# Copyright (c) 1990-1993 The Regents of the University of California. # Copyright (c) 1994-1996 Sun Microsystems, Inc. # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # # =head1 NAME Tk_Get3DBorder, Tk_Draw3DRectangle, Tk_Fill3DRectangle, Tk_Draw3DPolygon, Tk_Fill3DPolygon, Tk_3DVerticalBevel, Tk_3DHorizontalBevel, Tk_SetBackgroundFromBorder, Tk_NameOf3DBorder, Tk_3DBorderColor, Tk_3DBorderGC, Tk_Free3DBorder - draw borders with three-dimensional appearance =for category C Programming =head1 SYNOPSIS B<#include Etk.hE> Tk_3DBorder BIB<)> void BIB<)> void BIB<)> void BIB<)> void BIB<)> void B(IB<)> void B(IB<)> void BIB<)> char * BIB<)> XColor * BIB<)> GC * BIB<)> BIB<)> =head1 ARGUMENTS =over 4 =item Tcl_Interp *interp (in) Interpreter to use for error reporting. =item Tk_Window tkwin (in) Token for window (for all procedures except B, must be the window for which the border was allocated). =item Tk_Uid colorName (in) Textual description of color corresponding to background (flat areas). Illuminated edges will be brighter than this and shadowed edges will be darker than this. =item Drawable drawable (in) X token for window or pixmap; indicates where graphics are to be drawn. Must either be the X window for I or a pixmap with the same screen and depth as I. =item Tk_3DBorder border (in) Token for border previously allocated in call to B. =item int x (in) X-coordinate of upper-left corner of rectangle describing border or bevel, in pixels. =item int y (in) Y-coordinate of upper-left corner of rectangle describing border or bevel, in pixels. =item int width (in) Width of rectangle describing border or bevel, in pixels. =item int height (in) Height of rectangle describing border or bevel, in pixels. =item int borderWidth (in) Width of border in pixels. Positive means border is inside rectangle given by I, I, I, I, negative means border is outside rectangle. =item int relief (in) Indicates 3-D position of interior of object relative to exterior; should be TK_RELIEF_RAISED, TK_RELIEF_SUNKEN, TK_RELIEF_GROOVE, TK_RELIEF_SOLID, or TK_RELIEF_RIDGE (may also be TK_RELIEF_FLAT for B). =item XPoint *pointPtr (in) Pointer to array of points describing the set of vertices in a polygon. The polygon need not be closed (it will be closed automatically if it isn't). =item int numPoints (in) Number of points at I<*pointPtr>. =item int polyBorderWidth (in) Width of border in pixels. If positive, border is drawn to left of trajectory given by I; if negative, border is drawn to right of trajectory. If I is TK_RELIEF_GROOVE or TK_RELIEF_RIDGE then the border is centered on the trajectory. =item int leftRelief (in) Height of left side of polygon's path relative to right. TK_RELIEF_RAISED means left side should appear higher and TK_RELIEF_SUNKEN means right side should appear higher; TK_RELIEF_GROOVE and TK_RELIEF_RIDGE mean the obvious things. For B, TK_RELIEF_FLAT may also be specified to indicate no difference in height. =item int leftBevel (in) Non-zero means this bevel forms the left side of the object; zero means it forms the right side. =item int leftIn (in) Non-zero means that the left edge of the horizontal bevel angles in, so that the bottom of the edge is farther to the right than the top. Zero means the edge angles out, so that the bottom is farther to the left than the top. =item int rightIn (in) Non-zero means that the right edge of the horizontal bevel angles in, so that the bottom of the edge is farther to the left than the top. Zero means the edge angles out, so that the bottom is farther to the right than the top. =item int topBevel (in) Non-zero means this bevel forms the top side of the object; zero means it forms the bottom side. =item int which (in) Specifies which of the border's graphics contexts is desired. Must be TK_3D_FLAT_GC, TK_3D_LIGHT_GC, or TK_3D_DARK_GC. =back =head1 DESCRIPTION These procedures provide facilities for drawing window borders in a way that produces a three-dimensional appearance. B allocates colors and Pixmaps needed to draw a border in the window given by the I argument. The I argument indicates what colors should be used in the border. I may be any value acceptable to B. The color indicated by I will not actually be used in the border; it indicates the background color for the window (i.e. a color for flat surfaces). The illuminated portions of the border will appear brighter than indicated by I, and the shadowed portions of the border will appear darker than I. B returns a token that may be used in later calls to B. If an error occurs in allocating information for the border (e.g. I isn't a legal color specifier), then NULL is returned and an error message is left in Iresult>. Once a border structure has been created, B may be invoked to draw the border. The I argument specifies the window for which the border was allocated, and I specifies a window or pixmap in which the border is to be drawn. I need not refer to the same window as I, but it must refer to a compatible pixmap or window: one associated with the same screen and with the same depth as I. The I, I, I, and I arguments define the bounding box of the border region within I (usually I and I are zero and I and I are the dimensions of the window), and I specifies the number of pixels actually occupied by the border. The I argument indicates which of several three-dimensional effects is desired: TK_RELIEF_RAISED means that the interior of the rectangle should appear raised relative to the exterior of the rectangle, and TK_RELIEF_SUNKEN means that the interior should appear depressed. TK_RELIEF_GROOVE and TK_RELIEF_RIDGE mean that there should appear to be a groove or ridge around the exterior of the rectangle. B is somewhat like B except that it first fills the rectangular area with the background color (one corresponding to the I used to create I). Then it calls B to draw a border just inside the outer edge of the rectangular area. The argument I indicates the desired effect (TK_RELIEF_FLAT means no border should be drawn; all that happens is to fill the rectangle with the background color). The procedure B may be used to draw more complex shapes with a three-dimensional appearance. The I and I arguments define a trajectory, I indicates how wide the border should be (and on which side of the trajectory to draw it), and I indicates which side of the trajectory should appear raised. B draws a border around the given trajectory using the colors from I to produce a three-dimensional appearance. If the trajectory is non-self-intersecting, the appearance will be a raised or sunken polygon shape. The trajectory may be self-intersecting, although it's not clear how useful this is. B is to B what B is to B: it fills the polygonal area with the background color from I, then calls B to draw a border around the area (unless I is TK_RELIEF_FLAT; in this case no border is drawn). The procedures B and B provide lower-level drawing primitives that are used by procedures such as B. These procedures are also useful in their own right for drawing rectilinear border shapes. B draws a vertical beveled edge, such as the left or right side of a rectangle, and B draws a horizontal beveled edge, such as the top or bottom of a rectangle. Each procedure takes I, I, I, and I arguments that describe the rectangular area of the beveled edge (e.g., I is the border width for B). The I and I arguments indicate the position of the border relative to the ``inside'' of the object, and I indicates the relief of the inside of the object relative to the outside. B just draws a rectangular region. B draws a trapezoidal region to generate mitered corners; it should be called after B (otherwise B will overwrite the mitering in the corner). The I and I arguments to B describe the mitering at the corners; a value of 1 means that the bottom edge of the trapezoid will be shorter than the top, 0 means it will be longer. For example, to draw a rectangular border the top bevel should be drawn with 1 for both I and I, and the bottom bevel should be drawn with 0 for both arguments. The procedure B will modify the background pixel and/or pixmap of I to produce a result compatible with I. For color displays, the resulting background will just be the color given by the I argument passed to B when I was created; for monochrome displays, the resulting background will be a light stipple pattern, in order to distinguish the background from the illuminated portion of the border. Given a token for a border, the procedure B will return the I string that was passed to B to create the border. The procedure B returns the XColor structure that will be used for flat surfaces drawn for its I argument by procedures like B. The return value corresponds to the I passed to B. The XColor, and its associated pixel value, will remain allocated as long as I exists. The procedure B returns one of the X graphics contexts that are used to draw the border. The argument I selects which one of the three possible GC's: TK_3D_FLAT_GC returns the context used for flat surfaces, TK_3D_LIGHT_GC returns the context for light shadows, and TK_3D_DARK_GC returns the context for dark shadows. When a border is no longer needed, B should be called to release the resources associated with the border. There should be exactly one call to B for each call to B. =head1 KEYWORDS 3D, background, border, color, depressed, illumination, polygon, raised, shadow, three-dimensional effect