source: trunk/src/comctl32/draglist.cpp

Last change on this file was 10097, checked in by sandervl, 22 years ago

Wine resync

File size: 4.2 KB
Line 
1/* $Id: draglist.cpp,v 1.4 2003-05-15 14:25:12 sandervl Exp $ */
2/*
3 * Drag List control
4 *
5 * Copyright 1999 Eric Kohl
6 *
7 * NOTES
8 * This is just a dummy control. An author is needed! Any volunteers?
9 * I will only improve this control once in a while.
10 * Eric <ekohl@abo.rhein-zeitung.de>
11 *
12 * TODO:
13 * - Everything.
14 */
15
16/* WINE 991212 level */
17
18#include "commctrl.h"
19#include <winnt.h>
20#include <misc.h>
21
22static DWORD dwLastScrollTime = 0;
23
24extern LPSTR COMCTL32_aSubclass; /* global subclassing atom */
25
26typedef struct {
27 WNDPROC lpOldWindowProc;
28 BOOL isUnicode;
29 UINT uMsg;
30} DRAGLIST_INFO, *LPDRAGLIST_INFO;
31
32VOID WINAPI DrawInsert (HWND hwndParent, HWND hwndLB, INT nItem)
33{
34 dprintf(("COMCTL32: DrawInsert - empty stub!"));
35}
36
37
38INT WINAPI LBItemFromPt (HWND hwndLB, POINT pt, BOOL bAutoScroll)
39{
40 RECT rcClient;
41 INT nIndex;
42 DWORD dwScrollTime;
43
44 dprintf(("COMCTL32: LBItemFromPt"));
45
46 ScreenToClient (hwndLB, &pt);
47 GetClientRect (hwndLB, &rcClient);
48 nIndex = (INT)SendMessageA (hwndLB, LB_GETTOPINDEX, 0, 0);
49
50 if (PtInRect (&rcClient, pt))
51 {
52 /* point is inside -- get the item index */
53 while (TRUE)
54 {
55 if (SendMessageA (hwndLB, LB_GETITEMRECT, nIndex, (LPARAM)&rcClient) == LB_ERR)
56 return -1;
57
58 if (PtInRect (&rcClient, pt))
59 return nIndex;
60
61 nIndex++;
62 }
63 }
64 else
65 {
66 /* point is outside */
67 if (!bAutoScroll)
68 return -1;
69
70 if ((pt.x > rcClient.right) || (pt.x < rcClient.left))
71 return -1;
72
73 if (pt.y < 0)
74 nIndex--;
75 else
76 nIndex++;
77
78 dwScrollTime = GetTickCount ();
79
80 if ((dwScrollTime - dwLastScrollTime) < 200)
81 return -1;
82
83 dwLastScrollTime = dwScrollTime;
84
85 SendMessageA (hwndLB, LB_SETTOPINDEX, (WPARAM)nIndex, 0);
86 }
87
88 return -1;
89}
90
91
92static LRESULT CALLBACK
93DRAGLIST_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
94{
95 LPDRAGLIST_INFO lpDragInfo;
96 LRESULT ret;
97 DRAGLISTINFO draglist;
98
99 lpDragInfo = (LPDRAGLIST_INFO)GetPropA(hwnd, (LPCSTR)COMCTL32_aSubclass);
100
101 // 2002-03-08 PH
102 // this will definately crash
103#ifdef __WIN32OS2__
104 if(!lpDragInfo)
105 {
106 if(IsWindowUnicode( hwnd ))
107 return DefWindowProcW(hwnd, uMsg, wParam, lParam);
108 else
109 return DefWindowProcA(hwnd, uMsg, wParam, lParam);
110 }
111#else
112 if(!lpDragInfo) {
113 if(lpDragInfo->isUnicode) {
114 return DefWindowProcW(hwnd, uMsg, wParam, lParam);
115 }
116 else return DefWindowProcA(hwnd, uMsg, wParam, lParam);
117 }
118#endif
119
120 switch(uMsg) {
121 case WM_LBUTTONDOWN:
122 draglist.uNotification = DL_BEGINDRAG;
123 draglist.hWnd = hwnd;
124 draglist.ptCursor.x = LOWORD(lParam);
125 draglist.ptCursor.y = HIWORD(lParam);
126 ret = SendMessageA(GetParent(hwnd), (UINT)lpDragInfo->uMsg, GetWindowLongA(hwnd, GWL_ID), (LPARAM)&draglist);
127 goto defaultmsg; //correct?
128
129 case WM_NCDESTROY:
130 if(lpDragInfo->isUnicode) {
131 ret = CallWindowProcW(lpDragInfo->lpOldWindowProc, hwnd, uMsg, wParam, lParam);
132 }
133 else ret = CallWindowProcA(lpDragInfo->lpOldWindowProc, hwnd, uMsg, wParam, lParam);
134
135 SetWindowLongA(hwnd, GWL_WNDPROC, (LONG)lpDragInfo->lpOldWindowProc);
136 SetPropA(hwnd, (LPCSTR)COMCTL32_aSubclass, NULL);
137 COMCTL32_Free(lpDragInfo);
138 break;
139
140defaultmsg:
141 default:
142 if(lpDragInfo->isUnicode) {
143 return CallWindowProcW(lpDragInfo->lpOldWindowProc, hwnd, uMsg, wParam, lParam);
144 }
145 else return CallWindowProcA(lpDragInfo->lpOldWindowProc, hwnd, uMsg, wParam, lParam);
146 }
147 return 0;
148}
149
150BOOL WINAPI MakeDragList (HWND hwndLB)
151{
152 LPDRAGLIST_INFO lpDragInfo;
153
154 dprintf(("COMCTL32: MakeDragList %x - partly implemented", hwndLB));
155
156 lpDragInfo = (LPDRAGLIST_INFO)COMCTL32_Alloc(sizeof(DRAGLIST_INFO));
157 if(SetPropA(hwndLB, (LPCSTR)COMCTL32_aSubclass, (HANDLE)lpDragInfo) == FALSE) {
158 COMCTL32_Free(lpDragInfo);
159 return FALSE;
160 }
161 lpDragInfo->lpOldWindowProc = (WNDPROC)SetWindowLongA(hwndLB, GWL_WNDPROC, (LONG)DRAGLIST_WindowProc);
162 lpDragInfo->isUnicode = IsWindowUnicode(hwndLB);
163 lpDragInfo->uMsg = RegisterWindowMessageA(DRAGLISTMSGSTRINGA);
164 return TRUE;
165}
Note: See TracBrowser for help on using the repository browser.