annotate lwlib/xlwgcs.c @ 4539:061e030e3270

Fix some bugs in load-history construction, built-in symbol file names. lib-src/ChangeLog addition: 2008-12-27 Aidan Kehoe <kehoea@parhasard.net> * make-docfile.c (main): Allow more than one -d argument, followed by a directory to change to. (put_filename): Don't strip directory information; with previous change, allows retrieval of Lisp function and variable origin files from #'built-in-symbol-file relative to lisp-directory. (scan_lisp_file): Don't add an extraneous newline after the file name, put_filename has added the newline already. lisp/ChangeLog addition: 2008-12-27 Aidan Kehoe <kehoea@parhasard.net> * loadup.el (load-history): Add the contents of current-load-list to load-history before clearing it. Move the variable declarations earlier in the file to a format understood by make-docfile.c. * custom.el (custom-declare-variable): Add the variable's symbol to the current file's load history entry correctly, don't use a cons. Eliminate a comment that we don't need to worry about, we don't need to check the `initialized' C variable in Lisp. * bytecomp.el (byte-compile-output-file-form): Merge Andreas Schwab's pre-GPLv3 GNU change of 19970831 here; treat #'custom-declare-variable correctly, generating the docstrings in a format understood by make-docfile.c. * loadhist.el (symbol-file): Correct behaviour for checking autoloaded macros and functions when supplied with a TYPE argument. Accept fully-qualified paths from #'built-in-symbol-file; if a path is not fully-qualified, return it relative to lisp-directory if the filename corresponds to a Lisp file, and relative to (concat source-directory "/src/") otherwise. * make-docfile.el (preloaded-file-list): Rationalise some let bindings a little. Use the "-d" argument to make-docfile.c to supply Lisp paths relative to lisp-directory, not absolutely. Add in loadup.el explicitly to the list of files to be processed by make-docfile.c--it doesn't make sense to add it to preloaded-file-list, since that is used for purposes of byte-compilation too. src/ChangeLog addition: 2008-12-27 Aidan Kehoe <kehoea@parhasard.net> * doc.c (Fbuilt_in_symbol_file): Return a subr's filename immediately if we've found it. Check for compiled function and compiled macro docstrings in DOC too, and return them if they exist. The branch of the if statement focused on functions may have executed, but we may still want to check variable bindings; an else clause isn't appropriate.
author Aidan Kehoe <kehoea@parhasard.net>
date Sat, 27 Dec 2008 14:05:50 +0000
parents 04bc9d2f42c7
children 5460287a3327
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
1 /* Tabs Widget for XEmacs.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
2 Copyright (C) 1999 Edward A. Falk
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 398
diff changeset
3
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
4 This file is part of XEmacs.
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 398
diff changeset
5
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
6 XEmacs is free software; you can redistribute it and/or modify it
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
7 under the terms of the GNU General Public License as published by the
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
8 Free Software Foundation; either version 2, or (at your option) any
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
9 later version.
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 398
diff changeset
10
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
14 for more details.
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 398
diff changeset
15
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
17 along with XEmacs; see the file COPYING. If not, write to
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
19 Boston, MA 02111-1307, USA. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 398
diff changeset
20
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
21 /* Synched up with: Gcs.c 1.7 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 398
diff changeset
22
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
23 /* #### This code is duplicated many times within lwlib and XEmacs. It
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
24 should be modularised. */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
25
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
26 /*
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
27 * Gcs.c - Utility functions to allocate GCs.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
28 *
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
29 * Author: Edward A. Falk
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
30 * falk@falconer.vip.best.com
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
31 *
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
32 * Date: Sept 29, 1998
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
33 */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
34
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
35 /* Functions:
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
36 *
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
37 * GC AllocFgGC(w, fg, font)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
38 * Return a GC with foreground set as specified.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
39 * If font is None, then the returned GC is allocated with font specified
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
40 * as a "don't care" value.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
41 *
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
42 * GC
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
43 * AllocBackgroundGC(w, font)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
44 * Return a GC with the foreground set to the widget's background color.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
45 *
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
46 * GC
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
47 * AllocGreyGC(w, fg, font, contrast, be_nice_to_cmap)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
48 * Widget w ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
49 * Pixel fg ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
50 * Font font ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
51 * int contrast ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
52 * int be_nice_to_cmap ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
53 *
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
54 * Return a GC suitable for rendering a widget in its "inactive" color.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
55 * Normally returns a GC with a color somewhere between the widget's
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
56 * background color and the specified foreground. If font is None, then
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
57 * the returned GC is allocated with font specified as "don't care".
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
58 * If be_nice_to_cmap is True, the returned GC is created using a 50%
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
59 * dither instead of a new color.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
60 *
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
61 *
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
62 * GC
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
63 * AllocShadeGC(w, fg, bg, font, contrast, be_nice_to_cmap)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
64 * Widget w ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
65 * Pixel fg, bg ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
66 * Font font ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
67 * int contrast ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
68 * int be_nice_to_cmap ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
69 *
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
70 * Return a GC suitable for rendering in a shade somewhere between
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
71 * bg and fg, as determined by contrast (0 = bg, 100 = fg)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
72 * If font is None, then the returned GC is allocated with
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
73 * font specified as "don't care". If be_nice_to_cmap
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
74 * is True, the returned GC is created using a 50% dither
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
75 * instead of a new color.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
76 *
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
77 *
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
78 * GC
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
79 * AllocTopShadowGC(w, contrast, be_nice_to_cmap)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
80 * Return a GC suitable for rendering the "top shadow" decorations of
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
81 * a widget. Returns a GC with foreground computed from widget's
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
82 * background color and contrast. If be_nice_to_cmap is True, the
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
83 * returned GC will use a foreground color of white. If widget depth
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
84 * is 1, this function will use a foreground color of black.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
85 *
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
86 * GC
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
87 * AllocBotShadowGC(w, contrast, be_nice_to_cmap)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
88 * Return a GC suitable for rendering the "bottom shadow" decorations
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
89 * of a widget. Returns a GC with foreground computed from widget's
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
90 * background color and contrast. If be_nice_to_cmap is True, the
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
91 * returned GC will use a foreground color of black.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
92 *
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
93 * GC
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
94 * AllocArmGC(w, contrast, be_nice_to_cmap)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
95 * Return a GC suitable for rendering the "armed" decorations of a
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
96 * widget. This GC would typically be used to fill in the widget's
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
97 * background. Returns a GC with foreground computed from widget's
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
98 * background color and contrast. If be_nice_to_cmap is True, the
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
99 * returned GC will use a foreground color of black and a 50% dither.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
100 *
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
101 *
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
102 * void
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
103 * Draw3dBox(w, x,y,wid,hgt,s, topgc, botgc)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
104 * Utility function. Draws a raised shadow box with outside dimensions
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
105 * as specified by x,y,wid,hgt and shadow width specified by s.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
106 * A lowered shadow box may be generated by swapping topgc and botgc.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
107 *
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
108 */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
109
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
110 #include <config.h>
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
111 #include <stdio.h>
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
112
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
113 #include <X11/Xlib.h>
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
114 #include <X11/IntrinsicP.h>
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
115 #include <X11/StringDefs.h>
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
116 #include "../src/xmu.h"
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
117 #include "xlwgcs.h"
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
118
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
119 /* Color & GC allocation.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
120 *
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
121 * Frame widgets use the following graphics contexts:
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
122 *
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
123 * Foreground tab label text drawn this way
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
124 * Insensitive Fg foreground color greyed out.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
125 * Background frame background color
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
126 * Top shadow upper-left highlight around widget
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
127 * Bottom shadow lower-right highlight around widget
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
128 * Arm shadow button pressed and ready to be released
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
129 *
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
130 *
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
131 * GC's are defined as follows, depending on attributes and
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
132 * window depth:
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
133 *
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
134 * Monochrome:
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
135 * Foreground = foreground color attribute or BlackPixel()
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
136 * Grey = Foreground color + 50% dither
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
137 * Background = background color attribute or WhitePixel()
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
138 * top shadow = foreground
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
139 * bottom shadow = foreground
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
140 * arm shadow = (what?)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
141 *
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
142 * Color, beNiceToColormap=true:
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
143 * Foreground = foreground color attribute or BlackPixel()
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
144 * Grey = Foreground color + 50% dither
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
145 * Background = background color attribute or WhitePixel()
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
146 * top shadow = white
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
147 * bottom shadow = black
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
148 * arm shadow = (what?)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
149 *
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
150 * Color, beNiceToColormap=false:
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
151 * Foreground = foreground color attribute or BlackPixel()
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
152 * Grey = (foreground color + background color)/2
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
153 * Background = background color attribute or WhitePixel()
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
154 * top shadow = background * 1.2
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
155 * bottom shadow = background * .6
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
156 * arm shadow = background * .8
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
157 *
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
158 * Special cases:
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
159 * If background is white, ??
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
160 * if background is black, ??
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
161 *
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
162 *
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
163 * If the widget's background is solid white or solid black,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
164 * this code just picks some numbers. (The choice is designed
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 398
diff changeset
165 * to be compatible with ThreeD interface.)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
166 */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
167
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
168
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
169
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
170 #if XtSpecificationRelease < 5
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
171
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
172 static GC XtAllocateGC(Widget, int, unsigned long, XGCValues *,
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
173 unsigned long, unsigned long) ;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
174
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
175 #endif
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
176
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
177
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
178 #if NeedFunctionPrototypes
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
179 static Pixmap getDitherPixmap(Widget, int contrast) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
180 #else
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
181 static Pixmap getDitherPixmap() ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
182 #endif
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
183
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
184 /* return a GC with the specified foreground and optional font */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
185
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
186 GC
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
187 AllocFgGC(Widget w, Pixel fg, Font font)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
188 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
189 XGCValues values ;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
190 unsigned long vmask, dcmask ;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
191
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
192 values.foreground = fg ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
193 values.font = font ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
194
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
195 if( font != None ) {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
196 vmask = GCForeground|GCFont ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
197 dcmask = GCSubwindowMode|GCDashOffset|
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
198 GCDashList|GCArcMode|GCBackground|GCGraphicsExposures ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
199 } else {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
200 vmask = GCForeground ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
201 dcmask = GCFont|GCSubwindowMode|GCDashOffset|
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
202 GCDashList|GCArcMode|GCBackground|GCGraphicsExposures ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
203 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
204
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
205 return XtAllocateGC(w, w->core.depth, vmask, &values, 0L, dcmask) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
206 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
207
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
208
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
209 /* return gc with widget background color as the foreground */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
210
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
211 GC
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
212 AllocBackgroundGC(Widget w, Font font)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
213 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
214 return AllocFgGC(w, w->core.background_pixel, font) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
215 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
216
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
217
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
218 /* Allocate an "inactive" GC. Color is grey (possibly via
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
219 * dither pattern).
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
220 */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
221
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
222 GC
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
223 AllocGreyGC(Widget w, Pixel fg, Font font, int contrast, Bool be_nice_to_cmap)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
224 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
225 return AllocShadeGC(w, fg, w->core.background_pixel,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
226 font, contrast, be_nice_to_cmap) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
227 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
228
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
229
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
230 /* Allocate a GC somewhere between two colors. */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
231
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
232 GC
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
233 AllocShadeGC(Widget w, Pixel fg, Pixel bg, Font font,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 458
diff changeset
234 int contrast,
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 458
diff changeset
235 #ifdef HAVE_XMU
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 458
diff changeset
236 Bool be_nice_to_cmap
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 458
diff changeset
237 #else
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 458
diff changeset
238 Bool UNUSED (be_nice_to_cmap)
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 458
diff changeset
239 #endif
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 458
diff changeset
240 )
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
241 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
242 XGCValues values ;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
243 unsigned long vmask, dcmask ;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
244
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
245 values.foreground = fg ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
246 values.background = bg ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
247 values.font = font ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
248
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
249 if( font != None ) {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
250 vmask = GCForeground|GCFont ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
251 dcmask = GCSubwindowMode|GCDashOffset|
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
252 GCDashList|GCArcMode|GCGraphicsExposures ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
253 } else {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
254 vmask = GCForeground;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
255 dcmask = GCFont|GCSubwindowMode|GCDashOffset|
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
256 GCDashList|GCArcMode|GCGraphicsExposures ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
257 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
258 #ifdef HAVE_XMU
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
259 if( be_nice_to_cmap || w->core.depth == 1)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
260 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
261 if( contrast <= 5 )
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
262 values.foreground = bg ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
263 else if( contrast >= 95 )
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
264 values.foreground = fg ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
265 else {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
266 vmask |= GCBackground|GCStipple|GCFillStyle ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
267 values.fill_style = FillOpaqueStippled ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
268 values.stipple = getDitherPixmap(w, contrast) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
269 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
270
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
271 return XtAllocateGC(w, w->core.depth, vmask, &values, 0L, dcmask) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
272 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
273 else
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
274 #endif
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
275 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
276 dcmask |= GCBackground ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
277 values.foreground = AllocGreyPixel(w, fg, bg, contrast) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
278 return XtAllocateGC(w, w->core.depth, vmask, &values, 0L, dcmask) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
279 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
280 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
281
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
282 /* return top-shadow gc. */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
283
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
284 GC
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
285 AllocTopShadowGC(Widget w, int contrast, Bool be_nice_to_cmap)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
286 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
287 Screen *scr = XtScreen (w);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
288 XGCValues values ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
289
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
290 if( w->core.depth == 1 )
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
291 values.foreground = BlackPixelOfScreen(scr) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
292 else if( be_nice_to_cmap )
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
293 values.foreground = WhitePixelOfScreen(scr) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
294 else
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
295 values.foreground = AllocShadowPixel(w, 100+contrast) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
296
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
297 return XtAllocateGC(w, w->core.depth,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
298 GCForeground, &values,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
299 0L,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
300 GCBackground|GCFont|GCSubwindowMode|GCGraphicsExposures|
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
301 GCDashOffset|GCDashList|GCArcMode) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
302 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
303
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
304 /* return bottom-shadow gc. */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
305
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
306 GC
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
307 AllocBotShadowGC(Widget w, int contrast, Bool be_nice_to_cmap)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
308 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
309 Screen *scr = XtScreen (w);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
310 XGCValues values ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
311
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
312 if( w->core.depth == 1 || be_nice_to_cmap )
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
313 values.foreground = BlackPixelOfScreen(scr) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
314 else
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
315 values.foreground = AllocShadowPixel(w, 100-contrast) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
316
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
317 return XtAllocateGC(w, w->core.depth,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
318 GCForeground, &values,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
319 0L,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
320 GCBackground|GCFont|GCSubwindowMode|GCGraphicsExposures|
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
321 GCDashOffset|GCDashList|GCArcMode) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
322 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
323
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
324 /* return arm-shadow gc. */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
325
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
326 GC
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 458
diff changeset
327 AllocArmGC(Widget w, int contrast,
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 458
diff changeset
328 #ifdef HAVE_XMU
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 458
diff changeset
329 Bool be_nice_to_cmap
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 458
diff changeset
330 #else
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 458
diff changeset
331 Bool UNUSED (be_nice_to_cmap)
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 458
diff changeset
332 #endif
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 458
diff changeset
333 )
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
334 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
335 Screen *scr = XtScreen (w);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
336 XGCValues values ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
337
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
338 /* Not clear exactly what we should do here. Take a look at
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
339 * Xaw3d to see what they do.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
340 */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
341 #ifdef HAVE_XMU
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
342 if( w->core.depth == 1 || be_nice_to_cmap )
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
343 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
344 values.background = w->core.background_pixel ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
345 if( values.background == BlackPixelOfScreen(scr) )
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
346 values.foreground = WhitePixelOfScreen(scr) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
347 else
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
348 values.foreground = BlackPixelOfScreen(scr) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
349 values.fill_style = FillStippled ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
350 values.stipple = XmuCreateStippledPixmap(XtScreen(w), 1L, 0L, 1) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
351
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
352 return XtAllocateGC(w, w->core.depth,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
353 GCForeground|GCBackground|GCStipple|GCFillStyle,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
354 &values, 0L,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
355 GCFont|GCSubwindowMode|GCGraphicsExposures|
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
356 GCDashOffset|GCDashList|GCArcMode) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
357 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 398
diff changeset
358 else
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
359 #endif
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
360 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
361 values.foreground = AllocShadowPixel(w, 100-contrast) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
362 return XtAllocateGC(w, w->core.depth,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
363 GCForeground, &values,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
364 0L,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
365 GCBackground|GCFont|GCSubwindowMode|GCGraphicsExposures|
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
366 GCDashOffset|GCDashList|GCArcMode) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
367 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
368 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
369
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
370
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
371 Pixel
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
372 AllocShadowPixel(Widget w, int scale)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
373 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
374 XColor get_c, set_c ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
375 Display *dpy = XtDisplay(w) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
376 Screen *scr = XtScreen(w) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
377 Colormap cmap ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
378 Pixel maxColor ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
379
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
380 cmap = w->core.colormap ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
381
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
382 get_c.pixel = w->core.background_pixel ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
383 if( get_c.pixel == WhitePixelOfScreen(scr) ||
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
384 get_c.pixel == BlackPixelOfScreen(scr) )
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
385 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
386 /* what we *ought* to do is choose gray75 as the base color,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
387 * or perhaps gray83. Instead, we choose colors that are
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
388 * the same as ThreeD would choose.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
389 */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
390 if( scale > 100 ) scale = 200 - scale ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
391 set_c.red = set_c.green = set_c.blue = 65535*scale/100 ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
392 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
393 else
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
394 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
395 XQueryColor(dpy, cmap, &get_c) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
396 /* adjust scale so that brightest component does not
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
397 * exceed 65535; otherwise hue would change.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
398 */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
399 if( scale > 100 ) {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
400 maxColor = Max(get_c.red, Max(get_c.green, get_c.blue)) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
401 if( scale*maxColor > 65535*100 )
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
402 scale = 65535*100/maxColor ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
403 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
404 set_c.red = scale * get_c.red / 100 ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
405 set_c.green = scale * get_c.green / 100 ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
406 set_c.blue = scale * get_c.blue / 100 ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
407 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
408 set_c.flags = DoRed | DoGreen | DoBlue ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
409 if( XAllocColor(dpy, cmap, &set_c) )
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
410 return set_c.pixel ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
411 else if( scale > 100 )
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
412 return WhitePixelOfScreen(scr) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
413 else
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
414 return BlackPixelOfScreen(scr) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
415 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
416
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
417
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
418 /* Allocate a pixel partway between foreground and background */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
419
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
420
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
421 Pixel
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
422 AllocGreyPixel(Widget w, Pixel fg, Pixel bg, int scale)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
423 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
424 XColor get_cf, get_cb ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
425 Display *dpy = XtDisplay(w) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
426 Colormap cmap ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
427
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
428 cmap = w->core.colormap ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
429
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
430 get_cf.pixel = fg ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
431 get_cb.pixel = bg ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
432
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
433 XQueryColor(dpy, cmap, &get_cf) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
434 XQueryColor(dpy, cmap, &get_cb) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
435
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
436 return AllocGreyPixelC(w, &get_cf, &get_cb, scale) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
437 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
438
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
439
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
440
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
441 /* Allocate a pixel partway between foreground and background */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
442
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
443
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
444 Pixel
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
445 AllocGreyPixelC(Widget w, XColor *fg, XColor *bg, int scale)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
446 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
447 XColor set_c ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
448 Display *dpy = XtDisplay(w) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
449 int r,g,b ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
450 Colormap cmap = w->core.colormap ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
451
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
452 r = (fg->red * scale + bg->red * (100-scale)) / 100 ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
453 g = (fg->green * scale + bg->green * (100-scale)) / 100 ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
454 b = (fg->blue * scale + bg->blue * (100-scale)) / 100 ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
455
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
456 if( scale > 100 || scale < 0 ) /* look out for overflow */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
457 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
458 int minc, maxc ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
459 maxc = Max(r, Max(g,b)) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
460 minc = Min(r, Min(g,b)) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
461 if( maxc > 65535 )
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
462 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
463 maxc /= 16 ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
464 r = r*(65535/16) / maxc ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
465 g = g*(65535/16) / maxc ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
466 b = b*(65535/16) / maxc ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
467 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
468 if( minc < 0 )
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
469 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
470 r = Max(r,0) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
471 g = Max(g,0) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
472 b = Max(b,0) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
473 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
474 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
475
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
476 set_c.red = r ; set_c.green = g ; set_c.blue = b ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
477 set_c.flags = DoRed | DoGreen | DoBlue ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
478 (void)XAllocColor(dpy, cmap, &set_c) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
479 return set_c.pixel ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
480 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
481
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
482
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
483
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
484
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
485
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
486 /* draw a 3-d box */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
487
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
488 void
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
489 Draw3dBox(Widget w, int x, int y, int wid, int hgt, int s, GC topgc, GC botgc)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
490 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
491 Display *dpy = XtDisplay(w) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
492 Window win = XtWindow(w) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
493
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
494 if( s == 0 ) return ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
495
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
496 if( s == 1 ) {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
497 XDrawLine(dpy,win,botgc, x,y+hgt-1, x+wid-1,y+hgt-1) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
498 XDrawLine(dpy,win,botgc, x+wid-1,y, x+wid-1,y+hgt-1) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
499 XDrawLine(dpy,win,topgc, x,y, x,y+hgt-1) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
500 XDrawLine(dpy,win,topgc, x,y, x+wid-1,y) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
501 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
502 else
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
503 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
504 XPoint pts[6] ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
505
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
506 /* bottom-right shadow */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
507 pts[0].x = x ; pts[0].y = y + hgt ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
508 pts[1].x = s ; pts[1].y = -s ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
509 pts[2].x = wid-2*s ; pts[2].y = 0 ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
510 pts[3].x = 0 ; pts[3].y = -(hgt-2*s) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
511 pts[4].x = s ; pts[4].y = -s ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
512 pts[5].x = 0 ; pts[5].y = hgt ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
513 XFillPolygon(dpy,win,botgc, pts,6, Nonconvex,CoordModePrevious) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
514
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
515 /* top-left shadow */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
516 pts[0].x = x ; pts[0].y = y ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
517 pts[1].x = wid ; pts[1].y = 0 ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
518 pts[2].x = -s ; pts[2].y = s ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
519 pts[3].x = -wid+2*s ; pts[3].y = 0 ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
520 pts[4].x = 0 ; pts[4].y = hgt-2*s ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
521 pts[5].x = -s ; pts[5].y = s ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
522 XFillPolygon(dpy,win,topgc, pts,6, Nonconvex,CoordModePrevious) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
523 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
524 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
525
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
526 #if XtSpecificationRelease < 5
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
527
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
528 static GC
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 458
diff changeset
529 XtAllocateGC(Widget w, int UNUSED (depth), unsigned long mask,
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 458
diff changeset
530 XGCValues *values, unsigned long UNUSED (dynamic),
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 458
diff changeset
531 unsigned long UNUSED (dontcare))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
532 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
533 return XtGetGC(w, mask, values) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
534 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
535 #endif
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
536
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
537
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
538 static unsigned char screen0[2] = {0,0} ;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
539 static unsigned char screen25[2] = {0,0xaa} ;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
540 static unsigned char screen75[2] = {0xaa,0xff} ;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
541 static unsigned char screen100[2] = {0xff,0xff} ;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
542
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
543 static Pixmap
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
544 getDitherPixmap(Widget w, int contrast)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
545 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
546 Display *dpy = XtDisplay(w) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
547 Window win = XtWindow(w) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
548
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
549 if( contrast <= 5 )
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
550 return XCreateBitmapFromData(dpy,win, (char *)screen0, 2,2) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
551 else if( contrast <= 37 )
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
552 return XCreateBitmapFromData(dpy,win, (char *)screen25, 2,2) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
553 else if( contrast <= 62 )
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
554 return XmuCreateStippledPixmap(XtScreen(w), 1L, 0L, 1) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
555 else if( contrast <= 95 )
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
556 return XCreateBitmapFromData(dpy,win, (char *)screen75, 2,2) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
557 else
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
558 return XCreateBitmapFromData(dpy,win, (char *)screen100, 2,2) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
559 }