📄 render_frames.cpp
字号:
for(int r = 0; r < element()->totalRows(); r++)
{
for(int c = 0; c < element()->totalCols(); c++)
{
bool fixed = false;
if ( child->isFrameSet() )
fixed = static_cast<RenderFrameSet *>(child)->element()->noResize();
else
fixed = static_cast<RenderFrame *>(child)->element()->noResize();
if(fixed)
{
#ifdef DEBUG_LAYOUT
kdDebug( 6031 ) << "found fixed cell " << r << "/" << c << "!" << endl;
#endif
if( element()->totalCols() > 1)
{
if(c>0) m_vSplitVar[c-1] = false;
m_vSplitVar[c] = false;
}
if( element()->totalRows() > 1)
{
if(r>0) m_hSplitVar[r-1] = false;
m_hSplitVar[r] = false;
}
child = child->nextSibling();
if(!child) goto end2;
}
#ifdef DEBUG_LAYOUT
else
kdDebug( 6031 ) << "not fixed: " << r << "/" << c << "!" << endl;
#endif
}
}
}
RenderContainer::layout();
end2:
setNeedsLayout(false);
}
void RenderFrameSet::positionFrames()
{
int r;
int c;
RenderObject *child = firstChild();
if ( !child )
return;
// NodeImpl *child = _first;
// if(!child) return;
int yPos = 0;
#if NOKIA_CHANGES
// calculate frameset height based on actual content height to eliminate scrolling
bool out = false;
int widest = 0;
for(r = 0; r < element()->totalRows() && !out; r++)
{
int highest = 0;
int xPos = 0;
for(c = 0; c < element()->totalCols(); c++)
{
if ( !child ) {
out = true;
break;
}
child->setPos( xPos, yPos );
#ifdef DEBUG_LAYOUT
kdDebug(6040) << "child frame at (" << xPos << "/" << yPos << ") size (" << m_gridLayout[1][c] << "/" << m_gridLayout[0][r] << ")" << endl;
#endif
// has to be resized and itself resize its contents
child->setWidth( m_gridLayout[1][c] );
child->setHeight( m_gridLayout[0][r] );
child->setNeedsLayout(true);
child->layout();
if (highest<child->height())
highest = child->height();
xPos += child->width() + element()->border();
child = child->nextSibling();
}
if (xPos>widest)
widest = xPos;
yPos += highest + element()->border();
}
m_height = yPos - element()->border();
m_width = QMAX(m_width,widest - element()->border());
// ensure the rows and columns are filled
out = false;
child = firstChild();
for(r = 0; r < element()->totalRows() && !out; r++)
{
int highest = 0;
int xPos = 0;
for(c = 0; c < element()->totalCols(); c++)
{
if ( !child ) {
out = true;
break;
}
if (r == element()->totalRows()-1)
child->setHeight( m_height - child->yPos());
if (c == element()->totalCols()-1)
child->setWidth( m_width - child->xPos());
child = child->nextSibling();
}
}
// kdDebug(6040) << "pf m_height=" << m_height << endl;
#else // NOKIA_CHANGES
for(r = 0; r < element()->totalRows(); r++)
{
int xPos = 0;
for(c = 0; c < element()->totalCols(); c++)
{
child->setPos( xPos, yPos );
#ifdef DEBUG_LAYOUT
kdDebug(6040) << "child frame at (" << xPos << "/" << yPos << ") size (" << m_gridLayout[1][c] << "/" << m_gridLayout[0][r] << ")" << endl;
#endif
// has to be resized and itself resize its contents
if ((m_gridLayout[1][c] != child->width()) || (m_gridLayout[0][r] != child->height())) {
child->setWidth( m_gridLayout[1][c] );
child->setHeight( m_gridLayout[0][r] );
child->setNeedsLayout(true);
child->layout();
}
xPos += m_gridLayout[1][c] + element()->border();
child = child->nextSibling();
if ( !child )
return;
}
yPos += m_gridLayout[0][r] + element()->border();
}
#endif // NOKIA_CHANGES
// all the remaining frames are hidden to avoid ugly
// spurious unflowed frames
while ( child ) {
child->setWidth( 0 );
child->setHeight( 0 );
child->setNeedsLayout(false);
child = child->nextSibling();
}
}
bool RenderFrameSet::userResize( MouseEventImpl *evt )
{
if (needsLayout()) return false;
bool res = false;
int _x = evt->clientX();
int _y = evt->clientY();
if ( !m_resizing && evt->id() == EventImpl::MOUSEMOVE_EVENT || evt->id() == EventImpl::MOUSEDOWN_EVENT )
{
#ifdef DEBUG_LAYOUT
kdDebug( 6031 ) << "mouseEvent:check" << endl;
#endif
m_hSplit = -1;
m_vSplit = -1;
//bool resizePossible = true;
// check if we're over a horizontal or vertical boundary
int pos = m_gridLayout[1][0] + xPos();
for(int c = 1; c < element()->totalCols(); c++)
{
if(_x >= pos && _x <= pos+element()->border())
{
if(m_vSplitVar && m_vSplitVar[c-1] == true) m_vSplit = c-1;
#ifdef DEBUG_LAYOUT
kdDebug( 6031 ) << "vsplit!" << endl;
#endif
res = true;
break;
}
pos += m_gridLayout[1][c] + element()->border();
}
pos = m_gridLayout[0][0] + yPos();
for(int r = 1; r < element()->totalRows(); r++)
{
if( _y >= pos && _y <= pos+element()->border())
{
if(m_hSplitVar && m_hSplitVar[r-1] == true) m_hSplit = r-1;
#ifdef DEBUG_LAYOUT
kdDebug( 6031 ) << "hsplitvar = " << m_hSplitVar << endl;
kdDebug( 6031 ) << "hsplit!" << endl;
#endif
res = true;
break;
}
pos += m_gridLayout[0][r] + element()->border();
}
#ifdef DEBUG_LAYOUT
kdDebug( 6031 ) << m_hSplit << "/" << m_vSplit << endl;
#endif
QCursor cursor;
if(m_hSplit != -1 && m_vSplit != -1)
{
cursor = KCursor::sizeAllCursor();
}
else if( m_vSplit != -1 )
{
cursor = KCursor::sizeHorCursor();
}
else if( m_hSplit != -1 )
{
cursor = KCursor::sizeVerCursor();
}
if(evt->id() == EventImpl::MOUSEDOWN_EVENT)
{
setResizing(true);
KApplication::setOverrideCursor(cursor);
m_vSplitPos = _x;
m_hSplitPos = _y;
m_oldpos = -1;
}
else
canvas()->view()->viewport()->setCursor(cursor);
}
// ### check the resize is not going out of bounds.
if(m_resizing && evt->id() == EventImpl::MOUSEUP_EVENT)
{
setResizing(false);
KApplication::restoreOverrideCursor();
if(m_vSplit != -1 )
{
#ifdef DEBUG_LAYOUT
kdDebug( 6031 ) << "split xpos=" << _x << endl;
#endif
int delta = m_vSplitPos - _x;
m_gridDelta[1][m_vSplit] -= delta;
m_gridDelta[1][m_vSplit+1] += delta;
}
if(m_hSplit != -1 )
{
#ifdef DEBUG_LAYOUT
kdDebug( 6031 ) << "split ypos=" << _y << endl;
#endif
int delta = m_hSplitPos - _y;
m_gridDelta[0][m_hSplit] -= delta;
m_gridDelta[0][m_hSplit+1] += delta;
}
// this just schedules the relayout
// important, otherwise the moving indicator is not correctly erased
setNeedsLayout(true);
}
else if (m_resizing || evt->id() == EventImpl::MOUSEUP_EVENT) {
#if APPLE_CHANGES
KHTMLView *v = canvas()->view();
QPainter paint;
v->disableFlushDrawing();
v->lockDrawingFocus();
#else
QPainter paint( canvas()->view() );
#endif
paint.setPen( Qt::gray );
paint.setBrush( Qt::gray );
#if !APPLE_CHANGES
paint.setRasterOp( Qt::XorROP );
#endif
QRect r(xPos(), yPos(), width(), height());
const int rBord = 3;
int sw = element()->border();
int p = m_resizing ? (m_vSplit > -1 ? _x : _y) : -1;
if (m_vSplit > -1) {
if ( m_oldpos >= 0 )
#if APPLE_CHANGES
v->updateContents( m_oldpos + sw/2 - rBord , r.y(), 2*rBord, r.height(), true );
#else
paint.drawRect( m_oldpos + sw/2 - rBord , r.y(),
2*rBord, r.height() );
#endif
if ( p >= 0 ){
#if APPLE_CHANGES
paint.setPen( Qt::NoPen );
paint.setBrush( Qt::gray );
v->setDrawingAlpha((float)0.25);
paint.drawRect( p + sw/2 - rBord, r.y(), 2*rBord, r.height() );
v->setDrawingAlpha((float)1.0);
#else
paint.drawRect( p + sw/2 - rBord, r.y(), 2*rBord, r.height() );
#endif
}
} else {
if ( m_oldpos >= 0 )
#if APPLE_CHANGES
v->updateContents( r.x(), m_oldpos + sw/2 - rBord, r.width(), 2*rBord, true );
#else
paint.drawRect( r.x(), m_oldpos + sw/2 - rBord,
r.width(), 2*rBord );
#endif
if ( p >= 0 ){
#if APPLE_CHANGES
paint.setPen( Qt::NoPen );
paint.setBrush( Qt::gray );
v->setDrawingAlpha((float)0.25);
paint.drawRect( r.x(), p + sw/2 - rBord, r.width(), 2*rBord );
v->setDrawingAlpha((float)1.0);
#else
paint.drawRect( r.x(), p + sw/2 - rBord, r.width(), 2*rBord );
#endif
}
}
m_oldpos = p;
#if APPLE_CHANGES
v->unlockDrawingFocus();
v->enableFlushDrawing();
#endif
}
return res;
}
void RenderFrameSet::setResizing(bool e)
{
m_resizing = e;
for (RenderObject* p = parent(); p; p = p->parent())
if (p->isFrameSet()) static_cast<RenderFrameSet*>(p)->m_clientresizing = m_resizing;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -