ui/motif/Grid.c

changeset 913
3012ec57d84a
parent 901
884d70e847a3
child 921
c2b318b93062
equal deleted inserted replaced
912:06c37c12d149 913:3012ec57d84a
436 GridDef *rows = calloc(nrows, sizeof(GridDef)); 436 GridDef *rows = calloc(nrows, sizeof(GridDef));
437 int num_cols_expanding = 0; 437 int num_cols_expanding = 0;
438 int num_rows_expanding = 0; 438 int num_rows_expanding = 0;
439 int req_width = w->mywidget.padding_left + w->mywidget.padding_right; 439 int req_width = w->mywidget.padding_left + w->mywidget.padding_right;
440 int req_height = w->mywidget.padding_top + w->mywidget.padding_bottom; 440 int req_height = w->mywidget.padding_top + w->mywidget.padding_bottom;
441 int width = w->core.width;
442 int height = w->core.height;
441 443
442 //printf("container width: %d\n", (int)w->core.width); 444 //printf("container width: %d\n", (int)w->core.width);
443 445
444 // calculate the minimum size requirements for all columns and rows 446 // calculate the minimum size requirements for all columns and rows
445 // we need to run this 2 times: for widgets without colspan/rowspan first 447 // we need to run this 2 times: for widgets without colspan/rowspan first
598 600
599 } 601 }
600 602
601 // how much space can we add to each expanding col/row 603 // how much space can we add to each expanding col/row
602 int hexpand = 0; 604 int hexpand = 0;
603 int width_diff = (int)w->core.width - req_width; 605 int width_diff = width - req_width;
604 int hexpand2 = 0; 606 int hexpand2 = 0;
605 if(width_diff > 0 && num_cols_expanding > 0) { 607 if(width_diff > 0 && num_cols_expanding > 0) {
606 hexpand = width_diff / num_cols_expanding; 608 hexpand = width_diff / num_cols_expanding;
607 hexpand2 = width_diff-hexpand*num_cols_expanding; 609 hexpand2 = width_diff-hexpand*num_cols_expanding;
608 } 610 }
616 618
617 hexpand2 = 0; 619 hexpand2 = 0;
618 } 620 }
619 621
620 int vexpand = 0; 622 int vexpand = 0;
621 int height_diff = (int)w->core.height - req_height; 623 int height_diff = height - req_height;
622 int vexpand2 = 0; 624 int vexpand2 = 0;
623 if(height_diff > 0 && num_rows_expanding > 0) { 625 if(height_diff > 0 && num_rows_expanding > 0) {
624 vexpand = height_diff / num_rows_expanding; 626 vexpand = height_diff / num_rows_expanding;
625 vexpand2 = height_diff-vexpand*num_rows_expanding; 627 vexpand2 = height_diff-vexpand*num_rows_expanding;
626 } 628 }
652 cwidth += cols[constraints->grid.x+j].size + (j > 0 ? w->mywidget.columnspacing : 0); 654 cwidth += cols[constraints->grid.x+j].size + (j > 0 ? w->mywidget.columnspacing : 0);
653 } 655 }
654 } 656 }
655 width = cwidth; 657 width = cwidth;
656 } else { 658 } else {
657 width = c.size - w->mywidget.columnspacing; 659 width = c.size - w->mywidget.columnspacing - constraints->grid.margin_left - constraints->grid.margin_right;
658 } 660 }
659 } 661 }
660 if(constraints->grid.vfill) { 662 if(constraints->grid.vfill) {
661 if(constraints->grid.rowspan > 1) { 663 if(constraints->grid.rowspan > 1) {
662 Dimension cheight = 0; 664 Dimension cheight = 0;
665 cheight += rows[constraints->grid.y+j].size + (j > 0 ? w->mywidget.rowspacing : 0); 667 cheight += rows[constraints->grid.y+j].size + (j > 0 ? w->mywidget.rowspacing : 0);
666 } 668 }
667 } 669 }
668 height = cheight; 670 height = cheight;
669 } else { 671 } else {
670 height = r.size - w->mywidget.rowspacing; 672 height = r.size - w->mywidget.rowspacing - constraints->grid.margin_top - constraints->grid.margin_bottom;
671 } 673 }
672 } 674 }
673 675
674 if(width > 0 && height > 0) { 676 if(width > 0 && height > 0) {
675 XtConfigureWidget(child, x, y, width, height, child->core.border_width); 677 XtConfigureWidget(child, x, y, width, height, child->core.border_width);

mercurial