comparison os2/dw.c @ 153:a371875d5486

Sync up with the latest F/X sources.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Wed, 06 Nov 2002 17:28:04 +0000
parents e78027768548
children 7f8fcce45bdd
comparison
equal deleted inserted replaced
152:e78027768548 153:a371875d5486
341 else 341 else
342 { 342 {
343 char tmpbuf[100] = ""; 343 char tmpbuf[100] = "";
344 344
345 WinQueryClassName(box->items[z].hwnd, 99, tmpbuf); 345 WinQueryClassName(box->items[z].hwnd, 99, tmpbuf);
346 if(strncmp(tmpbuf, "#40", 4)==0) /* Notebook */ 346 if(strncmp(tmpbuf, SplitbarClassName, strlen(SplitbarClassName)+1)==0)
347 {
348 /* Then try the bottom or right box */
349 HWND mybox = (HWND)dw_window_get_data(box->items[z].hwnd, "_dw_bottomright");
350
351 if(mybox)
352 {
353 Box *splitbox = (Box *)WinQueryWindowPtr(mybox, QWP_USER);
354
355 if(splitbox && _focus_check_box(splitbox, handle, start == 3 ? 3 : 0, defaultitem))
356 return 1;
357 }
358
359 /* Try the top or left box */
360 mybox = (HWND)dw_window_get_data(box->items[z].hwnd, "_dw_topleft");
361
362 if(mybox)
363 {
364 Box *splitbox = (Box *)WinQueryWindowPtr(mybox, QWP_USER);
365
366 if(splitbox && _focus_check_box(splitbox, handle, start == 3 ? 3 : 0, defaultitem))
367 return 1;
368 }
369 }
370 else if(strncmp(tmpbuf, "#40", 4)==0) /* Notebook */
347 { 371 {
348 Box *notebox; 372 Box *notebox;
349 HWND page = (HWND)WinSendMsg(box->items[z].hwnd, BKM_QUERYPAGEWINDOWHWND, 373 HWND page = (HWND)WinSendMsg(box->items[z].hwnd, BKM_QUERYPAGEWINDOWHWND,
350 (MPARAM)dw_notebook_page_query(box->items[z].hwnd), 0); 374 (MPARAM)dw_notebook_page_query(box->items[z].hwnd), 0);
351 375
1355 } 1379 }
1356 else 1380 else
1357 WinSetFocus(HWND_DESKTOP, handle); 1381 WinSetFocus(HWND_DESKTOP, handle);
1358 } 1382 }
1359 1383
1384 #define ENTRY_CUT 1001
1385 #define ENTRY_COPY 1002
1386 #define ENTRY_PASTE 1003
1387
1388 /* Originally just intended for entryfields, it now serves as a generic
1389 * procedure for handling TAB presses to change input focus on controls.
1390 */
1391 MRESULT EXPENTRY _entryproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)
1392 {
1393 WindowData *blah = (WindowData *)WinQueryWindowPtr(hWnd, QWP_USER);
1394 PFNWP oldproc = 0;
1395 char tmpbuf[100];
1396
1397 if(blah)
1398 oldproc = blah->oldproc;
1399
1400 WinQueryClassName(hWnd, 99, tmpbuf);
1401
1402 /* These are the window classes which should get a menu */
1403 if(strncmp(tmpbuf, "#2", 3)==0 || /* Combobox */
1404 strncmp(tmpbuf, "#6", 3)==0 || /* Entryfield */
1405 strncmp(tmpbuf, "#10", 4)==0 || /* MLE */
1406 strncmp(tmpbuf, "#32", 4)==0) /* Spinbutton */
1407 {
1408 switch(msg)
1409 {
1410 case WM_CONTEXTMENU:
1411 {
1412 HWND menuitem;
1413 HMENUI hwndMenu = dw_menu_new(0L);
1414 long x, y;
1415
1416 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)))
1418 {
1419 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);
1421 }
1422
1423 dw_pointer_query_pos(&x, &y);
1424 dw_menu_popup(&hwndMenu, hWnd, x, y);
1425 }
1426 break;
1427 case WM_COMMAND:
1428 {
1429 ULONG command = COMMANDMSG(&msg)->cmd;
1430
1431 /* MLE */
1432 if(strncmp(tmpbuf, "#10", 4)==0)
1433 {
1434 switch(command)
1435 {
1436 case ENTRY_CUT:
1437 return WinSendMsg(hWnd, MLM_CUT, 0, 0);
1438 case ENTRY_COPY:
1439 return WinSendMsg(hWnd, MLM_COPY, 0, 0);
1440 case ENTRY_PASTE:
1441 return WinSendMsg(hWnd, MLM_PASTE, 0, 0);
1442 }
1443 }
1444 else /* Other */
1445 {
1446 HWND handle = hWnd;
1447
1448 /* Get the entryfield handle from multi window controls */
1449 if(strncmp(tmpbuf, "#2", 3)==0)
1450 handle = WinWindowFromID(hWnd, 667);
1451 if(strncmp(tmpbuf, "#32", 4)==0)
1452 handle = WinWindowFromID(hWnd, 1703);
1453
1454 if(handle)
1455 {
1456 switch(command)
1457 {
1458 case ENTRY_CUT:
1459 return WinSendMsg(handle, EM_CUT, 0, 0);
1460 case ENTRY_COPY:
1461 return WinSendMsg(handle, EM_COPY, 0, 0);
1462 case ENTRY_PASTE:
1463 return WinSendMsg(handle, EM_PASTE, 0, 0);
1464 }
1465 }
1466 }
1467 }
1468 break;
1469 }
1470 }
1471
1472 switch(msg)
1473 {
1474 case WM_BUTTON1DOWN:
1475 case WM_BUTTON2DOWN:
1476 case WM_BUTTON3DOWN:
1477 {
1478 if(strncmp(tmpbuf, "#32", 4)==0)
1479 _run_event(hWnd, WM_SETFOCUS, (MPARAM)FALSE, (MPARAM)TRUE);
1480 }
1481 break;
1482 case WM_CONTROL:
1483 {
1484 if(strncmp(tmpbuf, "#38", 4)==0)
1485 _run_event(hWnd, msg, mp1, mp2);
1486 }
1487 break;
1488 case WM_SETFOCUS:
1489 _run_event(hWnd, msg, mp1, mp2);
1490 break;
1491 case WM_CHAR:
1492 if(SHORT1FROMMP(mp2) == '\t')
1493 {
1494 if(CHARMSG(&msg)->fs & KC_SHIFT)
1495 _shift_focus_back(hWnd);
1496 else
1497 _shift_focus(hWnd);
1498 return FALSE;
1499 }
1500 else if(SHORT1FROMMP(mp2) == '\r' && blah && blah->clickdefault)
1501 _click_default(blah->clickdefault);
1502 /* When you hit escape we get this value and the
1503 * window hangs for reasons unknown. (in an MLE)
1504 */
1505 else if(SHORT1FROMMP(mp2) == 283)
1506 return (MRESULT)TRUE;
1507
1508 break;
1509 case WM_SIZE:
1510 {
1511 /* If it's a slider... make sure it shows the correct value */
1512 if(strncmp(tmpbuf, "#38", 4)==0)
1513 WinPostMsg(hWnd, WM_USER+7, 0, 0);
1514 }
1515 break;
1516 case WM_USER+7:
1517 {
1518 int pos = (int)dw_window_get_data(hWnd, "_dw_slider_value");
1519 WinSendMsg(hWnd, SLM_SETSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_INCREMENTVALUE), (MPARAM)pos);
1520 }
1521 break;
1522 }
1523
1524 if(oldproc)
1525 return oldproc(hWnd, msg, mp1, mp2);
1526
1527 return WinDefWindowProc(hWnd, msg, mp1, mp2);
1528 }
1529
1530 /* Deal with combobox specifics and enhancements */
1360 MRESULT EXPENTRY _comboentryproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2) 1531 MRESULT EXPENTRY _comboentryproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)
1361 { 1532 {
1362 WindowData *blah = (WindowData *)WinQueryWindowPtr(hWnd, QWP_USER); 1533 WindowData *blah = (WindowData *)WinQueryWindowPtr(hWnd, QWP_USER);
1363 1534
1364 switch(msg) 1535 switch(msg)
1365 { 1536 {
1537 case WM_CONTEXTMENU:
1538 case WM_COMMAND:
1539 return _entryproc(hWnd, msg, mp1, mp2);
1366 case WM_SETFOCUS: 1540 case WM_SETFOCUS:
1367 _run_event(hWnd, msg, mp1, mp2); 1541 _run_event(hWnd, msg, mp1, mp2);
1368 break; 1542 break;
1369 case WM_CHAR: 1543 case WM_CHAR:
1370 /* A Similar problem to the MLE, if ESC just return */ 1544 /* A Similar problem to the MLE, if ESC just return */
1377 return blah->oldproc(hWnd, msg, mp1, mp2); 1551 return blah->oldproc(hWnd, msg, mp1, mp2);
1378 1552
1379 return WinDefWindowProc(hWnd, msg, mp1, mp2); 1553 return WinDefWindowProc(hWnd, msg, mp1, mp2);
1380 } 1554 }
1381 1555
1382 /* Originally just intended for entryfields, it now serves as a generic 1556 /* Enhance the standard OS/2 MLE control */
1383 * procedure for handling TAB presses to change input focus on controls. 1557 MRESULT EXPENTRY _mleproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)
1384 */ 1558 {
1385 MRESULT EXPENTRY _entryproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)
1386 {
1387 WindowData *blah = (WindowData *)WinQueryWindowPtr(hWnd, QWP_USER);
1388 PFNWP oldproc = 0;
1389
1390 if(blah)
1391 oldproc = blah->oldproc;
1392
1393 switch(msg) 1559 switch(msg)
1394 { 1560 {
1395 case WM_BUTTON1DOWN: 1561 case WM_VSCROLL:
1396 case WM_BUTTON2DOWN: 1562 if(SHORT2FROMMP(mp2) == SB_SLIDERTRACK)
1397 case WM_BUTTON3DOWN: 1563 {
1398 { 1564 USHORT pos = SHORT1FROMMP(mp2);
1399 char tmpbuf[100]; 1565
1400 1566 return WinSendMsg(hWnd, msg, mp1, MPFROM2SHORT(pos, SB_SLIDERPOSITION));
1401 WinQueryClassName(hWnd, 99, tmpbuf);
1402
1403 if(strncmp(tmpbuf, "#32", 4)==0)
1404 _run_event(hWnd, WM_SETFOCUS, (MPARAM)FALSE, (MPARAM)TRUE);
1405 } 1567 }
1406 break; 1568 break;
1407 case WM_CONTROL: 1569 }
1408 { 1570 return _entryproc(hWnd, msg, mp1, mp2);
1409 char tmpbuf[100];
1410
1411 WinQueryClassName(hWnd, 99, tmpbuf);
1412
1413 if(strncmp(tmpbuf, "#38", 4)==0)
1414 _run_event(hWnd, msg, mp1, mp2);
1415 }
1416 break;
1417 case WM_SETFOCUS:
1418 _run_event(hWnd, msg, mp1, mp2);
1419 break;
1420 case WM_CHAR:
1421 if(SHORT1FROMMP(mp2) == '\t')
1422 {
1423 if(CHARMSG(&msg)->fs & KC_SHIFT)
1424 _shift_focus_back(hWnd);
1425 else
1426 _shift_focus(hWnd);
1427 return FALSE;
1428 }
1429 else if(SHORT1FROMMP(mp2) == '\r' && blah && blah->clickdefault)
1430 _click_default(blah->clickdefault);
1431 /* When you hit escape we get this value and the
1432 * window hangs for reasons unknown. (in an MLE)
1433 */
1434 else if(SHORT1FROMMP(mp2) == 283)
1435 return (MRESULT)TRUE;
1436
1437 break;
1438 case WM_SIZE:
1439 {
1440 char tmpbuf[100];
1441
1442 WinQueryClassName(hWnd, 99, tmpbuf);
1443
1444 /* If it's a slider... make sure it shows the correct value */
1445 if(strncmp(tmpbuf, "#38", 4)==0)
1446 WinPostMsg(hWnd, WM_USER+7, 0, 0);
1447 }
1448 break;
1449 case WM_USER+7:
1450 {
1451 int pos = (int)dw_window_get_data(hWnd, "_dw_slider_value");
1452 WinSendMsg(hWnd, SLM_SETSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_INCREMENTVALUE), (MPARAM)pos);
1453 }
1454 break;
1455 }
1456
1457 if(oldproc)
1458 return oldproc(hWnd, msg, mp1, mp2);
1459
1460 return WinDefWindowProc(hWnd, msg, mp1, mp2);
1461 } 1571 }
1462 1572
1463 int _dw_int_pos(HWND hwnd) 1573 int _dw_int_pos(HWND hwnd)
1464 { 1574 {
1465 int pos = (int)dw_window_get_data(hwnd, "_dw_percent_value"); 1575 int pos = (int)dw_window_get_data(hwnd, "_dw_percent_value");
3692 HWND_TOP, 3802 HWND_TOP,
3693 id, 3803 id,
3694 NULL, 3804 NULL,
3695 NULL); 3805 NULL);
3696 dw_window_set_font(tmp, DefaultFont); 3806 dw_window_set_font(tmp, DefaultFont);
3697 blah->oldproc = WinSubclassWindow(tmp, _entryproc); 3807 blah->oldproc = WinSubclassWindow(tmp, _mleproc);
3698 WinSetWindowPtr(tmp, QWP_USER, blah); 3808 WinSetWindowPtr(tmp, QWP_USER, blah);
3699 return tmp; 3809 return tmp;
3700 } 3810 }
3701 3811
3702 /* 3812 /*
4739 * handle: Handle to the MLE to be positioned. 4849 * handle: Handle to the MLE to be positioned.
4740 * line: Line to be visible. 4850 * line: Line to be visible.
4741 */ 4851 */
4742 void dw_mle_set_visible(HWND handle, int line) 4852 void dw_mle_set_visible(HWND handle, int line)
4743 { 4853 {
4744 int tmppnt; 4854 int tmppnt = (int)WinSendMsg(handle, MLM_CHARFROMLINE, MPFROMLONG(line), 0);
4745 4855 WinSendMsg(handle, MLM_SETSEL, MPFROMLONG(tmppnt), MPFROMLONG(tmppnt));
4746 if(line > 10)
4747 {
4748 tmppnt = (int)WinSendMsg(handle, MLM_CHARFROMLINE, MPFROMLONG(line - 10), 0);
4749 WinSendMsg(handle, MLM_SETFIRSTCHAR, MPFROMLONG(tmppnt), 0);
4750 }
4751 } 4856 }
4752 4857
4753 /* 4858 /*
4754 * Sets the editablity of an MLE box. 4859 * Sets the editablity of an MLE box.
4755 * Parameters: 4860 * Parameters: