|
68 | 68 | * [static] text_properties();
|
69 | 69 | * [static] text_autosize();
|
70 | 70 | * [static] text_size();
|
| 71 | + * [static] widget_decor_height(htext, hnotext, bool buttons); |
| 72 | + * [static] widget_decor_width(); |
71 | 73 | * [static] widget_min_height(conf, htext, hnotext, bool buttons);
|
72 | 74 | * [static] widget_min_width(conf, wtext, minw, buttons);
|
73 | 75 | * set_widget_size();
|
@@ -755,23 +757,44 @@ text_size(struct bsddialog_conf *conf, int rows, int cols, const char *text,
|
755 | 757 | }
|
756 | 758 |
|
757 | 759 | static int
|
758 |
| -widget_min_height(struct bsddialog_conf *conf, int htext, int hnotext, |
759 |
| - bool withbuttons) |
| 760 | +widget_decor_height(int htext, int hnotext, bool withbuttons) |
760 | 761 | {
|
761 |
| - int min; |
| 762 | + int h; |
762 | 763 |
|
763 | 764 | /* dialog borders */
|
764 |
| - min = BORDERS; |
| 765 | + h = BORDERS; |
765 | 766 |
|
766 | 767 | /* text */
|
767 |
| - min += htext; |
| 768 | + h += htext; |
768 | 769 |
|
769 | 770 | /* specific widget lines without text */
|
770 |
| - min += hnotext; |
| 771 | + h += hnotext; |
771 | 772 |
|
772 | 773 | /* buttons */
|
773 | 774 | if (withbuttons)
|
774 |
| - min += HBUTTONS; /* buttons and their up-border */ |
| 775 | + h += HBUTTONS; /* buttons and their up-border */ |
| 776 | + |
| 777 | + return (h); |
| 778 | +} |
| 779 | + |
| 780 | +static int |
| 781 | +widget_decor_width(void) |
| 782 | +{ |
| 783 | + int w; |
| 784 | + |
| 785 | + /* dialog borders */ |
| 786 | + w = BORDERS; |
| 787 | + |
| 788 | + return (w); |
| 789 | +} |
| 790 | + |
| 791 | +static int |
| 792 | +widget_min_height(struct bsddialog_conf *conf, int htext, int hnotext, |
| 793 | + bool withbuttons) |
| 794 | +{ |
| 795 | + int min; |
| 796 | + |
| 797 | + min = widget_decor_height(htext, hnotext, withbuttons); |
775 | 798 |
|
776 | 799 | /* conf.auto_minheight */
|
777 | 800 | min = MAX(min, (int)conf->auto_minheight);
|
@@ -812,8 +835,7 @@ widget_min_width(struct bsddialog_conf *conf, int wtext, int minwidget,
|
812 | 835 | min = MAX(min, wbottomtitle + 4);
|
813 | 836 | }
|
814 | 837 |
|
815 |
| - /* dialog borders */ |
816 |
| - min += BORDERS; |
| 838 | + min += widget_decor_width(); |
817 | 839 | /* conf.auto_minwidth */
|
818 | 840 | min = MAX(min, (int)conf->auto_minwidth);
|
819 | 841 |
|
@@ -895,21 +917,17 @@ int widget_maxsize(struct bsddialog_conf *conf, int rows, int cols, int *maxh,
|
895 | 917 | if (text_size(conf, rows, cols, text, bs, 0, 0, &htext, &wtext) != 0)
|
896 | 918 | return (BSDDIALOG_ERROR);
|
897 | 919 |
|
898 |
| - /* |
899 |
| - * XXX: Should possibly clear conf->auto_min{height,width} |
900 |
| - * temporarily. |
901 |
| - */ |
902 | 920 | minheight = widget_min_height(conf, htext, 0, bs->nbuttons > 0);
|
903 | 921 | if (h < minheight)
|
904 | 922 | RETURN_FMTERROR("Current rows: %d, needed at least: %d",
|
905 | 923 | h, minheight);
|
906 |
| - *maxh = h - minheight; |
| 924 | + *maxh = h - widget_decor_height(htext, 0, bs->nbuttons > 0); |
907 | 925 |
|
908 | 926 | minwidth = widget_min_width(conf, wtext, 0, bs);
|
909 | 927 | if (w < minwidth)
|
910 | 928 | RETURN_FMTERROR("Current cols: %d, needed at least %d",
|
911 | 929 | w, minwidth);
|
912 |
| - *maxw = w - minwidth; |
| 930 | + *maxw = w - widget_decor_width(); |
913 | 931 |
|
914 | 932 | return (0);
|
915 | 933 | }
|
|
0 commit comments