Release 980628
Sun Jun 28 18:37:02 1998 Alexandre Julliard <julliard@lrc.epfl.ch>
* [if1632/signal.c] [miscemu/instr.c] [memory/virtual.c]
Moved page-fault handling to INSTR_EmulateInstruction.
* [scheduler/thread.c]
Added locking and check for own thread in Suspend/ResumeThread.
Sat Jun 27 21:25:21 1998 Ulrich Weigand <weigand@informatik.uni-erlangen.de>
* [objects/dib.c] [objects/bitmap.c] [objects/oembitmap.c]
[graphics/x11drv/bitblt.c] [include/bitmap.h]
Improved DIB section handling using page fault handlers.
(Note: This patch includes code contributed by Matthew J. Francis.)
* [memory/virtual.c] [if1632/signal.c] [include/global.h]
Page Fault handler support added.
* [if1632/signal.c] [loader/signal.c] [tools/build.c] [misc/system.c]
[misc/winsock_dns.c] [include/sig_context.h] [include/thread.h]
16-bit %fs handling improved: Always preserve 16-bit %fs value,
always restore 32-bit %fs value for signal handlers.
* [if1632/thunk.c] [loader/module.c] [misc/callback.c] [windows/user.c]
[loader/ne/resource.c] [include/callback.h] [include/module.h]
[if1632/kernel.spec] [if1632/wprocs.spec]
Resource Handler function pointer stored as 16-bit SEGPTR.
* [loader/task.c] [windows/win.c] [windows/winpos.c] [if1632/user.spec]
[if1632/kernel.spec] [loader/ne/module.c]
Some minor incompatibilities fixed (Win32s relies on those):
GetExePtr, IsWindow16 should set ES on return; WINPOS_SendNCCalcSize
should cope with having the WINDOWPOS structure trashed;
the OFSTRUCT in the NE module image should be placed *last*.
* [include/windows.h]
Missing prototype for FlushViewOfFile.
* [loader/task.c]
Bugfix: Command line should *not* start with a blank.
* [loader/ne/segment.c]
Bugfix: Fixups to offset 0 were never applied.
* [misc/lstr.c]
Use debugstr_a in OutputDebugString16.
* [msdos/dpmi.c]
Stub for int 31 BL=2f AX=7a20 (NetWare: Get VLM Call Address) added.
* [msdos/int21.c]
Stub for int 21 AX=440d CL=6f (get drive map information) added.
Fri Jun 26 18:08:30 1998 Rein Klazes <rklazes@casema.net>
* [windows/winpos.c]
Fix small buglet that mixed up maximized and minimized windows.
* [include/x11drv.h] [objects/dc.c] [graphics/x11drv/pen.c]
[graphics/x11drv/graphics.c]
Fix some bugs with lines joining styles. Draws rectangles
with thick pens now correctly.
Fri Jun 26 16:22:23 1998 James Juran <jrj120@psu.edu>
* [misc/shell.c]
Fixed bug I introduced last release in InternalExtractIcon.
* [win32/file.c]
Added documentation for CreateFile32A.
* [documentation/wine.man]
Updated manpage.
* [ChangeLog]
Added my entry from last release.
Fri Jun 26 13:33:30 1998 Huw D M Davies <daviesh@abacus.physics.ox.ac.uk>
* [graphics/psdrv/*] [if1632/wineps.spec] [include/psdrv.h]
[include/print.h] [objects/gdiobj.c]
First stages of an internal Postscript driver. See
graphics/psdrv/README . Should print text (badly) from win3.1 notepad,
write and winword6.
* [documentation/printing]
Some notes on printing.
* [controls/edit.c]
Strip off WS_BORDER in WM_NCREATE, edit draws its own rectangle.
EC_USEFONTINFO seems to be used as a left/right value for EM_SETMARGINS
and not as an action as the docs say. This actually makes more sense.
Scroll the caret back to zero after a WM_SETTEXT.
Fri Jun 26 10:56:25 1998 Marcus Meissner <marcus@jet.franken.de>
* [if1632/snoop.c]
Added win16 inter-dll snooping.
* [win32/ordinals.c]
KERNEL_485 is GetProcessDword.
* [include/xmalloc.h][include/bitmap.h][misc/xmalloc.c]
Added xcalloc so we 0 initialize XImages.
Fixes/Hides the 'junk around MOPYFish'.
* [misc/ntdll.c]
Some stubs added.
Thu Jun 25 15:22:43 1998 Adrian Harvey <adrian@select.com.au>
* [scheduler/thread.c]
Implemented SuspendThread and ResumeThread.
Thu Jun 25 00:55:03 1998 Peter Hunnisett <hunnise@nortel.ca>
* [include/debug.h,dplay.h,dsound.h][multimedia/dsound.c,dplay.c]
[relay32/dplayx.spec,dplay.spec][multimedia/Makefile.in]
[documentation/status/directplay]
Added preliminary support for DirectPlay & DirectPlayLobby. Moved the
preliminary stubs put in the dsound files into two new files
dplay.h and dplay.c.
Added new debug channel (dplay) for this.
Created new document to keep track of implementation.
* [include/winioctl.h][win32/device.c]
Added some framework in DeviceIoControl to, in the future, support
the "builtin" windows dwIoControlCodes. Added new header file
winioctl.h .
* [multimedia/mmsystem.c]
Added slightly improved debugging information for PlaySound.
Wed Jun 24 12:00:00 1998 Juergen Schmied <juergen.schmied@metronet.de>
* [files/profile.c][graphics/x11drv/xfont.c][loader/module.c]
Changed lstrcmpi32A to strcasecmp, lstrncmpi32A to strncasecmp,
lstrcpy32A to strcpy, lstrlen32A to strlen, lstrcmp32A to strcmp
because it's not necessary to support locale on such places.
It causes a huge overhead and even fails sometimes
* [include/oleauto.h][include/winerror.h]
Added some ole-related constants.
* [misc/shell.c]
SHELL32_DllGetClassObject, SHGetSpecialFolderLocation,
SHGetPathFromIDList improved the stubs
* [ole/folders.c]
IShellFolder* functions rewrote the stubs so don't crash and give
something sensible back, started implementation of.
* [ole/typelib.c][relay32/oleaut32.spec]
LoadTypeLib32, RegisterTypeLib stub.
* [ole/ole2nls.c]
Fixed a buffer overrun in CompareString32A.
Test for a bad pointer in LCMapString32A (happens
in winhlp32 while building a index for searching).
* [relay32/oleaut32.spec] [ole/typelib.c]
Added stub for LoadTypeLib (ole32) to make excel95 happy.
Tue Jun 23 22:47:09 1998 Alex Priem <alexp@sci.kun.nl>
* [files/profile.c] [relay32/kernel32.spec]
Added WritePrivateProfileStructA, GetPrivateProfileStructA,
GetPrivateProfileSectionNames16.
Tue Jun 23 01:34:43 1998 Pascal Cuoq <pcuoq@ens-lyon.fr>
* [ole/ole2nls.c]
GetStringTypeEx32A: Implemented CT_CTYPE2 and CT_CTYPE3 cases.
LCMapString32A: Map final '\0' for '\0'-terminated strings.
* [misc/shellord.c] [files/profile.c] [graphics/driver.c]
[loader/module.c] [msdos/int21.c] [windows/driver.c] [files/drive.c]
Changed lstrcmpi32A -> strcasecmp. Should be OK in these places.
Sat Jun 20 23:40:00 1998 Bertho Stultiens <bertho@akhphd.au.dk>
* [tools/wrc/]
Wrc version 1.0.2 (20-Jun-1998). Please revert to
the file tools/wrc/CHANGES for details.
Sat Jun 20 14:58:00 1998 Marcel Baur <mbaur@g26.ethz.ch>
* [ole/ole2nls.c] [ole/nls/*]
Added the first 57 nls files, most are not yet complete.
Wed Jun 17 11:16:54 1998 David Luyer <luyer@ucs.uwa.edu.au>
* [relay32/relay386.c] [if1632/relay.c]
Move debug_relay_(include|exclude)_list handling into
seperate function RELAY_ShowDebugmsgsRelay(). Include
checking of this for 16 bit calls (originally only
32-bit calls).
* [relay32/snoop.c] [misc/main.c]
Add debug_snoop_(include|exclude)_list as per the relay stuff.
Fix typo and add information on -debugmsg +/-relay=... in
help on -debugmsg. Refer to availability of snoop too.
Tue Jun 10 22:00:18 1998 Eric Kohl <ekohl@abo.rhein-zeitung.de>
* [controls/header.c][include/header.h][include/commctrl.h]
Added owner draw support.
* [windows/nonclient.c][windows/sysmetics.c]
Fixed menu bar height for Win95 look.
Split NC_AdjustRect95() into NC_AdjustRectOuter95() and
NC_AdjustRectInner95 to fix a menu bar bug.
Improved Win95 look.
* [controls/progress.c]
Improved drawing code. Borders will be drawn by non-client code.
* [controls/updown.c]
Changed memory allocation and fixed some bugs.
* [controls/toolbar.c]
Fixed TB_BUTTONSTRUCTSIZE bug in MFC programs.
Several improvements.
* [misc/shell.c]
Added stub for BrowseForFoldersA().
* [misc/shellord.c]
Added stub for SHELL32_147().
* [controls/comctl32undoc.c]
Minor changes.
* [documentation/common_controls]
New File: Documentation about development status, undocumented
features and functions of the common controls.
diff --git a/controls/comctl32undoc.c b/controls/comctl32undoc.c
index 2719e3b..88b57d5 100644
--- a/controls/comctl32undoc.c
+++ b/controls/comctl32undoc.c
@@ -11,6 +11,7 @@
*
* TODO
* - Fix DSA_InsertItem.
+ * - Fix DSA_GetItem.
* - Write documentation.
*/
@@ -39,10 +40,6 @@
} DPA_DATA, *LPDPA_DATA;
-DWORD WINAPI Alloc (DWORD);
-DWORD WINAPI ReAlloc (DWORD, DWORD);
-DWORD WINAPI Free (DWORD);
-
DWORD WINAPI DSA_Create (DWORD, DWORD);
@@ -51,31 +48,32 @@
DWORD WINAPI DPA_InsertPtr (DWORD, DWORD, DWORD);
-LPSTR WINAPI COMCTL32_StrChrA (LPSTR lpString, CHAR cChar);
+
DWORD WINAPI
-Alloc (DWORD dwParam1)
+COMCTL32_Alloc (DWORD dwParam)
{
DWORD dwPtr;
- dwPtr = (DWORD)HeapAlloc (SystemHeap, HEAP_ZERO_MEMORY, dwParam1);
+ dwPtr = (DWORD)HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, dwParam);
- TRACE (commctrl, "(0x%08lx) ret=0x%08lx\n", dwParam1, dwPtr);
+ TRACE (commctrl, "(0x%08lx) ret=0x%08lx\n", dwParam, dwPtr);
return dwPtr;
}
DWORD WINAPI
-ReAlloc (DWORD dwParam1, DWORD dwParam2)
+COMCTL32_ReAlloc (DWORD dwParam1, DWORD dwParam2)
{
DWORD dwPtr;
if (dwParam1 == 0)
- dwPtr = (DWORD)HeapAlloc (SystemHeap, HEAP_ZERO_MEMORY, dwParam2);
+ dwPtr = (DWORD)HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY,
+ dwParam2);
else
- dwPtr = (DWORD)HeapReAlloc (SystemHeap, HEAP_ZERO_MEMORY,
+ dwPtr = (DWORD)HeapReAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY,
(LPVOID)dwParam1, dwParam2);
TRACE (commctrl, "(0x%08lx 0x%08lx) ret=0x%08lx\n",
@@ -86,15 +84,21 @@
DWORD WINAPI
-Free (DWORD dwParam1)
+COMCTL32_Free (DWORD dwParam)
{
- TRACE (commctrl, "(0x%08lx)\n", dwParam1);
- HeapFree (SystemHeap, 0, (LPVOID)dwParam1);
+ TRACE (commctrl, "(0x%08lx)\n", dwParam);
+ HeapFree (GetProcessHeap (), 0, (LPVOID)dwParam);
return 0;
}
+DWORD WINAPI
+COMCTL32_GetSize (DWORD dwParam)
+{
+ TRACE (commctrl, "(0x%08lx)\n", dwParam);
+ return (HeapSize (GetProcessHeap (), 0, (LPVOID)dwParam));
+}
@@ -136,6 +140,36 @@
DWORD WINAPI
+DSA_GetItem (DWORD dwParam1, DWORD dwParam2, DWORD dwParam3)
+{
+ FIXME (commctrl, "(0x%08lx 0x%08lx 0x%08lx): stub!\n",
+ dwParam1, dwParam2, dwParam3);
+
+ return 0;
+}
+
+
+DWORD WINAPI
+DSA_GetItemPtr (DWORD dwParam1, DWORD dwParam2)
+{
+ LPDSA_DATA dsaPtr = (LPDSA_DATA)dwParam1;
+
+ TRACE (commctrl, "(0x%08lx 0x%08lx)\n", dwParam1, dwParam2);
+
+ if (dsaPtr == NULL)
+ return 0;
+ if (dsaPtr->ptrs == NULL)
+ return 0;
+ if ((dwParam2 < 0) || (dwParam2 >= dsaPtr->dwEntryCount))
+ return 0;
+
+ TRACE (commctrl, "ret=0x%08lx\n", (DWORD)dsaPtr->ptrs[dwParam2]);
+
+ return (DWORD)dsaPtr->ptrs[dwParam2];
+}
+
+
+DWORD WINAPI
DSA_InsertItem (DWORD dwParam1, DWORD dwParam2, DWORD dwParam3)
{
LPDSA_DATA dsaPtr = (LPDSA_DATA)dwParam1;
@@ -188,24 +222,6 @@
}
-DWORD WINAPI
-DSA_GetItemPtr (DWORD dwParam1, DWORD dwParam2)
-{
- LPDSA_DATA dsaPtr = (LPDSA_DATA)dwParam1;
-
- TRACE (commctrl, "(0x%08lx 0x%08lx)\n", dwParam1, dwParam2);
-
- if (dsaPtr == NULL)
- return 0;
- if (dsaPtr->ptrs == NULL)
- return 0;
- if ((dwParam2 < 0) || (dwParam2 >= dsaPtr->dwEntryCount))
- return 0;
-
- TRACE (commctrl, "ret=0x%08lx\n", (DWORD)dsaPtr->ptrs[dwParam2]);
-
- return (DWORD)dsaPtr->ptrs[dwParam2];
-}
DWORD WINAPI
diff --git a/controls/commctrl.c b/controls/commctrl.c
index 22ef4c4..8dddf5b 100644
--- a/controls/commctrl.c
+++ b/controls/commctrl.c
@@ -218,7 +218,7 @@
/***********************************************************************
- * MenuHelp (COMCTL32.2)
+ * MenuHelp [COMCTL32.2]
*
*
*
@@ -234,7 +234,7 @@
if (!IsWindow32 (hwndStatus)) return;
switch (uMsg) {
- case WM_MENUSELECT:
+ case WM_MENUSELECT:
TRACE (commctrl, "WM_MENUSELECT wParam=0x%X lParam=0x%lX\n",
wParam, lParam);
@@ -245,7 +245,6 @@
else {
if (HIWORD(wParam) & MF_POPUP) {
TRACE (commctrl, "popup menu selected!\n");
- FIXME (commctrl, "no popup menu texts!\n");
szStatusText[0] = 0;
}
@@ -281,8 +280,8 @@
INT32 dxBitmap, INT32 dyBitmap, UINT32 uStructSize)
{
HWND32 hwndTB =
- CreateWindowEx32A(0, TOOLBARCLASSNAME32A, "", style, 0, 0, 0, 0,
- hwnd, (HMENU32)wID, 0, NULL);
+ CreateWindowEx32A (0, TOOLBARCLASSNAME32A, "", style, 0, 0, 0, 0,
+ hwnd, (HMENU32)wID, 0, NULL);
if(hwndTB) {
TBADDBITMAP tbab;
@@ -348,35 +347,39 @@
/***********************************************************************
* GetEffectiveClientRect [COMCTL32.4]
*
+ * PARAMS
+ * hwnd [I] handle to the client window.
+ * lpRect [O] pointer to the rectangle of the client window
+ * lpInfo [I] pointer to an array of integers
*
- *
+ * NOTES
*/
VOID WINAPI
GetEffectiveClientRect (HWND32 hwnd, LPRECT32 lpRect, LPINT32 lpInfo)
{
- RECT32 rcClient, rcCtrl;
- HWND32 hwndCtrl;
- LPINT32 lpRun;
+ RECT32 rcClient, rcCtrl;
+ INT32 idCtrl, *lpRun;
TRACE (commctrl, "hwnd=0x%08lx lpRect=0x%08lx lpInfo=0x%08lx\n",
(DWORD)hwnd, (DWORD)lpRect, (DWORD)lpInfo);
GetClientRect32 (hwnd, &rcClient);
-
+#if 0
lpRun = lpInfo;
- TRACE (commctrl, "*lpRun=0x%08x\n", *lpRun);
- while (*lpRun) {
- lpRun++;
- TRACE (commctrl, "control id 0x%08x\n", *lpRun);
- hwndCtrl = GetDlgItem32 (hwnd, *lpRun);
- GetWindowRect32 (hwndCtrl, &rcCtrl);
- MapWindowPoints32 (NULL, hwnd, (LPPOINT32)&rcCtrl, 2);
- SubtractRect32 (&rcClient, &rcClient, &rcCtrl);
- lpRun++;
- TRACE (commctrl, "*lpRun=0x%08x\n", *lpRun);
- }
+ do {
+ lpRun += 3;
+ idCtrl = *lpRun;
+ if (idCtrl) {
+ TRACE (commctrl, "control id 0x%x\n", idCtrl);
+ GetWindowRect32 (GetDlgItem32 (hwnd, idCtrl), &rcCtrl);
+ MapWindowPoints32 (NULL, hwnd, (LPPOINT32)&rcCtrl, 2);
+ SubtractRect32 (&rcClient, &rcClient, &rcCtrl);
+ lpRun++;
+ }
+ } while (idCtrl);
+#endif
CopyRect32 (lpRect, &rcClient);
}
diff --git a/controls/edit.c b/controls/edit.c
index d8407bc..acfef57 100644
--- a/controls/edit.c
+++ b/controls/edit.c
@@ -19,6 +19,7 @@
#include "resource.h"
#include "debug.h"
#include "callback.h"
+#include "tweak.h"
#define BUFLIMIT_MULTI 65534 /* maximum buffer size (not including '\0')
FIXME: BTW, new specs say 65535 (do you dare ???) */
@@ -177,6 +178,7 @@
static void EDIT_MoveWordForward(WND *wnd, EDITSTATE *es, BOOL32 extend);
static void EDIT_PaintLine(WND *wnd, EDITSTATE *es, HDC32 hdc, INT32 line, BOOL32 rev);
static INT32 EDIT_PaintText(WND *wnd, EDITSTATE *es, HDC32 hdc, INT32 x, INT32 y, INT32 line, INT32 col, INT32 count, BOOL32 rev);
+static void EDIT_SetCaretPos(WND *wnd, EDITSTATE *es, INT32 pos, BOOL32 after_wrap);
static void EDIT_SetRectNP(WND *wnd, EDITSTATE *es, LPRECT32 lprc);
static void EDIT_UnlockBuffer(WND *wnd, EDITSTATE *es, BOOL32 force);
static INT32 EDIT_WordBreakProc(LPSTR s, INT32 index, INT32 count, INT32 action);
@@ -216,7 +218,7 @@
static void EDIT_WM_Command(WND *wnd, EDITSTATE *es, INT32 code, INT32 id, HWND32 conrtol);
static void EDIT_WM_ContextMenu(WND *wnd, EDITSTATE *es, HWND32 hwnd, INT32 x, INT32 y);
static void EDIT_WM_Copy(WND *wnd, EDITSTATE *es);
-static LRESULT EDIT_WM_Create(WND *wnd, LPCREATESTRUCT32A cs);
+static LRESULT EDIT_WM_Create(WND *wnd, EDITSTATE *es, LPCREATESTRUCT32A cs);
static void EDIT_WM_Destroy(WND *wnd, EDITSTATE *es);
static LRESULT EDIT_WM_EraseBkGnd(WND *wnd, EDITSTATE *es, HDC32 dc);
static INT32 EDIT_WM_GetText(WND *wnd, EDITSTATE *es, INT32 count, LPSTR text);
@@ -227,6 +229,7 @@
static LRESULT EDIT_WM_LButtonDown(WND *wnd, EDITSTATE *es, DWORD keys, INT32 x, INT32 y);
static LRESULT EDIT_WM_LButtonUp(WND *wnd, EDITSTATE *es, DWORD keys, INT32 x, INT32 y);
static LRESULT EDIT_WM_MouseMove(WND *wnd, EDITSTATE *es, DWORD keys, INT32 x, INT32 y);
+static LRESULT EDIT_WM_NCCreate(WND *wnd, LPCREATESTRUCT32A cs);
static void EDIT_WM_Paint(WND *wnd, EDITSTATE *es);
static void EDIT_WM_Paste(WND *wnd, EDITSTATE *es);
static void EDIT_WM_SetFocus(WND *wnd, EDITSTATE *es, HWND32 window_losing_focus);
@@ -305,14 +308,14 @@
LRESULT result = 0;
switch (msg) {
- case WM_CREATE:
- DPRINTF_EDIT_MSG32("WM_CREATE");
- return EDIT_WM_Create(wnd, (LPCREATESTRUCT32A)lParam);
-
case WM_DESTROY:
DPRINTF_EDIT_MSG32("WM_DESTROY");
EDIT_WM_Destroy(wnd, es);
return 0;
+
+ case WM_NCCREATE:
+ DPRINTF_EDIT_MSG32("WM_NCCREATE");
+ return EDIT_WM_NCCreate(wnd, (LPCREATESTRUCT32A)lParam);
}
if (!es)
@@ -718,6 +721,11 @@
EDIT_WM_Copy(wnd, es);
break;
+ case WM_CREATE:
+ DPRINTF_EDIT_MSG32("WM_CREATE");
+ result = EDIT_WM_Create(wnd, es, (LPCREATESTRUCT32A)lParam);
+ break;
+
case WM_CUT:
DPRINTF_EDIT_MSG32("WM_CUT");
EDIT_WM_Cut(wnd, es);
@@ -1721,67 +1729,26 @@
/*********************************************************************
*
- * EM_SCROLLCARET
+ * EDIT_SetCaretPos
*
*/
-static void EDIT_EM_ScrollCaret(WND *wnd, EDITSTATE *es)
+static void EDIT_SetCaretPos(WND *wnd, EDITSTATE *es, INT32 pos,
+ BOOL32 after_wrap)
{
- if (es->style & ES_MULTILINE) {
- INT32 l;
- INT32 li;
- INT32 vlc;
- INT32 ww;
- INT32 cw = es->char_width;
- INT32 x;
- INT32 dy = 0;
- INT32 dx = 0;
+ LRESULT res = EDIT_EM_PosFromChar(wnd, es, pos, after_wrap);
+ INT32 x = SLOWORD(res);
+ INT32 y = SHIWORD(res);
- l = EDIT_EM_LineFromChar(wnd, es, es->selection_end);
- li = EDIT_EM_LineIndex(wnd, es, l);
- x = SLOWORD(EDIT_EM_PosFromChar(wnd, es, es->selection_end, es->flags & EF_AFTER_WRAP));
- vlc = (es->format_rect.bottom - es->format_rect.top) / es->line_height;
- if (l >= es->y_offset + vlc)
- dy = l - vlc + 1 - es->y_offset;
- if (l < es->y_offset)
- dy = l - es->y_offset;
- ww = es->format_rect.right - es->format_rect.left;
- if (x < es->format_rect.left)
- dx = x - es->format_rect.left - ww / HSCROLL_FRACTION / cw * cw;
- if (x > es->format_rect.right)
- dx = x - es->format_rect.left - (HSCROLL_FRACTION - 1) * ww / HSCROLL_FRACTION / cw * cw;
- if (dy || dx)
- EDIT_EM_LineScroll(wnd, es, dx, dy);
- } else {
- INT32 x;
- INT32 goal;
- INT32 format_width;
-
- if (!(es->style & ES_AUTOHSCROLL))
- return;
-
- x = SLOWORD(EDIT_EM_PosFromChar(wnd, es, es->selection_end, FALSE));
- format_width = es->format_rect.right - es->format_rect.left;
- if (x < es->format_rect.left) {
- goal = es->format_rect.left + format_width / HSCROLL_FRACTION;
- do {
- es->x_offset--;
- x = SLOWORD(EDIT_EM_PosFromChar(wnd, es, es->selection_end, FALSE));
- } while ((x < goal) && es->x_offset);
- /* FIXME: use ScrollWindow() somehow to improve performance */
- InvalidateRect32(wnd->hwndSelf, NULL, TRUE);
- } else if (x > es->format_rect.right) {
- INT32 x_last;
- INT32 len = lstrlen32A(es->text);
- goal = es->format_rect.right - format_width / HSCROLL_FRACTION;
- do {
- es->x_offset++;
- x = SLOWORD(EDIT_EM_PosFromChar(wnd, es, es->selection_end, FALSE));
- x_last = SLOWORD(EDIT_EM_PosFromChar(wnd, es, len, FALSE));
- } while ((x > goal) && (x_last > es->format_rect.right));
- /* FIXME: use ScrollWindow() somehow to improve performance */
- InvalidateRect32(wnd->hwndSelf, NULL, TRUE);
- }
- }
+ if(x < es->format_rect.left)
+ x = es->format_rect.left;
+ if(x > es->format_rect.right - 2)
+ x = es->format_rect.right - 2;
+ if(y > es->format_rect.bottom)
+ y = es->format_rect.bottom;
+ if(y < es->format_rect.top)
+ y = es->format_rect.top;
+ SetCaretPos32(x, y);
+ return;
}
@@ -1798,6 +1765,8 @@
CopyRect32(&es->format_rect, rc);
if (es->style & WS_BORDER) {
INT32 bw = GetSystemMetrics32(SM_CXBORDER) + 1;
+ if(!TWEAK_Win95Look)
+ bw += 2;
es->format_rect.left += bw;
es->format_rect.top += bw;
es->format_rect.right -= bw;
@@ -2496,6 +2465,72 @@
/*********************************************************************
*
+ * EM_SCROLLCARET
+ *
+ */
+static void EDIT_EM_ScrollCaret(WND *wnd, EDITSTATE *es)
+{
+ if (es->style & ES_MULTILINE) {
+ INT32 l;
+ INT32 li;
+ INT32 vlc;
+ INT32 ww;
+ INT32 cw = es->char_width;
+ INT32 x;
+ INT32 dy = 0;
+ INT32 dx = 0;
+
+ l = EDIT_EM_LineFromChar(wnd, es, es->selection_end);
+ li = EDIT_EM_LineIndex(wnd, es, l);
+ x = SLOWORD(EDIT_EM_PosFromChar(wnd, es, es->selection_end, es->flags & EF_AFTER_WRAP));
+ vlc = (es->format_rect.bottom - es->format_rect.top) / es->line_height;
+ if (l >= es->y_offset + vlc)
+ dy = l - vlc + 1 - es->y_offset;
+ if (l < es->y_offset)
+ dy = l - es->y_offset;
+ ww = es->format_rect.right - es->format_rect.left;
+ if (x < es->format_rect.left)
+ dx = x - es->format_rect.left - ww / HSCROLL_FRACTION / cw * cw;
+ if (x > es->format_rect.right)
+ dx = x - es->format_rect.left - (HSCROLL_FRACTION - 1) * ww / HSCROLL_FRACTION / cw * cw;
+ if (dy || dx)
+ EDIT_EM_LineScroll(wnd, es, dx, dy);
+ } else {
+ INT32 x;
+ INT32 goal;
+ INT32 format_width;
+
+ if (!(es->style & ES_AUTOHSCROLL))
+ return;
+
+ x = SLOWORD(EDIT_EM_PosFromChar(wnd, es, es->selection_end, FALSE));
+ format_width = es->format_rect.right - es->format_rect.left;
+ if (x < es->format_rect.left) {
+ goal = es->format_rect.left + format_width / HSCROLL_FRACTION;
+ do {
+ es->x_offset--;
+ x = SLOWORD(EDIT_EM_PosFromChar(wnd, es, es->selection_end, FALSE));
+ } while ((x < goal) && es->x_offset);
+ /* FIXME: use ScrollWindow() somehow to improve performance */
+ InvalidateRect32(wnd->hwndSelf, NULL, TRUE);
+ } else if (x > es->format_rect.right) {
+ INT32 x_last;
+ INT32 len = lstrlen32A(es->text);
+ goal = es->format_rect.right - format_width / HSCROLL_FRACTION;
+ do {
+ es->x_offset++;
+ x = SLOWORD(EDIT_EM_PosFromChar(wnd, es, es->selection_end, FALSE));
+ x_last = SLOWORD(EDIT_EM_PosFromChar(wnd, es, len, FALSE));
+ } while ((x > goal) && (x_last > es->format_rect.right));
+ /* FIXME: use ScrollWindow() somehow to improve performance */
+ InvalidateRect32(wnd->hwndSelf, NULL, TRUE);
+ }
+ }
+}
+
+
+/*********************************************************************
+ *
* EM_SETHANDLE
*
* FIXME: ES_LOWERCASE, ES_UPPERCASE, ES_OEMCONVERT, ES_NUMBER ???
@@ -2607,24 +2642,33 @@
/*********************************************************************
*
* EM_SETMARGINS
+ *
+ * EC_USEFONTINFO is used as a left or right value i.e. lParam and not as an
+ * action wParam despite what the docs say. It also appears not to affect
+ * multiline controls??
*
*/
-static void EDIT_EM_SetMargins(WND *wnd, EDITSTATE *es, INT32 action, INT32 left, INT32 right)
+static void EDIT_EM_SetMargins(WND *wnd, EDITSTATE *es, INT32 action,
+ INT32 left, INT32 right)
{
- if (action & EC_USEFONTINFO) {
- if (es->style & ES_MULTILINE) {
- /*
- * FIXME: do some GetABCCharWidth, or so
- * This is just preliminary
- */
- es->left_margin = es->right_margin = es->char_width/4;
- } else
- es->left_margin = es->right_margin = es->char_width/4;
- } else {
- if (action & EC_LEFTMARGIN)
+ if (action & EC_LEFTMARGIN) {
+ if (left != EC_USEFONTINFO)
es->left_margin = left;
- if (action & EC_RIGHTMARGIN)
- es->right_margin = right;
+ else
+ if (es->style & ES_MULTILINE)
+ es->left_margin = 0; /* ?? */
+ else
+ es->left_margin = es->char_width;
+ }
+
+ if (action & EC_RIGHTMARGIN) {
+ if (right != EC_USEFONTINFO)
+ es->right_margin = right;
+ else
+ if (es->style & ES_MULTILINE)
+ es->right_margin = 0; /* ?? */
+ else
+ es->right_margin = es->char_width;
}
TRACE(edit, "left=%d, right=%d\n", es->left_margin, es->right_margin);
}
@@ -2683,10 +2727,8 @@
es->flags |= EF_AFTER_WRAP;
else
es->flags &= ~EF_AFTER_WRAP;
- if (es->flags & EF_FOCUSED) {
- LRESULT pos = EDIT_EM_PosFromChar(wnd, es, end, after_wrap);
- SetCaretPos32(SLOWORD(pos), SHIWORD(pos));
- }
+ if (es->flags & EF_FOCUSED)
+ EDIT_SetCaretPos(wnd, es, end, after_wrap);
/* This is little bit more efficient than before, not sure if it can be improved. FIXME? */
ORDER_UINT32(start, end);
ORDER_UINT32(end, old_end);
@@ -2976,70 +3018,8 @@
* WM_CREATE
*
*/
-static LRESULT EDIT_WM_Create(WND *wnd, LPCREATESTRUCT32A cs)
+static LRESULT EDIT_WM_Create(WND *wnd, EDITSTATE *es, LPCREATESTRUCT32A cs)
{
- EDITSTATE *es;
-
- if (!(es = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*es))))
- return -1;
- *(EDITSTATE **)wnd->wExtra = es;
- if (!(es->heap = HeapCreate(0, 0x10000, 0)))
- return -1;
- es->style = cs->style;
-
- /* remove the WS_CAPTION style if it has been set - this is really a */
- /* pseudo option made from a combination of WS_BORDER and WS_DLGFRAME */
- if ((es->style & WS_BORDER) && (es->style & WS_DLGFRAME))
- es->style ^= WS_DLGFRAME;
-
- if (es->style & ES_MULTILINE) {
- es->buffer_size = BUFSTART_MULTI;
- es->buffer_limit = BUFLIMIT_MULTI;
- if (es->style & WS_VSCROLL)
- es->style |= ES_AUTOVSCROLL;
- if (es->style & WS_HSCROLL)
- es->style |= ES_AUTOHSCROLL;
- es->style &= ~ES_PASSWORD;
- if ((es->style & ES_CENTER) || (es->style & ES_RIGHT)) {
- if (es->style & ES_RIGHT)
- es->style &= ~ES_CENTER;
- es->style &= ~WS_HSCROLL;
- es->style &= ~ES_AUTOHSCROLL;
- }
-
- /* FIXME: for now, all multi line controls are AUTOVSCROLL */
- es->style |= ES_AUTOVSCROLL;
- } else {
- es->buffer_size = BUFSTART_SINGLE;
- es->buffer_limit = BUFLIMIT_SINGLE;
- es->style &= ~ES_CENTER;
- es->style &= ~ES_RIGHT;
- es->style &= ~WS_HSCROLL;
- es->style &= ~WS_VSCROLL;
- es->style &= ~ES_AUTOVSCROLL;
- es->style &= ~ES_WANTRETURN;
- if (es->style & ES_UPPERCASE) {
- es->style &= ~ES_LOWERCASE;
- es->style &= ~ES_NUMBER;
- } else if (es->style & ES_LOWERCASE)
- es->style &= ~ES_NUMBER;
- if (es->style & ES_PASSWORD)
- es->password_char = '*';
-
- /* FIXME: for now, all single line controls are AUTOHSCROLL */
- es->style |= ES_AUTOHSCROLL;
- }
- if (!(es->text = HeapAlloc(es->heap, 0, es->buffer_size + 1)))
- return -1;
- es->buffer_size = HeapSize(es->heap, 0, es->text) - 1;
- if (!(es->undo_text = HeapAlloc(es->heap, 0, es->buffer_size + 1)))
- return -1;
- es->undo_buffer_size = HeapSize(es->heap, 0, es->undo_text) - 1;
- *es->text = '\0';
- if (es->style & ES_MULTILINE)
- if (!(es->first_line_def = HeapAlloc(es->heap, HEAP_ZERO_MEMORY, sizeof(LINEDEF))))
- return -1;
- es->line_count = 1;
/*
* To initialize some final structure members, we call some helper
* functions. However, since the EDITSTATE is not consistent (i.e.
@@ -3547,6 +3527,78 @@
/*********************************************************************
*
+ * WM_NCCREATE
+ *
+ */
+static LRESULT EDIT_WM_NCCreate(WND *wnd, LPCREATESTRUCT32A cs)
+{
+ EDITSTATE *es;
+
+ if (!(es = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*es))))
+ return FALSE;
+ *(EDITSTATE **)wnd->wExtra = es;
+ if (!(es->heap = HeapCreate(0, 0x10000, 0)))
+ return FALSE;
+ es->style = cs->style;
+
+ if ((es->style & WS_BORDER) && !(es->style & WS_DLGFRAME))
+ SetWindowLong32A(wnd->hwndSelf, GWL_STYLE,
+ es->style & ~WS_BORDER);
+
+ if (es->style & ES_MULTILINE) {
+ es->buffer_size = BUFSTART_MULTI;
+ es->buffer_limit = BUFLIMIT_MULTI;
+ if (es->style & WS_VSCROLL)
+ es->style |= ES_AUTOVSCROLL;
+ if (es->style & WS_HSCROLL)
+ es->style |= ES_AUTOHSCROLL;
+ es->style &= ~ES_PASSWORD;
+ if ((es->style & ES_CENTER) || (es->style & ES_RIGHT)) {
+ if (es->style & ES_RIGHT)
+ es->style &= ~ES_CENTER;
+ es->style &= ~WS_HSCROLL;
+ es->style &= ~ES_AUTOHSCROLL;
+ }
+
+ /* FIXME: for now, all multi line controls are AUTOVSCROLL */
+ es->style |= ES_AUTOVSCROLL;
+ } else {
+ es->buffer_size = BUFSTART_SINGLE;
+ es->buffer_limit = BUFLIMIT_SINGLE;
+ es->style &= ~ES_CENTER;
+ es->style &= ~ES_RIGHT;
+ es->style &= ~WS_HSCROLL;
+ es->style &= ~WS_VSCROLL;
+ es->style &= ~ES_AUTOVSCROLL;
+ es->style &= ~ES_WANTRETURN;
+ if (es->style & ES_UPPERCASE) {
+ es->style &= ~ES_LOWERCASE;
+ es->style &= ~ES_NUMBER;
+ } else if (es->style & ES_LOWERCASE)
+ es->style &= ~ES_NUMBER;
+ if (es->style & ES_PASSWORD)
+ es->password_char = '*';
+
+ /* FIXME: for now, all single line controls are AUTOHSCROLL */
+ es->style |= ES_AUTOHSCROLL;
+ }
+ if (!(es->text = HeapAlloc(es->heap, 0, es->buffer_size + 1)))
+ return FALSE;
+ es->buffer_size = HeapSize(es->heap, 0, es->text) - 1;
+ if (!(es->undo_text = HeapAlloc(es->heap, 0, es->buffer_size + 1)))
+ return FALSE;
+ es->undo_buffer_size = HeapSize(es->heap, 0, es->undo_text) - 1;
+ *es->text = '\0';
+ if (es->style & ES_MULTILINE)
+ if (!(es->first_line_def = HeapAlloc(es->heap, HEAP_ZERO_MEMORY, sizeof(LINEDEF))))
+ return FALSE;
+ es->line_count = 1;
+
+ return TRUE;
+}
+
+/*********************************************************************
+ *
* WM_PAINT
*
*/
@@ -3559,7 +3611,6 @@
RECT32 rc;
RECT32 rcLine;
RECT32 rcRgn;
- LRESULT pos;
BOOL32 rev = IsWindowEnabled32(wnd->hwndSelf) &&
((es->flags & EF_FOCUSED) ||
(es->style & ES_NOHIDESEL));
@@ -3568,6 +3619,14 @@
EDIT_NOTIFY_PARENT(wnd, EN_UPDATE, "EN_UPDATE");
dc = BeginPaint32(wnd->hwndSelf, &ps);
+ if(es->style & WS_BORDER) {
+ GetClientRect32(wnd->hwndSelf, &rc);
+ if(es->style & ES_MULTILINE) {
+ if(es->style & WS_HSCROLL) rc.bottom++;
+ if(es->style & WS_VSCROLL) rc.right++;
+ }
+ Rectangle32(dc, rc.left, rc.top, rc.right, rc.bottom);
+ }
IntersectClipRect32(dc, es->format_rect.left,
es->format_rect.top,
es->format_rect.right,
@@ -3596,10 +3655,9 @@
}
if (es->font)
SelectObject32(dc, old_font);
- if (es->flags & EF_FOCUSED) {
- pos = EDIT_EM_PosFromChar(wnd, es, es->selection_end, es->flags & EF_AFTER_WRAP);
- SetCaretPos32(SLOWORD(pos), SHIWORD(pos));
- }
+ if (es->flags & EF_FOCUSED)
+ EDIT_SetCaretPos(wnd, es, es->selection_end,
+ es->flags & EF_AFTER_WRAP);
EndPaint32(wnd->hwndSelf, &ps);
if ((es->style & WS_VSCROLL) && !(es->flags & EF_VSCROLL_TRACK)) {
INT32 vlc = (es->format_rect.bottom - es->format_rect.top) / es->line_height;
@@ -3661,12 +3719,10 @@
*/
static void EDIT_WM_SetFocus(WND *wnd, EDITSTATE *es, HWND32 window_losing_focus)
{
- LRESULT pos;
-
es->flags |= EF_FOCUSED;
CreateCaret32(wnd->hwndSelf, 0, 2, es->line_height);
- pos = EDIT_EM_PosFromChar(wnd, es, es->selection_end, es->flags & EF_AFTER_WRAP);
- SetCaretPos32(SLOWORD(pos), SHIWORD(pos));
+ EDIT_SetCaretPos(wnd, es, es->selection_end,
+ es->flags & EF_AFTER_WRAP);
if(!(es->style & ES_NOHIDESEL))
EDIT_InvalidateText(wnd, es, es->selection_start, es->selection_end);
ShowCaret32(wnd->hwndSelf);
@@ -3678,6 +3734,10 @@
*
* WM_SETFONT
*
+ * With Win95 look the margins are set to default font value unless
+ * the system font (font == 0) is being set, in which case they are left
+ * unchanged.
+ *
*/
static void EDIT_WM_SetFont(WND *wnd, EDITSTATE *es, HFONT32 font, BOOL32 redraw)
{
@@ -3695,18 +3755,23 @@
if (font)
SelectObject32(dc, old_font);
ReleaseDC32(wnd->hwndSelf, dc);
- if (wnd->flags & WIN_ISWIN32)
- EDIT_EM_SetMargins(wnd, es, EC_USEFONTINFO, 0, 0);
+ if (font & TWEAK_Win95Look)
+ EDIT_EM_SetMargins(wnd, es, EC_LEFTMARGIN | EC_RIGHTMARGIN,
+ EC_USEFONTINFO, EC_USEFONTINFO);
if (es->style & ES_MULTILINE)
EDIT_BuildLineDefs_ML(wnd, es);
+ else {
+ RECT32 r;
+ GetClientRect32(wnd->hwndSelf, &r);
+ EDIT_SetRectNP(wnd, es, &r);
+ }
if (redraw)
InvalidateRect32(wnd->hwndSelf, NULL, TRUE);
if (es->flags & EF_FOCUSED) {
- LRESULT pos;
DestroyCaret32();
CreateCaret32(wnd->hwndSelf, 0, 2, es->line_height);
- pos = EDIT_EM_PosFromChar(wnd, es, es->selection_end, es->flags & EF_AFTER_WRAP);
- SetCaretPos32(SLOWORD(pos), SHIWORD(pos));
+ EDIT_SetCaretPos(wnd, es, es->selection_end,
+ es->flags & EF_AFTER_WRAP);
ShowCaret32(wnd->hwndSelf);
}
}
@@ -3723,10 +3788,14 @@
if (text) {
TRACE(edit, "\t'%s'\n", text);
EDIT_EM_ReplaceSel(wnd, es, FALSE, text);
- es->x_offset = 0;
+ } else {
+ TRACE(edit, "\t<NULL>\n");
+ EDIT_EM_ReplaceSel(wnd, es, FALSE, "");
}
+ es->x_offset = 0;
es->flags |= EF_MODIFIED;
es->flags |= EF_UPDATE;
+ EDIT_EM_SetSel(wnd, es, 0, 0, FALSE);
EDIT_EM_ScrollCaret(wnd, es);
}
diff --git a/controls/header.c b/controls/header.c
index 18bbfaa..1e7097aa 100644
--- a/controls/header.c
+++ b/controls/header.c
@@ -6,7 +6,6 @@
* TODO:
* - Imagelist support (partially).
* - Callback items.
- * - Owner draw support.
* - Order list support.
* - Control specific cursors (over dividers).
* - Hottrack support (partially).
@@ -38,8 +37,10 @@
static INT32
-HEADER_DrawItem (WND *wndPtr, HDC32 hdc, HEADER_ITEM *phdi, BOOL32 bHotTrack)
+HEADER_DrawItem (WND *wndPtr, HDC32 hdc, INT32 iItem, BOOL32 bHotTrack)
{
+ HEADER_INFO *infoPtr = HEADER_GetInfoPtr(wndPtr);
+ HEADER_ITEM *phdi = &infoPtr->items[iItem];
RECT32 r;
INT32 oldBkMode;
@@ -62,7 +63,18 @@
DrawEdge32 (hdc, &r, EDGE_ETCHED, BF_BOTTOM | BF_RIGHT | BF_ADJUST);
if (phdi->fmt & HDF_OWNERDRAW) {
- /* FIXME: owner drawn items */
+ DRAWITEMSTRUCT32 dis;
+ dis.CtlType = ODT_HEADER;
+ dis.CtlID = wndPtr->wIDmenu;
+ dis.itemID = iItem;
+ dis.itemAction = ODA_DRAWENTIRE;
+ dis.itemState = phdi->bDown ? ODS_SELECTED : 0;
+ dis.hwndItem = wndPtr->hwndSelf;
+ dis.hDC = hdc;
+ dis.rcItem = r;
+ dis.itemData = phdi->lParam;
+ SendMessage32A (GetParent32 (wndPtr->hwndSelf), WM_DRAWITEM,
+ (WPARAM32)wndPtr->wIDmenu, (LPARAM)&dis);
}
else {
UINT32 uTextJustify = DT_LEFT;
@@ -161,7 +173,6 @@
}
if (phdi->fmt & HDF_IMAGE) {
- HEADER_INFO *infoPtr = HEADER_GetInfoPtr(wndPtr);
// ImageList_Draw (infoPtr->himl, phdi->iImage,...);
@@ -203,7 +214,7 @@
x = rect.left;
for (i = 0; i < infoPtr->uNumItem; i++) {
- x = HEADER_DrawItem (wndPtr, hdc, &infoPtr->items[i], FALSE);
+ x = HEADER_DrawItem (wndPtr, hdc, i, FALSE);
}
if ((x <= rect.right) && (infoPtr->uNumItem > 0)) {
@@ -219,14 +230,14 @@
static void
-HEADER_RefreshItem (WND *wndPtr, HDC32 hdc, HEADER_ITEM *phdi)
+HEADER_RefreshItem (WND *wndPtr, HDC32 hdc, INT32 iItem)
{
HEADER_INFO *infoPtr = HEADER_GetInfoPtr(wndPtr);
HFONT32 hFont, hOldFont;
hFont = infoPtr->hFont ? infoPtr->hFont : GetStockObject32 (SYSTEM_FONT);
hOldFont = SelectObject32 (hdc, hFont);
- HEADER_DrawItem (wndPtr, hdc, phdi, FALSE);
+ HEADER_DrawItem (wndPtr, hdc, iItem, FALSE);
SelectObject32 (hdc, hOldFont);
}
@@ -501,8 +512,8 @@
if (infoPtr->uNumItem == 1) {
TRACE(header, "Simple delete!\n");
if (infoPtr->items[0].pszText)
- HeapFree (SystemHeap, 0, infoPtr->items[0].pszText);
- HeapFree (SystemHeap, 0, infoPtr->items);
+ HeapFree (GetProcessHeap (), 0, infoPtr->items[0].pszText);
+ HeapFree (GetProcessHeap (), 0, infoPtr->items);
infoPtr->items = 0;
infoPtr->uNumItem = 0;
}
@@ -511,10 +522,10 @@
TRACE(header, "Complex delete! [iItem=%d]\n", iItem);
if (infoPtr->items[iItem].pszText)
- HeapFree (SystemHeap, 0, infoPtr->items[iItem].pszText);
+ HeapFree (GetProcessHeap (), 0, infoPtr->items[iItem].pszText);
infoPtr->uNumItem--;
- infoPtr->items = HeapAlloc (SystemHeap, HEAP_ZERO_MEMORY,
+ infoPtr->items = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY,
sizeof (HEADER_ITEM) * infoPtr->uNumItem);
/* pre delete copy */
if (iItem > 0) {
@@ -528,7 +539,7 @@
(infoPtr->uNumItem - iItem) * sizeof(HEADER_ITEM));
}
- HeapFree (SystemHeap, 0, oldItems);
+ HeapFree (GetProcessHeap (), 0, oldItems);
}
HEADER_SetItemBounds (wndPtr);
@@ -669,7 +680,7 @@
iItem = infoPtr->uNumItem;
if (infoPtr->uNumItem == 0) {
- infoPtr->items = HeapAlloc (SystemHeap, HEAP_ZERO_MEMORY,
+ infoPtr->items = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY,
sizeof (HEADER_ITEM));
infoPtr->uNumItem++;
}
@@ -677,7 +688,7 @@
HEADER_ITEM *oldItems = infoPtr->items;
infoPtr->uNumItem++;
- infoPtr->items = HeapAlloc (SystemHeap, HEAP_ZERO_MEMORY,
+ infoPtr->items = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY,
sizeof (HEADER_ITEM) * infoPtr->uNumItem);
/* pre insert copy */
if (iItem > 0) {
@@ -691,7 +702,7 @@
(infoPtr->uNumItem - iItem) * sizeof(HEADER_ITEM));
}
- HeapFree (SystemHeap, 0, oldItems);
+ HeapFree (GetProcessHeap (), 0, oldItems);
}
infoPtr->items[iItem].bDown = FALSE;
@@ -703,7 +714,7 @@
if (phdi->mask & HDI_TEXT) {
len = lstrlen32A (phdi->pszText);
infoPtr->items[iItem].pszText =
- HeapAlloc (SystemHeap, HEAP_ZERO_MEMORY, len+1);
+ HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, len+1);
lstrcpy32A (infoPtr->items[iItem].pszText, phdi->pszText);
infoPtr->items[iItem].cchTextMax = phdi->cchTextMax;
}
@@ -748,7 +759,7 @@
lpLayout->pwpos->cy = 0;
else
lpLayout->pwpos->cy = infoPtr->nHeight;
- lpLayout->pwpos->flags = SWP_NOACTIVATE|SWP_NOZORDER;
+ lpLayout->pwpos->flags = SWP_NOZORDER;
TRACE (header, "Layout x=%d y=%d cx=%d cy=%d\n",
lpLayout->pwpos->x, lpLayout->pwpos->y,
@@ -818,9 +829,9 @@
if (phdi->mask & HDI_TEXT) {
INT32 len = lstrlen32A (phdi->pszText);
if (infoPtr->items[iItem].pszText)
- HeapFree (SystemHeap, 0, infoPtr->items[iItem].pszText);
+ HeapFree (GetProcessHeap (), 0, infoPtr->items[iItem].pszText);
infoPtr->items[iItem].pszText =
- HeapAlloc (SystemHeap, HEAP_ZERO_MEMORY, len+1);
+ HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, len+1);
lstrcpy32A (infoPtr->items[iItem].pszText, phdi->pszText);
infoPtr->items[iItem].cchTextMax = phdi->cchTextMax;
}
@@ -859,7 +870,7 @@
HFONT32 hOldFont;
HDC32 hdc;
- infoPtr = (HEADER_INFO *)HeapAlloc( SystemHeap, HEAP_ZERO_MEMORY,
+ infoPtr = (HEADER_INFO *)HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY,
sizeof(HEADER_INFO));
wndPtr->wExtra[0] = (DWORD)infoPtr;
@@ -896,15 +907,15 @@
if (infoPtr->items) {
for (iItem = 0; iItem < infoPtr->uNumItem; iItem++) {
if (infoPtr->items[iItem].pszText)
- HeapFree (SystemHeap, 0, infoPtr->items[iItem].pszText);
+ HeapFree (GetProcessHeap (), 0, infoPtr->items[iItem].pszText);
}
- HeapFree (SystemHeap, 0, infoPtr->items);
+ HeapFree (GetProcessHeap (), 0, infoPtr->items);
}
if (infoPtr->himl)
ImageList_Destroy (infoPtr->himl);
- HeapFree (SystemHeap, 0, infoPtr);
+ HeapFree (GetProcessHeap (), 0, infoPtr);
return 0;
}
@@ -962,7 +973,7 @@
/* Send WM_CUSTOMDRAW */
hdc = GetDC32 (wndPtr->hwndSelf);
- HEADER_RefreshItem (wndPtr, hdc, &infoPtr->items[iItem]);
+ HEADER_RefreshItem (wndPtr, hdc, iItem);
ReleaseDC32 (wndPtr->hwndSelf, hdc);
TRACE (header, "Pressed item %d!\n", iItem);
@@ -987,8 +998,6 @@
}
}
-
-
return 0;
}
@@ -1010,7 +1019,7 @@
if ((iItem == infoPtr->iMoveItem) && (flags == HHT_ONHEADER)) {
infoPtr->items[infoPtr->iMoveItem].bDown = FALSE;
hdc = GetDC32 (wndPtr->hwndSelf);
- HEADER_RefreshItem (wndPtr, hdc, &infoPtr->items[infoPtr->iMoveItem]);
+ HEADER_RefreshItem (wndPtr, hdc, infoPtr->iMoveItem);
ReleaseDC32 (wndPtr->hwndSelf, hdc);
HEADER_SendClickNotify (wndPtr, HDN_ITEMCLICK32A, infoPtr->iMoveItem);
@@ -1086,7 +1095,7 @@
else
infoPtr->items[infoPtr->iMoveItem].bDown = FALSE;
hdc = GetDC32 (wndPtr->hwndSelf);
- HEADER_RefreshItem (wndPtr, hdc, &infoPtr->items[infoPtr->iMoveItem]);
+ HEADER_RefreshItem (wndPtr, hdc, infoPtr->iMoveItem);
ReleaseDC32 (wndPtr->hwndSelf, hdc);
TRACE (header, "Moving pressed item %d!\n", infoPtr->iMoveItem);
@@ -1127,7 +1136,7 @@
}
if ((wndPtr->dwStyle & HDS_BUTTONS) && (wndPtr->dwStyle & HDS_HOTTRACK)) {
-
+ FIXME (header, "hot track support!\n");
}
return 0;
diff --git a/controls/listbox.c b/controls/listbox.c
index 60ea183..25af765 100644
--- a/controls/listbox.c
+++ b/controls/listbox.c
@@ -13,6 +13,7 @@
#include "win.h"
#include "combo.h"
#include "debug.h"
+#include "tweak.h"
/* Unimplemented yet:
* - LBS_NOSEL
@@ -1330,7 +1331,7 @@
if (index <= descr->focus_item)
{
descr->focus_item++;
- LISTBOX_MoveCaret( wnd, descr, descr->focus_item - 1, FALSE );
+ LISTBOX_MoveCaret( wnd, descr, descr->focus_item, FALSE );
}
/* If listbox was empty, set focus to the first item */
@@ -1447,7 +1448,7 @@
if (index <= descr->focus_item)
{
descr->focus_item--;
- LISTBOX_MoveCaret( wnd, descr, descr->focus_item + 1, FALSE );
+ LISTBOX_MoveCaret( wnd, descr, descr->focus_item, FALSE );
}
return LB_OKAY;
}
@@ -2484,6 +2485,11 @@
}
break;
+ case WM_NCCREATE:
+ if (TWEAK_Win95Look)
+ wnd->dwExStyle |= WS_EX_CLIENTEDGE;
+ return DefWindowProc32A( hwnd, msg, wParam, lParam );
+
default:
if ((msg >= WM_USER) && (msg < 0xc000))
WARN(listbox, "[%04x]: unknown msg %04x wp %08x lp %08lx\n",
diff --git a/controls/menu.c b/controls/menu.c
index ee407e2..6e60858 100644
--- a/controls/menu.c
+++ b/controls/menu.c
@@ -653,7 +653,10 @@
{
dwSize = GetTextExtent( hdc, lpitem->text, strlen(lpitem->text) );
lpitem->rect.right += LOWORD(dwSize);
- lpitem->rect.bottom += MAX( HIWORD(dwSize), SYSMETRICS_CYMENU );
+ if (TWEAK_Win95Look)
+ lpitem->rect.bottom += MAX (HIWORD(dwSize), sysMetrics[SM_CYMENU]- 1);
+ else
+ lpitem->rect.bottom += MAX( HIWORD(dwSize), SYSMETRICS_CYMENU );
lpitem->xTab = 0;
if (menuBar) lpitem->rect.right += MENU_BAR_ITEMS_SPACE;
@@ -698,6 +701,7 @@
lpitem = &lppop->items[start];
orgX = maxX;
orgY = SYSMETRICS_CYBORDER;
+
maxTab = maxTabWidth = 0;
/* Parse items until column break or end of menu */
@@ -731,6 +735,9 @@
lppop->Height = MAX( lppop->Height, orgY );
}
+ if(TWEAK_Win95Look)
+ lppop->Height++;
+
lppop->Width = maxX;
ReleaseDC32( 0, hdc );
}
@@ -881,22 +888,10 @@
*/
}
- if (lpitem->fState & MF_HILITE) {
- RECT32 r = rect;
- r.top += MENU_HighlightTopNudge;
- r.bottom += MENU_HighlightBottomNudge;
- r.left += MENU_HighlightLeftNudge;
- r.right += MENU_HighlightRightNudge;
- FillRect32( hdc, &r, GetSysColorBrush32(COLOR_HIGHLIGHT) );
- }
- else {
- RECT32 r = rect;
- r.top += MENU_HighlightTopNudge;
- r.bottom += MENU_HighlightBottomNudge;
- r.left += MENU_HighlightLeftNudge;
- r.right += MENU_HighlightRightNudge;
- FillRect32( hdc, &r, GetSysColorBrush32(COLOR_MENU) );
- }
+ if (lpitem->fState & MF_HILITE)
+ FillRect32( hdc, &rect, GetSysColorBrush32(COLOR_HIGHLIGHT) );
+ else
+ FillRect32( hdc, &rect, GetSysColorBrush32(COLOR_MENU) );
SetBkMode32( hdc, TRANSPARENT );
@@ -1147,9 +1142,6 @@
lprect->bottom = lprect->top + lppop->Height;
if (suppress_draw) return lppop->Height;
- if(TWEAK_Win95Look)
- ++lprect->bottom;
-
FillRect32(hDC, lprect, GetSysColorBrush32(COLOR_MENU) );
if(!TWEAK_Win95Look) {
@@ -1157,6 +1149,11 @@
MoveTo( hDC, lprect->left, lprect->bottom );
LineTo32( hDC, lprect->right, lprect->bottom );
}
+ else {
+ SelectObject32( hDC, GetSysColorPen32(COLOR_3DFACE));
+ MoveTo( hDC, lprect->left, lprect->bottom );
+ LineTo32( hDC, lprect->right, lprect->bottom );
+ }
if (lppop->nItems == 0) return SYSMETRICS_CYMENU;
for (i = 0; i < lppop->nItems; i++)
diff --git a/controls/progress.c b/controls/progress.c
index d83cb93..3acb294 100644
--- a/controls/progress.c
+++ b/controls/progress.c
@@ -29,25 +29,20 @@
/***********************************************************************
- * PROGRESS_Paint
- * Draw the arrows. The background need not be erased.
- * If dc!=0, it draws on it
+ * PROGRESS_Draw
+ * Draws the progress bar.
*/
-static void PROGRESS_Paint(WND *wndPtr, HDC32 dc)
+static void
+PROGRESS_Draw (WND *wndPtr, HDC32 hdc)
{
PROGRESS_INFO *infoPtr = PROGRESS_GetInfoPtr(wndPtr);
HBRUSH32 hbrBar, hbrBk;
int rightBar, rightMost, ledWidth;
- PAINTSTRUCT32 ps;
RECT32 rect;
- HDC32 hdc;
- TRACE(progress, "paint pos=%d min=%d, max=%d\n",
+ TRACE(progress, "refresh pos=%d min=%d, max=%d\n",
infoPtr->CurVal, infoPtr->MinVal, infoPtr->MaxVal);
- /* get a dc */
- hdc = dc==0 ? BeginPaint32(wndPtr->hwndSelf, &ps) : dc;
-
/* get the required bar brush */
if (infoPtr->ColorBar == CLR_DEFAULT)
hbrBar = GetSysColorBrush32(COLOR_HIGHLIGHT);
@@ -60,11 +55,10 @@
else
hbrBk = CreateSolidBrush32 (infoPtr->ColorBk);
- /* get rect for the bar, adjusted for the border */
+ /* get client rectangle */
GetClientRect32 (wndPtr->hwndSelf, &rect);
- /* draw the border */
- DrawEdge32(hdc, &rect, BDR_SUNKENOUTER, BF_RECT|BF_ADJUST);
+ /* draw the background */
FillRect32(hdc, &rect, hbrBk);
rect.left++; rect.right--; rect.top++; rect.bottom--;
@@ -125,13 +119,40 @@
/* delete background brush */
if (infoPtr->ColorBk != CLR_DEFAULT)
DeleteObject32 (hbrBk);
-
- /* clean-up */
- if(!dc)
- EndPaint32(wndPtr->hwndSelf, &ps);
}
/***********************************************************************
+ * PROGRESS_Refresh
+ * Draw the progress bar. The background need not be erased.
+ */
+static void
+PROGRESS_Refresh (WND *wndPtr)
+{
+ HDC32 hdc;
+
+ hdc = GetDC32 (wndPtr->hwndSelf);
+ PROGRESS_Draw (wndPtr, hdc);
+ ReleaseDC32 (wndPtr->hwndSelf, hdc);
+}
+
+/***********************************************************************
+ * PROGRESS_Paint
+ * Draw the progress bar. The background need not be erased.
+ * If dc!=0, it draws on it
+ */
+static void
+PROGRESS_Paint (WND *wndPtr)
+{
+ PAINTSTRUCT32 ps;
+ HDC32 hdc;
+
+ hdc = BeginPaint32 (wndPtr->hwndSelf, &ps);
+ PROGRESS_Draw (wndPtr, hdc);
+ EndPaint32 (wndPtr->hwndSelf, &ps);
+}
+
+
+/***********************************************************************
* PROGRESS_CoercePos
* Makes sure the current position (CUrVal) is within bounds.
*/
@@ -157,10 +178,15 @@
switch(message)
{
+ case WM_NCCREATE:
+ wndPtr->dwExStyle |= WS_EX_STATICEDGE;
+ return TRUE;
+
case WM_CREATE:
/* allocate memory for info struct */
- infoPtr = (PROGRESS_INFO *)HeapAlloc (SystemHeap, HEAP_ZERO_MEMORY,
- sizeof(PROGRESS_INFO));
+ infoPtr =
+ (PROGRESS_INFO *)HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY,
+ sizeof(PROGRESS_INFO));
wndPtr->wExtra[0] = (DWORD)infoPtr;
/* initialize the info struct */
@@ -175,7 +201,7 @@
case WM_DESTROY:
TRACE(progress, "Progress Ctrl destruction, hwnd=%04x\n", hwnd);
- HeapFree (SystemHeap, 0, infoPtr);
+ HeapFree (GetProcessHeap (), 0, infoPtr);
break;
case WM_ERASEBKGND:
@@ -194,7 +220,7 @@
break;
case WM_PAINT:
- PROGRESS_Paint(wndPtr, wParam);
+ PROGRESS_Paint (wndPtr);
break;
case PBM_DELTAPOS:
@@ -204,8 +230,7 @@
if(wParam != 0){
infoPtr->CurVal += (UINT16)wParam;
PROGRESS_CoercePos(wndPtr);
- InvalidateRect32 (hwnd, NULL, FALSE);
- UpdateWindow32 (hwnd);
+ PROGRESS_Refresh (wndPtr);
}
return temp;
@@ -216,8 +241,7 @@
if(temp != wParam){
infoPtr->CurVal = (UINT16)wParam;
PROGRESS_CoercePos(wndPtr);
- InvalidateRect32 (hwnd, NULL, FALSE);
- UpdateWindow32 (hwnd);
+ PROGRESS_Refresh (wndPtr);
}
return temp;
@@ -231,8 +255,7 @@
if(infoPtr->MaxVal <= infoPtr->MinVal)
infoPtr->MaxVal = infoPtr->MinVal+1;
PROGRESS_CoercePos(wndPtr);
- InvalidateRect32 (hwnd, NULL, FALSE);
- UpdateWindow32 (hwnd);
+ PROGRESS_Refresh (wndPtr);
}
return temp;
@@ -251,10 +274,7 @@
if(infoPtr->CurVal > infoPtr->MaxVal)
infoPtr->CurVal = infoPtr->MinVal;
if(temp != infoPtr->CurVal)
- {
- InvalidateRect32 (hwnd, NULL, FALSE);
- UpdateWindow32 (hwnd);
- }
+ PROGRESS_Refresh (wndPtr);
return temp;
case PBM_SETRANGE32:
@@ -266,8 +286,7 @@
if(infoPtr->MaxVal <= infoPtr->MinVal)
infoPtr->MaxVal = infoPtr->MinVal+1;
PROGRESS_CoercePos(wndPtr);
- InvalidateRect32 (hwnd, NULL, FALSE);
- UpdateWindow32 (hwnd);
+ PROGRESS_Refresh (wndPtr);
}
return temp;
@@ -287,16 +306,14 @@
if (wParam)
UNKNOWN_PARAM(PBM_SETBARCOLOR, wParam, lParam);
infoPtr->ColorBar = (COLORREF)lParam;
- InvalidateRect32 (hwnd, NULL, FALSE);
- UpdateWindow32 (hwnd);
+ PROGRESS_Refresh (wndPtr);
break;
case PBM_SETBKCOLOR:
if (wParam)
UNKNOWN_PARAM(PBM_SETBKCOLOR, wParam, lParam);
infoPtr->ColorBk = (COLORREF)lParam;
- InvalidateRect32 (hwnd, NULL, FALSE);
- UpdateWindow32 (hwnd);
+ PROGRESS_Refresh (wndPtr);
break;
default:
@@ -316,7 +333,8 @@
* Registers the progress bar window class.
*
*/
-void PROGRESS_Register(void)
+void
+PROGRESS_Register(void)
{
WNDCLASS32A wndClass;
diff --git a/controls/static.c b/controls/static.c
index 01f386c..255f01f 100644
--- a/controls/static.c
+++ b/controls/static.c
@@ -12,12 +12,13 @@
#include "static.h"
#include "heap.h"
#include "debug.h"
+#include "tweak.h"
static void STATIC_PaintTextfn( WND *wndPtr, HDC32 hdc );
static void STATIC_PaintRectfn( WND *wndPtr, HDC32 hdc );
static void STATIC_PaintIconfn( WND *wndPtr, HDC32 hdc );
static void STATIC_PaintBitmapfn( WND *wndPtr, HDC32 hdc );
-
+static void STATIC_PaintEtchedfn( WND *wndPtr, HDC32 hdc );
static COLORREF color_windowframe, color_background, color_window;
@@ -42,9 +43,9 @@
NULL, /* SS_OWNERDRAW */
STATIC_PaintBitmapfn, /* SS_BITMAP */
NULL, /* SS_ENHMETAFILE */
- NULL, /* SS_ETCHEDHORIZ */
- NULL, /* SS_ETCHEDVERT */
- NULL, /* SS_ETCHEDFRAME */
+ STATIC_PaintEtchedfn, /* SS_ETCHEDHORIZ */
+ STATIC_PaintEtchedfn, /* SS_ETCHEDVERT */
+ STATIC_PaintEtchedfn, /* SS_ETCHEDFRAME */
};
@@ -170,6 +171,9 @@
switch (uMsg)
{
case WM_NCCREATE:
+ if (TWEAK_Win95Look && (wndPtr->dwStyle & SS_SUNKEN))
+ wndPtr->dwExStyle |= WS_EX_STATICEDGE;
+
if (style == SS_ICON)
{
CREATESTRUCT32A *cs = (CREATESTRUCT32A *)lParam;
@@ -392,7 +396,7 @@
if (infoPtr->hIcon) DrawIcon32( hdc, rc.left, rc.top, infoPtr->hIcon );
}
-static void STATIC_PaintBitmapfn(WND *wndPtr, HDC32 hdc )
+static void STATIC_PaintBitmapfn(WND *wndPtr, HDC32 hdc )
{
RECT32 rc;
HBRUSH32 hbrush;
@@ -416,3 +420,48 @@
GDI_HEAP_UNLOCK(infoPtr->hIcon);
}
}
+
+
+static void STATIC_PaintEtchedfn( WND *wndPtr, HDC32 hdc )
+{
+ RECT32 rc;
+ HBRUSH32 hbrush;
+ HPEN32 hpen;
+
+ if (!TWEAK_Win95Look) return;
+
+ GetClientRect32( wndPtr->hwndSelf, &rc );
+ hbrush = SendMessage32A( GetParent32(wndPtr->hwndSelf), WM_CTLCOLORSTATIC,
+ hdc, wndPtr->hwndSelf );
+ FillRect32( hdc, &rc, hbrush );
+
+ switch (wndPtr->dwStyle & SS_TYPEMASK)
+ {
+ case SS_ETCHEDHORZ:
+ hpen = SelectObject32 (hdc, GetSysColorPen32 (COLOR_3DSHADOW));
+ MoveToEx32 (hdc, rc.left, rc.bottom / 2 - 1, NULL);
+ LineTo32 (hdc, rc.right - 1, rc.bottom / 2 - 1);
+ SelectObject32 (hdc, GetSysColorPen32 (COLOR_3DHIGHLIGHT));
+ MoveToEx32 (hdc, rc.left, rc.bottom / 2, NULL);
+ LineTo32 (hdc, rc.right, rc.bottom / 2);
+ LineTo32 (hdc, rc.right, rc.bottom / 2 - 1);
+ SelectObject32 (hdc, hpen);
+ break;
+
+ case SS_ETCHEDVERT:
+ hpen = SelectObject32 (hdc, GetSysColorPen32 (COLOR_3DSHADOW));
+ MoveToEx32 (hdc, rc.right / 2 - 1, rc.top, NULL);
+ LineTo32 (hdc, rc.right / 2 - 1, rc.bottom - 1);
+ SelectObject32 (hdc, GetSysColorPen32 (COLOR_3DHIGHLIGHT));
+ MoveToEx32 (hdc, rc.right / 2, rc.top, NULL);
+ LineTo32 (hdc, rc.right / 2, rc.bottom);
+ LineTo32 (hdc, rc.right / 2 -1 , rc.bottom);
+ SelectObject32 (hdc, hpen);
+ break;
+
+ case SS_ETCHEDFRAME:
+ DrawEdge32 (hdc, &rc, EDGE_ETCHED, BF_RECT);
+ break;
+ }
+}
+
diff --git a/controls/status.c b/controls/status.c
index 6df39b0..93113e1 100644
--- a/controls/status.c
+++ b/controls/status.c
@@ -103,7 +103,7 @@
/* now draw text */
if (text) {
int oldbkmode = SetBkMode32(hdc, TRANSPARENT);
- LPSTR p = text;
+ LPSTR p = (LPSTR)text;
UINT32 align = DT_LEFT;
if (*p == '\t') {
p++;
diff --git a/controls/toolbar.c b/controls/toolbar.c
index 3c5d134..4f3ce96 100644
--- a/controls/toolbar.c
+++ b/controls/toolbar.c
@@ -11,14 +11,16 @@
* Eric <ekohl@abo.rhein-zeitung.de>
*
* TODO:
- * - Many messages.
- * - All notifications.
+ * - Bitmap drawing.
+ * - Button wrapping.
+ * - Messages.
+ * - Notifications.
* - Fix TB_GETBITMAPFLAGS.
* - Fix TB_GETROWS and TB_SETROWS.
* - Tooltip support (partially).
* - Unicode suppport.
* - Internal COMMCTL32 bitmaps.
- * - Customize dialog.
+ * - Fix TOOLBAR_Customize. (Customize dialog.)
*
* Testing:
* - Run tests using Waite Group Windows95 API Bible Volume 2.
@@ -39,9 +41,10 @@
#include "debug.h"
-#define SEPARATOR_WIDTH 8
-#define SEPARATOR_HEIGHT 5
-
+#define SEPARATOR_WIDTH 8
+#define SEPARATOR_HEIGHT 5
+#define TOP_BORDER 2
+#define BOTTOM_BORDER 2
@@ -49,76 +52,94 @@
static void
+TOOLBAR_DrawFlatSeparator (LPRECT32 lpRect, HDC32 hdc)
+{
+ INT32 x = (lpRect->left + lpRect->right) / 2 - 1;
+ INT32 yBottom = lpRect->bottom - 3;
+ INT32 yTop = lpRect->top + 1;
+
+ SelectObject32 ( hdc, GetSysColorPen32 (COLOR_3DSHADOW));
+ MoveToEx32 (hdc, x, yBottom, NULL);
+ LineTo32 (hdc, x, yTop);
+ x++;
+ SelectObject32 ( hdc, GetSysColorPen32 (COLOR_3DHILIGHT));
+ MoveToEx32 (hdc, x, yBottom, NULL);
+ LineTo32 (hdc, x, yTop);
+}
+
+
+static void
TOOLBAR_DrawButton (WND *wndPtr, TBUTTON_INFO *btnPtr, HDC32 hdc)
{
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
+ BOOL32 bFlat = (wndPtr->dwStyle & TBSTYLE_FLAT);
RECT32 rc;
if (btnPtr->fsState & TBSTATE_HIDDEN) return;
rc = btnPtr->rect;
if (btnPtr->fsStyle & TBSTYLE_SEP) {
-
+ if ((bFlat) && (btnPtr->idCommand == 0))
+ TOOLBAR_DrawFlatSeparator (&btnPtr->rect, hdc);
+ return;
}
- else {
- if (!(btnPtr->fsState & TBSTATE_ENABLED)) {
- /* button is disabled */
- HICON32 hIcon;
- DrawEdge32 (hdc, &rc, EDGE_RAISED,
- BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
- hIcon = ImageList_GetIcon (infoPtr->himlDef, btnPtr->iBitmap, ILD_IMAGE);
- DrawState32A (hdc, (HBRUSH32)NULL, NULL, MAKELONG(hIcon, 0), 0,
- rc.left+1, rc.top+1,
- infoPtr->nBitmapWidth, infoPtr->nBitmapHeight, DST_ICON|DSS_DISABLED);
-// ImageList_Draw (infoPtr->himlDis, btnPtr->iBitmap, hdc,
-// rc.left+1, rc.top+1, ILD_NORMAL);
- return;
- }
- /* TBSTYLE_BUTTON */
- if (btnPtr->fsState & TBSTATE_PRESSED) {
- DrawEdge32 (hdc, &rc, EDGE_SUNKEN,
- BF_RECT | BF_MIDDLE | BF_ADJUST);
- ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
- rc.left+2, rc.top+2, ILD_NORMAL);
- return;
- }
-
- if ((btnPtr->fsStyle & TBSTYLE_CHECK) &&
- (btnPtr->fsState & TBSTATE_CHECKED)) {
- HBRUSH32 hbr;
- DrawEdge32 (hdc, &rc, EDGE_SUNKEN,
- BF_RECT | BF_MIDDLE | BF_ADJUST);
-
- hbr = SelectObject32 (hdc, CACHE_GetPattern55AABrush ());
- PatBlt32 (hdc, rc.left, rc.top, rc.right - rc.left,
- rc.bottom - rc.top, 0x00FA0089);
- SelectObject32 (hdc, hbr);
- ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
- rc.left+2, rc.top+2, ILD_NORMAL);
- return;
- }
-
- if (btnPtr->fsState & TBSTATE_INDETERMINATE) {
- HBRUSH32 hbr;
- DrawEdge32 (hdc, &rc, EDGE_RAISED,
- BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
-
- hbr = SelectObject32 (hdc, CACHE_GetPattern55AABrush ());
- PatBlt32 (hdc, rc.left, rc.top, rc.right - rc.left,
- rc.bottom - rc.top, 0x00FA0089);
- SelectObject32 (hdc, hbr);
-// ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
-// rc.left+1, rc.top+1, ILD_NORMAL);
- return;
- }
-
- /* normal state */
+ /* disabled */
+ if (!(btnPtr->fsState & TBSTATE_ENABLED)) {
+ HICON32 hIcon;
DrawEdge32 (hdc, &rc, EDGE_RAISED,
BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
- ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
- rc.left+1, rc.top+1, ILD_NORMAL);
+
+// ImageList_Draw (infoPtr->himlDis, btnPtr->iBitmap, hdc,
+// rc.left+1, rc.top+1, ILD_NORMAL);
+ return;
}
+
+ /* pressed TBSTYLE_BUTTON */
+ if (btnPtr->fsState & TBSTATE_PRESSED) {
+ DrawEdge32 (hdc, &rc, EDGE_SUNKEN,
+ BF_RECT | BF_MIDDLE | BF_ADJUST);
+ ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
+ rc.left+2, rc.top+2, ILD_NORMAL);
+ return;
+ }
+
+ /* checked TBSTYLE_CHECK*/
+ if ((btnPtr->fsStyle & TBSTYLE_CHECK) &&
+ (btnPtr->fsState & TBSTATE_CHECKED)) {
+ HBRUSH32 hbr;
+ DrawEdge32 (hdc, &rc, EDGE_SUNKEN,
+ BF_RECT | BF_MIDDLE | BF_ADJUST);
+
+ hbr = SelectObject32 (hdc, CACHE_GetPattern55AABrush ());
+ PatBlt32 (hdc, rc.left, rc.top, rc.right - rc.left,
+ rc.bottom - rc.top, 0x00FA0089);
+ SelectObject32 (hdc, hbr);
+ ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
+ rc.left+2, rc.top+2, ILD_NORMAL);
+ return;
+ }
+
+ /* indeterminate */
+ if (btnPtr->fsState & TBSTATE_INDETERMINATE) {
+ HBRUSH32 hbr;
+ DrawEdge32 (hdc, &rc, EDGE_RAISED,
+ BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
+
+ hbr = SelectObject32 (hdc, CACHE_GetPattern55AABrush ());
+ PatBlt32 (hdc, rc.left, rc.top, rc.right - rc.left,
+ rc.bottom - rc.top, 0x00FA0089);
+ SelectObject32 (hdc, hbr);
+// ImageList_Draw (infoPtr->himlDis, btnPtr->iBitmap, hdc,
+// rc.left+1, rc.top+1, ILD_NORMAL);
+ return;
+ }
+
+ /* normal state */
+ DrawEdge32 (hdc, &rc, EDGE_RAISED,
+ BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
+ ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
+ rc.left+1, rc.top+1, ILD_NORMAL);
}
@@ -130,14 +151,10 @@
TBUTTON_INFO *btnPtr;
INT32 i;
-
/* draw buttons */
-
btnPtr = infoPtr->buttons;
- for (i = 0; i < infoPtr->nNumButtons; i++) {
+ for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++)
TOOLBAR_DrawButton (wndPtr, btnPtr, hdc);
- btnPtr++;
- }
}
@@ -146,33 +163,63 @@
{
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
TBUTTON_INFO *btnPtr;
- RECT32 rect;
- INT32 i;
+ INT32 i, j, nRows;
+ INT32 x, y, cx, cy;
+ BOOL32 bVertical;
- rect.left = infoPtr->nIndent;
- rect.top = infoPtr->nButtonTop;
-// rect.right = rect.left + infoPtr->nButtonWidth;
- rect.bottom = rect.top + infoPtr->nButtonHeight;
+ x = infoPtr->nIndent;
+ y = TOP_BORDER;
+ cx = infoPtr->nButtonWidth;
+ cy = infoPtr->nButtonHeight;
+ nRows = 1;
btnPtr = infoPtr->buttons;
for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
- if (btnPtr->fsState & TBSTATE_HIDDEN) {
- btnPtr->rect.left = 0;
- btnPtr->rect.right = 0;
- btnPtr->rect.top = 0;
- btnPtr->rect.bottom = 0;
+ bVertical = FALSE;
+
+ if (btnPtr->fsState & TBSTATE_HIDDEN)
continue;
+
+ if (btnPtr->fsStyle & TBSTYLE_SEP) {
+ /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
+ /* it is the actual width of the separator. This is used for */
+ /* custom controls in toolbars. */
+ if ((wndPtr->dwStyle & TBSTYLE_WRAPABLE) &&
+ (btnPtr->fsState & TBSTATE_WRAP)) {
+ x = 0;
+ y += cy;
+ cx = infoPtr->nWidth;
+ cy = ((btnPtr->iBitmap == 0) ?
+ SEPARATOR_WIDTH : btnPtr->iBitmap) * 2 / 3;
+ nRows++;
+ bVertical = TRUE;
+ }
+ else
+ cx = (btnPtr->iBitmap == 0) ?
+ SEPARATOR_WIDTH : btnPtr->iBitmap;
+ }
+ else {
+ /* this must be a button */
+ cx = infoPtr->nButtonWidth;
+
}
- btnPtr->rect = rect;
- if (btnPtr->fsStyle & TBSTYLE_SEP)
- btnPtr->rect.right = btnPtr->rect.left + SEPARATOR_WIDTH;
+ btnPtr->rect.left = x;
+ btnPtr->rect.top = y;
+ btnPtr->rect.right = x + cx;
+ btnPtr->rect.bottom = y + cy;
+
+ if (bVertical) {
+ x = 0;
+ y += cy;
+ if (i < infoPtr->nNumButtons)
+ nRows++;
+ }
else
- btnPtr->rect.right = btnPtr->rect.left + infoPtr->nButtonWidth;
- rect.left = btnPtr->rect.right;
+ x += cx;
}
- infoPtr->nHeight = rect.bottom + 8;
+ infoPtr->nHeight = y + cy + BOTTOM_BORDER;
}
@@ -183,9 +230,8 @@
TBUTTON_INFO *btnPtr;
INT32 i;
-
btnPtr = infoPtr->buttons;
- for (i = 0; i < infoPtr->nNumButtons; i++) {
+ for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
if (btnPtr->fsStyle & TBSTYLE_SEP) {
if (PtInRect32 (&btnPtr->rect, *lpPt)) {
TRACE (toolbar, " ON SEPARATOR %d!\n", i);
@@ -197,10 +243,7 @@
TRACE (toolbar, " ON BUTTON %d!\n", i);
return i;
}
-
}
-
- btnPtr++;
}
TRACE (toolbar, " NOWHERE!\n");
@@ -215,12 +258,11 @@
INT32 i;
btnPtr = infoPtr->buttons;
- for (i = 0; i < infoPtr->nNumButtons; i++) {
+ for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
if (btnPtr->idCommand == idCommand) {
TRACE (toolbar, "command=%d index=%d\n", idCommand, i);
return i;
}
- btnPtr++;
}
TRACE (toolbar, "no index found for command=%d\n", idCommand);
return -1;
@@ -289,28 +331,15 @@
/* create new default image list */
TRACE (toolbar, "creating default image list!\n");
infoPtr->himlDef =
- ImageList_Create (infoPtr->nBitmapWidth,
- infoPtr->nBitmapHeight, ILC_COLOR | ILC_MASK,
- (INT32)wParam, 2);
+ ImageList_Create (infoPtr->nBitmapWidth, infoPtr->nBitmapHeight,
+ ILC_COLOR | ILC_MASK, (INT32)wParam, 2);
}
-#if 0
- if (!(infoPtr->himlDis)) {
- /* create new disabled image list */
- TRACE (toolbar, "creating disabled image list!\n");
- infoPtr->himlDis =
- ImageList_Create (infoPtr->nBitmapWidth,
- infoPtr->nBitmapHeight, ILC_COLOR | ILC_MASK,
- (INT32)wParam, 2);
- }
-#endif
-
/* Add bitmaps to the default image list */
if (lpAddBmp->hInst == (HINSTANCE32)0) {
nIndex =
ImageList_AddMasked (infoPtr->himlDef, (HBITMAP32)lpAddBmp->nID,
- 0xC0C0C0);
-// GetSysColor32 (COLOR_3DFACE));
+ GetSysColor32 (COLOR_3DFACE));
}
else if (lpAddBmp->hInst == HINST_COMMCTRL) {
/* add internal bitmaps */
@@ -353,17 +382,17 @@
if (infoPtr->nNumButtons == 0) {
infoPtr->buttons =
- HeapAlloc (SystemHeap, HEAP_ZERO_MEMORY,
+ HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY,
sizeof (TBUTTON_INFO) * nNewButtons);
}
else {
TBUTTON_INFO *oldButtons = infoPtr->buttons;
infoPtr->buttons =
- HeapAlloc (SystemHeap, HEAP_ZERO_MEMORY,
+ HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY,
sizeof (TBUTTON_INFO) * nNewButtons);
memcpy (&infoPtr->buttons[0], &oldButtons[0],
nOldButtons * sizeof(TBUTTON_INFO));
- HeapFree (SystemHeap, 0, oldButtons);
+ HeapFree (GetProcessHeap (), 0, oldButtons);
}
infoPtr->nNumButtons = nNewButtons;
@@ -409,20 +438,20 @@
nIndex = infoPtr->nNumStrings;
if (infoPtr->nNumStrings == 0) {
infoPtr->strings =
- HeapAlloc (SystemHeap, HEAP_ZERO_MEMORY, sizeof(char *));
+ HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(char *));
}
else {
char **oldStrings = infoPtr->strings;
infoPtr->strings =
- HeapAlloc (SystemHeap, HEAP_ZERO_MEMORY,
+ HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY,
sizeof(char *) * (infoPtr->nNumStrings + 1));
memcpy (&infoPtr->strings[0], &oldStrings[0],
sizeof(char *) * infoPtr->nNumStrings);
- HeapFree (SystemHeap, 0, oldStrings);
+ HeapFree (GetProcessHeap (), 0, oldStrings);
}
infoPtr->strings[infoPtr->nNumStrings] =
- HeapAlloc (SystemHeap, HEAP_ZERO_MEMORY, sizeof(char)*(len+1));
+ HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(char)*(len+1));
lstrcpy32A (infoPtr->strings[infoPtr->nNumStrings], szString);
infoPtr->nNumStrings++;
}
@@ -439,20 +468,20 @@
if (infoPtr->nNumStrings == 0) {
infoPtr->strings =
- HeapAlloc (SystemHeap, HEAP_ZERO_MEMORY, sizeof(char *));
+ HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(char *));
}
else {
char **oldStrings = infoPtr->strings;
infoPtr->strings =
- HeapAlloc (SystemHeap, HEAP_ZERO_MEMORY,
+ HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY,
sizeof(char *) * (infoPtr->nNumStrings + 1));
memcpy (&infoPtr->strings[0], &oldStrings[0],
sizeof(char *) * infoPtr->nNumStrings);
- HeapFree (SystemHeap, 0, oldStrings);
+ HeapFree (GetProcessHeap (), 0, oldStrings);
}
infoPtr->strings[infoPtr->nNumStrings] =
- HeapAlloc (SystemHeap, HEAP_ZERO_MEMORY, sizeof(char)*(len+1));
+ HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(char)*(len+1));
lstrcpy32A (infoPtr->strings[infoPtr->nNumStrings], p);
infoPtr->nNumStrings++;
@@ -493,6 +522,12 @@
{
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
+ if (infoPtr == NULL) {
+ ERR (toolbar, "(0x%08lx, 0x%08x, 0x%08lx)\n", (DWORD)wndPtr, wParam, lParam);
+ ERR (toolbar, "infoPtr == NULL!\n");
+ return 0;
+ }
+
infoPtr->dwStructSize = (DWORD)wParam;
return 0;
@@ -575,7 +610,13 @@
}
-// << TOOLBAR_Customize >>
+static LRESULT
+TOOLBAR_Customize (WND *wndPtr)
+{
+ FIXME (toolbar, "customization not implemented!\n");
+
+ return 0;
+}
static LRESULT
@@ -589,7 +630,7 @@
if (infoPtr->nNumButtons == 1) {
TRACE (toolbar, " simple delete!\n");
- HeapFree (SystemHeap, 0, infoPtr->buttons);
+ HeapFree (GetProcessHeap (), 0, infoPtr->buttons);
infoPtr->buttons = NULL;
infoPtr->nNumButtons = 0;
}
@@ -598,7 +639,7 @@
TRACE(toolbar, "complex delete! [nIndex=%d]\n", nIndex);
infoPtr->nNumButtons--;
- infoPtr->buttons = HeapAlloc (SystemHeap, HEAP_ZERO_MEMORY,
+ infoPtr->buttons = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY,
sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
if (nIndex > 0) {
memcpy (&infoPtr->buttons[0], &oldButtons[0],
@@ -610,7 +651,7 @@
(infoPtr->nNumButtons - nIndex) * sizeof(TBUTTON_INFO));
}
- HeapFree (SystemHeap, 0, oldButtons);
+ HeapFree (GetProcessHeap (), 0, oldButtons);
}
TOOLBAR_CalcToolbar (wndPtr);
@@ -636,7 +677,7 @@
btnPtr = &infoPtr->buttons[nIndex];
if (LOWORD(lParam) == FALSE)
- btnPtr->fsState &= ~TBSTATE_ENABLED;
+ btnPtr->fsState &= ~(TBSTATE_ENABLED | TBSTATE_PRESSED);
else
btnPtr->fsState |= TBSTATE_ENABLED;
@@ -700,7 +741,16 @@
// << TOOLBAR_GetButtonInfo >>
-// << TOOLBAR_GetButtonSize >>
+
+
+static LRESULT
+TOOLBAR_GetButtonSize (WND *wndPtr)
+{
+ TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
+
+ return MAKELONG((WORD)infoPtr->nButtonWidth,
+ (WORD)infoPtr->nButtonHeight);
+}
static LRESULT
@@ -904,7 +954,7 @@
oldButtons = infoPtr->buttons;
infoPtr->nNumButtons++;
- infoPtr->buttons = HeapAlloc (SystemHeap, HEAP_ZERO_MEMORY,
+ infoPtr->buttons = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY,
sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
/* pre insert copy */
if (nIndex > 0) {
@@ -926,7 +976,7 @@
(infoPtr->nNumButtons - nIndex - 1) * sizeof(TBUTTON_INFO));
}
- HeapFree (SystemHeap, 0, oldButtons);
+ HeapFree (GetProcessHeap (), 0, oldButtons);
TOOLBAR_CalcToolbar (wndPtr);
@@ -1059,7 +1109,37 @@
// << TOOLBAR_ReplaceBitmap >>
-// << TOOLBAR_SaveRestore >>
+
+
+static LRESULT
+TOOLBAR_SaveRestore32A (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
+{
+ TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
+ LPTBSAVEPARAMS32A lpSave = (LPTBSAVEPARAMS32A)lParam;
+
+ if (lpSave == NULL) return 0;
+
+ if ((BOOL32)wParam) {
+ /* save toolbar information */
+ FIXME (toolbar, "save to \"%s\" \"%s\"\n",
+ lpSave->pszSubKey, lpSave->pszValueName);
+
+
+ }
+ else {
+ /* restore toolbar information */
+
+ FIXME (toolbar, "restore from \"%s\" \"%s\"\n",
+ lpSave->pszSubKey, lpSave->pszValueName);
+
+
+ }
+
+ return 0;
+}
+
+
+// << TOOLBAR_SaveRestore32W >>
// << TOOLBAR_SetAnchorHighlight >>
@@ -1233,26 +1313,15 @@
static LRESULT
TOOLBAR_Create (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
{
- TOOLBAR_INFO *infoPtr;
-
- /* allocate memory for info structure */
- infoPtr = (TOOLBAR_INFO *)HeapAlloc (SystemHeap, HEAP_ZERO_MEMORY,
- sizeof(TOOLBAR_INFO));
- wndPtr->wExtra[0] = (DWORD)infoPtr;
-
- if (infoPtr == NULL) {
- ERR (toolbar, "could not allocate info memory!\n");
- return 0;
- }
+ TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
/* initialize info structure */
infoPtr->nButtonHeight = 22;
infoPtr->nButtonWidth = 23;
- infoPtr->nButtonTop = 2;
infoPtr->nBitmapHeight = 15;
infoPtr->nBitmapWidth = 16;
- infoPtr->nHeight = infoPtr->nButtonHeight + 6;
+ infoPtr->nHeight = infoPtr->nButtonHeight + TOP_BORDER + BOTTOM_BORDER;
infoPtr->nMaxRows = 1;
infoPtr->bCaptured = 0;
@@ -1260,6 +1329,8 @@
infoPtr->nOldHit = -1;
infoPtr->hwndNotify = GetParent32 (wndPtr->hwndSelf);
+ infoPtr->bTransparent = (wndPtr->dwStyle & TBSTYLE_FLAT);
+ infoPtr->nHotItem = -1;
return 0;
}
@@ -1276,16 +1347,16 @@
/* delete button data */
if (infoPtr->buttons)
- HeapFree (SystemHeap, 0, infoPtr->buttons);
+ HeapFree (GetProcessHeap (), 0, infoPtr->buttons);
/* delete strings */
if (infoPtr->strings) {
INT32 i;
for (i = 0; i < infoPtr->nNumStrings; i++)
if (infoPtr->strings[i])
- HeapFree (SystemHeap, 0, infoPtr->strings[i]);
+ HeapFree (GetProcessHeap (), 0, infoPtr->strings[i]);
- HeapFree (SystemHeap, 0, infoPtr->strings);
+ HeapFree (GetProcessHeap (), 0, infoPtr->strings);
}
/* destroy default image list */
@@ -1301,7 +1372,7 @@
ImageList_Destroy (infoPtr->himlHot);
/* free toolbar info data */
- HeapFree (SystemHeap, 0, infoPtr);
+ HeapFree (GetProcessHeap (), 0, infoPtr);
return 0;
}
@@ -1334,11 +1405,8 @@
TOOLBAR_DrawButton (wndPtr, btnPtr, hdc);
ReleaseDC32 (wndPtr->hwndSelf, hdc);
}
- else if (wndPtr->dwStyle & CCS_ADJUSTABLE) {
- /* customize */
-
- FIXME (toolbar, "customization not implemented!\n");
- }
+ else if (wndPtr->dwStyle & CCS_ADJUSTABLE)
+ TOOLBAR_Customize (wndPtr);
return 0;
}
@@ -1388,6 +1456,7 @@
INT32 nHit;
INT32 nOldIndex = -1;
HDC32 hdc;
+ BOOL32 bSendMessage = TRUE;
pt.x = (INT32)LOWORD(lParam);
pt.y = (INT32)HIWORD(lParam);
@@ -1399,25 +1468,28 @@
btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
btnPtr->fsState &= ~TBSTATE_PRESSED;
- if (btnPtr->fsStyle & TBSTYLE_CHECK) {
- if (btnPtr->fsStyle & TBSTYLE_GROUP) {
- nOldIndex = TOOLBAR_GetCheckedGroupButtonIndex (infoPtr, infoPtr->nButtonDown);
- if (nOldIndex == infoPtr->nButtonDown)
- return 0;
- if (nOldIndex != -1)
- infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
- btnPtr->fsState |= TBSTATE_CHECKED;
- }
- else {
- if (btnPtr->fsState & TBSTATE_CHECKED)
- btnPtr->fsState &= ~TBSTATE_CHECKED;
- else
+ if (nHit == infoPtr->nButtonDown) {
+ if (btnPtr->fsStyle & TBSTYLE_CHECK) {
+ if (btnPtr->fsStyle & TBSTYLE_GROUP) {
+ nOldIndex = TOOLBAR_GetCheckedGroupButtonIndex (infoPtr,
+ infoPtr->nButtonDown);
+ if (nOldIndex == infoPtr->nButtonDown)
+ bSendMessage = FALSE;
+ if ((nOldIndex != infoPtr->nButtonDown) &&
+ (nOldIndex != -1))
+ infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
btnPtr->fsState |= TBSTATE_CHECKED;
+ }
+ else {
+ if (btnPtr->fsState & TBSTATE_CHECKED)
+ btnPtr->fsState &= ~TBSTATE_CHECKED;
+ else
+ btnPtr->fsState |= TBSTATE_CHECKED;
+ }
}
}
-
- infoPtr->nButtonDown = -1;
- infoPtr->nOldHit = -1;
+ else
+ bSendMessage = FALSE;
hdc = GetDC32 (wndPtr->hwndSelf);
if (nOldIndex != -1)
@@ -1425,9 +1497,13 @@
TOOLBAR_DrawButton (wndPtr, btnPtr, hdc);
ReleaseDC32 (wndPtr->hwndSelf, hdc);
- SendMessage32A (GetParent32 (wndPtr->hwndSelf), WM_COMMAND,
- MAKEWPARAM(btnPtr->idCommand, 0),
- (LPARAM)wndPtr->hwndSelf);
+ if (bSendMessage)
+ SendMessage32A (infoPtr->hwndNotify, WM_COMMAND,
+ MAKEWPARAM(btnPtr->idCommand, 0),
+ (LPARAM)wndPtr->hwndSelf);
+
+ infoPtr->nButtonDown = -1;
+ infoPtr->nOldHit = -1;
}
return 0;
@@ -1470,34 +1546,43 @@
}
-
-
-
static LRESULT
TOOLBAR_NCCalcSize (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
{
- RECT32 tmpRect = {0, 0, 0, 0};
- LPRECT32 winRect;
-
-// DefWindowProc32A (wndPtr->hwndSelf, WM_NCCALCSIZE, wParam, lParam);
-
- winRect = (LPRECT32)lParam;
-
-// if (wndPtr->dwStyle & WS_BORDER)
-// InflateRect32 (&tmpRect, 1, 1);
-
if (!(wndPtr->dwStyle & CCS_NODIVIDER)) {
- tmpRect.top -= 2;
- tmpRect.bottom -= 2;
+ LPRECT32 winRect = (LPRECT32)lParam;
+ winRect->top += 2;
+ winRect->bottom += 2;
}
- winRect->left -= tmpRect.left;
- winRect->top -= tmpRect.top;
- winRect->right -= tmpRect.right;
- winRect->bottom -= tmpRect.bottom;
-
return DefWindowProc32A (wndPtr->hwndSelf, WM_NCCALCSIZE, wParam, lParam);
-// return 0;
+}
+
+
+static LRESULT
+TOOLBAR_NCCreate (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
+{
+ TOOLBAR_INFO *infoPtr;
+
+ /* allocate memory for info structure */
+ infoPtr = (TOOLBAR_INFO *)HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY,
+ sizeof(TOOLBAR_INFO));
+ wndPtr->wExtra[0] = (DWORD)infoPtr;
+
+ if (infoPtr == NULL) {
+ ERR (toolbar, "could not allocate info memory!\n");
+ return 0;
+ }
+
+ if ((TOOLBAR_INFO*)wndPtr->wExtra[0] != infoPtr) {
+ ERR (toolbar, "pointer assignment error!\n");
+ return 0;
+ }
+
+ /* this is just for security (reliable??)*/
+ infoPtr->dwStructSize = sizeof(TBBUTTON);
+
+ return DefWindowProc32A (wndPtr->hwndSelf, WM_NCCREATE, wParam, lParam);
}
@@ -1568,32 +1653,44 @@
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
RECT32 parent_rect;
HWND32 parent;
+ INT32 x, y, cx, cy;
INT32 flags;
+ UINT32 uPosFlags = 0;
flags = (INT32) wParam;
/* FIXME for flags =
- * SIZE_MAXIMIZED, SIZE_MAXSHOW, SIZE_MINIMIZED, SIZE_RESTORED
+ * SIZE_MAXIMIZED, SIZE_MAXSHOW, SIZE_MINIMIZED
*/
-// if (flags == SIZE_RESTORED) {
+ if (flags == SIZE_RESTORED) {
/* width and height don't apply */
parent = GetParent32 (wndPtr->hwndSelf);
GetClientRect32(parent, &parent_rect);
- infoPtr->nWidth = parent_rect.right - parent_rect.left;
- TOOLBAR_CalcToolbar (wndPtr);
- MoveWindow32(wndPtr->hwndSelf, parent_rect.left, parent_rect.top, //0, 0,
- infoPtr->nWidth, infoPtr->nHeight, TRUE);
-// }
+
+ if (wndPtr->dwStyle & CCS_NORESIZE)
+ uPosFlags |= SWP_NOSIZE;
+ else {
+ infoPtr->nWidth = parent_rect.right - parent_rect.left;
+ TOOLBAR_CalcToolbar (wndPtr);
+ cy = infoPtr->nHeight;
+ cx = infoPtr->nWidth;
+ }
+
+ if (wndPtr->dwStyle & CCS_NOPARENTALIGN) {
+ uPosFlags |= SWP_NOMOVE;
+ }
+
+ if (!(wndPtr->dwStyle & CCS_NODIVIDER))
+ cy += 2;
+
+ SetWindowPos32 (wndPtr->hwndSelf, 0, parent_rect.left, parent_rect.top,
+ cx, cy, uPosFlags | SWP_NOZORDER);
+ }
return 0;
}
-
-
-
-
-
LRESULT WINAPI
ToolbarWindowProc (HWND32 hwnd, UINT32 uMsg, WPARAM32 wParam, LPARAM lParam)
{
@@ -1632,7 +1729,8 @@
case TB_COMMANDTOINDEX:
return TOOLBAR_CommandToIndex (wndPtr, wParam, lParam);
-// case TB_CUSTOMIZE:
+ case TB_CUSTOMIZE:
+ return TOOLBAR_Customize (wndPtr);
case TB_DELETEBUTTON:
return TOOLBAR_DeleteButton (wndPtr, wParam, lParam);
@@ -1652,7 +1750,9 @@
return TOOLBAR_GetButton (wndPtr, wParam, lParam);
// case TB_GETBUTTONINFO: /* 4.71 */
-// case TB_GETBUTTONSIZE: /* 4.70 */
+
+ case TB_GETBUTTONSIZE:
+ return TOOLBAR_GetButtonSize (wndPtr);
case TB_GETBUTTONTEXT32A:
return TOOLBAR_GetButtonText32A (wndPtr, wParam, lParam);
@@ -1734,7 +1834,10 @@
return TOOLBAR_PressButton (wndPtr, wParam, lParam);
// case TB_REPLACEBITMAP:
-// case TB_SAVERESTORE32A:
+
+ case TB_SAVERESTORE32A:
+ return TOOLBAR_SaveRestore32A (wndPtr, wParam, lParam);
+
// case TB_SAVERESTORE32W:
// case TB_SETANCHORHIGHLIGHT: /* 4.71 */
@@ -1790,6 +1893,9 @@
case WM_DESTROY:
return TOOLBAR_Destroy (wndPtr, wParam, lParam);
+// case WM_ERASEBKGND:
+// return TOOLBAR_EraseBackground (wndPtr, wParam, lParam);
+
case WM_LBUTTONDBLCLK:
return TOOLBAR_LButtonDblClk (wndPtr, wParam, lParam);
@@ -1808,6 +1914,9 @@
case WM_NCCALCSIZE:
return TOOLBAR_NCCalcSize (wndPtr, wParam, lParam);
+ case WM_NCCREATE:
+ return TOOLBAR_NCCreate (wndPtr, wParam, lParam);
+
case WM_NCPAINT:
return TOOLBAR_NCPaint (wndPtr, wParam, lParam);
diff --git a/controls/updown.c b/controls/updown.c
index d71ba9d..03d6ed0 100644
--- a/controls/updown.c
+++ b/controls/updown.c
@@ -8,7 +8,9 @@
* arrow keys
* - I am not sure about the default values for the Min, Max, Pos
* (in the UPDOWN_INFO the fields: MinVal, MaxVal, CurVal)
- * - I think I do not handle correctly the WS_BORDER style.
+ * - I think I don not handle correctly the WS_BORDER style.
+ * (Should be fixed. <ekohl@abo.rhein-zeitung.de>)
+ *
* Testing:
* Not much. The following have not been tested at all:
* - horizontal arrows
@@ -63,7 +65,8 @@
"UpDown Ctrl: Unknown parameter(s) for message " #msg \
"(%04x): wp=%04x lp=%08lx\n", msg, wParam, lParam);
-#define UPDOWN_GetInfoPtr(wndPtr) ((UPDOWN_INFO *)wndPtr->wExtra)
+#define UPDOWN_GetInfoPtr(wndPtr) ((UPDOWN_INFO *)wndPtr->wExtra[0])
+
/***********************************************************************
* UPDOWN_InBounds
@@ -189,7 +192,7 @@
return FALSE;
}
else{
- /* we have a regural window, so will get the text */
+ /* we have a regular window, so will get the text */
if (!GetWindowText32A(infoPtr->Buddy, txt, sizeof(txt)))
return FALSE;
@@ -238,7 +241,7 @@
if(WIDGETS_IsControl32(WIN_FindWndPtr(infoPtr->Buddy), BIC32_LISTBOX)){
SendMessage32A(infoPtr->Buddy, LB_SETCURSEL32, infoPtr->CurVal, 0);
}
- else{ /* Regural window, so set caption to the number */
+ else{ /* Regular window, so set caption to the number */
len = sprintf(txt1, (infoPtr->Base==16) ? "%X" : "%d", infoPtr->CurVal);
sep = UPDOWN_GetThousandSep();
@@ -265,20 +268,16 @@
}
/***********************************************************************
- * UPDOWN_Paint
+ * UPDOWN_Draw [Internal]
+ *
* Draw the arrows. The background need not be erased.
*/
-static void UPDOWN_Paint(WND *wndPtr)
+static void UPDOWN_Draw (WND *wndPtr, HDC32 hdc)
{
UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr(wndPtr);
- PAINTSTRUCT32 ps;
BOOL32 prssed;
RECT32 rect;
- HDC32 hdc;
- /* start painting the button */
- hdc = BeginPaint32( wndPtr->hwndSelf, &ps );
-
/* Draw the incr button */
UPDOWN_GetArrowRect(wndPtr, &rect, TRUE);
prssed = (infoPtr->Flags & FLAG_INCR) && (infoPtr->Flags & FLAG_MOUSEIN);
@@ -298,10 +297,38 @@
(wndPtr->dwStyle & UDS_HORZ ? DFCS_SCROLLRIGHT : DFCS_SCROLLDOWN) |
(prssed ? DFCS_PUSHED : 0) |
(wndPtr->dwStyle&WS_DISABLED ? DFCS_INACTIVE : 0) );
+}
+
+/***********************************************************************
+ * UPDOWN_Refresh [Internal]
+ *
+ * Synchronous drawing (must NOT be used in WM_PAINT).
+ * Calls UPDOWN_Draw.
+ */
+static void UPDOWN_Refresh (WND *wndPtr)
+{
+ HDC32 hdc;
+
+ hdc = GetDC32 (wndPtr->hwndSelf);
+ UPDOWN_Draw (wndPtr, hdc);
+ ReleaseDC32 (wndPtr->hwndSelf, hdc);
+}
- /* clean-up */
- EndPaint32( wndPtr->hwndSelf, &ps );
+/***********************************************************************
+ * UPDOWN_Paint [Internal]
+ *
+ * Asynchronous drawing (must ONLY be used in WM_PAINT).
+ * Calls UPDOWN_Draw.
+ */
+static void UPDOWN_Paint (WND *wndPtr)
+{
+ PAINTSTRUCT32 ps;
+ HDC32 hdc;
+
+ hdc = BeginPaint32 (wndPtr->hwndSelf, &ps);
+ UPDOWN_Draw (wndPtr, hdc);
+ EndPaint32 (wndPtr->hwndSelf, &ps);
}
/***********************************************************************
@@ -355,9 +382,10 @@
/* now position the up/down */
/* Since the UDS_ALIGN* flags were used, */
/* we will pick the position and size of the window. */
+
SetWindowPos32(wndPtr->hwndSelf,0,x,budRect.top-DEFAULT_ADDTOP,DEFAULT_WIDTH,
(budRect.bottom-budRect.top)+DEFAULT_ADDTOP+DEFAULT_ADDBOT,
- SWP_NOACTIVATE|SWP_NOZORDER);
+ SWP_NOACTIVATE|SWP_NOZORDER);
return TRUE;
}
@@ -413,7 +441,8 @@
/* Also, notify it */
/* FIXME: do we need to send the notification only if
we do not have the UDS_SETBUDDYINT style set? */
- SendMessage32A(infoPtr->Buddy,
+
+ SendMessage32A(GetParent32 (wndPtr->hwndSelf),
wndPtr->dwStyle & UDS_HORZ ? WM_HSCROLL : WM_VSCROLL,
MAKELONG(incr ? SB_LINEUP : SB_LINEDOWN, infoPtr->CurVal),
wndPtr->hwndSelf);
@@ -457,7 +486,7 @@
ReleaseCapture(); /* if we still have it */
infoPtr->Flags = 0; /* get rid of any flags */
- UPDOWN_Paint(wndPtr); /* redraw the control just in case */
+ UPDOWN_Refresh (wndPtr); /* redraw the control just in case */
return TRUE;
}
@@ -505,7 +534,7 @@
infoPtr->Flags |= FLAG_MOUSEIN;
/* repaint the control */
- UPDOWN_Paint(wndPtr);
+ UPDOWN_Refresh (wndPtr);
/* process the click */
UPDOWN_DoAction(wndPtr, 1, infoPtr->Flags & FLAG_INCR);
@@ -541,7 +570,7 @@
}
/* If state changed, redraw the control */
if(temp != infoPtr->Flags)
- UPDOWN_Paint(wndPtr);
+ UPDOWN_Refresh (wndPtr);
break;
default:
@@ -562,9 +591,16 @@
switch(message)
{
- case WM_CREATE:
+ case WM_NCCREATE:
/* get rid of border, if any */
wndPtr->dwStyle &= ~WS_BORDER;
+ return TRUE;
+
+ case WM_CREATE:
+ infoPtr =
+ (UPDOWN_INFO*)HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY,
+ sizeof(UPDOWN_INFO));
+ wndPtr->wExtra[0] = (DWORD)infoPtr;
/* initialize the info struct */
infoPtr->AccelCount=0; infoPtr->AccelVect=0;
@@ -583,6 +619,10 @@
case WM_DESTROY:
if(infoPtr->AccelVect)
free(infoPtr->AccelVect);
+
+ HeapFree (GetProcessHeap (), 0, infoPtr);
+ wndPtr->wExtra[0] = 0;
+
TRACE(updown, "UpDown Ctrl destruction, hwnd=%04x\n", hwnd);
break;
@@ -785,7 +825,7 @@
}
/***********************************************************************
- * UPDOWN_Register [Internal]
+ * UPDOWN_Register [Internal]
*
* Registers the updown window class.
*/
@@ -796,10 +836,10 @@
if( GlobalFindAtom32A( UPDOWN_CLASS32A ) ) return;
ZeroMemory( &wndClass, sizeof( WNDCLASS32A ) );
- wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS | CS_VREDRAW;
+ wndClass.style = CS_GLOBALCLASS | CS_VREDRAW;
wndClass.lpfnWndProc = (WNDPROC32)UpDownWindowProc;
wndClass.cbClsExtra = 0;
- wndClass.cbWndExtra = sizeof(UPDOWN_INFO);
+ wndClass.cbWndExtra = sizeof(UPDOWN_INFO*);
wndClass.hCursor = LoadCursor32A( 0, IDC_ARROW32A );
wndClass.hbrBackground = (HBRUSH32)(COLOR_3DFACE + 1);
wndClass.lpszClassName = UPDOWN_CLASS32A;