📄 rebar.c
字号:
}
else {
if (adjcy && (y+mcy > adjcy)) {
mcy = adjcy - y;
TRACE("P1 row %u limiting mcy=%d, adjcy=%d, y=%d\n",
i, mcy, adjcy, y);
}
}
}
TRACE("P1 band %u, row %d, x=%d, y=%d, cxsep=%d, cx=%d\n",
i, row,
x, y, cxsep, cx);
if (infoPtr->dwStyle & CCS_VERT) {
/* bound the bottom side if we have a bounding rectangle */
rightx = clientcx;
bottomy = (lpRect) ? min(clientcy, y+cxsep+cx) : y+cxsep+cx;
lpBand->rcBand.left = x;
lpBand->rcBand.right = x + min(mcy,
lpBand->lcy+REBARSPACE(lpBand));
lpBand->rcBand.top = min(bottomy, y + cxsep);
lpBand->rcBand.bottom = bottomy;
lpBand->uMinHeight = lpBand->lcy;
y = bottomy;
}
else {
/* bound the right side if we have a bounding rectangle */
rightx = (lpRect) ? min(clientcx, x+cxsep+cx) : x+cxsep+cx;
bottomy = clientcy;
lpBand->rcBand.left = min(rightx, x + cxsep);
lpBand->rcBand.right = rightx;
lpBand->rcBand.top = y;
lpBand->rcBand.bottom = y + min(mcy,
lpBand->lcy+REBARSPACE(lpBand));
lpBand->uMinHeight = lpBand->lcy;
x = rightx;
}
TRACE("P1 band %u, row %d, (%d,%d)-(%d,%d)\n",
i, row,
lpBand->rcBand.left, lpBand->rcBand.top,
lpBand->rcBand.right, lpBand->rcBand.bottom);
prevBand = lpBand;
cntonrow++;
} /* for (i = 0; i < infoPtr->uNumBands... */
if (infoPtr->dwStyle & CCS_VERT)
x += mcy;
else
y += mcy;
for (j = rowstart; j < infoPtr->uNumBands; j++) {
lpBand = &infoPtr->bands[j];
if (infoPtr->dwStyle & CCS_VERT) {
lpBand->rcBand.right = lpBand->rcBand.left + mcy;
}
else {
lpBand->rcBand.bottom = lpBand->rcBand.top + mcy;
}
}
if (infoPtr->uNumBands)
infoPtr->uNumRows = row + 1;
/* ******* End Phase 1 - all bands on row at minimum size ******* */
/* ******* Start Phase 1a - Adjust heights for RBS_VARHEIGHT off ******* */
mmcy = 0;
if (!(infoPtr->dwStyle & RBS_VARHEIGHT)) {
INT xy;
/* get the max height of all bands */
for (i=0; i<infoPtr->uNumBands; i++) {
lpBand = &infoPtr->bands[i];
if (HIDDENBAND(lpBand)) continue;
if (infoPtr->dwStyle & CCS_VERT)
mmcy = max(mmcy, lpBand->rcBand.right - lpBand->rcBand.left);
else
mmcy = max(mmcy, lpBand->rcBand.bottom - lpBand->rcBand.top);
}
/* now adjust all rectangles by using the height found above */
xy = 0;
row = 0;
for (i=0; i<infoPtr->uNumBands; i++) {
lpBand = &infoPtr->bands[i];
if (HIDDENBAND(lpBand)) continue;
if (lpBand->iRow != row)
xy += (mmcy + SEP_WIDTH);
if (infoPtr->dwStyle & CCS_VERT) {
lpBand->rcBand.left = xy;
lpBand->rcBand.right = xy + mmcy;
}
else {
lpBand->rcBand.top = xy;
lpBand->rcBand.bottom = xy + mmcy;
}
}
/* set the x/y values to the correct maximum */
if (infoPtr->dwStyle & CCS_VERT)
x = xy + mmcy;
else
y = xy + mmcy;
}
/* ******* End Phase 1a - Adjust heights for RBS_VARHEIGHT off ******* */
/* ******* Start Phase 2 - split rows till adjustment height full ******* */
/* assumes that the following variables contain: */
/* y/x current height/width of all rows */
/* adjcy/adjcx adjustment height/width or 0 (as small as possible) */
if (lpRect && ((infoPtr->dwStyle & CCS_VERT) ? adjcx : adjcy)) {
INT i, prev_rh, new_rh, adj_rh, prev_idx, current_idx;
REBAR_BAND *prev, *current, *walk;
UINT j;
/* FIXME: problem # 2 */
if (((infoPtr->dwStyle & CCS_VERT) ?
#if PROBLEM2
(x < adjcx) : (y < adjcy)
#else
(adjcx - x > 5) : (adjcy - y > 4)
#endif
) &&
(infoPtr->uNumBands > 1)) {
for (i=(INT)infoPtr->uNumBands-2; i>=0; i--) {
TRACE("P2 adjcx=%d, adjcy=%d, x=%d, y=%d\n",
adjcx, adjcy, x, y);
/* find the current band (starts at i+1) */
current = &infoPtr->bands[i+1];
current_idx = i+1;
while (HIDDENBAND(current)) {
i--;
if (i < 0) break; /* out of bands */
current = &infoPtr->bands[i+1];
current_idx = i+1;
}
if (i < 0) break; /* out of bands */
/* now find the prev band (starts at i) */
prev = &infoPtr->bands[i];
prev_idx = i;
while (HIDDENBAND(prev)) {
i--;
if (i < 0) break; /* out of bands */
prev = &infoPtr->bands[i];
prev_idx = i;
}
if (i < 0) break; /* out of bands */
prev_rh = ircBw(prev);
if (prev->iRow == current->iRow) {
new_rh = (infoPtr->dwStyle & RBS_VARHEIGHT) ?
current->lcy + REBARSPACE(current) :
mmcy;
adj_rh = new_rh + SEP_WIDTH;
infoPtr->uNumRows++;
current->fDraw |= NTF_INVALIDATE;
current->iRow++;
if (infoPtr->dwStyle & CCS_VERT) {
current->rcBand.top = inity;
current->rcBand.bottom = clientcy;
current->rcBand.left += (prev_rh + SEP_WIDTH);
current->rcBand.right = current->rcBand.left + new_rh;
x += adj_rh;
}
else {
current->rcBand.left = initx;
current->rcBand.right = clientcx;
current->rcBand.top += (prev_rh + SEP_WIDTH);
current->rcBand.bottom = current->rcBand.top + new_rh;
y += adj_rh;
}
TRACE("P2 moving band %d to own row at (%d,%d)-(%d,%d)\n",
current_idx,
current->rcBand.left, current->rcBand.top,
current->rcBand.right, current->rcBand.bottom);
TRACE("P2 prev band %d at (%d,%d)-(%d,%d)\n",
prev_idx,
prev->rcBand.left, prev->rcBand.top,
prev->rcBand.right, prev->rcBand.bottom);
TRACE("P2 values: prev_rh=%d, new_rh=%d, adj_rh=%d\n",
prev_rh, new_rh, adj_rh);
/* for bands below current adjust row # and top/bottom */
for (j = current_idx+1; j<infoPtr->uNumBands; j++) {
walk = &infoPtr->bands[j];
if (HIDDENBAND(walk)) continue;
walk->fDraw |= NTF_INVALIDATE;
walk->iRow++;
if (infoPtr->dwStyle & CCS_VERT) {
walk->rcBand.left += adj_rh;
walk->rcBand.right += adj_rh;
}
else {
walk->rcBand.top += adj_rh;
walk->rcBand.bottom += adj_rh;
}
}
if ((infoPtr->dwStyle & CCS_VERT) ? (x >= adjcx) : (y >= adjcy))
break; /* all done */
}
}
}
}
/* ******* End Phase 2 - split rows till adjustment height full ******* */
/* ******* Start Phase 2a - mark first and last band in each ******* */
prevBand = NULL;
for (i = 0; i < infoPtr->uNumBands; i++) {
lpBand = &infoPtr->bands[i];
if (HIDDENBAND(lpBand))
continue;
if( !prevBand ) {
lpBand->fDraw |= DRAW_FIRST_IN_ROW;
prevBand = lpBand;
}
else if( prevBand->iRow == lpBand->iRow )
prevBand = lpBand;
else {
prevBand->fDraw |= DRAW_LAST_IN_ROW;
lpBand->fDraw |= DRAW_FIRST_IN_ROW;
prevBand = lpBand;
}
}
if( prevBand )
prevBand->fDraw |= DRAW_LAST_IN_ROW;
/* ******* End Phase 2a - mark first and last band in each ******* */
/* ******* Start Phase 2b - adjust all bands for height full ******* */
/* assumes that the following variables contain: */
/* y/x current height/width of all rows */
/* clientcy/clientcx height/width of client area */
if (((infoPtr->dwStyle & CCS_VERT) ? clientcx > x : clientcy > y) &&
infoPtr->uNumBands) {
INT diff, i;
UINT j;
diff = (infoPtr->dwStyle & CCS_VERT) ? clientcx - x : clientcy - y;
/* iterate backwards thru the rows */
for (i = infoPtr->uNumBands-1; i>=0; i--) {
lpBand = &infoPtr->bands[i];
if(HIDDENBAND(lpBand)) continue;
/* if row has more than 1 band, ignore it */
if( !(lpBand->fDraw&DRAW_FIRST_IN_ROW) )
continue;
if( !(lpBand->fDraw&DRAW_LAST_IN_ROW) )
continue;
/* FIXME: this next line is wrong, but fixing it to be inverted causes IE's sidebars to be the wrong size */
if (lpBand->fMask & RBBS_VARIABLEHEIGHT) continue;
if (((INT)lpBand->cyMaxChild < 1) ||
((INT)lpBand->cyIntegral < 1)) {
if (lpBand->cyMaxChild + lpBand->cyIntegral == 0) continue;
ERR("P2b band %u RBBS_VARIABLEHEIGHT set but cyMax=%d, cyInt=%d\n",
i, lpBand->cyMaxChild, lpBand->cyIntegral);
continue;
}
/* j is now the maximum height/width in the client area */
j = ((diff / lpBand->cyIntegral) * lpBand->cyIntegral) +
ircBw(lpBand);
if (j > lpBand->cyMaxChild + REBARSPACE(lpBand))
j = lpBand->cyMaxChild + REBARSPACE(lpBand);
diff -= (j - ircBw(lpBand));
if (infoPtr->dwStyle & CCS_VERT)
lpBand->rcBand.right = lpBand->rcBand.left + j;
else
lpBand->rcBand.bottom = lpBand->rcBand.top + j;
TRACE("P2b band %d, row %d changed to (%d,%d)-(%d,%d)\n",
i, lpBand->iRow,
lpBand->rcBand.left, lpBand->rcBand.top,
lpBand->rcBand.right, lpBand->rcBand.bottom);
if (diff <= 0) break;
}
if (diff < 0) {
ERR("P2b allocated more than available, diff=%d\n", diff);
diff = 0;
}
if (infoPtr->dwStyle & CCS_VERT)
x = clientcx - diff;
else
y = clientcy - diff;
}
/* ******* End Phase 2b - adjust all bands for height full ******* */
/* ******* Start Phase 3 - adjust all bands for width full ******* */
if (infoPtr->uNumBands) {
int startband;
/* If RBS_BANDBORDERS set then indicate to draw bottom separator */
/* on all bands in all rows but last row. */
/* Also indicate to draw the right separator for each band in */
/* each row but the rightmost band. */
if (infoPtr->dwStyle & RBS_BANDBORDERS) {
for (i=0; i<infoPtr->uNumBands; i++) {
lpBand = &infoPtr->bands[i];
if (HIDDENBAND(lpBand))
continue;
/* not righthand bands */
if( !(lpBand->fDraw & DRAW_LAST_IN_ROW) )
lpBand->fDraw |= DRAW_RIGHTSEP;
/* not the last row */
if( lpBand->iRow != infoPtr->uNumRows )
lpBand->fDraw |= DRAW_BOTTOMSEP;
}
}
/* Distribute the extra space on the horizontal and adjust */
/* all bands in row to same height. */
mcy = 0;
startband = -1;
for (i=0; i<infoPtr->uNumBands; i++) {
lpBand = &infoPtr->bands[i];
if( lpBand->fDraw & DRAW_FIRST_IN_ROW )
{
startband = i;
mcy = 0;
}
if ( (mcy < ircBw(lpBand)) && !HIDDENBAND(lpBand) )
mcy = ircBw(lpBand);
if( lpBand->fDraw & DRAW_LAST_IN_ROW )
{
TRACE("P3 processing row %d, starting band %d, ending band %d\n",
lpBand->iRow, startband, i);
if( startband < 0 )
ERR("Last band %d with no first, row %d\n", i, lpBand->iRow);
REBAR_AdjustBands (infoPtr, startband, i,
(infoPtr->dwStyle & CCS_VERT) ?
clientcy : clientcx, mcy);
}
}
/* Calculate the other rectangles in each band */
if (infoPtr->dwStyle & CCS_VERT) {
REBAR_CalcVertBand (infoPtr, 0, infoPtr->uNumBands,
notify);
}
else {
REBAR_CalcHorzBand (infoPtr, 0, infoPtr->uNumBands,
notify);
}
}
/* ******* End Phase 3 - adjust all bands for width full ******* */
/* now compute size of Rebar itself */
infoPtr->oldSize = infoPtr->calcSize;
if (infoPtr->uNumBands == 0) {
/* we have no bands, so make size the size of client */
x = clientcx;
y = clientcy;
}
if (infoPtr->dwStyle & CCS_VERT) {
if( infoPtr->uNumBands != 0 && x < REBAR_MINSIZE )
x = REBAR_MINSIZE;
infoPtr->calcSize.cx = x;
infoPtr->calcSize.cy = clientc
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -