comparison os2/dw.c @ 155:840c54766306

Another sync of sources, enhancements to dw_window_set_color() ... works completely on Windows now and added DW_CLR_DEFAULT. Also color pairs don't need to be of the same type anymore.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Thu, 07 Nov 2002 22:31:02 +0000
parents 7f8fcce45bdd
children 63258b34e70d
comparison
equal deleted inserted replaced
154:7f8fcce45bdd 155:840c54766306
1382 } 1382 }
1383 1383
1384 #define ENTRY_CUT 1001 1384 #define ENTRY_CUT 1001
1385 #define ENTRY_COPY 1002 1385 #define ENTRY_COPY 1002
1386 #define ENTRY_PASTE 1003 1386 #define ENTRY_PASTE 1003
1387 #define ENTRY_UNDO 1004
1388 #define ENTRY_SALL 1005
1387 1389
1388 /* Originally just intended for entryfields, it now serves as a generic 1390 /* Originally just intended for entryfields, it now serves as a generic
1389 * procedure for handling TAB presses to change input focus on controls. 1391 * procedure for handling TAB presses to change input focus on controls.
1390 */ 1392 */
1391 MRESULT EXPENTRY _entryproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2) 1393 MRESULT EXPENTRY _entryproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)
1411 { 1413 {
1412 HWND menuitem; 1414 HWND menuitem;
1413 HMENUI hwndMenu = dw_menu_new(0L); 1415 HMENUI hwndMenu = dw_menu_new(0L);
1414 long x, y; 1416 long x, y;
1415 1417
1418 if(strncmp(tmpbuf, "#10", 4)==0 && !WinSendMsg(hWnd, MLM_QUERYREADONLY, 0, 0))
1419 {
1420 menuitem = dw_menu_append_item(hwndMenu, "Undo", ENTRY_UNDO, 0L, TRUE, FALSE, 0L);
1421 dw_menu_append_item(hwndMenu, "", 0L, 0L, TRUE, FALSE, 0L);
1422 }
1416 menuitem = dw_menu_append_item(hwndMenu, "Copy", ENTRY_COPY, 0L, TRUE, FALSE, 0L); 1423 menuitem = dw_menu_append_item(hwndMenu, "Copy", ENTRY_COPY, 0L, TRUE, FALSE, 0L);
1417 if(strncmp(tmpbuf, "#10", 4)!=0 || (strncmp(tmpbuf, "#10", 4)==0 && !WinSendMsg(hWnd, MLM_QUERYREADONLY, 0, 0))) 1424 if(strncmp(tmpbuf, "#10", 4)!=0 || (strncmp(tmpbuf, "#10", 4)==0 && !WinSendMsg(hWnd, MLM_QUERYREADONLY, 0, 0)))
1418 { 1425 {
1419 menuitem = dw_menu_append_item(hwndMenu, "Cut", ENTRY_CUT, 0L, TRUE, FALSE, 0L); 1426 menuitem = dw_menu_append_item(hwndMenu, "Cut", ENTRY_CUT, 0L, TRUE, FALSE, 0L);
1420 menuitem = dw_menu_append_item(hwndMenu, "Paste", ENTRY_PASTE, 0L, TRUE, FALSE, 0L); 1427 menuitem = dw_menu_append_item(hwndMenu, "Paste", ENTRY_PASTE, 0L, TRUE, FALSE, 0L);
1421 } 1428 }
1422 1429 dw_menu_append_item(hwndMenu, "", 0L, 0L, TRUE, FALSE, 0L);
1430 menuitem = dw_menu_append_item(hwndMenu, "Select All", ENTRY_SALL, 0L, TRUE, FALSE, 0L);
1431
1432 WinSetFocus(HWND_DESKTOP, hWnd);
1423 dw_pointer_query_pos(&x, &y); 1433 dw_pointer_query_pos(&x, &y);
1424 dw_menu_popup(&hwndMenu, hWnd, x, y); 1434 dw_menu_popup(&hwndMenu, hWnd, x, y);
1425 } 1435 }
1426 break; 1436 break;
1427 case WM_COMMAND: 1437 case WM_COMMAND:
1437 return WinSendMsg(hWnd, MLM_CUT, 0, 0); 1447 return WinSendMsg(hWnd, MLM_CUT, 0, 0);
1438 case ENTRY_COPY: 1448 case ENTRY_COPY:
1439 return WinSendMsg(hWnd, MLM_COPY, 0, 0); 1449 return WinSendMsg(hWnd, MLM_COPY, 0, 0);
1440 case ENTRY_PASTE: 1450 case ENTRY_PASTE:
1441 return WinSendMsg(hWnd, MLM_PASTE, 0, 0); 1451 return WinSendMsg(hWnd, MLM_PASTE, 0, 0);
1452 case ENTRY_UNDO:
1453 return WinSendMsg(hWnd, MLM_UNDO, 0, 0);
1454 case ENTRY_SALL:
1455 {
1456 ULONG len = (ULONG)WinSendMsg(hWnd, MLM_QUERYTEXTLENGTH, 0, 0);
1457 return WinSendMsg(hWnd, MLM_SETSEL, 0, (MPARAM)len);
1458 }
1442 } 1459 }
1443 } 1460 }
1444 else /* Other */ 1461 else /* Other */
1445 { 1462 {
1446 HWND handle = hWnd; 1463 HWND handle = hWnd;
1459 return WinSendMsg(handle, EM_CUT, 0, 0); 1476 return WinSendMsg(handle, EM_CUT, 0, 0);
1460 case ENTRY_COPY: 1477 case ENTRY_COPY:
1461 return WinSendMsg(handle, EM_COPY, 0, 0); 1478 return WinSendMsg(handle, EM_COPY, 0, 0);
1462 case ENTRY_PASTE: 1479 case ENTRY_PASTE:
1463 return WinSendMsg(handle, EM_PASTE, 0, 0); 1480 return WinSendMsg(handle, EM_PASTE, 0, 0);
1481 case ENTRY_SALL:
1482 {
1483 LONG len = WinQueryWindowTextLength(hWnd);
1484 return WinSendMsg(hWnd, EM_SETSEL, MPFROM2SHORT(0, (SHORT)len), 0);
1485 }
1464 } 1486 }
1465 } 1487 }
1466 } 1488 }
1467 } 1489 }
1468 break; 1490 break;
1561 case WM_VSCROLL: 1583 case WM_VSCROLL:
1562 if(SHORT2FROMMP(mp2) == SB_SLIDERTRACK) 1584 if(SHORT2FROMMP(mp2) == SB_SLIDERTRACK)
1563 { 1585 {
1564 USHORT pos = SHORT1FROMMP(mp2); 1586 USHORT pos = SHORT1FROMMP(mp2);
1565 1587
1566 return WinSendMsg(hWnd, msg, mp1, MPFROM2SHORT(pos, SB_SLIDERPOSITION)); 1588 WinSendMsg(hWnd, msg, mp1, MPFROM2SHORT(pos, SB_SLIDERPOSITION));
1567 } 1589 }
1568 break; 1590 break;
1569 } 1591 }
1570 return _entryproc(hWnd, msg, mp1, mp2); 1592 return _entryproc(hWnd, msg, mp1, mp2);
1571 } 1593 }
3202 rgb2.fcOptions = 0; 3224 rgb2.fcOptions = 0;
3203 3225
3204 WinSetPresParam(handle, PP_FOREGROUNDCOLOR, sizeof(RGB2), &rgb2); 3226 WinSetPresParam(handle, PP_FOREGROUNDCOLOR, sizeof(RGB2), &rgb2);
3205 3227
3206 } 3228 }
3229 else if(fore != DW_CLR_DEFAULT)
3230 {
3231 if(fore == DW_CLR_BLACK)
3232 fore = CLR_BLACK;
3233 if(fore == DW_CLR_WHITE)
3234 fore = CLR_WHITE;
3235
3236 WinSetPresParam(handle, PP_FOREGROUNDCOLORINDEX, sizeof(ULONG), &fore);
3237 }
3207 if((back & DW_RGB_COLOR) == DW_RGB_COLOR) 3238 if((back & DW_RGB_COLOR) == DW_RGB_COLOR)
3208 { 3239 {
3209 RGB2 rgb2; 3240 RGB2 rgb2;
3210 3241
3211 rgb2.bBlue = DW_BLUE_VALUE(back); 3242 rgb2.bBlue = DW_BLUE_VALUE(back);
3214 rgb2.fcOptions = 0; 3245 rgb2.fcOptions = 0;
3215 3246
3216 WinSetPresParam(handle, PP_BACKGROUNDCOLOR, sizeof(RGB2), &rgb2); 3247 WinSetPresParam(handle, PP_BACKGROUNDCOLOR, sizeof(RGB2), &rgb2);
3217 return 0; 3248 return 0;
3218 } 3249 }
3219 if((fore & DW_RGB_COLOR) == DW_RGB_COLOR) 3250 else if(back != DW_CLR_DEFAULT)
3220 return 0; 3251 {
3221 3252 if(back == DW_CLR_BLACK)
3222 /* Slight conversion */ 3253 back = CLR_BLACK;
3223 if(fore == DW_CLR_BLACK) 3254 if(back == DW_CLR_WHITE)
3224 fore = CLR_BLACK; 3255 back = CLR_WHITE;
3225 if(fore == DW_CLR_WHITE) 3256
3226 fore = CLR_WHITE; 3257 WinSetPresParam(handle, PP_BACKGROUNDCOLORINDEX, sizeof(ULONG), &back);
3227 3258 }
3228 if(back == DW_CLR_BLACK) 3259 return 0;
3229 back = CLR_BLACK;
3230 if(back == DW_CLR_WHITE)
3231 back = CLR_WHITE;
3232
3233 return (WinSetPresParam(handle, PP_FOREGROUNDCOLORINDEX, sizeof(ULONG), &fore) |
3234 WinSetPresParam(handle, PP_BACKGROUNDCOLORINDEX, sizeof(ULONG), &back));
3235 } 3260 }
3236 3261
3237 /* 3262 /*
3238 * Sets the font used by a specified window (widget) handle. 3263 * Sets the font used by a specified window (widget) handle.
3239 * Parameters: 3264 * Parameters: