annotate lwlib/xlwgcs.c @ 853:2b6fa2618f76

[xemacs-hg @ 2002-05-28 08:44:22 by ben] merge my stderr-proc ws make-docfile.c: Fix places where we forget to check for EOF. code-init.el: Don't use CRLF conversion by default on process output. CMD.EXE and friends work both ways but Cygwin programs don't like the CRs. code-process.el, multicast.el, process.el: Removed. Improvements to call-process-internal: -- allows a buffer to be specified for input and stderr output -- use it on all systems -- implement C-g as documented -- clean up and comment call-process-region uses new call-process facilities; no temp file. remove duplicate funs in process.el. comment exactly how coding systems work and fix various problems. open-multicast-group now does similar coding-system frobbing to open-network-stream. dumped-lisp.el, faces.el, msw-faces.el: Fix some hidden errors due to code not being defined at the right time. xemacs.mak: Add -DSTRICT. ================================================================ ALLOW SEPARATION OF STDOUT AND STDERR IN PROCESSES ================================================================ Standard output and standard error can be processed separately in a process. Each can have its own buffer, its own mark in that buffer, and its filter function. You can specify a separate buffer for stderr in `start-process' to get things started, or use the new primitives: set-process-stderr-buffer process-stderr-buffer process-stderr-mark set-process-stderr-filter process-stderr-filter Also, process-send-region takes a 4th optional arg, a buffer. Currently always uses a pipe() under Unix to read the error output. (#### Would a PTY be better?) sysdep.h, sysproc.h, unexfreebsd.c, unexsunos4.c, nt.c, emacs.c, callproc.c, symsinit.h, sysdep.c, Makefile.in.in, process-unix.c: Delete callproc.c. Move child_setup() to process-unix.c. wait_for_termination() now only needed on a few really old systems. console-msw.h, event-Xt.c, event-msw.c, event-stream.c, event-tty.c, event-unixoid.c, events.h, process-nt.c, process-unix.c, process.c, process.h, procimpl.h: Rewrite the process methods to handle a separate channel for error input. Create Lstreams for reading in the error channel. Many process methods need change. In general the changes are fairly clear as they involve duplicating what's used for reading the normal stdout and changing for stderr -- although tedious, as such changes are required throughout the entire process code. Rewrote the code that reads process output to do two loops, one for stdout and one for stderr. gpmevent.c, tooltalk.c: set_process_filter takes an argument for stderr. ================================================================ NEW ERROR-TRAPPING MECHANISM ================================================================ Totally rewrite error trapping code to be unified and support more features. Basic function is call_trapping_problems(), which lets you specify, by means of flags, what sorts of problems you want trapped. these can include -- quit -- errors -- throws past the function -- creation of "display objects" (e.g. buffers) -- deletion of already-existing "display objects" (e.g. buffers) -- modification of already-existing buffers -- entering the debugger -- gc -- errors->warnings (ala suspended errors) etc. All other error funs rewritten in terms of this one. Various older mechanisms removed or rewritten. window.c, insdel.c, console.c, buffer.c, device.c, frame.c: When creating a display object, added call to note_object_created(), for use with trapping_problems mechanism. When deleting, call check_allowed_operation() and note_object deleted(). The trapping-problems code records the objects created since the call-trapping-problems began. Those objects can be deleted, but none others (i.e. previously existing ones). bytecode.c, cmdloop.c: internal_catch takes another arg. eval.c: Add long comments describing the "five lists" used to maintain state (backtrace, gcpro, specbind, etc.) in the Lisp engine. backtrace.h, eval.c: Implement trapping-problems mechanism, eliminate old mechanisms or redo in terms of new one. frame.c, gutter.c: Flush out the concept of "critical display section", defined by the in_display() var. Use an internal_bind() to get it reset, rather than just doing it at end, because there may be a non-local exit. event-msw.c, event-stream.c, console-msw.h, device.c, dialog-msw.c, frame.c, frame.h, intl.c, toolbar.c, menubar-msw.c, redisplay.c, alloc.c, menubar-x.c: Make use of new trapping-errors stuff and rewrite code based on old mechanisms. glyphs-widget.c, redisplay.h: Protect calling Lisp in redisplay. insdel.c: Protect hooks against deleting existing buffers. frame-msw.c: Use EQ, not EQUAL in hash tables whose keys are just numbers. Otherwise we run into stickiness in redisplay because internal_equal() can QUIT. ================================================================ SIGNAL, C-G CHANGES ================================================================ Here we change the way that C-g interacts with event reading. The idea is that a C-g occurring while we're reading a user event should be read as C-g, but elsewhere should be a QUIT. The former code did all sorts of bizarreness -- requiring that no QUIT occurs anywhere in event-reading code (impossible to enforce given the stuff called or Lisp code invoked), and having some weird system involving enqueue/dequeue of a C-g and interaction with Vquit_flag -- and it didn't work. Now, we simply enclose all code where we want C-g read as an event with {begin/end}_dont_check_for_quit(). This completely turns off the mechanism that checks (and may remove or alter) C-g in the read-ahead queues, so we just get the C-g normal. Signal.c documents this very carefully. cmdloop.c: Correct use of dont_check_for_quit to new scheme, remove old out-of-date comments. event-stream.c: Fix C-g handling to actually work. device-x.c: Disable quit checking when err out. signal.c: Cleanup. Add large descriptive comment. process-unix.c, process-nt.c, sysdep.c: Use QUIT instead of REALLY_QUIT. It's not necessary to use REALLY_QUIT and just confuses the issue. lisp.h: Comment quit handlers. ================================================================ CONS CHANGES ================================================================ free_cons() now takes a Lisp_Object not the result of XCONS(). car and cdr have been renamed so that they don't get used directly; go through XCAR(), XCDR() instead. alloc.c, dired.c, editfns.c, emodules.c, fns.c, glyphs-msw.c, glyphs-x.c, glyphs.c, keymap.c, minibuf.c, search.c, eval.c, lread.c, lisp.h: Correct free_cons calling convention: now takes Lisp_Object, not Lisp_Cons chartab.c: Eliminate direct use of ->car, ->cdr, should be black box. callint.c: Rewrote using EXTERNAL_LIST_LOOP to avoid use of Lisp_Cons. ================================================================ USE INTERNAL-BIND-* ================================================================ eval.c: Cleanups of these funs. alloc.c, fileio.c, undo.c, specifier.c, text.c, profile.c, lread.c, redisplay.c, menubar-x.c, macros.c: Rewrote to use internal_bind_int() and internal_bind_lisp_object() in place of whatever varied and cumbersome mechanisms were formerly there. ================================================================ SPECBIND SANITY ================================================================ backtrace.h: - Improved comments backtrace.h, bytecode.c, eval.c: Add new mechanism check_specbind_stack_sanity() for sanity checking code each time the catchlist or specbind stack change. Removed older prototype of same mechanism. ================================================================ MISC ================================================================ lisp.h, insdel.c, window.c, device.c, console.c, buffer.c: Fleshed out authorship. device-msw.c: Correct bad Unicode-ization. print.c: Be more careful when not initialized or in fatal error handling. search.c: Eliminate running_asynch_code, an FSF holdover. alloc.c: Added comments about gc-cons-threshold. dialog-x.c: Use begin_gc_forbidden() around code to build up a widget value tree, like in menubar-x.c. gui.c: Use Qunbound not Qnil as the default for gethash. lisp-disunion.h, lisp-union.h: Added warnings on use of VOID_TO_LISP(). lisp.h: Use ERROR_CHECK_STRUCTURES to turn on ERROR_CHECK_TRAPPING_PROBLEMS and ERROR_CHECK_TYPECHECK lisp.h: Add assert_with_message. lisp.h: Add macros for gcproing entire arrays. (You could do this before but it required manual twiddling the gcpro structure.) lisp.h: Add prototypes for new functions defined elsewhere.
author ben
date Tue, 28 May 2002 08:45:36 +0000
parents c33ae14dd6d0
children 04bc9d2f42c7
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,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
234 int contrast, Bool be_nice_to_cmap)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
235 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
236 XGCValues values ;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
237 unsigned long vmask, dcmask ;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
238
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
239 values.foreground = fg ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
240 values.background = bg ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
241 values.font = font ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
242
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
243 if( font != None ) {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
244 vmask = GCForeground|GCFont ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
245 dcmask = GCSubwindowMode|GCDashOffset|
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
246 GCDashList|GCArcMode|GCGraphicsExposures ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
247 } else {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
248 vmask = GCForeground;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
249 dcmask = GCFont|GCSubwindowMode|GCDashOffset|
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
250 GCDashList|GCArcMode|GCGraphicsExposures ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
251 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
252 #ifdef HAVE_XMU
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
253 if( be_nice_to_cmap || w->core.depth == 1)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
254 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
255 if( contrast <= 5 )
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
256 values.foreground = bg ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
257 else if( contrast >= 95 )
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
258 values.foreground = fg ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
259 else {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
260 vmask |= GCBackground|GCStipple|GCFillStyle ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
261 values.fill_style = FillOpaqueStippled ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
262 values.stipple = getDitherPixmap(w, contrast) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
263 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
264
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
265 return XtAllocateGC(w, w->core.depth, vmask, &values, 0L, dcmask) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
266 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
267 else
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
268 #endif
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 dcmask |= GCBackground ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
271 values.foreground = AllocGreyPixel(w, fg, bg, contrast) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
272 return XtAllocateGC(w, w->core.depth, vmask, &values, 0L, dcmask) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
273 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
274 }
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 /* return top-shadow gc. */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
277
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
278 GC
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
279 AllocTopShadowGC(Widget w, int contrast, Bool be_nice_to_cmap)
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 Screen *scr = XtScreen (w);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
282 XGCValues values ;
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 if( w->core.depth == 1 )
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
285 values.foreground = BlackPixelOfScreen(scr) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
286 else if( be_nice_to_cmap )
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
287 values.foreground = WhitePixelOfScreen(scr) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
288 else
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
289 values.foreground = AllocShadowPixel(w, 100+contrast) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
290
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
291 return XtAllocateGC(w, w->core.depth,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
292 GCForeground, &values,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
293 0L,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
294 GCBackground|GCFont|GCSubwindowMode|GCGraphicsExposures|
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
295 GCDashOffset|GCDashList|GCArcMode) ;
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
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
298 /* return bottom-shadow gc. */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
299
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
300 GC
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
301 AllocBotShadowGC(Widget w, int contrast, Bool be_nice_to_cmap)
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 Screen *scr = XtScreen (w);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
304 XGCValues values ;
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 if( w->core.depth == 1 || be_nice_to_cmap )
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
307 values.foreground = BlackPixelOfScreen(scr) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
308 else
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
309 values.foreground = AllocShadowPixel(w, 100-contrast) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
310
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
311 return XtAllocateGC(w, w->core.depth,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
312 GCForeground, &values,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
313 0L,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
314 GCBackground|GCFont|GCSubwindowMode|GCGraphicsExposures|
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
315 GCDashOffset|GCDashList|GCArcMode) ;
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
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
318 /* return arm-shadow gc. */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
319
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
320 GC
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
321 AllocArmGC(Widget w, int contrast, Bool be_nice_to_cmap)
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 Screen *scr = XtScreen (w);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
324 XGCValues values ;
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 /* Not clear exactly what we should do here. Take a look at
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
327 * Xaw3d to see what they do.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
328 */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
329 #ifdef HAVE_XMU
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
330 if( w->core.depth == 1 || be_nice_to_cmap )
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
331 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
332 values.background = w->core.background_pixel ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
333 if( values.background == BlackPixelOfScreen(scr) )
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
334 values.foreground = WhitePixelOfScreen(scr) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
335 else
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
336 values.foreground = BlackPixelOfScreen(scr) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
337 values.fill_style = FillStippled ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
338 values.stipple = XmuCreateStippledPixmap(XtScreen(w), 1L, 0L, 1) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
339
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
340 return XtAllocateGC(w, w->core.depth,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
341 GCForeground|GCBackground|GCStipple|GCFillStyle,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
342 &values, 0L,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
343 GCFont|GCSubwindowMode|GCGraphicsExposures|
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
344 GCDashOffset|GCDashList|GCArcMode) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
345 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 398
diff changeset
346 else
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
347 #endif
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
348 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
349 values.foreground = AllocShadowPixel(w, 100-contrast) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
350 return XtAllocateGC(w, w->core.depth,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
351 GCForeground, &values,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
352 0L,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
353 GCBackground|GCFont|GCSubwindowMode|GCGraphicsExposures|
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
354 GCDashOffset|GCDashList|GCArcMode) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
355 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
356 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
357
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
358
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
359 Pixel
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
360 AllocShadowPixel(Widget w, int scale)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
361 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
362 XColor get_c, set_c ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
363 Display *dpy = XtDisplay(w) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
364 Screen *scr = XtScreen(w) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
365 Colormap cmap ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
366 Pixel maxColor ;
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 cmap = w->core.colormap ;
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 get_c.pixel = w->core.background_pixel ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
371 if( get_c.pixel == WhitePixelOfScreen(scr) ||
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
372 get_c.pixel == BlackPixelOfScreen(scr) )
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 /* what we *ought* to do is choose gray75 as the base color,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
375 * or perhaps gray83. Instead, we choose colors that are
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
376 * the same as ThreeD would choose.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
377 */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
378 if( scale > 100 ) scale = 200 - scale ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
379 set_c.red = set_c.green = set_c.blue = 65535*scale/100 ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
380 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
381 else
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
382 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
383 XQueryColor(dpy, cmap, &get_c) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
384 /* adjust scale so that brightest component does not
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
385 * exceed 65535; otherwise hue would change.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
386 */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
387 if( scale > 100 ) {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
388 maxColor = Max(get_c.red, Max(get_c.green, get_c.blue)) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
389 if( scale*maxColor > 65535*100 )
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
390 scale = 65535*100/maxColor ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
391 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
392 set_c.red = scale * get_c.red / 100 ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
393 set_c.green = scale * get_c.green / 100 ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
394 set_c.blue = scale * get_c.blue / 100 ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
395 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
396 set_c.flags = DoRed | DoGreen | DoBlue ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
397 if( XAllocColor(dpy, cmap, &set_c) )
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
398 return set_c.pixel ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
399 else if( scale > 100 )
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
400 return WhitePixelOfScreen(scr) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
401 else
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
402 return BlackPixelOfScreen(scr) ;
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
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
405
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
406 /* Allocate a pixel partway between foreground and background */
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
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
409 Pixel
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
410 AllocGreyPixel(Widget w, Pixel fg, Pixel bg, int scale)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
411 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
412 XColor get_cf, get_cb ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
413 Display *dpy = XtDisplay(w) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
414 Colormap cmap ;
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 cmap = w->core.colormap ;
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 get_cf.pixel = fg ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
419 get_cb.pixel = bg ;
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 XQueryColor(dpy, cmap, &get_cf) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
422 XQueryColor(dpy, cmap, &get_cb) ;
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 return AllocGreyPixelC(w, &get_cf, &get_cb, scale) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
425 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
426
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
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
429 /* Allocate a pixel partway between foreground and background */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
430
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
431
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
432 Pixel
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
433 AllocGreyPixelC(Widget w, XColor *fg, XColor *bg, int scale)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
434 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
435 XColor set_c ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
436 Display *dpy = XtDisplay(w) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
437 int r,g,b ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
438 Colormap cmap = w->core.colormap ;
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 r = (fg->red * scale + bg->red * (100-scale)) / 100 ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
441 g = (fg->green * scale + bg->green * (100-scale)) / 100 ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
442 b = (fg->blue * scale + bg->blue * (100-scale)) / 100 ;
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 if( scale > 100 || scale < 0 ) /* look out for overflow */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
445 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
446 int minc, maxc ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
447 maxc = Max(r, Max(g,b)) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
448 minc = Min(r, Min(g,b)) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
449 if( maxc > 65535 )
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
450 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
451 maxc /= 16 ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
452 r = r*(65535/16) / maxc ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
453 g = g*(65535/16) / maxc ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
454 b = b*(65535/16) / maxc ;
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( minc < 0 )
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 r = Max(r,0) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
459 g = Max(g,0) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
460 b = Max(b,0) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
461 }
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
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
464 set_c.red = r ; set_c.green = g ; set_c.blue = b ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
465 set_c.flags = DoRed | DoGreen | DoBlue ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
466 (void)XAllocColor(dpy, cmap, &set_c) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
467 return set_c.pixel ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
468 }
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
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
471
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
472
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 /* draw a 3-d box */
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 void
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
477 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
478 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
479 Display *dpy = XtDisplay(w) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
480 Window win = XtWindow(w) ;
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 if( s == 0 ) return ;
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 if( s == 1 ) {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
485 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
486 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
487 XDrawLine(dpy,win,topgc, x,y, x,y+hgt-1) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
488 XDrawLine(dpy,win,topgc, x,y, x+wid-1,y) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
489 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
490 else
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
491 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
492 XPoint pts[6] ;
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 /* bottom-right shadow */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
495 pts[0].x = x ; pts[0].y = y + hgt ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
496 pts[1].x = s ; pts[1].y = -s ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
497 pts[2].x = wid-2*s ; pts[2].y = 0 ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
498 pts[3].x = 0 ; pts[3].y = -(hgt-2*s) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
499 pts[4].x = s ; pts[4].y = -s ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
500 pts[5].x = 0 ; pts[5].y = hgt ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
501 XFillPolygon(dpy,win,botgc, pts,6, Nonconvex,CoordModePrevious) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
502
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
503 /* top-left shadow */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
504 pts[0].x = x ; pts[0].y = y ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
505 pts[1].x = wid ; pts[1].y = 0 ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
506 pts[2].x = -s ; pts[2].y = s ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
507 pts[3].x = -wid+2*s ; pts[3].y = 0 ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
508 pts[4].x = 0 ; pts[4].y = hgt-2*s ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
509 pts[5].x = -s ; pts[5].y = s ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
510 XFillPolygon(dpy,win,topgc, pts,6, Nonconvex,CoordModePrevious) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
511 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
512 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
513
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
514 #if XtSpecificationRelease < 5
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
515
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
516 static GC
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
517 XtAllocateGC(Widget w, int depth, unsigned long mask, XGCValues *values,
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
518 unsigned long dynamic, unsigned long dontcare)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
519 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
520 return XtGetGC(w, mask, values) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
521 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
522 #endif
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
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
525 static unsigned char screen0[2] = {0,0} ;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
526 static unsigned char screen25[2] = {0,0xaa} ;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
527 static unsigned char screen75[2] = {0xaa,0xff} ;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
528 static unsigned char screen100[2] = {0xff,0xff} ;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
529
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
530 static Pixmap
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
531 getDitherPixmap(Widget w, int contrast)
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 Display *dpy = XtDisplay(w) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
534 Window win = XtWindow(w) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
535
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
536 if( contrast <= 5 )
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
537 return XCreateBitmapFromData(dpy,win, (char *)screen0, 2,2) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
538 else if( contrast <= 37 )
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
539 return XCreateBitmapFromData(dpy,win, (char *)screen25, 2,2) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
540 else if( contrast <= 62 )
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
541 return XmuCreateStippledPixmap(XtScreen(w), 1L, 0L, 1) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
542 else if( contrast <= 95 )
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
543 return XCreateBitmapFromData(dpy,win, (char *)screen75, 2,2) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
544 else
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
545 return XCreateBitmapFromData(dpy,win, (char *)screen100, 2,2) ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents:
diff changeset
546 }