1
0
Fork 0
mirror of synced 2025-03-07 03:53:26 +01:00
wine/misc/tweak.c
Alexandre Julliard 02e90087ff Release 980104
Sat Jan  3 17:15:56 1998  Alexandre Julliard  <julliard@lrc.epfl.ch>

	* [debugger/db_disasm.c]
	Added cpuid and cmpxchg instructions.

	* [if1632/builtin.c] [relay32/builtin32.c]
	Fixed broken -dll option with Win32 DLLs.

	* [include/heap.h]
	Added SYSTEM_LOCK/SYSTEM_UNLOCK macros.

	* [configure.in] [misc/lstr.c]
	Added check for wctype.h.
	Commented out --enable-ipc option (IPC code has been broken for a
	long time anyway).

	* [scheduler/critsection.c] [scheduler/event.c]
	  [scheduler/mutex.c] [scheduler/semaphore.c]
	Implemented Win32 synchronization objects.

	* [scheduler/synchro.c]
	Implemented WaitForMultipleObjects and related functions.

	* [scheduler/thread.c]
	If possible, use clone() in CreateThread().

	* [scheduler/thread.c] [scheduler/process.c]
	Made thread and process waitable objects.
	Thread and process id values are now different from the pointers
	they represent.

	* [win32/k32obj.c]
	Moved to scheduler directory.
	Added function table for waiting operations on objects.

	* [files/file.c] [memory/virtual.c]
	Added new K32OBJ function table.

Sun Jan  1 16:48:23 1997  Andreas Mohr <100.30936@germany.net>

	* [files/file.c]
	Fixed my patch for GetTempFileName16() as needed.
	It was ...Name32A() that didn't work properly, not ...Name16().

	* [graphics/x11drv/brush.c]
	Fixed a BadMatch error.

	* [msdos/int21.c]
	Fixed INT21_FindNextFCB() to get correct volume labels e.g.
	in "file open" dialog.

	* [multimedia/joystick.c] [relay32/winmm.spec]
	Stub JoyGetPosEx().

	* [scheduler/process.c] [relay32/kernel32.spec]
	Implemented RegisterServiceProcess().

Wed Dec 31 11:14:43 1997  Lawson Whitney  <lawson_whitney@juno.com>

	* [if1632/kernel.spec] [if1632/relay.c]
	Define CallProcEx32w - Thanks to Marcus Meissner for his excellent
	CallProc32W.

	* [loader/module.c]
	Take a shot at defining FreeLibrary32W.

Sun Dec 28 12:44:04 1997  Kai Morich <kai.morich@rhein-neckar.netsurf.de>

	* [controls/menu.c]
	Menu modification from WM_INITMENUPOPUP message fixed.
	Menu items now can have different wID and hSubMenu (Win95 behavior).

	* [misc/cpu.c]
	Improved IsProcessorFeaturePresent.

Sun Dec 28 03:21:08 1997  Ove Kaaven <ovek@main.arcticnet.no>

	* [include/winsock.h] [misc/winsock.c]
	Fixed WS_SOL_SOCKET for setsockopt(), and made select() return
	empty fd_sets if timeout.

	* [objects/palette.c]
	AnimatePalette() bailed out if entire palette is animated. Fixed.

	* [objects/dib.c]
	Added some code to SetDIBitsToDevice() and its helpers to fix
	some offseting problems.

	* [objects/cursoricon.c]
	Made CreateCursor32() convert the instance handle properly. Made
	DestroyCursor() return correct success status.

Wed Dec 24 17:56:34 1997  Dimitrie O. Paun  <dimi@cs.toronto.edu>

	* [windows/syscolor.c]
	Added definition of GetSysColorPen16/32. This function does not
	exist in the Win32 API but is a very close (and natural) relative
	to GetSysColorBrush function. Moreover, it is *very* much used 
	within Wine since there are a lot of places where we need to draw
	lines with the standard colors.

	* [controls/button.c] [controls/combo.c] [controls/icontitle.c]
	  [controls/menu.c] [controls/progress.c] [controls/scroll.c]
	  [controls/updown.c] [graphics/painting.c] [misc/tweak.c]
	  [windows/defwnd.c] [windows/graphics.c] [windows/nonclient.c]
	Replaced references to sysColorObjects with the appropriate
	call to GetSysColorBrush32/GetSysColorPen32. There is no need to
	expose the implementation of these functions, even within Wine.
	This makes the code easier to understand, debug, maintain.

	* [controls/uitools.c]
	Modified most of the functions in this file to use the now
	standard pens (i.e. GetSysColorPen32). These functions made
	*heavy* use of standard pens so I expect a lot less
	CreatePen/DeleteObject calls can do only good...:)
	Plus some minor modifications (*no* functional changes though).

	* [controls/updown.c]
	Used the new DrawFrameControl32 function to paint the control.
	I also deleted UDDOWN_DrawArrow since it was no longer required.

Tue Dec 23 00:03:33 1997  Steinar Hamre  <steinarh@stud.fim.ntnu.no>

	* [configure.in]
	Added check for -lw.

	* [include/wintypes.h] [tools/build.c]
	Changes to make the assembly understandable for even sun as.
	".ascii" -> ".string", "call %foo" -> "call *%foo",
	"pushw/popw %[cdes]s" written out to ".byte 0x66\npushl/popl %[cdes]s".

	* [memory/ldt.c]
	#ifdef added so <sys/seg.h> will not be included on Solaris.

Mon Dec 22 18:55:19 1997  Marcus Meissner <msmeissn@cip.informatik.uni-erlangen.de>

	* [configure.in]
	Added XF86DGA check.

	* [multimedia/dsound.c][relay32/dsound.spec][include/dsound.h]
	Started DirectSound. Only stubs for now.

	* [graphics/ddraw.c][include/ddraw.h][relay32/ddraw.spec]
	Started to implement DirectDraw. Mostly stubs, some
	testcases work. Requires the XF86DGA extension to XFree86.
	(check demo/blizdemo.exe from the Diablo CD-ROM).

	* [files/drive.c]
	Return correct "CDFS" fsname so Diablo is a bit happier.

Sun Dec 21 21:45:48 1997  Kevin Cozens <kcozens@interlog.com>

	* [misc/registry.c]
	Fixed bugs in the routines which read the Windows '95 registry
	files. Added extra information regarding the format of the Windows
	'95 registry files.
1998-01-04 17:49:09 +00:00

500 lines
15 KiB
C

/******************************************************************************
*
* tweak.c
*
* Windows 95 style interface tweaks.
* Copyright (c) 1997 Dave Cuthbert.
*
* FIXME: This file is, unfortunately, aptly named: the method of
* displaying Win95 style windows is a tweak. Lots of stuff does not yet
* work -- and probably never will unless some of this code is
* incorporated into the mainstream Wine code.
*
* DEVELOPERS, PLEASE NOTE: Before delving into the mainstream code and
* altering it, consider how your changes will affect the Win3.1 interface
* (which has taken a major effort to create!). After you make any sort of
* non-trivial change, *test* the Wine code running in Win3.1 mode! The
* object here is to make it so that the person who tests the latest version
* of Wine without adding the tweaks into wine.conf notices nothing out of
* the ordinary.
*
* Revision history
* 03-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
* Original implementation.
*
*****************************************************************************/
#include <stdio.h>
#include <malloc.h>
#include <X11/Xlib.h>
#include <string.h>
#include "dc.h"
#include "debug.h"
#include "graphics.h"
#include "options.h"
#include "stackframe.h"
#include "tweak.h"
#include "windows.h"
/* Parameters for windows/nonclient.c */
extern int NC_CaptionLeftNudge;
extern int NC_CaptionTopNudge;
extern int NC_SysControlNudge;
extern int NC_MaxControlNudge;
extern int NC_MinControlNudge;
extern UINT32 NC_CaptionTextFlags;
extern HBRUSH32 NC_WinHighlight95;
extern HBRUSH32 NC_WinShadow95;
/* Parameters for controls/menu.c */
extern UINT32 MENU_BarItemTopNudge;
extern UINT32 MENU_BarItemLeftNudge;
extern UINT32 MENU_ItemTopNudge;
extern UINT32 MENU_ItemLeftNudge;
extern UINT32 MENU_HighlightTopNudge;
extern UINT32 MENU_HighlightLeftNudge;
extern UINT32 MENU_HighlightBottomNudge;
extern UINT32 MENU_HighlightRightNudge;
/* General options */
HPEN32 TWEAK_PenFF95;
HPEN32 TWEAK_PenE095;
HPEN32 TWEAK_PenC095;
HPEN32 TWEAK_Pen8095;
HPEN32 TWEAK_Pen0095;
#if defined(WIN_95_LOOK)
int TWEAK_Win95Look = 1;
#else
int TWEAK_Win95Look = 0;
#endif
int TWEAK_WineInitialized = 0;
/******************************************************************************
*
* int TWEAK_MenuInit()
*
* Initializes the Win95 tweaks to the menu code. See controls/menu.c.
* Return value indicates success (non-zero) or failure.
*
* Revision history
* 06-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
* Original implementation.
*
*****************************************************************************/
static int TWEAK_MenuInit()
{
MENU_BarItemTopNudge =
PROFILE_GetWineIniInt("Tweak.Layout", "MenuBarItemTopNudge", 0);
MENU_BarItemLeftNudge =
PROFILE_GetWineIniInt("Tweak.Layout", "MenuBarItemLeftNudge", 0);
MENU_ItemTopNudge =
PROFILE_GetWineIniInt("Tweak.Layout", "MenuItemTopNudge", 0);
MENU_ItemLeftNudge =
PROFILE_GetWineIniInt("Tweak.Layout", "MenuItemLeftNudge", 0);
MENU_HighlightTopNudge =
PROFILE_GetWineIniInt("Tweak.Layout", "MenuHighlightTopNudge", 0);
MENU_HighlightLeftNudge =
PROFILE_GetWineIniInt("Tweak.Layout", "MenuHighlightLeftNudge", 0);
MENU_HighlightBottomNudge =
PROFILE_GetWineIniInt("Tweak.Layout", "MenuHighlightBottomNudge", 0);
MENU_HighlightRightNudge =
PROFILE_GetWineIniInt("Tweak.Layout", "MenuHighlightRightNudge", 0);
return 1;
}
/******************************************************************************
*
* int TWEAK_NonClientInit()
*
* Initializes the Win95 tweaks to the non-client drawing functions. See
* windows/nonclient.c. Return value indicates success (non-zero) or
* failure.
*
* Revision history
* 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
* Original implementation.
*
*****************************************************************************/
static int TWEAK_NonClientInit()
{
char key_value[2];
NC_CaptionLeftNudge =
PROFILE_GetWineIniInt("Tweak.Layout", "CaptionLeftNudge", 0);
NC_CaptionTopNudge =
PROFILE_GetWineIniInt("Tweak.Layout", "CaptionTopNudge", 0);
NC_SysControlNudge =
PROFILE_GetWineIniInt("Tweak.Layout", "SysControlNudge", 0);
NC_MaxControlNudge =
PROFILE_GetWineIniInt("Tweak.Layout", "MaxControlNudge", 0);
NC_MinControlNudge =
PROFILE_GetWineIniInt("Tweak.Layout", "MinControlNudge", 0);
NC_WinHighlight95 = CreateSolidBrush32(RGB(0xc0, 0xc0, 0xc0));
NC_WinShadow95 = CreateSolidBrush32(RGB(0x00, 0x00, 0x00));
NC_CaptionTextFlags = DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX;
PROFILE_GetWineIniString("Tweak.Layout", "CaptionAlignment",
TWEAK_Win95Look ? "l" : "c", key_value, 2);
switch(key_value[0]) {
case 'l':
case 'L':
NC_CaptionTextFlags |= DT_LEFT;
break;
case 'r':
case 'R':
NC_CaptionTextFlags |= DT_RIGHT;
break;
default:
NC_CaptionTextFlags |= DT_CENTER;
}
return 1;
}
/******************************************************************************
*
* int TWEAK_VarInit()
*
* Initializes the miscellaneous variables which are used in the tweak
* routines. Return value is non-zero on success.
*
* Revision history
* 07-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
* Original implementation.
*
*****************************************************************************/
static int TWEAK_VarInit()
{
TWEAK_Win95Look = PROFILE_GetWineIniBool("Tweak.Layout", "Win95Look", 0);
/* FIXME: Each color should really occupy a single entry in the wine.conf
file, but I couldn't settle on a good (intuitive!) format. */
TWEAK_PenFF95 = CreatePen32(
PS_SOLID, 1,
RGB(PROFILE_GetWineIniInt("Tweak.Colors", "PenFF95.Red", 0xff),
PROFILE_GetWineIniInt("Tweak.Colors", "PenFF95.Grn", 0xff),
PROFILE_GetWineIniInt("Tweak.Colors", "PenFF95.Blu", 0xff)));
TWEAK_PenE095 = CreatePen32(
PS_SOLID, 1,
RGB(PROFILE_GetWineIniInt("Tweak.Colors", "PenE095.Red", 0xe0),
PROFILE_GetWineIniInt("Tweak.Colors", "PenE095.Grn", 0xe0),
PROFILE_GetWineIniInt("Tweak.Colors", "PenE095.Blu", 0xe0)));
TWEAK_PenC095 = CreatePen32(
PS_SOLID, 1,
RGB(PROFILE_GetWineIniInt("Tweak.Colors", "PenC095.Red", 0xc0),
PROFILE_GetWineIniInt("Tweak.Colors", "PenC095.Grn", 0xc0),
PROFILE_GetWineIniInt("Tweak.Colors", "PenC095.Blu", 0xc0)));
TWEAK_Pen8095 = CreatePen32(
PS_SOLID, 1,
RGB(PROFILE_GetWineIniInt("Tweak.Colors", "Pen8095.Red", 0x80),
PROFILE_GetWineIniInt("Tweak.Colors", "Pen8095.Grn", 0x80),
PROFILE_GetWineIniInt("Tweak.Colors", "Pen8095.Blu", 0x80)));
TWEAK_Pen0095 = CreatePen32(
PS_SOLID, 1,
RGB(PROFILE_GetWineIniInt("Tweak.Colors", "Pen0095.Red", 0x00),
PROFILE_GetWineIniInt("Tweak.Colors", "Pen0095.Grn", 0x00),
PROFILE_GetWineIniInt("Tweak.Colors", "Pen0095.Blu", 0x00)));
dprintf_tweak(stddeb, "TWEAK_VarInit: Using %s look and feel.\n",
TWEAK_Win95Look ? "Win95" : "Win3.1");
return 1;
}
/******************************************************************************
*
* int TWEAK_Init()
*
* Does the full initialization of the Win95 tweak subsystem. Return value
* indicates success. Called by loader/main.c's MAIN_Init().
*
* Revision history
* 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
* Original implementation.
*
*****************************************************************************/
int TWEAK_Init()
{
TWEAK_VarInit();
TWEAK_NonClientInit();
TWEAK_MenuInit();
return 1;
}
/******************************************************************************
*
* int TWEAK_CheckConfiguration()
*
* Examines wine.conf for old/bad entries and recommends changes to the user.
*
* Revision history
* 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
* Original implementation.
*
*****************************************************************************/
int TWEAK_CheckConfiguration()
{
return 1;
}
/******************************************************************************
*
* Tweak graphic subsystem.
*
*****************************************************************************/
/******************************************************************************
*
* void TWEAK_DrawReliefRect95(
* HDC32 hdc, // Device context on which to draw
* RECT32 const *rect ) // Rectangle to use
*
* Draws the double-bordered Win95-style relief rectangle.
*
* Bugs
* There are some checks missing from this function. Perhaps the
* SelectObject32 calls should be examined? Hasn't failed on me (yet).
*
* Should I really be calling X functions directly from here? It is
* an optimization, but should I be optimizing alpha code? Probably
* not.
*
* Revision history
* 08-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
* Original implementation.
*
*****************************************************************************/
void TWEAK_DrawReliefRect95(
HDC32 hdc,
RECT32 const *rect )
{
DC *dc;
HPEN32 prevpen;
if((dc = (DC *)GDI_GetObjPtr(hdc, DC_MAGIC))) {
/* Draw the top/left lines first */
prevpen = SelectObject32(hdc, TWEAK_PenE095);
DC_SetupGCForPen(dc);
XDrawLine(display, dc->u.x.drawable, dc->u.x.gc, rect->left, rect->top,
rect->right - 1, rect->top);
XDrawLine(display, dc->u.x.drawable, dc->u.x.gc, rect->left, rect->top,
rect->left, rect->bottom - 1);
SelectObject32(hdc, TWEAK_PenFF95);
DC_SetupGCForPen(dc);
XDrawLine(display, dc->u.x.drawable, dc->u.x.gc, rect->left + 1,
rect->top + 1, rect->right - 2, rect->top + 1);
XDrawLine(display, dc->u.x.drawable, dc->u.x.gc, rect->left + 1,
rect->top + 1, rect->left + 1, rect->bottom - 2);
/* Now the bottom/right lines */
SelectObject32(hdc, TWEAK_Pen0095);
DC_SetupGCForPen(dc);
XDrawLine(display, dc->u.x.drawable, dc->u.x.gc, rect->left,
rect->bottom - 1, rect->right - 1, rect->bottom - 1);
XDrawLine(display, dc->u.x.drawable, dc->u.x.gc, rect->right - 1,
rect->top, rect->right - 1, rect->bottom - 1);
SelectObject32(hdc, TWEAK_Pen8095);
DC_SetupGCForPen(dc);
XDrawLine(display, dc->u.x.drawable, dc->u.x.gc, rect->left + 1,
rect->bottom - 2, rect->right - 2, rect->bottom - 2);
XDrawLine(display, dc->u.x.drawable, dc->u.x.gc, rect->right - 2,
rect->top + 1, rect->right - 2, rect->bottom - 2);
SelectObject32(hdc, prevpen);
}
return;
}
/******************************************************************************
*
* void TWEAK_DrawRevReliefRect95(
* HDC32 hdc, // Device context on which to draw
* RECT32 const *rect ) // Rectangle to use
*
* Draws the double-bordered Win95-style relief rectangle.
*
* Bugs
* There are some checks missing from this function. Perhaps the
* SelectObject32 calls should be examined? Hasn't failed on me (yet).
*
* Should I really be calling X functions directly from here? It is
* an optimization, but should I be optimizing alpha code? Probably
* not.
*
* Revision history
* 08-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
* Original implementation.
*
*****************************************************************************/
void TWEAK_DrawRevReliefRect95(
HDC32 hdc,
RECT32 const *rect )
{
DC *dc;
HPEN32 prevpen;
if((dc = (DC *)GDI_GetObjPtr(hdc, DC_MAGIC))) {
/* Draw the top/left lines first */
prevpen = SelectObject32(hdc, TWEAK_Pen8095);
DC_SetupGCForPen(dc);
XDrawLine(display, dc->u.x.drawable, dc->u.x.gc, rect->left, rect->top,
rect->right - 1, rect->top);
XDrawLine(display, dc->u.x.drawable, dc->u.x.gc, rect->left, rect->top,
rect->left, rect->bottom - 1);
SelectObject32(hdc, TWEAK_Pen0095);
DC_SetupGCForPen(dc);
XDrawLine(display, dc->u.x.drawable, dc->u.x.gc, rect->left + 1,
rect->top + 1, rect->right - 2, rect->top + 1);
XDrawLine(display, dc->u.x.drawable, dc->u.x.gc, rect->left + 1,
rect->top + 1, rect->left + 1, rect->bottom - 2);
/* Now the bottom/right lines */
SelectObject32(hdc, TWEAK_PenFF95);
DC_SetupGCForPen(dc);
XDrawLine(display, dc->u.x.drawable, dc->u.x.gc, rect->left,
rect->bottom - 1, rect->right - 1, rect->bottom - 1);
XDrawLine(display, dc->u.x.drawable, dc->u.x.gc, rect->right - 1,
rect->top, rect->right - 1, rect->bottom - 1);
SelectObject32(hdc, TWEAK_PenE095);
DC_SetupGCForPen(dc);
XDrawLine(display, dc->u.x.drawable, dc->u.x.gc, rect->left + 1,
rect->bottom - 2, rect->right - 2, rect->bottom - 2);
XDrawLine(display, dc->u.x.drawable, dc->u.x.gc, rect->right - 2,
rect->top + 1, rect->right - 2, rect->bottom - 2);
SelectObject32(hdc, prevpen);
}
return;
}
/******************************************************************************
*
* void TWEAK_DrawMenuSeparatorHoriz95(
* HDC32 hdc, // Device context on which to draw
* UINT32 xc1, // Left x-coordinate
* UINT32 yc, // Y-coordinate of the LOWER line
* UINT32 xc2 ) // Right x-coordinate
*
* Draws a horizontal menu separator bar Win 95 style.
*
* Bugs
* Same as those for DrawReliefRect95.
*
* Revision history
* 08-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
* Original implementation.
* 11-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
* Changed name from DrawMenuSeparator95
*
*****************************************************************************/
void TWEAK_DrawMenuSeparatorHoriz95(
HDC32 hdc,
UINT32 xc1,
UINT32 yc,
UINT32 xc2 )
{
DC *dc;
HPEN32 prevpen;
if((dc = (DC *)GDI_GetObjPtr(hdc, DC_MAGIC))) {
/* Draw the top line */
prevpen = SelectObject32(hdc, TWEAK_Pen8095);
DC_SetupGCForPen(dc);
XDrawLine(display, dc->u.x.drawable, dc->u.x.gc, xc1, yc - 1, xc2,
yc - 1);
/* And the bottom line */
SelectObject32(hdc, TWEAK_PenFF95);
DC_SetupGCForPen(dc);
XDrawLine(display, dc->u.x.drawable, dc->u.x.gc, xc1, yc, xc2, yc);
SelectObject32(hdc, prevpen);
}
return;
}
/******************************************************************************
*
* void TWEAK_DrawMenuSeparatorVert95(
* HDC32 hdc, // Device context on which to draw
* UINT32 xc, // X-coordinate of the RIGHT line
* UINT32 yc1, // top Y-coordinate
* UINT32 yc2 ) // bottom Y-coordinate
*
* Draws a vertical menu separator bar Win 95 style.
*
* Bugs
* Same as those for DrawReliefRect95.
*
* Revision history
* 11-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
* Original implementation.
*
*****************************************************************************/
void TWEAK_DrawMenuSeparatorVert95(
HDC32 hdc,
UINT32 xc,
UINT32 yc1,
UINT32 yc2 )
{
DC *dc;
HPEN32 prevpen;
if((dc = (DC *)GDI_GetObjPtr(hdc, DC_MAGIC))) {
/* Draw the top line */
prevpen = SelectObject32(hdc, TWEAK_Pen8095);
DC_SetupGCForPen(dc);
XDrawLine(display, dc->u.x.drawable, dc->u.x.gc, xc, yc1, xc,
yc2);
/* And the bottom line */
SelectObject32(hdc, TWEAK_PenFF95);
DC_SetupGCForPen(dc);
XDrawLine(display, dc->u.x.drawable, dc->u.x.gc, xc + 1, yc1, xc + 1,
yc2);
SelectObject32(hdc, prevpen);
}
return;
}