882 , QDrawBorderPixmap::DrawingHints hints
894 const int sourceCenterTop = sourceRect.
top() + sourceMargins.top();
895 const int sourceCenterLeft = sourceRect.
left() + sourceMargins.left();
896 const int sourceCenterBottom = sourceRect.
bottom() - sourceMargins.bottom() + 1;
897 const int sourceCenterRight = sourceRect.
right() - sourceMargins.right() + 1;
898 const int sourceCenterWidth = sourceCenterRight - sourceCenterLeft;
899 const int sourceCenterHeight = sourceCenterBottom - sourceCenterTop;
901 const int targetCenterTop = targetRect.top() + targetMargins.top();
902 const int targetCenterLeft = targetRect.left() + targetMargins.left();
903 const int targetCenterBottom = targetRect.bottom() - targetMargins.bottom() + 1;
904 const int targetCenterRight = targetRect.right() - targetMargins.right() + 1;
905 const int targetCenterWidth = targetCenterRight - targetCenterLeft;
906 const int targetCenterHeight = targetCenterBottom - targetCenterTop;
908 QVarLengthArray<qreal, 16> xTarget;
909 QVarLengthArray<qreal, 16> yTarget;
914 columns =
qMax(3, 2 +
qCeil(targetCenterWidth /
qreal(sourceCenterWidth)));
916 rows =
qMax(3, 2 +
qCeil(targetCenterHeight /
qreal(sourceCenterHeight)));
918 xTarget.resize(columns + 1);
919 yTarget.resize(rows + 1);
928 xTarget[0] = targetRect.left();
929 xTarget[1] = targetCenterLeft;
930 xTarget[columns - 1] = targetCenterRight;
931 xTarget[columns] = targetRect.left() + targetRect.width();
933 yTarget[0] = targetRect.top();
934 yTarget[1] = targetCenterTop;
935 yTarget[rows - 1] = targetCenterBottom;
936 yTarget[rows] = targetRect.top() + targetRect.height();
938 qreal dx = targetCenterWidth;
939 qreal dy = targetCenterHeight;
941 switch (rules.horizontal) {
943 dx = targetCenterWidth;
946 dx = sourceCenterWidth;
949 dx = targetCenterWidth /
qreal(columns - 2);
953 for (
int i = 2;
i < columns - 1; ++
i)
954 xTarget[
i] = xTarget[
i - 1] + dx;
956 switch (rules.vertical) {
958 dy = targetCenterHeight;
961 dy = sourceCenterHeight;
964 dy = targetCenterHeight /
qreal(rows - 2);
968 for (
int i = 2;
i < rows - 1; ++
i)
969 yTarget[
i] = yTarget[
i - 1] + dy;
972 if (targetMargins.top() > 0 && targetMargins.left() > 0 && sourceMargins.top() > 0 && sourceMargins.left() > 0) {
973 d.x = (0.5 * (xTarget[1] + xTarget[0]));
974 d.y = (0.5 * (yTarget[1] + yTarget[0]));
975 d.sourceLeft = sourceRect.
left();
976 d.sourceTop = sourceRect.
top();
977 d.width = sourceMargins.left();
978 d.height = sourceMargins.top();
979 d.scaleX =
qreal(xTarget[1] - xTarget[0]) /
d.width;
980 d.scaleY =
qreal(yTarget[1] - yTarget[0]) /
d.height;
982 opaqueData.append(
d);
984 translucentData.append(
d);
986 if (targetMargins.top() > 0 && targetMargins.right() > 0 && sourceMargins.top() > 0 && sourceMargins.right() > 0) {
987 d.x = (0.5 * (xTarget[columns] + xTarget[columns - 1]));
988 d.y = (0.5 * (yTarget[1] + yTarget[0]));
989 d.sourceLeft = sourceCenterRight;
990 d.sourceTop = sourceRect.
top();
991 d.width = sourceMargins.right();
992 d.height = sourceMargins.top();
993 d.scaleX =
qreal(xTarget[columns] - xTarget[columns - 1]) /
d.width;
994 d.scaleY =
qreal(yTarget[1] - yTarget[0]) /
d.height;
996 opaqueData.append(
d);
998 translucentData.append(
d);
1000 if (targetMargins.bottom() > 0 && targetMargins.left() > 0 && sourceMargins.bottom() > 0 && sourceMargins.left() > 0) {
1001 d.x = (0.5 * (xTarget[1] + xTarget[0]));
1002 d.y =(0.5 * (yTarget[rows] + yTarget[rows - 1]));
1003 d.sourceLeft = sourceRect.
left();
1004 d.sourceTop = sourceCenterBottom;
1005 d.width = sourceMargins.left();
1006 d.height = sourceMargins.bottom();
1007 d.scaleX =
qreal(xTarget[1] - xTarget[0]) /
d.width;
1008 d.scaleY =
qreal(yTarget[rows] - yTarget[rows - 1]) /
d.height;
1010 opaqueData.append(
d);
1012 translucentData.append(
d);
1014 if (targetMargins.bottom() > 0 && targetMargins.right() > 0 && sourceMargins.bottom() > 0 && sourceMargins.right() > 0) {
1015 d.x = (0.5 * (xTarget[columns] + xTarget[columns - 1]));
1016 d.y = (0.5 * (yTarget[rows] + yTarget[rows - 1]));
1017 d.sourceLeft = sourceCenterRight;
1018 d.sourceTop = sourceCenterBottom;
1019 d.width = sourceMargins.right();
1020 d.height = sourceMargins.bottom();
1021 d.scaleX =
qreal(xTarget[columns] - xTarget[columns - 1]) /
d.width;
1022 d.scaleY =
qreal(yTarget[rows] - yTarget[rows - 1]) /
d.height;
1024 opaqueData.append(
d);
1026 translucentData.append(
d);
1030 if (targetCenterWidth > 0 && sourceCenterWidth > 0) {
1031 if (targetMargins.top() > 0 && sourceMargins.top() > 0) {
1033 d.sourceLeft = sourceCenterLeft;
1034 d.sourceTop = sourceRect.
top();
1035 d.width = sourceCenterWidth;
1036 d.height = sourceMargins.top();
1037 d.y = (0.5 * (yTarget[1] + yTarget[0]));
1038 d.scaleX = dx /
d.width;
1039 d.scaleY =
qreal(yTarget[1] - yTarget[0]) /
d.height;
1040 for (
int i = 1;
i < columns - 1; ++
i) {
1041 d.x = (0.5 * (xTarget[
i + 1] + xTarget[
i]));
1045 data[
data.size() - 1].width = ((xTarget[columns - 1] - xTarget[columns - 2]) /
d.scaleX);
1047 if (targetMargins.bottom() > 0 && sourceMargins.bottom() > 0) {
1049 d.sourceLeft = sourceCenterLeft;
1050 d.sourceTop = sourceCenterBottom;
1051 d.width = sourceCenterWidth;
1052 d.height = sourceMargins.bottom();
1053 d.y = (0.5 * (yTarget[rows] + yTarget[rows - 1]));
1054 d.scaleX = dx /
d.width;
1055 d.scaleY =
qreal(yTarget[rows] - yTarget[rows - 1]) /
d.height;
1056 for (
int i = 1;
i < columns - 1; ++
i) {
1057 d.x = (0.5 * (xTarget[
i + 1] + xTarget[
i]));
1061 data[
data.size() - 1].width = ((xTarget[columns - 1] - xTarget[columns - 2]) /
d.scaleX);
1066 if (targetCenterHeight > 0 && sourceCenterHeight > 0) {
1067 if (targetMargins.left() > 0 && sourceMargins.left() > 0) {
1069 d.sourceLeft = sourceRect.
left();
1070 d.sourceTop = sourceCenterTop;
1071 d.width = sourceMargins.left();
1072 d.height = sourceCenterHeight;
1073 d.x = (0.5 * (xTarget[1] + xTarget[0]));
1074 d.scaleX =
qreal(xTarget[1] - xTarget[0]) /
d.width;
1075 d.scaleY = dy /
d.height;
1076 for (
int i = 1;
i < rows - 1; ++
i) {
1077 d.y = (0.5 * (yTarget[
i + 1] + yTarget[
i]));
1081 data[
data.size() - 1].height = ((yTarget[rows - 1] - yTarget[rows - 2]) /
d.scaleY);
1083 if (targetMargins.right() > 0 && sourceMargins.right() > 0) {
1085 d.sourceLeft = sourceCenterRight;
1086 d.sourceTop = sourceCenterTop;
1087 d.width = sourceMargins.right();
1088 d.height = sourceCenterHeight;
1089 d.x = (0.5 * (xTarget[columns] + xTarget[columns - 1]));
1090 d.scaleX =
qreal(xTarget[columns] - xTarget[columns - 1]) /
d.width;
1091 d.scaleY = dy /
d.height;
1092 for (
int i = 1;
i < rows - 1; ++
i) {
1093 d.y = (0.5 * (yTarget[
i + 1] + yTarget[
i]));
1097 data[
data.size() - 1].height = ((yTarget[rows - 1] - yTarget[rows - 2]) /
d.scaleY);
1102 if (targetCenterWidth > 0 && targetCenterHeight > 0 && sourceCenterWidth > 0 && sourceCenterHeight > 0) {
1104 d.sourceLeft = sourceCenterLeft;
1105 d.sourceTop = sourceCenterTop;
1106 d.width = sourceCenterWidth;
1107 d.height = sourceCenterHeight;
1108 d.scaleX = dx /
d.width;
1109 d.scaleY = dy /
d.height;
1111 qreal repeatWidth = (xTarget[columns - 1] - xTarget[columns - 2]) /
d.scaleX;
1112 qreal repeatHeight = (yTarget[rows - 1] - yTarget[rows - 2]) /
d.scaleY;
1114 for (
int j = 1;
j < rows - 1; ++
j) {
1115 d.y = (0.5 * (yTarget[
j + 1] + yTarget[
j]));
1116 for (
int i = 1;
i < columns - 1; ++
i) {
1117 d.x = (0.5 * (xTarget[
i + 1] + xTarget[
i]));
1121 data[
data.size() - 1].width = repeatWidth;
1124 for (
int i = 1;
i < columns - 1; ++
i)
1125 data[
data.size() -
i].height = repeatHeight;
1129 if (opaqueData.size())
1131 if (translucentData.size())