Thu Jan 13 11:45:13 1994 John Richardson <jrichard@cs.uml.edu> * [window/win.c] Added functions EnableWindow, IsWindowEnabled, and helper WIN_SetSensitive. * [window/event.c] Added checks for WS_DISABLED windows in EVENT_key, EVENT_MotionNotify, EVENT_ButtonPress, EVENT_ButtonRelease, EVENT_ConfigureNotify, EVENT_FocusIn, EVENT_FocusOut, and EVENT_EnterNotify. Key and button presses beep for a disabled window. If anyone finds better places for these checks, please tell me. Jan 17, 94 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte) * [misc/message.c] Cleanup on buttons answer value returned. * [control/combo.c] Now use OBM_COMBO bitmap dropdown button. Mon Jan 17 21:56:45 1994 Erik Bos (erik@trashcan.hacktic.nl) * [misc/comm/c] A few bugfixes. Tue Jan 18 06:36:48 1994 julliard@di.epfl.ch (Alexandre Julliard) * [loader/cursor.c] Added X cursor for IDC_SIZENS and IDC_SIZEWE. * [include/options.h] [misc/main.c] (New files) Rewrote main() function to get rid of Xt application context, and added command-line option parsing. * [objects/color.c] Use of a private map now configurable with command-line option. * [windows/defwnd.c] Added WM_SYSCOMMAND handling, and better WM_SETCURSOR handling. * [windows/event.c] Removed ConfigureNotify event handler (no longer needed). * [windows/message.c] Send WM_SETCURSOR message on mouse events. * [windows/nonclient.c] Use OEM bitmaps for the drawing of the non-client area. Added caption bar buttons handling, and moving and resizing of the window via the window frame (bypassing the window manager). * [windows/painting.c] Bug fix in BeginPaint(). * [windows/win.c] Set the override_redirect flag for windows (to bypass window manager). * [windows/winpos.c] Implemented WindowFromPoint(), ChildWindowFromPoint(), BringWindowToTop(), Get/SetInternalWindowPos(), Get/SetWindowPlacement(). Mon Jan 17 20:48:24 1994 Bob Amstadt (bob@pooh) * [memory/heap.c] Added support for multiple local heaps.
147 lines
3.3 KiB
C
147 lines
3.3 KiB
C
/*
|
|
* Color functions
|
|
*
|
|
* Copyright 1993 Alexandre Julliard
|
|
*/
|
|
|
|
static char Copyright[] = "Copyright Alexandre Julliard, 1993";
|
|
|
|
#include <stdlib.h>
|
|
#include <X11/Xlib.h>
|
|
|
|
#include "windows.h"
|
|
#include "options.h"
|
|
|
|
extern Display * display;
|
|
extern Screen * screen;
|
|
|
|
|
|
Colormap COLOR_WinColormap = 0;
|
|
|
|
|
|
/* System colors */
|
|
|
|
static const char * SysColors[] =
|
|
{
|
|
/* Low pixel values (0..7) */
|
|
|
|
"black", "red4", "green4", "yellow4",
|
|
"blue4", "magenta4", "cyan4", "gray50",
|
|
|
|
/* High pixel values (max-7..max) */
|
|
|
|
"gray75", "red", "green", "yellow",
|
|
"blue", "magenta", "cyan", "white"
|
|
};
|
|
|
|
#define NB_SYS_COLORS (sizeof(SysColors) / sizeof(SysColors[0]))
|
|
|
|
|
|
/***********************************************************************
|
|
* COLOR_FillDefaultMap
|
|
*
|
|
* Try to allocate colors from default screen map (used when we
|
|
* don't want to or can't use a private map).
|
|
*/
|
|
static int COLOR_FillDefaultMap()
|
|
{
|
|
XColor color;
|
|
int i, total = 0;
|
|
|
|
for (i = 0; i < NB_SYS_COLORS; i++)
|
|
{
|
|
if (XParseColor( display, DefaultColormapOfScreen( screen ),
|
|
SysColors[i], &color ))
|
|
{
|
|
if (XAllocColor( display, DefaultColormapOfScreen( screen ),
|
|
&color ))
|
|
total++;
|
|
}
|
|
}
|
|
return total;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* COLOR_BuildMap
|
|
*
|
|
* Fill the private colormap.
|
|
*/
|
|
static BOOL COLOR_BuildMap( Colormap map, int depth, int size )
|
|
{
|
|
XColor color;
|
|
int i;
|
|
|
|
/* Fill the whole map with a range of colors */
|
|
|
|
if ((1 << depth) > NB_SYS_COLORS)
|
|
{
|
|
int red_incr, green_incr, blue_incr;
|
|
int r, g, b;
|
|
|
|
blue_incr = 0x10000 >> (depth / 3);
|
|
red_incr = 0x10000 >> ((depth + 1) / 3);
|
|
green_incr = 0x10000 >> ((depth + 2) / 3);
|
|
|
|
for (i = 0, r = red_incr - 1; r < 0x10000; r += red_incr)
|
|
for (g = green_incr - 1; g < 0x10000; g += green_incr)
|
|
for (b = blue_incr - 1; b < 0x10000; b += blue_incr)
|
|
{
|
|
if (i >= size) break;
|
|
color.pixel = i++;
|
|
color.red = r;
|
|
color.green = g;
|
|
color.blue = b;
|
|
XStoreColor( display, map, &color );
|
|
}
|
|
}
|
|
|
|
/* Store the system palette colors */
|
|
|
|
for (i = 0; i < NB_SYS_COLORS; i++)
|
|
{
|
|
if (!XParseColor( display, map, SysColors[i], &color ))
|
|
color.red = color.green = color.blue = color.flags = 0;
|
|
if (i < NB_SYS_COLORS/2) color.pixel = i;
|
|
else color.pixel = (1 << depth) - NB_SYS_COLORS + i;
|
|
if (color.pixel < size) XStoreColor( display, map, &color );
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* COLOR_Init
|
|
*/
|
|
BOOL COLOR_Init()
|
|
{
|
|
Visual * visual = DefaultVisual( display, DefaultScreen(display) );
|
|
|
|
switch(visual->class)
|
|
{
|
|
case GrayScale:
|
|
case PseudoColor:
|
|
case DirectColor:
|
|
if (Options.usePrivateMap)
|
|
{
|
|
COLOR_WinColormap = XCreateColormap( display,
|
|
DefaultRootWindow(display),
|
|
visual, AllocAll );
|
|
if (COLOR_WinColormap)
|
|
{
|
|
COLOR_BuildMap(COLOR_WinColormap,
|
|
DefaultDepth(display, DefaultScreen(display)),
|
|
visual->map_entries );
|
|
break;
|
|
}
|
|
}
|
|
/* Fall through */
|
|
case StaticGray:
|
|
case StaticColor:
|
|
case TrueColor:
|
|
COLOR_FillDefaultMap();
|
|
COLOR_WinColormap = DefaultColormapOfScreen( screen );
|
|
break;
|
|
}
|
|
return TRUE;
|
|
}
|