comparison os2/dw.c @ 62:2be5174bdb5d

Sync with latest DW code. Tab and RGB fixes.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sat, 08 Dec 2001 04:47:43 +0000
parents 4a02842f8074
children a6801a2260af
comparison
equal deleted inserted replaced
61:4a02842f8074 62:2be5174bdb5d
184 184
185 WinQueryClassName(child, 99, tmpbuf); 185 WinQueryClassName(child, 99, tmpbuf);
186 186
187 if(strncmp(tmpbuf, "#3", 3)==0 && dw) /* Button */ 187 if(strncmp(tmpbuf, "#3", 3)==0 && dw) /* Button */
188 WinSetOwner(child, dw); 188 WinSetOwner(child, dw);
189 if(strncmp(tmpbuf, "#38", 4)==0 && dw) /* Slider */
190 WinSetOwner(child, 0);
189 else if(strncmp(tmpbuf, "dynamicwindows", 14) == 0) 191 else if(strncmp(tmpbuf, "dynamicwindows", 14) == 0)
190 dw = child; 192 dw = child;
191 193
192 _fix_button_owner(child, dw); 194 _fix_button_owner(child, dw);
193 } 195 }
1361 } 1363 }
1362 1364
1363 /* This procedure handles drawing of a percent bar */ 1365 /* This procedure handles drawing of a percent bar */
1364 MRESULT EXPENTRY _percentproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2) 1366 MRESULT EXPENTRY _percentproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)
1365 { 1367 {
1366 PercentBar *blah = (PercentBar *)WinQueryWindowPtr(hWnd, QWP_USER); 1368 WindowData *blah = (WindowData *)WinQueryWindowPtr(hWnd, QWP_USER);
1367 1369
1368 if(blah) 1370 if(blah)
1369 { 1371 return blah->oldproc(hWnd, msg, mp1, mp2);
1370 PFNWP myfunc = blah->oldproc;
1371
1372 switch(msg)
1373 {
1374 case WM_PAINT:
1375 {
1376 HPS hpsPaint;
1377 RECTL rclPaint, rclBar;
1378
1379 hpsPaint = WinBeginPaint(hWnd, 0, 0);
1380 WinQueryWindowRect(hWnd, &rclPaint);
1381
1382 /* Draw outer border */
1383 rclBar = rclPaint;
1384 GpiSetColor(hpsPaint, CLR_PALEGRAY);
1385 _Top(hpsPaint, rclBar);
1386 _Bottom(hpsPaint, rclBar);
1387 rclBar.yTop--;
1388 GpiSetColor(hpsPaint, CLR_WHITE);
1389 _Right(hpsPaint, rclBar);
1390 rclBar.yBottom++;
1391 GpiSetColor(hpsPaint, CLR_DARKGRAY);
1392 _Left(hpsPaint, rclBar);
1393
1394 /* Draw inner border */
1395 rclBar.xLeft++;
1396 rclBar.xRight--;
1397 GpiSetColor(hpsPaint, CLR_DARKGRAY);
1398 _Left(hpsPaint, rclBar);
1399 _Top(hpsPaint, rclBar);
1400 GpiSetColor(hpsPaint, CLR_WHITE);
1401 _Bottom(hpsPaint, rclBar);
1402 _Right(hpsPaint, rclBar);
1403
1404 /* Draw bar border */
1405 rclBar.xLeft++;
1406 rclBar.xRight--;
1407 rclBar.yBottom++;
1408 rclBar.yTop--;
1409 GpiSetColor(hpsPaint, CLR_DARKGRAY);
1410 _Left(hpsPaint, rclBar);
1411 _Top(hpsPaint, rclBar);
1412 _Bottom(hpsPaint, rclBar);
1413 _Right(hpsPaint, rclBar);
1414
1415 if(blah->pos)
1416 {
1417 rclBar.xRight = 3 + blah->pos;
1418 _Right(hpsPaint, rclBar);
1419
1420 /* Draw Bar itself */
1421 rclBar.xLeft = rclPaint.xLeft + 3;
1422 rclBar.xRight = rclPaint.xLeft + 2 + blah->pos;
1423 rclBar.yTop = rclPaint.yTop - 3;
1424 rclBar.yBottom = rclPaint.yBottom + 3;
1425
1426 WinFillRect(hpsPaint, &rclBar, CLR_DARKBLUE);
1427 }
1428
1429 /* Draw the background */
1430 rclBar.xLeft = rclPaint.xLeft + 3 + blah->pos;
1431 rclBar.xRight = rclPaint.xRight - 3;
1432 rclBar.yTop = rclPaint.yTop - 3;
1433 rclBar.yBottom = rclPaint.yBottom + 3;
1434
1435 WinFillRect(hpsPaint, &rclBar, CLR_PALEGRAY);
1436
1437 WinEndPaint(hpsPaint);
1438
1439 return (MRESULT)TRUE;
1440 }
1441 }
1442 return myfunc(hWnd, msg, mp1, mp2);
1443 }
1444 1372
1445 return WinDefWindowProc(hWnd, msg, mp1, mp2); 1373 return WinDefWindowProc(hWnd, msg, mp1, mp2);
1446 } 1374 }
1447 1375
1448 void _click_default(HWND handle) 1376 void _click_default(HWND handle)
4028 * Parameters: 3956 * Parameters:
4029 * id: An ID to be used with WinWindowFromID() or 0L. 3957 * id: An ID to be used with WinWindowFromID() or 0L.
4030 */ 3958 */
4031 HWND dw_percent_new(ULONG id) 3959 HWND dw_percent_new(ULONG id)
4032 { 3960 {
4033 PercentBar *blah = malloc(sizeof(PercentBar)); 3961 WindowData *blah = calloc(1, sizeof(WindowData));
4034 HWND tmp = WinCreateWindow(HWND_OBJECT, 3962 HWND tmp = WinCreateWindow(HWND_OBJECT,
4035 WC_STATIC, 3963 WC_SLIDER,
4036 "", 3964 "",
4037 WS_VISIBLE | SS_TEXT, 3965 WS_VISIBLE | SLS_READONLY
3966 | SLS_RIBBONSTRIP,
4038 0,0,2000,1000, 3967 0,0,2000,1000,
4039 NULLHANDLE, 3968 NULLHANDLE,
4040 HWND_TOP, 3969 HWND_TOP,
4041 id, 3970 id,
4042 NULL, 3971 NULL,
4043 NULL); 3972 NULL);
4044 dw_window_set_font(tmp, DefaultFont);
4045 dw_window_set_color(tmp, DW_CLR_BLUE, DW_CLR_PALEGRAY);
4046 3973
4047 blah->oldproc = WinSubclassWindow(tmp, _percentproc); 3974 blah->oldproc = WinSubclassWindow(tmp, _percentproc);
4048 blah->pos = 0;
4049 WinSetWindowPtr(tmp, QWP_USER, blah); 3975 WinSetWindowPtr(tmp, QWP_USER, blah);
4050 return tmp; 3976 return tmp;
4051 } 3977 }
4052 3978
4053 /* 3979 /*
4898 * Parameters: 4824 * Parameters:
4899 * handle: Handle to the slider to be queried. 4825 * handle: Handle to the slider to be queried.
4900 */ 4826 */
4901 unsigned int dw_percent_query_range(HWND handle) 4827 unsigned int dw_percent_query_range(HWND handle)
4902 { 4828 {
4903 unsigned long width; 4829 return SHORT2FROMMP(WinSendMsg(handle, SLM_QUERYSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION,SMA_RANGEVALUE), 0));
4904
4905 dw_window_get_pos_size(handle, 0, 0, &width, 0);
4906
4907 if(width - 6 < 1)
4908 return 1;
4909 return width - 6;
4910 } 4830 }
4911 4831
4912 /* 4832 /*
4913 * Sets the percent bar position. 4833 * Sets the percent bar position.
4914 * Parameters: 4834 * Parameters:
4915 * handle: Handle to the slider to be set. 4835 * handle: Handle to the slider to be set.
4916 * position: Position of the slider withing the range. 4836 * position: Position of the slider withing the range.
4917 */ 4837 */
4918 void dw_percent_set_pos(HWND handle, unsigned int position) 4838 void dw_percent_set_pos(HWND handle, unsigned int position)
4919 { 4839 {
4920 PercentBar *pb = (PercentBar *)WinQueryWindowPtr(handle, 0); 4840 WinSendMsg(handle, SLM_SETSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION,SMA_RANGEVALUE), (MPARAM)position);
4921
4922 if(pb)
4923 {
4924 RECTL rcl;
4925
4926 pb->pos = position;
4927 WinQueryWindowRect(handle, &rcl);
4928 WinInvalidateRect(handle, &rcl, FALSE);
4929 }
4930 } 4841 }
4931 4842
4932 /* 4843 /*
4933 * Sets the spinbutton value. 4844 * Sets the spinbutton value.
4934 * Parameters: 4845 * Parameters: