1 | /*
|
---|
2 | * This file is (C) Chris Wohlgemuth 2002
|
---|
3 | * It is part of the MediaFolder package
|
---|
4 | */
|
---|
5 | /*
|
---|
6 | * This program is free software; you can redistribute it and/or modify
|
---|
7 | * it under the terms of the GNU General Public License as published by
|
---|
8 | * the Free Software Foundation; either version 2, or (at your option)
|
---|
9 | * any later version.
|
---|
10 | *
|
---|
11 | * This program is distributed in the hope that it will be useful,
|
---|
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
14 | * GNU General Public License for more details.
|
---|
15 | *
|
---|
16 | * You should have received a copy of the GNU General Public License
|
---|
17 | * along with this program; see the file COPYING. If not, write to
|
---|
18 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
19 | */
|
---|
20 | #define INCL_GPILCIDS
|
---|
21 | #define INCL_GPIPRIMITIVES
|
---|
22 | #define INCL_GPIBITMAPS
|
---|
23 | #define INCL_GPILOGCOLORTABLE
|
---|
24 | #define INCL_SW
|
---|
25 | #define INCL_GPIREGIONS
|
---|
26 |
|
---|
27 | #include "mediafolder.hh"
|
---|
28 | #include "mediafolderres.h"
|
---|
29 | #include <stdio.h>
|
---|
30 | #include <stdlib.h>
|
---|
31 |
|
---|
32 |
|
---|
33 | /* Fonts to use in dialogs */
|
---|
34 | #define DEFAULT_DIALOG_FONT "9.WarpSans"
|
---|
35 |
|
---|
36 |
|
---|
37 | PFNWP oldButtonProc2; //place for original button-procedure
|
---|
38 | HWND hwndBubbleWindow=NULLHANDLE;// The handle of the help window
|
---|
39 | #define WM_NEWBUBBLE WM_USER+100 //Use ATOM later
|
---|
40 | #define xVal 12 //x-distance of Bubble
|
---|
41 | #define yVal 8 //y-distance of Bubble
|
---|
42 |
|
---|
43 | extern HMODULE hResource;
|
---|
44 |
|
---|
45 | extern CONTROLINFO ciControls[];
|
---|
46 | extern LOADEDBITMAP allBMPs[];
|
---|
47 | extern HPOINTER hptrArrowWE; /* Pointer for slider control */
|
---|
48 |
|
---|
49 | PFNWP oldButtonProc; //place for original button-procedure
|
---|
50 | PFNWP oldStaticTextProc;
|
---|
51 | PFNWP oldStaticProc;
|
---|
52 | PFNWP oldCheckBoxProc;
|
---|
53 | PFNWP oldSliderPaintProc;
|
---|
54 | PFNWP oldPlayTimeProc;
|
---|
55 |
|
---|
56 | /* Extern */
|
---|
57 | ULONG cwQueryOSRelease();
|
---|
58 | void sendConfig();
|
---|
59 | ULONG messageBox( char* text, ULONG ulTextID , LONG lSizeText,
|
---|
60 | char* title, ULONG ulTitleID, LONG lSizeTitle,
|
---|
61 | HMODULE hResource, HWND hwnd, ULONG ulFlags);
|
---|
62 | void getMessage(char* text,ULONG ulID, LONG lSizeText, HMODULE hResource,HWND hwnd);
|
---|
63 | MRESULT cwInsertMenuItem(int iPosition, HWND hwndMenu, HWND hwndSubMenu, int iID, char * chrText);
|
---|
64 | MRESULT cwInsertMenuSeparator(int iPosition, HWND hwndMenu, HWND hwndSubMenu);
|
---|
65 | void handleWindowPosChanged(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);/* In dataCddialogProcs.cpp */
|
---|
66 | void writeLogPrintf(char* logFile, char* format, ...);
|
---|
67 |
|
---|
68 | /* Local */
|
---|
69 | MRESULT EXPENTRY staticTextProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
70 | {
|
---|
71 | switch(msg)
|
---|
72 | {
|
---|
73 | case WM_SETWINDOWPARAMS:
|
---|
74 | {
|
---|
75 | MRESULT mr;
|
---|
76 | PWNDPARAMS pwp=(PWNDPARAMS)PVOIDFROMMP(mp1);
|
---|
77 | if(pwp->fsStatus==WPM_TEXT) {
|
---|
78 | /* The control text changes. Force repaint of background by frame. */
|
---|
79 | if(WinIsWindowVisible(hwnd)) {
|
---|
80 | WinShowWindow(hwnd, FALSE);
|
---|
81 | mr=oldStaticTextProc(hwnd, msg, mp1, mp2);/* Change text */
|
---|
82 | WinShowWindow(hwnd, TRUE);/* Force painting of text */
|
---|
83 | return mr;
|
---|
84 | }
|
---|
85 | }
|
---|
86 | }
|
---|
87 | break;
|
---|
88 | case WM_PAINT:
|
---|
89 | {
|
---|
90 | HPS hps;
|
---|
91 | char text[200];
|
---|
92 |
|
---|
93 | hps=WinBeginPaint(hwnd, NULLHANDLE, NULL);
|
---|
94 | if(WinQueryWindowText(hwnd, sizeof(text), text))
|
---|
95 | {
|
---|
96 | RECTL rcl;
|
---|
97 |
|
---|
98 | WinQueryWindowRect(hwnd, &rcl);
|
---|
99 | GpiCreateLogColorTable(hps, LCOL_PURECOLOR,LCOLF_RGB, 0, 0, NULLHANDLE);
|
---|
100 | rcl.xLeft+=1;
|
---|
101 |
|
---|
102 | WinDrawText(hps, strlen(text), text, &rcl, 0x00eeeeef,0, /*DT_CENTER|*/DT_VCENTER|DT_MNEMONIC);
|
---|
103 | rcl.xLeft-=1;
|
---|
104 | rcl.yBottom+=1;
|
---|
105 | WinDrawText(hps, strlen(text),text, &rcl, 0x00333355,0,DT_VCENTER /*| DT_CENTER*//*|DT_TEXTATTRS*/);
|
---|
106 |
|
---|
107 | }
|
---|
108 | WinEndPaint(hps);
|
---|
109 | return (MRESULT) 0;
|
---|
110 | }
|
---|
111 | default:
|
---|
112 | break;
|
---|
113 | }
|
---|
114 | return oldStaticTextProc(hwnd, msg, mp1, mp2);
|
---|
115 | }
|
---|
116 |
|
---|
117 | MRESULT EXPENTRY playTimeTextProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
118 | {
|
---|
119 | switch(msg)
|
---|
120 | {
|
---|
121 | case WM_BUTTON1CLICK:
|
---|
122 | WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_APPTERMINATENOTIFY,
|
---|
123 | MPFROM2SHORT(NOTIFY_CLICK, WinQueryWindowUShort(hwnd, QWS_ID)) ,0L);
|
---|
124 | return (MRESULT)0;
|
---|
125 | case WM_CONTEXTMENU:
|
---|
126 | WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_APPTERMINATENOTIFY,
|
---|
127 | MPFROM2SHORT(NOTIFY_CONTEXT, WinQueryWindowUShort(hwnd, QWS_ID)) ,0L);
|
---|
128 | return (MRESULT)0;
|
---|
129 | case WM_PAINT:
|
---|
130 | {
|
---|
131 | HPS hps;
|
---|
132 | RECTL rcl;
|
---|
133 | char text[100];
|
---|
134 | CONTROLINFO ci;
|
---|
135 |
|
---|
136 | ci=ciControls[CTRLIDX_PLAYTIME];//ciVolSliderArm;
|
---|
137 |
|
---|
138 | hps=WinBeginPaint(hwnd, NULLHANDLE, NULL);
|
---|
139 | if(WinQueryWindowText(hwnd, sizeof(text), text))
|
---|
140 | {
|
---|
141 | POINTL ptl= {0};
|
---|
142 | WinDrawBitmap(hps, ci.hbmSource,
|
---|
143 | &ci.rclSource,
|
---|
144 | &ptl,
|
---|
145 | 0, 0,
|
---|
146 | DBM_IMAGEATTRS);
|
---|
147 | WinQueryWindowRect(hwnd,&rcl);
|
---|
148 | WinDrawText(hps, strlen(text),text, &rcl,0,0,DT_CENTER|DT_VCENTER|DT_TEXTATTRS);
|
---|
149 | }
|
---|
150 | WinEndPaint(hps);
|
---|
151 | return (MRESULT) 0;
|
---|
152 | }
|
---|
153 | default:
|
---|
154 | break;
|
---|
155 | }
|
---|
156 | return oldPlayTimeProc(hwnd, msg, mp1, mp2);
|
---|
157 | }
|
---|
158 |
|
---|
159 |
|
---|
160 | /* This function paints all our controls with the provided bitmaps */
|
---|
161 | /* It's called from the guiproc */
|
---|
162 | MRESULT paintControls(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
163 | {
|
---|
164 | USERBUTTON* ubPtr;
|
---|
165 | CONTROLINFO ci;
|
---|
166 | RECTL rcl;
|
---|
167 | SWP swp;
|
---|
168 |
|
---|
169 | ubPtr=(USERBUTTON*)PVOIDFROMMP(mp2);
|
---|
170 | switch(SHORT1FROMMP(mp1))
|
---|
171 | {
|
---|
172 | case IDPB_SKIPFORWARD:
|
---|
173 | if(ubPtr->fsState==BDS_DEFAULT||!ubPtr->fsState)
|
---|
174 | ci=ciControls[CTRLIDX_SKIPFWDBUTTON];
|
---|
175 | else {
|
---|
176 | ci=ciControls[CTRLIDX_SKIPFWDBUTTONSEL];
|
---|
177 | }
|
---|
178 | break;
|
---|
179 | case IDPB_SKIPBACK:
|
---|
180 | if(ubPtr->fsState==BDS_DEFAULT||!ubPtr->fsState)
|
---|
181 | ci=ciControls[CTRLIDX_SKIPBACKBUTTON];
|
---|
182 | else {
|
---|
183 | ci=ciControls[CTRLIDX_SKIPBACKBUTTONSEL];
|
---|
184 | }
|
---|
185 | break;
|
---|
186 | case IDPB_PLAY:
|
---|
187 | if(ubPtr->fsState==BDS_DEFAULT||!ubPtr->fsState)
|
---|
188 | ci=ciControls[CTRLIDX_PLAYBUTTON];
|
---|
189 | else {
|
---|
190 | ci=ciControls[CTRLIDX_PLAYBUTTONSEL];
|
---|
191 | }
|
---|
192 | break;
|
---|
193 | case IDPB_PAUSE:
|
---|
194 | if(ubPtr->fsState==BDS_DEFAULT||!ubPtr->fsState)
|
---|
195 | ci=ciControls[CTRLIDX_PAUSEBUTTON];
|
---|
196 | else {
|
---|
197 | ci=ciControls[CTRLIDX_PAUSEBUTTONSEL];
|
---|
198 | }
|
---|
199 | break;
|
---|
200 | case IDPB_STOP:
|
---|
201 | if(ubPtr->fsState==BDS_DEFAULT||!ubPtr->fsState)
|
---|
202 | ci=ciControls[CTRLIDX_STOPBUTTON];
|
---|
203 | else {
|
---|
204 | ci=ciControls[CTRLIDX_STOPBUTTONSEL];
|
---|
205 | }
|
---|
206 | break;
|
---|
207 | case IDPB_POSBAR:
|
---|
208 | ci=ciControls[CTRLIDX_POSSLIDER];//ciPosSlider;
|
---|
209 | break;
|
---|
210 | case IDPB_SLIDERARM:
|
---|
211 | ci=ciControls[CTRLIDX_POSSLIDERARM];//ciPosSliderArm;
|
---|
212 | break;
|
---|
213 | case IDSL_VOLUME:
|
---|
214 | ci=ciControls[CTRLIDX_VOLSLIDER];//ciVolSlider;
|
---|
215 | break;
|
---|
216 | case IDSL_VOLUMEARM:
|
---|
217 | if(WinQueryCapture(HWND_DESKTOP==hwnd))
|
---|
218 | ci=ciControls[CTRLIDX_VOLSLIDERARMSEL];//ciVolSliderArm;
|
---|
219 | else
|
---|
220 | ci=ciControls[CTRLIDX_VOLSLIDERARM];//ciVolSliderArm;
|
---|
221 | break;
|
---|
222 | default:
|
---|
223 | return (MRESULT)0;
|
---|
224 | }
|
---|
225 | rcl.yBottom=0;
|
---|
226 | rcl.xLeft=0;
|
---|
227 | WinDrawBitmap(ubPtr->hps, ci.hbmSource,
|
---|
228 | &ci.rclSource,
|
---|
229 | (PPOINTL)&rcl,
|
---|
230 | 0, 0,
|
---|
231 | DBM_IMAGEATTRS);
|
---|
232 | if(ubPtr->fsStateOld!=ubPtr->fsState)
|
---|
233 | ubPtr->fsState =( ubPtr->fsStateOld==BDS_DEFAULT ? BDS_HILITED : BDS_DEFAULT);
|
---|
234 | return (MRESULT)0;
|
---|
235 | }
|
---|
236 |
|
---|
237 | /* This function paints all our controls with the provided bitmaps. */
|
---|
238 | BOOL paintHilitedControl(HWND hwnd, USHORT usControl, BOOL bHilite)
|
---|
239 | {
|
---|
240 | CONTROLINFO ci;
|
---|
241 | RECTL rcl;
|
---|
242 | SWP swp;
|
---|
243 | HPS hps;
|
---|
244 | static ULONG ulShowFeedback=0;
|
---|
245 |
|
---|
246 | if(!ulShowFeedback) {
|
---|
247 | /* Query the INI setting*/
|
---|
248 | if(!PrfQueryProfileInt(HINI_USERPROFILE, APPKEY_CWMM, MFLDR_NO_VISUAL_FEEDBACK, 0))
|
---|
249 | ulShowFeedback=1; /* Flash play controls */
|
---|
250 | else
|
---|
251 | ulShowFeedback=2; /* Don't flash play controls while playing */
|
---|
252 | }
|
---|
253 |
|
---|
254 | if(ulShowFeedback==2)
|
---|
255 | return 1;
|
---|
256 |
|
---|
257 | switch(usControl)
|
---|
258 | {
|
---|
259 | case IDPB_PLAY:
|
---|
260 | if(!bHilite) {
|
---|
261 | ci=ciControls[CTRLIDX_PLAYBUTTON];
|
---|
262 | }
|
---|
263 | else {
|
---|
264 | ci=ciControls[CTRLIDX_PLAYBUTTONSEL];
|
---|
265 | }
|
---|
266 | break;
|
---|
267 | case IDPB_PAUSE:
|
---|
268 | if(!bHilite) {
|
---|
269 | ci=ciControls[CTRLIDX_PAUSEBUTTON];
|
---|
270 | }
|
---|
271 | else {
|
---|
272 | ci=ciControls[CTRLIDX_PAUSEBUTTONSEL];
|
---|
273 | }
|
---|
274 | break;
|
---|
275 | default:
|
---|
276 | return 0;
|
---|
277 | }
|
---|
278 | rcl.yBottom=0;
|
---|
279 | rcl.xLeft=0;
|
---|
280 | hps=WinGetPS(hwnd);
|
---|
281 | WinDrawBitmap(hps, ci.hbmSource,
|
---|
282 | &ci.rclSource,
|
---|
283 | (PPOINTL)&rcl,
|
---|
284 | 0, 0,
|
---|
285 | DBM_IMAGEATTRS);
|
---|
286 | WinReleasePS(hps);
|
---|
287 | return 1;
|
---|
288 | }
|
---|
289 |
|
---|
290 | /* This proc handles the custom painting for check boxes */
|
---|
291 | MRESULT EXPENTRY checkBoxProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
292 | {
|
---|
293 |
|
---|
294 | switch(msg)
|
---|
295 | {
|
---|
296 | case WM_DESTROY:
|
---|
297 | {
|
---|
298 | MFLDRCTRLDATA * mFldrCtrlData=(MFLDRCTRLDATA *) WinQueryWindowULong(hwnd,QWL_USER);;
|
---|
299 |
|
---|
300 | if(!mFldrCtrlData)
|
---|
301 | free(mFldrCtrlData);
|
---|
302 | break;
|
---|
303 | }
|
---|
304 | case WM_PAINT:
|
---|
305 | {
|
---|
306 | short checkState;
|
---|
307 | BOOL bHighLite;
|
---|
308 | HPS hps;
|
---|
309 | RECTL rcl;
|
---|
310 | char text[100];
|
---|
311 | CONTROLINFO ci;
|
---|
312 | MFLDRCTRLDATA * mFldrCtrlData=(MFLDRCTRLDATA *) WinQueryWindowULong(hwnd,QWL_USER);
|
---|
313 |
|
---|
314 | checkState = SHORT1FROMMR(WinSendMsg(hwnd,BM_QUERYCHECK,NULL,NULL));
|
---|
315 | bHighLite = LONGFROMMR(WinSendMsg(hwnd,BM_QUERYHILITE,NULL,NULL));
|
---|
316 | if(checkState==0) {
|
---|
317 | /* unchecked */
|
---|
318 | if(mFldrCtrlData)
|
---|
319 | mFldrCtrlData->bPreviousCheckState=0;
|
---|
320 | if(bHighLite)
|
---|
321 | ci=ciControls[CTRLIDX_UNCHECKSEL];
|
---|
322 | else
|
---|
323 | ci=ciControls[CTRLIDX_UNCHECK];//ciVolSliderArm;
|
---|
324 | }
|
---|
325 | else if(checkState==1) {
|
---|
326 | /* checked */
|
---|
327 | if(mFldrCtrlData)
|
---|
328 | mFldrCtrlData->bPreviousCheckState=1;
|
---|
329 | if(bHighLite)
|
---|
330 | ci=ciControls[CTRLIDX_CHECKSEL];
|
---|
331 | else
|
---|
332 | ci=ciControls[CTRLIDX_CHECK];
|
---|
333 | }
|
---|
334 |
|
---|
335 | WinQueryWindowRect(hwnd, &rcl);
|
---|
336 | hps=WinBeginPaint(hwnd, NULLHANDLE, NULL);
|
---|
337 | if(WinQueryWindowText(hwnd, sizeof(text), text))
|
---|
338 | {
|
---|
339 | POINTL ptl= {0};
|
---|
340 | ULONG ulPos;
|
---|
341 | char text2[120];
|
---|
342 | ptl.y=(rcl.yTop-ci.rclSource.yTop)/2;
|
---|
343 |
|
---|
344 | WinDrawBitmap(hps, ci.hbmSource,
|
---|
345 | NULL,//&ci.rclSource,
|
---|
346 | &ptl,
|
---|
347 | 0, 0,
|
---|
348 | DBM_IMAGEATTRS);
|
---|
349 | // WinQueryWindowRect(hwnd,&rcl);
|
---|
350 | rcl.xLeft+=ci.rclSource.xRight+2;
|
---|
351 | GpiCreateLogColorTable(hps, LCOL_PURECOLOR,LCOLF_RGB, 0, 0, NULLHANDLE);
|
---|
352 | rcl.xLeft+=1;
|
---|
353 | /* Get mnemonic */
|
---|
354 | if(mFldrCtrlData && (ulPos=mFldrCtrlData->ulMnemonicPos) & 0x00010000){
|
---|
355 | ulPos&=0x0000FFFF;
|
---|
356 | strncpy(text2,text,ulPos);
|
---|
357 | text2[ulPos]=0;
|
---|
358 | strcat(text2,"~");
|
---|
359 | strcat(text2,&text[ulPos]);
|
---|
360 | WinDrawText(hps, strlen(text2), text2, &rcl, 0x00eeeeef,0, DT_VCENTER|DT_MNEMONIC);
|
---|
361 | rcl.xLeft-=1;
|
---|
362 | rcl.yBottom+=1;
|
---|
363 | WinDrawText(hps, strlen(text2), text2, &rcl, 0x00333355,0,/*DT_TEXTATTRS|*/DT_VCENTER|DT_MNEMONIC);
|
---|
364 | }
|
---|
365 | else {
|
---|
366 | WinDrawText(hps, strlen(text), text, &rcl, 0x00eeeeef,0, DT_VCENTER|DT_MNEMONIC);
|
---|
367 | rcl.xLeft-=1;
|
---|
368 | rcl.yBottom+=1;
|
---|
369 | WinDrawText(hps, strlen(text),text, &rcl, 0x00333355,0,DT_VCENTER/*|DT_TEXTATTRS*/);
|
---|
370 | }
|
---|
371 | }/* WinQueryWindowText() */
|
---|
372 | // if(WinQueryFocus(HWND_DESKTOP)==hwnd)
|
---|
373 | // WinSetFocus(HWND_DESKTOP, hwnd);
|
---|
374 | WinEndPaint(hps);
|
---|
375 | return (MRESULT) 0;
|
---|
376 | }
|
---|
377 | case BM_SETHILITE:
|
---|
378 | case BM_SETDEFAULT:
|
---|
379 | case BM_SETCHECK:
|
---|
380 | {
|
---|
381 | MRESULT mr;
|
---|
382 | WinEnableWindowUpdate(hwnd, FALSE);
|
---|
383 | mr=oldCheckBoxProc(hwnd, msg, mp1, mp2);
|
---|
384 | WinEnableWindowUpdate(hwnd, TRUE);
|
---|
385 | WinInvalidateRect(hwnd, NULL,TRUE);
|
---|
386 | return mr;
|
---|
387 | }
|
---|
388 | default:
|
---|
389 | break;
|
---|
390 | }
|
---|
391 | return oldCheckBoxProc(hwnd, msg, mp1, mp2);
|
---|
392 | }
|
---|
393 | MRESULT EXPENTRY sliderPaintProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
394 | {
|
---|
395 |
|
---|
396 | switch(msg)
|
---|
397 | {
|
---|
398 | case WM_PAINT:
|
---|
399 | {
|
---|
400 | short checkState;
|
---|
401 | HPS hps;
|
---|
402 | RECTL rcl, rcl2;
|
---|
403 | char text[100];
|
---|
404 | CONTROLINFO ci;
|
---|
405 | MRESULT mr;
|
---|
406 |
|
---|
407 | hps=WinBeginPaint(hwnd, NULLHANDLE, NULL);
|
---|
408 | WinQueryWindowRect(hwnd, &rcl);
|
---|
409 | WinValidateRect(hwnd,&rcl,TRUE);
|
---|
410 |
|
---|
411 | mr=oldSliderPaintProc(hwnd, msg, mp1, mp2);
|
---|
412 |
|
---|
413 | rcl2=rcl;
|
---|
414 | hps=WinGetPS(hwnd);
|
---|
415 | rcl2.yBottom=rcl2.yTop-5;
|
---|
416 | WinFillRect(hps,&rcl2, CLR_BLUE);
|
---|
417 | rcl2=rcl;
|
---|
418 | rcl2.yTop=rcl2.yBottom+5;
|
---|
419 | WinFillRect(hps,&rcl2, CLR_BLUE);
|
---|
420 | WinEndPaint(hps);
|
---|
421 | return mr;
|
---|
422 | }
|
---|
423 | case WM_APPTERMINATENOTIFY:
|
---|
424 | {
|
---|
425 | HPS hps;
|
---|
426 | RECTL rcl,rcl2;
|
---|
427 |
|
---|
428 | WinQueryWindowRect(hwnd, &rcl);
|
---|
429 | rcl2=rcl;
|
---|
430 | hps=WinGetPS(hwnd);
|
---|
431 | rcl2.yBottom=rcl2.yTop-5;
|
---|
432 | WinFillRect(hps,&rcl2, CLR_BLUE);
|
---|
433 | rcl2=rcl;
|
---|
434 | rcl2.yTop=rcl2.yBottom+5;
|
---|
435 | WinFillRect(hps,&rcl2, CLR_BLUE);
|
---|
436 |
|
---|
437 | WinReleasePS(hps);
|
---|
438 | return (MRESULT) TRUE;
|
---|
439 | }
|
---|
440 | default:
|
---|
441 | break;
|
---|
442 | }
|
---|
443 | return oldSliderPaintProc(hwnd, msg, mp1, mp2);
|
---|
444 | }
|
---|
445 |
|
---|
446 |
|
---|
447 | #define USERSLIDER 1 /* Set to 0 to let the proc paint the control. With set to 1
|
---|
448 | a WM_DRAWITEM msg is sent to the parent. */
|
---|
449 | BOOL userSlider=USERSLIDER;
|
---|
450 | #define SLOFFSET 3 /* The offset of the active slider area to the window border */
|
---|
451 | MRESULT EXPENTRY privateSliderProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
452 | {
|
---|
453 |
|
---|
454 | switch (msg)
|
---|
455 | {
|
---|
456 | case WM_CREATE:
|
---|
457 | {
|
---|
458 | PCREATESTRUCT pCreate=(CREATESTRUCT*)PVOIDFROMMP(mp2);
|
---|
459 |
|
---|
460 | /* Initialize the slider data */
|
---|
461 | WinSetWindowUShort(hwnd, SLIDERARMWIDTH,20);
|
---|
462 | WinSetWindowUShort(hwnd, SLIDERARMHEIGHT,10);
|
---|
463 | WinSetWindowUShort(hwnd, SLINCREMENTS,100);
|
---|
464 | /* Dimensions of slider. The slider active area is smaller than the window to
|
---|
465 | allow drawing of active state. */
|
---|
466 | WinSetWindowULong(hwnd, SLIDERCX,pCreate->cx-2*SLOFFSET);
|
---|
467 | WinSetWindowULong(hwnd, SLIDERCY,pCreate->cy-2*SLOFFSET);
|
---|
468 | WinSetWindowULong(hwnd, SLIDERX,SLOFFSET);
|
---|
469 | WinSetWindowULong(hwnd, SLIDERY,SLOFFSET);
|
---|
470 | WinSetWindowULong(hwnd, SLIDERARMPOS, 0);
|
---|
471 | WinSetWindowULong(hwnd, SLDRAGGING,FALSE);
|
---|
472 |
|
---|
473 | return (MRESULT)0;
|
---|
474 | }
|
---|
475 | case SLM_SETSLIDERINFO:
|
---|
476 | switch(SHORT1FROMMP(mp1))
|
---|
477 | {
|
---|
478 | case SMA_SLIDERARMPOSITION:
|
---|
479 | /* SMA_RANGEVALUE */
|
---|
480 | if(!WinQueryWindowULong(hwnd, SLDRAGGING)) {
|
---|
481 | if(SHORT2FROMMP(mp1)==SMA_RANGEVALUE) {
|
---|
482 | WinSetWindowULong(hwnd, SLIDERARMPOS, LONGFROMMP(mp2));
|
---|
483 | WinInvalidateRect(hwnd, NULLHANDLE,TRUE);
|
---|
484 | return (MRESULT)0;
|
---|
485 | }
|
---|
486 | else if(SHORT2FROMMP(mp1)==SMA_INCREMENTVALUE) {
|
---|
487 | LONG lInc=LONGFROMMP(mp2)*(WinQueryWindowULong(hwnd, SLIDERCX)-WinQueryWindowUShort(hwnd, SLIDERARMWIDTH));
|
---|
488 | lInc/=WinQueryWindowUShort(hwnd, SLINCREMENTS);
|
---|
489 | WinSetWindowULong(hwnd, SLIDERARMPOS, lInc);
|
---|
490 | WinInvalidateRect(hwnd, NULLHANDLE,TRUE);
|
---|
491 | return (MRESULT)0;
|
---|
492 | }
|
---|
493 | }
|
---|
494 | break;
|
---|
495 | case SMA_SLIDERARMDIMENSIONS:
|
---|
496 | WinSetWindowUShort(hwnd, SLIDERARMWIDTH, SHORT1FROMMP(mp2));
|
---|
497 | WinSetWindowUShort(hwnd, SLIDERARMHEIGHT, SHORT2FROMMP(mp2));
|
---|
498 | return (MRESULT)0;
|
---|
499 | default:
|
---|
500 | break;
|
---|
501 | }
|
---|
502 | break;
|
---|
503 | case WM_SIZE:
|
---|
504 | WinSetWindowULong(hwnd, SLIDERCX, SHORT1FROMMP(mp2)-2*SLOFFSET);
|
---|
505 | WinSetWindowULong(hwnd, SLIDERCY, SHORT2FROMMP(mp2)-2*SLOFFSET);
|
---|
506 | WinInvalidateRect(hwnd, NULLHANDLE,TRUE);
|
---|
507 | return (MRESULT)0;
|
---|
508 | case WM_BUTTON1DOWN:
|
---|
509 | {
|
---|
510 | SHORT x=SHORT1FROMMP( mp1);
|
---|
511 | SHORT y=SHORT2FROMMP( mp1);
|
---|
512 | LONG lPos=WinQueryWindowULong(hwnd, SLIDERARMPOS);
|
---|
513 | USHORT usWidth=WinQueryWindowUShort(hwnd, SLIDERARMWIDTH);
|
---|
514 |
|
---|
515 | if(x<=lPos+usWidth+SLOFFSET && x>=lPos+SLOFFSET &&
|
---|
516 | y<=WinQueryWindowUShort(hwnd, SLIDERY)+WinQueryWindowUShort(hwnd, SLIDERCY)
|
---|
517 | && y>=WinQueryWindowUShort(hwnd, SLIDERY)) {
|
---|
518 | WinSetWindowUShort(hwnd, PTRPOSINSLARM, x-lPos-SLOFFSET);
|
---|
519 | }
|
---|
520 | WinSetFocus(HWND_DESKTOP, hwnd);
|
---|
521 | break;
|
---|
522 | }
|
---|
523 |
|
---|
524 | case WM_FOCUSCHANGE:
|
---|
525 | {
|
---|
526 | HPS hps;
|
---|
527 | RECTL rcl;
|
---|
528 | POINTL ptl;
|
---|
529 |
|
---|
530 | if(SHORT1FROMMP(mp2)) {
|
---|
531 | hps=WinGetPS(hwnd);
|
---|
532 | WinQueryWindowRect(hwnd, &rcl);
|
---|
533 | GpiSetLineType(hps, LINETYPE_DOT);
|
---|
534 | ptl.x=rcl.xLeft;
|
---|
535 | ptl.y=rcl.yBottom;
|
---|
536 | GpiMove(hps,&ptl);
|
---|
537 | ptl.x=rcl.xRight-1;
|
---|
538 | GpiLine(hps,&ptl);
|
---|
539 | ptl.y=rcl.yTop-1;
|
---|
540 | GpiLine(hps,&ptl);
|
---|
541 | ptl.x=rcl.xLeft;
|
---|
542 | GpiLine(hps,&ptl);
|
---|
543 | ptl.y=rcl.yBottom;
|
---|
544 | GpiLine(hps,&ptl);
|
---|
545 | WinReleasePS(hps);
|
---|
546 | }
|
---|
547 | else
|
---|
548 | WinInvalidateRect(hwnd, NULLHANDLE,TRUE);
|
---|
549 |
|
---|
550 | break;
|
---|
551 | }
|
---|
552 | case WM_CHAR:
|
---|
553 | if(WinQueryFocus(HWND_DESKTOP)==hwnd) {
|
---|
554 | if(SHORT2FROMMP(mp2)==VK_TAB && (SHORT1FROMMP(mp1) & KC_VIRTUALKEY))
|
---|
555 | if(SHORT1FROMMP(mp1) & (KC_KEYUP|KC_PREVDOWN))
|
---|
556 | return (MRESULT)TRUE;
|
---|
557 |
|
---|
558 | #if 0
|
---|
559 | /**/
|
---|
560 | if(SHORT2FROMMP(mp2)==VK_RIGHT && (SHORT1FROMMP(mp1) & KC_VIRTUALKEY))
|
---|
561 | /* if(SHORT1FROMMP(mp1) & (KC_KEYUP|KC_PREVDOWN))*/ {
|
---|
562 | DosBeep(5000, 100);
|
---|
563 | return (MRESULT)TRUE;
|
---|
564 | }
|
---|
565 | if(SHORT2FROMMP(mp2)==VK_LEFT && (SHORT1FROMMP(mp1) & KC_VIRTUALKEY))
|
---|
566 | if(SHORT1FROMMP(mp1) & (KC_KEYUP|KC_PREVDOWN)) {
|
---|
567 | DosBeep(500, 100);
|
---|
568 | return (MRESULT)TRUE;
|
---|
569 | }
|
---|
570 | #endif
|
---|
571 |
|
---|
572 | return WinDefWindowProc(hwnd, msg, mp1, mp2);
|
---|
573 | }
|
---|
574 |
|
---|
575 | #if 0
|
---|
576 | if(WinQueryFocus(HWND_DESKTOP)==hwnd) {
|
---|
577 | /* We have the focus */
|
---|
578 | if((SHORT1FROMMP(mp1) & (KC_VIRTUALKEY))==(KC_VIRTUALKEY)) {
|
---|
579 | LONG lPos=WinQueryWindowULong(hwnd, SLIDERARMPOS);
|
---|
580 | USHORT usWidth=WinQueryWindowUShort(hwnd, SLIDERARMWIDTH);
|
---|
581 | ULONG ulCx=WinQueryWindowULong(hwnd, SLIDERCX);
|
---|
582 |
|
---|
583 | switch(SHORT2FROMMP(mp2))
|
---|
584 | {
|
---|
585 | case VK_RIGHT:
|
---|
586 | if(SHORT1FROMMP(mp1) & (KC_KEYUP|KC_PREVDOWN)) {
|
---|
587 | lPos+=1;
|
---|
588 | if(lPos>ulCx-usWidth)
|
---|
589 | lPos=ulCx-usWidth;
|
---|
590 | else {
|
---|
591 | WinPostMsg( hwnd,
|
---|
592 | SLM_SETSLIDERINFO,
|
---|
593 | MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_RANGEVALUE),
|
---|
594 | MPFROMLONG( (LONG) lPos ));
|
---|
595 | lPos=(lPos*100)/(WinQueryWindowULong(hwnd, SLIDERCX)-WinQueryWindowUShort(hwnd, SLIDERARMWIDTH));
|
---|
596 |
|
---|
597 | WinPostMsg( WinQueryWindow(hwnd, QW_PARENT),WM_CONTROL,
|
---|
598 | MPFROM2SHORT(WinQueryWindowUShort(hwnd, QWS_ID), SLN_CHANGE),
|
---|
599 | MPFROMLONG(lPos));
|
---|
600 |
|
---|
601 | if(SHORT1FROMMP(mp1) & KC_LONEKEY) {
|
---|
602 | /* Post SLN_CHANGE notification */
|
---|
603 | WinPostMsg( WinQueryWindow(hwnd, QW_PARENT),WM_CONTROL,
|
---|
604 | MPFROM2SHORT(WinQueryWindowUShort(hwnd, QWS_ID), SLN_CHANGE),
|
---|
605 | MPFROMLONG(lPos));
|
---|
606 | WinSetWindowULong(hwnd, SLDRAGGING, FALSE);
|
---|
607 | }
|
---|
608 | else {
|
---|
609 | WinSetWindowULong(hwnd, SLDRAGGING, TRUE);
|
---|
610 | /* Post SLN_SLIDERTRACK notification */
|
---|
611 | WinPostMsg(WinQueryWindow(hwnd, QW_PARENT),WM_CONTROL,
|
---|
612 | MPFROM2SHORT(WinQueryWindowUShort(hwnd, QWS_ID), SLN_SLIDERTRACK),
|
---|
613 | MPFROMLONG(lPos));
|
---|
614 | }
|
---|
615 |
|
---|
616 | }
|
---|
617 | WinSetWindowULong(hwnd, SLIDERARMPOS, lPos);
|
---|
618 | }
|
---|
619 | return (MRESULT)TRUE;
|
---|
620 | case VK_LEFT:
|
---|
621 | if(SHORT1FROMMP(mp1) & (KC_KEYUP|KC_PREVDOWN)) {
|
---|
622 | lPos-=1;
|
---|
623 | if(lPos<0) {
|
---|
624 | lPos=0;
|
---|
625 | }
|
---|
626 | else {
|
---|
627 | WinPostMsg( hwnd,
|
---|
628 | SLM_SETSLIDERINFO,
|
---|
629 | MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_RANGEVALUE),
|
---|
630 | MPFROMLONG( (LONG) lPos ));
|
---|
631 | lPos=(lPos*100)/(WinQueryWindowULong(hwnd, SLIDERCX)-WinQueryWindowUShort(hwnd, SLIDERARMWIDTH));
|
---|
632 | /* Post SLN_CHANGE notification */
|
---|
633 | WinPostMsg( WinQueryWindow(hwnd, QW_PARENT),WM_CONTROL,
|
---|
634 | MPFROM2SHORT(WinQueryWindowUShort(hwnd, QWS_ID), SLN_CHANGE),
|
---|
635 | MPFROMLONG(lPos));
|
---|
636 |
|
---|
637 | if(SHORT1FROMMP(mp1) & KC_LONEKEY) {
|
---|
638 | /* Post SLN_CHANGE notification */
|
---|
639 | WinPostMsg( WinQueryWindow(hwnd, QW_PARENT),WM_CONTROL,
|
---|
640 | MPFROM2SHORT(WinQueryWindowUShort(hwnd, QWS_ID), SLN_CHANGE),
|
---|
641 | MPFROMLONG(lPos));
|
---|
642 | WinSetWindowULong(hwnd, SLDRAGGING, FALSE);
|
---|
643 | }
|
---|
644 | else {
|
---|
645 | WinSetWindowULong(hwnd, SLDRAGGING, TRUE);
|
---|
646 | /* Post SLN_SLIDERTRACK notification */
|
---|
647 | WinPostMsg(WinQueryWindow(hwnd, QW_PARENT),WM_CONTROL,
|
---|
648 | MPFROM2SHORT(WinQueryWindowUShort(hwnd, QWS_ID), SLN_SLIDERTRACK),
|
---|
649 | MPFROMLONG(lPos));
|
---|
650 | }
|
---|
651 |
|
---|
652 | }
|
---|
653 | WinSetWindowULong(hwnd, SLIDERARMPOS, lPos);
|
---|
654 |
|
---|
655 | }
|
---|
656 | return (MRESULT)TRUE;
|
---|
657 | default:
|
---|
658 | break;
|
---|
659 | }
|
---|
660 | }
|
---|
661 |
|
---|
662 | }
|
---|
663 | #endif
|
---|
664 | break;
|
---|
665 | case WM_BUTTON1MOTIONSTART:
|
---|
666 | {
|
---|
667 | SHORT x=SHORT1FROMMP( mp1);
|
---|
668 | SHORT y=SHORT2FROMMP( mp1);
|
---|
669 | LONG lPos=WinQueryWindowULong(hwnd, SLIDERARMPOS);
|
---|
670 | USHORT usWidth=WinQueryWindowUShort(hwnd, SLIDERARMWIDTH);
|
---|
671 |
|
---|
672 | if(x<=lPos+usWidth+SLOFFSET && x>=lPos+SLOFFSET &&
|
---|
673 | y<=WinQueryWindowUShort(hwnd, SLIDERY)+WinQueryWindowUShort(hwnd, SLIDERCY)
|
---|
674 | && y>=WinQueryWindowUShort(hwnd, SLIDERY)){
|
---|
675 | // if(x<=lPos+usWidth && y<=WinQueryWindowUShort(hwnd, SLIDERY)+WinQueryWindowUShort(hwnd, SLIDERCY)
|
---|
676 | // && y>=WinQueryWindowUShort(hwnd, SLIDERY)) {
|
---|
677 | WinSetWindowULong(hwnd, SLDRAGGING, TRUE);
|
---|
678 | if(hptrArrowWE)
|
---|
679 | WinSetPointer(HWND_DESKTOP, hptrArrowWE);
|
---|
680 |
|
---|
681 | WinSetCapture(HWND_DESKTOP, hwnd);
|
---|
682 | }
|
---|
683 | break;
|
---|
684 | }
|
---|
685 | case WM_BUTTON1MOTIONEND:
|
---|
686 | if(WinQueryWindowULong(hwnd, SLDRAGGING)) {
|
---|
687 | LONG lPos=WinQueryWindowULong(hwnd, SLIDERARMPOS);
|
---|
688 | WinSetWindowULong(hwnd, SLDRAGGING,FALSE);
|
---|
689 | WinSetCapture(HWND_DESKTOP, NULLHANDLE);
|
---|
690 | lPos=(lPos*100)/(WinQueryWindowULong(hwnd, SLIDERCX)-WinQueryWindowUShort(hwnd, SLIDERARMWIDTH));
|
---|
691 | /* Post SLN_CHANGE notification */
|
---|
692 | WinPostMsg(WinQueryWindow(hwnd, QW_PARENT),WM_CONTROL, MPFROM2SHORT(WinQueryWindowUShort(hwnd, QWS_ID), SLN_CHANGE),
|
---|
693 | MPFROMLONG(lPos));
|
---|
694 | }
|
---|
695 | break;
|
---|
696 |
|
---|
697 | case WM_MOUSEMOVE:
|
---|
698 | if(WinQueryWindowULong(hwnd, SLDRAGGING)) {
|
---|
699 | HPS hps;
|
---|
700 | RECTL rcl, rcl2, rcl3;
|
---|
701 | LONG lTemp;
|
---|
702 | SHORT x=SHORT1FROMMP(mp1);
|
---|
703 | LONG lPos=WinQueryWindowULong(hwnd, SLIDERARMPOS);
|
---|
704 | USHORT usWidth=WinQueryWindowUShort(hwnd, SLIDERARMWIDTH);
|
---|
705 |
|
---|
706 | lTemp=lPos;
|
---|
707 |
|
---|
708 | rcl.xLeft=WinQueryWindowULong(hwnd, SLIDERX);
|
---|
709 | rcl.yBottom=WinQueryWindowULong(hwnd, SLIDERY);
|
---|
710 | rcl.xRight=rcl.xLeft+WinQueryWindowULong(hwnd, SLIDERCX);
|
---|
711 | rcl.yTop=rcl.yBottom+WinQueryWindowULong(hwnd, SLIDERCY);
|
---|
712 |
|
---|
713 | rcl2=rcl3=rcl;
|
---|
714 | rcl.xLeft=x-WinQueryWindowUShort(hwnd, PTRPOSINSLARM);
|
---|
715 | if(rcl.xLeft<rcl2.xLeft)/* Make sure we stop at the left border */
|
---|
716 | rcl.xLeft=rcl2.xLeft;
|
---|
717 |
|
---|
718 | rcl.xRight=rcl.xLeft+usWidth;
|
---|
719 | if(rcl.xRight>rcl2.xRight)
|
---|
720 | {/* Make sure we stop at the right border */
|
---|
721 | rcl.xRight=rcl2.xRight;
|
---|
722 | rcl.xLeft=rcl.xRight-usWidth;
|
---|
723 | }
|
---|
724 | lPos=rcl.xLeft-WinQueryWindowULong(hwnd, SLIDERX);/* Save position zero based */
|
---|
725 | WinSetWindowULong(hwnd, SLIDERARMPOS, lPos);
|
---|
726 | if(lPos!=lTemp) {
|
---|
727 | BOOL rc;
|
---|
728 |
|
---|
729 | hps=WinGetPS(hwnd);
|
---|
730 | /* Paint Background not necessary here */
|
---|
731 |
|
---|
732 | /* Shaft */
|
---|
733 | /* Left part */
|
---|
734 | rcl3.xRight=rcl.xLeft;
|
---|
735 |
|
---|
736 | rc=FALSE;
|
---|
737 |
|
---|
738 | if(userSlider) {
|
---|
739 | OWNERITEM oi={0};
|
---|
740 | oi.hwnd=hwnd;
|
---|
741 | oi.hps=hps;
|
---|
742 | oi.fsState=SLS_OWNERDRAW;/* More to come */
|
---|
743 | oi.rclItem=rcl3;
|
---|
744 | oi.idItem=SDA_SLIDERSHAFT;
|
---|
745 | rc=(BOOL)WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_DRAWITEM, MPFROMSHORT(WinQueryWindowUShort(hwnd, QWS_ID)),
|
---|
746 | MPFROMP(&oi) );
|
---|
747 | }
|
---|
748 | if(!rc)
|
---|
749 | WinFillRect(hps, &rcl3, CLR_GREEN);
|
---|
750 |
|
---|
751 | /* Right part */
|
---|
752 | rcl3.xRight=rcl2.xRight;
|
---|
753 | rcl3.xLeft=rcl.xRight;
|
---|
754 | rc=FALSE;
|
---|
755 | if(userSlider) {
|
---|
756 | OWNERITEM oi={0};
|
---|
757 | oi.hwnd=hwnd;
|
---|
758 | oi.hps=hps;
|
---|
759 | oi.fsState=SLS_OWNERDRAW;/* More to come */
|
---|
760 | oi.rclItem=rcl3;
|
---|
761 | oi.idItem=SDA_SLIDERSHAFT;
|
---|
762 | rc=(BOOL)WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_DRAWITEM, MPFROMSHORT(WinQueryWindowUShort(hwnd, QWS_ID)),
|
---|
763 | MPFROMP(&oi) );
|
---|
764 | }
|
---|
765 | if(!rc)
|
---|
766 | WinFillRect(hps, &rcl3, CLR_WHITE);
|
---|
767 |
|
---|
768 | /* Paint Slider */
|
---|
769 | rc=FALSE;
|
---|
770 | if(userSlider) {
|
---|
771 | OWNERITEM oi={0};
|
---|
772 | oi.hwnd=hwnd;
|
---|
773 | oi.hps=hps;
|
---|
774 | oi.fsState=SLS_OWNERDRAW;/* More to come */
|
---|
775 | oi.rclItem=rcl;
|
---|
776 | oi.idItem=SDA_SLIDERARM;
|
---|
777 | rc=(BOOL)WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_DRAWITEM, MPFROMSHORT(WinQueryWindowUShort(hwnd, QWS_ID)),
|
---|
778 | MPFROMP(&oi) );
|
---|
779 |
|
---|
780 | }
|
---|
781 | if(!rc)
|
---|
782 | {
|
---|
783 | WinFillRect(hps,&rcl, CLR_BLUE);
|
---|
784 | WinDrawBorder(hps, &rcl, 2, 2, 0, 0 ,0x0400);
|
---|
785 | }
|
---|
786 |
|
---|
787 | WinReleasePS(hps);
|
---|
788 | lPos=(lPos*100)/(WinQueryWindowULong(hwnd, SLIDERCX)-WinQueryWindowUShort(hwnd, SLIDERARMWIDTH));
|
---|
789 | /* Post SLN_SLIDERTRACK notification */
|
---|
790 | WinPostMsg(WinQueryWindow(hwnd, QW_PARENT),WM_CONTROL,
|
---|
791 | MPFROM2SHORT(WinQueryWindowUShort(hwnd, QWS_ID), SLN_SLIDERTRACK),
|
---|
792 | MPFROMLONG(lPos));
|
---|
793 | }
|
---|
794 | return MRTRUE;
|
---|
795 | }
|
---|
796 | else {
|
---|
797 | if(hptrArrowWE) {
|
---|
798 | /* Not dragging */
|
---|
799 | /* Change pointer to drag pointer when over the arm */
|
---|
800 | SHORT x=SHORT1FROMMP( mp1);
|
---|
801 | SHORT y=SHORT2FROMMP( mp1);
|
---|
802 | LONG lPos=WinQueryWindowULong(hwnd, SLIDERARMPOS);
|
---|
803 | USHORT usWidth=WinQueryWindowUShort(hwnd, SLIDERARMWIDTH);
|
---|
804 | if(x<=lPos+usWidth+SLOFFSET && x>=lPos+SLOFFSET &&
|
---|
805 | y<=WinQueryWindowUShort(hwnd, SLIDERY)+WinQueryWindowUShort(hwnd, SLIDERCY)
|
---|
806 | && y>=WinQueryWindowUShort(hwnd, SLIDERY)) {
|
---|
807 | WinSetPointer(HWND_DESKTOP, hptrArrowWE);
|
---|
808 | return MRTRUE;
|
---|
809 | }
|
---|
810 | }
|
---|
811 | }
|
---|
812 | break;
|
---|
813 | case WM_PAINT:
|
---|
814 | {
|
---|
815 |
|
---|
816 | HPS hps, hps2;
|
---|
817 | RECTL rcl, rcl2, rcl3;
|
---|
818 | POINTL ptl;
|
---|
819 | LONG lPos=WinQueryWindowULong(hwnd, SLIDERARMPOS);
|
---|
820 | USHORT usWidth=WinQueryWindowUShort(hwnd, SLIDERARMWIDTH);
|
---|
821 | BOOL rc;
|
---|
822 |
|
---|
823 | WinQueryWindowRect(hwnd, &rcl);
|
---|
824 |
|
---|
825 | /* Shaft */
|
---|
826 | rcl2.xLeft=WinQueryWindowULong(hwnd, SLIDERX);
|
---|
827 | rcl2.yBottom=WinQueryWindowULong(hwnd, SLIDERY);
|
---|
828 | rcl2.xRight=rcl2.xLeft+WinQueryWindowULong(hwnd, SLIDERCX)-1;
|
---|
829 | rcl2.yTop=rcl2.yBottom+WinQueryWindowULong(hwnd, SLIDERCY)-1;
|
---|
830 |
|
---|
831 | /* Background */
|
---|
832 | hps2=WinGetPS(hwnd);
|
---|
833 | GpiExcludeClipRectangle(hps2,&rcl2);
|
---|
834 | rc=FALSE;
|
---|
835 | if(userSlider) {
|
---|
836 | OWNERITEM oi={0};
|
---|
837 | oi.hwnd=hwnd;
|
---|
838 | oi.hps=hps2;
|
---|
839 | oi.fsState=SLS_OWNERDRAW;/* More to come */
|
---|
840 | oi.rclItem=rcl;
|
---|
841 | oi.idItem=SDA_BACKGROUND;
|
---|
842 | rc=(BOOL)WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_DRAWITEM, MPFROMSHORT(WinQueryWindowUShort(hwnd, QWS_ID)),
|
---|
843 | MPFROMP(&oi) );
|
---|
844 | }
|
---|
845 | if(!rc)
|
---|
846 | WinFillRect(hps2, &rcl, CLR_PALEGRAY);
|
---|
847 | /* Focus */
|
---|
848 | if(WinQueryFocus(HWND_DESKTOP)==hwnd) {
|
---|
849 | GpiSetLineType(hps2, LINETYPE_DOT);
|
---|
850 | ptl.x=rcl.xLeft;
|
---|
851 | ptl.y=rcl.yBottom;
|
---|
852 | GpiMove(hps2,&ptl);
|
---|
853 | ptl.x=rcl.xRight-1;
|
---|
854 | GpiLine(hps2,&ptl);
|
---|
855 | ptl.y=rcl.yTop-1;
|
---|
856 | GpiLine(hps2,&ptl);
|
---|
857 | ptl.x=rcl.xLeft;
|
---|
858 | GpiLine(hps2,&ptl);
|
---|
859 | ptl.y=rcl.yBottom;
|
---|
860 | GpiLine(hps2,&ptl);
|
---|
861 | }
|
---|
862 |
|
---|
863 | WinReleasePS(hps2);
|
---|
864 | rcl2.yTop+=1;
|
---|
865 | rcl2.xRight+=1;
|
---|
866 | hps=WinBeginPaint(hwnd, NULLHANDLE, NULLHANDLE);
|
---|
867 | rcl3=rcl=rcl2;
|
---|
868 | /* Arm pos */
|
---|
869 | rcl2.xLeft+=lPos;
|
---|
870 | /* Arm size */
|
---|
871 | rcl2.xRight=rcl2.xLeft+usWidth;
|
---|
872 |
|
---|
873 | /* Shaft */
|
---|
874 | /* Left part */
|
---|
875 | rcl3.xRight=rcl2.xLeft;
|
---|
876 | rc=FALSE;
|
---|
877 | if(userSlider) {
|
---|
878 | OWNERITEM oi={0};
|
---|
879 | oi.hwnd=hwnd;
|
---|
880 | oi.hps=hps;
|
---|
881 | oi.fsState=SLS_OWNERDRAW;/* More to come */
|
---|
882 | oi.rclItem=rcl3;
|
---|
883 | oi.idItem=SDA_SLIDERSHAFT;
|
---|
884 | rc=(BOOL)WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_DRAWITEM, MPFROMSHORT(WinQueryWindowUShort(hwnd, QWS_ID)),
|
---|
885 | MPFROMP(&oi) );
|
---|
886 |
|
---|
887 | }
|
---|
888 | if(!rc)
|
---|
889 | WinFillRect(hps, &rcl3, CLR_GREEN);
|
---|
890 |
|
---|
891 | /* Right part */
|
---|
892 | rcl3.xRight=rcl.xRight;
|
---|
893 | rcl3.xLeft=rcl2.xRight;
|
---|
894 | rc=FALSE;
|
---|
895 | if(userSlider) {
|
---|
896 | OWNERITEM oi={0};
|
---|
897 | oi.hwnd=hwnd;
|
---|
898 | oi.hps=hps;
|
---|
899 | oi.fsState=SLS_OWNERDRAW;/* More to come */
|
---|
900 | oi.rclItem=rcl3;
|
---|
901 | oi.idItem=SDA_SLIDERSHAFT;
|
---|
902 | rc=(BOOL)WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_DRAWITEM, MPFROMSHORT(WinQueryWindowUShort(hwnd, QWS_ID)),
|
---|
903 | MPFROMP(&oi) );
|
---|
904 | }
|
---|
905 | if(!rc)
|
---|
906 | WinFillRect(hps, &rcl3, CLR_WHITE);
|
---|
907 |
|
---|
908 | rc=FALSE;
|
---|
909 | if(userSlider) {
|
---|
910 | OWNERITEM oi={0};
|
---|
911 | oi.hwnd=hwnd;
|
---|
912 | oi.hps=hps;
|
---|
913 | oi.fsState=SLS_OWNERDRAW;/* More to come */
|
---|
914 | oi.rclItem=rcl2;
|
---|
915 | oi.idItem=SDA_SLIDERARM;
|
---|
916 | rc=(BOOL)WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_DRAWITEM, MPFROMSHORT(WinQueryWindowUShort(hwnd, QWS_ID)),
|
---|
917 | MPFROMP(&oi) );
|
---|
918 | }
|
---|
919 | if(!rc)
|
---|
920 | {
|
---|
921 | WinFillRect(hps,&rcl2, CLR_BLUE);
|
---|
922 | WinDrawBorder(hps, &rcl2, 2, 2, 0, 0 ,0x0400);
|
---|
923 | }
|
---|
924 |
|
---|
925 | WinEndPaint(hps);
|
---|
926 | return (MRESULT)0;
|
---|
927 | }
|
---|
928 | break;
|
---|
929 | default:
|
---|
930 | break;
|
---|
931 | }
|
---|
932 | return WinDefWindowProc(hwnd, msg, mp1, mp2);
|
---|
933 | }
|
---|
934 |
|
---|
935 | MRESULT drawSlider(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2, USHORT id)
|
---|
936 | {
|
---|
937 | POWNERITEM poi;
|
---|
938 | CONTROLINFO ci, ciArm;
|
---|
939 | RECTL rcl;
|
---|
940 | POINTL ptl= {0};
|
---|
941 |
|
---|
942 | poi=(POWNERITEM)PVOIDFROMMP(mp2);
|
---|
943 |
|
---|
944 | switch(id)
|
---|
945 | {
|
---|
946 | case IDSL_POSBAR:
|
---|
947 | ci=ciControls[CTRLIDX_POSSLIDER];
|
---|
948 | ciArm=ciControls[CTRLIDX_POSSLIDERARM];
|
---|
949 | break;
|
---|
950 | case IDSL_VOLUME:
|
---|
951 | ci=ciControls[CTRLIDX_VOLSLIDER];//ciVolSlider;
|
---|
952 | // if(WinQueryCapture(HWND_DESKTOP==hwnd))
|
---|
953 | ciArm=ciControls[CTRLIDX_VOLSLIDERARMSEL];//ciVolSliderArm;
|
---|
954 | // else
|
---|
955 | // ciArm=ciControls[CTRLIDX_VOLSLIDERARM];//ciVolSliderArm;
|
---|
956 | break;
|
---|
957 | default:
|
---|
958 | return (MRESULT)FALSE;
|
---|
959 | }
|
---|
960 |
|
---|
961 | switch(poi->idItem)
|
---|
962 | {
|
---|
963 | case SDA_SLIDERARM:
|
---|
964 | WinDrawBitmap(poi->hps, ciArm.hbmSource,
|
---|
965 | &ciArm.rclSource,
|
---|
966 | (PPOINTL)&poi->rclItem,
|
---|
967 | 0, 0,
|
---|
968 | DBM_IMAGEATTRS);
|
---|
969 | return (MRESULT) TRUE;
|
---|
970 | case SDA_BACKGROUND:
|
---|
971 | {
|
---|
972 | WinDrawBitmap(poi->hps,
|
---|
973 | ci.hbmSource,
|
---|
974 | &ci.rclSource,
|
---|
975 | (PPOINTL)&poi->rclItem,
|
---|
976 | 0, 0,
|
---|
977 | DBM_IMAGEATTRS);
|
---|
978 | // WinFillRect(poi->hps,&poi->rclItem, CLR_WHITE);
|
---|
979 | return (MRESULT) TRUE;
|
---|
980 | }
|
---|
981 | case SDA_SLIDERSHAFT:
|
---|
982 | {
|
---|
983 | RECTL rcl;
|
---|
984 |
|
---|
985 | rcl=ci.rclSource;
|
---|
986 | rcl.xLeft+=poi->rclItem.xLeft;
|
---|
987 | rcl.xRight=rcl.xLeft+(poi->rclItem.xRight-poi->rclItem.xLeft);
|
---|
988 | rcl.yBottom+=SLOFFSET;
|
---|
989 | rcl.yTop-=SLOFFSET;
|
---|
990 |
|
---|
991 | if(!WinDrawBitmap(poi->hps, ci.hbmSource,
|
---|
992 | &rcl,
|
---|
993 | //&ci.rclSource,
|
---|
994 | (PPOINTL)&poi->rclItem,
|
---|
995 | 0, 0,
|
---|
996 | DBM_IMAGEATTRS))
|
---|
997 | return (MRESULT)FALSE;
|
---|
998 | return (MRESULT)TRUE;
|
---|
999 | }
|
---|
1000 | default:
|
---|
1001 | return (MRESULT)TRUE;
|
---|
1002 | }
|
---|
1003 | /* Done */
|
---|
1004 | return (MRESULT)TRUE;
|
---|
1005 | }
|
---|
1006 |
|
---|
1007 | /***********************************************************/
|
---|
1008 | /* */
|
---|
1009 | /* Move the controls to the position defined by the */
|
---|
1010 | /* background bitmap. */
|
---|
1011 | /* */
|
---|
1012 | /***********************************************************/
|
---|
1013 | void adjustDialogControlPos(HWND hwnd)
|
---|
1014 | {
|
---|
1015 | CONTROLINFO ci;
|
---|
1016 | ULONG ulStyle;
|
---|
1017 | char text[CCHMAXPATH];
|
---|
1018 | ULONG ulLen;
|
---|
1019 | HWND hwndTemp;
|
---|
1020 | POINTL ptl;
|
---|
1021 | SWP swp;
|
---|
1022 |
|
---|
1023 | /* Pos slider */
|
---|
1024 | ci=ciControls[CTRLIDX_POSSLIDER];//ciPosSlider;
|
---|
1025 | WinCreateWindow(hwnd, SLIDER_CLASS, "", WS_VISIBLE | WS_TABSTOP, 0,0, 10, 10,
|
---|
1026 | hwnd, HWND_TOP, ci.id, NULLHANDLE, NULLHANDLE);
|
---|
1027 | WinSetWindowPos(WinWindowFromID(hwnd, ci.id),HWND_TOP, ci.rclSource.xLeft, ci.rclSource.yBottom,
|
---|
1028 | ci.rclSource.xRight-ci.rclSource.xLeft,
|
---|
1029 | ci.rclSource.yTop-ci.rclSource.yBottom, SWP_MOVE | SWP_SIZE);
|
---|
1030 |
|
---|
1031 | WinSendMsg(WinWindowFromID(hwnd, ci.id),SLM_SETSLIDERINFO,
|
---|
1032 | MPFROM2SHORT(SMA_SLIDERARMDIMENSIONS,0),
|
---|
1033 | MPFROM2SHORT( 9, 9));
|
---|
1034 | /* Vol slider */
|
---|
1035 | ci=ciControls[CTRLIDX_VOLSLIDER];//ciVolSlider;
|
---|
1036 | WinCreateWindow(hwnd, SLIDER_CLASS, "", WS_VISIBLE | WS_TABSTOP, 0,0, 10, 10,
|
---|
1037 | hwnd, HWND_TOP, ci.id, NULLHANDLE, NULLHANDLE);
|
---|
1038 | WinSetWindowPos(WinWindowFromID(hwnd, ci.id),HWND_TOP, ci.rclSource.xLeft, ci.rclSource.yBottom,
|
---|
1039 | ci.rclSource.xRight-ci.rclSource.xLeft,
|
---|
1040 | ci.rclSource.yTop-ci.rclSource.yBottom, SWP_MOVE | SWP_SIZE);
|
---|
1041 | WinSendMsg(WinWindowFromID(hwnd, ci.id),SLM_SETSLIDERINFO,
|
---|
1042 | MPFROM2SHORT(SMA_SLIDERARMDIMENSIONS,0),
|
---|
1043 | MPFROM2SHORT( 9, 9));
|
---|
1044 | /* Playtime text */
|
---|
1045 | ci=ciControls[CTRLIDX_PLAYTIME];
|
---|
1046 | WinSetWindowPos(WinWindowFromID(hwnd, ci.id),HWND_TOP, ci.rclSource.xLeft,ci.rclSource.yBottom,
|
---|
1047 | ci.rclSource.xRight-ci.rclSource.xLeft,
|
---|
1048 | ci.rclSource.yTop-ci.rclSource.yBottom, SWP_MOVE|SWP_SIZE);
|
---|
1049 | oldPlayTimeProc=WinSubclassWindow(WinWindowFromID(hwnd, IDST_PLAYTIME), playTimeTextProc);
|
---|
1050 | /* Skip back button */
|
---|
1051 | ci=ciControls[CTRLIDX_SKIPBACKBUTTON];
|
---|
1052 | ulStyle=WinQueryWindowULong(WinWindowFromID(hwnd, ci.id),QWL_STYLE);
|
---|
1053 | WinSetWindowULong(WinWindowFromID(hwnd, ci.id),QWL_STYLE,ulStyle|BS_USERBUTTON);
|
---|
1054 | WinSetWindowPos(WinWindowFromID(hwnd, ci.id),HWND_TOP, ci.rclDest.xLeft , ci.rclDest.yBottom,
|
---|
1055 | ci.rclDest.xRight-ci.rclDest.xLeft,
|
---|
1056 | ci.rclDest.yTop-ci.rclDest.yBottom, SWP_MOVE|SWP_SIZE);
|
---|
1057 | /* STOP button */
|
---|
1058 | ci=ciControls[CTRLIDX_STOPBUTTON];
|
---|
1059 | ulStyle=WinQueryWindowULong(WinWindowFromID(hwnd, ci.id),QWL_STYLE);
|
---|
1060 | WinSetWindowULong(WinWindowFromID(hwnd, ci.id),QWL_STYLE,ulStyle|BS_USERBUTTON);
|
---|
1061 | WinSetWindowPos(WinWindowFromID(hwnd, ci.id),HWND_TOP, ci.rclDest.xLeft , ci.rclDest.yBottom,
|
---|
1062 | ci.rclDest.xRight-ci.rclDest.xLeft,
|
---|
1063 | ci.rclDest.yTop-ci.rclDest.yBottom, SWP_MOVE|SWP_SIZE);
|
---|
1064 | /* Pause button */
|
---|
1065 | ci=ciControls[CTRLIDX_PAUSEBUTTON];
|
---|
1066 | ulStyle=WinQueryWindowULong(WinWindowFromID(hwnd, ci.id),QWL_STYLE);
|
---|
1067 | WinSetWindowULong(WinWindowFromID(hwnd, ci.id),QWL_STYLE,ulStyle|BS_USERBUTTON);
|
---|
1068 | WinSetWindowPos(WinWindowFromID(hwnd, ci.id),HWND_TOP, ci.rclDest.xLeft , ci.rclDest.yBottom,
|
---|
1069 | ci.rclDest.xRight-ci.rclDest.xLeft,
|
---|
1070 | ci.rclDest.yTop-ci.rclDest.yBottom, SWP_MOVE|SWP_SIZE);
|
---|
1071 | /* Play button */
|
---|
1072 | ci=ciControls[CTRLIDX_PLAYBUTTON];
|
---|
1073 | ulStyle=WinQueryWindowULong(WinWindowFromID(hwnd, ci.id),QWL_STYLE);
|
---|
1074 | WinSetWindowULong(WinWindowFromID(hwnd, ci.id),QWL_STYLE,ulStyle|BS_USERBUTTON);
|
---|
1075 | WinSetWindowPos(WinWindowFromID(hwnd, ci.id),HWND_TOP, ci.rclDest.xLeft , ci.rclDest.yBottom,
|
---|
1076 | ci.rclDest.xRight-ci.rclDest.xLeft,
|
---|
1077 | ci.rclDest.yTop-ci.rclDest.yBottom, SWP_MOVE|SWP_SIZE);
|
---|
1078 | /* Skip forward button */
|
---|
1079 | ci=ciControls[CTRLIDX_SKIPFWDBUTTON];
|
---|
1080 | ulStyle=WinQueryWindowULong(WinWindowFromID(hwnd, ci.id),QWL_STYLE);
|
---|
1081 | WinSetWindowULong(WinWindowFromID(hwnd, ci.id),QWL_STYLE,ulStyle|BS_USERBUTTON);
|
---|
1082 | WinSetWindowPos(WinWindowFromID(hwnd, ci.id),HWND_TOP, ci.rclDest.xLeft , ci.rclDest.yBottom,
|
---|
1083 | ci.rclDest.xRight-ci.rclDest.xLeft,
|
---|
1084 | ci.rclDest.yTop-ci.rclDest.yBottom, SWP_MOVE|SWP_SIZE);
|
---|
1085 | /* Repeat Checkbox */
|
---|
1086 | ci=ciControls[CTRLIDX_CHECK];//ciPosSlider;
|
---|
1087 | #if 0
|
---|
1088 | ptl.x=ci.rclDest.xLeft;
|
---|
1089 | ptl.y=ci.rclDest.yBottom;
|
---|
1090 | WinMapDlgPoints(hwnd, &ptl, 1, FALSE);
|
---|
1091 |
|
---|
1092 | WinSetWindowPos(WinWindowFromID(hwnd, ci.id),HWND_TOP, ptl.x , ptl.y,
|
---|
1093 | 0, 0, SWP_MOVE);
|
---|
1094 | #endif
|
---|
1095 | WinQueryWindowPos(WinWindowFromID(hwnd, ci.id), &swp);
|
---|
1096 | WinSetWindowPos(WinWindowFromID(hwnd, ci.id),HWND_TOP, ci.rclDest.xLeft , ci.rclDest.yBottom,
|
---|
1097 | 131, swp.cy, SWP_MOVE);
|
---|
1098 |
|
---|
1099 | /* Remove BS_USERBUTTON style otherwise BS_AUTOCHECKBOX doesn't work. BS_USERBUTTON is necessary because eStyler
|
---|
1100 | from eCS only checks during creation of the button for this style... OS/2 does it always when painting a control. */
|
---|
1101 | ulStyle=WinQueryWindowULong(WinWindowFromID(hwnd, ci.id),QWL_STYLE);
|
---|
1102 | ulStyle&=~BS_USERBUTTON;
|
---|
1103 | WinSetWindowULong(WinWindowFromID(hwnd, ci.id),QWL_STYLE,ulStyle | BS_AUTOCHECKBOX);
|
---|
1104 | /* Subclass */
|
---|
1105 | oldCheckBoxProc=WinSubclassWindow(WinWindowFromID(hwnd, ci.id),checkBoxProc);
|
---|
1106 | /* Find mnemonic */
|
---|
1107 | hwndTemp=WinWindowFromID(hwnd, ci.id);
|
---|
1108 | if((ulLen=WinQueryWindowText( hwndTemp, sizeof(text), text))!=0) {
|
---|
1109 | int a;
|
---|
1110 |
|
---|
1111 | text[CCHMAXPATH-1]=0;
|
---|
1112 | for(a=0;a<ulLen;a++) {
|
---|
1113 | if(WinSendMsg( hwndTemp, WM_MATCHMNEMONIC,MPFROMSHORT((USHORT)text[a]),0))
|
---|
1114 | break;/* Ok, mnemonic found */
|
---|
1115 | }
|
---|
1116 | if(a<=ulLen) {
|
---|
1117 | MFLDRCTRLDATA * mFldrCtrlData=(MFLDRCTRLDATA *)malloc(sizeof(MFLDRCTRLDATA));
|
---|
1118 |
|
---|
1119 | if(mFldrCtrlData) {
|
---|
1120 | mFldrCtrlData->ulMnemonicPos=0x00010000+a;
|
---|
1121 | WinSetWindowULong(hwndTemp, QWL_USER, (ULONG)mFldrCtrlData);/* For mnemonic */
|
---|
1122 | }
|
---|
1123 | }
|
---|
1124 | }
|
---|
1125 |
|
---|
1126 | /* Random Checkbox */
|
---|
1127 | ci=ciControls[CTRLIDX_RANDOMCHECK];
|
---|
1128 | WinQueryWindowPos(WinWindowFromID(hwnd, ci.id), &swp);
|
---|
1129 | WinSetWindowPos(WinWindowFromID(hwnd, ci.id),HWND_TOP, ci.rclDest.xLeft , ci.rclDest.yBottom,
|
---|
1130 | 131, swp.cy, SWP_MOVE|SWP_SIZE);
|
---|
1131 | /* Remove BS_USERBUTTON style otherwise BS_AUTOCHECKBOX doesn't work. BS_USERBUTTON is necessary because eStyler
|
---|
1132 | from eCS only checks during creation of the button for this style... OS/2 does it always when painting a control. */
|
---|
1133 | ulStyle=WinQueryWindowULong(WinWindowFromID(hwnd, ci.id),QWL_STYLE);
|
---|
1134 | ulStyle&=~BS_USERBUTTON;
|
---|
1135 | WinSetWindowULong(WinWindowFromID(hwnd, ci.id),QWL_STYLE,ulStyle | BS_AUTOCHECKBOX);
|
---|
1136 | /* Subclass */
|
---|
1137 | oldCheckBoxProc=WinSubclassWindow(WinWindowFromID(hwnd, ci.id),checkBoxProc);
|
---|
1138 | /* Find mnemonic */
|
---|
1139 | hwndTemp=WinWindowFromID(hwnd, ci.id);
|
---|
1140 | if((ulLen=WinQueryWindowText( hwndTemp, sizeof(text), text))!=0) {
|
---|
1141 | int a;
|
---|
1142 |
|
---|
1143 | text[CCHMAXPATH-1]=0;
|
---|
1144 | for(a=0;a<ulLen;a++) {
|
---|
1145 | if(WinSendMsg( hwndTemp, WM_MATCHMNEMONIC,MPFROMSHORT((USHORT)text[a]),0))
|
---|
1146 | break;/* Ok, mnemonic found */
|
---|
1147 | }
|
---|
1148 | if(a<=ulLen) {
|
---|
1149 | MFLDRCTRLDATA * mFldrCtrlData=(MFLDRCTRLDATA *)malloc(sizeof(MFLDRCTRLDATA));
|
---|
1150 |
|
---|
1151 | if(mFldrCtrlData) {
|
---|
1152 | mFldrCtrlData->ulMnemonicPos=0x00010000+a;
|
---|
1153 | WinSetWindowULong(hwndTemp, QWL_USER, (ULONG)mFldrCtrlData);/* For mnemonic */
|
---|
1154 | }
|
---|
1155 | }
|
---|
1156 | }
|
---|
1157 |
|
---|
1158 | }
|
---|
1159 |
|
---|
1160 |
|
---|