wine/controls/static.c
Alexandre Julliard 8664b890b0 Release 960405
Fri Apr  5 15:22:55 1996  Alexandre Julliard  <julliard@lrc.epfl.ch>

	* [controls/button.c] [controls/static.c]
	Changes to use WND * wherever possible.

	* [debugger/dbg.y] [debugger/debug.l]
	Added 'info module' and 'walk module' commands.

	* [if1632/Makefile.in] [if1632/relay.c] [tools/build.c]
	Added assembly code generation to call from Wine into 32-bit code.
	Changed all 'call32' references in 'callfrom16' to avoid confusion
	with Win32 routines.

	* [include/callback.h]
	Added prototypes for 32-bit callbacks.

	* [loader/module.c] [if1632/relay32.c] [tools/build.c]
	Unified 16- and 32-bit modules. The fake module for 32-bit DLLs is
	now generated by the build program.

	* [include/module.h]
	Added extra info to NE_MODULE for Win32 modules to point to the PE
	module data.

	* [include/pe_image.h] [loader/pe_image.c] [win32/resource.c]
	Removed the wine_files list. The PE data for a module can now be
	accessed with the NE_WIN32_MODULE macro.

	* [loader/signal.c] [miscemu/instr.c]
	Don't start the BIOS timer at startup, but only after an access to
	the 0x40 segment.

	* [memory/local.c]
	Changed LOCAL_Lock() to return a 32-bit pointer.

	* [misc/main.c] [include/dlls.h]
	Some built-in DLLs (like KERNEL) can no longer be disabled from
 	the command-line.
	
Thu Apr  4 19:54:39 1996  Keith Reynolds <keithr@sco.COM>

	* [*/*]
	A lot of small changes to support SCO OpenServer 5.

Thu Apr  4 15:38:13 1996  Frans van Dorsselaer <dorssel@rulhm1.leidenuniv.nl>

	* [controls/edit.c]
	Fixed GetKeyState() call to use 0x8000 convention.

	* [include/windows.h]
	Added undocumented messages EM_SCROLL and EM_GETTHUMB.

Thu Apr  4 09:52:52 1996  John Harvey <john@division.co.uk>

	* [if1632/except.S]
	Modified code to assemble on unixware.

Wed Apr  3 09:38:26 1996  Juergen Marquardt <marqu@lunar.advantest.de>

	* [objects/font.c]
	Implementation of a second font cache which will be updated
	dynamically.

Mon Apr  1 16:47:40 1996  Robert Pouliot <krynos@qbc.clic.net>

	* [resources/sysres_Cz.rc] [resources/sysres_Da.rc]
	  [resources/sysres_De.rc] [resources/sysres_Eo.rc]
	  [resources/sysres_Es.rc] [resources/sysres_Fi.rc]
	  [resources/sysres_No.rc] [resources/TODO]
	Updated FIND_TEXT and REPLACE_TEXT to work like the English version.
1996-04-05 14:58:24 +00:00

297 lines
8.1 KiB
C

/*
* Static control
*
* Copyright David W. Metcalfe, 1993
*
*/
#include <stdio.h>
#include <windows.h>
#include "win.h"
#include "user.h"
#include "static.h"
extern void DEFWND_SetText( WND *wndPtr, LPSTR text ); /* windows/defwnd.c */
static void STATIC_PaintTextfn( WND *wndPtr, HDC hdc );
static void STATIC_PaintRectfn( WND *wndPtr, HDC hdc );
static void STATIC_PaintIconfn( WND *wndPtr, HDC hdc );
static COLORREF color_windowframe, color_background, color_window;
typedef void (*pfPaint)( WND *, HDC);
#define LAST_STATIC_TYPE SS_LEFTNOWORDWRAP
static pfPaint staticPaintFunc[LAST_STATIC_TYPE+1] =
{
STATIC_PaintTextfn, /* SS_LEFT */
STATIC_PaintTextfn, /* SS_CENTER */
STATIC_PaintTextfn, /* SS_RIGHT */
STATIC_PaintIconfn, /* SS_ICON */
STATIC_PaintRectfn, /* SS_BLACKRECT */
STATIC_PaintRectfn, /* SS_GRAYRECT */
STATIC_PaintRectfn, /* SS_WHITERECT */
STATIC_PaintRectfn, /* SS_BLACKFRAME */
STATIC_PaintRectfn, /* SS_GRAYFRAME */
STATIC_PaintRectfn, /* SS_WHITEFRAME */
NULL, /* Not defined */
STATIC_PaintTextfn, /* SS_SIMPLE */
STATIC_PaintTextfn /* SS_LEFTNOWORDWRAP */
};
/***********************************************************************
* STATIC_SetIcon
*
* Set the icon for an SS_ICON control.
*/
static HICON STATIC_SetIcon( WND *wndPtr, HICON hicon )
{
HICON prevIcon;
STATICINFO *infoPtr = (STATICINFO *)wndPtr->wExtra;
if ((wndPtr->dwStyle & 0x0f) != SS_ICON) return 0;
prevIcon = infoPtr->hIcon;
infoPtr->hIcon = hicon;
if (hicon)
{
CURSORICONINFO *info = (CURSORICONINFO *) GlobalLock( hicon );
SetWindowPos( wndPtr->hwndSelf, 0, 0, 0, info->nWidth, info->nHeight,
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER );
GlobalUnlock( hicon );
}
return prevIcon;
}
/***********************************************************************
* StaticWndProc
*/
LONG StaticWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
LONG lResult = 0;
WND *wndPtr = WIN_FindWndPtr(hWnd);
LONG style = wndPtr->dwStyle & 0x0000000F;
STATICINFO *infoPtr = (STATICINFO *)wndPtr->wExtra;
switch (uMsg) {
case WM_ENABLE:
InvalidateRect(hWnd, NULL, FALSE);
break;
case WM_NCCREATE:
if (style == SS_ICON)
{
CREATESTRUCT * createStruct = (CREATESTRUCT *)PTR_SEG_TO_LIN(lParam);
if (createStruct->lpszName)
{
HICON hicon = LoadIcon( createStruct->hInstance,
createStruct->lpszName );
if (!hicon) /* Try OEM icon (FIXME: is this right?) */
hicon = LoadIcon( 0, createStruct->lpszName );
STATIC_SetIcon( wndPtr, hicon );
}
return 1;
}
return DefWindowProc(hWnd, uMsg, wParam, lParam);
case WM_CREATE:
if (style < 0L || style > LAST_STATIC_TYPE)
{
fprintf( stderr, "STATIC: Unknown style 0x%02lx\n", style );
lResult = -1L;
break;
}
/* initialise colours */
color_windowframe = GetSysColor(COLOR_WINDOWFRAME);
color_background = GetSysColor(COLOR_BACKGROUND);
color_window = GetSysColor(COLOR_WINDOW);
break;
case WM_NCDESTROY:
if (style == SS_ICON)
DestroyIcon( STATIC_SetIcon( wndPtr, 0 ) );
else
lResult = DefWindowProc(hWnd, uMsg, wParam, lParam);
break;
case WM_PAINT:
{
PAINTSTRUCT ps;
BeginPaint( hWnd, &ps );
if (staticPaintFunc[style])
(staticPaintFunc[style])( wndPtr, ps.hdc );
EndPaint( hWnd, &ps );
}
break;
case WM_SYSCOLORCHANGE:
color_windowframe = GetSysColor(COLOR_WINDOWFRAME);
color_background = GetSysColor(COLOR_BACKGROUND);
color_window = GetSysColor(COLOR_WINDOW);
InvalidateRect(hWnd, NULL, TRUE);
break;
case WM_SETTEXT:
if (style == SS_ICON)
/* FIXME : should we also return the previous hIcon here ??? */
STATIC_SetIcon( wndPtr, LoadIcon( wndPtr->hInstance,
(SEGPTR)lParam ));
else
DEFWND_SetText( wndPtr, (LPSTR)PTR_SEG_TO_LIN(lParam) );
InvalidateRect( hWnd, NULL, FALSE );
UpdateWindow( hWnd );
break;
case WM_SETFONT:
if (style == SS_ICON) return 0;
infoPtr->hFont = (HFONT)wParam;
if (LOWORD(lParam))
{
InvalidateRect( hWnd, NULL, FALSE );
UpdateWindow( hWnd );
}
break;
case WM_GETFONT:
return infoPtr->hFont;
case WM_NCHITTEST:
return HTTRANSPARENT;
case WM_GETDLGCODE:
return DLGC_STATIC;
case STM_GETICON:
return infoPtr->hIcon;
case STM_SETICON:
lResult = STATIC_SetIcon( wndPtr, (HICON)wParam );
InvalidateRect( hWnd, NULL, FALSE );
UpdateWindow( hWnd );
break;
default:
lResult = DefWindowProc(hWnd, uMsg, wParam, lParam);
break;
}
return lResult;
}
static void STATIC_PaintTextfn( WND *wndPtr, HDC hdc )
{
RECT rc;
HBRUSH hBrush;
char *text;
WORD wFormat;
LONG style = wndPtr->dwStyle;
STATICINFO *infoPtr = (STATICINFO *)wndPtr->wExtra;
GetClientRect( wndPtr->hwndSelf, &rc);
text = USER_HEAP_LIN_ADDR( wndPtr->hText );
switch (style & 0x0000000F)
{
case SS_LEFT:
wFormat = DT_LEFT | DT_EXPANDTABS | DT_WORDBREAK | DT_NOCLIP;
break;
case SS_CENTER:
wFormat = DT_CENTER | DT_EXPANDTABS | DT_WORDBREAK | DT_NOCLIP;
break;
case SS_RIGHT:
wFormat = DT_RIGHT | DT_EXPANDTABS | DT_WORDBREAK | DT_NOCLIP;
break;
case SS_SIMPLE:
wFormat = DT_LEFT | DT_SINGLELINE | DT_VCENTER | DT_NOCLIP;
break;
case SS_LEFTNOWORDWRAP:
wFormat = DT_LEFT | DT_SINGLELINE | DT_EXPANDTABS | DT_VCENTER | DT_NOCLIP;
break;
default:
return;
}
if (style & SS_NOPREFIX)
wFormat |= DT_NOPREFIX;
if (infoPtr->hFont) SelectObject( hdc, infoPtr->hFont );
#ifdef WINELIB32
hBrush = SendMessage( GetParent(wndPtr->hwndSelf), WM_CTLCOLORSTATIC,
hdc, wndPtr->hwndSelf );
#else
hBrush = SendMessage( GetParent(wndPtr->hwndSelf), WM_CTLCOLOR, (WORD)hdc,
MAKELONG(wndPtr->hwndSelf, CTLCOLOR_STATIC));
#endif
if (!hBrush) hBrush = GetStockObject(WHITE_BRUSH);
FillRect(hdc, &rc, hBrush);
if (text) DrawText( hdc, text, -1, &rc, wFormat );
}
static void STATIC_PaintRectfn( WND *wndPtr, HDC hdc )
{
RECT rc;
HBRUSH hBrush;
GetClientRect( wndPtr->hwndSelf, &rc);
switch (wndPtr->dwStyle & 0x0f)
{
case SS_BLACKRECT:
hBrush = CreateSolidBrush(color_windowframe);
FillRect( hdc, &rc, hBrush );
break;
case SS_GRAYRECT:
hBrush = CreateSolidBrush(color_background);
FillRect( hdc, &rc, hBrush );
break;
case SS_WHITERECT:
hBrush = CreateSolidBrush(color_window);
FillRect( hdc, &rc, hBrush );
break;
case SS_BLACKFRAME:
hBrush = CreateSolidBrush(color_windowframe);
FrameRect( hdc, &rc, hBrush );
break;
case SS_GRAYFRAME:
hBrush = CreateSolidBrush(color_background);
FrameRect( hdc, &rc, hBrush );
break;
case SS_WHITEFRAME:
hBrush = CreateSolidBrush(color_window);
FrameRect( hdc, &rc, hBrush );
break;
default:
return;
}
DeleteObject( hBrush );
}
static void STATIC_PaintIconfn( WND *wndPtr, HDC hdc )
{
RECT rc;
HBRUSH hbrush;
STATICINFO *infoPtr = (STATICINFO *)wndPtr->wExtra;
GetClientRect( wndPtr->hwndSelf, &rc);
#ifdef WINELIB32
hbrush = SendMessage( GetParent(wndPtr->hwndSelf), WM_CTLCOLORSTATIC,
hdc, wndPtr->hwndSelf );
#else
hbrush = SendMessage( GetParent(wndPtr->hwndSelf), WM_CTLCOLOR, hdc,
MAKELONG(wndPtr->hwndSelf, CTLCOLOR_STATIC));
#endif
FillRect( hdc, &rc, hbrush );
if (infoPtr->hIcon) DrawIcon( hdc, rc.left, rc.top, infoPtr->hIcon );
}