Tue Apr 5 14:36:59 1994 Bob Amstadt (bob@pooh) * [include/mdi.h] [windows/mdi.c] Use WM_PARENTNOTIFY messages to activate children. Generate WM_CHILDACTIVATE messages. Beginnings handler for maxmized child window. Clean up when children are destroyed. * [windows/message.c] [windows/nonclient.c] [windows/winpos.c] Removed code add 94/03/26. Apr 4, 94 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte) * [control/menu.c] Make mouse menu navigation working again. :-)) (be carefull, clicking outside menus (ie.: clientrect) not resolved yet) * [windows/nonclient.c] [controls/scroll.c] Bugs fix in NCTrackScrollBars(). * [misc/dos_fs.c] Bug fix in 'ToDos()' in conversion for '/', (example: '/window/' was translated to 'WINDOWs'). * [miscemu/int21.c] Function ChangeDir() extract possible drive before DOS_ChangeDir(). * [loader/library.c] [loader/wine.c] Playing around moving function GetProcAddress() and put some code in. Mon Apr 4 21:39:07 1994 Alexandre Julliard (julliard@lamisun.epfl.ch) * [misc/main.c] Better explanation of command-line options. * [objects/dib.c] Implemented SetDIBitsToDevice(). * [windows/dc.c] Bug fix in SetDCState(). * [windows/event.c] Removed WS_DISABLED handling (now done in message.c). * [windows/message.c] Added sending a WM_PARENTNOTIFY message in MSG_TranslateMouseMsg(). Use WindowFromPoint() to find the window for mouse events, taking into account disabled windows. * [windows/painting.c] Bug fix in BeginPaint() to allow calling it at other times than on WM_PAINT (Solitaire needs it...) * [windows/win.c] Implemented FindWindow(). Rewritten EnableWindow() to behave more like Windows. * [windows/winpos.c] Rewritten WindowFromPoint() to also search child windows. Mon Apr 4 17:36:32 1994 Erik Bos (erik@trashcan.hacktic.nl) * [include/int21.h] -> [msdos.h] renamed. * [miscemu/int10.h] [miscemu/int25.h] [miscemu/int26.h] new, added for int 10, 25 and 26. * [miscemu/ioports.c] new, added to allow win apps to use ioports. * [loader/signal.c] Added support for in, inb, out, outb instructions. Sun Mar 27 13:40:25 1994 Bob Amstadt (bob@pooh) * controls/menu.c (InsertMenu): Changed to use FindMenuItem(). Sat Mar 26 21:23:55 1994 Bob Amstadt (bob@pooh) * [windows/mdi.c] Window list properly updated. * [windows/message.c] Call WINPOS_ChildActivate() when mouse pressed. * [windows/nonclient.c] Use WINPOS_IsAnActiveWindow() instead of GetActiveWindow() in NC_HandleNCPaint(). * [windows/winpos.c] Created functions WINPOS_IsAnActiveWindow() and WINPOS_ActivateChild() Thu Mar 24 14:49:17 1994 Bob Amstadt (bob@pooh) * controls/menu.c (DeleteMenu): Changed to use FindMenuItem (DeleteMenu): Many bug fixes. * [controls/menu.c] Created function FindMenuItem(). Thu Mar 24 14:17:24 1994 Bob Amstadt (bob@pooh) * [windows/win.c] Removed incorrect MDI handling code from CreateWindowEx(). * [controls/menu.c] MF_STRING items needed to allocate a private copy of string. * [controls/menu.c] Fixed buggy calls to GlobalFree(). * [memory/global.c] Eliminated some redundant code with function call. Wed Mar 23 1994 Pentti Moilanen (pentti.moilanen@ntc.nokia.com) * [windows/timer.c] timer list pointers looped in InsertTimer Tue Mar 29 13:32:08 MET DST 1994 julliard@di.epfl.ch (Alexandre Julliard) * [misc/cursor.c] A few changes for desktop window support. * [misc/main.c] Added -depth option. * [misc/rect.c] Yet another bug fix in SubtractRect(). * [objects/bitmap.c] Changes to use only one depth (specified with -depth) for color bitmaps. * [objects/brush.c] Added support for dithered solid brushes. * [objects/color.c] Use the same 20 system colors as in Windows. System palette initialisation now done in COLOR_InitPalette(). Added support for a color mapping table to map logical color indexes to X colormap entries. Implemented GetNearestColor() and RealizeDefaultPalette(). * [objects/dib.c] Added support for color mapping table. * [objects/dither.c] (New file) Implemented solid color dithering. * [objects/palette.c] Implemented GetSystemPaletteEntries() and SelectPalette(). * [windows/class.c] Make a copy of the menu name in RegisterClass(). * [windows/dc.c] Fixed device caps when using a desktop window. Added support for the color mapping table in DCs. * [windows/event.c] Added ConfigureNotify handler on desktop window. * [windows/message.c] Removed call to XTranslateCoordinates() on every mouse motion New function MSG_Synchronize() to synchronize with the X server. * [windows/syscolor.c] Rewritten SYSCOLOR_Init() to read the system colors from WIN.INI. * [windows/winpos.c] Added synchronization on window mapping. Solves the double redraw problem when starting Solitaire. Mar 27, 94 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte) * [control/menu.c] * [windows/defwnd.c] Make keyboard navigation working with menubar, but temporarely inserted a bug in menubar mouse handling ... :-(( (it will be fix next week !) * [windows/defwnd.c] Connect VK_MENU to menubar navigation. * [loader/library.c] GetModuleHandle() return 'fictive 0xF000+ handles' for built-in DLLs. Sun Mar 20 22:32:13 1994 Erik Bos (erik@trashcan.hacktic.nl) * [misc/main.c] Added Copy(). Added a check for `-h' to show usage. * [misc/dos_fs.c] Fixed bug in FindFile(), to load directories as dlls. * [misc/dos_fs.c] Fixed ToUnix() and ToDos() again, as my previous patch didn't make it. * [misc/dos_fs.c] [miscemu/int21.c] Bug fixes, should be able to handle all winfile and progman int21 requests now except for a few small things. Tue Mar 29 06:25:54 1994 crw@harris.mlb.semi.harris.com (Carl Williams) * [memory/heap.c] Implemented GetFreeSystemResources(). Mon Mar 21 17:32:25 1994 Bob Amstadt (bob@pooh) * controls/menu.c (GetSubMenu): Function did not return correct value * [windows/mdi.c] Beginnings of menu handling. Thu Mar 10 11:32:06 1994 Stefan (SAM) Muenzel (muenzel@tat.physik.uni-tuebingen.de) * [objects/font.c] if font.width equals zero use asterix instead. Mon Mar 21 17:23:37 MET 1994 julliard@di.epfl.ch (Alexandre Julliard) * [objects/bitmap.c] Rewritten bitmap code to use exclusively X pixmaps; *much* faster. * [objects/brush.c] Some changes with pattern brushes because of the new bitmap code. * [objects/color.c] Added function COLOR_ToPhysical for better color mapping. * [objects/dib.c] Heavily optimized SetDIBits(). * [windows/dc.c] Opimized SetDCState() and DC_SetupGC*() functions. Added stub for CreateIC(). Mar 20, 94 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte) * [misc/message.c] Call SetFocus() after closing box to give back focus to previous owner. * [misc/files.c] Small bug fix in GetTempFilename() : replace a '\' to '\\'. * [control/scroll.c] Calls to BitBlt() replace by StretchBlt(). * [control/menu.c] Call SetFocus() to previous owner after closing Popups. Fill stub DeleteMenu(). * [control/listbox.c] * [control/combo.c] Use SetFocus() in WM_LBUTTONDOWN. Close ComboBox List upon WM_KILLFOCUS. Early development of WM_MEASUREITEM mecanism. * [windows/defwnd.c] Early development of WM_MEASUREITEM mecanism. Tue Mar 22 10:44:57 1994 Miguel de Icaza (miguel@xochitl) * [misc/atom.c] Fixed sintaxis problem when building the library. Tue Mar 15 13:11:56 1994 Bob Amstadt (bob@pooh) * [include/windows.h] Added message types and structures for MDI * [include/mdi.h] Created internal structures for handling MDI * [windows/mdi.c] Began creating MDI support Thu Mar 10 16:51:46 1994 Bob Amstadt (bob@pooh) * [loader/wine.c] [include/wine.h] Added new field to "struct w_files" to hold the "name table" resource for Windows 3.0 programs * [loader/resource.c] Added code to handle programs with a "name table" resource. LoadResourceByName() modified to check for the existence of this resource. Mon Mar 14 22:31:42 MET 1994 julliard@di.epfl.ch (Alexandre Julliard) * [objects/color.c] Added installing the private colormap on the desktop window. * [windows/event.c] Cleaned up focus event handling (see focus.c). Use GetFocus() to direct key events to the correct window. * [windows/focus.c] Rewritten SetFocus() to: - only set X focus on top-level windows - send WM_SETFOCUS and WM_KILLFOCUS messages (was done in event.c) - prevent setting focus to disabled windows - install private colormap so -privatemap option works again * [windows/message.c] [windows/timer.c] Changed timer management to no longer use PostMessage(), but to generate timer messages on the fly. Also fixed a related bug in GetMessage() which could cause busy-waiting. * [windows/win.c] Only select focus events on top-level windows. * [windows/winpos.c] Added some sanity checks for desktop window. Fri Mar 4 20:42:01 1994 Erik Bos (erik@trashcan.hacktic.nl) * [misc/dos_fs.c] bug fixes in ToUnix(), WinIniFileName(), GetUnixFileName(). Support for tilde symbol added for rootdirectories in [drives] section of wine's configfile. * [misc/file.c] hread(), hwrite() added. * [misc/main.c] hmemcpy() added. * [if1632/stress.spec] [include/stress.h] [misc/stress.c] Added STRESS.DLL, an useless dll used to stress a windows system. * [*/*] Added missing #includes, fixed prototypes for prototype checking. * [include/prototypes.h] Added prototypes for loader/*c, if1632/*c. Tue Mar 8 09:54:34 1994 Bob Amstadt (bob@pooh) * [Configure] Added reminder to set WINEPATH, if it is not set. * [Imakefile] Removed #elif's * [controls/button.c] Added BN_CLICKED notification for owner-draw buttons. * [if1632/kernel.spec] [memory/heap.c] Changed Local* functions to WIN16_Local* to prevent unconcious use of these functions. * [if1632/relay.c] Push old Stack16Frame on stack before setting. * [include/atom.h] [misc/atom.c] [include/heap.h] [memory/local.c] Added multiple local heap handling in Atom* functions. * [include/regfunc.h] [miscemu/int21.c] Rewrote DOS3Call() use context frame that is already on the stack. * [misc/profile.c] Fixed to allow leading ";" to mark comments. * [misc/spy.c] Fixed bugs and added support for "include" and "exclude" filters. * [misc/user.c] Rearranged calls in InitApp(). * [misc/font.c] Fixed font handling to create system fonts, if they are used. * [windows/dc.c] If text drawn on window with no font specified, then default the font to the system font. Mon Mar 7 20:32:09 MET 1994 julliard@di.epfl.ch (Alexandre Julliard) * [controls/desktop.c] Added handling of WM_NCCREATE and WM_ERASEBKGND functions. Implemented SetDeskPattern(). * [misc/main.c] Added -desktop option to get a large desktop window with everything inside it. Added -name option. * [misc/rect.c] Bug fix in SubtractRect(). * [objects/*.c] Replaced the DefaultRootWindow() macro by the rootWindow variable. * [windows/event.c] [windows/message.c] [windows/nonclient.c] [windows/win.c] A few changes to accomodate the new desktop window. Tue Mar 8 11:13:03 1994 Miguel de Icaza (miguel@xochitl.nuclecu.unam.mx) * [toolkit/arch.c] --New file-- Routines for converting little endian data structures to big-endian data structures, currently only BITMAP structures are converted. * [misc/atom.c] When used as part of the WineLib, the code is much simpler. Doesn't depend on alignement. * [loader/wine.c] Ifdefed Emulator dependent code if compiling WineLib. * [loader/resource.c] Moved misc/resource.c to loader/resource.c. * [loader/dump.c,ldt.c,ldtlib.c,library,c,selector.c,signal.c] Ifdefed whole code if compiling WINELIB. * [include/winsock.h] Added compilation define to allow compilation on SunOS. * [include/wine.h] Removed load_typeinfo and load_nameinfo prototypes, they belong to neexe.h * [include/neexe.h] Added load_typeinfo and load_nameinfo prototypes. * [include/arch.h] Fixed some bugs in the conversion routines. Added macros for Bitmap loading. Tue Mar 8 12:52:05 1994 crw@maniac.mlb.semi.harris.com (Carl Williams) * [if1632/kernel.spec] [memory/global.c] Implemented GetFreeSpace() * [if1632/user.spec] [loader/resource.c] Implemented CreateIcon()
735 lines
20 KiB
C
735 lines
20 KiB
C
/*
|
|
* Interface code to SCROLLBAR widget
|
|
*
|
|
* Copyright Martin Ayotte, 1993
|
|
*
|
|
*/
|
|
|
|
/*
|
|
#define DEBUG_SCROLL
|
|
*/
|
|
static char Copyright[] = "Copyright Martin Ayotte, 1993";
|
|
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <sys/types.h>
|
|
#include <sys/stat.h>
|
|
#include "windows.h"
|
|
#include "sysmetrics.h"
|
|
#include "scroll.h"
|
|
#include "heap.h"
|
|
#include "win.h"
|
|
#include "prototypes.h"
|
|
|
|
HBITMAP hUpArrow = 0;
|
|
HBITMAP hDnArrow = 0;
|
|
HBITMAP hLfArrow = 0;
|
|
HBITMAP hRgArrow = 0;
|
|
HBITMAP hUpArrowD = 0;
|
|
HBITMAP hDnArrowD = 0;
|
|
HBITMAP hLfArrowD = 0;
|
|
HBITMAP hRgArrowD = 0;
|
|
|
|
LPHEADSCROLL ScrollBarGetWindowAndStorage(HWND hWnd, WND **wndPtr);
|
|
LPHEADSCROLL ScrollBarGetStorageHeader(HWND hWnd);
|
|
LPHEADSCROLL GetScrollObjectStruct(HWND hWnd, int nBar);
|
|
void ScrollBarButtonDown(HWND hWnd, int nBar, int x, int y);
|
|
void ScrollBarButtonUp(HWND hWnd, int nBar, int x, int y);
|
|
void ScrollBarMouseMove(HWND hWnd, int nBar, WORD wParam, int x, int y);
|
|
void StdDrawScrollBar(HWND hWnd, HDC hDC, int nBar, LPRECT lprect, LPHEADSCROLL lphs);
|
|
int CreateScrollBarStruct(HWND hWnd);
|
|
void NC_CreateScrollBars(HWND hWnd);
|
|
LPHEADSCROLL AllocScrollBar(DWORD dwStyle, int width, int height);
|
|
|
|
|
|
/***********************************************************************
|
|
* WIDGETS_ScrollBarWndProc
|
|
*/
|
|
LONG ScrollBarWndProc( HWND hWnd, WORD message, WORD wParam, LONG lParam )
|
|
{
|
|
WORD wRet;
|
|
short x, y;
|
|
short width, height;
|
|
WND *wndPtr;
|
|
LPHEADSCROLL lphs;
|
|
PAINTSTRUCT ps;
|
|
HDC hDC;
|
|
BITMAP bm;
|
|
RECT rect, rect2;
|
|
static RECT rectsel;
|
|
switch(message)
|
|
{
|
|
case WM_CREATE:
|
|
CreateScrollBarStruct(hWnd);
|
|
#ifdef DEBUG_SCROLL
|
|
printf("ScrollBar Creation !\n");
|
|
#endif
|
|
return 0;
|
|
case WM_DESTROY:
|
|
lphs = ScrollBarGetWindowAndStorage(hWnd, &wndPtr);
|
|
if (lphs == 0) return 0;
|
|
#ifdef DEBUG_SCROLL
|
|
printf("ScrollBar WM_DESTROY %lX !\n", lphs);
|
|
#endif
|
|
free(lphs);
|
|
*((LPHEADSCROLL *)&wndPtr->wExtra[1]) = 0;
|
|
return 0;
|
|
|
|
case WM_LBUTTONDOWN:
|
|
SetCapture(hWnd);
|
|
ScrollBarButtonDown(hWnd, SB_CTL, LOWORD(lParam), HIWORD(lParam));
|
|
break;
|
|
case WM_LBUTTONUP:
|
|
ReleaseCapture();
|
|
ScrollBarButtonUp(hWnd, SB_CTL, LOWORD(lParam), HIWORD(lParam));
|
|
break;
|
|
|
|
case WM_MOUSEMOVE:
|
|
ScrollBarMouseMove(hWnd, SB_CTL, wParam, LOWORD(lParam), HIWORD(lParam));
|
|
break;
|
|
case WM_KEYDOWN:
|
|
case WM_KEYUP:
|
|
case WM_CHAR:
|
|
lphs = ScrollBarGetWindowAndStorage(hWnd, &wndPtr);
|
|
return(SendMessage(wndPtr->hwndParent, message, wParam, lParam));
|
|
|
|
case WM_TIMER:
|
|
#ifdef DEBUG_SCROLL
|
|
printf("ScrollBar WM_TIMER wParam=%X lParam=%lX !\n", wParam, lParam);
|
|
#endif
|
|
lphs = ScrollBarGetWindowAndStorage(hWnd, &wndPtr);
|
|
KillTimer(hWnd, wParam);
|
|
switch(lphs->ButtonDown) {
|
|
case 0:
|
|
lphs->TimerPending = FALSE;
|
|
return 0;
|
|
case 1:
|
|
case 3:
|
|
SendMessage(wndPtr->hwndParent, lphs->Direction,
|
|
SB_LINEUP, MAKELONG(0, hWnd));
|
|
break;
|
|
case 2:
|
|
case 4:
|
|
SendMessage(wndPtr->hwndParent, lphs->Direction,
|
|
SB_LINEDOWN, MAKELONG(0, hWnd));
|
|
break;
|
|
case 5:
|
|
SendMessage(wndPtr->hwndParent, lphs->Direction,
|
|
SB_PAGEUP, MAKELONG(0, hWnd));
|
|
break;
|
|
case 6:
|
|
SendMessage(wndPtr->hwndParent, lphs->Direction,
|
|
SB_PAGEDOWN, MAKELONG(0, hWnd));
|
|
break;
|
|
}
|
|
SetTimer(hWnd, 1, 100, NULL);
|
|
return 0;
|
|
|
|
case WM_PAINT:
|
|
hDC = BeginPaint(hWnd, &ps);
|
|
lphs = ScrollBarGetStorageHeader(hWnd);
|
|
if (lphs != NULL) {
|
|
GetClientRect(hWnd, &rect);
|
|
StdDrawScrollBar(hWnd, hDC, SB_CTL, &rect, lphs);
|
|
}
|
|
EndPaint(hWnd, &ps);
|
|
break;
|
|
default:
|
|
return DefWindowProc( hWnd, message, wParam, lParam );
|
|
}
|
|
return(0);
|
|
}
|
|
|
|
|
|
|
|
void ScrollBarButtonDown(HWND hWnd, int nBar, int x, int y)
|
|
{
|
|
LPHEADSCROLL lphs;
|
|
HWND hWndParent;
|
|
RECT rect, rect2;
|
|
int width, height;
|
|
LONG dwOwner;
|
|
lphs = GetScrollObjectStruct(hWnd, nBar);
|
|
if (nBar == SB_CTL) {
|
|
hWndParent = GetParent(hWnd);
|
|
dwOwner = MAKELONG(0, lphs->hWndOwner);
|
|
#ifdef DEBUG_SCROLL
|
|
printf("ScrollBarButtonDown SB_CTL // x=%d y=%d\n", x, y);
|
|
#endif
|
|
}
|
|
else {
|
|
hWndParent = hWnd;
|
|
dwOwner = 0L;
|
|
#ifdef DEBUG_SCROLL
|
|
printf("ScrollBarButtonDown SB_?SCROLL // x=%d y=%d\n", x, y);
|
|
#endif
|
|
}
|
|
/*
|
|
SetFocus(lphs->hWndOwner);
|
|
*/
|
|
CopyRect(&rect, &lphs->rect);
|
|
#ifdef DEBUG_SCROLL
|
|
printf("ScrollDown / x=%d y=%d left=%d top=%d right=%d bottom=%d \n",
|
|
x, y, rect.left, rect.top, rect.right, rect.bottom);
|
|
#endif
|
|
if (lphs->Direction == WM_VSCROLL) {
|
|
width = rect.right - rect.left;
|
|
if (y < (lphs->CurPix + width)) {
|
|
if (y < width) {
|
|
lphs->ButtonDown = 1;
|
|
CopyRect(&rect2, &rect);
|
|
rect2.bottom = rect2.top + width;
|
|
InvalidateRect(lphs->hWndOwner, &rect2, TRUE);
|
|
#ifdef DEBUG_SCROLL
|
|
printf("ScrollBarButtonDown send SB_LINEUP\n");
|
|
#endif
|
|
SendMessage(hWndParent, lphs->Direction,
|
|
SB_LINEUP, dwOwner);
|
|
}
|
|
else {
|
|
lphs->ButtonDown = 5;
|
|
#ifdef DEBUG_SCROLL
|
|
printf("ScrollBarButtonDown send SB_PAGEUP\n");
|
|
#endif
|
|
SendMessage(hWndParent, lphs->Direction,
|
|
SB_PAGEUP, dwOwner);
|
|
}
|
|
}
|
|
if (y > (lphs->CurPix + (width << 1))) {
|
|
if (y > (rect.bottom - rect.top - width)) {
|
|
lphs->ButtonDown = 2;
|
|
CopyRect(&rect2, &rect);
|
|
rect2.top = rect2.bottom - width;
|
|
InvalidateRect(lphs->hWndOwner, &rect2, TRUE);
|
|
#ifdef DEBUG_SCROLL
|
|
printf("ScrollBarButtonDown send SB_LINEDOWN\n");
|
|
#endif
|
|
SendMessage(hWndParent, lphs->Direction,
|
|
SB_LINEDOWN, dwOwner);
|
|
}
|
|
else {
|
|
lphs->ButtonDown = 6;
|
|
#ifdef DEBUG_SCROLL
|
|
printf("ScrollBarButtonDown send SB_PAGEDOWN\n");
|
|
#endif
|
|
SendMessage(hWndParent, lphs->Direction,
|
|
SB_PAGEDOWN, dwOwner);
|
|
}
|
|
}
|
|
if ((y > (lphs->CurPix + width)) &&
|
|
(y < (lphs->CurPix + (width << 1)))) {
|
|
lphs->ThumbActive = TRUE;
|
|
#ifdef DEBUG_SCROLL
|
|
printf("THUMB DOWN !\n");
|
|
#endif
|
|
}
|
|
}
|
|
else {
|
|
height = rect.bottom - rect.top;
|
|
if (x < (lphs->CurPix + height)) {
|
|
if (x < height) {
|
|
lphs->ButtonDown = 3;
|
|
CopyRect(&rect2, &rect);
|
|
rect2.right = rect2.left + height;
|
|
InvalidateRect(lphs->hWndOwner, &rect2, TRUE);
|
|
#ifdef DEBUG_SCROLL
|
|
printf("ScrollBarButtonDown send SB_LINEUP\n");
|
|
#endif
|
|
SendMessage(hWndParent, lphs->Direction,
|
|
SB_LINEUP, dwOwner);
|
|
}
|
|
else {
|
|
lphs->ButtonDown = 5;
|
|
#ifdef DEBUG_SCROLL
|
|
printf("ScrollBarButtonDown send SB_PAGEUP\n");
|
|
#endif
|
|
SendMessage(hWndParent, lphs->Direction,
|
|
SB_PAGEUP, dwOwner);
|
|
}
|
|
}
|
|
if (x > (lphs->CurPix + (height << 1))) {
|
|
if (x > (rect.right - rect.left - height)) {
|
|
lphs->ButtonDown = 4;
|
|
CopyRect(&rect2, &rect);
|
|
rect2.left = rect2.right - height;
|
|
InvalidateRect(lphs->hWndOwner, &rect2, TRUE);
|
|
#ifdef DEBUG_SCROLL
|
|
printf("ScrollBarButtonDown send SB_LINEDOWN\n");
|
|
#endif
|
|
SendMessage(hWndParent, lphs->Direction,
|
|
SB_LINEDOWN, dwOwner);
|
|
}
|
|
else {
|
|
lphs->ButtonDown = 6;
|
|
#ifdef DEBUG_SCROLL
|
|
printf("ScrollBarButtonDown send SB_PAGEDOWN\n");
|
|
#endif
|
|
SendMessage(hWndParent, lphs->Direction,
|
|
SB_PAGEDOWN, dwOwner);
|
|
}
|
|
}
|
|
if ((x > (lphs->CurPix + height)) &&
|
|
(x < (lphs->CurPix + (height << 1)))) {
|
|
lphs->ThumbActive = TRUE;
|
|
#ifdef DEBUG_SCROLL
|
|
printf("THUMB DOWN !\n");
|
|
#endif
|
|
}
|
|
}
|
|
if (lphs->ButtonDown != 0) {
|
|
UpdateWindow(lphs->hWndOwner);
|
|
if (!lphs->TimerPending && nBar == SB_CTL) {
|
|
lphs->TimerPending = TRUE;
|
|
SetTimer(lphs->hWndOwner, 1, 500, NULL);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
void ScrollBarButtonUp(HWND hWnd, int nBar, int x, int y)
|
|
{
|
|
LPHEADSCROLL lphs;
|
|
RECT rect, rect2;
|
|
HDC hDC;
|
|
#ifdef DEBUG_SCROLL
|
|
printf("ScrollBarButtonUp // x=%d y=%d\n", x, y);
|
|
#endif
|
|
lphs = GetScrollObjectStruct(hWnd, nBar);
|
|
lphs->ThumbActive = FALSE;
|
|
if (lphs->ButtonDown != 0) {
|
|
lphs->ButtonDown = 0;
|
|
GetClientRect(lphs->hWndOwner, &rect);
|
|
if (nBar == SB_CTL) {
|
|
InvalidateRect(lphs->hWndOwner, &rect, TRUE);
|
|
UpdateWindow(lphs->hWndOwner);
|
|
}
|
|
else {
|
|
hDC = GetWindowDC(lphs->hWndOwner);
|
|
StdDrawScrollBar(lphs->hWndOwner, hDC, nBar, &lphs->rect, lphs);
|
|
ReleaseDC(lphs->hWndOwner, hDC);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
void ScrollBarMouseMove(HWND hWnd, int nBar, WORD wParam, int x, int y)
|
|
{
|
|
LPHEADSCROLL lphs;
|
|
HWND hWndParent;
|
|
HWND hWndOwner;
|
|
LONG dwOwner;
|
|
if ((wParam & MK_LBUTTON) == 0) return;
|
|
lphs = GetScrollObjectStruct(hWnd, nBar);
|
|
if (lphs->ThumbActive == 0) return;
|
|
if (nBar == SB_CTL) {
|
|
hWndParent = GetParent(hWnd);
|
|
hWndOwner = lphs->hWndOwner;
|
|
#ifdef DEBUG_SCROLL
|
|
printf("ScrollBarButtonMove SB_CTL // x=%d y=%d\n", x, y);
|
|
#endif
|
|
}
|
|
else {
|
|
hWndParent = hWnd;
|
|
hWndOwner = 0;
|
|
#ifdef DEBUG_SCROLL
|
|
printf("ScrollBarButtonMove SB_?SCROLL // x=%d y=%d\n", x, y);
|
|
#endif
|
|
}
|
|
if (lphs->Direction == WM_VSCROLL) {
|
|
int butsiz = lphs->rect.right - lphs->rect.left;
|
|
y = y - butsiz - (butsiz >> 1);
|
|
}
|
|
else {
|
|
int butsiz = lphs->rect.bottom - lphs->rect.top;
|
|
y = x - butsiz - (butsiz >> 1);
|
|
}
|
|
x = (y * (lphs->MaxVal - lphs->MinVal) /
|
|
lphs->MaxPix) + lphs->MinVal;
|
|
#ifdef DEBUG_SCROLL
|
|
printf("Scroll WM_MOUSEMOVE val=%d pix=%d\n", x, y);
|
|
#endif
|
|
SendMessage(hWndParent, lphs->Direction,
|
|
SB_THUMBTRACK, MAKELONG(x, hWndOwner));
|
|
}
|
|
|
|
|
|
LPHEADSCROLL ScrollBarGetWindowAndStorage(HWND hWnd, WND **wndPtr)
|
|
{
|
|
WND *Ptr;
|
|
LPHEADSCROLL lphs;
|
|
*(wndPtr) = Ptr = WIN_FindWndPtr(hWnd);
|
|
if (Ptr == 0) {
|
|
printf("Bad Window handle on ScrollBar !\n");
|
|
return 0;
|
|
}
|
|
lphs = *((LPHEADSCROLL *)&Ptr->wExtra[1]);
|
|
return lphs;
|
|
}
|
|
|
|
|
|
LPHEADSCROLL ScrollBarGetStorageHeader(HWND hWnd)
|
|
{
|
|
WND *wndPtr;
|
|
LPHEADSCROLL lphs;
|
|
wndPtr = WIN_FindWndPtr(hWnd);
|
|
if (wndPtr == 0) {
|
|
printf("Bad Window handle on ScrollBar !\n");
|
|
return 0;
|
|
}
|
|
lphs = *((LPHEADSCROLL *)&wndPtr->wExtra[1]);
|
|
return lphs;
|
|
}
|
|
|
|
|
|
|
|
void StdDrawScrollBar(HWND hWnd, HDC hDC, int nBar, LPRECT lprect, LPHEADSCROLL lphs)
|
|
{
|
|
HWND hWndParent;
|
|
HBRUSH hBrush;
|
|
HDC hMemDC;
|
|
BITMAP bm;
|
|
RECT rect;
|
|
UINT i, w, h, siz;
|
|
char C[128];
|
|
if (lphs == NULL) return;
|
|
#ifdef DEBUG_SCROLL
|
|
if (lphs->Direction == WM_VSCROLL)
|
|
printf("StdDrawScrollBar Vertical left=%d top=%d right=%d bottom=%d !\n",
|
|
lprect->left, lprect->top, lprect->right, lprect->bottom);
|
|
else
|
|
printf("StdDrawScrollBar Horizontal left=%d top=%d right=%d bottom=%d !\n",
|
|
lprect->left, lprect->top, lprect->right, lprect->bottom);
|
|
#endif
|
|
if (nBar == SB_CTL)
|
|
hWndParent = GetParent(hWnd);
|
|
else
|
|
hWndParent = lphs->hWndOwner;
|
|
hBrush = SendMessage(hWndParent, WM_CTLCOLOR, (WORD)hDC,
|
|
MAKELONG(hWnd, CTLCOLOR_SCROLLBAR));
|
|
if (hBrush == (HBRUSH)NULL) hBrush = GetStockObject(LTGRAY_BRUSH);
|
|
CopyRect(&lphs->rect, lprect);
|
|
CopyRect(&rect, lprect);
|
|
w = rect.right - rect.left;
|
|
h = rect.bottom - rect.top;
|
|
if (lphs->Direction == WM_VSCROLL)
|
|
lphs->MaxPix = h - 3 * w;
|
|
else
|
|
lphs->MaxPix = w - 3 * h;
|
|
if (lphs->MaxVal != lphs->MinVal)
|
|
lphs->CurPix = lphs->MaxPix * (abs((short)lphs->CurVal) - abs(lphs->MinVal)) /
|
|
(abs(lphs->MaxVal) - abs(lphs->MinVal));
|
|
if (lphs->CurPix > lphs->MaxPix) lphs->CurPix = lphs->MaxPix;
|
|
hMemDC = CreateCompatibleDC(hDC);
|
|
if (lphs->Direction == WM_VSCROLL) {
|
|
GetObject(hUpArrow, sizeof(BITMAP), (LPSTR)&bm);
|
|
if (lphs->ButtonDown == 1)
|
|
SelectObject(hMemDC, hUpArrowD);
|
|
else
|
|
SelectObject(hMemDC, hUpArrow);
|
|
StretchBlt(hDC, rect.left, rect.top, w, w, hMemDC,
|
|
0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);
|
|
GetObject(hDnArrow, sizeof(BITMAP), (LPSTR)&bm);
|
|
if (lphs->ButtonDown == 2)
|
|
SelectObject(hMemDC, hDnArrowD);
|
|
else
|
|
SelectObject(hMemDC, hDnArrow);
|
|
StretchBlt(hDC, rect.left, rect.bottom - w, w, w, hMemDC,
|
|
0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);
|
|
rect.top += w;
|
|
rect.bottom -= w;
|
|
}
|
|
else {
|
|
GetObject(hLfArrow, sizeof(BITMAP), (LPSTR)&bm);
|
|
if (lphs->ButtonDown == 3)
|
|
SelectObject(hMemDC, hLfArrowD);
|
|
else
|
|
SelectObject(hMemDC, hLfArrow);
|
|
StretchBlt(hDC, rect.left, rect.top, h, h, hMemDC,
|
|
0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);
|
|
GetObject(hRgArrow, sizeof(BITMAP), (LPSTR)&bm);
|
|
if (lphs->ButtonDown == 4)
|
|
SelectObject(hMemDC, hRgArrowD);
|
|
else
|
|
SelectObject(hMemDC, hRgArrow);
|
|
StretchBlt(hDC, rect.right - h, rect.top, h, h, hMemDC,
|
|
0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);
|
|
rect.left += h;
|
|
rect.right -= h;
|
|
}
|
|
DeleteDC(hMemDC);
|
|
FillRect(hDC, &rect, hBrush);
|
|
if (lphs->Direction == WM_VSCROLL)
|
|
SetRect(&rect, rect.left, rect.top + lphs->CurPix,
|
|
rect.left + w, rect.top + lphs->CurPix + w);
|
|
else
|
|
SetRect(&rect, rect.left + lphs->CurPix, rect.top,
|
|
rect.left + lphs->CurPix + h, rect.top + h);
|
|
/*
|
|
if (lphs->Direction == WM_VSCROLL)
|
|
SetRect(&rect, rect.left, rect.top + lphs->CurPix + w,
|
|
rect.left + w, rect.top + lphs->CurPix + (w << 1));
|
|
else
|
|
SetRect(&rect, rect.left + lphs->CurPix + h, rect.top,
|
|
rect.left + lphs->CurPix + (h << 1), rect.top + h);
|
|
*/
|
|
FrameRect(hDC, &rect, GetStockObject(BLACK_BRUSH));
|
|
InflateRect(&rect, -1, -1);
|
|
FillRect(hDC, &rect, GetStockObject(LTGRAY_BRUSH));
|
|
DrawReliefRect(hDC, rect, 2, 0);
|
|
InflateRect(&rect, -3, -3);
|
|
DrawReliefRect(hDC, rect, 1, 1);
|
|
}
|
|
|
|
|
|
|
|
int CreateScrollBarStruct(HWND hWnd)
|
|
{
|
|
RECT rect;
|
|
int width, height;
|
|
WND *wndPtr;
|
|
LPHEADSCROLL lphs;
|
|
wndPtr = WIN_FindWndPtr(hWnd);
|
|
width = wndPtr->rectClient.right - wndPtr->rectClient.left;
|
|
height = wndPtr->rectClient.bottom - wndPtr->rectClient.top;
|
|
if (width <= height)
|
|
lphs = AllocScrollBar(WS_VSCROLL, width, height);
|
|
else
|
|
lphs = AllocScrollBar(WS_HSCROLL, width, height);
|
|
#ifdef DEBUG_SCROLL
|
|
printf("CreateScrollBarStruct %lX !\n", lphs);
|
|
#endif
|
|
*((LPHEADSCROLL *)&wndPtr->wExtra[1]) = lphs;
|
|
lphs->hWndOwner = hWnd;
|
|
CopyRect(&lphs->rect, &wndPtr->rectClient);
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
|
|
LPHEADSCROLL AllocScrollBar(DWORD dwStyle, int width, int height)
|
|
{
|
|
LPHEADSCROLL lphs;
|
|
if (hUpArrow == (HBITMAP)NULL)
|
|
hUpArrow = LoadBitmap((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_UPARROWI));
|
|
if (hDnArrow == (HBITMAP)NULL)
|
|
hDnArrow = LoadBitmap((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_DNARROWI));
|
|
if (hLfArrow == (HBITMAP)NULL)
|
|
hLfArrow = LoadBitmap((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_LFARROWI));
|
|
if (hRgArrow == (HBITMAP)NULL)
|
|
hRgArrow = LoadBitmap((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_RGARROWI));
|
|
if (hUpArrowD == (HBITMAP)NULL)
|
|
hUpArrowD = LoadBitmap((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_UPARROWD));
|
|
if (hDnArrowD == (HBITMAP)NULL)
|
|
hDnArrowD = LoadBitmap((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_DNARROWD));
|
|
if (hLfArrowD == (HBITMAP)NULL)
|
|
hLfArrowD = LoadBitmap((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_LFARROWD));
|
|
if (hRgArrowD == (HBITMAP)NULL)
|
|
hRgArrowD = LoadBitmap((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_RGARROWD));
|
|
lphs = (LPHEADSCROLL)malloc(sizeof(HEADSCROLL));
|
|
if (lphs == 0) {
|
|
printf("Bad Memory Alloc on ScrollBar !\n");
|
|
return NULL;
|
|
}
|
|
lphs->ThumbActive = FALSE;
|
|
lphs->TimerPending = FALSE;
|
|
lphs->ButtonDown = 0;
|
|
lphs->MinVal = 0;
|
|
lphs->MaxVal = 100;
|
|
lphs->CurVal = 0;
|
|
lphs->CurPix = 0;
|
|
if (dwStyle & WS_VSCROLL) {
|
|
lphs->MaxPix = height - 3 * width;
|
|
lphs->Direction = WM_VSCROLL;
|
|
}
|
|
else {
|
|
lphs->MaxPix = width - 3 * height;
|
|
lphs->Direction = WM_HSCROLL;
|
|
}
|
|
if (lphs->MaxPix < 1) lphs->MaxPix = 1;
|
|
return lphs;
|
|
}
|
|
|
|
|
|
void NC_CreateScrollBars(HWND hWnd)
|
|
{
|
|
RECT rect;
|
|
int width, height;
|
|
WND *wndPtr;
|
|
LPHEADSCROLL lphs;
|
|
wndPtr = WIN_FindWndPtr(hWnd);
|
|
width = wndPtr->rectClient.right - wndPtr->rectClient.left;
|
|
height = wndPtr->rectClient.bottom - wndPtr->rectClient.top;
|
|
if (wndPtr->dwStyle & WS_VSCROLL) {
|
|
if (wndPtr->dwStyle & WS_HSCROLL) height -= SYSMETRICS_CYHSCROLL;
|
|
lphs = AllocScrollBar(WS_VSCROLL, SYSMETRICS_CXVSCROLL, height);
|
|
#ifdef DEBUG_SCROLL
|
|
printf("NC_CreateScrollBars Vertical %lX !\n", lphs);
|
|
#endif
|
|
lphs->hWndOwner = hWnd;
|
|
wndPtr->VScroll = lphs;
|
|
}
|
|
if (wndPtr->dwStyle & WS_HSCROLL) {
|
|
if (wndPtr->dwStyle & WS_VSCROLL) width -= SYSMETRICS_CYVSCROLL;
|
|
lphs = AllocScrollBar(WS_HSCROLL, width, SYSMETRICS_CYHSCROLL);
|
|
#ifdef DEBUG_SCROLL
|
|
printf("NC_CreateScrollBars Horizontal %lX !\n", lphs);
|
|
#endif
|
|
lphs->hWndOwner = hWnd;
|
|
wndPtr->HScroll = lphs;
|
|
}
|
|
}
|
|
|
|
|
|
/*************************************************************************
|
|
* GetScrollObjectStruct [internal]
|
|
*/
|
|
LPHEADSCROLL GetScrollObjectStruct(HWND hWnd, int nBar)
|
|
{
|
|
WND *wndPtr;
|
|
if (nBar != SB_CTL) {
|
|
wndPtr = WIN_FindWndPtr(hWnd);
|
|
if (nBar == SB_VERT) return (LPHEADSCROLL)wndPtr->VScroll;
|
|
if (nBar == SB_HORZ) return (LPHEADSCROLL)wndPtr->HScroll;
|
|
return NULL;
|
|
}
|
|
return ScrollBarGetStorageHeader(hWnd);
|
|
}
|
|
|
|
|
|
/*************************************************************************
|
|
* SetScrollPos [USER.62]
|
|
*/
|
|
int SetScrollPos(HWND hWnd, int nBar, int nPos, BOOL bRedraw)
|
|
{
|
|
LPHEADSCROLL lphs;
|
|
HDC hDC;
|
|
int nRet;
|
|
lphs = GetScrollObjectStruct(hWnd, nBar);
|
|
if (lphs == NULL) return 0;
|
|
nRet = lphs->CurVal;
|
|
lphs->CurVal = (short)nPos;
|
|
if (lphs->MaxVal != lphs->MinVal)
|
|
lphs->CurPix = lphs->MaxPix * (abs((short)nPos) - abs(lphs->MinVal)) /
|
|
(abs(lphs->MaxVal) - abs(lphs->MinVal));
|
|
if (lphs->CurPix > lphs->MaxPix) lphs->CurPix = lphs->MaxPix;
|
|
#ifdef DEBUG_SCROLL
|
|
printf("SetScrollPos val=%d pixval=%d pixmax%d\n",
|
|
(short)nPos, lphs->CurPix, lphs->MaxPix);
|
|
printf("SetScrollPos min=%d max=%d\n",
|
|
lphs->MinVal, lphs->MaxVal);
|
|
#endif
|
|
if ((bRedraw) && (IsWindowVisible(lphs->hWndOwner))) {
|
|
if (nBar == SB_CTL) {
|
|
InvalidateRect(lphs->hWndOwner, &lphs->rect, TRUE);
|
|
UpdateWindow(lphs->hWndOwner);
|
|
}
|
|
else {
|
|
if (lphs->rect.right != 0 && lphs->rect.bottom != 0) {
|
|
hDC = GetWindowDC(lphs->hWndOwner);
|
|
StdDrawScrollBar(lphs->hWndOwner, hDC, nBar, &lphs->rect, lphs);
|
|
ReleaseDC(lphs->hWndOwner, hDC);
|
|
}
|
|
}
|
|
}
|
|
return nRet;
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
* GetScrollPos [USER.63]
|
|
*/
|
|
int GetScrollPos(HWND hWnd, int nBar)
|
|
{
|
|
LPHEADSCROLL lphs;
|
|
lphs = GetScrollObjectStruct(hWnd, nBar);
|
|
if (lphs == NULL) return 0;
|
|
return lphs->CurVal;
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
* SetScrollRange [USER.64]
|
|
*/
|
|
void SetScrollRange(HWND hWnd, int nBar, int MinPos, int MaxPos, BOOL bRedraw)
|
|
{
|
|
LPHEADSCROLL lphs;
|
|
HDC hDC;
|
|
lphs = GetScrollObjectStruct(hWnd, nBar);
|
|
if (lphs == NULL) return;
|
|
lphs->MinVal = (short)MinPos;
|
|
lphs->MaxVal = (short)MaxPos;
|
|
if (lphs->MaxVal != lphs->MinVal)
|
|
lphs->CurPix = abs(lphs->MaxVal) *
|
|
(abs(lphs->CurVal) - abs(lphs->MinVal)) /
|
|
(abs(lphs->MaxVal) - abs(lphs->MinVal));
|
|
if (lphs->CurPix > lphs->MaxPix) lphs->CurPix = lphs->MaxPix;
|
|
#ifdef DEBUG_SCROLL
|
|
printf("SetScrollRange min=%d max=%d\n", lphs->MinVal, lphs->MaxVal);
|
|
#endif
|
|
if ((bRedraw) && (IsWindowVisible(lphs->hWndOwner))) {
|
|
if (nBar == SB_CTL) {
|
|
InvalidateRect(lphs->hWndOwner, &lphs->rect, TRUE);
|
|
UpdateWindow(lphs->hWndOwner);
|
|
}
|
|
else {
|
|
if (lphs->rect.right != 0 && lphs->rect.bottom != 0) {
|
|
hDC = GetWindowDC(lphs->hWndOwner);
|
|
StdDrawScrollBar(lphs->hWndOwner, hDC, nBar, &lphs->rect, lphs);
|
|
ReleaseDC(lphs->hWndOwner, hDC);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
* GetScrollRange [USER.65]
|
|
*/
|
|
void GetScrollRange(HWND hWnd, int nBar, LPINT lpMin, LPINT lpMax)
|
|
{
|
|
LPHEADSCROLL lphs;
|
|
lphs = GetScrollObjectStruct(hWnd, nBar);
|
|
if (lphs == NULL) return;
|
|
*lpMin = lphs->MinVal;
|
|
*lpMax = lphs->MaxVal;
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
* ShowScrollBar [USER.267]
|
|
*/
|
|
void ShowScrollBar(HWND hWnd, WORD wBar, BOOL bFlag)
|
|
{
|
|
WND *wndPtr;
|
|
#ifdef DEBUG_SCROLL
|
|
printf("ShowScrollBar hWnd=%04X wBar=%d bFlag=%d\n", hWnd, wBar, bFlag);
|
|
#endif
|
|
if (wBar == SB_CTL) {
|
|
if (bFlag)
|
|
ShowWindow(hWnd, SW_SHOW);
|
|
else
|
|
ShowWindow(hWnd, SW_HIDE);
|
|
return;
|
|
}
|
|
wndPtr = WIN_FindWndPtr(hWnd);
|
|
/*
|
|
if ((wBar == SB_VERT) || (wBar == SB_BOTH)) {
|
|
if (bFlag)
|
|
wndPtr->dwStyle |= WS_VSCROLL;
|
|
else
|
|
wndPtr->dwStyle &= 0xFFFFFFFFL ^ WS_VSCROLL;
|
|
}
|
|
if ((wBar == SB_HORZ) || (wBar == SB_BOTH)) {
|
|
if (bFlag)
|
|
wndPtr->dwStyle |= WS_HSCROLL;
|
|
else
|
|
wndPtr->dwStyle &= 0xFFFFFFFFL ^ WS_HSCROLL;
|
|
}
|
|
*/
|
|
}
|
|
|
|
|