mirror of
git://source.winehq.org/git/wine.git
synced 2024-11-05 18:01:34 +00:00
2d159fb707
Thu Jul 14 17:50:45 1994 Bob Amstadt (bob@pooh) * [Configure] Autodetects Linux version (if running Linux). * [loader/signal.c] New signals for Linux. * [loader/ldtlib.c] New structure field in sys call. Sun Jul 10 19:31:34 1994 Olaf Flebbe (olaf@dragon) * [load/resource.c] fixed Memory (Resource) Leak. * [load/main.c] fixed a printf. Tue Jul 12 18:50:34 1994 Alexandre Julliard (julliard@lamisun.epfl.ch) * [controls/desktop.c] Implemented desktop wallpaper (only 16 colors for now). * [controls/menu.c] [windows/nonclient.c] Preliminary work to allow multi-line menus. * [misc/main.c] No backing store on desktop window (not useful). * [objects/text.c] A few fixes to DrawText() to make underlines under mnemonic letters to look better. * [windows/graphics.c] More fixes to GRAPH_DrawArc(), and some fixes to Polygon(). Implemented PolyPolygon() (partially working). * [windows/winpos.c] New function WINPOS_SendNCCalcSize(). Cleaned up SetWindowPos() and added preliminary support for multi-line menus. Mon Jul 11 19:15:51 1994 Miguel de Icaza (miguel@sphinx) * [controls/edit.c] Changes to work as a library. * [if1632/callback.c] Ifdefed module. * [if1632/relay.c] Changes to allow linking with WineLib. * [include/windows.h] Added macro WINELIB_UNIMP * [loader/library.c] When compiling WineLib, GetProcAddress is not implemented yet. * [loader/main.c] Added empty InitDLL when using WineLib. * [loader/ne_image.c] Some parts of the loader are needed for WineLib, ifdefed correctly * [misc/{audio.c,mcicda.c,mmaux.c,mmsystem.c] Disable compilation of module when compiling WineLib. * [toolkit/heap.c] Fixed small bug. When passed an invalid handle WineLib would crash, now return NULL. * [toolkit/winmain.c] Call CreateNewTask in _WinMain. Sun Jul 10 09:08:02 1994 David Metcalfe <david@prism.demon.co.uk> * [controls/edit.c] [controls/widget.c] More changes to improve compatibility with Windows' edit control. Finished off tab stop support. Mon Jul 11 21:05:02 MET DST 1994 Erik Bos <erik@hacktic.nl> * [if1632/relay.c] # of ordinals in shell.dll changed to 103. * [loader/signal.c] sti, cli will now be ignored. * [objects/brush.c] Added stub for GetSysColorBrush().
221 lines
5.9 KiB
C
221 lines
5.9 KiB
C
/*
|
|
* Desktop window class.
|
|
*
|
|
* Copyright 1994 Alexandre Julliard
|
|
*/
|
|
|
|
static char Copyright[] = "Copyright Alexandre Julliard, 1994";
|
|
|
|
#include <fcntl.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include "win.h"
|
|
#include "desktop.h"
|
|
#include "prototypes.h"
|
|
|
|
|
|
/***********************************************************************
|
|
* DESKTOP_LoadBitmap
|
|
*
|
|
* Load a bitmap from a file. Used by SetDeskWallPaper().
|
|
*/
|
|
static HBITMAP DESKTOP_LoadBitmap( HDC hdc, char *filename )
|
|
{
|
|
BITMAPFILEHEADER *fileHeader;
|
|
BITMAPINFO *bitmapInfo;
|
|
HBITMAP hbitmap;
|
|
char *unixFileName, *buffer;
|
|
int file;
|
|
long size;
|
|
|
|
/* Read all the file into memory */
|
|
|
|
if (!(unixFileName = GetUnixFileName( filename ))) return 0;
|
|
if ((file = open( unixFileName, O_RDONLY )) == -1) return 0;
|
|
size = lseek( file, 0, SEEK_END );
|
|
if (!(buffer = (char *)malloc( size )))
|
|
{
|
|
close( file );
|
|
return 0;
|
|
}
|
|
lseek( file, 0, SEEK_SET );
|
|
size = read( file, buffer, size );
|
|
close( file );
|
|
fileHeader = (BITMAPFILEHEADER *)buffer;
|
|
bitmapInfo = (BITMAPINFO *)(buffer + sizeof(BITMAPFILEHEADER));
|
|
|
|
/* Check header content */
|
|
if ((fileHeader->bfType != 0x4d42) || (size < fileHeader->bfSize))
|
|
{
|
|
free( buffer );
|
|
return 0;
|
|
}
|
|
hbitmap = CreateDIBitmap( hdc, &bitmapInfo->bmiHeader, CBM_INIT,
|
|
buffer + fileHeader->bfOffBits,
|
|
bitmapInfo, DIB_RGB_COLORS );
|
|
free( buffer );
|
|
return hbitmap;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* DESKTOP_DoEraseBkgnd
|
|
*
|
|
* Handle the WM_ERASEBKGND message.
|
|
*/
|
|
static LONG DESKTOP_DoEraseBkgnd( HWND hwnd, HDC hdc, DESKTOPINFO *infoPtr )
|
|
{
|
|
RECT rect;
|
|
GetClientRect( hwnd, &rect );
|
|
|
|
/* Paint desktop pattern (only if wall paper does not cover everything) */
|
|
|
|
if (!infoPtr->hbitmapWallPaper ||
|
|
(!infoPtr->fTileWallPaper && (infoPtr->bitmapSize.cx < rect.right) &&
|
|
(infoPtr->bitmapSize.cy < rect.bottom)))
|
|
{
|
|
/* Set colors in case pattern is a monochrome bitmap */
|
|
SetBkColor( hdc, RGB(0,0,0) );
|
|
SetTextColor( hdc, GetSysColor(COLOR_BACKGROUND) );
|
|
FillRect( hdc, &rect, infoPtr->hbrushPattern );
|
|
}
|
|
|
|
/* Paint wall paper */
|
|
|
|
if (infoPtr->hbitmapWallPaper)
|
|
{
|
|
int x, y;
|
|
HDC hdcmem;
|
|
|
|
hdcmem = CreateCompatibleDC( hdc );
|
|
SelectObject( hdcmem, infoPtr->hbitmapWallPaper );
|
|
if (infoPtr->fTileWallPaper)
|
|
{
|
|
for (y = 0; y < rect.bottom; y += infoPtr->bitmapSize.cy)
|
|
for (x = 0; x < rect.right; x += infoPtr->bitmapSize.cx)
|
|
BitBlt( hdc, x, y,
|
|
infoPtr->bitmapSize.cx, infoPtr->bitmapSize.cy,
|
|
hdcmem, 0, 0, SRCCOPY );
|
|
}
|
|
else
|
|
{
|
|
x = (rect.left + rect.right - infoPtr->bitmapSize.cx) / 2;
|
|
y = (rect.top + rect.bottom - infoPtr->bitmapSize.cy) / 2;
|
|
if (x < 0) x = 0;
|
|
if (y < 0) y = 0;
|
|
BitBlt( hdc, x, y, infoPtr->bitmapSize.cx, infoPtr->bitmapSize.cy,
|
|
hdcmem, 0, 0, SRCCOPY );
|
|
}
|
|
DeleteDC( hdcmem );
|
|
}
|
|
|
|
return 1;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* DesktopWndProc
|
|
*
|
|
* Window procedure for the desktop window.
|
|
*/
|
|
LONG DesktopWndProc ( HWND hwnd, WORD message, WORD wParam, LONG lParam )
|
|
{
|
|
WND *wndPtr = WIN_FindWndPtr( hwnd );
|
|
DESKTOPINFO *infoPtr = (DESKTOPINFO *)wndPtr->wExtra;
|
|
|
|
/* Most messages are ignored (we DON'T call DefWindowProc) */
|
|
|
|
switch(message)
|
|
{
|
|
/* Warning: this message is sent directly by */
|
|
/* WIN_CreateDesktopWindow() and does not contain a valid lParam */
|
|
case WM_NCCREATE:
|
|
infoPtr->hbrushPattern = 0;
|
|
infoPtr->hbitmapWallPaper = 0;
|
|
SetDeskPattern();
|
|
SetDeskWallPaper( (LPSTR)-1 );
|
|
break;
|
|
|
|
case WM_ERASEBKGND:
|
|
if (rootWindow == DefaultRootWindow(display)) return 1;
|
|
return DESKTOP_DoEraseBkgnd( hwnd, (HDC)wParam, infoPtr );
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* SetDeskPattern (USER.279)
|
|
*/
|
|
BOOL SetDeskPattern()
|
|
{
|
|
char buffer[100];
|
|
GetProfileString( "desktop", "Pattern", "(None)", buffer, 100 );
|
|
return DESKTOP_SetPattern( buffer );
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* SetDeskWallPaper (USER.285)
|
|
*/
|
|
BOOL SetDeskWallPaper( LPSTR filename )
|
|
{
|
|
HBITMAP hbitmap;
|
|
HDC hdc;
|
|
char buffer[256];
|
|
WND *wndPtr = WIN_FindWndPtr( GetDesktopWindow() );
|
|
DESKTOPINFO *infoPtr = (DESKTOPINFO *)wndPtr->wExtra;
|
|
|
|
if (filename == (LPSTR)-1)
|
|
{
|
|
GetProfileString( "desktop", "WallPaper", "(None)", buffer, 256 );
|
|
filename = buffer;
|
|
}
|
|
hdc = GetDC( 0 );
|
|
hbitmap = DESKTOP_LoadBitmap( hdc, filename );
|
|
ReleaseDC( 0, hdc );
|
|
if (infoPtr->hbitmapWallPaper) DeleteObject( infoPtr->hbitmapWallPaper );
|
|
infoPtr->hbitmapWallPaper = hbitmap;
|
|
infoPtr->fTileWallPaper = GetProfileInt( "desktop", "TileWallPaper", 0 );
|
|
if (hbitmap)
|
|
{
|
|
BITMAP bmp;
|
|
GetObject( hbitmap, sizeof(bmp), (LPSTR)&bmp );
|
|
infoPtr->bitmapSize.cx = (bmp.bmWidth != 0) ? bmp.bmWidth : 1;
|
|
infoPtr->bitmapSize.cy = (bmp.bmHeight != 0) ? bmp.bmHeight : 1;
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* DESKTOP_SetPattern
|
|
*
|
|
* Set the desktop pattern.
|
|
*/
|
|
BOOL DESKTOP_SetPattern(char *pattern )
|
|
{
|
|
WND *wndPtr = WIN_FindWndPtr( GetDesktopWindow() );
|
|
DESKTOPINFO *infoPtr = (DESKTOPINFO *)wndPtr->wExtra;
|
|
int pat[8];
|
|
|
|
if (infoPtr->hbrushPattern) DeleteObject( infoPtr->hbrushPattern );
|
|
memset( pat, 0, sizeof(pat) );
|
|
if (pattern && sscanf( pattern, " %d %d %d %d %d %d %d %d",
|
|
&pat[0], &pat[1], &pat[2], &pat[3],
|
|
&pat[4], &pat[5], &pat[6], &pat[7] ))
|
|
{
|
|
WORD pattern[8];
|
|
HBITMAP hbitmap;
|
|
int i;
|
|
|
|
for (i = 0; i < 8; i++) pattern[i] = pat[i] & 0xffff;
|
|
hbitmap = CreateBitmap( 8, 8, 1, 1, pattern );
|
|
infoPtr->hbrushPattern = CreatePatternBrush( hbitmap );
|
|
DeleteObject( hbitmap );
|
|
}
|
|
else infoPtr->hbrushPattern = CreateSolidBrush( GetSysColor(COLOR_BACKGROUND) );
|
|
return TRUE;
|
|
}
|
|
|