mirror of
https://github.com/reactos/wine.git
synced 2025-01-12 22:53:12 +00:00
7d654eb24e
Sat Feb 24 16:17:05 1996 Alexandre Julliard <julliard@lrc.epfl.ch> * [files/profile.c] Added \r when writing profile files, for DOS compatibility. * [memory/global.c] Fixed bug in GlobalReAlloc() that caused a discarded block not to be reallocated if its size was not changed. * [memory/selector.c] Avoid setting a valid LDT entry with base and limit set to 0, as this causes the kernel to clear the entry. This fixes a crash when exiting Windows program manager. * [objects/metafile.c] Removed call to creat() instead of _lcreat() for WINELIB. Fri Feb 23 00:35:54 1996 Thomas Sandford <tdgsandf@prds-grn.demon.co.uk> * [if1632/gdi32.spec] GetTextExtentPointA now has win32 specific implementation. * [include/struct32.h] Define new structure tagSIZE32 and typedef SIZE32 to it. Define prototype for function PARAM32_SIZE16to32 * [win32/param32.c] New functions PARAM32_SIZE16to32 and WIN32_GetTextExtentPointA * [win32/memory.c] Added missing file pointer parameter to fprintf. Thu Feb 22 01:14:21 1996 Eric Warnke <ew2193@csc.albany.edu> * [windows/nonclient.c] Added more familiar icon activity, ie single click brings up system menu. Wed Feb 21 13:07:04 1996 Frans van Dorsselaer <dorssel@rulhm1.leidenuniv.nl> * [controls/menu.c] Added calls to HideCaret() and ShowCaret() from within TrackPopupMenu(), MENU_TrackMouseMenuBar() and MENU_TrackKbdMenuBar(). Are there any more places where this should be done? * [controls/static.c] Fixed a FIXME in STATIC_SetIcon(), which now returns a handle to the previous icon. Added a new FIXME at the point where WM_SETTEXT is handled for a SS_ICON static control. * [misc/commdlg.c] Implemented FindText() and ReplaceText() Still missing : Templates and Hooks handling / error checking * [resources/sysres_En.c] Redesigned FIND_TEXT and REPLACE_TEXT dialogs, so they now work. Languages other than En should update these too, though, as well as redimension the controls because some of the text doesn't fit. Created file resources/TODO to explain this. * [windows/caret.c] Re-written. It now uses the correct R2_XORPEN. It resets the blink timer on SetCaretPos(). It does its own hide/show scheme when SetCaretPos() is called (should be faster). Mon Feb 19 21:50:00 1996 Alex Korobka <alex@phm30.pharm.sunysb.edu> * [controls/listbox.c] Miscellaneous changes for better LBS_EXTENDEDSEL support. Removed several superfluous redrawals of item list. * [controls/scroll.c] WM_GETDLGCODE return value. * [windows/win.c] FlashWindow function. * [windows/painting.c] [windows/scroll.c] Added HideCaret/ShowCaret calls. * [objects/font.c] Added GetCharABCWidths stub. * [include/windows.h] "#define"s needed for changes mentioned above. Mon Feb 19 20:12:03 1996 Hans de Graaff <Hans.deGraaff@twi72.twi.tudelft.nl> * [include/winsock.h] Change order of includes to get in_addr struct defined in time. (Note: Linux 1.3.66, libc 5.2.18) * [misc/main.c] [include/options.h] [miscemu/int2f.c] Changed the -enhanced option into a -mode option, which can be either 'standard' or 'enhanced'. 'enhanced' is the default.
305 lines
8.2 KiB
C
305 lines
8.2 KiB
C
/*
|
|
* Static control
|
|
*
|
|
* Copyright David W. Metcalfe, 1993
|
|
*
|
|
static char Copyright[] = "Copyright David W. Metcalfe, 1993";
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include <windows.h>
|
|
#include "win.h"
|
|
#include "user.h"
|
|
#include "static.h"
|
|
|
|
extern void DEFWND_SetText( HWND hwnd, LPSTR text ); /* windows/defwnd.c */
|
|
|
|
static void PaintTextfn( HWND hwnd, HDC hdc );
|
|
static void PaintRectfn( HWND hwnd, HDC hdc );
|
|
static void PaintIconfn( HWND hwnd, HDC hdc );
|
|
|
|
|
|
static COLORREF color_windowframe, color_background, color_window;
|
|
|
|
|
|
typedef void (*pfPaint)(HWND, HDC);
|
|
|
|
#define LAST_STATIC_TYPE SS_LEFTNOWORDWRAP
|
|
|
|
static pfPaint staticPaintFunc[LAST_STATIC_TYPE+1] =
|
|
{
|
|
PaintTextfn, /* SS_LEFT */
|
|
PaintTextfn, /* SS_CENTER */
|
|
PaintTextfn, /* SS_RIGHT */
|
|
PaintIconfn, /* SS_ICON */
|
|
PaintRectfn, /* SS_BLACKRECT */
|
|
PaintRectfn, /* SS_GRAYRECT */
|
|
PaintRectfn, /* SS_WHITERECT */
|
|
PaintRectfn, /* SS_BLACKFRAME */
|
|
PaintRectfn, /* SS_GRAYFRAME */
|
|
PaintRectfn, /* SS_WHITEFRAME */
|
|
NULL, /* Not defined */
|
|
PaintTextfn, /* SS_SIMPLE */
|
|
PaintTextfn /* SS_LEFTNOWORDWRAP */
|
|
};
|
|
|
|
|
|
/***********************************************************************
|
|
* STATIC_SetIcon
|
|
*
|
|
* Set the icon for an SS_ICON control.
|
|
*/
|
|
static HICON STATIC_SetIcon( HWND hwnd, HICON hicon )
|
|
{
|
|
HICON prevIcon;
|
|
WND *wndPtr = WIN_FindWndPtr( hwnd );
|
|
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( hwnd, 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,
|
|
(SEGPTR)createStruct->lpszName );
|
|
if (!hicon) /* Try OEM icon (FIXME: is this right?) */
|
|
hicon = LoadIcon( 0, (SEGPTR)createStruct->lpszName );
|
|
STATIC_SetIcon( hWnd, 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( hWnd, 0 ) );
|
|
else
|
|
lResult = DefWindowProc(hWnd, uMsg, wParam, lParam);
|
|
break;
|
|
|
|
case WM_PAINT:
|
|
{
|
|
PAINTSTRUCT ps;
|
|
BeginPaint( hWnd, &ps );
|
|
if (staticPaintFunc[style])
|
|
(staticPaintFunc[style])( hWnd, 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( hWnd, LoadIcon( wndPtr->hInstance,
|
|
(SEGPTR)lParam ));
|
|
else
|
|
DEFWND_SetText( hWnd, (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 (LONG)infoPtr->hFont;
|
|
|
|
case WM_NCHITTEST:
|
|
return HTTRANSPARENT;
|
|
|
|
case WM_GETDLGCODE:
|
|
return DLGC_STATIC;
|
|
|
|
case STM_GETICON:
|
|
return (LONG)infoPtr->hIcon;
|
|
|
|
case STM_SETICON:
|
|
lResult = (LONG)STATIC_SetIcon( hWnd, (HICON)wParam );
|
|
InvalidateRect( hWnd, NULL, FALSE );
|
|
UpdateWindow( hWnd );
|
|
break;
|
|
|
|
default:
|
|
lResult = DefWindowProc(hWnd, uMsg, wParam, lParam);
|
|
break;
|
|
}
|
|
|
|
return lResult;
|
|
}
|
|
|
|
|
|
static void PaintTextfn( HWND hwnd, HDC hdc )
|
|
{
|
|
RECT rc;
|
|
HBRUSH hBrush;
|
|
char *text;
|
|
WORD wFormat;
|
|
|
|
WND *wndPtr = WIN_FindWndPtr(hwnd);
|
|
LONG style = wndPtr->dwStyle;
|
|
STATICINFO *infoPtr = (STATICINFO *)wndPtr->wExtra;
|
|
|
|
GetClientRect(hwnd, &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 = (HBRUSH)SendMessage( wndPtr->hwndParent, WM_CTLCOLORSTATIC,
|
|
(WPARAM)hdc, (LPARAM)hwnd );
|
|
#else
|
|
hBrush = SendMessage( wndPtr->hwndParent, WM_CTLCOLOR, (WORD)hdc,
|
|
MAKELONG(hwnd, CTLCOLOR_STATIC));
|
|
#endif
|
|
if (hBrush == (HBRUSH)NULL) hBrush = GetStockObject(WHITE_BRUSH);
|
|
FillRect(hdc, &rc, hBrush);
|
|
if (text)
|
|
DrawText(hdc, text, -1, &rc, wFormat);
|
|
}
|
|
|
|
static void PaintRectfn( HWND hwnd, HDC hdc )
|
|
{
|
|
RECT rc;
|
|
HBRUSH hBrush;
|
|
|
|
WND *wndPtr = WIN_FindWndPtr(hwnd);
|
|
|
|
GetClientRect(hwnd, &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 PaintIconfn( HWND hwnd, HDC hdc )
|
|
{
|
|
RECT rc;
|
|
HBRUSH hbrush;
|
|
WND *wndPtr = WIN_FindWndPtr(hwnd);
|
|
STATICINFO *infoPtr = (STATICINFO *)wndPtr->wExtra;
|
|
|
|
GetClientRect(hwnd, &rc);
|
|
#ifdef WINELIB32
|
|
hbrush = (HBRUSH)SendMessage( wndPtr->hwndParent, WM_CTLCOLORSTATIC,
|
|
(WPARAM)hdc, (LPARAM)hwnd );
|
|
#else
|
|
hbrush = SendMessage( wndPtr->hwndParent, WM_CTLCOLOR, hdc,
|
|
MAKELONG(hwnd, CTLCOLOR_STATIC));
|
|
#endif
|
|
FillRect( hdc, &rc, hbrush );
|
|
if (infoPtr->hIcon) DrawIcon( hdc, rc.left, rc.top, infoPtr->hIcon );
|
|
}
|