wine/controls/status.c
Alexandre Julliard f90efa9cf0 Release 980614
Sun Jun 15 10:30:35 1998  Andreas Mohr <100.30936@germany.net>

	* [files/dos_fs.c] [files/file.c] [if1632/wprocs.spec]
	  [misc/aspi.c]
	Added support for scanners that need Adaptec's ASPI2DOS.

	* [graphics/env.c] [misc/printerdrv.c] [graphics/win16drv/init.c]
	  [if1632/gdi.spec] [include/gdi.h]
	Enhanced printer support (especially Win95):
	Drv[GS]etPrinterData, [GS]etEnvironment; added AbortProc handling.

	* [misc/tapi32.c] [relay32/tapi32.spec]
	Added some stubs.

	* [configure.in] [graphics/fontengine.c] [include/windows.h]
	  [misc/comm.c] [misc/w32skrnl.c] [misc/win32s16.c]
	Made Wine compile on HP-UX (just for fun ;)

	* [controls/menu.c] [include/windows.h]
	Complete rewrite of EnableMenuItem32.
	Free Agent 32 still doesn't work :(

	* [misc/version.c] [if1632/kernel.spec] [include/winbase.h]
	Implemented GetVersionEx16.

	* [misc/network.c] [if1632/user.spec]
	Fixed arguments of WNetGetPropertyText.

	* [misc/version.c] [relay32/comctl32.spec] [relay32/oleaut32.spec]
	Implemented COMCTL32_DllGetVersion, OaBuildVersion.

	* [win32/file.c]
	Fixed UNC handling of CreateFile32.

Sat Jun 13 22:35:12 1998  Douglas Ridgway  <ridgway@winehq.com>

	* [Makefile.in] [Make.rules.in]
	Added pattern for CVS merge files to 'make clean'

	* [ole/olecli.c] [windows/scroll.c] [windows/grahics.c]
	Add some DC handle unlocking. (When hdc's are always unlocked,
	they can be made moveable.)

	* [documentation/wine.texinfo] 
	Started a Wine Design chapter with discussion of 
	graphics driver model.

Sat Jun 13 11:19:25 1998  David Luyer <luyer@ucs.uwa.edu.au>

	* [misc/main.c] [relay32/relay386.c]
	Added new option -debugmsg +relay=.... or -debugmsg -relay=...

Fri Jun 12 22:56:09 1998  Marcus Meissner <marcus@jet.franken.de>

	* [relay32/snoop.c][relay32/builtin.c][loader/pe_image.c]
	Added inter win32 dll snooping. Use -debugmsg +snoop.
	Number of arguments and string references are autodetected.
	Some small bugfixes in the PE loader.

	* [misc/system.c]
	Disabled SystemTimers. They do not work with the current
	%fs handling in the 32->16 relaycode. (helps labview)

	* [msdos/dpmi.c][msdos/int2f.c][files/drive.c]
	Added a monoton linear increasing memory allocator for DPMI (required
	for LabView, HAFAS, ...)
	mscdex handling in emulated realmode interrupts (for mcicda.drv)
	allocate logical drives only once. (helps Myst)

	* [files/profile.c]
	Handle ^Z as space. Found on CDROMS (helps Myst Installer).

	* [multimedia/mmio.c]
	mmio* partially updated to win32. No funny additions.

	* [windows/driver.c]
	Added win32 driver handling (will be used for win32 multimedia/
	msvideo drivers).

	* [win32/device.c]
	Added device handling (K32OBJ_DEVICE_IOCTL). Implemented 
	VTDAPI.5 (used by win95' WINMM.timeGetTime())

Fri Jun 12 18:01:18 1998 Rein Klazes <rklazes@casema.net>

	* [ole/compobj.c relay32/ole32.spec]
	Add a stub for CoLockObjectExternal32.

	* [objects/clipping.c]
	Fix in IntersectClipRect(), when there is no initial clipping
	region.

	* [graphics/x11drv/graphics.c]
	Corrected several "one-off" errors for the Ellipse, Rectangle
	and RoundRectangle (especially small ones) draw routines. 
	Arc and friends still have to be done.

Fri Jun 12 06:23:19 1998  Matthew Becker <mbecker@glasscity.net>

	* [misc/ntdll.c]
	Fixed some of the parameter counts.

	* [misc/registry.c]
	General cleanup, documentation.
	Standard keys are allowed to be 'closed' and succeed.

	* [misc/shell.c]
	Check for correct return values from Reg* functions.

	* [win32/newfns.c]
	Added stubs for OpenDesktopA, SetThreadDesktop, and
	SetUserObjectInformationA.

Wed Jun 10  20:28:08 1998  James Juran  <jrj120@psu.edu>

	* [debugger/break.c]
	Fixed bug introduced in 980503 that broke the -debug command 
	line option for PE executable files.

	* [configure.in] [include/acconfig.h] [include/debugtools.h]
	  [documentation/debug-msgs]
	Added 'configure' options to compile out debugging messages.
	Use --disable-debug to disable all debugging messages, and
	--disable-trace to just disable TRACE messages.  This results
	in a stripped executable that is 15-20% smaller.  This option
	is very much untested--don't expect it to work.

	* [documentation/debug-msgs] [documentation/debugging]
	Minor updates.

	* [*/*.c]
	Fixed some compile warnings.  This also includes the
	compile_warnings_trivial patch from WineHQ.

Tue Jun 10 22:00:18 1998  Eric Kohl <ekohl@abo.rhein-zeitung.de>

	* [windows/sysmetrics.c][include/sysmetrics.h]
	Fixed some Win95 values.

	* [windows/nonclient.c][include/windows.h]
	Fixed some Win95 drawing bugs.
	Added extended window style flags (WS_EX_xxx).

	* [misc/printdrv.c][relay32/winspool.spec]
	Added stubs for DeletePrinterDriver32A, DeleteMonitor32A
	and DeletePort32A.

	* [windows/mdi.c][include/windows.h][relay32/user32.spec]
	Added stubs for CascadeWindows and TileWindows.

	* [controls/toolbar.c][include/toolbar.h]
	Fixed a few bugs and implemented new features.

	* [misc/shellord.c][relay32/shell32.spec]
	Added stubs for SHELL32_60, SHELL32_61 and SHELL32_184.

	* [controls/comctl32undoc.c][relay32/comctl32.spec]
	New file comctl32undoc.c. Contains undocumented functions
	of COMCTL32.DLL. These functions are needed to run EXPLORER.EXE
	IEXPLORE.EXE and TASKMAN.EXE.

	* [controls/status.c]
	Added text alignment.

Tue Jun  8 22:00:00 1998  Bertho Stultiens <bertho@akhphd.au.dk>

	* [programs/*/Makefile.in]
	Changed the rules to use wrc as resource compiler but
	passing the source through gcc first for macro expansion.

	* [programs/*/*.rc]
	Added #include "windows.h" for the resource compiler in the
	appropriate files.

	* [tools/wrc/wrc.[ch]] [tools/wrc/writeres.c]
	Added commandline option -A for autoregister code.
	Corrected the underscore problem by checking the proper define
	from config.h.

Sun Jun  7 22:09:29 1998  Pascal Cuoq <pcuoq@ens-lyon.fr>

	* [ole/ole2nls.c] [memory/string.c]
	Improved LCMapString32A, and changed CompareString32A,
	lstrcmp, lstrcmpi to use it.

Sat Jun  6 19:00:50 1998  Martin Strömberg <ams@ludd.luth.se>

	* [include/winnt.h]
	Added typedefs for security and tokens.

Sat Jun  6 12:26:31 1998  Morten Welinder  <terra@diku.dk>

	* [objects/text.c]
	Use debugstr_an in DrawText16.

	* [loader/resource.c]
	Use debugres_w in FindResourceEx32W.  Avoid crashing during
	debug when wm is NULL.

	* [if1632/relay.c]
	In RELAY_DebugCallTo16, send output to the right place and
	avoid side effects in macro arguments.

Wed Jun  3 20:56:03 1998  Huw D M Davies <daviesh@abacus.physics.ox.ac.uk>

	* [controls/scroll.c] [windows/nonclient.c]
	Fix several off by one errors in scrollbar painting.

Tue Jun  2 23:58:59 1998  Insomnia (Stea Greene) <insomnia@core.binghamton.edu>

	* [graphics/dsound.c]
	Rewrote mixer code to handle panning and volume for 16->16, 16->8,
	8->16, and 8->8 bit mixes.  Conforms to DirectX's "logarithmic
	hearing scale" as specified in M$VC docs.  Still does not handle
	mixing of different frequencies (I am still working on that). 
	Tested 16->16 extensively with StarCraft.  Other mixing combinations
	untested but should work fine.  Still kind of a work in progress,
	so be warned.

Tue Jun  2 03:31:33 1998  Alexander V. Lukyanov <lav@long.yar.ru>

	* [tools/wrc/utils.c]
	dup_basename: fix to strip directory.

Mon Jun  1 20:00:00 1998  Juergen Schmied <juergen.schmied@metronet.de>

	* [include/windows.h] [objects/cursoricon.c] [relay32/user32.spec]
	Added stubs LoadCursorFromFileW and LoadCursorFromFileA.
1998-06-14 15:24:15 +00:00

863 lines
20 KiB
C

/*
* Interface code to StatusWindow widget/control
*
* Copyright 1996 Bruce Milner
* Copyright 1998 Eric Kohl
*/
#include "windows.h"
#include "status.h"
#include "commctrl.h"
#include "heap.h"
#include "win.h"
/*
* Run tests using Waite Group Windows95 API Bible Vol. 1&2
* The second cdrom contains executables drawstat.exe,gettext.exe,
* simple.exe, getparts.exe, setparts.exe, statwnd.exe
*/
/*
* Fixme/Todo
* 1) Don't hard code bar to bottom of window, allow CCS_TOP also.
+ 2) Tooltip support.
*/
#define _MAX(a,b) (((a)>(b))?(a):(b))
#define _MIN(a,b) (((a)>(b))?(b):(a))
#define HORZ_BORDER 0
#define VERT_BORDER 2
#define HORZ_GAP 2
static STATUSWINDOWINFO *GetStatusInfo(HWND32 hwnd)
{
WND *wndPtr;
wndPtr = WIN_FindWndPtr(hwnd);
return ((STATUSWINDOWINFO *) wndPtr->wExtra[0]);
}
static void
STATUS_DrawSizeGrip (HDC32 hdc, LPRECT32 lpRect)
{
HPEN32 hOldPen;
POINT32 pt;
INT32 i;
pt.x = lpRect->right - 1;
pt.y = lpRect->bottom - 1;
hOldPen = SelectObject32 (hdc, GetSysColorPen32 (COLOR_3DFACE));
MoveToEx32 (hdc, pt.x - 12, pt.y, NULL);
LineTo32 (hdc, pt.x, pt.y);
LineTo32 (hdc, pt.x, pt.y - 12);
pt.x--;
pt.y--;
SelectObject32 (hdc, GetSysColorPen32 (COLOR_3DSHADOW));
for (i = 1; i < 11; i += 4) {
MoveToEx32 (hdc, pt.x - i, pt.y, NULL);
LineTo32 (hdc, pt.x, pt.y - i);
MoveToEx32 (hdc, pt.x - i-1, pt.y, NULL);
LineTo32 (hdc, pt.x, pt.y - i-1);
}
SelectObject32 (hdc, GetSysColorPen32 (COLOR_3DHIGHLIGHT));
for (i = 3; i < 13; i += 4) {
MoveToEx32 (hdc, pt.x - i, pt.y, NULL);
LineTo32 (hdc, pt.x, pt.y - i);
}
SelectObject32 (hdc, hOldPen);
}
static void
SB_DrawPart( HDC32 hdc, LPRECT32 lprc, HICON32 hIcon,
LPCSTR text, UINT32 style )
{
RECT32 r = *lprc;
UINT32 border = BDR_SUNKENOUTER;
if (style==SBT_POPOUT)
border = BDR_RAISEDOUTER;
else if (style==SBT_NOBORDERS)
border = 0;
DrawEdge32(hdc, &r, border, BF_RECT|BF_ADJUST);
/* draw the icon */
if (hIcon) {
INT32 cy = r.bottom - r.top;
r.left += 2;
DrawIconEx32 (hdc, r.left, r.top, hIcon, cy, cy, 0, 0, DI_NORMAL);
r.left += cy;
}
/* now draw text */
if (text) {
int oldbkmode = SetBkMode32(hdc, TRANSPARENT);
LPSTR p = text;
UINT32 align = DT_LEFT;
if (*p == '\t') {
p++;
align = DT_CENTER;
if (*p == '\t') {
p++;
align = DT_RIGHT;
}
}
r.left += 3;
DrawText32A(hdc, p, lstrlen32A(p), &r, align|DT_VCENTER|DT_SINGLELINE);
if (oldbkmode != TRANSPARENT)
SetBkMode32(hdc, oldbkmode);
}
}
static BOOL32
SW_Refresh( HWND32 hwnd, HDC32 hdc, STATUSWINDOWINFO *self )
{
int i;
RECT32 rect;
HBRUSH32 hbrBk;
HFONT32 hOldFont;
WND *wndPtr;
wndPtr = WIN_FindWndPtr(hwnd);
if (!IsWindowVisible32(hwnd)) {
return (TRUE);
}
GetClientRect32 (hwnd, &rect);
if (self->clrBk != CLR_DEFAULT)
hbrBk = CreateSolidBrush32 (self->clrBk);
else
hbrBk = GetSysColorBrush32 (COLOR_3DFACE);
FillRect32(hdc, &rect, hbrBk);
hOldFont = SelectObject32 (hdc, self->hFont ? self->hFont : self->hDefaultFont);
if (self->simple) {
SB_DrawPart (hdc,
&self->part0.bound,
self->part0.hIcon,
self->part0.text,
self->part0.style);
}
else {
for (i = 0; i < self->numParts; i++) {
if (self->parts[i].style == SBT_OWNERDRAW) {
DRAWITEMSTRUCT32 dis;
WND *wndPtr = WIN_FindWndPtr(hwnd);
dis.CtlID = wndPtr->wIDmenu;
dis.itemID = -1;
dis.hwndItem = hwnd;
dis.hDC = hdc;
dis.rcItem = self->part0.bound;
dis.itemData = (INT32)self->part0.text;
SendMessage32A (GetParent32 (hwnd), WM_DRAWITEM,
(WPARAM32)wndPtr->wIDmenu, (LPARAM)&dis);
}
else
SB_DrawPart (hdc,
&self->parts[i].bound,
self->parts[i].hIcon,
self->parts[i].text,
self->parts[i].style);
}
}
SelectObject32 (hdc, hOldFont);
if (self->clrBk != CLR_DEFAULT)
DeleteObject32 (hbrBk);
if (wndPtr->dwStyle & SBARS_SIZEGRIP)
STATUS_DrawSizeGrip (hdc, &rect);
return TRUE;
}
static LRESULT
SW_GetBorders(STATUSWINDOWINFO *self, HWND32 hwnd, WPARAM32 wParam, LPARAM lParam)
{
LPINT32 out;
out = (LPINT32) lParam;
out[0] = HORZ_BORDER; /* horizontal border width */
out[1] = VERT_BORDER; /* vertical border width */
out[2] = HORZ_GAP; /* width of border between rectangles */
return TRUE;
}
static void
SW_SetPartBounds(HWND32 hwnd, STATUSWINDOWINFO *self)
{
int i;
RECT32 rect, *r;
STATUSWINDOWPART *part;
/* get our window size */
GetClientRect32(hwnd, &rect);
rect.top += VERT_BORDER;
/* set bounds for simple rectangle */
self->part0.bound = rect;
/* set bounds for non-simple rectangles */
for (i = 0; i < self->numParts; i++) {
part = &self->parts[i];
r = &self->parts[i].bound;
r->top = rect.top;
r->bottom = rect.bottom;
if (i == 0)
r->left = 0;
else
r->left = self->parts[i-1].bound.right + HORZ_GAP;
if (part->x == -1)
r->right = rect.right;
else
r->right = part->x;
}
}
static LRESULT
SW_SetText(STATUSWINDOWINFO *self, HWND32 hwnd, WPARAM32 wParam, LPARAM lParam)
{
int part_num;
int style;
LPSTR text;
int len;
STATUSWINDOWPART *part;
text = (LPSTR) lParam;
part_num = ((INT32) wParam) & 0x00ff;
style = ((INT32) wParam) & 0xff00;
if ((self->simple) || (self->parts==NULL) || (part_num==255))
part = &self->part0;
else
part = &self->parts[part_num];
if (!part) return FALSE;
part->style = style;
if (style == SBT_OWNERDRAW) {
part->text = text;
}
else {
/* duplicate string */
if (part->text)
HeapFree(SystemHeap, 0, part->text);
part->text = 0;
if (text && (len = lstrlen32A(text))) {
part->text = HeapAlloc(SystemHeap, 0, len+1);
lstrcpy32A(part->text, text);
}
}
InvalidateRect32(hwnd, &part->bound, FALSE);
// SW_RefreshPart (hdc, part);
return TRUE;
}
static LRESULT
SW_SetParts(STATUSWINDOWINFO *self, HWND32 hwnd, WPARAM32 wParam, LPARAM lParam)
{
HDC32 hdc;
LPINT32 parts;
STATUSWINDOWPART * tmp;
int i;
int oldNumParts;
if (self->simple) {
self->simple = FALSE;
}
oldNumParts = self->numParts;
self->numParts = (INT32) wParam;
parts = (LPINT32) lParam;
if (oldNumParts > self->numParts) {
for (i = self->numParts ; i < oldNumParts; i++) {
if (self->parts[i].text && (self->parts[i].style != SBT_OWNERDRAW))
HeapFree(SystemHeap, 0, self->parts[i].text);
}
}
else if (oldNumParts < self->numParts) {
tmp = HeapAlloc(SystemHeap, HEAP_ZERO_MEMORY,
sizeof(STATUSWINDOWPART) * self->numParts);
for (i = 0; i < oldNumParts; i++) {
tmp[i] = self->parts[i];
}
if (self->parts)
HeapFree(SystemHeap, 0, self->parts);
self->parts = tmp;
}
for (i = 0; i < self->numParts; i++) {
self->parts[i].x = parts[i];
}
SW_SetPartBounds(hwnd, self);
hdc = GetDC32(hwnd);
SW_Refresh(hwnd, hdc, self);
ReleaseDC32(hwnd, hdc);
return TRUE;
}
static LRESULT
SW_GetParts(STATUSWINDOWINFO *self, HWND32 hwnd, WPARAM32 wParam, LPARAM lParam)
{
LPINT32 parts;
INT32 num_parts;
int i;
self = GetStatusInfo(hwnd);
num_parts = (INT32) wParam;
parts = (LPINT32) lParam;
if (parts) {
return (self->numParts);
for (i = 0; i < num_parts; i++) {
parts[i] = self->parts[i].x;
}
}
return (self->numParts);
}
static LRESULT
SW_Create(HWND32 hwnd, WPARAM32 wParam, LPARAM lParam)
{
LPCREATESTRUCT32A lpCreate = (LPCREATESTRUCT32A) lParam;
NONCLIENTMETRICS32A nclm;
RECT32 rect;
int width, len;
HDC32 hdc;
HWND32 parent;
WND *wndPtr;
STATUSWINDOWINFO *self;
wndPtr = WIN_FindWndPtr(hwnd);
self = (STATUSWINDOWINFO*)HeapAlloc (SystemHeap, HEAP_ZERO_MEMORY,
sizeof(STATUSWINDOWINFO));
wndPtr->wExtra[0] = (DWORD)self;
self->numParts = 1;
self->parts = 0;
self->simple = FALSE;
self->clrBk = CLR_DEFAULT;
self->hFont = 0;
GetClientRect32(hwnd, &rect);
nclm.cbSize = sizeof(NONCLIENTMETRICS32A);
SystemParametersInfo32A (SPI_GETNONCLIENTMETRICS, 0, &nclm, 0);
self->hDefaultFont = CreateFontIndirect32A (&nclm.lfStatusFont);
/* initialize simple case */
self->part0.bound = rect;
self->part0.text = 0;
self->part0.x = 0;
self->part0.style = 0;
self->part0.hIcon = 0;
/* initialize first part */
self->parts = HeapAlloc (SystemHeap, HEAP_ZERO_MEMORY,
sizeof(STATUSWINDOWPART));
self->parts[0].bound = rect;
self->parts[0].text = 0;
self->parts[0].x = -1;
self->parts[0].style = 0;
self->parts[0].hIcon = 0;
if ((len = lstrlen32A (lpCreate->lpszName))) {
self->parts[0].text = HeapAlloc (SystemHeap, 0, len + 1);
lstrcpy32A (self->parts[0].text, lpCreate->lpszName);
}
if ((hdc = GetDC32 (0))) {
TEXTMETRIC32A tm;
HFONT32 hOldFont;
hOldFont = SelectObject32 (hdc,self->hDefaultFont);
GetTextMetrics32A(hdc, &tm);
self->textHeight = tm.tmHeight;
SelectObject32 (hdc, hOldFont);
ReleaseDC32(0, hdc);
}
parent = GetParent32 (hwnd);
GetClientRect32 (parent, &rect);
width = rect.right - rect.left;
self->height = self->textHeight + 4 + VERT_BORDER;
MoveWindow32 (hwnd, lpCreate->x, lpCreate->y-1, width, self->height, FALSE);
SW_SetPartBounds (hwnd, self);
return 0;
}
static LRESULT
SW_GetRect(STATUSWINDOWINFO *self, HWND32 hwnd, WPARAM32 wParam, LPARAM lParam)
{
int part_num;
LPRECT32 rect;
part_num = ((INT32) wParam) & 0x00ff;
rect = (LPRECT32) lParam;
if (self->simple)
*rect = self->part0.bound;
else
*rect = self->parts[part_num].bound;
return TRUE;
}
static LRESULT
SW_GetText(STATUSWINDOWINFO *self, HWND32 hwnd, WPARAM32 wParam, LPARAM lParam)
{
int part_num;
LRESULT result;
STATUSWINDOWPART *part;
LPSTR out_text;
part_num = ((INT32) wParam) & 0x00ff;
out_text = (LPSTR) lParam;
if (self->simple)
part = &self->part0;
else
part = &self->parts[part_num];
if (part->style == SBT_OWNERDRAW)
result = (LRESULT) part->text;
else {
result = part->text ? lstrlen32A(part->text) : 0;
result |= (part->style << 16);
if (out_text) {
lstrcpy32A(out_text, part->text);
}
}
return result;
}
static LRESULT
SW_GetTextLength(STATUSWINDOWINFO *self, HWND32 hwnd, WPARAM32 wParam, LPARAM lParam)
{
int part_num;
STATUSWINDOWPART *part;
DWORD result;
part_num = ((INT32) wParam) & 0x00ff;
if (self->simple)
part = &self->part0;
else
part = &self->parts[part_num];
if (part->text)
result = lstrlen32A(part->text);
else
result = 0;
result |= (part->style << 16);
return result;
}
static LRESULT
SW_SetMinHeight(STATUSWINDOWINFO *self, HWND32 hwnd, WPARAM32 wParam, LPARAM lParam)
{
INT32 width, x, y;
RECT32 parent_rect;
HWND32 parent;
if (IsWindowVisible32 (hwnd)) {
parent = GetParent32(hwnd);
GetClientRect32(parent, &parent_rect);
self->height = (INT32)wParam + VERT_BORDER;
width = parent_rect.right - parent_rect.left;
x = parent_rect.left;
y = parent_rect.bottom - self->height;
MoveWindow32(hwnd, parent_rect.left, parent_rect.bottom - self->height,
width, self->height, TRUE);
SW_SetPartBounds(hwnd, self);
}
return TRUE;
}
static LRESULT
SW_SetBkColor(STATUSWINDOWINFO *self, HWND32 hwnd, WPARAM32 wParam, LPARAM lParam)
{
COLORREF oldBkColor;
HDC32 hdc;
oldBkColor = self->clrBk;
self->clrBk = (COLORREF)lParam;
hdc = GetDC32(hwnd);
SW_Refresh(hwnd, hdc, self);
ReleaseDC32(hwnd, hdc);
return oldBkColor;
}
static LRESULT
SW_SetIcon (STATUSWINDOWINFO *self, HWND32 hwnd, WPARAM32 wParam, LPARAM lParam)
{
INT32 nPart = (INT32)wParam & 0x00ff;
if ((nPart < -1) || (nPart >= self->numParts)) return FALSE;
if (nPart == -1) {
self->part0.hIcon = (HICON32)lParam;
if (self->simple)
InvalidateRect32(hwnd, &self->part0.bound, FALSE);
}
else {
self->parts[nPart].hIcon = (HICON32)lParam;
if (!(self->simple))
InvalidateRect32(hwnd, &self->parts[nPart].bound, FALSE);
}
return TRUE;
}
static LRESULT
SW_GetIcon(STATUSWINDOWINFO *self, HWND32 hwnd, WPARAM32 wParam, LPARAM lParam)
{
INT32 nPart;
nPart = (INT32)wParam & 0x00ff;
if ((nPart < -1) || (nPart >= self->numParts)) return 0;
if (nPart == -1)
return (self->part0.hIcon);
else
return (self->parts[nPart].hIcon);
}
static LRESULT
SW_Simple(STATUSWINDOWINFO *self, HWND32 hwnd, WPARAM32 wParam, LPARAM lParam)
{
WND *wndPtr;
BOOL32 simple;
HDC32 hdc;
NMHDR nmhdr;
wndPtr = WIN_FindWndPtr(hwnd);
simple = (BOOL32) wParam;
self->simple = simple;
/* send notification */
nmhdr.hwndFrom = hwnd;
nmhdr.idFrom = wndPtr->wIDmenu;
nmhdr.code = SBN_SIMPLEMODECHANGE;
SendMessage32A (GetParent32 (hwnd), WM_NOTIFY, 0, (LPARAM)&nmhdr);
hdc = GetDC32(hwnd);
SW_Refresh(hwnd, hdc, self);
ReleaseDC32(hwnd, hdc);
return TRUE;
}
static LRESULT
SW_Destroy(STATUSWINDOWINFO *self, HWND32 hwnd, WPARAM32 wParam, LPARAM lParam)
{
int i;
for (i = 0; i < self->numParts; i++) {
if (self->parts[i].text && (self->parts[i].style != SBT_OWNERDRAW))
HeapFree(SystemHeap, 0, self->parts[i].text);
}
if (self->part0.text && (self->part0.style != SBT_OWNERDRAW))
HeapFree(SystemHeap, 0, self->part0.text);
HeapFree(SystemHeap, 0, self->parts);
/* delete default font */
if (self->hDefaultFont)
DeleteObject32 (self->hDefaultFont);
HeapFree(SystemHeap, 0, self);
return 0;
}
static LRESULT
SW_WMGetText (STATUSWINDOWINFO *self, HWND32 hwnd, WPARAM32 wParam, LPARAM lParam)
{
INT32 len;
if (!(self->parts[0].text))
return 0;
len = lstrlen32A (self->parts[0].text);
if (wParam > len) {
lstrcpy32A ((LPSTR)lParam, self->parts[0].text);
return len;
}
else
return -1;
}
static LRESULT
SW_WMGetTextLength (STATUSWINDOWINFO *self, HWND32 hwnd, WPARAM32 wParam, LPARAM lParam)
{
if (!(self->parts[0].text))
return 0;
return (lstrlen32A (self->parts[0].text));
}
static LRESULT
SW_NcHitTest (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
{
RECT32 rect;
POINT32 pt;
if (wndPtr->dwStyle & SBARS_SIZEGRIP) {
GetClientRect32 (wndPtr->hwndSelf, &rect);
pt.x = (INT32)LOWORD(lParam);
pt.y = (INT32)HIWORD(lParam);
ScreenToClient32 (wndPtr->hwndSelf, &pt);
rect.left = rect.right - 13;
rect.top += 2;
if (PtInRect32 (&rect, pt))
return HTBOTTOMRIGHT;
}
return DefWindowProc32A (wndPtr->hwndSelf, WM_NCHITTEST, wParam, lParam);
}
static LRESULT
SW_NcLButtonDown (HWND32 hwnd, WPARAM32 wParam, LPARAM lParam)
{
PostMessage32A (GetParent32 (hwnd), WM_NCLBUTTONDOWN,
wParam, lParam);
return 0;
}
static LRESULT
SW_NcLButtonUp (HWND32 hwnd, WPARAM32 wParam, LPARAM lParam)
{
PostMessage32A (GetParent32 (hwnd), WM_NCLBUTTONUP,
wParam, lParam);
return 0;
}
static LRESULT
SW_Paint(STATUSWINDOWINFO *self, HWND32 hwnd)
{
HDC32 hdc;
PAINTSTRUCT32 ps;
hdc = BeginPaint32(hwnd, &ps);
SW_Refresh(hwnd, hdc, self);
EndPaint32(hwnd, &ps);
return 0;
}
static LRESULT
SW_WMSetFont (STATUSWINDOWINFO *self, HWND32 hwnd, WPARAM32 wParam, LPARAM lParam)
{
HDC32 hdc;
self->hFont = (HFONT32)wParam;
if (LOWORD(lParam) == TRUE) {
hdc = GetDC32(hwnd);
SW_Refresh(hwnd, hdc, self);
ReleaseDC32(hwnd, hdc);
}
return 0;
}
static LRESULT
SW_WMSetText (STATUSWINDOWINFO *self, HWND32 hwnd, WPARAM32 wParam, LPARAM lParam)
{
int len;
STATUSWINDOWPART *part;
if (self->numParts == 0) return FALSE;
part = &self->parts[0];
/* duplicate string */
if (part->text)
HeapFree(SystemHeap, 0, part->text);
part->text = 0;
if (lParam && (len = lstrlen32A((LPCSTR)lParam))) {
part->text = HeapAlloc (SystemHeap, 0, len+1);
lstrcpy32A (part->text, (LPCSTR)lParam);
}
InvalidateRect32(hwnd, &part->bound, FALSE);
// SW_RefreshPart (hdc, part);
return TRUE;
}
static LRESULT
SW_Size(STATUSWINDOWINFO *self, HWND32 hwnd, WPARAM32 wParam, LPARAM lParam)
{
/* Need to resize width to match parent */
INT32 width, x, y;
RECT32 parent_rect;
HWND32 parent;
INT32 flags;
flags = (INT32) wParam;
/* FIXME for flags =
* SIZE_MAXIMIZED, SIZE_MAXSHOW, SIZE_MINIMIZED, SIZE_RESTORED
*/
if (flags == SIZE_RESTORED) {
/* width and height don't apply */
parent = GetParent32(hwnd);
GetClientRect32(parent, &parent_rect);
width = parent_rect.right - parent_rect.left;
x = parent_rect.left;
y = parent_rect.bottom - self->height;
MoveWindow32(hwnd, parent_rect.left, parent_rect.bottom - self->height,
width, self->height, TRUE);
SW_SetPartBounds(hwnd, self);
}
return 0;
}
static LRESULT
SW_SendNotify (HWND32 hwnd, UINT32 code)
{
WND *wndPtr;
NMHDR nmhdr;
wndPtr = WIN_FindWndPtr(hwnd);
nmhdr.hwndFrom = hwnd;
nmhdr.idFrom = wndPtr->wIDmenu;
nmhdr.code = code;
SendMessage32A (GetParent32 (hwnd), WM_NOTIFY, 0, (LPARAM)&nmhdr);
return 0;
}
LRESULT WINAPI
StatusWindowProc (HWND32 hwnd, UINT32 msg, WPARAM32 wParam, LPARAM lParam)
{
STATUSWINDOWINFO *self;
WND *wndPtr;
wndPtr = WIN_FindWndPtr(hwnd);
self = GetStatusInfo(hwnd);
switch (msg) {
case SB_GETBORDERS:
return SW_GetBorders(self, hwnd, wParam, lParam);
case SB_GETICON:
return SW_GetIcon(self, hwnd, wParam, lParam);
case SB_GETPARTS:
return SW_GetParts(self, hwnd, wParam, lParam);
case SB_GETRECT:
return SW_GetRect(self, hwnd, wParam, lParam);
case SB_GETTEXT32A:
return SW_GetText(self, hwnd, wParam, lParam);
case SB_GETTEXTLENGTH32A:
return SW_GetTextLength(self, hwnd, wParam, lParam);
case SB_ISSIMPLE:
return self->simple;
case SB_SETBKCOLOR:
return SW_SetBkColor(self, hwnd, wParam, lParam);
case SB_SETICON:
return SW_SetIcon(self, hwnd, wParam, lParam);
case SB_SETMINHEIGHT:
return SW_SetMinHeight(self, hwnd, wParam, lParam);
case SB_SETPARTS:
return SW_SetParts(self, hwnd, wParam, lParam);
case SB_SETTEXT32A:
return SW_SetText(self, hwnd, wParam, lParam);
case SB_SIMPLE:
return SW_Simple(self, hwnd, wParam, lParam);
case WM_CREATE:
return SW_Create(hwnd, wParam, lParam);
case WM_DESTROY:
return SW_Destroy(self, hwnd, wParam, lParam);
case WM_GETFONT:
return self->hFont;
case WM_GETTEXT:
return SW_WMGetText(self, hwnd, wParam, lParam);
case WM_GETTEXTLENGTH:
return SW_WMGetTextLength(self, hwnd, wParam, lParam);
case WM_LBUTTONDBLCLK:
return SW_SendNotify (hwnd, NM_DBLCLK);
case WM_LBUTTONUP:
return SW_SendNotify (hwnd, NM_CLICK);
case WM_NCHITTEST:
return SW_NcHitTest (wndPtr, wParam, lParam);
case WM_NCLBUTTONDOWN:
return SW_NcLButtonDown (hwnd, wParam, lParam);
case WM_NCLBUTTONUP:
return SW_NcLButtonUp (hwnd, wParam, lParam);
case WM_PAINT:
return SW_Paint(self, hwnd);
case WM_RBUTTONDBLCLK:
return SW_SendNotify (hwnd, NM_RDBLCLK);
case WM_RBUTTONUP:
return SW_SendNotify (hwnd, NM_RCLICK);
case WM_SETFONT:
return SW_WMSetFont(self, hwnd, wParam, lParam);
case WM_SETTEXT:
return SW_WMSetText(self, hwnd, wParam, lParam);
case WM_SIZE:
return SW_Size(self, hwnd, wParam, lParam);
default:
return DefWindowProc32A (hwnd, msg, wParam, lParam);
}
return 0;
}
/***********************************************************************
* STATUS_Register [Internal]
*
* Registers the status window class.
*/
void STATUS_Register (void)
{
WNDCLASS32A wndClass;
if (GlobalFindAtom32A (STATUSCLASSNAME32A)) return;
ZeroMemory (&wndClass, sizeof(WNDCLASS32A));
wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS | CS_VREDRAW;
wndClass.lpfnWndProc = (WNDPROC32)StatusWindowProc;
wndClass.cbClsExtra = 0;
wndClass.cbWndExtra = sizeof(STATUSWINDOWINFO *);
wndClass.hCursor = LoadCursor32A (0, IDC_ARROW32A);
wndClass.hbrBackground = (HBRUSH32)(COLOR_3DFACE + 1);
wndClass.lpszClassName = STATUSCLASSNAME32A;
RegisterClass32A (&wndClass);
}