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 | #define INCL_GPILCIDS
|
---|
29 | #define INCL_GPIPRIMITIVES
|
---|
30 | #define INCL_GPIBITMAPS
|
---|
31 | #define INCL_GPILOGCOLORTABLE
|
---|
32 | #define INCL_SW
|
---|
33 | #define INCL_GPIREGIONS
|
---|
34 | #define INCL_WIN
|
---|
35 |
|
---|
36 | #include <os2.h>
|
---|
37 |
|
---|
38 | #include "common.h"
|
---|
39 | #include "classvolumeres.h"
|
---|
40 | #include "mmres.h"
|
---|
41 | #include "classvolume.h"
|
---|
42 | #include <stdio.h>
|
---|
43 | #include <stdlib.h>
|
---|
44 |
|
---|
45 |
|
---|
46 | /* Fonts to use in dialogs */
|
---|
47 | #define DEFAULT_DIALOG_FONT "9.WarpSans"
|
---|
48 |
|
---|
49 | /* Bitmap data */
|
---|
50 | extern LOADEDBITMAP allBMPs[];
|
---|
51 | extern CONTROLINFO ciControls[];
|
---|
52 |
|
---|
53 | /* Window procedures */
|
---|
54 | extern PFNWP orgBgProc; /* Org proc of background */
|
---|
55 | extern PFNWP orgButtonProc;
|
---|
56 | extern HPOINTER hptrArrowWE;
|
---|
57 |
|
---|
58 |
|
---|
59 | /* This custom button proc is only for DnD handling */
|
---|
60 | MRESULT EXPENTRY buttonProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
61 | {
|
---|
62 | switch(msg)
|
---|
63 | {
|
---|
64 | default:
|
---|
65 | break;
|
---|
66 | }
|
---|
67 | if(orgButtonProc)
|
---|
68 | return (*orgButtonProc)(hwnd, msg, mp1, mp2);
|
---|
69 | else
|
---|
70 | return WinDefWindowProc(hwnd, msg, mp1, mp2);
|
---|
71 | }
|
---|
72 |
|
---|
73 | MRESULT EXPENTRY bgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
74 | {
|
---|
75 | switch(msg)
|
---|
76 | {
|
---|
77 | /*****************************************************/
|
---|
78 | /* Paint the background */
|
---|
79 | /*****************************************************/
|
---|
80 | case WM_PAINT:
|
---|
81 | {
|
---|
82 | SWP swp;
|
---|
83 | RECTL rcl;
|
---|
84 | HPS hps;
|
---|
85 |
|
---|
86 | WinQueryWindowPos(hwnd,&swp);
|
---|
87 | if(swp.fl & SWP_MINIMIZE)
|
---|
88 | break;
|
---|
89 |
|
---|
90 | hps=WinBeginPaint(hwnd, NULLHANDLE, NULLHANDLE);
|
---|
91 | WinQueryWindowRect(hwnd, &rcl);
|
---|
92 | WinDrawBitmap(hps, allBMPs[MAIN_BMP_IDX].hbm,
|
---|
93 | NULLHANDLE,
|
---|
94 | (PPOINTL)&rcl,
|
---|
95 | 0, 0,
|
---|
96 | DBM_IMAGEATTRS);
|
---|
97 | WinEndPaint(hps);
|
---|
98 | return MRFALSE;
|
---|
99 | }
|
---|
100 | default:
|
---|
101 | break;
|
---|
102 | }
|
---|
103 | if(orgBgProc)
|
---|
104 | return (*orgBgProc)(hwnd, msg, mp1, mp2);
|
---|
105 | else
|
---|
106 | return WinDefWindowProc(hwnd, msg, mp1, mp2);
|
---|
107 | }
|
---|
108 |
|
---|
109 | /* This function paints all our controls with the provided bitmaps */
|
---|
110 | /* It's called from the guiproc */
|
---|
111 | MRESULT paintControls(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
112 | {
|
---|
113 | USERBUTTON* ubPtr;
|
---|
114 | CONTROLINFO ci;
|
---|
115 | RECTL rcl;
|
---|
116 |
|
---|
117 | ubPtr=(USERBUTTON*)PVOIDFROMMP(mp2);
|
---|
118 | switch(SHORT1FROMMP(mp1))
|
---|
119 | {
|
---|
120 | #if 0
|
---|
121 | case IDPB_POSBAR:
|
---|
122 | ci=ciControls[CTRLIDX_POSSLIDER];//ciPosSlider;
|
---|
123 | break;
|
---|
124 | case IDPB_SLIDERARM:
|
---|
125 | DosBeep(5000, 30);
|
---|
126 | ci=ciControls[CTRLIDX_POSSLIDERARM];//ciPosSliderArm;
|
---|
127 | break;
|
---|
128 | case IDSL_VOLUME:
|
---|
129 | ci=ciControls[CTRLIDX_VOLSLIDER];//ciVolSlider;
|
---|
130 | break;
|
---|
131 | case IDSL_VOLUMEARM:
|
---|
132 | if(WinQueryCapture(HWND_DESKTOP==hwnd))
|
---|
133 | ci=ciControls[CTRLIDX_VOLSLIDERARMSEL];//ciVolSliderArm;
|
---|
134 | else
|
---|
135 | ci=ciControls[CTRLIDX_VOLSLIDERARM];//ciVolSliderArm;
|
---|
136 | break;
|
---|
137 | #endif
|
---|
138 | default:
|
---|
139 | return (MRESULT)0;
|
---|
140 | }
|
---|
141 | rcl.yBottom=0;
|
---|
142 | rcl.xLeft=0;
|
---|
143 |
|
---|
144 | WinDrawBitmap(ubPtr->hps, ci.hbmSource,
|
---|
145 | &ci.rclSource,
|
---|
146 | (PPOINTL)&rcl,
|
---|
147 | 0, 0,
|
---|
148 | DBM_IMAGEATTRS);
|
---|
149 | if(ubPtr->fsStateOld!=ubPtr->fsState)
|
---|
150 | ubPtr->fsState =( ubPtr->fsStateOld==BDS_DEFAULT ? BDS_HILITED : BDS_DEFAULT);
|
---|
151 |
|
---|
152 | return (MRESULT)0;
|
---|
153 | }
|
---|
154 |
|
---|
155 |
|
---|
156 | /* This function paints all our controls with the provided bitmaps. */
|
---|
157 | BOOL paintHilitedControl(HWND hwnd, USHORT usControl, BOOL bHilite)
|
---|
158 | {
|
---|
159 | // static ULONG ulShowFeedback=0;
|
---|
160 |
|
---|
161 | #if 0
|
---|
162 | if(!ulShowFeedback) {
|
---|
163 | /* Query the INI setting*/
|
---|
164 | if(!PrfQueryProfileInt(HINI_USERPROFILE, APPKEY_CWMM, MFLDR_NO_VISUAL_FEEDBACK, 0))
|
---|
165 | ulShowFeedback=1; /* Flash play controls */
|
---|
166 | else
|
---|
167 | ulShowFeedback=2; /* Don't flash play controls while playing */
|
---|
168 | }
|
---|
169 |
|
---|
170 |
|
---|
171 | if(ulShowFeedback==2)
|
---|
172 | return 1;
|
---|
173 |
|
---|
174 | switch(usControl)
|
---|
175 | {
|
---|
176 | case IDPB_PLAY:
|
---|
177 | if(!bHilite) {
|
---|
178 | ci=ciControls[CTRLIDX_PLAYBUTTON];
|
---|
179 | }
|
---|
180 | else {
|
---|
181 | ci=ciControls[CTRLIDX_PLAYBUTTONSEL];
|
---|
182 | }
|
---|
183 | break;
|
---|
184 | case IDPB_PAUSE:
|
---|
185 | if(!bHilite) {
|
---|
186 | ci=ciControls[CTRLIDX_PAUSEBUTTON];
|
---|
187 | }
|
---|
188 | else {
|
---|
189 | ci=ciControls[CTRLIDX_PAUSEBUTTONSEL];
|
---|
190 | }
|
---|
191 | break;
|
---|
192 | default:
|
---|
193 | return 0;
|
---|
194 | }
|
---|
195 | rcl.yBottom=0;
|
---|
196 | rcl.xLeft=0;
|
---|
197 | hps=WinGetPS(hwnd);
|
---|
198 | WinDrawBitmap(hps, ci.hbmSource,
|
---|
199 | &ci.rclSource,
|
---|
200 | (PPOINTL)&rcl,
|
---|
201 | 0, 0,
|
---|
202 | DBM_IMAGEATTRS);
|
---|
203 | WinReleasePS(hps);
|
---|
204 | #endif
|
---|
205 | return 1;
|
---|
206 | }
|
---|
207 |
|
---|
208 |
|
---|
209 | #define USERSLIDER 1 /* Set to 0 to let the proc paint the control. With set to 1
|
---|
210 | a WM_DRAWITEM msg is sent to the parent. */
|
---|
211 | BOOL userSlider=USERSLIDER;
|
---|
212 | #define SLOFFSET 3 /* The offset of the active slider area to the window border */
|
---|
213 | MRESULT EXPENTRY privateSliderProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
214 | {
|
---|
215 |
|
---|
216 | switch (msg)
|
---|
217 | {
|
---|
218 | case WM_CREATE:
|
---|
219 | {
|
---|
220 | PCREATESTRUCT pCreate=(CREATESTRUCT*)PVOIDFROMMP(mp2);
|
---|
221 |
|
---|
222 | /* Initialize the slider data */
|
---|
223 | WinSetWindowUShort(hwnd, SLIDERARMWIDTH,20);
|
---|
224 | WinSetWindowUShort(hwnd, SLIDERARMHEIGHT,10);
|
---|
225 | WinSetWindowUShort(hwnd, SLINCREMENTS,100);
|
---|
226 | /* Dimensions of slider. The slider active area is smaller than the window to
|
---|
227 | allow drawing of active state. */
|
---|
228 | WinSetWindowULong(hwnd, SLIDERCX,pCreate->cx-2*SLOFFSET);
|
---|
229 | WinSetWindowULong(hwnd, SLIDERCY,pCreate->cy-2*SLOFFSET);
|
---|
230 | WinSetWindowULong(hwnd, SLIDERX,SLOFFSET);
|
---|
231 | WinSetWindowULong(hwnd, SLIDERY,SLOFFSET);
|
---|
232 | WinSetWindowULong(hwnd, SLIDERARMPOS, 0);
|
---|
233 | WinSetWindowULong(hwnd, SLDRAGGING,FALSE);
|
---|
234 |
|
---|
235 | return (MRESULT)0;
|
---|
236 | }
|
---|
237 | case SLM_SETSLIDERINFO:
|
---|
238 | switch(SHORT1FROMMP(mp1))
|
---|
239 | {
|
---|
240 | case SMA_SLIDERARMPOSITION:
|
---|
241 | /* SMA_RANGEVALUE */
|
---|
242 | if(!WinQueryWindowULong(hwnd, SLDRAGGING)) {
|
---|
243 | if(SHORT2FROMMP(mp1)==SMA_RANGEVALUE) {
|
---|
244 | WinSetWindowULong(hwnd, SLIDERARMPOS, LONGFROMMP(mp2));
|
---|
245 | WinInvalidateRect(hwnd, NULLHANDLE,TRUE);
|
---|
246 | return (MRESULT)0;
|
---|
247 | }
|
---|
248 | else if(SHORT2FROMMP(mp1)==SMA_INCREMENTVALUE) {
|
---|
249 | LONG lInc=LONGFROMMP(mp2)*(WinQueryWindowULong(hwnd, SLIDERCX)-WinQueryWindowUShort(hwnd, SLIDERARMWIDTH));
|
---|
250 | lInc/=WinQueryWindowUShort(hwnd, SLINCREMENTS);
|
---|
251 | WinSetWindowULong(hwnd, SLIDERARMPOS, lInc);
|
---|
252 | WinInvalidateRect(hwnd, NULLHANDLE,TRUE);
|
---|
253 | return (MRESULT)0;
|
---|
254 | }
|
---|
255 | }
|
---|
256 | break;
|
---|
257 | case SMA_SLIDERARMDIMENSIONS:
|
---|
258 | WinSetWindowUShort(hwnd, SLIDERARMWIDTH, SHORT1FROMMP(mp2));
|
---|
259 | WinSetWindowUShort(hwnd, SLIDERARMHEIGHT, SHORT2FROMMP(mp2));
|
---|
260 | return (MRESULT)0;
|
---|
261 | default:
|
---|
262 | break;
|
---|
263 | }
|
---|
264 | break;
|
---|
265 | case WM_SIZE:
|
---|
266 | WinSetWindowULong(hwnd, SLIDERCX, SHORT1FROMMP(mp2)-2*SLOFFSET);
|
---|
267 | WinSetWindowULong(hwnd, SLIDERCY, SHORT2FROMMP(mp2)-2*SLOFFSET);
|
---|
268 | WinInvalidateRect(hwnd, NULLHANDLE,TRUE);
|
---|
269 | return (MRESULT)0;
|
---|
270 | case WM_BUTTON1DOWN:
|
---|
271 | {
|
---|
272 | SHORT x=SHORT1FROMMP( mp1);
|
---|
273 | SHORT y=SHORT2FROMMP( mp1);
|
---|
274 | LONG lPos=WinQueryWindowULong(hwnd, SLIDERARMPOS);
|
---|
275 | USHORT usWidth=WinQueryWindowUShort(hwnd, SLIDERARMWIDTH);
|
---|
276 |
|
---|
277 | if(x<=lPos+usWidth+SLOFFSET && x>=lPos+SLOFFSET &&
|
---|
278 | y<=WinQueryWindowUShort(hwnd, SLIDERY)+WinQueryWindowUShort(hwnd, SLIDERCY)
|
---|
279 | && y>=WinQueryWindowUShort(hwnd, SLIDERY)) {
|
---|
280 | WinSetWindowUShort(hwnd, PTRPOSINSLARM, x-lPos-SLOFFSET);
|
---|
281 | }
|
---|
282 | WinSetFocus(HWND_DESKTOP, hwnd);
|
---|
283 | break;
|
---|
284 | }
|
---|
285 | case WM_FOCUSCHANGE:
|
---|
286 | {
|
---|
287 | HPS hps;
|
---|
288 | RECTL rcl;
|
---|
289 | POINTL ptl;
|
---|
290 |
|
---|
291 | if(SHORT1FROMMP(mp2)) {
|
---|
292 | hps=WinGetPS(hwnd);
|
---|
293 | WinQueryWindowRect(hwnd, &rcl);
|
---|
294 | GpiSetLineType(hps, LINETYPE_DOT);
|
---|
295 | ptl.x=rcl.xLeft;
|
---|
296 | ptl.y=rcl.yBottom;
|
---|
297 | GpiMove(hps,&ptl);
|
---|
298 | ptl.x=rcl.xRight-1;
|
---|
299 | GpiLine(hps,&ptl);
|
---|
300 | ptl.y=rcl.yTop-1;
|
---|
301 | GpiLine(hps,&ptl);
|
---|
302 | ptl.x=rcl.xLeft;
|
---|
303 | GpiLine(hps,&ptl);
|
---|
304 | ptl.y=rcl.yBottom;
|
---|
305 | GpiLine(hps,&ptl);
|
---|
306 | WinReleasePS(hps);
|
---|
307 | }
|
---|
308 | else
|
---|
309 | WinInvalidateRect(hwnd, NULLHANDLE,TRUE);
|
---|
310 |
|
---|
311 | break;
|
---|
312 | }
|
---|
313 | case WM_CHAR:
|
---|
314 | if(WinQueryFocus(HWND_DESKTOP)==hwnd) {
|
---|
315 | if(SHORT2FROMMP(mp2)==VK_TAB && (SHORT1FROMMP(mp1) & KC_VIRTUALKEY))
|
---|
316 | if(SHORT1FROMMP(mp1) & (KC_KEYUP|KC_PREVDOWN))
|
---|
317 | return (MRESULT)TRUE;
|
---|
318 | return WinDefWindowProc(hwnd, msg, mp1, mp2);
|
---|
319 | }
|
---|
320 | break;
|
---|
321 | case WM_BUTTON1MOTIONSTART:
|
---|
322 | {
|
---|
323 | SHORT x=SHORT1FROMMP( mp1);
|
---|
324 | SHORT y=SHORT2FROMMP( mp1);
|
---|
325 | LONG lPos=WinQueryWindowULong(hwnd, SLIDERARMPOS);
|
---|
326 | USHORT usWidth=WinQueryWindowUShort(hwnd, SLIDERARMWIDTH);
|
---|
327 |
|
---|
328 | if(x<=lPos+usWidth+SLOFFSET && x>=lPos+SLOFFSET &&
|
---|
329 | y<=WinQueryWindowUShort(hwnd, SLIDERY)+WinQueryWindowUShort(hwnd, SLIDERCY)
|
---|
330 | && y>=WinQueryWindowUShort(hwnd, SLIDERY)){
|
---|
331 | // if(x<=lPos+usWidth && y<=WinQueryWindowUShort(hwnd, SLIDERY)+WinQueryWindowUShort(hwnd, SLIDERCY)
|
---|
332 | // && y>=WinQueryWindowUShort(hwnd, SLIDERY)) {
|
---|
333 | WinSetWindowULong(hwnd, SLDRAGGING, TRUE);
|
---|
334 | if(hptrArrowWE)
|
---|
335 | WinSetPointer(HWND_DESKTOP, hptrArrowWE);
|
---|
336 |
|
---|
337 | WinSetCapture(HWND_DESKTOP, hwnd);
|
---|
338 | }
|
---|
339 | break;
|
---|
340 | }
|
---|
341 | case WM_BUTTON1MOTIONEND:
|
---|
342 | if(WinQueryWindowULong(hwnd, SLDRAGGING)) {
|
---|
343 | LONG lPos=WinQueryWindowULong(hwnd, SLIDERARMPOS);
|
---|
344 | WinSetWindowULong(hwnd, SLDRAGGING,FALSE);
|
---|
345 | WinSetCapture(HWND_DESKTOP, NULLHANDLE);
|
---|
346 | lPos=(lPos*100)/(WinQueryWindowULong(hwnd, SLIDERCX)-WinQueryWindowUShort(hwnd, SLIDERARMWIDTH));
|
---|
347 | /* Post SLN_CHANGE notification */
|
---|
348 | WinPostMsg(WinQueryWindow(hwnd, QW_PARENT),WM_CONTROL,
|
---|
349 | MPFROM2SHORT(WinQueryWindowUShort(hwnd, QWS_ID), SLN_CHANGE),
|
---|
350 | MPFROMLONG(lPos));
|
---|
351 | }
|
---|
352 | break;
|
---|
353 |
|
---|
354 | case WM_MOUSEMOVE:
|
---|
355 | if(WinQueryWindowULong(hwnd, SLDRAGGING)) {
|
---|
356 |
|
---|
357 | HPS hps;
|
---|
358 | RECTL rcl, rcl2, rcl3;
|
---|
359 | LONG lTemp;
|
---|
360 | SHORT x=SHORT1FROMMP(mp1);
|
---|
361 | LONG lPos=WinQueryWindowULong(hwnd, SLIDERARMPOS);
|
---|
362 | USHORT usWidth=WinQueryWindowUShort(hwnd, SLIDERARMWIDTH);
|
---|
363 |
|
---|
364 |
|
---|
365 | lTemp=lPos;
|
---|
366 |
|
---|
367 | rcl.xLeft=WinQueryWindowULong(hwnd, SLIDERX);
|
---|
368 | rcl.yBottom=WinQueryWindowULong(hwnd, SLIDERY);
|
---|
369 | rcl.xRight=rcl.xLeft+WinQueryWindowULong(hwnd, SLIDERCX);
|
---|
370 | rcl.yTop=rcl.yBottom+WinQueryWindowULong(hwnd, SLIDERCY);
|
---|
371 |
|
---|
372 | rcl2=rcl3=rcl;
|
---|
373 | rcl.xLeft=x-WinQueryWindowUShort(hwnd, PTRPOSINSLARM);
|
---|
374 | if(rcl.xLeft<rcl2.xLeft)/* Make sure we stop at the left border */
|
---|
375 | rcl.xLeft=rcl2.xLeft;
|
---|
376 |
|
---|
377 | rcl.xRight=rcl.xLeft+usWidth;
|
---|
378 | if(rcl.xRight>rcl2.xRight)
|
---|
379 | {/* Make sure we stop at the right border */
|
---|
380 | rcl.xRight=rcl2.xRight;
|
---|
381 | rcl.xLeft=rcl.xRight-usWidth;
|
---|
382 | }
|
---|
383 | lPos=rcl.xLeft-WinQueryWindowULong(hwnd, SLIDERX);/* Save position zero based */
|
---|
384 | WinSetWindowULong(hwnd, SLIDERARMPOS, lPos);
|
---|
385 | if(lPos!=lTemp) {
|
---|
386 | BOOL rc;
|
---|
387 |
|
---|
388 | hps=WinGetPS(hwnd);
|
---|
389 | /* Paint Background not necessary here */
|
---|
390 |
|
---|
391 | /* Shaft */
|
---|
392 | /* Left part */
|
---|
393 | rcl3.xRight=rcl.xLeft;
|
---|
394 |
|
---|
395 | rc=FALSE;
|
---|
396 |
|
---|
397 | if(userSlider) {
|
---|
398 | OWNERITEM oi={0};
|
---|
399 | oi.hwnd=hwnd;
|
---|
400 | oi.hps=hps;
|
---|
401 | oi.fsState=SLS_OWNERDRAW;/* More to come */
|
---|
402 | oi.rclItem=rcl3;
|
---|
403 | oi.idItem=SDA_SLIDERSHAFT;
|
---|
404 | rc=(BOOL)WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_DRAWITEM,
|
---|
405 | MPFROMSHORT(WinQueryWindowUShort(hwnd, QWS_ID)),
|
---|
406 | MPFROMP(&oi) );
|
---|
407 | }
|
---|
408 | if(!rc)
|
---|
409 | WinFillRect(hps, &rcl3, CLR_PALEGRAY);
|
---|
410 |
|
---|
411 | /* Right part */
|
---|
412 | rcl3.xRight=rcl2.xRight;
|
---|
413 | rcl3.xLeft=rcl.xRight;
|
---|
414 | rc=FALSE;
|
---|
415 | if(userSlider) {
|
---|
416 | OWNERITEM oi={0};
|
---|
417 | oi.hwnd=hwnd;
|
---|
418 | oi.hps=hps;
|
---|
419 | oi.fsState=SLS_OWNERDRAW;/* More to come */
|
---|
420 | oi.rclItem=rcl3;
|
---|
421 | oi.idItem=SDA_SLIDERSHAFT;
|
---|
422 | rc=(BOOL)WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_DRAWITEM,
|
---|
423 | MPFROMSHORT(WinQueryWindowUShort(hwnd, QWS_ID)),
|
---|
424 | MPFROMP(&oi) );
|
---|
425 | }
|
---|
426 | if(!rc)
|
---|
427 | WinFillRect(hps, &rcl3, CLR_PALEGRAY);
|
---|
428 |
|
---|
429 | /* Paint Slider */
|
---|
430 | rc=FALSE;
|
---|
431 | if(userSlider) {
|
---|
432 | OWNERITEM oi={0};
|
---|
433 | oi.hwnd=hwnd;
|
---|
434 | oi.hps=hps;
|
---|
435 | oi.fsState=SLS_OWNERDRAW;/* More to come */
|
---|
436 | oi.rclItem=rcl;
|
---|
437 | oi.idItem=SDA_SLIDERARM;
|
---|
438 | rc=(BOOL)WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_DRAWITEM,
|
---|
439 | MPFROMSHORT(WinQueryWindowUShort(hwnd, QWS_ID)),
|
---|
440 | MPFROMP(&oi) );
|
---|
441 |
|
---|
442 | }
|
---|
443 | if(!rc)
|
---|
444 | {
|
---|
445 | WinFillRect(hps,&rcl, CLR_PALEGRAY);
|
---|
446 | WinDrawBorder(hps, &rcl, 2, 2, 0, 0 ,0x0400);
|
---|
447 | }
|
---|
448 |
|
---|
449 | WinReleasePS(hps);
|
---|
450 | lPos=(lPos*100)/(WinQueryWindowULong(hwnd, SLIDERCX)-WinQueryWindowUShort(hwnd, SLIDERARMWIDTH));
|
---|
451 | /* Post SLN_SLIDERTRACK notification */
|
---|
452 | WinPostMsg(WinQueryWindow(hwnd, QW_PARENT),WM_CONTROL,
|
---|
453 | MPFROM2SHORT(WinQueryWindowUShort(hwnd, QWS_ID), SLN_SLIDERTRACK),
|
---|
454 | MPFROMLONG(lPos));
|
---|
455 | }
|
---|
456 | return MRTRUE;
|
---|
457 | }
|
---|
458 | else {
|
---|
459 | if(hptrArrowWE) {
|
---|
460 | /* Not dragging */
|
---|
461 | /* Change pointer to drag pointer when over the arm */
|
---|
462 | SHORT x=SHORT1FROMMP( mp1);
|
---|
463 | SHORT y=SHORT2FROMMP( mp1);
|
---|
464 | LONG lPos=WinQueryWindowULong(hwnd, SLIDERARMPOS);
|
---|
465 | USHORT usWidth=WinQueryWindowUShort(hwnd, SLIDERARMWIDTH);
|
---|
466 | if(x<=lPos+usWidth+SLOFFSET && x>=lPos+SLOFFSET &&
|
---|
467 | y<=WinQueryWindowUShort(hwnd, SLIDERY)+WinQueryWindowUShort(hwnd, SLIDERCY)
|
---|
468 | && y>=WinQueryWindowUShort(hwnd, SLIDERY)) {
|
---|
469 | WinSetPointer(HWND_DESKTOP, hptrArrowWE);
|
---|
470 | // WinSetPointer(HWND_DESKTOP, WinQuerySysPointer(HWND_DESKTOP, SPTR_SIZEWE, FALSE));
|
---|
471 | return MRTRUE;
|
---|
472 | }
|
---|
473 | }
|
---|
474 | }
|
---|
475 | break;
|
---|
476 | case WM_PAINT:
|
---|
477 | {
|
---|
478 |
|
---|
479 | HPS hps, hps2;
|
---|
480 | RECTL rcl, rcl2, rcl3;
|
---|
481 | POINTL ptl;
|
---|
482 | LONG lPos=WinQueryWindowULong(hwnd, SLIDERARMPOS);
|
---|
483 | USHORT usWidth=WinQueryWindowUShort(hwnd, SLIDERARMWIDTH);
|
---|
484 | BOOL rc;
|
---|
485 |
|
---|
486 | WinQueryWindowRect(hwnd, &rcl);
|
---|
487 |
|
---|
488 | /* Shaft */
|
---|
489 | rcl2.xLeft=WinQueryWindowULong(hwnd, SLIDERX);
|
---|
490 | rcl2.yBottom=WinQueryWindowULong(hwnd, SLIDERY);
|
---|
491 | rcl2.xRight=rcl2.xLeft+WinQueryWindowULong(hwnd, SLIDERCX)-1;
|
---|
492 | rcl2.yTop=rcl2.yBottom+WinQueryWindowULong(hwnd, SLIDERCY)-1;
|
---|
493 |
|
---|
494 | /* Background */
|
---|
495 | hps2=WinGetPS(hwnd);
|
---|
496 | GpiExcludeClipRectangle(hps2,&rcl2);
|
---|
497 | rc=FALSE;
|
---|
498 | if(userSlider) {
|
---|
499 | OWNERITEM oi={0};
|
---|
500 | oi.hwnd=hwnd;
|
---|
501 | oi.hps=hps2;
|
---|
502 | oi.fsState=SLS_OWNERDRAW;/* More to come */
|
---|
503 | oi.rclItem=rcl;
|
---|
504 | oi.idItem=SDA_BACKGROUND;
|
---|
505 | rc=(BOOL)WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_DRAWITEM, MPFROMSHORT(WinQueryWindowUShort(hwnd, QWS_ID)),
|
---|
506 | MPFROMP(&oi) );
|
---|
507 | }
|
---|
508 | if(!rc)
|
---|
509 | WinFillRect(hps2, &rcl, CLR_PALEGRAY);
|
---|
510 | /* Focus */
|
---|
511 | if(WinQueryFocus(HWND_DESKTOP)==hwnd) {
|
---|
512 | GpiSetLineType(hps2, LINETYPE_DOT);
|
---|
513 | ptl.x=rcl.xLeft;
|
---|
514 | ptl.y=rcl.yBottom;
|
---|
515 | GpiMove(hps2,&ptl);
|
---|
516 | ptl.x=rcl.xRight-1;
|
---|
517 | GpiLine(hps2,&ptl);
|
---|
518 | ptl.y=rcl.yTop-1;
|
---|
519 | GpiLine(hps2,&ptl);
|
---|
520 | ptl.x=rcl.xLeft;
|
---|
521 | GpiLine(hps2,&ptl);
|
---|
522 | ptl.y=rcl.yBottom;
|
---|
523 | GpiLine(hps2,&ptl);
|
---|
524 | }
|
---|
525 |
|
---|
526 | WinReleasePS(hps2);
|
---|
527 | rcl2.yTop+=1;
|
---|
528 | rcl2.xRight+=1;
|
---|
529 | hps=WinBeginPaint(hwnd, NULLHANDLE, NULLHANDLE);
|
---|
530 | rcl3=rcl=rcl2;
|
---|
531 | /* Arm pos */
|
---|
532 | rcl2.xLeft+=lPos;
|
---|
533 | /* Arm size */
|
---|
534 | rcl2.xRight=rcl2.xLeft+usWidth;
|
---|
535 |
|
---|
536 | /* Shaft */
|
---|
537 | /* Left part */
|
---|
538 | rcl3.xRight=rcl2.xLeft;
|
---|
539 | rc=FALSE;
|
---|
540 | if(userSlider) {
|
---|
541 | OWNERITEM oi={0};
|
---|
542 | oi.hwnd=hwnd;
|
---|
543 | oi.hps=hps;
|
---|
544 | oi.fsState=SLS_OWNERDRAW;/* More to come */
|
---|
545 | oi.rclItem=rcl3;
|
---|
546 | oi.idItem=SDA_SLIDERSHAFT;
|
---|
547 | rc=(BOOL)WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_DRAWITEM, MPFROMSHORT(WinQueryWindowUShort(hwnd, QWS_ID)),
|
---|
548 | MPFROMP(&oi) );
|
---|
549 |
|
---|
550 | }
|
---|
551 | if(!rc)
|
---|
552 | WinFillRect(hps, &rcl3, CLR_GREEN);
|
---|
553 |
|
---|
554 | /* Right part */
|
---|
555 | rcl3.xRight=rcl.xRight;
|
---|
556 | rcl3.xLeft=rcl2.xRight;
|
---|
557 | rc=FALSE;
|
---|
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, MPFROMSHORT(WinQueryWindowUShort(hwnd, QWS_ID)),
|
---|
566 | MPFROMP(&oi) );
|
---|
567 | }
|
---|
568 | if(!rc)
|
---|
569 | WinFillRect(hps, &rcl3, CLR_PALEGRAY);
|
---|
570 |
|
---|
571 | rc=FALSE;
|
---|
572 | if(userSlider) {
|
---|
573 | OWNERITEM oi={0};
|
---|
574 | oi.hwnd=hwnd;
|
---|
575 | oi.hps=hps;
|
---|
576 | oi.fsState=SLS_OWNERDRAW;/* More to come */
|
---|
577 | oi.rclItem=rcl2;
|
---|
578 | oi.idItem=SDA_SLIDERARM;
|
---|
579 | rc=(BOOL)WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_DRAWITEM, MPFROMSHORT(WinQueryWindowUShort(hwnd, QWS_ID)),
|
---|
580 | MPFROMP(&oi) );
|
---|
581 | }
|
---|
582 | if(!rc)
|
---|
583 | {
|
---|
584 | WinFillRect(hps,&rcl2, CLR_PALEGRAY);
|
---|
585 | WinDrawBorder(hps, &rcl2, 2, 2, 0, 0 ,0x0400);
|
---|
586 | }
|
---|
587 |
|
---|
588 | WinEndPaint(hps);
|
---|
589 | return (MRESULT)0;
|
---|
590 | }
|
---|
591 | break;
|
---|
592 | default:
|
---|
593 | break;
|
---|
594 | }
|
---|
595 | return WinDefWindowProc(hwnd, msg, mp1, mp2);
|
---|
596 | }
|
---|
597 |
|
---|
598 | MRESULT drawSlider(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2, USHORT id)
|
---|
599 | {
|
---|
600 | POWNERITEM poi;
|
---|
601 | CONTROLINFO ci, ciArm;
|
---|
602 |
|
---|
603 | poi=(POWNERITEM)PVOIDFROMMP(mp2);
|
---|
604 |
|
---|
605 | switch(id)
|
---|
606 | {
|
---|
607 | case IDSL_MMPLAYERVOLUME:
|
---|
608 | ci=ciControls[CTRLIDX_VOLSLIDER];//ciVolSlider;
|
---|
609 | // if(WinQueryCapture(HWND_DESKTOP==hwnd))
|
---|
610 | ciArm=ciControls[CTRLIDX_VOLSLIDERARMSEL];//ciVolSliderArm;
|
---|
611 | // else
|
---|
612 | // ciArm=ciControls[CTRLIDX_VOLSLIDERARM];//ciVolSliderArm;
|
---|
613 | break;
|
---|
614 | default:
|
---|
615 | return (MRESULT)FALSE;
|
---|
616 | }
|
---|
617 |
|
---|
618 | switch(poi->idItem)
|
---|
619 | {
|
---|
620 | case SDA_SLIDERARM:
|
---|
621 | if(ciArm.hbmSource)
|
---|
622 | //DosBeep(5000, 50);
|
---|
623 | WinDrawBitmap(poi->hps, ciArm.hbmSource,
|
---|
624 | &ciArm.rclSource,
|
---|
625 | (PPOINTL)&poi->rclItem,
|
---|
626 | 0, 0,
|
---|
627 | DBM_IMAGEATTRS);
|
---|
628 | // WinFillRect(poi->hps,&poi->rclItem, CLR_RED);
|
---|
629 | return (MRESULT) TRUE;
|
---|
630 | case SDA_BACKGROUND:
|
---|
631 | {
|
---|
632 | WinDrawBitmap(poi->hps,
|
---|
633 | ci.hbmSource,
|
---|
634 | &ci.rclSource,
|
---|
635 | (PPOINTL)&poi->rclItem,
|
---|
636 | 0, 0,
|
---|
637 | DBM_IMAGEATTRS);
|
---|
638 | // WinFillRect(poi->hps,&poi->rclItem, CLR_WHITE);
|
---|
639 | return (MRESULT) TRUE;
|
---|
640 | }
|
---|
641 | case SDA_SLIDERSHAFT:
|
---|
642 | {
|
---|
643 | RECTL rcl;
|
---|
644 |
|
---|
645 | rcl=ci.rclSource;
|
---|
646 | rcl.xLeft+=poi->rclItem.xLeft;
|
---|
647 | rcl.xRight=rcl.xLeft+(poi->rclItem.xRight-poi->rclItem.xLeft);
|
---|
648 | rcl.yBottom+=SLOFFSET;
|
---|
649 | rcl.yTop-=SLOFFSET;
|
---|
650 |
|
---|
651 | if(!WinDrawBitmap(poi->hps, ci.hbmSource,
|
---|
652 | &rcl,
|
---|
653 | //&ci.rclSource,
|
---|
654 | (PPOINTL)&poi->rclItem,
|
---|
655 | 0, 0,
|
---|
656 | DBM_IMAGEATTRS))
|
---|
657 | return (MRESULT)FALSE;
|
---|
658 | return (MRESULT)TRUE;
|
---|
659 | }
|
---|
660 | default:
|
---|
661 | return (MRESULT)TRUE;
|
---|
662 | }
|
---|
663 | /* Done */
|
---|
664 | return (MRESULT)TRUE;
|
---|
665 | }
|
---|
666 |
|
---|
667 |
|
---|
668 |
|
---|