Mercurial > hg > xemacs-beta
annotate lwlib/xlwgcs.c @ 5551:40a52efbf3a3
Reflect change of location of packages to share/
2011-08-14 Mike Sperber <mike@xemacs.org>
* xemacs-faq.texi:
* xemacs/packages.texi: Reflect change of location of packages
from lib/ to share/.
| author | Mike Sperber <sperber@deinprogramm.de> |
|---|---|
| date | Sun, 14 Aug 2011 13:51:14 +0200 |
| parents | 308d34e9f07d |
| children | 574f0cded429 |
| rev | line source |
|---|---|
| 398 | 1 /* Tabs Widget for XEmacs. |
| 2 Copyright (C) 1999 Edward A. Falk | |
| 442 | 3 |
| 398 | 4 This file is part of XEmacs. |
| 442 | 5 |
|
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4769
diff
changeset
|
6 XEmacs is free software: you can redistribute it and/or modify it |
|
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4769
diff
changeset
|
7 under the terms of the GNU General Public License as published by the |
|
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4769
diff
changeset
|
8 Free Software Foundation, either version 3 of the License, or (at your |
|
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4769
diff
changeset
|
9 option) any later version. |
| 442 | 10 |
|
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4769
diff
changeset
|
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT |
|
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4769
diff
changeset
|
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4769
diff
changeset
|
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4769
diff
changeset
|
14 for more details. |
| 442 | 15 |
|
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4769
diff
changeset
|
16 You should have received a copy of the GNU General Public License |
|
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4769
diff
changeset
|
17 along with XEmacs. If not, see <http://www.gnu.org/licenses/>. */ |
| 442 | 18 |
| 398 | 19 /* Synched up with: Gcs.c 1.7 */ |
| 442 | 20 |
| 398 | 21 /* #### This code is duplicated many times within lwlib and XEmacs. It |
| 22 should be modularised. */ | |
| 23 | |
| 24 /* | |
| 25 * Gcs.c - Utility functions to allocate GCs. | |
| 26 * | |
| 27 * Author: Edward A. Falk | |
| 28 * falk@falconer.vip.best.com | |
| 29 * | |
| 30 * Date: Sept 29, 1998 | |
| 31 */ | |
| 32 | |
| 33 /* Functions: | |
| 34 * | |
| 35 * GC AllocFgGC(w, fg, font) | |
| 36 * Return a GC with foreground set as specified. | |
| 37 * If font is None, then the returned GC is allocated with font specified | |
| 38 * as a "don't care" value. | |
| 39 * | |
| 40 * GC | |
| 41 * AllocBackgroundGC(w, font) | |
| 42 * Return a GC with the foreground set to the widget's background color. | |
| 43 * | |
| 44 * GC | |
| 45 * AllocGreyGC(w, fg, font, contrast, be_nice_to_cmap) | |
| 46 * Widget w ; | |
| 47 * Pixel fg ; | |
| 48 * Font font ; | |
| 49 * int contrast ; | |
| 50 * int be_nice_to_cmap ; | |
| 51 * | |
| 52 * Return a GC suitable for rendering a widget in its "inactive" color. | |
| 53 * Normally returns a GC with a color somewhere between the widget's | |
| 54 * background color and the specified foreground. If font is None, then | |
| 55 * the returned GC is allocated with font specified as "don't care". | |
| 56 * If be_nice_to_cmap is True, the returned GC is created using a 50% | |
| 57 * dither instead of a new color. | |
| 58 * | |
| 59 * | |
| 60 * GC | |
| 61 * AllocShadeGC(w, fg, bg, font, contrast, be_nice_to_cmap) | |
| 62 * Widget w ; | |
| 63 * Pixel fg, bg ; | |
| 64 * Font font ; | |
| 65 * int contrast ; | |
| 66 * int be_nice_to_cmap ; | |
| 67 * | |
| 68 * Return a GC suitable for rendering in a shade somewhere between | |
| 69 * bg and fg, as determined by contrast (0 = bg, 100 = fg) | |
| 70 * If font is None, then the returned GC is allocated with | |
| 71 * font specified as "don't care". If be_nice_to_cmap | |
| 72 * is True, the returned GC is created using a 50% dither | |
| 73 * instead of a new color. | |
| 74 * | |
| 75 * | |
| 76 * GC | |
| 77 * AllocTopShadowGC(w, contrast, be_nice_to_cmap) | |
| 78 * Return a GC suitable for rendering the "top shadow" decorations of | |
| 79 * a widget. Returns a GC with foreground computed from widget's | |
| 80 * background color and contrast. If be_nice_to_cmap is True, the | |
| 81 * returned GC will use a foreground color of white. If widget depth | |
| 82 * is 1, this function will use a foreground color of black. | |
| 83 * | |
| 84 * GC | |
| 85 * AllocBotShadowGC(w, contrast, be_nice_to_cmap) | |
| 86 * Return a GC suitable for rendering the "bottom shadow" decorations | |
| 87 * of a widget. Returns a GC with foreground computed from widget's | |
| 88 * background color and contrast. If be_nice_to_cmap is True, the | |
| 89 * returned GC will use a foreground color of black. | |
| 90 * | |
| 91 * GC | |
| 92 * AllocArmGC(w, contrast, be_nice_to_cmap) | |
| 93 * Return a GC suitable for rendering the "armed" decorations of a | |
| 94 * widget. This GC would typically be used to fill in the widget's | |
| 95 * background. Returns a GC with foreground computed from widget's | |
| 96 * background color and contrast. If be_nice_to_cmap is True, the | |
| 97 * returned GC will use a foreground color of black and a 50% dither. | |
| 98 * | |
| 99 * | |
| 100 * void | |
| 101 * Draw3dBox(w, x,y,wid,hgt,s, topgc, botgc) | |
| 102 * Utility function. Draws a raised shadow box with outside dimensions | |
| 103 * as specified by x,y,wid,hgt and shadow width specified by s. | |
| 104 * A lowered shadow box may be generated by swapping topgc and botgc. | |
| 105 * | |
| 106 */ | |
| 107 | |
| 108 #include <config.h> | |
| 109 #include <stdio.h> | |
| 110 | |
| 111 #include <X11/Xlib.h> | |
| 112 #include <X11/IntrinsicP.h> | |
| 113 #include <X11/StringDefs.h> | |
|
4769
5460287a3327
Remove support for pre-X11R5 systems, including systems without Xmu. See
Jerry James <james@xemacs.org>
parents:
2286
diff
changeset
|
114 #include <X11/Xmu/Drawing.h> |
|
5460287a3327
Remove support for pre-X11R5 systems, including systems without Xmu. See
Jerry James <james@xemacs.org>
parents:
2286
diff
changeset
|
115 #include <X11/Xmu/Misc.h> |
| 398 | 116 #include "xlwgcs.h" |
| 117 | |
| 118 /* Color & GC allocation. | |
| 119 * | |
| 120 * Frame widgets use the following graphics contexts: | |
| 121 * | |
| 122 * Foreground tab label text drawn this way | |
| 123 * Insensitive Fg foreground color greyed out. | |
| 124 * Background frame background color | |
| 125 * Top shadow upper-left highlight around widget | |
| 126 * Bottom shadow lower-right highlight around widget | |
| 127 * Arm shadow button pressed and ready to be released | |
| 128 * | |
| 129 * | |
| 130 * GC's are defined as follows, depending on attributes and | |
| 131 * window depth: | |
| 132 * | |
| 133 * Monochrome: | |
| 134 * Foreground = foreground color attribute or BlackPixel() | |
| 135 * Grey = Foreground color + 50% dither | |
| 136 * Background = background color attribute or WhitePixel() | |
| 137 * top shadow = foreground | |
| 138 * bottom shadow = foreground | |
| 139 * arm shadow = (what?) | |
| 140 * | |
| 141 * Color, beNiceToColormap=true: | |
| 142 * Foreground = foreground color attribute or BlackPixel() | |
| 143 * Grey = Foreground color + 50% dither | |
| 144 * Background = background color attribute or WhitePixel() | |
| 145 * top shadow = white | |
| 146 * bottom shadow = black | |
| 147 * arm shadow = (what?) | |
| 148 * | |
| 149 * Color, beNiceToColormap=false: | |
| 150 * Foreground = foreground color attribute or BlackPixel() | |
| 151 * Grey = (foreground color + background color)/2 | |
| 152 * Background = background color attribute or WhitePixel() | |
| 153 * top shadow = background * 1.2 | |
| 154 * bottom shadow = background * .6 | |
| 155 * arm shadow = background * .8 | |
| 156 * | |
| 157 * Special cases: | |
| 158 * If background is white, ?? | |
| 159 * if background is black, ?? | |
| 160 * | |
| 161 * | |
| 162 * If the widget's background is solid white or solid black, | |
| 163 * this code just picks some numbers. (The choice is designed | |
| 442 | 164 * to be compatible with ThreeD interface.) |
| 398 | 165 */ |
| 166 | |
| 167 | |
| 168 | |
| 169 #if NeedFunctionPrototypes | |
| 170 static Pixmap getDitherPixmap(Widget, int contrast) ; | |
| 171 #else | |
| 172 static Pixmap getDitherPixmap() ; | |
| 173 #endif | |
| 174 | |
| 175 /* return a GC with the specified foreground and optional font */ | |
| 176 | |
| 177 GC | |
| 178 AllocFgGC(Widget w, Pixel fg, Font font) | |
| 179 { | |
| 180 XGCValues values ; | |
| 458 | 181 unsigned long vmask, dcmask ; |
| 398 | 182 |
| 183 values.foreground = fg ; | |
| 184 values.font = font ; | |
| 185 | |
| 186 if( font != None ) { | |
| 187 vmask = GCForeground|GCFont ; | |
| 188 dcmask = GCSubwindowMode|GCDashOffset| | |
| 189 GCDashList|GCArcMode|GCBackground|GCGraphicsExposures ; | |
| 190 } else { | |
| 191 vmask = GCForeground ; | |
| 192 dcmask = GCFont|GCSubwindowMode|GCDashOffset| | |
| 193 GCDashList|GCArcMode|GCBackground|GCGraphicsExposures ; | |
| 194 } | |
| 195 | |
| 196 return XtAllocateGC(w, w->core.depth, vmask, &values, 0L, dcmask) ; | |
| 197 } | |
| 198 | |
| 199 | |
| 200 /* return gc with widget background color as the foreground */ | |
| 201 | |
| 202 GC | |
| 203 AllocBackgroundGC(Widget w, Font font) | |
| 204 { | |
| 205 return AllocFgGC(w, w->core.background_pixel, font) ; | |
| 206 } | |
| 207 | |
| 208 | |
| 209 /* Allocate an "inactive" GC. Color is grey (possibly via | |
| 210 * dither pattern). | |
| 211 */ | |
| 212 | |
| 213 GC | |
| 214 AllocGreyGC(Widget w, Pixel fg, Font font, int contrast, Bool be_nice_to_cmap) | |
| 215 { | |
| 216 return AllocShadeGC(w, fg, w->core.background_pixel, | |
| 217 font, contrast, be_nice_to_cmap) ; | |
| 218 } | |
| 219 | |
| 220 | |
| 221 /* Allocate a GC somewhere between two colors. */ | |
| 222 | |
| 223 GC | |
| 224 AllocShadeGC(Widget w, Pixel fg, Pixel bg, Font font, | |
|
4769
5460287a3327
Remove support for pre-X11R5 systems, including systems without Xmu. See
Jerry James <james@xemacs.org>
parents:
2286
diff
changeset
|
225 int contrast, Bool be_nice_to_cmap) |
| 398 | 226 { |
| 227 XGCValues values ; | |
| 458 | 228 unsigned long vmask, dcmask ; |
| 398 | 229 |
| 230 values.foreground = fg ; | |
| 231 values.background = bg ; | |
| 232 values.font = font ; | |
| 233 | |
| 234 if( font != None ) { | |
| 235 vmask = GCForeground|GCFont ; | |
| 236 dcmask = GCSubwindowMode|GCDashOffset| | |
| 237 GCDashList|GCArcMode|GCGraphicsExposures ; | |
| 238 } else { | |
| 239 vmask = GCForeground; | |
| 240 dcmask = GCFont|GCSubwindowMode|GCDashOffset| | |
| 241 GCDashList|GCArcMode|GCGraphicsExposures ; | |
| 242 } | |
| 243 if( be_nice_to_cmap || w->core.depth == 1) | |
| 244 { | |
| 245 if( contrast <= 5 ) | |
| 246 values.foreground = bg ; | |
| 247 else if( contrast >= 95 ) | |
| 248 values.foreground = fg ; | |
| 249 else { | |
| 250 vmask |= GCBackground|GCStipple|GCFillStyle ; | |
| 251 values.fill_style = FillOpaqueStippled ; | |
| 252 values.stipple = getDitherPixmap(w, contrast) ; | |
| 253 } | |
| 254 | |
| 255 return XtAllocateGC(w, w->core.depth, vmask, &values, 0L, dcmask) ; | |
|
4769
5460287a3327
Remove support for pre-X11R5 systems, including systems without Xmu. See
Jerry James <james@xemacs.org>
parents:
2286
diff
changeset
|
256 } else { |
| 398 | 257 dcmask |= GCBackground ; |
| 258 values.foreground = AllocGreyPixel(w, fg, bg, contrast) ; | |
| 259 return XtAllocateGC(w, w->core.depth, vmask, &values, 0L, dcmask) ; | |
| 260 } | |
| 261 } | |
| 262 | |
| 263 /* return top-shadow gc. */ | |
| 264 | |
| 265 GC | |
| 266 AllocTopShadowGC(Widget w, int contrast, Bool be_nice_to_cmap) | |
| 267 { | |
| 268 Screen *scr = XtScreen (w); | |
| 269 XGCValues values ; | |
| 270 | |
| 271 if( w->core.depth == 1 ) | |
| 272 values.foreground = BlackPixelOfScreen(scr) ; | |
| 273 else if( be_nice_to_cmap ) | |
| 274 values.foreground = WhitePixelOfScreen(scr) ; | |
| 275 else | |
| 276 values.foreground = AllocShadowPixel(w, 100+contrast) ; | |
| 277 | |
| 278 return XtAllocateGC(w, w->core.depth, | |
| 279 GCForeground, &values, | |
| 280 0L, | |
| 281 GCBackground|GCFont|GCSubwindowMode|GCGraphicsExposures| | |
| 282 GCDashOffset|GCDashList|GCArcMode) ; | |
| 283 } | |
| 284 | |
| 285 /* return bottom-shadow gc. */ | |
| 286 | |
| 287 GC | |
| 288 AllocBotShadowGC(Widget w, int contrast, Bool be_nice_to_cmap) | |
| 289 { | |
| 290 Screen *scr = XtScreen (w); | |
| 291 XGCValues values ; | |
| 292 | |
| 293 if( w->core.depth == 1 || be_nice_to_cmap ) | |
| 294 values.foreground = BlackPixelOfScreen(scr) ; | |
| 295 else | |
| 296 values.foreground = AllocShadowPixel(w, 100-contrast) ; | |
| 297 | |
| 298 return XtAllocateGC(w, w->core.depth, | |
| 299 GCForeground, &values, | |
| 300 0L, | |
| 301 GCBackground|GCFont|GCSubwindowMode|GCGraphicsExposures| | |
| 302 GCDashOffset|GCDashList|GCArcMode) ; | |
| 303 } | |
| 304 | |
| 305 /* return arm-shadow gc. */ | |
| 306 | |
| 307 GC | |
|
4769
5460287a3327
Remove support for pre-X11R5 systems, including systems without Xmu. See
Jerry James <james@xemacs.org>
parents:
2286
diff
changeset
|
308 AllocArmGC(Widget w, int contrast, Bool be_nice_to_cmap) |
| 398 | 309 { |
| 310 Screen *scr = XtScreen (w); | |
| 311 XGCValues values ; | |
| 312 | |
| 313 /* Not clear exactly what we should do here. Take a look at | |
| 314 * Xaw3d to see what they do. | |
| 315 */ | |
| 316 if( w->core.depth == 1 || be_nice_to_cmap ) | |
| 317 { | |
| 318 values.background = w->core.background_pixel ; | |
| 319 if( values.background == BlackPixelOfScreen(scr) ) | |
| 320 values.foreground = WhitePixelOfScreen(scr) ; | |
| 321 else | |
| 322 values.foreground = BlackPixelOfScreen(scr) ; | |
| 323 values.fill_style = FillStippled ; | |
| 324 values.stipple = XmuCreateStippledPixmap(XtScreen(w), 1L, 0L, 1) ; | |
| 325 | |
| 326 return XtAllocateGC(w, w->core.depth, | |
| 327 GCForeground|GCBackground|GCStipple|GCFillStyle, | |
| 328 &values, 0L, | |
| 329 GCFont|GCSubwindowMode|GCGraphicsExposures| | |
| 330 GCDashOffset|GCDashList|GCArcMode) ; | |
|
4769
5460287a3327
Remove support for pre-X11R5 systems, including systems without Xmu. See
Jerry James <james@xemacs.org>
parents:
2286
diff
changeset
|
331 } else { |
| 398 | 332 values.foreground = AllocShadowPixel(w, 100-contrast) ; |
| 333 return XtAllocateGC(w, w->core.depth, | |
| 334 GCForeground, &values, | |
| 335 0L, | |
| 336 GCBackground|GCFont|GCSubwindowMode|GCGraphicsExposures| | |
| 337 GCDashOffset|GCDashList|GCArcMode) ; | |
| 338 } | |
| 339 } | |
| 340 | |
| 341 | |
| 342 Pixel | |
| 343 AllocShadowPixel(Widget w, int scale) | |
| 344 { | |
| 345 XColor get_c, set_c ; | |
| 346 Display *dpy = XtDisplay(w) ; | |
| 347 Screen *scr = XtScreen(w) ; | |
| 348 Colormap cmap ; | |
| 349 Pixel maxColor ; | |
| 350 | |
| 351 cmap = w->core.colormap ; | |
| 352 | |
| 353 get_c.pixel = w->core.background_pixel ; | |
| 354 if( get_c.pixel == WhitePixelOfScreen(scr) || | |
| 355 get_c.pixel == BlackPixelOfScreen(scr) ) | |
| 356 { | |
| 357 /* what we *ought* to do is choose gray75 as the base color, | |
| 358 * or perhaps gray83. Instead, we choose colors that are | |
| 359 * the same as ThreeD would choose. | |
| 360 */ | |
| 361 if( scale > 100 ) scale = 200 - scale ; | |
| 362 set_c.red = set_c.green = set_c.blue = 65535*scale/100 ; | |
| 363 } | |
| 364 else | |
| 365 { | |
| 366 XQueryColor(dpy, cmap, &get_c) ; | |
| 367 /* adjust scale so that brightest component does not | |
| 368 * exceed 65535; otherwise hue would change. | |
| 369 */ | |
| 370 if( scale > 100 ) { | |
| 371 maxColor = Max(get_c.red, Max(get_c.green, get_c.blue)) ; | |
| 372 if( scale*maxColor > 65535*100 ) | |
| 373 scale = 65535*100/maxColor ; | |
| 374 } | |
| 375 set_c.red = scale * get_c.red / 100 ; | |
| 376 set_c.green = scale * get_c.green / 100 ; | |
| 377 set_c.blue = scale * get_c.blue / 100 ; | |
| 378 } | |
| 379 set_c.flags = DoRed | DoGreen | DoBlue ; | |
| 380 if( XAllocColor(dpy, cmap, &set_c) ) | |
| 381 return set_c.pixel ; | |
| 382 else if( scale > 100 ) | |
| 383 return WhitePixelOfScreen(scr) ; | |
| 384 else | |
| 385 return BlackPixelOfScreen(scr) ; | |
| 386 } | |
| 387 | |
| 388 | |
| 389 /* Allocate a pixel partway between foreground and background */ | |
| 390 | |
| 391 | |
| 392 Pixel | |
| 393 AllocGreyPixel(Widget w, Pixel fg, Pixel bg, int scale) | |
| 394 { | |
| 395 XColor get_cf, get_cb ; | |
| 396 Display *dpy = XtDisplay(w) ; | |
| 397 Colormap cmap ; | |
| 398 | |
| 399 cmap = w->core.colormap ; | |
| 400 | |
| 401 get_cf.pixel = fg ; | |
| 402 get_cb.pixel = bg ; | |
| 403 | |
| 404 XQueryColor(dpy, cmap, &get_cf) ; | |
| 405 XQueryColor(dpy, cmap, &get_cb) ; | |
| 406 | |
| 407 return AllocGreyPixelC(w, &get_cf, &get_cb, scale) ; | |
| 408 } | |
| 409 | |
| 410 | |
| 411 | |
| 412 /* Allocate a pixel partway between foreground and background */ | |
| 413 | |
| 414 | |
| 415 Pixel | |
| 416 AllocGreyPixelC(Widget w, XColor *fg, XColor *bg, int scale) | |
| 417 { | |
| 418 XColor set_c ; | |
| 419 Display *dpy = XtDisplay(w) ; | |
| 420 int r,g,b ; | |
| 421 Colormap cmap = w->core.colormap ; | |
| 422 | |
| 423 r = (fg->red * scale + bg->red * (100-scale)) / 100 ; | |
| 424 g = (fg->green * scale + bg->green * (100-scale)) / 100 ; | |
| 425 b = (fg->blue * scale + bg->blue * (100-scale)) / 100 ; | |
| 426 | |
| 427 if( scale > 100 || scale < 0 ) /* look out for overflow */ | |
| 428 { | |
| 429 int minc, maxc ; | |
| 430 maxc = Max(r, Max(g,b)) ; | |
| 431 minc = Min(r, Min(g,b)) ; | |
| 432 if( maxc > 65535 ) | |
| 433 { | |
| 434 maxc /= 16 ; | |
| 435 r = r*(65535/16) / maxc ; | |
| 436 g = g*(65535/16) / maxc ; | |
| 437 b = b*(65535/16) / maxc ; | |
| 438 } | |
| 439 if( minc < 0 ) | |
| 440 { | |
| 441 r = Max(r,0) ; | |
| 442 g = Max(g,0) ; | |
| 443 b = Max(b,0) ; | |
| 444 } | |
| 445 } | |
| 446 | |
| 447 set_c.red = r ; set_c.green = g ; set_c.blue = b ; | |
| 448 set_c.flags = DoRed | DoGreen | DoBlue ; | |
| 449 (void)XAllocColor(dpy, cmap, &set_c) ; | |
| 450 return set_c.pixel ; | |
| 451 } | |
| 452 | |
| 453 | |
| 454 | |
| 455 | |
| 456 | |
| 457 /* draw a 3-d box */ | |
| 458 | |
| 459 void | |
| 460 Draw3dBox(Widget w, int x, int y, int wid, int hgt, int s, GC topgc, GC botgc) | |
| 461 { | |
| 462 Display *dpy = XtDisplay(w) ; | |
| 463 Window win = XtWindow(w) ; | |
| 464 | |
| 465 if( s == 0 ) return ; | |
| 466 | |
| 467 if( s == 1 ) { | |
| 468 XDrawLine(dpy,win,botgc, x,y+hgt-1, x+wid-1,y+hgt-1) ; | |
| 469 XDrawLine(dpy,win,botgc, x+wid-1,y, x+wid-1,y+hgt-1) ; | |
| 470 XDrawLine(dpy,win,topgc, x,y, x,y+hgt-1) ; | |
| 471 XDrawLine(dpy,win,topgc, x,y, x+wid-1,y) ; | |
| 472 } | |
| 473 else | |
| 474 { | |
| 475 XPoint pts[6] ; | |
| 476 | |
| 477 /* bottom-right shadow */ | |
| 478 pts[0].x = x ; pts[0].y = y + hgt ; | |
| 479 pts[1].x = s ; pts[1].y = -s ; | |
| 480 pts[2].x = wid-2*s ; pts[2].y = 0 ; | |
| 481 pts[3].x = 0 ; pts[3].y = -(hgt-2*s) ; | |
| 482 pts[4].x = s ; pts[4].y = -s ; | |
| 483 pts[5].x = 0 ; pts[5].y = hgt ; | |
| 484 XFillPolygon(dpy,win,botgc, pts,6, Nonconvex,CoordModePrevious) ; | |
| 485 | |
| 486 /* top-left shadow */ | |
| 487 pts[0].x = x ; pts[0].y = y ; | |
| 488 pts[1].x = wid ; pts[1].y = 0 ; | |
| 489 pts[2].x = -s ; pts[2].y = s ; | |
| 490 pts[3].x = -wid+2*s ; pts[3].y = 0 ; | |
| 491 pts[4].x = 0 ; pts[4].y = hgt-2*s ; | |
| 492 pts[5].x = -s ; pts[5].y = s ; | |
| 493 XFillPolygon(dpy,win,topgc, pts,6, Nonconvex,CoordModePrevious) ; | |
| 494 } | |
| 495 } | |
| 496 | |
| 458 | 497 static unsigned char screen0[2] = {0,0} ; |
| 498 static unsigned char screen25[2] = {0,0xaa} ; | |
| 499 static unsigned char screen75[2] = {0xaa,0xff} ; | |
| 500 static unsigned char screen100[2] = {0xff,0xff} ; | |
| 398 | 501 |
| 502 static Pixmap | |
| 503 getDitherPixmap(Widget w, int contrast) | |
| 504 { | |
| 505 Display *dpy = XtDisplay(w) ; | |
| 506 Window win = XtWindow(w) ; | |
| 507 | |
| 508 if( contrast <= 5 ) | |
| 509 return XCreateBitmapFromData(dpy,win, (char *)screen0, 2,2) ; | |
| 510 else if( contrast <= 37 ) | |
| 511 return XCreateBitmapFromData(dpy,win, (char *)screen25, 2,2) ; | |
| 512 else if( contrast <= 62 ) | |
| 513 return XmuCreateStippledPixmap(XtScreen(w), 1L, 0L, 1) ; | |
| 514 else if( contrast <= 95 ) | |
| 515 return XCreateBitmapFromData(dpy,win, (char *)screen75, 2,2) ; | |
| 516 else | |
| 517 return XCreateBitmapFromData(dpy,win, (char *)screen100, 2,2) ; | |
| 518 } |
