Mercurial > dwindows
comparison os2/dw.c @ 7:005fa766e8c2
Updates to latest build.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Tue, 03 Jul 2001 13:54:29 +0000 |
parents | 67a643a734d9 |
children | e22584460709 |
comparison
equal
deleted
inserted
replaced
6:160798fd63c4 | 7:005fa766e8c2 |
---|---|
960 return myfunc(hWnd, msg, mp1, mp2); | 960 return myfunc(hWnd, msg, mp1, mp2); |
961 } | 961 } |
962 | 962 |
963 return WinDefWindowProc(hWnd, msg, mp1, mp2); | 963 return WinDefWindowProc(hWnd, msg, mp1, mp2); |
964 } | 964 } |
965 /* This procedure handles drawing of a status border */ | |
966 MRESULT EXPENTRY _statusproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2) | |
967 { | |
968 PFNWP *blah = WinQueryWindowPtr(hWnd, QWP_USER); | |
969 | |
970 if(blah && *blah) | |
971 { | |
972 PFNWP myfunc = *blah; | |
973 | |
974 switch(msg) | |
975 { | |
976 case WM_PAINT: | |
977 { | |
978 HPS hpsPaint; | |
979 RECTL rclPaint; | |
980 POINTL ptl1, ptl2; | |
981 char buf[1024]; | |
982 | |
983 hpsPaint = WinBeginPaint(hWnd, 0, 0); | |
984 WinQueryWindowRect(hWnd, &rclPaint); | |
985 WinFillRect(hpsPaint, &rclPaint, CLR_PALEGRAY); | |
986 | |
987 GpiSetColor(hpsPaint, CLR_DARKGRAY); | |
988 ptl1.x = 0; | |
989 ptl2.y = ptl1.y = rclPaint.yTop - rclPaint.yBottom; | |
990 ptl2.x = rclPaint.xRight - rclPaint.xLeft; | |
991 GpiMove(hpsPaint, &ptl1); | |
992 GpiLine(hpsPaint, &ptl2); | |
993 ptl2.y = ptl2.x = 0; | |
994 GpiMove(hpsPaint, &ptl1); | |
995 GpiLine(hpsPaint, &ptl2); | |
996 | |
997 GpiSetColor(hpsPaint, CLR_WHITE); | |
998 ptl2.x = ptl1.x = rclPaint.xRight - rclPaint.xLeft; | |
999 ptl1.y = 0; | |
1000 ptl2.y = rclPaint.yTop - rclPaint.yBottom; | |
1001 GpiMove(hpsPaint, &ptl1); | |
1002 GpiLine(hpsPaint, &ptl2); | |
1003 ptl2.y = ptl2.x = 0; | |
1004 GpiMove(hpsPaint, &ptl1); | |
1005 GpiLine(hpsPaint, &ptl2); | |
1006 | |
1007 WinQueryWindowText(hWnd, 1024, buf); | |
1008 rclPaint.xLeft += 3; | |
1009 rclPaint.xRight--; | |
1010 rclPaint.yTop--; | |
1011 rclPaint.yBottom++; | |
1012 | |
1013 GpiSetColor(hpsPaint, CLR_BLACK); | |
1014 WinDrawText(hpsPaint, -1, buf, &rclPaint, DT_TEXTATTRS, DT_TEXTATTRS, DT_VCENTER | DT_LEFT | DT_TEXTATTRS); | |
1015 WinEndPaint(hpsPaint); | |
1016 | |
1017 return (MRESULT)TRUE; | |
1018 } | |
1019 } | |
1020 return myfunc(hWnd, msg, mp1, mp2); | |
1021 } | |
1022 | |
1023 return WinDefWindowProc(hWnd, msg, mp1, mp2); | |
1024 } | |
1025 | |
965 /* Originally just intended for entryfields, it now serves as a generic | 1026 /* Originally just intended for entryfields, it now serves as a generic |
966 * procedure for handling TAB presses to change input focus on controls. | 1027 * procedure for handling TAB presses to change input focus on controls. |
967 */ | 1028 */ |
968 MRESULT EXPENTRY _entryproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2) | 1029 MRESULT EXPENTRY _entryproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2) |
969 { | 1030 { |
1409 Box *mybox = (Box *)WinQueryWindowPtr(hWnd, QWP_USER); | 1470 Box *mybox = (Box *)WinQueryWindowPtr(hWnd, QWP_USER); |
1410 | 1471 |
1411 if(!SHORT1FROMMP(mp2) && !SHORT2FROMMP(mp2)) | 1472 if(!SHORT1FROMMP(mp2) && !SHORT2FROMMP(mp2)) |
1412 return (MPARAM)TRUE; | 1473 return (MPARAM)TRUE; |
1413 | 1474 |
1414 if(mybox) | 1475 if(mybox && mybox->flags != DW_MINIMIZED) |
1415 { | 1476 { |
1416 /* Hide the window when recalculating to reduce | 1477 /* Hide the window when recalculating to reduce |
1417 * CPU load. | 1478 * CPU load. |
1418 */ | 1479 */ |
1419 WinShowWindow(hWnd, FALSE); | 1480 WinShowWindow(hWnd, FALSE); |
1427 case WM_MINMAXFRAME: | 1488 case WM_MINMAXFRAME: |
1428 { | 1489 { |
1429 Box *mybox = (Box *)WinQueryWindowPtr(hWnd, QWP_USER); | 1490 Box *mybox = (Box *)WinQueryWindowPtr(hWnd, QWP_USER); |
1430 SWP *swp = (SWP *)mp1; | 1491 SWP *swp = (SWP *)mp1; |
1431 | 1492 |
1493 if(mybox && (swp->fl & SWP_MINIMIZE)) | |
1494 mybox->flags = DW_MINIMIZED; | |
1495 | |
1496 if(mybox && (swp->fl & SWP_RESTORE)) | |
1497 mybox->flags = 0; | |
1498 | |
1432 if(mybox && (swp->fl & SWP_MAXIMIZE)) | 1499 if(mybox && (swp->fl & SWP_MAXIMIZE)) |
1433 { | 1500 { |
1434 int z; | 1501 int z; |
1502 | |
1503 mybox->flags = 0; | |
1435 | 1504 |
1436 /* Hide the window when recalculating to reduce | 1505 /* Hide the window when recalculating to reduce |
1437 * CPU load. | 1506 * CPU load. |
1438 */ | 1507 */ |
1439 WinShowWindow(hWnd, FALSE); | 1508 WinShowWindow(hWnd, FALSE); |
2507 tmp = WinCreateWindow(HWND_OBJECT, | 2576 tmp = WinCreateWindow(HWND_OBJECT, |
2508 WC_NOTEBOOK, | 2577 WC_NOTEBOOK, |
2509 NULL, | 2578 NULL, |
2510 WS_VISIBLE | | 2579 WS_VISIBLE | |
2511 BKS_TABBEDDIALOG | | 2580 BKS_TABBEDDIALOG | |
2512 flags, | 2581 flags, |
2513 0,0,2000,1000, | 2582 0,0,2000,1000, |
2514 NULLHANDLE, | 2583 NULLHANDLE, |
2515 HWND_TOP, | 2584 HWND_TOP, |
2516 id, | 2585 id, |
2517 NULL, | 2586 NULL, |
2741 id, | 2810 id, |
2742 NULL, | 2811 NULL, |
2743 NULL); | 2812 NULL); |
2744 dw_window_set_font(tmp, DefaultFont); | 2813 dw_window_set_font(tmp, DefaultFont); |
2745 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_PALEGRAY); | 2814 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_PALEGRAY); |
2815 return tmp; | |
2816 } | |
2817 | |
2818 /* | |
2819 * Create a new status text window (widget) to be packed. | |
2820 * Parameters: | |
2821 * text: The text to be display by the static text widget. | |
2822 * id: An ID to be used with WinWindowFromID() or 0L. | |
2823 */ | |
2824 HWND dw_status_text_new(char *text, ULONG id) | |
2825 { | |
2826 PFNWP *blah = malloc(sizeof(PFNWP)); | |
2827 HWND tmp = WinCreateWindow(HWND_OBJECT, | |
2828 WC_STATIC, | |
2829 text, | |
2830 WS_VISIBLE | SS_TEXT, | |
2831 0,0,2000,1000, | |
2832 NULLHANDLE, | |
2833 HWND_TOP, | |
2834 id, | |
2835 NULL, | |
2836 NULL); | |
2837 dw_window_set_font(tmp, DefaultFont); | |
2838 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_PALEGRAY); | |
2839 | |
2840 *blah = WinSubclassWindow(tmp, _statusproc); | |
2841 WinSetWindowPtr(tmp, QWP_USER, blah); | |
2746 return tmp; | 2842 return tmp; |
2747 } | 2843 } |
2748 | 2844 |
2749 /* | 2845 /* |
2750 * Create a new Multiline Editbox window (widget) to be packed. | 2846 * Create a new Multiline Editbox window (widget) to be packed. |
2951 * Create a new spinbutton window (widget) to be packed. | 3047 * Create a new spinbutton window (widget) to be packed. |
2952 * Parameters: | 3048 * Parameters: |
2953 * text: The text to be display by the static text widget. | 3049 * text: The text to be display by the static text widget. |
2954 * id: An ID to be used with WinWindowFromID() or 0L. | 3050 * id: An ID to be used with WinWindowFromID() or 0L. |
2955 */ | 3051 */ |
2956 HWND | 3052 HWND dw_spinbutton_new(char *text, ULONG id) |
2957 dw_spinbutton_new(char *text, ULONG id) | |
2958 { | 3053 { |
2959 PFNWP *blah = malloc(sizeof(PFNWP)); | 3054 PFNWP *blah = malloc(sizeof(PFNWP)); |
2960 HWND tmp = WinCreateWindow(HWND_OBJECT, | 3055 HWND tmp = WinCreateWindow(HWND_OBJECT, |
2961 WC_SPINBUTTON, | 3056 WC_SPINBUTTON, |
2962 text, | 3057 text, |
3768 if(line > 10) | 3863 if(line > 10) |
3769 { | 3864 { |
3770 tmppnt = (int)WinSendMsg(handle, MLM_CHARFROMLINE, MPFROMLONG(line - 10), 0); | 3865 tmppnt = (int)WinSendMsg(handle, MLM_CHARFROMLINE, MPFROMLONG(line - 10), 0); |
3771 WinSendMsg(handle, MLM_SETFIRSTCHAR, MPFROMLONG(tmppnt), 0); | 3866 WinSendMsg(handle, MLM_SETFIRSTCHAR, MPFROMLONG(tmppnt), 0); |
3772 } | 3867 } |
3868 } | |
3869 | |
3870 /* | |
3871 * Sets the editablity of an MLE box. | |
3872 * Parameters: | |
3873 * handle: Handle to the MLE. | |
3874 * state: TRUE if it can be edited, FALSE for readonly. | |
3875 */ | |
3876 void dw_mle_set_editable(HWND handle, int state) | |
3877 { | |
3878 WinSendMsg(handle, MLM_SETREADONLY, MPFROMLONG(state ? FALSE : TRUE), 0); | |
3879 } | |
3880 | |
3881 /* | |
3882 * Sets the word wrap state of an MLE box. | |
3883 * Parameters: | |
3884 * handle: Handle to the MLE. | |
3885 * state: TRUE if it wraps, FALSE if it doesn't. | |
3886 */ | |
3887 void dw_mle_set_word_wrap(HWND handle, int state) | |
3888 { | |
3773 } | 3889 } |
3774 | 3890 |
3775 /* | 3891 /* |
3776 * Sets the current cursor position of an MLE box. | 3892 * Sets the current cursor position of an MLE box. |
3777 * Parameters: | 3893 * Parameters: |