Mercurial > dwindows
comparison win/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 | a6801a2260af |
comparison
equal
deleted
inserted
replaced
60:61869769c050 | 61:4a02842f8074 |
---|---|
457 } | 457 } |
458 } | 458 } |
459 return 0; | 459 return 0; |
460 } | 460 } |
461 | 461 |
462 int _focus_check_box_back(Box *box, HWND handle, int start, HWND defaultitem) | |
463 { | |
464 int z; | |
465 static HWND lasthwnd, firsthwnd; | |
466 static int finish_searching; | |
467 | |
468 /* Start is 2 when we have cycled completely and | |
469 * need to set the focus to the last widget we found | |
470 * that was valid. | |
471 */ | |
472 if(start == 2) | |
473 { | |
474 if(lasthwnd) | |
475 SetFocus(lasthwnd); | |
476 return 0; | |
477 } | |
478 | |
479 /* Start is 1 when we are entering the function | |
480 * for the first time, it is zero when entering | |
481 * the function recursively. | |
482 */ | |
483 if(start == 1) | |
484 { | |
485 lasthwnd = handle; | |
486 finish_searching = 0; | |
487 firsthwnd = 0; | |
488 } | |
489 | |
490 for(z=0;z<box->count;z++) | |
491 { | |
492 if(box->items[z].type == TYPEBOX) | |
493 { | |
494 Box *thisbox = (Box *)GetWindowLong(box->items[z].hwnd, GWL_USERDATA); | |
495 | |
496 if(thisbox && _focus_check_box_back(thisbox, handle, start == 3 ? 3 : 0, defaultitem)) | |
497 return 1; | |
498 } | |
499 else | |
500 { | |
501 if(box->items[z].hwnd == handle) | |
502 { | |
503 if(lasthwnd == handle && firsthwnd) | |
504 SetFocus(firsthwnd); | |
505 else if(lasthwnd == handle && !firsthwnd) | |
506 finish_searching = 1; | |
507 else | |
508 SetFocus(lasthwnd); | |
509 | |
510 /* If we aren't looking for the last handle, | |
511 * return immediately. | |
512 */ | |
513 if(!finish_searching) | |
514 return 1; | |
515 } | |
516 if(_validate_focus(box->items[z].hwnd)) | |
517 { | |
518 /* Start is 3 when we are looking for the | |
519 * first valid item in the layout. | |
520 */ | |
521 if(start == 3) | |
522 { | |
523 if(!defaultitem || (defaultitem && box->items[z].hwnd == defaultitem)) | |
524 { | |
525 SetFocus(_normalize_handle(box->items[z].hwnd)); | |
526 return 1; | |
527 } | |
528 } | |
529 | |
530 if(!firsthwnd) | |
531 firsthwnd = _normalize_handle(box->items[z].hwnd); | |
532 | |
533 lasthwnd = _normalize_handle(box->items[z].hwnd); | |
534 } | |
535 else | |
536 { | |
537 char tmpbuf[100] = ""; | |
538 | |
539 GetClassName(box->items[z].hwnd, tmpbuf, 99); | |
540 | |
541 if(strnicmp(tmpbuf, WC_TABCONTROL, strlen(WC_TABCONTROL))==0) /* Notebook */ | |
542 { | |
543 NotebookPage **array = (NotebookPage **)GetWindowLong(box->items[z].hwnd, GWL_USERDATA); | |
544 int pageid = TabCtrl_GetCurSel(box->items[z].hwnd); | |
545 | |
546 if(pageid > -1 && array && array[pageid]) | |
547 { | |
548 Box *notebox; | |
549 | |
550 if(array[pageid]->hwnd) | |
551 { | |
552 notebox = (Box *)GetWindowLong(array[pageid]->hwnd, GWL_USERDATA); | |
553 | |
554 if(notebox && _focus_check_box_back(notebox, handle, start == 3 ? 3 : 0, defaultitem)) | |
555 return 1; | |
556 } | |
557 } | |
558 } | |
559 } | |
560 } | |
561 } | |
562 return 0; | |
563 } | |
564 | |
462 /* This function finds the first widget in the | 565 /* This function finds the first widget in the |
463 * layout and moves the current focus to it. | 566 * layout and moves the current focus to it. |
464 */ | 567 */ |
465 void _initial_focus(HWND handle) | 568 void _initial_focus(HWND handle) |
466 { | 569 { |
503 thisbox = (Box *)GetWindowLong(lastbox, GWL_USERDATA); | 606 thisbox = (Box *)GetWindowLong(lastbox, GWL_USERDATA); |
504 if(thisbox) | 607 if(thisbox) |
505 { | 608 { |
506 if(_focus_check_box(thisbox, handle, 1, 0) == 0) | 609 if(_focus_check_box(thisbox, handle, 1, 0) == 0) |
507 _focus_check_box(thisbox, handle, 2, 0); | 610 _focus_check_box(thisbox, handle, 2, 0); |
611 } | |
612 } | |
613 | |
614 /* This function finds the current widget in the | |
615 * layout and moves the current focus to the next item. | |
616 */ | |
617 void _shift_focus_back(HWND handle) | |
618 { | |
619 Box *thisbox; | |
620 | |
621 HWND box, lastbox = GetParent(handle); | |
622 | |
623 /* Find the toplevel window */ | |
624 while((box = GetParent(lastbox))) | |
625 { | |
626 lastbox = box; | |
627 } | |
628 | |
629 thisbox = (Box *)GetWindowLong(lastbox, GWL_USERDATA); | |
630 if(thisbox) | |
631 { | |
632 if(_focus_check_box_back(thisbox, handle, 1, 0) == 0) | |
633 _focus_check_box_back(thisbox, handle, 2, 0); | |
508 } | 634 } |
509 } | 635 } |
510 | 636 |
511 /* ResetWindow: | 637 /* ResetWindow: |
512 * Resizes window to the exact same size to trigger | 638 * Resizes window to the exact same size to trigger |
1330 } | 1456 } |
1331 break; | 1457 break; |
1332 case WM_CHAR: | 1458 case WM_CHAR: |
1333 if(LOWORD(mp1) == '\t') | 1459 if(LOWORD(mp1) == '\t') |
1334 { | 1460 { |
1335 _shift_focus(hWnd); | 1461 if(GetAsyncKeyState(VK_SHIFT)) |
1462 _shift_focus_back(hWnd); | |
1463 else | |
1464 _shift_focus(hWnd); | |
1336 return TRUE; | 1465 return TRUE; |
1337 } | 1466 } |
1338 break; | 1467 break; |
1339 case WM_USER: | 1468 case WM_USER: |
1340 windowfunc = (void *)mp1; | 1469 windowfunc = (void *)mp1; |
1651 _wndproc(hWnd, msg, mp1, mp2); | 1780 _wndproc(hWnd, msg, mp1, mp2); |
1652 break; | 1781 break; |
1653 case WM_CHAR: | 1782 case WM_CHAR: |
1654 if(LOWORD(mp1) == '\t') | 1783 if(LOWORD(mp1) == '\t') |
1655 { | 1784 { |
1656 if(cinfo->combo) | 1785 if(GetAsyncKeyState(VK_SHIFT)) |
1657 _shift_focus(cinfo->combo); | 1786 { |
1658 else if(cinfo->buddy) | 1787 if(cinfo->combo) |
1659 _shift_focus(cinfo->buddy); | 1788 _shift_focus_back(cinfo->combo); |
1789 else if(cinfo->buddy) | |
1790 _shift_focus_back(cinfo->buddy); | |
1791 else | |
1792 _shift_focus_back(hWnd); | |
1793 } | |
1660 else | 1794 else |
1661 _shift_focus(hWnd); | 1795 { |
1796 if(cinfo->combo) | |
1797 _shift_focus(cinfo->combo); | |
1798 else if(cinfo->buddy) | |
1799 _shift_focus(cinfo->buddy); | |
1800 else | |
1801 _shift_focus(hWnd); | |
1802 } | |
1662 return FALSE; | 1803 return FALSE; |
1663 } | 1804 } |
1664 else if(LOWORD(mp1) == '\r') | 1805 else if(LOWORD(mp1) == '\r') |
1665 { | 1806 { |
1666 if(cinfo->clickdefault) | 1807 if(cinfo->clickdefault) |
1785 LV_ITEM lvi; | 1926 LV_ITEM lvi; |
1786 int iItem; | 1927 int iItem; |
1787 | 1928 |
1788 if(LOWORD(mp1) == '\t') | 1929 if(LOWORD(mp1) == '\t') |
1789 { | 1930 { |
1790 _shift_focus(hWnd); | 1931 if(GetAsyncKeyState(VK_SHIFT)) |
1932 _shift_focus_back(hWnd); | |
1933 else | |
1934 _shift_focus(hWnd); | |
1791 return FALSE; | 1935 return FALSE; |
1792 } | 1936 } |
1793 | 1937 |
1794 if(msg == WM_CHAR && (char)mp1 != '\r') | 1938 if(msg == WM_CHAR && (char)mp1 != '\r') |
1795 break; | 1939 break; |
1876 break; | 2020 break; |
1877 #else | 2021 #else |
1878 case WM_CHAR: | 2022 case WM_CHAR: |
1879 if(LOWORD(mp1) == '\t') | 2023 if(LOWORD(mp1) == '\t') |
1880 { | 2024 { |
1881 _shift_focus(hWnd); | 2025 if(GetAsyncKeyState(VK_SHIFT)) |
2026 _shift_focus_back(hWnd); | |
2027 else | |
2028 _shift_focus(hWnd); | |
1882 return FALSE; | 2029 return FALSE; |
1883 } | 2030 } |
1884 break; | 2031 break; |
1885 #endif | 2032 #endif |
1886 } | 2033 } |
2259 } | 2406 } |
2260 } | 2407 } |
2261 #endif | 2408 #endif |
2262 if(LOWORD(mp1) == '\t') | 2409 if(LOWORD(mp1) == '\t') |
2263 { | 2410 { |
2264 _shift_focus(hwnd); | 2411 if(GetAsyncKeyState(VK_SHIFT)) |
2412 _shift_focus_back(hwnd); | |
2413 else | |
2414 _shift_focus(hwnd); | |
2265 return FALSE; | 2415 return FALSE; |
2266 } | 2416 } |
2267 } | 2417 } |
2418 break; | |
2419 case WM_KEYDOWN: | |
2420 if(mp1 == VK_LEFT || mp1 == VK_UP) | |
2421 _shift_focus_back(hwnd); | |
2422 if(mp1 == VK_RIGHT || mp1 == VK_DOWN) | |
2423 _shift_focus(hwnd); | |
2268 break; | 2424 break; |
2269 case WM_TIMER: | 2425 case WM_TIMER: |
2270 if (hwndBubble) | 2426 if (hwndBubble) |
2271 { | 2427 { |
2272 DestroyWindow(hwndBubble); | 2428 DestroyWindow(hwndBubble); |