comparison os2/dw.c @ 283:54aafc134652

BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups, and fixed SHIFT-TAB through splitbars. Simplified the TAB and SHIFT-TAB handling code on OS/2.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Mon, 17 Mar 2003 15:33:51 +0000
parents 030188d45a69
children 0e6f09149eaa
comparison
equal deleted inserted replaced
282:916045924784 283:54aafc134652
1 /* 1 /*
2 * Dynamic Windows: 2 * Dynamic Windows:
3 * A GTK like implementation of the PM GUI 3 * A GTK like implementation of the PM GUI
4 * 4 *
5 * (C) 2000-2002 Brian Smith <dbsoft@technologist.com> 5 * (C) 2000-2003 Brian Smith <dbsoft@technologist.com>
6 * (C) 2000 Achim Hasenmueller <achimha@innotek.de> 6 * (C) 2000 Achim Hasenmueller <achimha@innotek.de>
7 * (C) 2000 Peter Nielsen <peter@pmview.com> 7 * (C) 2000 Peter Nielsen <peter@pmview.com>
8 * (C) 1998 Sergey I. Yevtushenko (some code borrowed from cell toolkit) 8 * (C) 1998 Sergey I. Yevtushenko (some code borrowed from cell toolkit)
9 * 9 *
10 */ 10 */
364 return 0; 364 return 0;
365 } 365 }
366 366
367 int _focus_check_box(Box *box, HWND handle, int start, HWND defaultitem) 367 int _focus_check_box(Box *box, HWND handle, int start, HWND defaultitem)
368 { 368 {
369 int z; 369 int z, n;
370 static HWND lasthwnd, firsthwnd; 370 static HWND lasthwnd, firsthwnd;
371 static int finish_searching; 371 static int finish_searching;
372 372
373 /* Start is 2 when we have cycled completely and 373 /* Start is 2 when we have cycled completely and
374 * need to set the focus to the last widget we found 374 * need to set the focus to the last widget we found
390 lasthwnd = handle; 390 lasthwnd = handle;
391 finish_searching = 0; 391 finish_searching = 0;
392 firsthwnd = 0; 392 firsthwnd = 0;
393 } 393 }
394 394
395 /* Vertical boxes are inverted on OS/2 */ 395 for(n=0;n<box->count;n++)
396 if(box->type == BOXVERT) 396 {
397 { 397 /* Vertical boxes are inverted on OS/2 */
398 for(z=0;z<box->count;z++) 398 if(box->type == DW_VERT)
399 { 399 z = n;
400 if(box->items[z].type == TYPEBOX) 400 else
401 z = box->count - n - 1;
402
403 if(box->items[z].type == TYPEBOX)
404 {
405 Box *thisbox = WinQueryWindowPtr(box->items[z].hwnd, QWP_USER);
406
407 if(thisbox && _focus_check_box(thisbox, handle, start == 3 ? 3 : 0, defaultitem))
408 return 1;
409 }
410 else
411 {
412 if(box->items[z].hwnd == handle)
401 { 413 {
402 Box *thisbox = WinQueryWindowPtr(box->items[z].hwnd, QWP_USER); 414 if(lasthwnd == handle && firsthwnd)
403 415 WinSetFocus(HWND_DESKTOP, firsthwnd);
404 if(thisbox && _focus_check_box(thisbox, handle, start == 3 ? 3 : 0, defaultitem)) 416 else if(lasthwnd == handle && !firsthwnd)
417 finish_searching = 1;
418 else
419 WinSetFocus(HWND_DESKTOP, lasthwnd);
420
421 /* If we aren't looking for the last handle,
422 * return immediately.
423 */
424 if(!finish_searching)
405 return 1; 425 return 1;
426 }
427 if(_validate_focus(box->items[z].hwnd))
428 {
429 /* Start is 3 when we are looking for the
430 * first valid item in the layout.
431 */
432 if(start == 3)
433 {
434 if(!defaultitem || (defaultitem && defaultitem == box->items[z].hwnd))
435 {
436 WinSetFocus(HWND_DESKTOP, box->items[z].hwnd);
437 return 1;
438 }
439 }
440
441 if(!firsthwnd)
442 firsthwnd = box->items[z].hwnd;
443
444 lasthwnd = box->items[z].hwnd;
406 } 445 }
407 else 446 else
408 { 447 {
409 if(box->items[z].hwnd == handle) 448 char tmpbuf[100] = "";
449
450 WinQueryClassName(box->items[z].hwnd, 99, tmpbuf);
451 if(strncmp(tmpbuf, SplitbarClassName, strlen(SplitbarClassName)+1)==0)
410 { 452 {
411 if(lasthwnd == handle && firsthwnd) 453 /* Then try the bottom or right box */
412 WinSetFocus(HWND_DESKTOP, firsthwnd); 454 HWND mybox = (HWND)dw_window_get_data(box->items[z].hwnd, "_dw_bottomright");
413 else if(lasthwnd == handle && !firsthwnd) 455
414 finish_searching = 1; 456 if(mybox)
415 else 457 {
416 WinSetFocus(HWND_DESKTOP, lasthwnd); 458 Box *splitbox = (Box *)WinQueryWindowPtr(mybox, QWP_USER);
417 459
418 /* If we aren't looking for the last handle, 460 if(splitbox && _focus_check_box(splitbox, handle, start == 3 ? 3 : 0, defaultitem))
419 * return immediately. 461 return 1;
420 */ 462 }
421 if(!finish_searching) 463
422 return 1; 464 /* Try the top or left box */
465 mybox = (HWND)dw_window_get_data(box->items[z].hwnd, "_dw_topleft");
466
467 if(mybox)
468 {
469 Box *splitbox = (Box *)WinQueryWindowPtr(mybox, QWP_USER);
470
471 if(splitbox && _focus_check_box(splitbox, handle, start == 3 ? 3 : 0, defaultitem))
472 return 1;
473 }
423 } 474 }
424 if(_validate_focus(box->items[z].hwnd)) 475 else if(strncmp(tmpbuf, "#40", 4)==0) /* Notebook */
425 { 476 {
426 /* Start is 3 when we are looking for the 477 Box *notebox;
427 * first valid item in the layout. 478 HWND page = (HWND)WinSendMsg(box->items[z].hwnd, BKM_QUERYPAGEWINDOWHWND,
428 */ 479 (MPARAM)dw_notebook_page_query(box->items[z].hwnd), 0);
429 if(start == 3) 480
481 if(page)
430 { 482 {
431 if(!defaultitem || (defaultitem && defaultitem == box->items[z].hwnd)) 483 notebox = (Box *)WinQueryWindowPtr(page, QWP_USER);
432 { 484
433 WinSetFocus(HWND_DESKTOP, box->items[z].hwnd); 485 if(notebox && _focus_check_box(notebox, handle, start == 3 ? 3 : 0, defaultitem))
434 return 1; 486 return 1;
435 }
436 }
437
438 if(!firsthwnd)
439 firsthwnd = box->items[z].hwnd;
440
441 lasthwnd = box->items[z].hwnd;
442 }
443 else
444 {
445 char tmpbuf[100] = "";
446
447 WinQueryClassName(box->items[z].hwnd, 99, tmpbuf);
448 if(strncmp(tmpbuf, SplitbarClassName, strlen(SplitbarClassName)+1)==0)
449 {
450 /* Then try the bottom or right box */
451 HWND mybox = (HWND)dw_window_get_data(box->items[z].hwnd, "_dw_bottomright");
452
453 if(mybox)
454 {
455 Box *splitbox = (Box *)WinQueryWindowPtr(mybox, QWP_USER);
456
457 if(splitbox && _focus_check_box(splitbox, handle, start == 3 ? 3 : 0, defaultitem))
458 return 1;
459 }
460
461 /* Try the top or left box */
462 mybox = (HWND)dw_window_get_data(box->items[z].hwnd, "_dw_topleft");
463
464 if(mybox)
465 {
466 Box *splitbox = (Box *)WinQueryWindowPtr(mybox, QWP_USER);
467
468 if(splitbox && _focus_check_box(splitbox, handle, start == 3 ? 3 : 0, defaultitem))
469 return 1;
470 }
471 }
472 else if(strncmp(tmpbuf, "#40", 4)==0) /* Notebook */
473 {
474 Box *notebox;
475 HWND page = (HWND)WinSendMsg(box->items[z].hwnd, BKM_QUERYPAGEWINDOWHWND,
476 (MPARAM)dw_notebook_page_query(box->items[z].hwnd), 0);
477
478 if(page)
479 {
480 notebox = (Box *)WinQueryWindowPtr(page, QWP_USER);
481
482 if(notebox && _focus_check_box(notebox, handle, start == 3 ? 3 : 0, defaultitem))
483 return 1;
484 }
485 } 487 }
486 } 488 }
487 } 489 }
488 } 490 }
489 } 491 }
490 else
491 {
492 for(z=box->count-1;z>-1;z--)
493 {
494 if(box->items[z].type == TYPEBOX)
495 {
496 Box *thisbox = WinQueryWindowPtr(box->items[z].hwnd, QWP_USER);
497
498 if(thisbox && _focus_check_box(thisbox, handle, start == 3 ? 3 : 0, defaultitem))
499 return 1;
500 }
501 else
502 {
503 if(box->items[z].hwnd == handle)
504 {
505 if(lasthwnd == handle && firsthwnd)
506 WinSetFocus(HWND_DESKTOP, firsthwnd);
507 else if(lasthwnd == handle && !firsthwnd)
508 finish_searching = 1;
509 else
510 WinSetFocus(HWND_DESKTOP, lasthwnd);
511
512 /* If we aren't looking for the last handle,
513 * return immediately.
514 */
515 if(!finish_searching)
516 return 1;
517 }
518 if(_validate_focus(box->items[z].hwnd))
519 {
520 /* Start is 3 when we are looking for the
521 * first valid item in the layout.
522 */
523 if(start == 3)
524 {
525 if(!defaultitem || (defaultitem && defaultitem == box->items[z].hwnd))
526 {
527 WinSetFocus(HWND_DESKTOP, box->items[z].hwnd);
528 return 1;
529 }
530 }
531
532 if(!firsthwnd)
533 firsthwnd = box->items[z].hwnd;
534
535 lasthwnd = box->items[z].hwnd;
536 }
537 else
538 {
539 char tmpbuf[100] = "";
540
541 WinQueryClassName(box->items[z].hwnd, 99, tmpbuf);
542 if(strncmp(tmpbuf, "#40", 4)==0) /* Notebook */
543 {
544 Box *notebox;
545 HWND page = (HWND)WinSendMsg(box->items[z].hwnd, BKM_QUERYPAGEWINDOWHWND,
546 (MPARAM)dw_notebook_page_query(box->items[z].hwnd), 0);
547
548 if(page)
549 {
550 notebox = (Box *)WinQueryWindowPtr(page, QWP_USER);
551
552 if(notebox && _focus_check_box(notebox, handle, start == 3 ? 3 : 0, defaultitem))
553 return 1;
554 }
555 }
556 }
557 }
558 }
559 }
560 return 0; 492 return 0;
561 } 493 }
562 494
563 int _focus_check_box_back(Box *box, HWND handle, int start, HWND defaultitem) 495 int _focus_check_box_back(Box *box, HWND handle, int start, HWND defaultitem)
564 { 496 {
565 int z; 497 int z, n;
566 static HWND lasthwnd, firsthwnd; 498 static HWND lasthwnd, firsthwnd;
567 static int finish_searching; 499 static int finish_searching;
568 500
569 /* Start is 2 when we have cycled completely and 501 /* Start is 2 when we have cycled completely and
570 * need to set the focus to the last widget we found 502 * need to set the focus to the last widget we found
586 lasthwnd = handle; 518 lasthwnd = handle;
587 finish_searching = 0; 519 finish_searching = 0;
588 firsthwnd = 0; 520 firsthwnd = 0;
589 } 521 }
590 522
591 /* Vertical boxes are inverted on OS/2 */ 523 for(n=0;n<box->count;n++)
592 if(box->type == BOXVERT) 524 {
593 { 525 /* Vertical boxes are inverted on OS/2 */
594 for(z=box->count-1;z>-1;z--) 526 if(box->type == DW_VERT)
595 { 527 z = box->count - n - 1;
596 if(box->items[z].type == TYPEBOX) 528 else
529 z = n;
530
531 if(box->items[z].type == TYPEBOX)
532 {
533 Box *thisbox = WinQueryWindowPtr(box->items[z].hwnd, QWP_USER);
534
535 if(thisbox && _focus_check_box_back(thisbox, handle, start == 3 ? 3 : 0, defaultitem))
536 return 1;
537 }
538 else
539 {
540 if(box->items[z].hwnd == handle)
597 { 541 {
598 Box *thisbox = WinQueryWindowPtr(box->items[z].hwnd, QWP_USER); 542 if(lasthwnd == handle && firsthwnd)
599 543 WinSetFocus(HWND_DESKTOP, firsthwnd);
600 if(thisbox && _focus_check_box_back(thisbox, handle, start == 3 ? 3 : 0, defaultitem)) 544 else if(lasthwnd == handle && !firsthwnd)
545 finish_searching = 1;
546 else
547 WinSetFocus(HWND_DESKTOP, lasthwnd);
548
549 /* If we aren't looking for the last handle,
550 * return immediately.
551 */
552 if(!finish_searching)
601 return 1; 553 return 1;
554 }
555 if(_validate_focus(box->items[z].hwnd))
556 {
557 /* Start is 3 when we are looking for the
558 * first valid item in the layout.
559 */
560 if(start == 3)
561 {
562 if(!defaultitem || (defaultitem && defaultitem == box->items[z].hwnd))
563 {
564 WinSetFocus(HWND_DESKTOP, box->items[z].hwnd);
565 return 1;
566 }
567 }
568
569 if(!firsthwnd)
570 firsthwnd = box->items[z].hwnd;
571
572 lasthwnd = box->items[z].hwnd;
602 } 573 }
603 else 574 else
604 { 575 {
605 if(box->items[z].hwnd == handle) 576 char tmpbuf[100] = "";
577
578 WinQueryClassName(box->items[z].hwnd, 99, tmpbuf);
579 if(strncmp(tmpbuf, SplitbarClassName, strlen(SplitbarClassName)+1)==0)
606 { 580 {
607 if(lasthwnd == handle && firsthwnd) 581 /* Try the top or left box */
608 WinSetFocus(HWND_DESKTOP, firsthwnd); 582 HWND mybox = (HWND)dw_window_get_data(box->items[z].hwnd, "_dw_topleft");
609 else if(lasthwnd == handle && !firsthwnd) 583
610 finish_searching = 1; 584 if(mybox)
611 else
612 WinSetFocus(HWND_DESKTOP, lasthwnd);
613
614 /* If we aren't looking for the last handle,
615 * return immediately.
616 */
617 if(!finish_searching)
618 return 1;
619 }
620 if(_validate_focus(box->items[z].hwnd))
621 {
622 /* Start is 3 when we are looking for the
623 * first valid item in the layout.
624 */
625 if(start == 3)
626 { 585 {
627 if(!defaultitem || (defaultitem && defaultitem == box->items[z].hwnd)) 586 Box *splitbox = (Box *)WinQueryWindowPtr(mybox, QWP_USER);
628 { 587
629 WinSetFocus(HWND_DESKTOP, box->items[z].hwnd); 588 if(splitbox && _focus_check_box_back(splitbox, handle, start == 3 ? 3 : 0, defaultitem))
630 return 1; 589 return 1;
631 }
632 } 590 }
633 591
634 if(!firsthwnd) 592 /* Then try the bottom or right box */
635 firsthwnd = box->items[z].hwnd; 593 mybox = (HWND)dw_window_get_data(box->items[z].hwnd, "_dw_bottomright");
636 594
637 lasthwnd = box->items[z].hwnd; 595 if(mybox)
638 }
639 else
640 {
641 char tmpbuf[100] = "";
642
643 WinQueryClassName(box->items[z].hwnd, 99, tmpbuf);
644 if(strncmp(tmpbuf, "#40", 4)==0) /* Notebook */
645 { 596 {
646 Box *notebox; 597 Box *splitbox = (Box *)WinQueryWindowPtr(mybox, QWP_USER);
647 HWND page = (HWND)WinSendMsg(box->items[z].hwnd, BKM_QUERYPAGEWINDOWHWND, 598
648 (MPARAM)dw_notebook_page_query(box->items[z].hwnd), 0); 599 if(splitbox && _focus_check_box_back(splitbox, handle, start == 3 ? 3 : 0, defaultitem))
649 600 return 1;
650 if(page)
651 {
652 notebox = (Box *)WinQueryWindowPtr(page, QWP_USER);
653
654 if(notebox && _focus_check_box_back(notebox, handle, start == 3 ? 3 : 0, defaultitem))
655 return 1;
656 }
657 } 601 }
658 } 602 }
659 } 603 else if(strncmp(tmpbuf, "#40", 4)==0) /* Notebook */
660 }
661 }
662 else
663 {
664 for(z=0;z<box->count;z++)
665 {
666 if(box->items[z].type == TYPEBOX)
667 {
668 Box *thisbox = WinQueryWindowPtr(box->items[z].hwnd, QWP_USER);
669
670 if(thisbox && _focus_check_box_back(thisbox, handle, start == 3 ? 3 : 0, defaultitem))
671 return 1;
672 }
673 else
674 {
675 if(box->items[z].hwnd == handle)
676 { 604 {
677 if(lasthwnd == handle && firsthwnd) 605 Box *notebox;
678 WinSetFocus(HWND_DESKTOP, firsthwnd); 606 HWND page = (HWND)WinSendMsg(box->items[z].hwnd, BKM_QUERYPAGEWINDOWHWND,
679 else if(lasthwnd == handle && !firsthwnd) 607 (MPARAM)dw_notebook_page_query(box->items[z].hwnd), 0);
680 finish_searching = 1; 608
681 else 609 if(page)
682 WinSetFocus(HWND_DESKTOP, lasthwnd);
683
684 /* If we aren't looking for the last handle,
685 * return immediately.
686 */
687 if(!finish_searching)
688 return 1;
689 }
690 if(_validate_focus(box->items[z].hwnd))
691 {
692 /* Start is 3 when we are looking for the
693 * first valid item in the layout.
694 */
695 if(start == 3)
696 { 610 {
697 if(!defaultitem || (defaultitem && defaultitem == box->items[z].hwnd)) 611 notebox = (Box *)WinQueryWindowPtr(page, QWP_USER);
698 { 612
699 WinSetFocus(HWND_DESKTOP, box->items[z].hwnd); 613 if(notebox && _focus_check_box_back(notebox, handle, start == 3 ? 3 : 0, defaultitem))
700 return 1; 614 return 1;
701 }
702 }
703
704 if(!firsthwnd)
705 firsthwnd = box->items[z].hwnd;
706
707 lasthwnd = box->items[z].hwnd;
708 }
709 else
710 {
711 char tmpbuf[100] = "";
712
713 WinQueryClassName(box->items[z].hwnd, 99, tmpbuf);
714 if(strncmp(tmpbuf, "#40", 4)==0) /* Notebook */
715 {
716 Box *notebox;
717 HWND page = (HWND)WinSendMsg(box->items[z].hwnd, BKM_QUERYPAGEWINDOWHWND,
718 (MPARAM)dw_notebook_page_query(box->items[z].hwnd), 0);
719
720 if(page)
721 {
722 notebox = (Box *)WinQueryWindowPtr(page, QWP_USER);
723
724 if(notebox && _focus_check_box_back(notebox, handle, start == 3 ? 3 : 0, defaultitem))
725 return 1;
726 }
727 } 615 }
728 } 616 }
729 } 617 }
730 } 618 }
731 } 619 }
760 HWND box, lastbox = _toplevel_window(handle); 648 HWND box, lastbox = _toplevel_window(handle);
761 649
762 box = WinWindowFromID(lastbox, FID_CLIENT); 650 box = WinWindowFromID(lastbox, FID_CLIENT);
763 if(box) 651 if(box)
764 thisbox = WinQueryWindowPtr(box, QWP_USER); 652 thisbox = WinQueryWindowPtr(box, QWP_USER);
765 else 653 else
766 thisbox = WinQueryWindowPtr(lastbox, QWP_USER); 654 thisbox = WinQueryWindowPtr(lastbox, QWP_USER);
767 655
768 if(thisbox) 656 if(thisbox)
769 { 657 {
770 if(_focus_check_box(thisbox, handle, 1, 0) == 0) 658 if(_focus_check_box(thisbox, handle, 1, 0) == 0)
781 HWND box, lastbox = _toplevel_window(handle); 669 HWND box, lastbox = _toplevel_window(handle);
782 670
783 box = WinWindowFromID(lastbox, FID_CLIENT); 671 box = WinWindowFromID(lastbox, FID_CLIENT);
784 if(box) 672 if(box)
785 thisbox = WinQueryWindowPtr(box, QWP_USER); 673 thisbox = WinQueryWindowPtr(box, QWP_USER);
786 else 674 else
787 thisbox = WinQueryWindowPtr(lastbox, QWP_USER); 675 thisbox = WinQueryWindowPtr(lastbox, QWP_USER);
788 676
789 if(thisbox) 677 if(thisbox)
790 { 678 {
791 if(_focus_check_box_back(thisbox, handle, 1, 0) == 0) 679 if(_focus_check_box_back(thisbox, handle, 1, 0) == 0)
820 size += s; 708 size += s;
821 origsize += os; 709 origsize += os;
822 } 710 }
823 else 711 else
824 { 712 {
825 size += (type == BOXHORZ ? tmp->items[z].width : tmp->items[z].height); 713 size += (type == DW_HORZ ? tmp->items[z].width : tmp->items[z].height);
826 origsize += (type == BOXHORZ ? tmp->items[z].origwidth : tmp->items[z].origheight); 714 origsize += (type == DW_HORZ ? tmp->items[z].origwidth : tmp->items[z].origheight);
827 } 715 }
828 } 716 }
829 } 717 }
830 else 718 else
831 { 719 {
838 { 726 {
839 if(tmp->items[z].type == TYPEBOX) 727 if(tmp->items[z].type == TYPEBOX)
840 _count_size(tmp->items[z].hwnd, type, &tmpsize, &tmporigsize); 728 _count_size(tmp->items[z].hwnd, type, &tmpsize, &tmporigsize);
841 else 729 else
842 { 730 {
843 tmpsize = (type == BOXHORZ ? tmp->items[z].width : tmp->items[z].height); 731 tmpsize = (type == DW_HORZ ? tmp->items[z].width : tmp->items[z].height);
844 tmporigsize = (type == BOXHORZ ? tmp->items[z].origwidth : tmp->items[z].origheight); 732 tmporigsize = (type == DW_HORZ ? tmp->items[z].origwidth : tmp->items[z].origheight);
845 } 733 }
846 734
847 if(tmpsize > size) 735 if(tmpsize > size)
848 size = tmpsize; 736 size = tmpsize;
849 } 737 }
1017 905
1018 /* Just in case */ 906 /* Just in case */
1019 tmp->xratio = thisbox->xratio; 907 tmp->xratio = thisbox->xratio;
1020 tmp->yratio = thisbox->yratio; 908 tmp->yratio = thisbox->yratio;
1021 909
1022 if(thisbox->type == BOXVERT) 910 if(thisbox->type == DW_VERT)
1023 { 911 {
1024 if((thisbox->items[z].width-((thisbox->items[z].pad*2)+(tmp->pad*2)))!=0) 912 if((thisbox->items[z].width-((thisbox->items[z].pad*2)+(tmp->pad*2)))!=0)
1025 tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-((thisbox->items[z].pad*2)+(tmp->pad*2))))/((float)(thisbox->items[z].width-((thisbox->items[z].pad*2)+(tmp->pad*2)))); 913 tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-((thisbox->items[z].pad*2)+(tmp->pad*2))))/((float)(thisbox->items[z].width-((thisbox->items[z].pad*2)+(tmp->pad*2))));
1026 } 914 }
1027 else 915 else
1028 { 916 {
1029 if((thisbox->items[z].width-tmp->upx)!=0) 917 if((thisbox->items[z].width-tmp->upx)!=0)
1030 tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-tmp->upx))/((float)(thisbox->items[z].width-tmp->upx)); 918 tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-tmp->upx))/((float)(thisbox->items[z].width-tmp->upx));
1031 } 919 }
1032 if(thisbox->type == BOXHORZ) 920 if(thisbox->type == DW_HORZ)
1033 { 921 {
1034 if((thisbox->items[z].height-((thisbox->items[z].pad*2)+(tmp->pad*2)))!=0) 922 if((thisbox->items[z].height-((thisbox->items[z].pad*2)+(tmp->pad*2)))!=0)
1035 tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-((thisbox->items[z].pad*2)+(tmp->pad*2))))/((float)(thisbox->items[z].height-((thisbox->items[z].pad*2)+(tmp->pad*2)))); 923 tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-((thisbox->items[z].pad*2)+(tmp->pad*2))))/((float)(thisbox->items[z].height-((thisbox->items[z].pad*2)+(tmp->pad*2))));
1036 } 924 }
1037 else 925 else
1058 } 946 }
1059 } 947 }
1060 948
1061 if(pass > 1 && *depth > 0) 949 if(pass > 1 && *depth > 0)
1062 { 950 {
1063 if(thisbox->type == BOXVERT) 951 if(thisbox->type == DW_VERT)
1064 { 952 {
1065 if((thisbox->minwidth-((thisbox->items[z].pad*2)+(thisbox->parentpad*2))) == 0) 953 if((thisbox->minwidth-((thisbox->items[z].pad*2)+(thisbox->parentpad*2))) == 0)
1066 thisbox->items[z].xratio = 1.0; 954 thisbox->items[z].xratio = 1.0;
1067 else 955 else
1068 thisbox->items[z].xratio = ((float)((thisbox->width * thisbox->parentxratio)-((thisbox->items[z].pad*2)+(thisbox->parentpad*2))))/((float)(thisbox->minwidth-((thisbox->items[z].pad*2)+(thisbox->parentpad*2)))); 956 thisbox->items[z].xratio = ((float)((thisbox->width * thisbox->parentxratio)-((thisbox->items[z].pad*2)+(thisbox->parentpad*2))))/((float)(thisbox->minwidth-((thisbox->items[z].pad*2)+(thisbox->parentpad*2))));
1073 thisbox->items[z].xratio = 1.0; 961 thisbox->items[z].xratio = 1.0;
1074 else 962 else
1075 thisbox->items[z].xratio = ((float)((thisbox->width * thisbox->parentxratio)-thisbox->upx))/((float)(thisbox->minwidth-thisbox->upx)); 963 thisbox->items[z].xratio = ((float)((thisbox->width * thisbox->parentxratio)-thisbox->upx))/((float)(thisbox->minwidth-thisbox->upx));
1076 } 964 }
1077 965
1078 if(thisbox->type == BOXHORZ) 966 if(thisbox->type == DW_HORZ)
1079 { 967 {
1080 if((thisbox->minheight-((thisbox->items[z].pad*2)+(thisbox->parentpad*2))) == 0) 968 if((thisbox->minheight-((thisbox->items[z].pad*2)+(thisbox->parentpad*2))) == 0)
1081 thisbox->items[z].yratio = 1.0; 969 thisbox->items[z].yratio = 1.0;
1082 else 970 else
1083 thisbox->items[z].yratio = ((float)((thisbox->height * thisbox->parentyratio)-((thisbox->items[z].pad*2)+(thisbox->parentpad*2))))/((float)(thisbox->minheight-((thisbox->items[z].pad*2)+(thisbox->parentpad*2)))); 971 thisbox->items[z].yratio = ((float)((thisbox->height * thisbox->parentyratio)-((thisbox->items[z].pad*2)+(thisbox->parentpad*2))))/((float)(thisbox->minheight-((thisbox->items[z].pad*2)+(thisbox->parentpad*2))));
1105 { 993 {
1106 thisbox->items[z].xratio = thisbox->xratio; 994 thisbox->items[z].xratio = thisbox->xratio;
1107 thisbox->items[z].yratio = thisbox->yratio; 995 thisbox->items[z].yratio = thisbox->yratio;
1108 } 996 }
1109 997
1110 if(thisbox->type == BOXVERT) 998 if(thisbox->type == DW_VERT)
1111 { 999 {
1112 if((thisbox->items[z].width + (thisbox->items[z].pad*2)) > uxmax) 1000 if((thisbox->items[z].width + (thisbox->items[z].pad*2)) > uxmax)
1113 uxmax = (thisbox->items[z].width + (thisbox->items[z].pad*2)); 1001 uxmax = (thisbox->items[z].width + (thisbox->items[z].pad*2));
1114 if(thisbox->items[z].hsize != SIZEEXPAND) 1002 if(thisbox->items[z].hsize != SIZEEXPAND)
1115 { 1003 {
1136 (*usedpadx) += (thisbox->items[z].pad*2) + thisbox->items[z].width; 1024 (*usedpadx) += (thisbox->items[z].pad*2) + thisbox->items[z].width;
1137 else 1025 else
1138 (*usedpadx) += thisbox->items[z].pad*2; 1026 (*usedpadx) += thisbox->items[z].pad*2;
1139 } 1027 }
1140 } 1028 }
1141 if(thisbox->type == BOXHORZ) 1029 if(thisbox->type == DW_HORZ)
1142 { 1030 {
1143 if((thisbox->items[z].height + (thisbox->items[z].pad*2)) > uymax) 1031 if((thisbox->items[z].height + (thisbox->items[z].pad*2)) > uymax)
1144 uymax = (thisbox->items[z].height + (thisbox->items[z].pad*2)); 1032 uymax = (thisbox->items[z].height + (thisbox->items[z].pad*2));
1145 if(thisbox->items[z].vsize != SIZEEXPAND) 1033 if(thisbox->items[z].vsize != SIZEEXPAND)
1146 { 1034 {
1183 if(pass > 1) 1071 if(pass > 1)
1184 { 1072 {
1185 /* Any SIZEEXPAND items should be set to uxmax/uymax */ 1073 /* Any SIZEEXPAND items should be set to uxmax/uymax */
1186 for(z=0;z<thisbox->count;z++) 1074 for(z=0;z<thisbox->count;z++)
1187 { 1075 {
1188 if(thisbox->items[z].hsize == SIZEEXPAND && thisbox->type == BOXVERT) 1076 if(thisbox->items[z].hsize == SIZEEXPAND && thisbox->type == DW_VERT)
1189 thisbox->items[z].width = uxmax-(thisbox->items[z].pad*2); 1077 thisbox->items[z].width = uxmax-(thisbox->items[z].pad*2);
1190 if(thisbox->items[z].vsize == SIZEEXPAND && thisbox->type == BOXHORZ) 1078 if(thisbox->items[z].vsize == SIZEEXPAND && thisbox->type == DW_HORZ)
1191 thisbox->items[z].height = uymax-(thisbox->items[z].pad*2); 1079 thisbox->items[z].height = uymax-(thisbox->items[z].pad*2);
1192 /* Run this code segment again to finalize the sized after setting uxmax/uymax values. */ 1080 /* Run this code segment again to finalize the sized after setting uxmax/uymax values. */
1193 if(thisbox->items[z].type == TYPEBOX) 1081 if(thisbox->items[z].type == TYPEBOX)
1194 { 1082 {
1195 Box *tmp = WinQueryWindowPtr(thisbox->items[z].hwnd, QWP_USER); 1083 Box *tmp = WinQueryWindowPtr(thisbox->items[z].hwnd, QWP_USER);
1196 1084
1197 if(tmp) 1085 if(tmp)
1198 { 1086 {
1199 if(*depth > 0) 1087 if(*depth > 0)
1200 { 1088 {
1201 if(thisbox->type == BOXVERT) 1089 if(thisbox->type == DW_VERT)
1202 { 1090 {
1203 tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-((thisbox->items[z].pad*2)+(thisbox->pad*2))))/((float)(tmp->minwidth-((thisbox->items[z].pad*2)+(thisbox->pad*2)))); 1091 tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-((thisbox->items[z].pad*2)+(thisbox->pad*2))))/((float)(tmp->minwidth-((thisbox->items[z].pad*2)+(thisbox->pad*2))));
1204 tmp->width = thisbox->items[z].width; 1092 tmp->width = thisbox->items[z].width;
1205 } 1093 }
1206 if(thisbox->type == BOXHORZ) 1094 if(thisbox->type == DW_HORZ)
1207 { 1095 {
1208 tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-((thisbox->items[z].pad*2)+(thisbox->pad*2))))/((float)(tmp->minheight-((thisbox->items[z].pad*2)+(thisbox->pad*2)))); 1096 tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-((thisbox->items[z].pad*2)+(thisbox->pad*2))))/((float)(tmp->minheight-((thisbox->items[z].pad*2)+(thisbox->pad*2))));
1209 tmp->height = thisbox->items[z].height; 1097 tmp->height = thisbox->items[z].height;
1210 } 1098 }
1211 } 1099 }
1296 1184
1297 } 1185 }
1298 1186
1299 } 1187 }
1300 1188
1301 if(thisbox->type == BOXHORZ) 1189 if(thisbox->type == DW_HORZ)
1302 currentx += width + vectorx + (pad * 2); 1190 currentx += width + vectorx + (pad * 2);
1303 if(thisbox->type == BOXVERT) 1191 if(thisbox->type == DW_VERT)
1304 currenty += height + vectory + (pad * 2); 1192 currenty += height + vectory + (pad * 2);
1305 } 1193 }
1306 } 1194 }
1307 } 1195 }
1308 return 0; 1196 return 0;
2613 Box *tmp = WinQueryWindowPtr(thisbox->items[z].hwnd, QWP_USER); 2501 Box *tmp = WinQueryWindowPtr(thisbox->items[z].hwnd, QWP_USER);
2614 _changebox(tmp, percent, type); 2502 _changebox(tmp, percent, type);
2615 } 2503 }
2616 else 2504 else
2617 { 2505 {
2618 if(type == BOXHORZ) 2506 if(type == DW_HORZ)
2619 { 2507 {
2620 if(thisbox->items[z].hsize == SIZEEXPAND) 2508 if(thisbox->items[z].hsize == SIZEEXPAND)
2621 thisbox->items[z].width = (int)(((float)thisbox->items[z].origwidth) * (((float)percent)/((float)100.0))); 2509 thisbox->items[z].width = (int)(((float)thisbox->items[z].origwidth) * (((float)percent)/((float)100.0)));
2622 } 2510 }
2623 else 2511 else
2629 } 2517 }
2630 } 2518 }
2631 2519
2632 void _handle_splitbar_resize(HWND hwnd, float percent, int type, int x, int y) 2520 void _handle_splitbar_resize(HWND hwnd, float percent, int type, int x, int y)
2633 { 2521 {
2634 if(type == BOXHORZ) 2522 if(type == DW_HORZ)
2635 { 2523 {
2636 int newx = x; 2524 int newx = x;
2637 float ratio = (float)percent/(float)100.0; 2525 float ratio = (float)percent/(float)100.0;
2638 HWND handle1 = (HWND)dw_window_get_data(hwnd, "_dw_topleft"); 2526 HWND handle1 = (HWND)dw_window_get_data(hwnd, "_dw_topleft");
2639 HWND handle2 = (HWND)dw_window_get_data(hwnd, "_dw_bottomright"); 2527 HWND handle2 = (HWND)dw_window_get_data(hwnd, "_dw_bottomright");
2711 2599
2712 hps = WinBeginPaint(hwnd, 0, 0); 2600 hps = WinBeginPaint(hwnd, 0, 0);
2713 2601
2714 WinQueryWindowRect(hwnd, &rcl); 2602 WinQueryWindowRect(hwnd, &rcl);
2715 2603
2716 if(type == BOXHORZ) 2604 if(type == DW_HORZ)
2717 { 2605 {
2718 ptl[0].x = rcl.xLeft + start; 2606 ptl[0].x = rcl.xLeft + start;
2719 ptl[0].y = rcl.yBottom; 2607 ptl[0].y = rcl.yBottom;
2720 ptl[1].x = rcl.xRight + start + 3; 2608 ptl[1].x = rcl.xRight + start + 3;
2721 ptl[1].y = rcl.yTop; 2609 ptl[1].y = rcl.yTop;
2736 } 2624 }
2737 return MRFROMSHORT(FALSE); 2625 return MRFROMSHORT(FALSE);
2738 2626
2739 case WM_MOUSEMOVE: 2627 case WM_MOUSEMOVE:
2740 { 2628 {
2741 if(type == BOXHORZ) 2629 if(type == DW_HORZ)
2742 WinSetPointer(HWND_DESKTOP, 2630 WinSetPointer(HWND_DESKTOP,
2743 WinQuerySysPointer(HWND_DESKTOP, 2631 WinQuerySysPointer(HWND_DESKTOP,
2744 SPTR_SIZEWE, 2632 SPTR_SIZEWE,
2745 FALSE)); 2633 FALSE));
2746 else 2634 else
2761 2649
2762 WinMapWindowPoints(hwnd, HWND_DESKTOP, 2650 WinMapWindowPoints(hwnd, HWND_DESKTOP,
2763 (PPOINTL)&rclBounds, 2); 2651 (PPOINTL)&rclBounds, 2);
2764 2652
2765 2653
2766 if(type == BOXHORZ) 2654 if(type == DW_HORZ)
2767 { 2655 {
2768 rclFrame.xLeft = start; 2656 rclFrame.xLeft = start;
2769 rclFrame.xRight = start + SPLITBAR_WIDTH; 2657 rclFrame.xRight = start + SPLITBAR_WIDTH;
2770 } 2658 }
2771 else 2659 else
2781 if(rc == TRUE) 2669 if(rc == TRUE)
2782 { 2670 {
2783 int width = (rclBounds.xRight - rclBounds.xLeft); 2671 int width = (rclBounds.xRight - rclBounds.xLeft);
2784 int height = (rclBounds.yTop - rclBounds.yBottom); 2672 int height = (rclBounds.yTop - rclBounds.yBottom);
2785 2673
2786 if(type == BOXHORZ) 2674 if(type == DW_HORZ)
2787 { 2675 {
2788 start = rclFrame.xLeft - rclBounds.xLeft; 2676 start = rclFrame.xLeft - rclBounds.xLeft;
2789 if(width - SPLITBAR_WIDTH > 1 && start < width - SPLITBAR_WIDTH) 2677 if(width - SPLITBAR_WIDTH > 1 && start < width - SPLITBAR_WIDTH)
2790 *percent = ((float)start / (float)(width - SPLITBAR_WIDTH)) * 100.0; 2678 *percent = ((float)start / (float)(width - SPLITBAR_WIDTH)) * 100.0;
2791 } 2679 }
3677 HWND hwndclient = 0, hwndframe; 3565 HWND hwndclient = 0, hwndframe;
3678 Box *newbox = calloc(1, sizeof(Box)); 3566 Box *newbox = calloc(1, sizeof(Box));
3679 WindowData *blah = calloc(1, sizeof(WindowData)); 3567 WindowData *blah = calloc(1, sizeof(WindowData));
3680 3568
3681 newbox->pad = 0; 3569 newbox->pad = 0;
3682 newbox->type = BOXVERT; 3570 newbox->type = DW_VERT;
3683 newbox->count = 0; 3571 newbox->count = 0;
3684 3572
3685 flStyle |= FCF_NOBYTEALIGN; 3573 flStyle |= FCF_NOBYTEALIGN;
3686 3574
3687 if(flStyle & DW_FCF_TITLEBAR) 3575 if(flStyle & DW_FCF_TITLEBAR)
3704 } 3592 }
3705 3593
3706 /* 3594 /*
3707 * Create a new Box to be packed. 3595 * Create a new Box to be packed.
3708 * Parameters: 3596 * Parameters:
3709 * type: Either BOXVERT (vertical) or BOXHORZ (horizontal). 3597 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal).
3710 * pad: Number of pixels to pad around the box. 3598 * pad: Number of pixels to pad around the box.
3711 */ 3599 */
3712 HWND API dw_box_new(int type, int pad) 3600 HWND API dw_box_new(int type, int pad)
3713 { 3601 {
3714 Box *newbox = calloc(1, sizeof(Box)); 3602 Box *newbox = calloc(1, sizeof(Box));
3738 } 3626 }
3739 3627
3740 /* 3628 /*
3741 * Create a new Group Box to be packed. 3629 * Create a new Group Box to be packed.
3742 * Parameters: 3630 * Parameters:
3743 * type: Either BOXVERT (vertical) or BOXHORZ (horizontal). 3631 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal).
3744 * pad: Number of pixels to pad around the box. 3632 * pad: Number of pixels to pad around the box.
3745 * title: Text to be displayined in the group outline. 3633 * title: Text to be displayined in the group outline.
3746 */ 3634 */
3747 HWND API dw_groupbox_new(int type, int pad, char *title) 3635 HWND API dw_groupbox_new(int type, int pad, char *title)
3748 { 3636 {
4912 } 4800 }
4913 else 4801 else
4914 thisbox = WinQueryWindowPtr(box, QWP_USER); 4802 thisbox = WinQueryWindowPtr(box, QWP_USER);
4915 if(thisbox) 4803 if(thisbox)
4916 { 4804 {
4917 if(thisbox->type == BOXHORZ) 4805 if(thisbox->type == DW_HORZ)
4918 dw_box_pack_start_stub(box, item, width, height, hsize, vsize, pad); 4806 dw_box_pack_start_stub(box, item, width, height, hsize, vsize, pad);
4919 else 4807 else
4920 dw_box_pack_end_stub(box, item, width, height, hsize, vsize, pad); 4808 dw_box_pack_end_stub(box, item, width, height, hsize, vsize, pad);
4921 } 4809 }
4922 } 4810 }
5180 * pageid: Page ID in the notebook which is being packed. 5068 * pageid: Page ID in the notebook which is being packed.
5181 * page: Box handle to be packed. 5069 * page: Box handle to be packed.
5182 */ 5070 */
5183 void API dw_notebook_pack(HWND handle, ULONG pageid, HWND page) 5071 void API dw_notebook_pack(HWND handle, ULONG pageid, HWND page)
5184 { 5072 {
5185 HWND tmpbox = dw_box_new(BOXVERT, 0); 5073 HWND tmpbox = dw_box_new(DW_VERT, 0);
5186 5074
5187 dw_box_pack_start(tmpbox, page, 0, 0, TRUE, TRUE, 0); 5075 dw_box_pack_start(tmpbox, page, 0, 0, TRUE, TRUE, 0);
5188 WinSubclassWindow(tmpbox, _wndproc); 5076 WinSubclassWindow(tmpbox, _wndproc);
5189 WinSendMsg(handle, BKM_SETPAGEWINDOWHWND, 5077 WinSendMsg(handle, BKM_SETPAGEWINDOWHWND,
5190 MPFROMLONG(pageid), MPFROMHWND(tmpbox)); 5078 MPFROMLONG(pageid), MPFROMHWND(tmpbox));
7394 } 7282 }
7395 7283
7396 /* 7284 /*
7397 * Creates a splitbar window (widget) with given parameters. 7285 * Creates a splitbar window (widget) with given parameters.
7398 * Parameters: 7286 * Parameters:
7399 * type: Value can be BOXVERT or BOXHORZ. 7287 * type: Value can be DW_VERT or DW_HORZ.
7400 * topleft: Handle to the window to be top or left. 7288 * topleft: Handle to the window to be top or left.
7401 * bottomright: Handle to the window to be bottom or right. 7289 * bottomright: Handle to the window to be bottom or right.
7402 * Returns: 7290 * Returns:
7403 * A handle to a splitbar window or NULL on failure. 7291 * A handle to a splitbar window or NULL on failure.
7404 */ 7292 */
7414 id, 7302 id,
7415 NULL, 7303 NULL,
7416 NULL); 7304 NULL);
7417 if(tmp) 7305 if(tmp)
7418 { 7306 {
7419 HWND tmpbox = dw_box_new(BOXVERT, 0); 7307 HWND tmpbox = dw_box_new(DW_VERT, 0);
7420 float *percent = malloc(sizeof(float)); 7308 float *percent = malloc(sizeof(float));
7421 7309
7422 dw_box_pack_start(tmpbox, topleft, 1, 1, TRUE, TRUE, 0); 7310 dw_box_pack_start(tmpbox, topleft, 1, 1, TRUE, TRUE, 0);
7423 WinSetParent(tmpbox, tmp, FALSE); 7311 WinSetParent(tmpbox, tmp, FALSE);
7424 dw_window_set_data(tmp, "_dw_topleft", (void *)tmpbox); 7312 dw_window_set_data(tmp, "_dw_topleft", (void *)tmpbox);
7425 7313
7426 tmpbox = dw_box_new(BOXVERT, 0); 7314 tmpbox = dw_box_new(DW_VERT, 0);
7427 dw_box_pack_start(tmpbox, bottomright, 1, 1, TRUE, TRUE, 0); 7315 dw_box_pack_start(tmpbox, bottomright, 1, 1, TRUE, TRUE, 0);
7428 WinSetParent(tmpbox, tmp, FALSE); 7316 WinSetParent(tmpbox, tmp, FALSE);
7429 *percent = 50.0; 7317 *percent = 50.0;
7430 dw_window_set_data(tmp, "_dw_bottomright", (void *)tmpbox); 7318 dw_window_set_data(tmp, "_dw_bottomright", (void *)tmpbox);
7431 dw_window_set_data(tmp, "_dw_percent", (void *)percent); 7319 dw_window_set_data(tmp, "_dw_percent", (void *)percent);
7489 } 7377 }
7490 else 7378 else
7491 thisbox = WinQueryWindowPtr(box, QWP_USER); 7379 thisbox = WinQueryWindowPtr(box, QWP_USER);
7492 if(thisbox) 7380 if(thisbox)
7493 { 7381 {
7494 if(thisbox->type == BOXHORZ) 7382 if(thisbox->type == DW_HORZ)
7495 dw_box_pack_end_stub(box, item, width, height, hsize, vsize, pad); 7383 dw_box_pack_end_stub(box, item, width, height, hsize, vsize, pad);
7496 else 7384 else
7497 dw_box_pack_start_stub(box, item, width, height, hsize, vsize, pad); 7385 dw_box_pack_start_stub(box, item, width, height, hsize, vsize, pad);
7498 } 7386 }
7499 } 7387 }