comparison win/dw.c @ 456:935436731b41

Hybrid fix, seems the last change illiminated some important code that dealt with varying padding sizes in the opposite direction of the box. This readds that code but optimizes it and includes the groupbox calculations that were already present in the previous code path. This fix will be added to the OS/2 tree as well pending testing of this new code path.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Wed, 25 Jun 2003 03:39:44 +0000
parents dd04a4d781f8
children 12ba7e744560
comparison
equal deleted inserted replaced
455:dd04a4d781f8 456:935436731b41
842 int uymax = 0, uxmax = 0; 842 int uymax = 0, uxmax = 0;
843 int upymax = 0, upxmax = 0; 843 int upymax = 0, upxmax = 0;
844 /* Used for the SIZEEXPAND */ 844 /* Used for the SIZEEXPAND */
845 int nux = *usedx, nuy = *usedy; 845 int nux = *usedx, nuy = *usedy;
846 int nupx = *usedpadx, nupy = *usedpady; 846 int nupx = *usedpadx, nupy = *usedpady;
847 int textheight = 0;
848 847
849 (*usedx) += (thisbox->pad * 2); 848 (*usedx) += (thisbox->pad * 2);
850 (*usedy) += (thisbox->pad * 2); 849 (*usedy) += (thisbox->pad * 2);
851 850
852 if(thisbox->grouphwnd) 851 if(thisbox->grouphwnd)
853 { 852 {
854 char *text = dw_window_get_text(thisbox->grouphwnd); 853 char *text = dw_window_get_text(thisbox->grouphwnd);
855 854
855 thisbox->grouppady = 0;
856
856 if(text) 857 if(text)
857 { 858 {
858 dw_font_text_extents(thisbox->grouphwnd, 0, text, NULL, &textheight); 859 dw_font_text_extents(thisbox->grouphwnd, 0, text, NULL, &thisbox->grouppady);
859 dw_free(text); 860 dw_free(text);
860 } 861 }
861 862
862 (*usedx) += 6; 863 if(thisbox->grouppady)
863 (*usedpadx) += 6; 864 thisbox->grouppady += 3;
864 (*usedy) += textheight ? (3 + textheight) : 6; 865 else
865 (*usedpady) += textheight ? (3 + textheight) : 6; 866 thisbox->grouppady = 6;
867
868 thisbox->grouppadx = 6;
869
870 (*usedx) += thisbox->grouppadx;
871 (*usedpadx) += thisbox->grouppadx;
872 (*usedy) += thisbox->grouppady;
873 (*usedpady) += thisbox->grouppady;
866 } 874 }
867 875
868 for(z=0;z<thisbox->count;z++) 876 for(z=0;z<thisbox->count;z++)
869 { 877 {
870 if(thisbox->items[z].type == TYPEBOX) 878 if(thisbox->items[z].type == TYPEBOX)
906 914
907 /* Just in case */ 915 /* Just in case */
908 tmp->xratio = thisbox->xratio; 916 tmp->xratio = thisbox->xratio;
909 tmp->yratio = thisbox->yratio; 917 tmp->yratio = thisbox->yratio;
910 918
911 if((thisbox->items[z].width-tmp->upx)!=0) 919 if(thisbox->type == DW_VERT)
912 tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-tmp->upx))/((float)(thisbox->items[z].width-tmp->upx)); 920 {
913 if((thisbox->items[z].height-tmp->upy)!=0) 921 int tmppad = (thisbox->items[z].pad*2)+(tmp->pad*2)+tmp->grouppady;
914 tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-tmp->upy))/((float)(thisbox->items[z].height-tmp->upy)); 922
923 if((thisbox->items[z].width - tmppad)!=0)
924 tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-tmppad))/((float)(thisbox->items[z].width-tmppad));
925 }
926 else
927 {
928 if((thisbox->items[z].width-tmp->upx)!=0)
929 tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-tmp->upx))/((float)(thisbox->items[z].width-tmp->upx));
930 }
931 if(thisbox->type == DW_HORZ)
932 {
933 int tmppad = (thisbox->items[z].pad*2)+(tmp->pad*2)+tmp->grouppadx;
934
935 if((thisbox->items[z].height-tmppad)!=0)
936 tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-tmppad))/((float)(thisbox->items[z].height-tmppad));
937 }
938 else
939 {
940 if((thisbox->items[z].height-tmp->upy)!=0)
941 tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-tmp->upy))/((float)(thisbox->items[z].height-tmp->upy));
942 }
915 943
916 nux = *usedx; nuy = *usedy; 944 nux = *usedx; nuy = *usedy;
917 upx = *usedpadx + (tmp->pad*2); upy = *usedpady + (tmp->pad*2); 945 upx = *usedpadx + (tmp->pad*2); upy = *usedpady + (tmp->pad*2);
918 } 946 }
919 947
931 } 959 }
932 } 960 }
933 961
934 if(pass > 1 && *depth > 0) 962 if(pass > 1 && *depth > 0)
935 { 963 {
936 if(thisbox->minwidth-thisbox->upx == 0) 964 if(thisbox->type == DW_VERT)
937 thisbox->items[z].xratio = 1.0; 965 {
966 int tmppad = (thisbox->items[z].pad*2)+(thisbox->parentpad*2)+thisbox->grouppadx;
967
968 if((thisbox->minwidth-tmppad) == 0)
969 thisbox->items[z].xratio = 1.0;
970 else
971 thisbox->items[z].xratio = ((float)((thisbox->width * thisbox->parentxratio)-tmppad))/((float)(thisbox->minwidth-tmppad));
972 }
938 else 973 else
939 thisbox->items[z].xratio = ((float)((thisbox->width * thisbox->parentxratio)-thisbox->upx))/((float)(thisbox->minwidth-thisbox->upx)); 974 {
940 if(thisbox->minheight-thisbox->upy == 0) 975 if(thisbox->minwidth-thisbox->upx == 0)
941 thisbox->items[z].yratio = 1.0; 976 thisbox->items[z].xratio = 1.0;
977 else
978 thisbox->items[z].xratio = ((float)((thisbox->width * thisbox->parentxratio)-thisbox->upx))/((float)(thisbox->minwidth-thisbox->upx));
979 }
980
981 if(thisbox->type == DW_HORZ)
982 {
983 int tmppad = (thisbox->items[z].pad*2)+(thisbox->parentpad*2)+thisbox->grouppady;
984
985 if((thisbox->minheight-tmppad) == 0)
986 thisbox->items[z].yratio = 1.0;
987 else
988 thisbox->items[z].yratio = ((float)((thisbox->height * thisbox->parentyratio)-tmppad))/((float)(thisbox->minheight-tmppad));
989 }
942 else 990 else
943 thisbox->items[z].yratio = ((float)((thisbox->height * thisbox->parentyratio)-thisbox->upy))/((float)(thisbox->minheight-thisbox->upy)); 991 {
992 if(thisbox->minheight-thisbox->upy == 0)
993 thisbox->items[z].yratio = 1.0;
994 else
995 thisbox->items[z].yratio = ((float)((thisbox->height * thisbox->parentyratio)-thisbox->upy))/((float)(thisbox->minheight-thisbox->upy));
996 }
944 997
945 if(thisbox->items[z].type == TYPEBOX) 998 if(thisbox->items[z].type == TYPEBOX)
946 { 999 {
947 Box *tmp = (Box *)GetWindowLongPtr(thisbox->items[z].hwnd, GWLP_USERDATA); 1000 Box *tmp = (Box *)GetWindowLongPtr(thisbox->items[z].hwnd, GWLP_USERDATA);
948 1001
1036 currenty += thisbox->pad; 1089 currenty += thisbox->pad;
1037 1090
1038 if(thisbox->grouphwnd) 1091 if(thisbox->grouphwnd)
1039 { 1092 {
1040 currentx += 3; 1093 currentx += 3;
1041 currenty += textheight ? textheight : 3; 1094 currenty += thisbox->grouppady - 3;
1042 } 1095 }
1043 1096
1044 /* The second pass is for expansion and actual placement. */ 1097 /* The second pass is for expansion and actual placement. */
1045 if(pass > 1) 1098 if(pass > 1)
1046 { 1099 {