source: branches/v2.9/classes/mm-progs/MMPlayer/customprocs.c

Last change on this file was 2, checked in by stevenhl, 8 years ago

Import sources from cwmm-full.zip dated 2005-03-21

File size: 28.7 KB
Line 
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/*
21 * If you need another license for your project/product (commercial,
22 * noncommercial, whatever) contact me at
23 *
24 * http://www.os2world.com/cdwriting
25 * http://www.geocities.com/SiliconValley/Sector/5785/
26 *
27 */
28
29#define INCL_GPILCIDS
30#define INCL_GPIPRIMITIVES
31#define INCL_GPIBITMAPS
32#define INCL_GPILOGCOLORTABLE
33#define INCL_SW
34#define INCL_GPIREGIONS
35#define INCL_WIN
36
37#include <os2.h>
38
39#include "common.h"
40#include "mmplayerres.h"
41#include "mmres.h"
42#include "mmplayer.h"
43#include <stdio.h>
44#include <stdlib.h>
45
46
47/* Fonts to use in dialogs */
48#define DEFAULT_DIALOG_FONT "9.WarpSans"
49
50/* Bitmap data */
51extern LOADEDBITMAP allBMPs[];
52extern CONTROLINFO ciControls[];
53
54/* Window procedures */
55extern PFNWP oldPlayTimeProc;
56extern PFNWP orgBgProc; /* Org proc of background */
57extern PFNWP orgButtonProc;
58extern HPOINTER hptrArrowWE;
59
60MRESULT handleDrag0ver(PDRAGINFO pdi, HWND hwnd);
61MRESULT handleDrop(PDRAGINFO pdi, HWND hwnd);
62
63/* This custom button proc is only for DnD handling */
64MRESULT EXPENTRY buttonProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
65{
66 switch(msg)
67 {
68 /* Drag and drop of audio files */
69 case DM_DRAGOVER:
70 {
71 PDRAGINFO pdi=PVOIDFROMMP(mp1);
72
73 return handleDrag0ver( pdi, WinQueryWindow(hwnd, QW_PARENT));
74 }
75 case DM_DROP:
76 {
77 PDRAGINFO pdi=PVOIDFROMMP(mp1);
78
79 return handleDrop( pdi, WinQueryWindow(hwnd, QW_PARENT));
80 }
81 default:
82 break;
83 }
84 if(orgButtonProc)
85 return (*orgButtonProc)(hwnd, msg, mp1, mp2);
86 else
87 return WinDefWindowProc(hwnd, msg, mp1, mp2);
88}
89
90MRESULT EXPENTRY bgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
91{
92 switch(msg)
93 {
94 /*****************************************************/
95 /* Paint the background */
96 /*****************************************************/
97 case WM_PAINT:
98 {
99 SWP swp;
100 RECTL rcl;
101 HPS hps;
102
103 WinQueryWindowPos(hwnd,&swp);
104 if(swp.fl & SWP_MINIMIZE)
105 break;
106
107 hps=WinBeginPaint(hwnd, NULLHANDLE, NULLHANDLE);
108 WinQueryWindowRect(hwnd, &rcl);
109 WinDrawBitmap(hps, allBMPs[MAIN_BMP_IDX].hbm,
110 NULLHANDLE,
111 (PPOINTL)&rcl,
112 0, 0,
113 DBM_IMAGEATTRS);
114 WinEndPaint(hps);
115 return MRFALSE;
116 }
117 default:
118 break;
119 }
120 if(orgBgProc)
121 return (*orgBgProc)(hwnd, msg, mp1, mp2);
122 else
123 return WinDefWindowProc(hwnd, msg, mp1, mp2);
124}
125
126/* This function paints all our controls with the provided bitmaps */
127/* It's called from the guiproc */
128MRESULT paintControls(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
129{
130 USERBUTTON* ubPtr;
131 CONTROLINFO ci;
132 RECTL rcl;
133
134 ubPtr=(USERBUTTON*)PVOIDFROMMP(mp2);
135 switch(SHORT1FROMMP(mp1))
136 {
137 case IDPB_MMPLAYERPLAY:
138 if(ubPtr->fsState==BDS_DEFAULT||!ubPtr->fsState)
139 ci=ciControls[CTRLIDX_PLAYBUTTON];
140 else {
141 ci=ciControls[CTRLIDX_PLAYBUTTONSEL];
142 }
143 break;
144 case IDPB_MMPLAYERPAUSE:
145 if(ubPtr->fsState==BDS_DEFAULT||!ubPtr->fsState)
146 ci=ciControls[CTRLIDX_PAUSEBUTTON];
147 else {
148 ci=ciControls[CTRLIDX_PAUSEBUTTONSEL];
149 }
150 break;
151 case IDPB_MMPLAYERSTOP:
152 if(ubPtr->fsState==BDS_DEFAULT||!ubPtr->fsState)
153 ci=ciControls[CTRLIDX_STOPBUTTON];
154 else {
155 ci=ciControls[CTRLIDX_STOPBUTTONSEL];
156 }
157 break;
158#if 0
159 case IDPB_POSBAR:
160 ci=ciControls[CTRLIDX_POSSLIDER];//ciPosSlider;
161 break;
162 case IDPB_SLIDERARM:
163 DosBeep(5000, 30);
164 ci=ciControls[CTRLIDX_POSSLIDERARM];//ciPosSliderArm;
165 break;
166 case IDSL_VOLUME:
167 ci=ciControls[CTRLIDX_VOLSLIDER];//ciVolSlider;
168 break;
169 case IDSL_VOLUMEARM:
170 if(WinQueryCapture(HWND_DESKTOP==hwnd))
171 ci=ciControls[CTRLIDX_VOLSLIDERARMSEL];//ciVolSliderArm;
172 else
173 ci=ciControls[CTRLIDX_VOLSLIDERARM];//ciVolSliderArm;
174 break;
175#endif
176 default:
177 return (MRESULT)0;
178 }
179 rcl.yBottom=0;
180 rcl.xLeft=0;
181
182 //DosBeep(5000, 100);
183
184 WinDrawBitmap(ubPtr->hps, ci.hbmSource,
185 &ci.rclSource,
186 (PPOINTL)&rcl,
187 0, 0,
188 DBM_IMAGEATTRS);
189 if(ubPtr->fsStateOld!=ubPtr->fsState)
190 ubPtr->fsState =( ubPtr->fsStateOld==BDS_DEFAULT ? BDS_HILITED : BDS_DEFAULT);
191
192 return (MRESULT)0;
193}
194
195
196/* This function paints all our controls with the provided bitmaps. */
197BOOL paintHilitedControl(HWND hwnd, USHORT usControl, BOOL bHilite)
198{
199 // static ULONG ulShowFeedback=0;
200
201#if 0
202 if(!ulShowFeedback) {
203 /* Query the INI setting*/
204 if(!PrfQueryProfileInt(HINI_USERPROFILE, APPKEY_CWMM, MFLDR_NO_VISUAL_FEEDBACK, 0))
205 ulShowFeedback=1; /* Flash play controls */
206 else
207 ulShowFeedback=2; /* Don't flash play controls while playing */
208 }
209
210
211 if(ulShowFeedback==2)
212 return 1;
213
214 switch(usControl)
215 {
216 case IDPB_PLAY:
217 if(!bHilite) {
218 ci=ciControls[CTRLIDX_PLAYBUTTON];
219 }
220 else {
221 ci=ciControls[CTRLIDX_PLAYBUTTONSEL];
222 }
223 break;
224 case IDPB_PAUSE:
225 if(!bHilite) {
226 ci=ciControls[CTRLIDX_PAUSEBUTTON];
227 }
228 else {
229 ci=ciControls[CTRLIDX_PAUSEBUTTONSEL];
230 }
231 break;
232 default:
233 return 0;
234 }
235 rcl.yBottom=0;
236 rcl.xLeft=0;
237 hps=WinGetPS(hwnd);
238 WinDrawBitmap(hps, ci.hbmSource,
239 &ci.rclSource,
240 (PPOINTL)&rcl,
241 0, 0,
242 DBM_IMAGEATTRS);
243 WinReleasePS(hps);
244#endif
245 return 1;
246}
247
248
249#define USERSLIDER 1 /* Set to 0 to let the proc paint the control. With set to 1
250 a WM_DRAWITEM msg is sent to the parent. */
251BOOL userSlider=USERSLIDER;
252#define SLOFFSET 3 /* The offset of the active slider area to the window border */
253MRESULT EXPENTRY privateSliderProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
254{
255
256 switch (msg)
257 {
258#if 0
259 /* Drag and drop of audio files */
260 case DM_DRAGOVER:
261 {
262 PDRAGINFO pdi=PVOIDFROMMP(mp1);
263
264 return handleDrag0ver( pdi, WinQueryWindow(hwnd, QW_PARENT));
265 }
266 case DM_DROP:
267 {
268 PDRAGINFO pdi=PVOIDFROMMP(mp1);
269
270 return handleDrop( pdi, WinQueryWindow(hwnd, QW_PARENT));
271 }
272#endif
273 case WM_CREATE:
274 {
275 PCREATESTRUCT pCreate=(CREATESTRUCT*)PVOIDFROMMP(mp2);
276
277 /* Initialize the slider data */
278 WinSetWindowUShort(hwnd, SLIDERARMWIDTH,20);
279 WinSetWindowUShort(hwnd, SLIDERARMHEIGHT,10);
280 WinSetWindowUShort(hwnd, SLINCREMENTS,100);
281 /* Dimensions of slider. The slider active area is smaller than the window to
282 allow drawing of active state. */
283 WinSetWindowULong(hwnd, SLIDERCX,pCreate->cx-2*SLOFFSET);
284 WinSetWindowULong(hwnd, SLIDERCY,pCreate->cy-2*SLOFFSET);
285 WinSetWindowULong(hwnd, SLIDERX,SLOFFSET);
286 WinSetWindowULong(hwnd, SLIDERY,SLOFFSET);
287 WinSetWindowULong(hwnd, SLIDERARMPOS, 0);
288 WinSetWindowULong(hwnd, SLDRAGGING,FALSE);
289
290 return (MRESULT)0;
291 }
292 case SLM_SETSLIDERINFO:
293 switch(SHORT1FROMMP(mp1))
294 {
295 case SMA_SLIDERARMPOSITION:
296 /* SMA_RANGEVALUE */
297 if(!WinQueryWindowULong(hwnd, SLDRAGGING)) {
298 if(SHORT2FROMMP(mp1)==SMA_RANGEVALUE) {
299 WinSetWindowULong(hwnd, SLIDERARMPOS, LONGFROMMP(mp2));
300 WinInvalidateRect(hwnd, NULLHANDLE,TRUE);
301 return (MRESULT)0;
302 }
303 else if(SHORT2FROMMP(mp1)==SMA_INCREMENTVALUE) {
304 LONG lInc=LONGFROMMP(mp2)*(WinQueryWindowULong(hwnd, SLIDERCX)-WinQueryWindowUShort(hwnd, SLIDERARMWIDTH));
305 lInc/=WinQueryWindowUShort(hwnd, SLINCREMENTS);
306 WinSetWindowULong(hwnd, SLIDERARMPOS, lInc);
307 WinInvalidateRect(hwnd, NULLHANDLE,TRUE);
308 return (MRESULT)0;
309 }
310 }
311 break;
312 case SMA_SLIDERARMDIMENSIONS:
313 WinSetWindowUShort(hwnd, SLIDERARMWIDTH, SHORT1FROMMP(mp2));
314 WinSetWindowUShort(hwnd, SLIDERARMHEIGHT, SHORT2FROMMP(mp2));
315 return (MRESULT)0;
316 default:
317 break;
318 }
319 break;
320 case WM_SIZE:
321 WinSetWindowULong(hwnd, SLIDERCX, SHORT1FROMMP(mp2)-2*SLOFFSET);
322 WinSetWindowULong(hwnd, SLIDERCY, SHORT2FROMMP(mp2)-2*SLOFFSET);
323 WinInvalidateRect(hwnd, NULLHANDLE,TRUE);
324 return (MRESULT)0;
325 case WM_BUTTON1DOWN:
326 {
327 SHORT x=SHORT1FROMMP( mp1);
328 SHORT y=SHORT2FROMMP( mp1);
329 LONG lPos=WinQueryWindowULong(hwnd, SLIDERARMPOS);
330 USHORT usWidth=WinQueryWindowUShort(hwnd, SLIDERARMWIDTH);
331
332 if(x<=lPos+usWidth+SLOFFSET && x>=lPos+SLOFFSET &&
333 y<=WinQueryWindowUShort(hwnd, SLIDERY)+WinQueryWindowUShort(hwnd, SLIDERCY)
334 && y>=WinQueryWindowUShort(hwnd, SLIDERY)) {
335 WinSetWindowUShort(hwnd, PTRPOSINSLARM, x-lPos-SLOFFSET);
336 }
337 WinSetFocus(HWND_DESKTOP, hwnd);
338 break;
339 }
340 case WM_FOCUSCHANGE:
341 {
342 HPS hps;
343 RECTL rcl;
344 POINTL ptl;
345
346 if(SHORT1FROMMP(mp2)) {
347 hps=WinGetPS(hwnd);
348 WinQueryWindowRect(hwnd, &rcl);
349 GpiSetLineType(hps, LINETYPE_DOT);
350 ptl.x=rcl.xLeft;
351 ptl.y=rcl.yBottom;
352 GpiMove(hps,&ptl);
353 ptl.x=rcl.xRight-1;
354 GpiLine(hps,&ptl);
355 ptl.y=rcl.yTop-1;
356 GpiLine(hps,&ptl);
357 ptl.x=rcl.xLeft;
358 GpiLine(hps,&ptl);
359 ptl.y=rcl.yBottom;
360 GpiLine(hps,&ptl);
361 WinReleasePS(hps);
362 }
363 else
364 WinInvalidateRect(hwnd, NULLHANDLE,TRUE);
365
366 break;
367 }
368 case WM_CHAR:
369 if(WinQueryFocus(HWND_DESKTOP)==hwnd) {
370 if(SHORT2FROMMP(mp2)==VK_TAB && (SHORT1FROMMP(mp1) & KC_VIRTUALKEY))
371 if(SHORT1FROMMP(mp1) & (KC_KEYUP|KC_PREVDOWN))
372 return (MRESULT)TRUE;
373
374#if 0
375 /**/
376 if(SHORT2FROMMP(mp2)==VK_RIGHT && (SHORT1FROMMP(mp1) & KC_VIRTUALKEY))
377 /* if(SHORT1FROMMP(mp1) & (KC_KEYUP|KC_PREVDOWN))*/ {
378 DosBeep(5000, 100);
379 return (MRESULT)TRUE;
380 }
381 if(SHORT2FROMMP(mp2)==VK_LEFT && (SHORT1FROMMP(mp1) & KC_VIRTUALKEY))
382 if(SHORT1FROMMP(mp1) & (KC_KEYUP|KC_PREVDOWN)) {
383 DosBeep(500, 100);
384 return (MRESULT)TRUE;
385 }
386#endif
387
388 return WinDefWindowProc(hwnd, msg, mp1, mp2);
389 }
390
391#if 0
392 if(WinQueryFocus(HWND_DESKTOP)==hwnd) {
393 /* We have the focus */
394 if((SHORT1FROMMP(mp1) & (KC_VIRTUALKEY))==(KC_VIRTUALKEY)) {
395 LONG lPos=WinQueryWindowULong(hwnd, SLIDERARMPOS);
396 USHORT usWidth=WinQueryWindowUShort(hwnd, SLIDERARMWIDTH);
397 ULONG ulCx=WinQueryWindowULong(hwnd, SLIDERCX);
398
399 switch(SHORT2FROMMP(mp2))
400 {
401 case VK_RIGHT:
402 if(SHORT1FROMMP(mp1) & (KC_KEYUP|KC_PREVDOWN)) {
403 lPos+=1;
404 if(lPos>ulCx-usWidth)
405 lPos=ulCx-usWidth;
406 else {
407 WinPostMsg( hwnd,
408 SLM_SETSLIDERINFO,
409 MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_RANGEVALUE),
410 MPFROMLONG( (LONG) lPos ));
411 lPos=(lPos*100)/(WinQueryWindowULong(hwnd, SLIDERCX)-WinQueryWindowUShort(hwnd, SLIDERARMWIDTH));
412
413 WinPostMsg( WinQueryWindow(hwnd, QW_PARENT),WM_CONTROL,
414 MPFROM2SHORT(WinQueryWindowUShort(hwnd, QWS_ID), SLN_CHANGE),
415 MPFROMLONG(lPos));
416
417 if(SHORT1FROMMP(mp1) & KC_LONEKEY) {
418 /* Post SLN_CHANGE notification */
419 WinPostMsg( WinQueryWindow(hwnd, QW_PARENT),WM_CONTROL,
420 MPFROM2SHORT(WinQueryWindowUShort(hwnd, QWS_ID), SLN_CHANGE),
421 MPFROMLONG(lPos));
422 WinSetWindowULong(hwnd, SLDRAGGING, FALSE);
423 }
424 else {
425 WinSetWindowULong(hwnd, SLDRAGGING, TRUE);
426 /* Post SLN_SLIDERTRACK notification */
427 WinPostMsg(WinQueryWindow(hwnd, QW_PARENT),WM_CONTROL,
428 MPFROM2SHORT(WinQueryWindowUShort(hwnd, QWS_ID), SLN_SLIDERTRACK),
429 MPFROMLONG(lPos));
430 }
431
432 }
433 WinSetWindowULong(hwnd, SLIDERARMPOS, lPos);
434 }
435 return (MRESULT)TRUE;
436 case VK_LEFT:
437 if(SHORT1FROMMP(mp1) & (KC_KEYUP|KC_PREVDOWN)) {
438 lPos-=1;
439 if(lPos<0) {
440 lPos=0;
441 }
442 else {
443 WinPostMsg( hwnd,
444 SLM_SETSLIDERINFO,
445 MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_RANGEVALUE),
446 MPFROMLONG( (LONG) lPos ));
447 lPos=(lPos*100)/(WinQueryWindowULong(hwnd, SLIDERCX)-WinQueryWindowUShort(hwnd, SLIDERARMWIDTH));
448 /* Post SLN_CHANGE notification */
449 WinPostMsg( WinQueryWindow(hwnd, QW_PARENT),WM_CONTROL,
450 MPFROM2SHORT(WinQueryWindowUShort(hwnd, QWS_ID), SLN_CHANGE),
451 MPFROMLONG(lPos));
452
453 if(SHORT1FROMMP(mp1) & KC_LONEKEY) {
454 /* Post SLN_CHANGE notification */
455 WinPostMsg( WinQueryWindow(hwnd, QW_PARENT),WM_CONTROL,
456 MPFROM2SHORT(WinQueryWindowUShort(hwnd, QWS_ID), SLN_CHANGE),
457 MPFROMLONG(lPos));
458 WinSetWindowULong(hwnd, SLDRAGGING, FALSE);
459 }
460 else {
461 WinSetWindowULong(hwnd, SLDRAGGING, TRUE);
462 /* Post SLN_SLIDERTRACK notification */
463 WinPostMsg(WinQueryWindow(hwnd, QW_PARENT),WM_CONTROL,
464 MPFROM2SHORT(WinQueryWindowUShort(hwnd, QWS_ID), SLN_SLIDERTRACK),
465 MPFROMLONG(lPos));
466 }
467
468 }
469 WinSetWindowULong(hwnd, SLIDERARMPOS, lPos);
470
471 }
472 return (MRESULT)TRUE;
473 default:
474 break;
475 }
476 }
477
478 }
479#endif
480 break;
481 case WM_BUTTON1MOTIONSTART:
482 {
483 SHORT x=SHORT1FROMMP( mp1);
484 SHORT y=SHORT2FROMMP( mp1);
485 LONG lPos=WinQueryWindowULong(hwnd, SLIDERARMPOS);
486 USHORT usWidth=WinQueryWindowUShort(hwnd, SLIDERARMWIDTH);
487
488 if(x<=lPos+usWidth+SLOFFSET && x>=lPos+SLOFFSET &&
489 y<=WinQueryWindowUShort(hwnd, SLIDERY)+WinQueryWindowUShort(hwnd, SLIDERCY)
490 && y>=WinQueryWindowUShort(hwnd, SLIDERY)){
491 // if(x<=lPos+usWidth && y<=WinQueryWindowUShort(hwnd, SLIDERY)+WinQueryWindowUShort(hwnd, SLIDERCY)
492 // && y>=WinQueryWindowUShort(hwnd, SLIDERY)) {
493 WinSetWindowULong(hwnd, SLDRAGGING, TRUE);
494 if(hptrArrowWE)
495 WinSetPointer(HWND_DESKTOP, hptrArrowWE);
496
497 WinSetCapture(HWND_DESKTOP, hwnd);
498 }
499 break;
500 }
501 case WM_BUTTON1MOTIONEND:
502 if(WinQueryWindowULong(hwnd, SLDRAGGING)) {
503 LONG lPos=WinQueryWindowULong(hwnd, SLIDERARMPOS);
504 WinSetWindowULong(hwnd, SLDRAGGING,FALSE);
505 WinSetCapture(HWND_DESKTOP, NULLHANDLE);
506 lPos=(lPos*100)/(WinQueryWindowULong(hwnd, SLIDERCX)-WinQueryWindowUShort(hwnd, SLIDERARMWIDTH));
507 /* Post SLN_CHANGE notification */
508 WinPostMsg(WinQueryWindow(hwnd, QW_PARENT),WM_CONTROL,
509 MPFROM2SHORT(WinQueryWindowUShort(hwnd, QWS_ID), SLN_CHANGE),
510 MPFROMLONG(lPos));
511 }
512 break;
513
514 case WM_MOUSEMOVE:
515 if(WinQueryWindowULong(hwnd, SLDRAGGING)) {
516
517 HPS hps;
518 RECTL rcl, rcl2, rcl3;
519 LONG lTemp;
520 SHORT x=SHORT1FROMMP(mp1);
521 LONG lPos=WinQueryWindowULong(hwnd, SLIDERARMPOS);
522 USHORT usWidth=WinQueryWindowUShort(hwnd, SLIDERARMWIDTH);
523
524
525 lTemp=lPos;
526
527 rcl.xLeft=WinQueryWindowULong(hwnd, SLIDERX);
528 rcl.yBottom=WinQueryWindowULong(hwnd, SLIDERY);
529 rcl.xRight=rcl.xLeft+WinQueryWindowULong(hwnd, SLIDERCX);
530 rcl.yTop=rcl.yBottom+WinQueryWindowULong(hwnd, SLIDERCY);
531
532 rcl2=rcl3=rcl;
533 rcl.xLeft=x-WinQueryWindowUShort(hwnd, PTRPOSINSLARM);
534 if(rcl.xLeft<rcl2.xLeft)/* Make sure we stop at the left border */
535 rcl.xLeft=rcl2.xLeft;
536
537 rcl.xRight=rcl.xLeft+usWidth;
538 if(rcl.xRight>rcl2.xRight)
539 {/* Make sure we stop at the right border */
540 rcl.xRight=rcl2.xRight;
541 rcl.xLeft=rcl.xRight-usWidth;
542 }
543 lPos=rcl.xLeft-WinQueryWindowULong(hwnd, SLIDERX);/* Save position zero based */
544 WinSetWindowULong(hwnd, SLIDERARMPOS, lPos);
545 if(lPos!=lTemp) {
546 BOOL rc;
547
548 hps=WinGetPS(hwnd);
549 /* Paint Background not necessary here */
550
551 /* Shaft */
552 /* Left part */
553 rcl3.xRight=rcl.xLeft;
554
555 rc=FALSE;
556
557 if(userSlider) {
558 OWNERITEM oi={0};
559 oi.hwnd=hwnd;
560 oi.hps=hps;
561 oi.fsState=SLS_OWNERDRAW;/* More to come */
562 oi.rclItem=rcl3;
563 oi.idItem=SDA_SLIDERSHAFT;
564 rc=(BOOL)WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_DRAWITEM,
565 MPFROMSHORT(WinQueryWindowUShort(hwnd, QWS_ID)),
566 MPFROMP(&oi) );
567 }
568 if(!rc)
569 WinFillRect(hps, &rcl3, CLR_PALEGRAY);
570
571 /* Right part */
572 rcl3.xRight=rcl2.xRight;
573 rcl3.xLeft=rcl.xRight;
574 rc=FALSE;
575 if(userSlider) {
576 OWNERITEM oi={0};
577 oi.hwnd=hwnd;
578 oi.hps=hps;
579 oi.fsState=SLS_OWNERDRAW;/* More to come */
580 oi.rclItem=rcl3;
581 oi.idItem=SDA_SLIDERSHAFT;
582 rc=(BOOL)WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_DRAWITEM,
583 MPFROMSHORT(WinQueryWindowUShort(hwnd, QWS_ID)),
584 MPFROMP(&oi) );
585 }
586 if(!rc)
587 WinFillRect(hps, &rcl3, CLR_PALEGRAY);
588
589 /* Paint Slider */
590 rc=FALSE;
591 if(userSlider) {
592 OWNERITEM oi={0};
593 oi.hwnd=hwnd;
594 oi.hps=hps;
595 oi.fsState=SLS_OWNERDRAW;/* More to come */
596 oi.rclItem=rcl;
597 oi.idItem=SDA_SLIDERARM;
598 rc=(BOOL)WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_DRAWITEM,
599 MPFROMSHORT(WinQueryWindowUShort(hwnd, QWS_ID)),
600 MPFROMP(&oi) );
601
602 }
603 if(!rc)
604 {
605 WinFillRect(hps,&rcl, CLR_PALEGRAY);
606 WinDrawBorder(hps, &rcl, 2, 2, 0, 0 ,0x0400);
607 }
608
609 WinReleasePS(hps);
610 lPos=(lPos*100)/(WinQueryWindowULong(hwnd, SLIDERCX)-WinQueryWindowUShort(hwnd, SLIDERARMWIDTH));
611 /* Post SLN_SLIDERTRACK notification */
612 WinPostMsg(WinQueryWindow(hwnd, QW_PARENT),WM_CONTROL,
613 MPFROM2SHORT(WinQueryWindowUShort(hwnd, QWS_ID), SLN_SLIDERTRACK),
614 MPFROMLONG(lPos));
615 }
616 return MRTRUE;
617 }
618 else {
619 if(hptrArrowWE) {
620 /* Not dragging */
621 /* Change pointer to drag pointer when over the arm */
622 SHORT x=SHORT1FROMMP( mp1);
623 SHORT y=SHORT2FROMMP( mp1);
624 LONG lPos=WinQueryWindowULong(hwnd, SLIDERARMPOS);
625 USHORT usWidth=WinQueryWindowUShort(hwnd, SLIDERARMWIDTH);
626 if(x<=lPos+usWidth+SLOFFSET && x>=lPos+SLOFFSET &&
627 y<=WinQueryWindowUShort(hwnd, SLIDERY)+WinQueryWindowUShort(hwnd, SLIDERCY)
628 && y>=WinQueryWindowUShort(hwnd, SLIDERY)) {
629 WinSetPointer(HWND_DESKTOP, hptrArrowWE);
630 // WinSetPointer(HWND_DESKTOP, WinQuerySysPointer(HWND_DESKTOP, SPTR_SIZEWE, FALSE));
631 return MRTRUE;
632 }
633 }
634 }
635 break;
636 case WM_PAINT:
637 {
638
639 HPS hps, hps2;
640 RECTL rcl, rcl2, rcl3;
641 POINTL ptl;
642 LONG lPos=WinQueryWindowULong(hwnd, SLIDERARMPOS);
643 USHORT usWidth=WinQueryWindowUShort(hwnd, SLIDERARMWIDTH);
644 BOOL rc;
645
646 WinQueryWindowRect(hwnd, &rcl);
647
648 /* Shaft */
649 rcl2.xLeft=WinQueryWindowULong(hwnd, SLIDERX);
650 rcl2.yBottom=WinQueryWindowULong(hwnd, SLIDERY);
651 rcl2.xRight=rcl2.xLeft+WinQueryWindowULong(hwnd, SLIDERCX)-1;
652 rcl2.yTop=rcl2.yBottom+WinQueryWindowULong(hwnd, SLIDERCY)-1;
653
654 /* Background */
655 hps2=WinGetPS(hwnd);
656 GpiExcludeClipRectangle(hps2,&rcl2);
657 rc=FALSE;
658 if(userSlider) {
659 OWNERITEM oi={0};
660 oi.hwnd=hwnd;
661 oi.hps=hps2;
662 oi.fsState=SLS_OWNERDRAW;/* More to come */
663 oi.rclItem=rcl;
664 oi.idItem=SDA_BACKGROUND;
665 rc=(BOOL)WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_DRAWITEM, MPFROMSHORT(WinQueryWindowUShort(hwnd, QWS_ID)),
666 MPFROMP(&oi) );
667 }
668 if(!rc)
669 WinFillRect(hps2, &rcl, CLR_PALEGRAY);
670 /* Focus */
671 if(WinQueryFocus(HWND_DESKTOP)==hwnd) {
672 GpiSetLineType(hps2, LINETYPE_DOT);
673 ptl.x=rcl.xLeft;
674 ptl.y=rcl.yBottom;
675 GpiMove(hps2,&ptl);
676 ptl.x=rcl.xRight-1;
677 GpiLine(hps2,&ptl);
678 ptl.y=rcl.yTop-1;
679 GpiLine(hps2,&ptl);
680 ptl.x=rcl.xLeft;
681 GpiLine(hps2,&ptl);
682 ptl.y=rcl.yBottom;
683 GpiLine(hps2,&ptl);
684 }
685
686 WinReleasePS(hps2);
687 rcl2.yTop+=1;
688 rcl2.xRight+=1;
689 hps=WinBeginPaint(hwnd, NULLHANDLE, NULLHANDLE);
690 rcl3=rcl=rcl2;
691 /* Arm pos */
692 rcl2.xLeft+=lPos;
693 /* Arm size */
694 rcl2.xRight=rcl2.xLeft+usWidth;
695
696 /* Shaft */
697 /* Left part */
698 rcl3.xRight=rcl2.xLeft;
699 rc=FALSE;
700 if(userSlider) {
701 OWNERITEM oi={0};
702 oi.hwnd=hwnd;
703 oi.hps=hps;
704 oi.fsState=SLS_OWNERDRAW;/* More to come */
705 oi.rclItem=rcl3;
706 oi.idItem=SDA_SLIDERSHAFT;
707 rc=(BOOL)WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_DRAWITEM, MPFROMSHORT(WinQueryWindowUShort(hwnd, QWS_ID)),
708 MPFROMP(&oi) );
709
710 }
711 if(!rc)
712 WinFillRect(hps, &rcl3, CLR_GREEN);
713
714 /* Right part */
715 rcl3.xRight=rcl.xRight;
716 rcl3.xLeft=rcl2.xRight;
717 rc=FALSE;
718 if(userSlider) {
719 OWNERITEM oi={0};
720 oi.hwnd=hwnd;
721 oi.hps=hps;
722 oi.fsState=SLS_OWNERDRAW;/* More to come */
723 oi.rclItem=rcl3;
724 oi.idItem=SDA_SLIDERSHAFT;
725 rc=(BOOL)WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_DRAWITEM, MPFROMSHORT(WinQueryWindowUShort(hwnd, QWS_ID)),
726 MPFROMP(&oi) );
727 }
728 if(!rc)
729 WinFillRect(hps, &rcl3, CLR_PALEGRAY);
730
731 rc=FALSE;
732 if(userSlider) {
733 OWNERITEM oi={0};
734 oi.hwnd=hwnd;
735 oi.hps=hps;
736 oi.fsState=SLS_OWNERDRAW;/* More to come */
737 oi.rclItem=rcl2;
738 oi.idItem=SDA_SLIDERARM;
739 rc=(BOOL)WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_DRAWITEM, MPFROMSHORT(WinQueryWindowUShort(hwnd, QWS_ID)),
740 MPFROMP(&oi) );
741 }
742 if(!rc)
743 {
744 WinFillRect(hps,&rcl2, CLR_PALEGRAY);
745 WinDrawBorder(hps, &rcl2, 2, 2, 0, 0 ,0x0400);
746 }
747
748 WinEndPaint(hps);
749 return (MRESULT)0;
750 }
751 break;
752 default:
753 break;
754 }
755 return WinDefWindowProc(hwnd, msg, mp1, mp2);
756}
757
758MRESULT drawSlider(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2, USHORT id)
759{
760 POWNERITEM poi;
761 CONTROLINFO ci, ciArm;
762
763 poi=(POWNERITEM)PVOIDFROMMP(mp2);
764
765 switch(id)
766 {
767 case IDSL_MMPLAYERPOSBAR:
768 ci=ciControls[CTRLIDX_POSSLIDER];
769 ciArm=ciControls[CTRLIDX_POSSLIDERARM];
770 break;
771 case IDSL_MMPLAYERVOLUME:
772 ci=ciControls[CTRLIDX_VOLSLIDER];//ciVolSlider;
773 // if(WinQueryCapture(HWND_DESKTOP==hwnd))
774 ciArm=ciControls[CTRLIDX_VOLSLIDERARMSEL];//ciVolSliderArm;
775 // else
776 // ciArm=ciControls[CTRLIDX_VOLSLIDERARM];//ciVolSliderArm;
777 break;
778 default:
779 return (MRESULT)FALSE;
780 }
781
782 switch(poi->idItem)
783 {
784 case SDA_SLIDERARM:
785 if(ciArm.hbmSource)
786 //DosBeep(5000, 50);
787 WinDrawBitmap(poi->hps, ciArm.hbmSource,
788 &ciArm.rclSource,
789 (PPOINTL)&poi->rclItem,
790 0, 0,
791 DBM_IMAGEATTRS);
792 // WinFillRect(poi->hps,&poi->rclItem, CLR_RED);
793 return (MRESULT) TRUE;
794 case SDA_BACKGROUND:
795 {
796 WinDrawBitmap(poi->hps,
797 ci.hbmSource,
798 &ci.rclSource,
799 (PPOINTL)&poi->rclItem,
800 0, 0,
801 DBM_IMAGEATTRS);
802 // WinFillRect(poi->hps,&poi->rclItem, CLR_WHITE);
803 return (MRESULT) TRUE;
804 }
805 case SDA_SLIDERSHAFT:
806 {
807 RECTL rcl;
808
809 rcl=ci.rclSource;
810 rcl.xLeft+=poi->rclItem.xLeft;
811 rcl.xRight=rcl.xLeft+(poi->rclItem.xRight-poi->rclItem.xLeft);
812 rcl.yBottom+=SLOFFSET;
813 rcl.yTop-=SLOFFSET;
814
815 if(!WinDrawBitmap(poi->hps, ci.hbmSource,
816 &rcl,
817 //&ci.rclSource,
818 (PPOINTL)&poi->rclItem,
819 0, 0,
820 DBM_IMAGEATTRS))
821 return (MRESULT)FALSE;
822 return (MRESULT)TRUE;
823 }
824 default:
825 return (MRESULT)TRUE;
826 }
827 /* Done */
828 return (MRESULT)TRUE;
829}
830
831
832MRESULT EXPENTRY playTimeTextProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
833{
834 switch(msg)
835 {
836 /* Drag and drop of audio files */
837 case DM_DRAGOVER:
838 {
839 PDRAGINFO pdi=PVOIDFROMMP(mp1);
840
841 return handleDrag0ver( pdi, WinQueryWindow(hwnd, QW_PARENT));
842 }
843 case DM_DROP:
844 {
845 PDRAGINFO pdi=PVOIDFROMMP(mp1);
846
847 return handleDrop( pdi, WinQueryWindow(hwnd, QW_PARENT));
848 }
849
850 case WM_BUTTON1CLICK:
851
852 WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_APPTERMINATENOTIFY,
853 MPFROM2SHORT(NOTIFY_CLICK, WinQueryWindowUShort(hwnd, QWS_ID)) ,0L);
854 return (MRESULT)0;
855 case WM_CONTEXTMENU:
856 WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_APPTERMINATENOTIFY,
857 MPFROM2SHORT(NOTIFY_CONTEXT, WinQueryWindowUShort(hwnd, QWS_ID)) ,0L);
858 return (MRESULT)0;
859 case WM_PAINT:
860 {
861 HPS hps;
862 RECTL rcl;
863 char text[100];
864 CONTROLINFO ci;
865
866 ci=ciControls[CTRLIDX_PLAYTIME];//ciVolSliderArm;
867
868 hps=WinBeginPaint(hwnd, NULLHANDLE, NULL);
869 if(WinQueryWindowText(hwnd, sizeof(text), text))
870 {
871 POINTL ptl= {0};
872 WinDrawBitmap(hps, ci.hbmSource,
873 &ci.rclSource,
874 &ptl,
875 0, 0,
876 DBM_IMAGEATTRS);
877 WinQueryWindowRect(hwnd,&rcl);
878 WinDrawText(hps, strlen(text),text, &rcl,0,0,DT_CENTER|DT_VCENTER|DT_TEXTATTRS);
879 }
880 WinEndPaint(hps);
881 return (MRESULT) 0;
882 }
883 default:
884 break;
885 }
886 return oldPlayTimeProc(hwnd, msg, mp1, mp2);
887}
Note: See TracBrowser for help on using the repository browser.