comparison os2/dw.c @ 61:4a02842f8074

Added shift-tab and up/down/left/right button support. And added missing checkbox fix for windows.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Wed, 05 Dec 2001 06:03:49 +0000
parents 61869769c050
children 2be5174bdb5d
comparison
equal deleted inserted replaced
60:61869769c050 61:4a02842f8074
437 } 437 }
438 } 438 }
439 return 0; 439 return 0;
440 } 440 }
441 441
442 int _focus_check_box_back(Box *box, HWND handle, int start, HWND defaultitem)
443 {
444 int z;
445 static HWND lasthwnd, firsthwnd;
446 static int finish_searching;
447
448 /* Start is 2 when we have cycled completely and
449 * need to set the focus to the last widget we found
450 * that was valid.
451 */
452 if(start == 2)
453 {
454 if(lasthwnd)
455 WinSetFocus(HWND_DESKTOP, lasthwnd);
456 return 0;
457 }
458
459 /* Start is 1 when we are entering the function
460 * for the first time, it is zero when entering
461 * the function recursively.
462 */
463 if(start == 1)
464 {
465 lasthwnd = handle;
466 finish_searching = 0;
467 firsthwnd = 0;
468 }
469
470 /* Vertical boxes are inverted on OS/2 */
471 if(box->type == BOXVERT)
472 {
473 for(z=box->count-1;z>-1;z--)
474 {
475 if(box->items[z].type == TYPEBOX)
476 {
477 Box *thisbox = WinQueryWindowPtr(box->items[z].hwnd, QWP_USER);
478
479 if(thisbox && _focus_check_box_back(thisbox, handle, start == 3 ? 3 : 0, defaultitem))
480 return 1;
481 }
482 else
483 {
484 if(box->items[z].hwnd == handle)
485 {
486 if(lasthwnd == handle && firsthwnd)
487 WinSetFocus(HWND_DESKTOP, firsthwnd);
488 else if(lasthwnd == handle && !firsthwnd)
489 finish_searching = 1;
490 else
491 WinSetFocus(HWND_DESKTOP, lasthwnd);
492
493 /* If we aren't looking for the last handle,
494 * return immediately.
495 */
496 if(!finish_searching)
497 return 1;
498 }
499 if(_validate_focus(box->items[z].hwnd))
500 {
501 /* Start is 3 when we are looking for the
502 * first valid item in the layout.
503 */
504 if(start == 3)
505 {
506 if(!defaultitem || (defaultitem && defaultitem == box->items[z].hwnd))
507 {
508 WinSetFocus(HWND_DESKTOP, box->items[z].hwnd);
509 return 1;
510 }
511 }
512
513 if(!firsthwnd)
514 firsthwnd = box->items[z].hwnd;
515
516 lasthwnd = box->items[z].hwnd;
517 }
518 else
519 {
520 char tmpbuf[100] = "";
521
522 WinQueryClassName(box->items[z].hwnd, 99, tmpbuf);
523 if(strncmp(tmpbuf, "#40", 3)==0) /* Notebook */
524 {
525 Box *notebox;
526 HWND page = (HWND)WinSendMsg(box->items[z].hwnd, BKM_QUERYPAGEWINDOWHWND,
527 (MPARAM)dw_notebook_page_query(box->items[z].hwnd), 0);
528
529 if(page)
530 {
531 notebox = (Box *)WinQueryWindowPtr(page, QWP_USER);
532
533 if(notebox && _focus_check_box_back(notebox, handle, start == 3 ? 3 : 0, defaultitem))
534 return 1;
535 }
536 }
537 }
538 }
539 }
540 }
541 else
542 {
543 for(z=0;z<box->count;z++)
544 {
545 if(box->items[z].type == TYPEBOX)
546 {
547 Box *thisbox = WinQueryWindowPtr(box->items[z].hwnd, QWP_USER);
548
549 if(thisbox && _focus_check_box_back(thisbox, handle, start == 3 ? 3 : 0, defaultitem))
550 return 1;
551 }
552 else
553 {
554 if(box->items[z].hwnd == handle)
555 {
556 if(lasthwnd == handle && firsthwnd)
557 WinSetFocus(HWND_DESKTOP, firsthwnd);
558 else if(lasthwnd == handle && !firsthwnd)
559 finish_searching = 1;
560 else
561 WinSetFocus(HWND_DESKTOP, lasthwnd);
562
563 /* If we aren't looking for the last handle,
564 * return immediately.
565 */
566 if(!finish_searching)
567 return 1;
568 }
569 if(_validate_focus(box->items[z].hwnd))
570 {
571 /* Start is 3 when we are looking for the
572 * first valid item in the layout.
573 */
574 if(start == 3)
575 {
576 if(!defaultitem || (defaultitem && defaultitem == box->items[z].hwnd))
577 {
578 WinSetFocus(HWND_DESKTOP, box->items[z].hwnd);
579 return 1;
580 }
581 }
582
583 if(!firsthwnd)
584 firsthwnd = box->items[z].hwnd;
585
586 lasthwnd = box->items[z].hwnd;
587 }
588 else
589 {
590 char tmpbuf[100] = "";
591
592 WinQueryClassName(box->items[z].hwnd, 99, tmpbuf);
593 if(strncmp(tmpbuf, "#40", 3)==0) /* Notebook */
594 {
595 Box *notebox;
596 HWND page = (HWND)WinSendMsg(box->items[z].hwnd, BKM_QUERYPAGEWINDOWHWND,
597 (MPARAM)dw_notebook_page_query(box->items[z].hwnd), 0);
598
599 if(page)
600 {
601 notebox = (Box *)WinQueryWindowPtr(page, QWP_USER);
602
603 if(notebox && _focus_check_box_back(notebox, handle, start == 3 ? 3 : 0, defaultitem))
604 return 1;
605 }
606 }
607 }
608 }
609 }
610 }
611 return 0;
612 }
613
442 /* This function finds the first widget in the 614 /* This function finds the first widget in the
443 * layout and moves the current focus to it. 615 * layout and moves the current focus to it.
444 */ 616 */
445 int _initial_focus(HWND handle) 617 int _initial_focus(HWND handle)
446 { 618 {
480 652
481 if(thisbox) 653 if(thisbox)
482 { 654 {
483 if(_focus_check_box(thisbox, handle, 1, 0) == 0) 655 if(_focus_check_box(thisbox, handle, 1, 0) == 0)
484 _focus_check_box(thisbox, handle, 2, 0); 656 _focus_check_box(thisbox, handle, 2, 0);
657 }
658 }
659
660 /* This function finds the current widget in the
661 * layout and moves the current focus to the next item.
662 */
663 void _shift_focus_back(HWND handle)
664 {
665 Box *thisbox;
666 HWND box, lastbox = WinQueryWindow(handle, QW_PARENT);
667
668 /* Find the toplevel window */
669 while((box = WinQueryWindow(lastbox, QW_PARENT)) > 0x80000001)
670 {
671 lastbox = box;
672 }
673
674 box = WinWindowFromID(lastbox, FID_CLIENT);
675 if(box)
676 thisbox = WinQueryWindowPtr(box, QWP_USER);
677 else
678 thisbox = WinQueryWindowPtr(lastbox, QWP_USER);
679
680 if(thisbox)
681 {
682 if(_focus_check_box_back(thisbox, handle, 1, 0) == 0)
683 _focus_check_box_back(thisbox, handle, 2, 0);
485 } 684 }
486 } 685 }
487 686
488 /* ResetWindow: 687 /* ResetWindow:
489 * Resizes window to the exact same size to trigger 688 * Resizes window to the exact same size to trigger
1328 _run_event(hWnd, msg, mp1, mp2); 1527 _run_event(hWnd, msg, mp1, mp2);
1329 break; 1528 break;
1330 case WM_CHAR: 1529 case WM_CHAR:
1331 if(SHORT1FROMMP(mp2) == '\t') 1530 if(SHORT1FROMMP(mp2) == '\t')
1332 { 1531 {
1333 _shift_focus(hWnd); 1532 if(CHARMSG(&msg)->fs & KC_SHIFT)
1533 _shift_focus_back(hWnd);
1534 else
1535 _shift_focus(hWnd);
1334 return FALSE; 1536 return FALSE;
1335 } 1537 }
1336 else if(SHORT1FROMMP(mp2) == '\r' && blah && blah->clickdefault) 1538 else if(SHORT1FROMMP(mp2) == '\r' && blah && blah->clickdefault)
1337 _click_default(blah->clickdefault); 1539 _click_default(blah->clickdefault);
1338 1540
1359 switch(msg) 1561 switch(msg)
1360 { 1562 {
1361 case WM_CHAR: 1563 case WM_CHAR:
1362 if(SHORT1FROMMP(mp2) == '\t') 1564 if(SHORT1FROMMP(mp2) == '\t')
1363 { 1565 {
1364 _shift_focus(hWnd); 1566 if(CHARMSG(&msg)->fs & KC_SHIFT)
1567 _shift_focus_back(hWnd);
1568 else
1569 _shift_focus(hWnd);
1365 return FALSE; 1570 return FALSE;
1366 } 1571 }
1367 else if(SHORT1FROMMP(mp2) == '\r' && blah && blah->clickdefault) 1572 else if(SHORT1FROMMP(mp2) == '\r' && blah && blah->clickdefault)
1368 _click_default(blah->clickdefault); 1573 _click_default(blah->clickdefault);
1369 break; 1574 break;
1984 windowfunc((void *)mp2); 2189 windowfunc((void *)mp2);
1985 break; 2190 break;
1986 case WM_CHAR: 2191 case WM_CHAR:
1987 if(SHORT1FROMMP(mp2) == '\t') 2192 if(SHORT1FROMMP(mp2) == '\t')
1988 { 2193 {
1989 _shift_focus(hWnd); 2194 if(CHARMSG(&msg)->fs & KC_SHIFT)
2195 _shift_focus_back(hWnd);
2196 else
2197 _shift_focus(hWnd);
1990 return FALSE; 2198 return FALSE;
1991 } 2199 }
1992 break; 2200 break;
1993 case WM_DESTROY: 2201 case WM_DESTROY:
1994 /* Free memory before destroying */ 2202 /* Free memory before destroying */
2408 } 2616 }
2409 } 2617 }
2410 #endif 2618 #endif
2411 if(SHORT1FROMMP(mp2) == '\t') 2619 if(SHORT1FROMMP(mp2) == '\t')
2412 { 2620 {
2621 if(CHARMSG(&msg)->fs & KC_SHIFT)
2622 _shift_focus_back(hwnd);
2623 else
2624 _shift_focus(hwnd);
2625 WinSendMsg(hwnd, BM_SETDEFAULT, 0, 0);
2626 return FALSE;
2627 }
2628 else if(!(CHARMSG(&msg)->fs & KC_KEYUP) && (CHARMSG(&msg)->vkey == VK_LEFT || CHARMSG(&msg)->vkey == VK_UP))
2629 {
2630 _shift_focus_back(hwnd);
2631 return FALSE;
2632 }
2633 else if(!(CHARMSG(&msg)->fs & KC_KEYUP) && (CHARMSG(&msg)->vkey == VK_RIGHT || CHARMSG(&msg)->vkey == VK_DOWN))
2634 {
2413 _shift_focus(hwnd); 2635 _shift_focus(hwnd);
2414 WinSendMsg(hwnd, BM_SETDEFAULT, 0, 0);
2415 return FALSE; 2636 return FALSE;
2416 } 2637 }
2417 } 2638 }
2418 break; 2639 break;
2419 case 0x041f: 2640 case 0x041f:
2426 2647
2427 case 0x041e: 2648 case 0x041e:
2428 2649
2429 if(!*bubble->bubbletext) 2650 if(!*bubble->bubbletext)
2430 break; 2651 break;
2431
2432 2652
2433 if(hwndBubble) 2653 if(hwndBubble)
2434 { 2654 {
2435 WinDestroyWindow(hwndBubble); 2655 WinDestroyWindow(hwndBubble);
2436 hwndBubble = 0; 2656 hwndBubble = 0;