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

Last change on this file was 104, checked in by gyoung, 23 months ago

Remaining changes from merge with Lars 2.9 branch

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